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
255
Reaction score
112
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,651
Reaction score
5,168
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
255
Reaction score
112
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,651
Reaction score
5,168
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 Profile Posts

Ami
--- OP Candy ---

Kids: Trick Or Treat!
Hero: Alright,here's the Candies (Give A Bunch Of Candy).
Kids: Thank you,Mister! (Running)
Hero: How cute they are…
F.Archer: Did you give them a OP Candy,accidently?
Hero: Huh?
Halloween, a day where kids are encouraged to take candy from strangers.
Stream will be live shortly with a session of the Interactive Text Adventure! Feel free to drop by!
Took a break from spriting dinosaurs to carve a dinosaur pumpkin.

Little early but to all of you that celebrate it :

Forum statistics

Threads
104,669
Messages
1,007,973
Members
136,157
Latest member
Tian
Top