Drawing an icon with Eval?

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"?
Please post a link to the plugin so we can see the instructions for ourselves.
"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.

I've moved this thread to Plugin Support. Thank you.

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?
drawText is a function from the base JS files not from the plugin..
Yeah, but that function is never called in the plugin in order to draw the menu entries...
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.
So far, is there any way to draw an icon? Maybe with TextManager too or raw javascript?
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.

Original thread: https://forums.rpgmakerweb.com/threads/drawing-an-icon-with-eval.106488/