factoriolib / flib

A set of high-quality, commonly-used utilities for creating Factorio mods.
https://mods.factorio.com/mod/flib
MIT License
61 stars 15 forks source link

Template style_mods are ignored if an element also has style_mods #22

Closed mgkr closed 3 years ago

mgkr commented 3 years ago

If I have something like

gui_util.add_templates{
  header_button = {type="button", style="dark_button", style_mods={width=80, font_color=core_styles.bold_font_color}}
}

and then somewhere else have an element like

{template="header_button", style_mods={width=200, maximal_width=500},caption="Name"}

Then the template style_mods (specifically font_color) no longer works - I assume the whole template style_mod section is simply ignored or overwritten by the element style_mod.

My expectation would be that individual element style_mod values would overwrite the corresponding template style_mod values - and let the rest (of the template style_mod) carry through. I.e. a union of the two - with the element style_mod winning if there is overlap.

raiguard commented 3 years ago

Yes... this is a deficiency I've known about for a while. However, I'm not going to fix it, because I'm rewriting the GUI module and element templates are going away entirely. I recommend avoiding them and instead using a builder function or other alternative.

mgkr commented 3 years ago

I recommend avoiding them and instead using a builder function or other alternative.

Woa - Thanks for the heads up!

Any approximate timeframe idea for that re-write? Just so I have an idea if I should wait for it - or "roll-my-own" (I'm in no rush)

raiguard commented 3 years ago

Lol, the rewrite is hard. I am currently on my seventh attempt, with the previous attempts ranging from slightly more than the current module to a full-blown reactive GUI framework. My newest attempt is a streamlined version of the current module, with some helper functions for updating existing GUIs and things related to lists.

The rewrite won't come out until after Factorio 1.1 releases, since it relies on new GUI-related features coming in that version.