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
250
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,624
Reaction score
5,160
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
250
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,624
Reaction score
5,160
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

We are truly intellectuals.
Without using violence without weapons
Our group has as many as 1.3 million people and more than 1 hundred thousand talks.
We gathered in an hour, more than 4.5 Half a hundred thousand



I got a Sword.
I got an Axe.
I got two Swords.
Nothing to see here, just walking with my dog.
I haven’t worked on my game in a while. Tomorrow might be the day.
*squeals* :kaoblush:


I've been experimenting with improved memory management again, which allowed me to include items to increase player path length. These are both 44 grid spaces long, and stable. :LZSexcite:
I FINALLY DID IT! 5 years making my very first game and I just officially released it on STEAM..... OMG..... I can say I finished a game! The feelings!!!!!

Forum statistics

Threads
104,463
Messages
1,006,474
Members
135,971
Latest member
Akasheee
Top