• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Javascript MV - Update Window on Selection

kR1pt0n1t3

Active Member
Dec 31, 2017
821
976
Can I call myMenuStatusWindow.prototype.refresh();? from an event?

I think that would fix everything with that problem but only if I could call the function.

Thanks again for the effort :)

I also thought the call common event function does it instantly... I didn't know it reserves the call for when you're on the map.

EDIT:

I just did what you said and added a call common event at the end of that clothes event in the room and it works perfectly... Why didn't I think of that :/

Now I'm off to rendering pictures :/ This is gonna take so fucking long to do :(

EDIT2:

Do you know maybe why the Journal command doesn't show up in my menu?
I've installed Yep_QuestJournal but it doesn't show up in the main menu.
 

Magnus4fun

Newbie
Jun 28, 2017
17
12
You cannot call the refresh function of a window that doesn't exist. So you would probably only be able to call "myMenuStatusWindow.prototype.refresh()" while "myMenuStatusWindow" is open (and actually created). If it is not shown then why would you refresh it anyway?

The reason the Journal is not showing is because you use YEP_MainMenuManager which doesn't show the Journal. However you can add the journal to it. Here is how taken from the yanfly website.
You don't have permission to view the spoiler content. Log in or register now.
 
  • Like
Reactions: kR1pt0n1t3

kR1pt0n1t3

Active Member
Dec 31, 2017
821
976
Bah...

I thought since it was made by the same person he made it to automatically add itself to the menu.

Thanks yet again. Journal works like a charm now.
 

kR1pt0n1t3

Active Member
Dec 31, 2017
821
976
Hey Magnus, got another question.



I tried to find how to change in itemWindow for the empty slot to write "Remove" or "Undress" but for the life of me I can't find how to do it.

I think it's here but whatever I do, it won't show text in that slot.

Code:
Window_ItemList.prototype.makeItemList = function() {
    this._data = $gameParty.allItems().filter(function(item) {
        return this.includes(item);
    }, this);
    if (this.includes(null)) {
        this._data.push(null);
    }
};
 

Magnus4fun

Newbie
Jun 28, 2017
17
12
It is actually in the "Window_ItemList.prototype.drawItem", where you set it to write either "Remove" or "Undress" if the index is null.
It would look something like this:
Code:
Window_ItemList.prototype.drawItem = function(index) {
        var item = this._data[index];
        if (item) {
            var numberWidth = this.numberWidth();
            var rect = this.itemRect(index);
            rect.width -= this.textPadding();
            this.changePaintOpacity(this.isEnabled(item));
            this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
            this.drawItemNumber(item, rect.x, rect.y, rect.width);
            this.changePaintOpacity(1);
        } else {
            var rect = this.itemRect(index);
            this.drawText("Remove", rect.x, rect.y, rect.width);
        }
    };
However this probably will change how the Window_ItemList looks like for other places than the Window_EquipItem. So you should be aware of that.

If you really want to to customize how the list looks like then I guess you could make a custom Window_ItemList and make your Window_EquipItem use that one instead.
 

kR1pt0n1t3

Active Member
Dec 31, 2017
821
976
Can't I just make something like this inside the else of the drawItem

if (this.itemRect.type == 'armor'){
this.drawText("Remove", rect.x, rect.y, rect.width);}
else {
whatever there was before you altered
};
 

Magnus4fun

Newbie
Jun 28, 2017
17
12
I am stupid. Since Window_EquipItem inherits Window_ItemList then you can just do this:
Code:
Window_EquipItem.prototype.drawItem = function(index) {
        var item = this._data[index];
        if (item) {
            var numberWidth = this.numberWidth();
            var rect = this.itemRect(index);
            rect.width -= this.textPadding();
            this.changePaintOpacity(this.isEnabled(item));
            this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
            this.drawItemNumber(item, rect.x, rect.y, rect.width);
            this.changePaintOpacity(1);
        } else if (this._slotId != -1){
            var rect = this.itemRect(index);
            this.drawText("Undress", rect.x, rect.y, rect.width);
        }
    };
This will only affect Window_EquipItem. The condition (this._slotId != -1) is there so it wont display "Undress" before you have selected "Change Clothes"
 
  • Like
Reactions: kR1pt0n1t3

kR1pt0n1t3

Active Member
Dec 31, 2017
821
976
Thx bro.

I'll test it out when I get home.

EDIT:

Is there a way to get to the type of the item?
I'd like to say "Unequip" for sword and for clothes "Undress"?

Can I use something like if(this.item.etype == 'armor')?

If it's too complicated don't bother with it, I'll just write "Remove" then.
 

Magnus4fun

Newbie
Jun 28, 2017
17
12
The easiest way I can imagine doing it would be like this:
Code:
Window_EquipItem.prototype.drawItem = function(index) {
    var item = this._data[index];
    if (item) {
        var numberWidth = this.numberWidth();
        var rect = this.itemRect(index);
        rect.width -= this.textPadding();
        this.changePaintOpacity(this.isEnabled(item));
        this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
        this.drawItemNumber(item, rect.x, rect.y, rect.width);
        this.changePaintOpacity(1);
    } else if (this._slotId != -1){
        var rect = this.itemRect(index);
        switch(this._slotId) {
            case 0:
                this.drawText("Unequip", rect.x, rect.y, rect.width);
                break;
            case 1:
            case 2:
                this.drawText("Undress", rect.x, rect.y, rect.width);
                break;
            case 3:
            case 4:
                this.drawText("Take off", rect.x, rect.y, rect.width);
                break;
            default:
                this.drawText("_slotId unknown: " + this._slotId, rect.x, rect.y, rect.width);
        }
    }
};
This allows you to change what it says depending on what slot you're looking at. So if it is your "Hand" slot it would say "Unequip". If however you want to do it also depending on kind of item it is. Then it would be a bit more difficult but I still think it would be possible.

You cannot use "if(this.item.etype == 'armor')" because this.item() would refer to the item selected in the Window_EquipItem and not Window_EquipSlot so you whouldn't get the item you have equiped. Also I don't think there is anything called etype, there is an etypeId tho.