Javascript MV - Update Window on Selection

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
I'm trying to update a window I made when a player selects an item in equipment window.

Code:
    myMenuStatusWindow.prototype.refresh = function() {
        var x = this.textPadding();
        var width = this.contents.width - this.textPadding() * 2;
        this.contents.clear();
        if ($gameActors.actor(1).equips(1).contains($dataArmors[1]))
        {
            this.drawPicture('Maya', 0, 0);
        };
    };
I can't figure out how to do this...

I've tried to see how the help window on top works and updates the text inside and then apply the same thing to my window but for the life of me I can't work it out.

So basically I need to make my window work just like the help window but instead of changing the text it will change the picture I add.

You don't have permission to view the spoiler content. Log in or register now.
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
I haven't really done much javascript or coding for RPGMaker MV and it seems like you use some custom stuff. SO this might be a stupid question but did you remember to call your refresh-function from the scene? Especially in the onItemOK function.

Code:
Scene_Equip.prototype.onItemOk = function() {
        SoundManager.playEquip();
        this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item());
        this._slotWindow.activate();
        this._slotWindow.refresh();
        this._itemWindow.deselect();
        this._itemWindow.refresh();
        this._statusWindow.refresh();
        
        this._myMenuStatusWindow.refresh(); // <-- Something like this call
        
    };
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
Thanks for the reply.

I called the refresh function in three places and that works.

Scene_Equip.prototype.onItemOk
Scene_Equip.prototype.commandClear
Scene_Equip.prototype.commandOptimize

But the way the refresh function now works is that it checks the item the character has equipped "$gameActors.actor(1).equips(1).contains($dataArmors[1])" and then updates the picture.

The way I want it to work is for the picture to get updated as the player scrolls through items in the slotWindow.

There is a function Scene_Equip.prototype.commandEquip and inside there's "this._slotWindow.select(0);" which I assume calls another function that has the code for the select window part.

There are few things that bother me

1. How can I call my custom function from another function?
2. How can I get to the selected item ID inside the slotWindow?
(I would need the Id to know what picture to update when I call my refresh function)
3. Where would I need to call the refresh function?
(For the life of me, I can't find where to call it. I assume it's somewhere in the code below.)

You don't have permission to view the spoiler content. Log in or register now.

You don't have permission to view the spoiler content. Log in or register now.
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
I might have gone a bit overboard and coded a possible solution. But first to answer your questions:

Answer to Questions:

1) In your plugin you just add the original method with a function call to your method. It could look like this:
Code:
Scene_Equip.prototype.refreshActor = function() {
        var actor = this.actor();
        this._statusWindow.setActor(actor);
        this._slotWindow.setActor(actor);
        this._itemWindow.setActor(actor);
        this._myImageWindow.setActor(actor);
    };
2) The function "Window_EquipSlot.prototype.updateHelp" is the key. This function gets called every time you scroll through the items in the slotWindow.

3) I would do it in "Window_EquipSlot.prototype.updateHelp" as specified below.

Now to my solution:
There is quite a lot of stuff. Some of it might be unnecessary but I am not 100% sure how your game is supposed to be.

  • To the Window_EquipSlot I add your window. This way it can call the functions from your window.
  • I add the following to the "Window_EquipSlot.prototype.updateHelp"
    Code:
    if(this._myWindow) {
                    if(this.item()){
                        this._myWindow.drawPreviewPicture(0, 0, this.index(), (this.item()).id);               
                    } else {
                        this._myWindow.refresh();
                    }
            }
    This code calls a function in your window which draws the picture which matches the item. If there isn't any items in the slot then it calls the refresh function.
  • I have 3 set methods to set the values for the actor, slot, and item which should be drawn when calling the refresh method. (In my code at the botton I do not update all of these values. You should tho)
  • I have a drawImage function which is used to decide which image to draw using the actor, slot, and item. To do this it uses 3 layers of switch statements. This could probably be done better. In the code below it draws text instead of images.
  • I have a function called "drawPreviewPicture" which just clears the window and calls the draw function. (This method could posible be deleted by doing a few changes)

Code:
(function() {
    

    Window_EquipSlot.prototype.setMyWindow = function(myWindow) {
        this._myWindow = myWindow;
        this.callUpdateHelp();
    };

    Window_EquipSlot.prototype.updateHelp = function() {
        Window_Selectable.prototype.updateHelp.call(this);
        this.setHelpWindowItem(this.item());
        if (this._statusWindow) {
            this._statusWindow.setTempActor(null);
        }

        if(this._myWindow) {
                if(this.item()){
                    this._myWindow.drawPreviewPicture(0, 0, this.index(), (this.item()).id);               
                } else {
                    this._myWindow.refresh();
                }
        }
    };


    function myImageWindow() {
        this.initialize.apply(this, arguments);
    };

    myImageWindow.prototype = Object.create(Window_Base.prototype);
    myImageWindow.prototype.constructor = myImageWindow;

    myImageWindow.prototype.initialize = function(x, y, width, height) {
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
    };
    
    myImageWindow.prototype.setActor = function(actor) {
        if (this._actor !== actor) {
            this._actor = actor;
            this.refresh();
        }
    };

    myImageWindow.prototype.setItemId = function(itemId) {
        if (this._itemId !== itemId) {
            this._itemId = itemId;
            this.refresh();
        }
    };

    myImageWindow.prototype.setSlotId = function(slotId) {
        if (this._slotId !== slotId) {
            this._slotId = slotId;
            this.refresh();
        }
    };
    
    myImageWindow.prototype.refresh = function() {
        this.contents.clear();
        if (this._actor) {
            this.drawImage(0, 0, this._slotId, this._itemId);
        }
    };

    myImageWindow.prototype.drawImage = function(x, y, slotId, itemId) {
        var actorId = (this._actor).actorId();
        switch(slotId) {
            case 1:
                switch(itemId) {
                    case 1:
                        switch(actorId) {
                            case 1:
                                this.drawText("ItemId: 1, ActorId: 1", x, y, 270);
                                break;
                            default:
                                this.drawText("This Actor doesn't have art", x, y, 270);
                        }
                        break;
                    case 5:
                        switch(actorId) {
                            case 1:
                                this.drawText("ItemId: 5, ActorId: 1", x, y, 270);
                                break;
                            default:
                                this.drawText("This Actor doesn't have art", x, y, 270);
                        }
                        break;
                    case 6:
                        switch(actorId) {
                            case 1:
                                this.drawText("ItemId: 6, ActorId: 1", x, y, 270);
                                break;
                            default:
                                this.drawText("This Actor doesn't have art", x, y, 270);
                        }
                        break;
                    default:
                        this.drawText("Default: " + actorId, x, y, 270);
                }
                break;
            default:
                this.drawText("SlotId: " + slotId, x, y, 270);
        }
    };

    myImageWindow.prototype.drawPreviewPicture = function(x, y, slotId, itemId) {
        this.contents.clear();
        this.drawImage(x, y, slotId, itemId)
    };
    

    Scene_Equip.prototype.createMyImageWindow = function() {
        var wx = Graphics.boxWidth - (Graphics.boxWidth - this._slotWindow.width)
        var wy = 0
        var ww = Graphics.boxWidth - this._slotWindow.width
        var wh = Graphics.boxHeight
        this._myImageWindow = new myImageWindow(wx, wy, ww, wh);
        this._slotWindow.setMyWindow(this._myImageWindow);
        this.addWindow(this._myImageWindow);
    };

    Scene_Equip.prototype.create = function() {
        Scene_MenuBase.prototype.create.call(this);
        this.createHelpWindow();
        this.createStatusWindow();
        this.createCommandWindow();
        this.createSlotWindow();
        this.createItemWindow();
        this.createMyImageWindow();
        this.refreshActor();
    };

    Scene_Equip.prototype.refreshActor = function() {
        var actor = this.actor();
        this._statusWindow.setActor(actor);
        this._slotWindow.setActor(actor);
        this._itemWindow.setActor(actor);
        this._myImageWindow.setActor(actor);
    };
    
})();
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
I'll try it when I get home.

Thank you so much for your time on this.

EDIT:

I just noticed I fucking wrote incorrectly the name of the window. It's not the slotWindow I need... In the first post I wrote everything correctly but after that I wrote wrong. If you look at the picture in the first post the bottom window is the select window you open after you click in the slot window that you want to change equipment in that slot. As you scroll through items you can put in that slot, the help description in the top window updates based on what item you selected in that bottom window. I want the picture in the right window to update as the player scrolls through the items in the select window just as the help window updates with a description of the item.

Is that too complicated to implement inside the code you already wrote?
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
Actually thats how I understod it the first time as well.
It is easy to implement the solution using the itemWindow as well. (I actually did this first before I did the slotWindow)
You just need to use the "Window_EquipItem.prototype.updateHelp" instead of "Window_EquipSlot.prototype.updateHelp" pretty much.

Note:
When I made this I used RPGMaker MV version 1.0.1. You probably use a newer version and I do not know if there are any differences. If it doesn't work please tell me and I'll try getting the correct version to fix it.
I love fixing "bugs" like this so it is a great deal of fun for me.

On another note the code is made to support multiple actors, multiple item slots (in your case "Weapon", "Clothes", "Bra", "Panties", and "Accessory") and it expects a image for each combination (You can ofc set defaults).

Updated code:
Code:
(function() {

    Window_EquipItem.prototype.setMyWindow = function(myWindow) {
        this._myWindow = myWindow;
        this.callUpdateHelp();
    };

    Window_EquipItem.prototype.updateHelp = function() {
        Window_ItemList.prototype.updateHelp.call(this);
        if (this._actor && this._statusWindow) {
            var actor = JsonEx.makeDeepCopy(this._actor);
            actor.forceChangeEquip(this._slotId, this.item());
            this._statusWindow.setTempActor(actor);
        }

        if(this._myWindow) {
                if(this.item()){
                    this._myWindow.drawPreviewPicture(0, 0, this._slotId, (this.item()).id);               
                } else {
                    this._myWindow.refresh();
                }
        }

    };


    function myImageWindow() {
        this.initialize.apply(this, arguments);
    };

    myImageWindow.prototype = Object.create(Window_Base.prototype);
    myImageWindow.prototype.constructor = myImageWindow;

    myImageWindow.prototype.initialize = function(x, y, width, height) {
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
    };
    
    myImageWindow.prototype.setActor = function(actor) {
        if (this._actor !== actor) {
            this._actor = actor;
            this.refresh();
        }
    };

    myImageWindow.prototype.setItemId = function(itemId) {
        if (this._itemId !== itemId) {
            this._itemId = itemId;
            this.refresh();
        }
    };

    myImageWindow.prototype.setSlotId = function(slotId) {
        if (this._slotId !== slotId) {
            this._slotId = slotId;
            this.refresh();
        }
    };
    
    myImageWindow.prototype.refresh = function() {
        this.contents.clear();
        if (this._actor) {
            this.drawImage(0, 0, this._slotId, this._itemId);
        }
    };

    myImageWindow.prototype.drawImage = function(x, y, slotId, itemId) {
        var actorId = (this._actor).actorId();
        switch(slotId) {
            case 1:
                switch(itemId) {
                    case 1:
                        switch(actorId) {
                            case 1:
                                this.drawText("ItemId: 1, ActorId: 1", x, y, 270);
                                break;
                            default:
                                this.drawText("This Actor doesn't have art", x, y, 270);
                        }
                        break;
                    case 5:
                        switch(actorId) {
                            case 1:
                                this.drawText("ItemId: 5, ActorId: 1", x, y, 270);
                                break;
                            default:
                                this.drawText("This Actor doesn't have art", x, y, 270);
                        }
                        break;
                    case 6:
                        switch(actorId) {
                            case 1:
                                this.drawText("ItemId: 6, ActorId: 1", x, y, 270);
                                break;
                            default:
                                this.drawText("This Actor doesn't have art", x, y, 270);
                        }
                        break;
                    default:
                        this.drawText("Default: " + actorId, x, y, 270);
                }
                break;
            default:
                this.drawText("SlotId: " + slotId, x, y, 270);
        }
    };

    myImageWindow.prototype.drawPreviewPicture = function(x, y, slotId, itemId) {
        this.contents.clear();
        this.drawImage(x, y, slotId, itemId)
    };
    

    Scene_Equip.prototype.createMyImageWindow = function() {
        var wx = Graphics.boxWidth - (Graphics.boxWidth - this._slotWindow.width)
        var wy = 0
        var ww = Graphics.boxWidth - this._slotWindow.width
        var wh = Graphics.boxHeight
        this._myImageWindow = new myImageWindow(wx, wy, ww, wh);
        this._itemWindow.setMyWindow(this._myImageWindow);
        this.addWindow(this._myImageWindow);
    };

    Scene_Equip.prototype.create = function() {
        Scene_MenuBase.prototype.create.call(this);
        this.createHelpWindow();
        this.createStatusWindow();
        this.createCommandWindow();
        this.createSlotWindow();
        this.createItemWindow();
        this.createMyImageWindow();
        this.refreshActor();
    };

    Scene_Equip.prototype.refreshActor = function() {
        var actor = this.actor();
        this._statusWindow.setActor(actor);
        this._slotWindow.setActor(actor);
        this._itemWindow.setActor(actor);
        this._myImageWindow.setActor(actor);
    };
    
})();
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
I managed to change few things and now everything does as I wanted to.

Thank you so much! Without you I wouldn't be able to get this far :)

I love when everything works as it should.

EDIT:

Hehe... the moment I posted this reply I get a notification the thread has been updated. Upon looking at the code you posted I noticed I did the same changes as you did. A bit of logic goes a long way. At least in this case.

Tx again for the effort and for helping out.
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
Great to hear :D
You're welcome! If you happen to encounter another problem feel free to message me and I'll probably look into it :)
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
Changing this to work like this has a problem I didn't think about before.

The myImageWindow now updates based on the selection of the item. Because of that if a player uses Remove All or Optimize, it won't update the picture.

I could call another function inside:
- Scene_Equip.prototype.commandOptimize
- Scene_Equip.prototype.commandClear

and do something like I did before; clear window and check what item is equipped and then show the picture again.

Code:
if ($gameActors.actor(1).equips(1).contains($dataArmors[1]))
        {
            this.drawPicture('Maya', 0, 0); //267
        };
Is there an easier way to do this using the code I already have?
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
hmmm, the values _actor, _itemId, and _slotId for the myImageWindow are the values being used when the image is being drawn by the refresh function. So you could probably make it so you update these values when you call:
- Scene_Equip.prototype.commandOptimize
- Scene_Equip.prototype.commandClear
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
That's a good idea actually.

I'll try doing that later and test it, but I think it will work.
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
Everything works as it's supposed to now!!!

HURRAY!!

Still, I have one more question regarding a font size problem I was having. I made this thread in the wrong section before I made this and I still haven't been able to solve it. Could you take a look at it?



I think I know what's causing it but I don't know how to fix it.

drawTextEx reads one character at a time while drawText reads the whole text at once.
I think that's the problem but I have no clue how to make it work.
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
Got another small problem.

Scene_Equip.prototype.onSlotCancel = function() {
this._slotWindow.deselect();
this._commandWindow.activate();
Scene_Menu.prototype.myMenuStatusWindow.refresh();
};

I need to update myMenuStatusWindow after the player finishes changing player equipment.
This bolded text doesn't seem to work. I tried all kinds of things but since one if Scene_Equip and other one is Scene_Menu it doesn't work.

There is no Scene_Menu refresh function. There is only Scene_Menu.prototype.start but this only updates the first time you open the menu. When you come to main menu from the equipment window it doesn't update it.

Is there a function I can write and call this._myMenuStatusWindow.refresh(); from inside the Scene_Menu?
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
Just put it in "Scene_Menu.prototype.initialize" from my tests it seems to be called everytime the Scene_Menu comes into view. However so does "Scene_Menu.prototype.start" and "Scene_Menu.prototype.create" (except for the very first time).

If it does not work could you then send me your file so I could test it directly?
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
It's not working. It's probably because the function I'm calling isn't even initialized yet. I don't know if you'll be able to test because I'm also calling a common event where I'm setting variables based on what gear is equipped. I thought it would be more fitting to do that inside the RPG maker editor than inside the code. Then also I have events for changing clothes that I made for testing of this as well.

It's also more practical that way when I start building game and want to change gear.

One thing to note is that there are two functions. One is myMenuStatusWindow which I need to be updated and the other one is myImageWindow which we solved the problem for. The difference between those two is that inside the equipment window only pictures of the selected gear will show while on the main menu a full picture with all equipped items will be shown.

Code:
/*:
* @plugindesc Tales of Aeria Menu Changes
* @author kR1pt0n1t3 with help from Magnus4fun
* @help
*/
/////////////////////////////////////////////////////////////////////////////
(function() {
    function myMenuStatusWindow() {
        this.initialize.apply(this, arguments);
    };

    myMenuStatusWindow.prototype = Object.create(Window_Base.prototype);
    myMenuStatusWindow.prototype.constructor = myMenuStatusWindow;

    myMenuStatusWindow.prototype.initialize = function(x, y, width, height) {
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
    };

    myMenuStatusWindow.prototype.refresh = function() {
        this.contents.clear();
        $gameTemp.reserveCommonEvent(2);
        if($gameVariables.value(6) == 1){
            this.drawPicture('Maya', 0, 0);
        }
    };
    /////////////////////////////////////////////////////////////////////////////
    function myMenuTop() {
        this.initialize.apply(this, arguments);
    };

    myMenuTop.prototype = Object.create(Window_Base.prototype);
    myMenuTop.prototype.constructor = myMenuTop;

    myMenuTop.prototype.initialize = function(x, y, width, height) {
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
    };

    myMenuTop.prototype.refresh = function() {
        this.contents.clear();
    };
    /////////////////////////////////////////////////////////////////////////////
    function myMenuBottom() {
        this.initialize.apply(this, arguments);
    };

    myMenuBottom.prototype = Object.create(Window_Base.prototype);
    myMenuBottom.prototype.constructor = myMenuBottom;

    myMenuBottom.prototype.initialize = function(x, y, width, height) {
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
    };

    myMenuBottom.prototype.refresh = function() {
        this.contents.clear();
    };
    /////////////////////////////////////////////////////////////////////////////
    Window_Base.prototype.drawPicture = function(filename, x, y) {
        var bitmap = ImageManager.loadPicture(filename);
        this.contents.blt(bitmap, 0, 0, bitmap._canvas.width, bitmap._canvas.height, x, y);
    };
    /////////////////////////////////////////////////////////////////////////////
    Scene_Menu.prototype.create = function() {
        Scene_MenuBase.prototype.create.call(this);
        this.createCommandWindow();
        this.createGoldWindow();
        this.createStatusWindow();
        this.createmyMenuStatusWindow();
        this.createmyMenuTop();
        this.createmyMenuBottom();
    };

    Scene_Menu.prototype.createmyMenuStatusWindow = function() {
        var wx = Graphics.boxWidth - 500
        var wy = 0
        var ww = 500//Graphics.boxWidth - wx
        var wh = Graphics.boxHeight
        this._myMenuStatusWindow = new myMenuStatusWindow(wx, wy, ww, wh);
        this.addWindow(this._myMenuStatusWindow);
     
    };

    Scene_Menu.prototype.createmyMenuTop = function() {
        var wx = this._commandWindow.width
        var wy = 0
        var ww = Graphics.boxWidth - 500 - this._commandWindow.width
        var wh = Graphics.boxHeight / 2
        this._myMenuTop = new myMenuTop(wx, wy, ww, wh);
        this.addWindow(this._myMenuTop);
     
    };

    Scene_Menu.prototype.createmyMenuBottom = function() {
        var wx = this._commandWindow.width
        var wy = Graphics.boxHeight / 2
        var ww = Graphics.boxWidth - 500 - this._commandWindow.width
        var wh = Graphics.boxHeight / 2
        this._myMenuBottom = new myMenuBottom(wx, wy, ww, wh);
        this.addWindow(this._myMenuBottom);
     
    };

    Window_EquipItem.prototype.setMyWindow = function(myWindow) {
        this._myWindow = myWindow;
        this.callUpdateHelp();
    };

    Window_EquipItem.prototype.updateHelp = function() {
        Window_ItemList.prototype.updateHelp.call(this);
        if (this._actor && this._statusWindow) {
            var actor = JsonEx.makeDeepCopy(this._actor);
            actor.forceChangeEquip(this._slotId, this.item());
            this._statusWindow.setTempActor(actor);
        }

        if(this._myWindow) {
                if(this.item()){
                    this._myWindow.drawPreviewPicture(0, 0, this._slotId, (this.item()).id);            
                } else {
                    this._myWindow.refresh();
                }
        }

    };

    function myImageWindow() {
        this.initialize.apply(this, arguments);
    };

    myImageWindow.prototype = Object.create(Window_Base.prototype);
    myImageWindow.prototype.constructor = myImageWindow;

    myImageWindow.prototype.initialize = function(x, y, width, height) {
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
    };
 
    myImageWindow.prototype.setActor = function(actor) {
        if (this._actor !== actor) {
            this._actor = actor;
            this.refresh();
        }
    };

    myImageWindow.prototype.setItemId = function(itemId) {
        if (this._itemId !== itemId) {
            this._itemId = itemId;
            this.refresh();
        }
    };

    myImageWindow.prototype.setSlotId = function(slotId) {
        if (this._slotId !== slotId) {
            this._slotId = slotId;
            this.refresh();
        }
    };
 
    myImageWindow.prototype.refresh = function() {
        this.contents.clear();
        if (this._actor) {
            this.drawImage(0, 0, this._slotId, this._itemId);
        }
    };

    myImageWindow.prototype.drawPreviewPicture = function(x, y, slotId, itemId) {
        this.contents.clear();
        this.drawImage(x, y, slotId, itemId)
    };
 
    myImageWindow.prototype.drawImage = function(x, y, slotId, itemId) {
        var actorId = (this._actor).actorId();
        switch(slotId) {
            case 1:
                switch(itemId) {
                    case 1:
                        switch(actorId) {
                            case 1:
                                this.drawText("ItemId: 1", x, y, 270);
                                break;
                            default:
                                this.drawText("This Actor doesn't have art", x, y, 270);
                        }
                        break;
                    case 2:
                        switch(actorId) {
                            case 1:
                                this.drawText("ItemId: 2", x, y, 270);
                                break;
                            default:
                                this.drawText("This Actor doesn't have art", x, y, 270);
                        }
                        break;
                    case 3:
                        switch(actorId) {
                            case 1:
                                this.drawText("ItemId: 3", x, y, 270);
                                break;
                            default:
                                this.drawText("This Actor doesn't have art", x, y, 270);
                        }
                        break;
                    default:
                        this.drawText("ItemId: " + itemId, x, y, 270);
                }
                break;
            default:
                var myItemId = $gameActors.actor(1).equips()[1].id;
                this.drawText("Item Id: " + myItemId, x, y, 270);
        }
    };

    Scene_Equip.prototype.createMyImageWindow = function() {
        var wx = Graphics.boxWidth - (Graphics.boxWidth - this._slotWindow.width)
        var wy = 0
        var ww = Graphics.boxWidth - this._slotWindow.width
        var wh = Graphics.boxHeight
        this._myImageWindow = new myImageWindow(wx, wy, ww, wh);
        this._itemWindow.setMyWindow(this._myImageWindow);
        this.addWindow(this._myImageWindow);
    };

    Scene_Equip.prototype.create = function() {
        Scene_MenuBase.prototype.create.call(this);
        this.createHelpWindow();
        this.createStatusWindow();
        this.createCommandWindow();
        this.createSlotWindow();
        this.createItemWindow();
        this.createMyImageWindow();
        this.refreshActor();
    };

    Scene_Equip.prototype.refreshActor = function() {
        var actor = this.actor();
        this._statusWindow.setActor(actor);
        this._slotWindow.setActor(actor);
        this._itemWindow.setActor(actor);
        this._myImageWindow.setActor(actor);
    };
 
})();

/////UNUSED RIGHT NOW/////
    /*myImageWindow.prototype.optimize = function(slotId, itemId) {
        this.contents.clear();
        if (this._actor) {
            this.drawImage(0, 0, slotId, itemId);
        }
    };*/
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
From my test it seems to work fine the refresh method is called every single time wihtout me changing anything.

What version of RPGMaker MV are you using?
Maybe it is something else in the project that causes the problem?
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
I think you're looking at the wrong window.
This is the window that needs to update.
The function that does this is myMenuStatusWindow.



Code:
    myMenuStatusWindow.prototype.refresh = function() {
        this.contents.clear();
        $gameTemp.reserveCommonEvent(2);
        if($gameVariables.value(6) == 1){
            this.drawPicture('Maya', 0, 0);
        }
    };
This part of code is for the update of that picture in the menu.
The problem I'm having is that once I'm done inside the equipment menu and close it down, it doesn't update this picture. I need to open and close the menu twice for it to update. That's because I can't find the function for onClickclose if it even exists.

Also, I'm calling the equipment menu with "SceneManager.push(Scene_Equip);" from an event inside the main character bedroom and not from the main menu as you can see on the picture.

I think I might solve this if I knew how to call this function from within an event inside the rpg maker editor.

Can I put inside plugin command or script code something like
myMenuStatusWindow.prototype.refresh();?

EDIT:
Is there a way to set "Always Dash" and "Command Remember" to on as the game starts? I want to remove the options from the main menu as well but I want those options to be on and not off like it's on default.

So basically I need to change the default options and then I can remove the Options from the menu without worries.
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
I am not really sure. My windows look very different, it is not possible for me to debug it as I do not get the bug.
You could try sending me your project with the bug and I could look at it. Otherwise I cannot fix a bug I cannot recreate :/

EDIT:
Yeah you can do that by adding :
ConfigManager.alwaysDash = true;​
ConfigManager.commandRemember = true;
To the "Scene_Boot.prototype.create" function like this:

Code:
Scene_Boot.prototype.create = function() {
        Scene_Base.prototype.create.call(this);
        DataManager.loadDatabase();
        ConfigManager.load();
        this.loadSystemWindowImage();
        
        ConfigManager.alwaysDash = true;
        ConfigManager.commandRemember = true;
        
    };
It could also possible be added to "ConfigManager.load" instead.
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
I finally found the mistake after way to much time. I feel stupid for not realizing it sooner.
As I said earlier the refresh function do indeed get called.
However $gameTemp.reserveCommonEvent(2) reserves the call to the common event. This means that the event will be called when you enter the map. This is after you CLOSE the window.

So what actually happend?
  1. You open the menu.
  2. The refresh function is called.
  3. $gameTemp.reserveCommonEvent(2) reserves a call for the common event.
  4. $gameVariables.value(6) is not updated yet. So it shows the not updated image.
  5. You close the menu.
  6. The common event is called and the $gameVariables.value(6) is updated.
  7. You open the menu.
  8. The correct image is showing.
How to fix this?
  • You could probably fix it by calling the common event in other places (such as after you are done equiping clothes and at the start of the game)
  • Find a way to call common events while being in a menu
  • Not use a common event, but specify the same things in the plug in

I also cleaned up the plugin a little and I split it into 3 plugins to make it easier to read (I think so anyway)