RMMZ [Help] How to manipulate gold window from shop number window?

Status
Not open for further replies.

lordvalinar

Lord of the Damned
Veteran
Joined
Mar 31, 2013
Messages
249
Reaction score
111
First Language
English
Primarily Uses
RMMZ
Hmm anyone have an idea how to manipulate the gold window from the shop number window?

Thinking of showing a color-coded difference in prices.
* Ex1: You have 300G, something costs 50G in buy mode -> Shows 250G in (red) on your gold window
* Ex2: You have 300G, and selling a potion for 50G in sell mode -> Shows 350G in (green) on your gold window

I'm trying to use SceneManager._scene, but the numberWindow never seems to be "active" when calling the gold window refresh
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,613
Reaction score
5,155
First Language
Dutch
Primarily Uses
RMXP
Before I close this, can you share how you solved it?
This might be useful for future users.
 

lordvalinar

Lord of the Damned
Veteran
Joined
Mar 31, 2013
Messages
249
Reaction score
111
First Language
English
Primarily Uses
RMMZ
Before I close this, can you share how you solved it?
This might be useful for future users.
Oh! Sure! I would like to apologize prematurely since I suck at explaining things, but I'll try.
Alright so the two main important methods to do this (+one new one) are:

JavaScript:
// This will return the gold window to normal
const sceneShop_endNumInput = Scene_Shop.prototype.endNumberInput;
Scene_Shop.prototype.endNumberInput = function() {
    sceneShop_endNumInput.call(this);
    this._goldWindow.refresh();
};

// This will call a separate method that we use to
// control the new color scheme.
const wsn_refresh = Window_ShopNumber.prototype.refresh;
Window_ShopNumber.prototype.refresh = function() {
    wsn_refresh.call(this);
    const goldWindow = SceneManager._scene._goldWindow;
    goldWindow.numWindowRefresh();
};

// The new method to refresh the gold window's changes
Window_Gold.prototype.numWindowRefresh = function() {
    const scene = SceneManager._scene;
    const numWindow = scene._numberWindow;
    const cmdWindow = scene._commandWindow;
    const total = numWindow._price * numWindow.number();
    const unit = this.currencyUnit();
    const rect = this.itemLineRect(0);
    this.contents.clear();
    switch (cmdWindow.currentSymbol()) {
        case "buy": {
            let value = this.value() - total;
            this.processColorChange(10);
            this.drawCurrencyValue(value, unit, rect.x, rect.y, rect.width);
        } break;
        case "sell": {
            let value = this.value() + total;
            this.processColorChange(24);
            this.drawCurrencyValue(value, unit, rect.x, rect.y, rect.width);
        } break;
    }
    this.resetFontSettings();
};
Now there may be better ways to optimize it, but for the moment It Just Works lol.
Note: My code doesn't actually use the drawCurrencyValue() function, so it's untested, I have a different function for its setup. But hopefully this can at least help.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,613
Reaction score
5,155
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.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Woke up on an awful nightmare of being banned here because some mod didn't liked me in a super-heroes freeform round robin RP where I used throwing normal hammer as power and it was qualified being too OP. XD Nice to read you all guys. Will not wait next nightmares.
Staring at all the RPG Maker versions I have and realizing that my project has been a long time coming. But, I finally feel like I have the knowledge and experience to make it into something good.
We're almost done with the jam game! :D

Forum statistics

Threads
104,324
Messages
1,005,563
Members
135,844
Latest member
andrewshetty123
Top