I have a custom GUI element that it would be nice to have an item tooltip on. Or a recipe tooltip. Or whatever vanilla tooltip may be best applicable to the use case.
Unfortunately it seems that the tooltip is limited to LocalisedString. It would be nice if we could have something like a TooltipSpecification, which can either be a LocalisedString or a TooltipPath like "item/iron-plate" to show the tooltip for the Iron Plate item.
The closest I can get to this goal is to use a choose-elem-button and set it to "locked". This gets the tooltip like I want, but it doesn't allow me to use "number" which is needed in my use-case.
Apply built-in tooltips to custom GUI elements
Re: Apply built-in tooltips to custom GUI elements
+1
when you use choose-elem-button the cost to add the button and lock can be significant. this to get the game tooltip if you can have a button to get tooltip, it will be super
elem-button:
when you use choose-elem-button the cost to add the button and lock can be significant. this to get the game tooltip if you can have a button to get tooltip, it will be super
elem-button:
- elem_type :: string: The type of the button - one of the following values.
- item :: string (optional): If type is "item" - the default value for the button.
- tile :: string (optional): If type is "tile" - the default value for the button.
- entity :: string (optional): If type is "entity" - the default value for the button.
- signal :: SignalID (optional): If type is "signal" - the default value for the button.
- fluid :: string (optional): If type is "fluid" - the default value for the button.
- recipe :: string (optional): If type is "recipe" - the default value for the button.
- decorative :: string (optional): If type is "decorative" - the default value for the button.
- item-group :: string (optional): If type is "item-group" - the default value for the button.
- achievement :: string (optional): If type is "achievement" - the default value for the button.
- equipment :: string (optional): If type is "equipment" - the default value for the button.
- technology :: string (optional): If type is "technology" - the default value for the button.
Re: Apply built-in tooltips to custom GUI elements
Where can I get this easy-to-use-looking performance information from?choose-elem-button-cost.png
Mods: ingteb, ixuClock, ixuAutoSave, NoCheating, hardCrafting (Maintainer) and more
Desperately tried to implement redo![Smile :)](./images/smilies/icon_e_smile.gif)
Desperately tried to implement redo
![Smile :)](./images/smilies/icon_e_smile.gif)
Re: Apply built-in tooltips to custom GUI elements
Jarg`s Factorio Debugger has a profiling mode, it's super useful.
Re: Apply built-in tooltips to custom GUI elements
I'd be interested in some code that shows the performance impact of creating and or setting locked on choose elem buttons. Because there's nothing inherently expensive about either of those so I suspect something else is going on.
If you want to get ahold of me I'm almost always on Discord.
Re: Apply built-in tooltips to custom GUI elements
Hello Rseding91,
I did few tests, what surprises me is that the locked setting has a more important value than the creation.
the mod test
Press hotkey [K] in game to open/close test panel
recipes in vanilla:
recipe in Pyanodon Mods (it just a test, i never want display all recipes)
entity in Pyanodon Mods saved game with Pyanodon Mods
I did few tests, what surprises me is that the locked setting has a more important value than the creation.
the mod test
Press hotkey [K] in game to open/close test panel
recipes in vanilla:
recipe in Pyanodon Mods (it just a test, i never want display all recipes)
entity in Pyanodon Mods saved game with Pyanodon Mods
Re: Apply built-in tooltips to custom GUI elements
Ok, I profiled it and it's now fixed for the next release.
The issue was adding and setting the value 1 at a time.
* Every time a new widget is added to any GUI the "widget under mouse" is invalidated and the game flags it as such
* Every time 'locked' was set on one of the elements the game would 'update widget' for the choose elem button and as part of that it would check and remove the tooltip for the widget if the mouse was over it
* The way "widget under mouse" is found is to recursively go through the widgets on screen finding which one the mouse is inside of until the final widget is gotten
That meant the "add, set locked, repeat" would be doing a reclusive scan of the widgets on screen for each added element.
The tooltip logic removal was only meant to happen when changing the selected elem on the widget so I fixed it by only doing the tooltip removal logic when the selected elem changes instead of every time.
Now setting 'locked' takes basically zero CPU time (as it should). In the meantime you can fix it on your end by adding all the elements then iterating them and setting locked. Since setting locked doesn't invalidate the widget-under-mouse; adding/removing widgets does.
The issue was adding and setting the value 1 at a time.
* Every time a new widget is added to any GUI the "widget under mouse" is invalidated and the game flags it as such
* Every time 'locked' was set on one of the elements the game would 'update widget' for the choose elem button and as part of that it would check and remove the tooltip for the widget if the mouse was over it
* The way "widget under mouse" is found is to recursively go through the widgets on screen finding which one the mouse is inside of until the final widget is gotten
That meant the "add, set locked, repeat" would be doing a reclusive scan of the widgets on screen for each added element.
The tooltip logic removal was only meant to happen when changing the selected elem on the widget so I fixed it by only doing the tooltip removal logic when the selected elem changes instead of every time.
Now setting 'locked' takes basically zero CPU time (as it should). In the meantime you can fix it on your end by adding all the elements then iterating them and setting locked. Since setting locked doesn't invalidate the widget-under-mouse; adding/removing widgets does.
If you want to get ahold of me I'm almost always on Discord.
Re: Apply built-in tooltips to custom GUI elements
Glad this helped uncover a performance issue, but I still have my issue of wanting an item tooltip on my sprite-button (with number, so choose-elem-button is insufficient)
Re: Apply built-in tooltips to custom GUI elements
This has been implemented as LuaGuiElement.elem_tooltip