-
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
Refactor features, overlays, and junction option groups #1422
Conversation
They were all entangled hence somewhat larger than expected commit.
Ensure mod options will always be set false if not validated.
Similar approach to CheckboxOption, but just a button.
- Move pathfind stats cb to overlays group - Split maint buttons in to two groups... - Tools group - Config group
@krzychu124 We're limited to saving as EDIT: We could store it as a global option = much more flexible, eg. we could use |
Yeah, global options might be a good idea to store this info |
Not if we get rid of On the other hand, we don't need load and save for globalconfig if we add event I'm not sure if you are going to change anything there but I can fix everything and create base for GlobalConfig options |
The scope property has a Note that currently the checkboxes are defined as static fields on the group classes; I wasn't sure at what point global config gets loaded, and also what happens if it's reloaded or reset eg. in-game via the buttons on Maintenance tab? Like, how will that affect the instance reference? |
I already replaced static access with generic, reset/reload can be solver with observer. I'll experiment with that and try to add basic support for it. We can improve it later, since I already have working solution for "allow-despawn" feature but without persistence layer 😕 |
ready for review |
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.
Looks ok 👍
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.
Looked through the changes, just minor naming
return SimulationAccuracy.MaxValue - value; | ||
} | ||
// See: OnAfterLoadData() and related methods | ||
private static bool _needUpdateRoutingManager = false; |
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.
Confusing naming. Routing manager NEEDS update? We or someone else should update routing manager? Who will update?
Suggested naming: _updateRoutingManagerFlag
| _routingManagerUpdateFlag
, or _invalidateRoutingManager
Missing xmldoc. Don't send to read code instead of writing 1line explanation.
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 have a hunch it might not even be necessary (ie. it can probably be completely removed) but need to check first... brb
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.
RoutingManager.OnAfterLoadData()
invokes RecalculateAll()
so I don't need the _needUpdateRoutingManager
stuff (during deserialisation, I can just ignore requests because post-deserialisation the RoutingManager
is going to do full recalc anyway).
However I noticed that RequestFullRecalculation()
is doing different stuff to RecalculateAll()
(nothing to do with this PR) so that might merit some investigation at future date.
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.
@kianzarrin Can you verify my assumptions in the comment above - that during deserialisation I don't need to trigger RequestFullRecalculation()
becuase routing manager will subseuqently do a RecalculateAll()
?
@@ -262,11 +303,11 @@ public bool MayPublishSegmentChanges() | |||
save[55] = OptionsMassEditTab.RoundAboutQuickFix_ParkingBanYieldR.Save(); | |||
|
|||
save[56] = PoliciesTab.NoDoubleCrossings.Save(); | |||
save[57] = PoliciesTab.DedicatedTurningLanes.Save(); | |||
save[57] = PoliciesTab_AtJunctionsGroup.DedicatedTurningLanes.Save(); |
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.
Naming. Save is an action to write something somewhere. What Save here doing is Serilalization, maybe Serialize
? if that's not a reserved name.
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.
Yeah, that naming is from the original CheckboxOption
before I started altering it. As it's just converting bool to byte maybe ToByte()
would be better name?
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 a task to #1356 to rename the methods.
The routing manager already does full recalc after deserialization so there's no need for options manager to queue that action
Actually it might be a commit before that but its in the PR |
thanks for heads up - investgating... |
Compiled mod for testing: TMPE.zip
Part of ongoing work for #1356 phase 2 - #1356 (comment)
This started out as just a refactor of the
Activated Features
option group, but it was heavily entangled withOverlays
andAt Junctions
option groups so they got refactored too. In the process noticed that there were some duplicateSet..
functions inMaintenanceTab
andPoliciesTab
, so they got chainsawed.CheckboxOption
Set..
andOn..Changed
functionsOptions.cs
toOptionsManager.cs
Fixes: #1423
Updates: #62