Please Help, drawcharacter not working as it should.

Discussion in 'Learning Javascript' started by ougitou1, May 7, 2018.

Thread Status:
Not open for further replies.
  1. ougitou1

    ougitou1 Invisible Black Veteran

    Messages:
    101
    Likes Received:
    9
    First Language:
    en-
    Primarily Uses:
    N/A
    Ok ive been stuck for a while now and ive just now thought of a solution. Naturaly since my code doesnt work as intended the problem must be on my side hence why im here. I need your collective help to recreate a small section of the code.

    It should be simple enough. A window with 3 selectable panels much like on the default save file screen however in a horizontal manner, and now for the important part; in any one of those panels 'draw' a character. (using drawCharacter from window base i presume.)

    Simple right?

    Anyway, by comparing i'll be able to see if and where there are errors in my script.
    thanks you for your help and patience.
    --------------------------------------------------------------------------------------------
    ok the thing is, drawcharacter doesn't seem to work, but if i go back a scene then return it works, but never on the first time.

    attached is my code its terrible and probably unreadable tho, sorry....

    Code:
    
    //-----------------------------------------------------------------------------
    // Window_SavefileList
    //
    // The window for selecting a save file on the save and load screens.
    
    function Window_SavefileList() {
        this.initialize.apply(this, arguments);
    }
    
    Window_SavefileList.prototype = Object.create(Window_Selectable.prototype);
    Window_SavefileList.prototype.constructor = Window_SavefileList;
    
    Window_SavefileList.prototype.initialize = function(x, y, width, height) {
        Window_Selectable.prototype.initialize.call(this, x, y, width, height);
        this.activate();
        this.y += 75;
        this.width = Graphics.boxWidth - 70;
        this.height = Graphics.boxHeight / 4 + 190;
        this._mode = null;
    
        this.setBackgroundType(2);
    };
    
    Window_SavefileList.prototype.setMode = function(mode) {
        this._mode = mode;
    };
    
    Window_SavefileList.prototype.maxCols = function() {
        return 3;
    };
    
    Window_SavefileList.prototype.maxItems = function() {
        return 3; //DataManager.maxSavefiles();
    };
    
    Window_SavefileList.prototype.maxVisibleItems = function() {
        return 3; //_max_save_slots; //5;
    };
    
    Window_SavefileList.prototype.itemHeight = function() {
        var innerHeight = this.height - this.padding * 2;
        return Graphics.boxHeight / 4 + 150;//Math.floor(innerHeight / this.maxVisibleItems());
    };
    
    
    Window_SavefileList.prototype.drawItem = function(index) {
        var id = index + 1;
        var valid = DataManager.isThisGameFile(id);
        var info = DataManager.loadSavefileInfo(id);
        locationname[id] = DataManager.loadSavefileInfo(id).location;
        var rect = this.itemRectForText(index);
        this.resetTextColor();
        if (this._mode === 'load') {
            this.changePaintOpacity(valid);
        }
        this.drawFileId(id, rect.x, rect.y);
        if (info) {
            //console.log("checked out fine!");
            this.changePaintOpacity(valid);
            this.drawContents(info, rect, valid);
            this.changePaintOpacity(true);
        }
    };
    
    Window_SavefileList.prototype.update = function()
    {
    Window_Selectable.prototype.update.call(this);
    //----------------------
    this._touching = false;
    var ind1 = this.index();
    var is1_enabled = false;
    var is2_enabled = false;
    var is3_enabled = false;
    var curr;
    var checked_;
    catch_ind = ind1;
    
    /*
    if (ind1 == 0)
    {
    is1_enabled = true;
    is2_enabled = false;
    is3_enabled = false;
    };
    
    if (ind1 == 1)
    {
    is1_enabled = false;
    is2_enabled = true;
    is3_enabled = false;
    };
    
    if (ind1 == 2)
    {
    is1_enabled = false;
    is2_enabled = false;
    is3_enabled = true;
    };
    
    if(is1_enabled == true)
    {
    curr = 1;
    } else if (is2_enabled == true)
    {
    curr = 2;
    } else if (is3_enabled == true)
    {
    curr = 3;
    }*/
    
    if(Input.isTriggered('right') || Input.isTriggered('left') || Input.isTriggered('up') || Input.isTriggered('down'))
    {
    console.log(locationname[catch_ind + 1]);
    
    }
    
    
    
    //-----------------------
    };
    
    Window_SavefileList.prototype.drawFileId = function(id, x, y) {
        //this.drawText(TextManager.file + ' ' + id, x, y, 180);
    };
    
    Window_SavefileList.prototype.drawContents = function(info, rect, valid) {
        var bottom = rect.y + rect.height;
        if (rect.width >= 20) {
            //this.drawGameTitle(info,  ++ rect.x, rect.y, rect.width/2  + rect.width/4);
            if (valid) {
                this.drawPartyCharacters(info, rect.x, rect.y + 20);
                //console.log("bottom = ", bottom, "info = ", info, "rect x = ", rect.x , "rect.y = ", rect.y, "rect.width = ", rect.width );
            }
    
        }
        var lineHeight = this.lineHeight();
        var y2 = bottom - lineHeight;
        if (y2 >= lineHeight) {
           // this.drawPlaytime(info, rect.x, y2, rect.width);
        }
    };
    
    Window_SavefileList.prototype.drawGameTitle = function(info, x, y, width) {
        if (info.title) {
            this.drawText(info.title, x, y, width);
        }
    };
    
    Window_SavefileList.prototype.drawPartyCharacters = function(info, x, y) {
        if (info.characters) {
    
            for (var i = 0; i < info.characters.length; i++) {
                console.log(info.characters[i]);
                var data = info.characters[i];
                this.drawCharacter("Actor1", 7, x + 10, y + 10); // + i * 48  problem is here!!!!! <<<<<+======= i think
                //sprite.anchor.x = 0.5;
                // sprite.anchor.y = 0.5;
            }
        }
    };
    
    Window_SavefileList.prototype.drawPlaytime = function(info, x, y, width) {
        if (info.playtime) {
            this.drawText(info.playtime, x, y, width, 'right');
        }
    };
    
    Window_SavefileList.prototype.playOkSound = function() {
    };
    
    
    Window_SavefileList.prototype._refreshCursor = function() {
        var pad = this._padding;
        var x = 0; //this._cursorRect.x + pad - this.origin.x;
        var y = 0; //this._cursorRect.y + pad - this.origin.y;
        var w = 0; //this._cursorRect.width;
        var h = 0; //this._cursorRect.height;
        var m = 0; //4;
        var x2 = 0; //Math.max(x + 25, pad);
        var y2 = 0; //Math.max(y - 7, pad);
        var ox = 0; //x - x2;
        var oy = 0; //y - y2;
        var w2 = 0; //Math.min(w, this._width - pad - x2);
        var h2 = 0; //Math.min(h, this._height - pad - y2);
        var bitmap = null; //ImageManager.loadTitle2("bar3");
    
        this._windowCursorSprite.bitmap = null;// bitmap;
        this._windowCursorSprite.move(x2, y2);
    
    };
    
     
    Last edited: May 7, 2018
    #1
  2. taarna23

    taarna23 Marshmallow Princess Global Mod

    Messages:
    2,349
    Likes Received:
    4,623
    Location:
    Saskatoon, SK, Canada
    First Language:
    English
    @ougitou1 The way you're wording this, it sounds more like a request. You're better off posting your code for others to review. Or at least the part you think is going wrong.
     
    #2
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    36,914
    Likes Received:
    10,851
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Could you please edit your post and change the title to state what it is you need help with? Everyone who posts a thread here "needs help" - it's nice to know, before going into the thread, what it's about, as people can save their time if they know they can't assist.
     
    #3
  4. ougitou1

    ougitou1 Invisible Black Veteran

    Messages:
    101
    Likes Received:
    9
    First Language:
    en-
    Primarily Uses:
    N/A
    Ah... ok ill edit the title @Shaz. I'm not really sure how to tho...
    @taarna23 The code is beta so its all jumbled and confusing, almost like a piece of the matrix. :kaoswt:
     
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    36,914
    Likes Received:
    10,851
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    If you edit your first post, then click Use Full Editor, it will let you change the title (and tags, should you ever need to do that).
     
    #5
  6. ougitou1

    ougitou1 Invisible Black Veteran

    Messages:
    101
    Likes Received:
    9
    First Language:
    en-
    Primarily Uses:
    N/A
    oh ok. thankx for the info.
     
    #6
  7. ougitou1

    ougitou1 Invisible Black Veteran

    Messages:
    101
    Likes Received:
    9
    First Language:
    en-
    Primarily Uses:
    N/A
    Good news, i have found a solution and it turns out that my way of implementing rows and columns in a window was wrong, not only was it wrong it was bad. ugh... so bad turns out i still have a lot to learn. Feel free to close. Toodles~
     
    Last edited: May 8, 2018
    #7
  8. Shaz

    Shaz Veteran Veteran

    Messages:
    36,914
    Likes Received:
    10,851
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    to have a thread closed, you need to report your first post and request it to be closed.
     
    #8
  9. slimmmeiske2

    slimmmeiske2 Little Red Riding Hood Moderator

    Messages:
    4,672
    Likes Received:
    3,791
    Location:
    Belgium
    First Language:
    Dutch
    Primarily Uses:
    RMXP

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #9
Thread Status:
Not open for further replies.

Share This Page