Page 1 of 1
Don't exit the game if a saved GUI has incompatible styles.
Posted: Tue Apr 19, 2016 11:20 pm
by JasonC
If a GUI is saved with a game, and if the save is loaded but the mod's styles have been changed and are no longer compatible with the saved GUI, the game pops up an error dialog and then just exits completely.
Can it not do this? Can it just print a message to the console then simply not create the element or something?
It would make
this a non-issue. Currently it is not really possible to make updates to a mod that make styles incompatible with the old GUI, period, because it completely breaks all previously saved files that saved the old incompatible GUI's in them, and users can therefore never upgrade. Which is kinda no good.
Re: Don't exit the game if a saved GUI has incompatible styles.
Posted: Wed Apr 20, 2016 2:03 am
by Rseding91
Can you provide a small save (limit map to 50x50) and a sample mod with a single GUI element that reproduces the error? I'll get it taken care of for 0.13 if you can do that.
Re: Don't exit the game if a saved GUI has incompatible styles.
Posted: Wed Apr 20, 2016 3:53 am
by JasonC
Rseding91 wrote:Can you provide a small save (limit map to 50x50) and a sample mod with a single GUI element that reproduces the error? I'll get it taken care of for 0.13 if you can do that.
Example created at
https://github.com/JC3/StyleUpdateExample:
- style-update-example-1.0.0: The "first" version of a mod, which provides a GUI with a button.
- style-update-example-2.0.0: The "second" version, where the button and its style have been changed to a checkbox.
- style-update-example-gui-hidden: A game saved with version 1.0.0 and the GUI hidden.
- style-update-example-gui-displayed: A game saved with version 1.0.0 and the GUI displayed.
The mod adds a button to the top that says "toggle". Press it to hide/show a frame with another button on it. The button on that frame is the offending button here.
For instant gratification:
- Install version 2.0.0 of the mod.
- Load style-update-example-gui-displayed.
- The game will produce an error and exit.
The hidden GUI save won't have the issue since the GUI doesn't exist in the save.
A more "realistic" example:
- Install version 1.0.0 of the mod.
- Start a new game.
- Press the "toggle" button in the top left to show the GUI.
- Save the game.
- Update to version 2.0.0 of the mod.
- Load the game.
- The game will produce an error and exit.
The differences between 1.0.0 and 2.0.0 are marked in the 2.0.0 source. They are:
There is a workaround, by the way, so you're not
completely hosed.
I propose, for 0.13, that the behavior for incompatible styles be identical to the behavior for styles that no longer exist. But just to be clear: Only when loading from saves. The behavior on ".add()" is already different from the save load behavior (it displays the standard Lua error box and also doesn't exit the game) and that should probably remain unchanged because it helps during development.