@@ -53,7 +53,55 @@ public static class OptionsGeneralTab {
53
53
internal static void MakeSettings_General ( ExtUITabstrip tabStrip ) {
54
54
UIHelper panelHelper = tabStrip . AddTabPage ( T ( "Tab:General" ) ) ;
55
55
56
- UIHelperBase generalGroup = panelHelper . AddGroup ( T ( "Tab:General" ) ) ;
56
+ // Group: Localisation
57
+
58
+ // TODO: Add translation key "General.Group:Localisation"
59
+ UIHelperBase groupLocalisation = panelHelper . AddGroup ( T ( "General.Group:Localisation" ) ) ;
60
+ AddLanguageDropdown ( groupLocalisation ,
61
+ GlobalConfig . Instance . LanguageCode ) ;
62
+ // TODO: Ditch separate MPH vs. km/h setting; selected icon theme should determine that? #1221
63
+ AddMphCheckbox ( groupLocalisation ,
64
+ GlobalConfig . Instance . Main . DisplaySpeedLimitsMph ) ;
65
+ AddIconThemeDropdown ( groupLocalisation ,
66
+ GlobalConfig . Instance . Main . RoadSignTheme ) ;
67
+
68
+ // Group: Interface
69
+
70
+ // TODO: Add translation key "General.Group:Interface"
71
+ UIHelperBase groupInterface = panelHelper . AddGroup ( T ( "General.Group:Interface" ) ) ;
72
+ AddPositionLockSettings ( groupInterface ,
73
+ GlobalConfig . Instance . Main . MainMenuButtonPosLocked ,
74
+ GlobalConfig . Instance . Main . MainMenuPosLocked ) ;
75
+ AddUuiCheckbox ( groupInterface ,
76
+ GlobalConfig . Instance . Main . UseUUI ) ;
77
+ AddGuiScaleSlider ( groupInterface ,
78
+ GlobalConfig . Instance . Main . GuiScale ) ;
79
+ // TODO: These should either be both `opacity` or both `transparency`
80
+ AddGuiTransparencySliders ( groupInterface ,
81
+ GlobalConfig . Instance . Main . GuiOpacity ,
82
+ GlobalConfig . Instance . Main . OverlayTransparency ) ;
83
+ AddTutorialCheckbox ( groupInterface ,
84
+ GlobalConfig . Instance . Main . EnableTutorial ) ;
85
+
86
+ // Group: Simulation
87
+
88
+ UIHelperBase groupSimulation = panelHelper . AddGroup ( T ( "General.Group:Simulation" ) ) ;
89
+ AddSimAccuracyDropdown ( groupSimulation ,
90
+ ( int ) Options . simulationAccuracy ) ;
91
+ AddInstantEffectCheckbox ( groupSimulation ,
92
+ Options . instantEffects ) ;
93
+
94
+ // Group: Compatibility
95
+
96
+ // TODO: Add translation key "General.Group:Compatibility"
97
+ UIHelperBase groupCompatibility = panelHelper . AddGroup ( T ( "General.Group:Compatibility" ) ) ;
98
+ AddModCheckerCheckboxes ( groupCompatibility ,
99
+ GlobalConfig . Instance . Main . ScanForKnownIncompatibleModsAtStartup ,
100
+ GlobalConfig . Instance . Main . IgnoreDisabledMods ,
101
+ GlobalConfig . Instance . Main . ShowCompatibilityCheckErrorMessage ) ;
102
+ }
103
+
104
+ private static void AddLanguageDropdown ( UIHelperBase group , string ? currentLangCode ) {
57
105
string [ ] languageLabels = new string [ Translation . AvailableLanguageCodes . Count + 1 ] ;
58
106
languageLabels [ 0 ] = T ( "General.Dropdown.Option:Game language" ) ;
59
107
@@ -64,130 +112,152 @@ internal static void MakeSettings_General(ExtUITabstrip tabStrip) {
64
112
}
65
113
66
114
int languageIndex = 0 ;
67
- string curLangCode = GlobalConfig . Instance . LanguageCode ;
68
115
69
- if ( curLangCode != null ) {
70
- languageIndex = Translation . AvailableLanguageCodes . IndexOf ( curLangCode ) ;
116
+ if ( currentLangCode != null ) {
117
+ languageIndex = Translation . AvailableLanguageCodes . IndexOf ( currentLangCode ) ;
71
118
if ( languageIndex < 0 ) {
72
119
languageIndex = 0 ;
73
120
} else {
74
121
++ languageIndex ;
75
122
}
76
123
}
77
124
78
- _languageDropdown = generalGroup . AddDropdown (
125
+ _languageDropdown = group . AddDropdown (
79
126
text : T ( "General.Dropdown:Select language" ) + ":" ,
80
127
options : languageLabels ,
81
128
defaultSelection : languageIndex ,
82
129
eventCallback : OnLanguageChanged ) as UIDropDown ;
83
- _lockButtonToggle = generalGroup . AddCheckbox (
130
+ }
131
+
132
+ private static void AddMphCheckbox ( UIHelperBase group , bool DisplaySpeedLimitsMph ) {
133
+ _displayMphToggle = group . AddCheckbox (
134
+ text : Translation . SpeedLimits . Get ( "Checkbox:Display speed limits mph" ) ,
135
+ defaultValue : DisplaySpeedLimitsMph ,
136
+ eventCallback : OnDisplayMphChanged ) as UICheckBox ;
137
+ }
138
+
139
+ private static void AddIconThemeDropdown ( UIHelperBase group , string ? roadSignTheme ) {
140
+ string FormatThemeName ( string themeName ) {
141
+ return Translation . SpeedLimits . Get ( $ "RoadSignTheme:{ themeName } ") ;
142
+ }
143
+
144
+ var themeOptions = RoadSignThemes . ThemeNames
145
+ . Select ( FormatThemeName )
146
+ . ToArray ( ) ;
147
+ int selectedThemeIndex = RoadSignThemes . ThemeNames . FindIndex ( x => x == roadSignTheme ) ;
148
+ int defaultSignsThemeIndex = RoadSignThemes . FindDefaultThemeIndex ( GlobalConfig . Instance . Main . DisplaySpeedLimitsMph ) ;
149
+
150
+ _roadSignsThemeDropdown
151
+ = group . AddDropdown (
152
+ text : Translation . SpeedLimits . Get ( "General.Dropdown:Road signs theme" ) + ":" ,
153
+ options : themeOptions ,
154
+ defaultSelection : selectedThemeIndex >= 0 ? selectedThemeIndex : defaultSignsThemeIndex ,
155
+ eventCallback : OnRoadSignsThemeChanged ) as UIDropDown ;
156
+ _roadSignsThemeDropdown . width *= 2.0f ;
157
+ }
158
+
159
+ private static void AddPositionLockSettings ( UIHelperBase group , bool buttonLocked , bool toolbarLocked ) {
160
+ _lockButtonToggle = group . AddCheckbox (
84
161
text : T ( "General.Checkbox:Lock main menu button position" ) ,
85
- defaultValue : GlobalConfig . Instance . Main . MainMenuButtonPosLocked ,
162
+ defaultValue : buttonLocked ,
86
163
eventCallback : OnLockButtonChanged ) as UICheckBox ;
87
- _lockMenuToggle = generalGroup . AddCheckbox (
164
+
165
+ _lockMenuToggle = group . AddCheckbox (
88
166
text : T ( "General.Checkbox:Lock main menu window position" ) ,
89
- defaultValue : GlobalConfig . Instance . Main . MainMenuPosLocked ,
167
+ defaultValue : toolbarLocked ,
90
168
eventCallback : OnLockMenuChanged ) as UICheckBox ;
169
+ }
91
170
92
- _useUUI = generalGroup . AddCheckbox (
171
+ private static void AddUuiCheckbox ( UIHelperBase group , bool useUUI ) {
172
+ _useUUI = group . AddCheckbox (
93
173
text : T ( "General.Checkbox:Use UnifiedUI" ) ,
94
- defaultValue : GlobalConfig . Instance . Main . UseUUI ,
174
+ defaultValue : useUUI ,
95
175
eventCallback : OnUseUUIChanged ) as UICheckBox ;
176
+ }
96
177
97
- _guiScaleSlider = generalGroup . AddSlider (
178
+ private static void AddGuiScaleSlider ( UIHelperBase group , float guiScale ) {
179
+ _guiScaleSlider = group . AddSlider (
98
180
text : T ( "General.Slider:GUI scale" ) + ":" ,
99
181
min : 50 ,
100
182
max : 200 ,
101
183
step : 5 ,
102
- defaultValue : GlobalConfig . Instance . Main . GuiScale ,
184
+ defaultValue : guiScale ,
103
185
eventCallback : OnGuiScaleChanged ) as UISlider ;
104
186
_guiScaleSlider . parent . Find < UILabel > ( "Label" ) . width = 500 ;
187
+ }
105
188
106
- _guiOpacitySlider = generalGroup . AddSlider (
189
+ private static void AddGuiTransparencySliders ( UIHelperBase group , byte guiOpacity , byte overlayTransparency ) {
190
+ _guiOpacitySlider = group . AddSlider (
107
191
text : T ( "General.Slider:Window transparency" ) + ":" ,
108
192
min : 0 ,
109
193
max : 100 ,
110
194
step : 5 ,
111
- defaultValue : GlobalConfig . Instance . Main . GuiOpacity ,
195
+ defaultValue : guiOpacity ,
112
196
eventCallback : OnGuiOpacityChanged ) as UISlider ;
113
197
_guiOpacitySlider . parent . Find < UILabel > ( "Label" ) . width = 500 ;
114
198
115
- _overlayTransparencySlider = generalGroup . AddSlider (
199
+ _overlayTransparencySlider = group . AddSlider (
116
200
text : T ( "General.Slider:Overlay transparency" ) + ":" ,
117
201
min : 0 ,
118
202
max : 100 ,
119
203
step : 5 ,
120
- defaultValue : GlobalConfig . Instance . Main . OverlayTransparency ,
204
+ defaultValue : overlayTransparency ,
121
205
eventCallback : OnOverlayTransparencyChanged ) as UISlider ;
122
206
_overlayTransparencySlider . parent . Find < UILabel > ( "Label" ) . width = 500 ;
123
- _enableTutorialToggle = generalGroup . AddCheckbox (
207
+ }
208
+
209
+ private static void AddTutorialCheckbox ( UIHelperBase group , bool enableTutorial ) {
210
+ _enableTutorialToggle = group . AddCheckbox (
124
211
T ( "General.Checkbox:Enable tutorials" ) ,
125
- GlobalConfig . Instance . Main . EnableTutorial ,
212
+ enableTutorial ,
126
213
OnEnableTutorialsChanged ) as UICheckBox ;
127
- _showCompatibilityCheckErrorToggle
128
- = generalGroup . AddCheckbox (
129
- T ( "General.Checkbox:Notify me about TM:PE startup conflicts" ) ,
130
- GlobalConfig . Instance . Main . ShowCompatibilityCheckErrorMessage ,
131
- OnShowCompatibilityCheckErrorChanged ) as UICheckBox ;
214
+ }
215
+
216
+ private static void AddModCheckerCheckboxes ( UIHelperBase group , bool scanMods , bool ignoreDisabled , bool reportUnexpected ) {
132
217
_scanForKnownIncompatibleModsToggle
133
- = generalGroup . AddCheckbox (
134
- Translation . ModConflicts . Get ( "Checkbox:Scan for known incompatible mods on startup" ) ,
135
- GlobalConfig . Instance . Main . ScanForKnownIncompatibleModsAtStartup ,
136
- OnScanForKnownIncompatibleModsChanged ) as UICheckBox ;
137
- _ignoreDisabledModsToggle = generalGroup . AddCheckbox (
138
- text : Translation . ModConflicts . Get ( "Checkbox:Ignore disabled mods" ) ,
139
- defaultValue : GlobalConfig . Instance . Main . IgnoreDisabledMods ,
140
- eventCallback : OnIgnoreDisabledModsChanged ) as UICheckBox ;
218
+ = group . AddCheckbox (
219
+ Translation . ModConflicts . Get ( "Checkbox:Scan for known incompatible mods on startup" ) ,
220
+ scanMods ,
221
+ OnScanForKnownIncompatibleModsChanged ) as UICheckBox ;
222
+
223
+ _ignoreDisabledModsToggle
224
+ = group . AddCheckbox (
225
+ text : Translation . ModConflicts . Get ( "Checkbox:Ignore disabled mods" ) ,
226
+ defaultValue : ignoreDisabled ,
227
+ eventCallback : OnIgnoreDisabledModsChanged ) as UICheckBox ;
141
228
Options . Indent ( _ignoreDisabledModsToggle ) ;
142
229
143
- // General: Speed Limits
144
- SetupSpeedLimitsPanel ( generalGroup ) ;
230
+ _showCompatibilityCheckErrorToggle
231
+ = group . AddCheckbox (
232
+ T ( "General.Checkbox:Notify me about TM:PE startup conflicts" ) ,
233
+ reportUnexpected ,
234
+ OnShowCompatibilityCheckErrorChanged ) as UICheckBox ;
235
+ }
145
236
146
- // General: Simulation
147
- UIHelperBase simGroup = panelHelper . AddGroup ( T ( "General.Group:Simulation" ) ) ;
237
+
238
+ private static void AddSimAccuracyDropdown ( UIHelperBase group , int simulationAccuracy ) {
148
239
string [ ] simPrecisionOptions = new [ ] {
149
240
T ( "General.Dropdown.Option:Very low" ) ,
150
241
T ( "General.Dropdown.Option:Low" ) ,
151
242
T ( "General.Dropdown.Option:Medium" ) ,
152
243
T ( "General.Dropdown.Option:High" ) ,
153
244
T ( "General.Dropdown.Option:Very high" ) ,
154
245
} ;
155
- _simulationAccuracyDropdown = simGroup . AddDropdown (
156
- text : T ( "General.Dropdown:Simulation accuracy" ) + ":" ,
157
- options : simPrecisionOptions ,
158
- defaultSelection : ( int ) Options . simulationAccuracy ,
159
- eventCallback : OnSimulationAccuracyChanged ) as UIDropDown ;
160
246
161
- _instantEffectsToggle = simGroup . AddCheckbox (
162
- text : T ( "General.Checkbox:Apply AI changes right away" ) ,
163
- defaultValue : Options . instantEffects ,
164
- eventCallback : OnInstantEffectsChanged ) as UICheckBox ;
247
+ _simulationAccuracyDropdown
248
+ = group . AddDropdown (
249
+ text : T ( "General.Dropdown:Simulation accuracy" ) + ":" ,
250
+ options : simPrecisionOptions ,
251
+ defaultSelection : simulationAccuracy ,
252
+ eventCallback : OnSimulationAccuracyChanged ) as UIDropDown ;
165
253
}
166
254
167
- private static void SetupSpeedLimitsPanel ( UIHelperBase generalGroup ) {
168
- Main mainConfig = GlobalConfig . Instance . Main ;
169
-
170
- _displayMphToggle = generalGroup . AddCheckbox (
171
- text : Translation . SpeedLimits . Get ( "Checkbox:Display speed limits mph" ) ,
172
- defaultValue : mainConfig . DisplaySpeedLimitsMph ,
173
- eventCallback : OnDisplayMphChanged ) as UICheckBox ;
174
-
175
- string FormatThemeName ( string themeName ) {
176
- return Translation . SpeedLimits . Get ( $ "RoadSignTheme:{ themeName } ") ;
177
- }
178
-
179
- var themeOptions = RoadSignThemes . ThemeNames
180
- . Select ( FormatThemeName )
181
- . ToArray ( ) ;
182
- int selectedThemeIndex = RoadSignThemes . ThemeNames . FindIndex ( x => x == mainConfig . RoadSignTheme ) ;
183
- int defaultSignsThemeIndex = RoadSignThemes . FindDefaultThemeIndex ( GlobalConfig . Instance . Main . DisplaySpeedLimitsMph ) ;
184
- _roadSignsThemeDropdown
185
- = generalGroup . AddDropdown (
186
- text : Translation . SpeedLimits . Get ( "General.Dropdown:Road signs theme" ) + ":" ,
187
- options : themeOptions ,
188
- defaultSelection : selectedThemeIndex >= 0 ? selectedThemeIndex : defaultSignsThemeIndex ,
189
- eventCallback : OnRoadSignsThemeChanged ) as UIDropDown ;
190
- _roadSignsThemeDropdown . width *= 2.0f ;
255
+ private static void AddInstantEffectCheckbox ( UIHelperBase group , bool instantEffects ) {
256
+ _instantEffectsToggle
257
+ = group . AddCheckbox (
258
+ text : T ( "General.Checkbox:Apply AI changes right away" ) ,
259
+ defaultValue : instantEffects ,
260
+ eventCallback : OnInstantEffectsChanged ) as UICheckBox ;
191
261
}
192
262
193
263
private static void OnLanguageChanged ( int newLanguageIndex ) {
0 commit comments