RMMZ Scene addWindow with animation

PMantis13

Caipirinha lover.
Veteran
Joined
Aug 29, 2020
Messages
31
Reaction score
18
First Language
PT-BR
Primarily Uses
RMMZ
Hello dear makers!

I've been doing MyCustomScene.addWindow(myWindowInstance) for sometime, but now I noticed that the window does not have its opening animation. I've been messing with the windows functions, and I noticed the open function animates it properly, but it seems I can't call it if the window is not added to the window layers.

Is there anyway I can add a window to a scene and open it up with it's animation?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,610
Reaction score
976
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi :)
Did you try to overwrite the open method for your window?
When you add your window to the scene, as soon as the scene starts, the window is already open?
Maybe you can try to initialize this window closed, and see if the open animation works(opening it via console log)?
 

PMantis13

Caipirinha lover.
Veteran
Joined
Aug 29, 2020
Messages
31
Reaction score
18
First Language
PT-BR
Primarily Uses
RMMZ
Hi :)
Did you try to overwrite the open method for your window?
When you add your window to the scene, as soon as the scene starts, the window is already open?
Maybe you can try to initialize this window closed, and see if the open animation works(opening it via console log)?
My Scene already has 2 other Windows that are open as soons as the Scene is created. They are a Window_Command with some selectables, and another Window_Base that displays info based on what command is being selected. The third Window is a Window_Command, more like a yes/no confirmation window, that I open with MyScene.addWindow(this.confirmationWindow) when the user chooses an option on the previous Window_Command.

The thing is, when I call this: MyScene.addWindow(this.confirmationWindow), the Window opens without any animation. Then I use the close() function to close it, activating the last Window, and I open it up again but now with the open function (since this window is already on the window layers), and it animates wonderfully. Is there any way I can add the window (MyScene.addWindow(this.confirmationWindow)) in a closed state, in order to always open it up with the animation?
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,610
Reaction score
976
First Language
Portuguese - Br
Primarily Uses
RMMV
Oh, I get it.
This command:
MyScene.addWindow(this.confirmationWindow)
Is to add the window to the scene/window layers of the scene. Not to open the window.
So I think when you are using it, the window shows no animation because by default the window is already open when you add it.

Maybe you can try something like that, when the scene is starting/initiating:
JavaScript:
MyScene.addWindow(this.confirmationWindow)
this.confirmationWindow.close()
this.confirmationWindow.hide()
this.confirmationWindow.deactivate()
I don't know the correct order or command, but it should be some of these 3 above.

Then, when you need the confirmation window, you can only open and activate it.
this.confirmationWindow.open()
this.confirmationWindow.activate()

Something like the Scene_Equip do with the itemWindow:
JavaScript:
Scene_Equip.prototype.createItemWindow = function() {
    const rect = this.itemWindowRect();
    this._itemWindow = new Window_EquipItem(rect);
    this._itemWindow.setHelpWindow(this._helpWindow);
    this._itemWindow.setStatusWindow(this._statusWindow);
    this._itemWindow.setHandler("ok", this.onItemOk.bind(this));
    this._itemWindow.setHandler("cancel", this.onItemCancel.bind(this));
    this._itemWindow.hide(); // Here! It hides the window, then add it later.
    this._slotWindow.setItemWindow(this._itemWindow);
    this.addWindow(this._itemWindow); // Add the window already hided.
};

Scene_Equip.prototype.onSlotOk = function() {
    this._slotWindow.hide();
    this._itemWindow.show(); // Now he shows it!
    this._itemWindow.activate();
    this._itemWindow.select(0);
};
NOTE: I don't know if hiding a window just turns off the visibility or it closes too. And if the show command just does the reverse. Maybe you need to hide and close. Don't know for sure ^^''
 

PMantis13

Caipirinha lover.
Veteran
Joined
Aug 29, 2020
Messages
31
Reaction score
18
First Language
PT-BR
Primarily Uses
RMMZ
It worked like a charm! Feels a liiittle hacky, but eh, who cares. For any who stumble into the same problem, I'm doing this when I add my windows:
JavaScript:
    this.questListWindow = this.buildQuestListWindow();
    this.questDetailsWindow = this.buildQuestDetailWindow();
    this.questConfirmationWindow = this.buildQuestConfirmationWindow();
    this.questConfirmationWindow.hide();
    this.questConfirmationWindow.close();

    this.addWindow(this.questListWindow);
    this.addWindow(this.questDetailsWindow);
    this.addWindow(this.questConfirmationWindow);
I had to hide the window first because it was showing it closing for a brief moment when the scene popped up. So, if the player selects a command from this.questListWindow, the handler function is called, opening this.questConfirmationWindow:
JavaScript:
    this.questConfirmationWindow.show();
    this.questConfirmationWindow.open();
    this.questConfirmationWindow.activate();
Now if the player cancels/escapes this window, we gotta have another handler function for 'cancel' closing this window (not hiding it anymore) and activating the last one:
JavaScript:
    this.questConfirmationWindow.close();
    this.questListWindow.activate();
Feels hacky because whenever I'm opening the Window for the second time, I'm still calling "show", when I don't need it anymore.

Thanks again for your time, @Eliaquim ! Nice to have you around when I struggle with these stuff.
 

PMantis13

Caipirinha lover.
Veteran
Joined
Aug 29, 2020
Messages
31
Reaction score
18
First Language
PT-BR
Primarily Uses
RMMZ
By the way, this is how the scene is turning out (portuguese at first, but you know it, right @Eliaquim ? Missing a msg on the confirmation box, lol):

rmmz.gif
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,610
Reaction score
976
First Language
Portuguese - Br
Primarily Uses
RMMV
It's already looking pretty good!
I was struggling another day to write texts on a window(like you did with the right one). It seems a little confuse to me yet xD
I think you will add a picture to it to in that blank space, right?
Looks good! ^^
 

PMantis13

Caipirinha lover.
Veteran
Joined
Aug 29, 2020
Messages
31
Reaction score
18
First Language
PT-BR
Primarily Uses
RMMZ
Yeah, I had to override some functions in order to draw the command options at the bottom of the window. I'm also using a drawText function that automatically breaks line when the text is too big.

That empty space will carry a picture of the map the player is going to do the quest. This game is very Monster Hunter inspired haha.

Thanks a lot for all your support, @Eliaquim !
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I always told my DA fans how much I hate slot machines. They're fine in games as a risk-and-reward system. But when you're spending REAL MONEY in a Vegas casino to try and hit the jackpot (which very, very few people will), it can really hurt your budget. Gambling is a bad habit, and I don't like wasting my money on a slim chance. Go to Vegas for the experience, not the jackpot.
Took the kids to a corn maze. They gave us a map and had lights at certain points in the maze. Not overwhelming... or underwhelming... just... whelming.
Okay, vacuuming fruit flies out of the air is surprisingly effective.
Finally finished my menu redesign after like a month of coding! I hate designing menus... Good news though - I thought of a complete redesign for it now, so yay...
Still no scam calls all day... also I got a quick gig designing a mascot drawing for a small business, so I might actually make some green of my own after all. That would be a perfect job for me, since I love art and digital design.

Forum statistics

Threads
104,389
Messages
1,006,034
Members
135,919
Latest member
SuitonKoton
Top