Drawing an icon with Eval?

KravenarGames

Veteran
Veteran
Joined
Feb 19, 2017
Messages
130
Reaction score
15
First Language
English
Primarily Uses
N/A
Hello everyone,
I'm tweaking the Yanfly's plugin "Main Menu Manager".
When assigning the Menu-Command name it says:

"Name
– This is how the command will appear visually in the main menu. This is an eval, which means, it’s code driven. If you want the command to appear just as it is, use ‘quotes’ around it."

So far, if I write 'Custom Command' it works.
But how can I make appear an icon before the command? Like '\i[404] Custom Command' ? With a single slash \ or double \\, it doesn't work. So I suppose it should be code driven, but I don't know how.
Can someone enlight me about this "eval"?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Please post a link to the plugin so we can see the instructions for ourselves.
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
"eval" is a javascript keyword for executing strings as code.
Parameters are strings by default and will get executed as code by Yanfly's main menu manager from what you describe.
So by putting " " you're telling the main menu manager that this is not code but a litteral string, and it will not work. It's likely meant to be used so that you can have dynamic text for commands using variables or switches.

So Yanfly's main menu manager is not the issue.
You have to look at how the menu handles text codes. Basically there's 2 functions in the RM engine used to draw text: drawText and drawTextEx.
drawText doesn't process textcodes and drawTextEx does.

If you look at window command, the drawItem method which is used to draw text for the menu commands uses drawText, so it means there's no way text codes will work, period.

Your solution would be to write actual js code in the eval to draw the icon inside the window at the proper coordinates. How to do that exactly is the crux of the problem and would require looking at how Yanfly modifies the main menu, and the main menu itself.

Another solution would be to modify the drawItem duntion of window command to change drawText into drawTextEx, but that's very likely to cause issues.
Code:
Window_MenuCommand.prototype.drawItem = function(index) {
    var rect = this.itemRectForText(index);
    var align = this.itemTextAlign();
    this.resetTextColor();
    this.changePaintOpacity(this.isCommandEnabled(index));
    this.drawTextEx(this.commandName(index), rect.x, rect.y, rect.width, align);
};
That should probably work, but don't blame me if it wrecks formatting in your menu, because drawTextEx doesn't take width into account when drawing text or even alignement as opposed from drawText.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,224
First Language
Dutch
Primarily Uses
RMXP

I've moved this thread to Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

KravenarGames

Veteran
Veteran
Joined
Feb 19, 2017
Messages
130
Reaction score
15
First Language
English
Primarily Uses
N/A
Digging deep through the code I've not been able to find anything like DrawText... but it calls many times this: "TextManager", like "TextManager.skill" for calling the skill name. Could the TextManager be used to call an icon?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
drawText is a function from the base JS files not from the plugin..
 

KravenarGames

Veteran
Veteran
Joined
Feb 19, 2017
Messages
130
Reaction score
15
First Language
English
Primarily Uses
N/A
Yeah, but that function is never called in the plugin in order to draw the menu entries...
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
If the plugin still relies on the default engine code for actually writing the texts, it doesnt need to actually call drawText itself. It just needs to set which text is to be drawn and let the engine handle itself.

So even if drawText doesnt exist or called in the plugin directly, you cant be sure that it doesn't use it at all.

Actually most windows don't even call drawText if you look only at their own code, because its being called by their "parent" instead, so there's no need for them to write it again.

Remember, most plugins dont run by itself, it runs side by side with the engine.
 
Last edited:

KravenarGames

Veteran
Veteran
Joined
Feb 19, 2017
Messages
130
Reaction score
15
First Language
English
Primarily Uses
N/A
So far, is there any way to draw an icon? Maybe with TextManager too or raw javascript?
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
Browse through text manager and see for yourself.
Look into the window being used (window menu command), if it's not in there, look into its parent, repeat until you find the function.

Anyway the function is aptly named drawIcon(id,x,y) and is a method of Window Base.

Code:
this.drawIcon(iconId,rect.x,rect.y);
"your text here"
That may work depending on when the eval is being processed.

Edit: for future reference TextManager is used as a place to store what you put in the system tabs of the database. It has nothing to do with actually outputting that text.
 
Last edited:

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

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,859
Messages
1,017,030
Members
137,566
Latest member
Fl0shVS
Top