ModLib icon indicating copy to clipboard operation
ModLib copied to clipboard

Check if options were modified before asking to restart

Open MLNW opened this issue 5 years ago • 4 comments

At the moment simply opening the options to look at them and afterwards hitting Done opens up the dialogue asking to restart the game to make sure options are correctly loaded.

Since no options were changed it would make sense to forgo this dialog.

On a related note: Is it really necessary to restart the game every time an option is configured? Might make sense to make it configurable by a mod if certain settings force a reboot.

MLNW avatar Apr 17 '20 16:04 MLNW

The screen should already only restart if something was changed. The settings screen uses an undo/redo system to log the changes that have been made. If anything was changed (ie added to the undo stack) then it says it needs to restart. If the stack is empty, it just closes the window. I'll have to have a look and see if there are any phantom changes being made.

The restarting is legacy from when ModLib was part of Bannerlord Tweaks and enabling things required the game to restart to take effect. I have plans to add the functionality to tag which settings require a restart, and it will only restart if those settings were changed.

mipen avatar Apr 18 '20 05:04 mipen

Okay, then it must have been a bug. I think I remember that I tried out what happens when disabling a group of options. But I redid those changes myself. I'm guessing that is not taken into account.

Regarding the restart: sounds like you already had the same idea as I described.

MLNW avatar Apr 18 '20 06:04 MLNW

Yeah, toggling a setting on then off again will add two actions to the undo stack, which means that it was techincally changed, even if the end result is the same. It might be worth changing the implementation to instead save the state of the settings when the UI is opened then compare the two states when it is closed, but for now there are more pressing things that need to be added/fixed. I'll put this down as something to think about in the future.

mipen avatar Apr 18 '20 13:04 mipen

If not forcing a restart - can you add an event I can subscribe to when settings change? I pull once from ModLib on start and then store my settings in a separate state - to remove the hard link to modlib i load all the modlib settings through reflection. If you can fire an event, I can pull in the updated settings easily enough.

brandonm4 avatar Apr 19 '20 21:04 brandonm4