-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options API #1378
Add options API #1378
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some thoughts
return true; | ||
} | ||
catch (Exception ex) { | ||
ex.LogException(); | ||
|
||
// even though there was error, the options are now available for querying |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh .. are you sure about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. If the load method fails, the options will just have default values but TM:PE will still be fully operable.
The goal was to prevent other mods reading options either prior to options being set, or during save/load, or from main menu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But whats the point of playing with default options?
And what happens if I save the game with those defaults?
And what if another mod makes descisions based on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If its fine for krzy its fine for me though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't try to save anything if failed to load, that won't overwrite old data, so in case of a bug in load code it could be loaded after applying hotfix - IIRC game is cloning mod data container so even if you not longer have a mod, data will be migrated to new saves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to this PR, what would the difference be?
If the data fails to load, the LoadData()
method will still return false
just like it previously did, which results in loadingSucceeded = false
at the call site - that currently has no effect on whether SaveData()
gets invoked later.
I've created an issue to track the need to prevent data save should data fail to load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is ok, you can merge :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated based on review feedback |
return true; | ||
} | ||
catch (Exception ex) { | ||
ex.LogException(); | ||
|
||
// even though there was error, the options are now available for querying |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But whats the point of playing with default options?
And what happens if I save the game with those defaults?
And what if another mod makes descisions based on that?
return true; | ||
} | ||
catch (Exception ex) { | ||
ex.LogException(); | ||
|
||
// even though there was error, the options are now available for querying |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If its fine for krzy its fine for me though.
Fixes: #1376
Simple API for external mods to get TM:PE mod
Options
values. For example, if a mod needs to know which TMPE features are enabled, or get info on policy settings, icon theme, etc.Vague example:
Options are referenced by name, thus allowing us to alter names at later date whilst keeping API intact (a simple oldname -> newname lookup can be added on our side).
Options are accessed via reflection - while not super fast, it's reliable and allows us to easily handle possible future transition from option fields to properties, etc.
Thanks to @DaEgi01 for suggestion to use generics.