Improve tooltip moddability @ FFF318

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Improve tooltip moddability @ FFF318

Post by eradicator »

What?
With https://factorio.com/blog/post/fff-318 promising fancy new tooltips for vanilla i'd like to take the chance and grab some attention to moddability of those. Currently there are two methods for tooltip modding:

Rich Text
hacky proof of concept
tooltip_richtext.png
tooltip_richtext.png (304.32 KiB) Viewed 2053 times
Disabled choose-elem-button
tooltip_chose_elm.png
tooltip_chose_elm.png (266.4 KiB) Viewed 2053 times
Both methods have problems:

Rich Text while better than the plain text from pre-0.17 only offers very limited format control, but complete content control, and can be used on any type of gui element, not only buttons.

Disabled choose-elem-buttons automatically create standard tooltips and thus can not be extended with mod-specific information. They also can not be used on anything else like labels or sliders, switches etc.

So what?
So, i'd like to request more moddability for tooltips. There are two stages that this could be improved:

Stage1: Allow assigning a new "fancy multi-tooltip" of arbitrary composition to all LuaGuiElement types (or if difficult a limited subset). This means that it's up to the mod which tooltips should be shown, i.e. it should be possible to show a recipe alongside it's technology instead of it's products.

Stage2: Allow accessing tooltips as standard LuaGuiElements so they can be completely customized. As this needs to be performant for large numbers of tooltips on the same screen (i.e. Helmod/FactoryPlanner) i'm not sure how this would be done. Pre-creating all tooltips when a majority of them will never be shown seems inefficient. Using an event-based solution like "on_player_focused_element" to allow mods to dynamically create tooltips would incur multiplayer lag on tooltips which is also undesirable. And assigning a sandboxed function to each tooltip that dynamically creates it seems unrealistic, as does a custom "tooltip description language". So... given my lack of knowledge of engine internals and coding inexperience i regrettably don't really have a workable proposition for this :|.

Thank your for reading this far. And hopefully someone has useful feedback-feedback ;).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13202
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Improve tooltip moddability @ FFF318

Post by Rseding91 »

Allowing mods to define a Lua GUI elements tooltip as another Lua GUI element might be viable. It's definitely not a simple task though.

Making all tooltips use the LuaGuiElement system is never going to happen so that's just out automatically.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Improve tooltip moddability @ FFF318

Post by eradicator »

Rseding91 wrote:
Tue Oct 29, 2019 6:31 pm
Allowing mods to define a Lua GUI elements tooltip as another Lua GUI element might be viable. It's definitely not a simple task though.

Making all tooltips use the LuaGuiElement system is never going to happen so that's just out automatically.
Do you just mean that there would be two ways to define tooltips? Ofc i don't want to break existing mods.

Speaking of which, the FFF mentions that the system uses "Categories" in the background, so regarding "Stage 1" of the OP, would it be possible/realistic/useful to expose these so that mods can construct a "vanilla like" tooltip i.e. by specifying it as a table. And would that be less work/more performant than the "tooltip as a LuaGuiElement" approach?

A very rough example:

Code: Select all

a_gui_element.fancy_tooltips = { 
  direction = 'horizontal' --how to show several tooltips at once
  components = {{ --list of multiple tooltips (as described in the FFF for recipies+products)
    {category = 'root', --free text description field
     text = {'item-description.personal-roboport'}},
    {category  = 'placed-in-equipment-grid'
      name = 'personal-roboport'}, -- take the information from a known prototype?
    {category = 'consumes-electricity',
     something = '1kJ',
     something = '2MW',
    }},
  }
}
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Improve tooltip moddability @ FFF318

Post by Therenas »

I would appreciate the proposals here quite a bit. I would mainly make use of stage 1, so I can display proper recipe tooltips where I want them to be. I assume the new fancy multi-stage recipe tooltips would be useable for this too, as those are really nice and not reproduceable easily or at all by a mod.

Regarding the stage 2 of this, now that I think about it I assume the (old) vanilla recipe tooltips use a system similar to the GUI one themselves? Either way, we'd probably not need all GUI elements to be available for use in tooltips, only some basic ones like flows, tables, labels and sprites, if limiting it to those makes the implementation easier.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2916
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Improve tooltip moddability @ FFF318

Post by Optera »

Even being able to allow adding certain lines to existing tooltips would be enough for my purposes.
Namely displaying max_speed of all rolling stock and not just locomotives.

User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Improve tooltip moddability @ FFF318

Post by Therenas »

I just tried the workaround to not being able to have the nice tooltips. I created locked choose-elem-buttons instead of normal sprite-buttons. On an admittedly large set of 1500 buttons, it makes the creation time (for the whole function) go from 55ms to 850ms. Even on much smaller sets of 16 buttons, it goes from 2.7ms to 4.6ms. So that workaround is obviously not going to work. I assume that performance loss has nothing to do with the tooltips themselves, but more with the fact that choose-elem-buttons are not at all intended to be used this way. So this is another argument to why being able to put the tooltips on other elements might be needed.

User avatar
KiwiHawk
Filter Inserter
Filter Inserter
Posts: 254
Joined: Thu Jul 05, 2018 9:48 am
Contact:

Re: Improve tooltip moddability @ FFF318

Post by KiwiHawk »

Bump!

I'm working on improvements for Helmod. I'd like to create vanilla style tooltips for energy "recipes". Current tooltip:
HelmodTooltip.png
HelmodTooltip.png (72.01 KiB) Viewed 1256 times
I'd like to make it look more like this, but probably without details of products:
HelmodTooltip2.png
HelmodTooltip2.png (123.22 KiB) Viewed 1256 times
Dev for Bob's mods, Angel's mods, Helmod, Sea Block, Circuit Processing, Science Cost Tweaker.

Buy me a coffee

Post Reply

Return to “Modding interface requests”