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

Tristate toggle #1675

Merged
merged 19 commits into from
Nov 16, 2022
Merged

Tristate toggle #1675

merged 19 commits into from
Nov 16, 2022

Conversation

kianzarrin
Copy link
Collaborator

@kianzarrin kianzarrin commented Oct 11, 2022

latest-branch-build.zip

fixes: #1671
see issue for details.

you can review first 2 commits individually:
1st- added extension for UIHelper to ensure type safety and convenience.
2nd- Added interface to propagate option dependencies (E.g.: enter blocked junction depends on junction restrictions).
this used to only work with checkbox but now it also works with tristate checkbox.

other commits:
- Created tristate toggle option
- if user moves mouse over the tristate sprite, tooltip is `yes no N/A`. 
but if user moves mouse over the text label, the tooltip explain what the option does.

Test:
I tested propagation of dependencies also work.

test code:

diff --git a/TLM/TLM/State/OptionsTabs/PoliciesTab_RoundaboutsGroup.cs b/TLM/TLM/State/OptionsTabs/PoliciesTab_RoundaboutsGroup.cs
index 387cc6a3..c11dc8ef 100644
--- a/TLM/TLM/State/OptionsTabs/PoliciesTab_RoundaboutsGroup.cs
+++ b/TLM/TLM/State/OptionsTabs/PoliciesTab_RoundaboutsGroup.cs
@@ -57,7 +57,12 @@ namespace TrafficManager.State {
             };
 
         public static CheckboxOption RoundAboutQuickFix_ParkingBanYieldR =
-            new (nameof(Options.RoundAboutQuickFix_ParkingBanYieldR), Options.PersistTo.Savegame) {
+            new (nameof(Options.RoundAboutQuickFix_ParkingBanYieldR), Options.PersistTo.Global) {
+                Label = "Roundabout.Option:Put parking ban on roundabout branches",
+            };
+
+        public static TriStateCheckboxOption RoundAboutQuickFix_ParkingBanYieldR2 =
+            new(nameof(Options.RoundAboutQuickFix_ParkingBanYieldR), Options.PersistTo.Global) {
                 Label = "Roundabout.Option:Put parking ban on roundabout branches",
             };
 
@@ -85,6 +90,8 @@ namespace TrafficManager.State {
                     .PropagateTrueTo(MaintenanceTab_FeaturesGroup.ParkingRestrictionsEnabled);
                 RoundAboutQuickFix_ParkingBanYieldR
                     .PropagateTrueTo(MaintenanceTab_FeaturesGroup.ParkingRestrictionsEnabled);
+                RoundAboutQuickFix_ParkingBanYieldR2
+                    .PropagateTrueTo(MaintenanceTab_FeaturesGroup.ParkingRestrictionsEnabled);
             }
             catch (Exception ex) {
                 ex.LogException();
@@ -105,6 +112,7 @@ namespace TrafficManager.State {
             RoundAboutQuickFix_RealisticSpeedLimits.AddUI(group);
             RoundAboutQuickFix_ParkingBanMainR.AddUI(group);
             RoundAboutQuickFix_ParkingBanYieldR.AddUI(group);
+            RoundAboutQuickFix_ParkingBanYieldR2.AddUI(group);
         }
 
         private static string T(string key) => Translation.Options.Get(key);

@kianzarrin kianzarrin self-assigned this Oct 14, 2022
@kianzarrin kianzarrin added UI User interface updates Settings Road config, mod options, config xml labels Oct 14, 2022
@kvakvs
Copy link
Collaborator

kvakvs commented Oct 16, 2022

Is this used anywhere in the UI, how to test?

@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Oct 16, 2022

Is this used anywhere in the UI, how to test?

You need to type test code like the one I gave you on discord. also attached a test code in the description of this PR

What do you want to test?

@kianzarrin
Copy link
Collaborator Author

should I squash these two commits to the second commit and force push?
43a119a
66f958f
this way all commits relating to propagation can be reviewed as one commit.

@kvakvs
Copy link
Collaborator

kvakvs commented Oct 16, 2022

Is this used anywhere in the UI, how to test?

You need to type test code like the one I gave you on discord. also attached a test code in the description of this PR
What do you want to test?

I want to see where this is used. Are you merging unused code?

@kianzarrin
Copy link
Collaborator Author

Are you merging unused code?

yes. next step is cleanup roundabout/high priority polices but that would be too much for this PR.

@krzychu124 krzychu124 self-requested a review November 11, 2022 15:12
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.

Tested with example code, seems to be working ok, but it is not disabled in the main menu as the other checkboxes

@kianzarrin
Copy link
Collaborator Author

@krzychu124 fixed disabled color
image

@kianzarrin kianzarrin merged commit 1fdf0f7 into master Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Settings Road config, mod options, config xml UI User interface updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tri-state toggle in options
3 participants