Skip to content
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 remainder of Policies tab groups #1455

Merged
merged 9 commits into from
Mar 12, 2022

Conversation

originalfoo
Copy link
Member

@originalfoo originalfoo commented Mar 4, 2022

Compiled mod for testing: TMPE.zip

Part of ongoing work on #1356 phase 2.

This completes phase 2 refactor of all mod options groups.

Closes: #62

@originalfoo originalfoo added UI User interface updates code cleanup Refactor code, remove old code, improve maintainability Settings Road config, mod options, config xml labels Mar 4, 2022
@originalfoo originalfoo added this to the 11.6.5.1 milestone Mar 4, 2022
@originalfoo originalfoo self-assigned this Mar 4, 2022
@originalfoo originalfoo changed the title Refactor remainder of policies tab groups Refactor remainder of Policies tab groups Mar 4, 2022
Copy link
Member

@krzychu124 krzychu124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works in game without any noticeable issues 👍

Copy link
Collaborator

@kvakvs kvakvs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questioning why Propagate*To can fail

=> SteamHelper.IsDLCOwned(SteamHelper.DLC.NaturalDisastersDLC);

internal static void AddUI(UIHelperBase tab) {
if (!HasNaturalDisastersDLC) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be a good idea to show the group caption at all times, but then if DLC is not owned, add a text label explaining that a DLC is required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm thinking of doing that in later iteration once I add some more UI components.

EvacBussesMayIgnoreRules.AddUI(group);
}

private static bool NaturalDisastersDlcValidator(bool desired, out bool result) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this exists? Confusing function: updates some out variable and returns true? Move the logic to the caller.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a guard in central location at the moment. I'll probably change that in 11.6.5.2 branch but depends on how things go with converting Options to instance-based.

private static UIDropDown _vehicleRestrictionsAggressionDropDown;

static PoliciesTab_OnRoadsGroup() {
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this can fail? It should never fail in my opinion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Krzychu made same comment recently. The reason I do it is because if anything goes wrong in a static constructor it causes cascading failure in C:SL which does not guard against that eventuality. That in turn results in user's game config file being wiped, all mods are then disabled, paradox account reset, etc.

Errors are most likely to creep in during dev and test phase - while they will obviously get fixed it's a complete PITA to have to re-enable 140 mods, espeically when some mods (Ambient Sounds Tuner in particular) need enabling last to prevent further settings loss. So the try..catch is really just to protect myself from my own stupid bugs during dev & test :)

@@ -121,14 +121,14 @@ public class RoundaboutMassEdit {
}

private static void FixRulesRoundabout(ushort segmentId, bool startNode) {
if (OptionsMassEditTab.RoundAboutQuickFix_PrioritySigns) {
if (Options.RoundAboutQuickFix_PrioritySigns) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change? performance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, but just as an interim measure (eg. as you mentioned in another PR, harmony could be used to remove the reflection bottleneck).

For now my main goal is just to get everything in options as consistent as possible. In next stage I'm seeking to make the options fields instance-based; currently they are static. Once instance-based, it will be appropriate to define defaults at the field level (currently defaults are being set in OptionsManager.LoadData() as an interim workaround for static fields in Options.cs), and there will be a whole bunch of other changes.

@kianzarrin
Copy link
Collaborator

Path of evil is default value in new game. is this expected? I remember it used to be minor complaints.
image

@kianzarrin
Copy link
Collaborator

Also "vehicles going straight on can change lane on junctions" is on by default. Isn't that illegal in the real world?
image

@originalfoo
Copy link
Member Author

originalfoo commented Mar 12, 2022

Path of evil is default value in new game. is this expected? I remember it used to be minor complaints.

Good catch!

Looking at Options.cs before I started altering stuff:

public static int recklessDrivers = 3;

new[] {
    Translation.Options.Get("Gameplay.Dropdown.Option:Path Of Evil (10%)"), // 0 
    Translation.Options.Get("Gameplay.Dropdown.Option:Rush Hour (5%)"), // 1
    Translation.Options.Get("Gameplay.Dropdown.Option:Minor Complaints (2%)"), // 2
    Translation.Options.Get("Gameplay.Dropdown.Option:Holy City (0%)"), // 3
},

So yeah, should be Holy City (0%). Will send commit to fix.

Also "vehicles going straight on can change lane on junctions" is on by default. Isn't that illegal in the real world?

Another good catch! Should be off by default, will update in next commit.

@originalfoo
Copy link
Member Author

@kianzarrin Fixed bugs you spotted.

@originalfoo
Copy link
Member Author

@kvakvs Is there any changes you specifically want in this PR or can comments above be left until next phase of updates to options stuff?

Copy link
Collaborator

@kvakvs kvakvs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the code diff earlier. Its fine

@originalfoo originalfoo merged commit 02e8fe2 into master Mar 12, 2022
@originalfoo originalfoo deleted the refactor-policies-tab-groups branch March 12, 2022 22:15
@kianzarrin
Copy link
Collaborator

kianzarrin commented Mar 12, 2022

I checked WS TMPE and this build and found more differences. Not sure if its withing the scope of this PR.

  • Individual driving style used to be on by default
  • buses may ignore lane arrows used to be off by default

Old values in new game:
Screenshot (34)
Screenshot (36)
Screenshot (37)
Screenshot (38)

@originalfoo
Copy link
Member Author

urg, 1 sec, will send PR to fix

@originalfoo
Copy link
Member Author

buses may ignore lane arrows used to be off by default

Yeah, that was causing constant trickle of support so it was changed in this PR.

Can change it back to off by default if desired. @krzychu124 what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Refactor code, remove old code, improve maintainability Settings Road config, mod options, config xml UI User interface updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple users report roundabout quick-setup not working Changes to mod settings UI
4 participants