Status
Not open for further replies.

Lady_Blackpearl

Villager
Member
Joined
May 25, 2018
Messages
27
Reaction score
15
First Language
Italian
Primarily Uses
RMMV
So, I made another custom menu, for now I added some graphic and the status window. but I have a small problem. The faceset of characters are not loading the first time you open menu, they load only after close and open again the menu. Any fix? (I have try do a search on google but I can't find anything). The js contain also the reserveface code, but seem does nothing...
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,141
First Language
English
Primarily Uses
RMMV
3 options I can think of:

1.) The normal code uses the "Window_Base.prototype.reserveFaceImages" function when creating the windows, which seems to work fine.

Code:
Scene_Menu.prototype.createStatusWindow = function() {
    this._statusWindow = new Window_MenuStatus(this._commandWindow.width, 0);
    this._statusWindow.reserveFaceImages();  //  <-- You can add a similar line to your custom code
    this.addWindow(this._statusWindow);
};


2.) Use the Sprite class. This class already comes with a "load listener" so that it automatically draws after the bitmap is loaded.

Code:
//Call this function when initializing Scene_Menu
Scene_Menu.prototype.drawMyFaceSprites = function() {
    this._haroldFace = new Sprite(ImageManager.loadFace('harold');
    this.addChild(this._haroldFace);
};

Note: Using this method has no link between the face and the window anymore


3.) Set a timeout and try to draw the image again later. You can/should read more information about window.setTimeout here.

Basically this option will try to draw the image. If the image bitmap is not loaded yet, it will try again after XX time.

Code:
Window_MyCustomWindow.prototype.safelyDrawFace = function(name, index, x, y, w, h) {
    // Try to load the image bitmap. If we have loaded it before, it comes instantly.
    // Otherwise, it takes some time.
    const bitmap = ImageManager.loadFace(name);
    // If we do not have the bitmap ready to draw, then try again after 25 ms
    if (bitmap.width <= 0) {
      return setTimeout(this.safelyDrawFace.bind(this, name, index, x, y, w, h), 25);
    }
    // The bitmap must be ready if we got here, so draw the face now
    this.drawFace(name, index, x, y, w, h);
};
 

Lady_Blackpearl

Villager
Member
Joined
May 25, 2018
Messages
27
Reaction score
15
First Language
Italian
Primarily Uses
RMMV
Thank you! I will try one of this options and see. It is strange tho, because I didn't made much chnges to the code (for now) but just add a background and some more images to it. But isn't the first time that it does that.

EDIT: forgot to mention that my custom menu plugin have the first option but it does nothing at all.

this._statusWindow.reserveFaceImages(); this for my custom menu plugin isn't working :X yes it is inside that function.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,141
First Language
English
Primarily Uses
RMMV
I would not recommend #2 for menu faces, because it would become separated from the window if the player changed formation, for example.
It is very useful in other scenarios, so it could be good to try for research purposes. Here's a decent tutorial on using Sprite.

You can also call the reserveFaces function from an event. It only reserves the face for actors in the party, so you would have to call it any time the party gets new actors.
Code:
// in an event Script command
Window_Base.prototype.reserveFaceImages.call(null);
 

Lady_Blackpearl

Villager
Member
Joined
May 25, 2018
Messages
27
Reaction score
15
First Language
Italian
Primarily Uses
RMMV
Well yes, problem is that reserveFaceImage isn't working for me at all. :x yep the option 2 is to complicated I guess.

EDIT: So I made a test. I placed this Window_Base.prototype.reserveFaceImages.call(null); in the Scene_Map.prototype.callMenu = function() {} before the this_waitCount = 2;

Is working. My guess is could be a bug of rpg maker loading to fast menu to don't manage to load the images faster? or the lack of an update/refresh somewhere.
 
Last edited:

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,634
Reaction score
1,453
First Language
French
Primarily Uses
RMMV
the problem is that rmmv initialize a new stage at each opening menu.
You can create a pre-loaded menu but it hard and need good knowledge in js.

best way it make a special sceneLoading manager for loading all perma stuff like menu!.
Good approach are to dispatch resource as a pack.
 

Lady_Blackpearl

Villager
Member
Joined
May 25, 2018
Messages
27
Reaction score
15
First Language
Italian
Primarily Uses
RMMV
Well I know some java but cant do much deep things, I guess leaving for now that code in the scene_map will do because I'm not sure where to start. I have been watching and following tutorials so Im making my own menu with some copy paste and modify of the scene and window default js. I copied the whole window_menustatus and paste in my plugin, it work but it had same problem of images not loading at first menu opening, they load only after close and reopen it. So my guess was that this problem only happened once (the first time you open menu) and the problem is between the Scene_Map.prototype.callMenu and my plugin. In fact placing Window_Base.prototype.reserveFaceImages.call(null); before the waitcount remove the problem...

EDIT: also this work too... But placing Window_Base.prototype.reserveFaceImages.call(); in the create function won't work. No clue tho. Now is working just fine. Until i find better or I remake the whole status window. :p Still don't know why it does this problem, afetr all is just a copy of the original code... with soem small modify in the coord pos and the row/cols.
Code:
Scene_Menu.prototype.initialize = function() {
    Scene_MenuBase.prototype.initialize.call(this);
    Window_Base.prototype.reserveFaceImages.call();
};
 
Last edited:

Lady_Blackpearl

Villager
Member
Joined
May 25, 2018
Messages
27
Reaction score
15
First Language
Italian
Primarily Uses
RMMV
I geuss this topic can be closed as I found this way to fix the small problem, until i find better solution! Thankst o everyone that helped, appreciate!
 

slimmmeiske2

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

Latest Threads

Latest Profile Posts

I'm finally back! :kaojoy:
A lot of RL issues happened this year which didn't let me work on Aithne as much, but I am back with new inspiration!
In that time my art style also changed a little, so I'll be doing a small art change with busts/menu art
Ops forgot to fix the hand on the weaponless sprite o_O
opening old GIMP files is a blessing and a curse because it can be fun to look at art you started once upon a time and want to finish BUT come to a total halt when you remember your past self forgot to create separate layers for most files
"The bigger the person, the longer the wait"

Forum statistics

Threads
113,722
Messages
1,076,934
Members
147,751
Latest member
DaTedinator
Top