Help Windows - How it works?

Status
Not open for further replies.

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,673
Reaction score
1,084
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi people!

I'm making a plugin to add help windows to several scenes on the game.
It's working fine, but the problem is that I am using the update function of each scene to update the help windows(so it's updating every frame).
Ex:
Code:
Scene_GameEnd.prototype.update = function() {
    Scene_MenuBase.prototype.update.call(this);
        Eli.HelpWindows.setGameEndHelp();
};
But I've seen that this functions exists in window selectable:
Code:
Window_Selectable.prototype.setHelpWindow = function(helpWindow) {
    this._helpWindow = helpWindow;
    this.callUpdateHelp();
};

Window_Selectable.prototype.callUpdateHelp = function() {
    if (this.active && this._helpWindow) {
        this.updateHelp();
    }
};

Window_Selectable.prototype.updateHelp = function() {
    this._helpWindow.clear();
};
};
So, I've tried to use that updateHelp instead of SceneUpdate's functions.
In the Shop Scene, I use that code and it works:

Code:
Scene_Shop.prototype.createCommandWindow = function() {
//Alias the function
    this._commandWindow.setHelpWindow(this._helpWindow); //=== Add this.
};

Window_ShopCommand.prototype.updateHelp = function() {
    Eli.HelpWindows.setShopHelp();
};
So I manage to add a help window in SceneTitle. But I can't update it as I did with scene Shop(using updateHelp), I can only update it if I use the Scene_title update.

Code:
Window_TitleCommand.prototype.updateHelp = function() {
    Eli.HelpWindows.setTitleHelp(); // ==== not working

Scene_Title.prototype.update = function() {
//Alias that function
    //=== Add below
    if(this._commandWindow.isOpenAndActive()) {
        this._helpWindow.show();
        this._helpWindow.open();
        Eli.HelpWindows.setTitleHelp(); // ==== Working!
    }
};
};
So, I'm really confused on how the code is working on Mv. When the updateHelp is called? Every time I move the cursor? Select something?

I see that differences between the two scenes:
Scene_Shop.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Title.prototype = Object.create(Scene_Base.prototype);

BUT, Scene_MenuBase has already inherity the Scene_Base, right?

Another thing that I can't figure it out while I'm looking at the code.
The help texts that we made in the editor for the items.
When we are in Scene_Item, every time I select another item, the Help windows is updating constantly to change the texts(every frame), or it updates only when I move the cursor, selecting items?

Or should I not be worried about using Scene Update functions to update my help windows in all scenes(menus, title, and shop)?
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
399
Reaction score
221
First Language
English
Primarily Uses
RMMV
I'm not 100% sure on the question here, but help windows are typically used with Window_Selectable, these only need to be updated if the players selection changes (ie different information needs to be shown). To do this the window calls callUpdateHelp when a new index is selected - see Window_Selectable.prototype.select.

callUpdateHelp, as the name might suggest, calls the function updateHelp, but only if the selectable window is active and it actually has a help window.

As Window_TitleCommand is constructed from Window_Command, which is in turn constructed by Window_Selectable, this functionality already exists, you just need to make sure the window has a help window set.

To do this you first need to create a help window. Unfortunately, as Scene_Title is constructed from Scene_Base, the function createHelpWindow doesn't exist, so you'll need to add it - refer to Scene_MenuBase.prototype.createHelpWindow, it's the same process.

From here, call the newly created function as you're creating Scene_Title and you'll have a help window in the scene - you just need to add this to the command window now. In the function createCommandWindow you just need to run

Code:
this._commandWindow.setHelpWindow(this._helpWindow);
//make sure that the command window and help window are actually created before this runs or you'll encounter errors.
You'll also need to code what updateHelp is to do, other than clear itself, but I can't tell you what you want it to do. Hopefully that walkthrough gives you the jist of things and answers at least some of your queries. :)
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,673
Reaction score
1,084
First Language
Portuguese - Br
Primarily Uses
RMMV
@Silva Thank you for your explanation! I'm pretty sure that I've had tried that(add the help window functions in title scene and set it in window title command).
But maybe I was tired and miss something. I will try it again just to be sure.

From what you explained, I think I got how it works. Thanks.
I will report here if I make it or not.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,673
Reaction score
1,084
First Language
Portuguese - Br
Primarily Uses
RMMV
@Silva
Thanks a lot! It is working now!
The help window is not updating because it has been created in Scene_title.prototype.create after the command window.
So it shows on the scene, but can't update. Guess this function can't be aliased. But I follow your advice and everything is working now.

Code:
//OVERWRITE
Eli.HelpWindows.Scene_Title_create = Scene_Title.prototype.create;
Scene_Title.prototype.create = function() {
    Scene_Base.prototype.create.call(this); 
    this.createBackground();
    this.createForeground();
    this.createWindowLayer();
    this.createHelpWindow(); // ==== Add create help window
    this.createCommandWindow();
    //Eli.HelpWindows.Scene_Title_create.call(this); -- old alias.
// Can't alias, because createHelpWindow has to be called before create command window.
//Even if I alias and put createHelpWindow before the alias, it will throw an error. If I put after, the help window don't update.
// If it has some incompatibility, we can alias, and use the update function of the scene to update the help window. Instead of the function updateHelp.
};

//ALIAS
Eli.HelpWindows.Scene_Title_start = Scene_Title.prototype.start;
Scene_Title.prototype.start = function() {
    Eli.HelpWindows.Scene_Title_start.call(this);
    this._helpWindow.hide();
    this._helpWindow.close();
};
//ALIAS
Eli.HelpWindows.Scene_Title_update = Scene_Title.prototype.update;
Scene_Title.prototype.update = function() {
    Eli.HelpWindows.Scene_Title_update.call(this);
    if(this._commandWindow.isOpenAndActive()) {
        this._helpWindow.show();
        this._helpWindow.open();
        //Eli.HelpWindows.setTitleHelp();
    }
};

// NEW FUNCTION
Scene_Title.prototype.createHelpWindow = function() {
    this._helpWindow = new Window_Help();
    this.addWindow(this._helpWindow);
    this._helpWindow.y = 0;
    this._helpWindow.x = 0;
    this._helpWindow.width = Graphics.width;
    this._helpWindow.height = 108;
};
// ALIAS
Eli.HelpWindows.Scene_Title_createCommandWindow = Scene_Title.prototype.createCommandWindow;
Scene_Title.prototype.createCommandWindow = function() {
    Eli.HelpWindows.Scene_Title_createCommandWindow.call(this);
    this._commandWindow.setHelpWindow(this._helpWindow);
};

Window_TitleCommand.prototype.updateHelp = function() {
    this._helpWindow.clear();
    Eli.HelpWindows.setTitleHelp();
};
:MV1:
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,307
Reaction score
8,512
First Language
English
Primarily Uses
RMMV

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

rux
Just 80% of my motivation on game making lmao, anyone got tips on how to not be unmotivated?
I've signed up for a job training program for people with Asperger's Syndrome. I went to a "test run" today so they could see how well I did with simple jobs, and I amazed them. Most new people do it in 30+ minutes, while I finished in a mere 15 minutes. Gives me time to work on a screenplay for Studio MDHR...
People,I have seen that Someone from China/Chile and London is doing a Vaccine Against COVID-19.
Doing anything that yield good result in the long run is like sowing seeds. With proper care, they will grow and bear fruits. I'm excited for tomorrow. :D

Forum statistics

Threads
105,454
Messages
1,013,831
Members
137,104
Latest member
sasakureman
Top