Setting a style by name on a LuaGuiElement that already has manual style overrides removes the overrides - but only after save/load.
Expected behavior
Gui apperance should not be altered by save/load cycles.
Explanation
I'm using on_gui_changed_* events to change the style of textboxes to 'invalid_value_textfield' when the user inputs garbage, and back to normal when the value becomes ok. But because the textfield had a fxied width set upon creation i noticed that this resets the fixed width - but only if the user saves/loads while the gui is still open. I don't want to have to create two seperate gui style prototypes for every text field of non-standard width...
Reproduction
- Use the code.
- Save the game.
- Load the game.
- See how the gui changed.
Code: Select all
/c
local p = game.player
p.gui.center.clear()
local f = p.gui.center.add{
type = 'frame'
}
f.style.width = 190
local x1 = f.add{
type = 'textfield',
text = 'Short text',
}
x1.style.width = 80
x1.style.minimal_width = 10
x1.style.horizontally_squashable = true
local x2 = f.add{
type = 'textfield',
text = 'Short text',
}
x2.style.width = 80
x2.style = 'textbox' --[[this triggers the bug]]