1919using System . Collections . Generic ;
2020using Orts . Simulation . RollingStocks ;
2121using ORTS . Common . Input ;
22- using ORTS . Settings ;
22+ using ORTS . Common ;
2323
2424namespace Orts . Viewer3D . WebServices . SwitchPanel
2525{
@@ -42,79 +42,68 @@ public void init(UserCommand userCommand)
4242
4343 switch ( userCommand )
4444 {
45- case ORTS . Common . Input . UserCommand . ControlLight :
46- init1 ( userCommand , "Cabin Light" ) ;
47- break ;
48-
49- case ORTS . Common . Input . UserCommand . ControlAlerter :
50- init1 ( userCommand , "Reset" ) ;
51- break ;
52-
53- case ORTS . Common . Input . UserCommand . GameMultiPlayerDispatcher :
54- init1 ( userCommand , "Map" ) ;
55- break ;
56-
5745 case ORTS . Common . Input . UserCommand . ControlBatterySwitchClose :
5846 switch ( locomotive . LocomotivePowerSupply . BatterySwitch . Mode )
5947 {
6048 case Simulation . RollingStocks . SubSystems . PowerSupplies . BatterySwitch . ModeType . AlwaysOn :
61- init0 ( ORTS . Common . Input . UserCommand . ControlBatterySwitchClose , " Battery Switch" ) ;
49+ init0 ( ORTS . Common . Input . UserCommand . ControlBatterySwitchClose , GetParticularString ( "SwitchPanel" , " Battery switch" ) ) ;
6250 break ;
6351 case Simulation . RollingStocks . SubSystems . PowerSupplies . BatterySwitch . ModeType . Switch :
64- init1 ( ORTS . Common . Input . UserCommand . ControlBatterySwitchClose , " Battery Switch" ) ;
52+ init1 ( ORTS . Common . Input . UserCommand . ControlBatterySwitchClose , GetParticularString ( "SwitchPanel" , " Battery switch" ) ) ;
6553 break ;
6654 case Simulation . RollingStocks . SubSystems . PowerSupplies . BatterySwitch . ModeType . PushButtons :
67- init2 ( ORTS . Common . Input . UserCommand . ControlBatterySwitchClose , ORTS . Common . Input . UserCommand . ControlBatterySwitchOpen , " Battery Switch" ) ;
55+ init2 ( ORTS . Common . Input . UserCommand . ControlBatterySwitchClose , ORTS . Common . Input . UserCommand . ControlBatterySwitchOpen , GetParticularString ( "SwitchPanel" , " Battery switch" ) ) ;
6856 break ;
6957 }
7058 break ;
7159
7260 case ORTS . Common . Input . UserCommand . ControlMasterKey :
7361 if ( locomotive . LocomotivePowerSupply . MasterKey . Mode == Simulation . RollingStocks . SubSystems . PowerSupplies . MasterKey . ModeType . AlwaysOn )
74- init0 ( ORTS . Common . Input . UserCommand . ControlMasterKey , " Master Key" ) ;
62+ init0 ( ORTS . Common . Input . UserCommand . ControlMasterKey , GetParticularString ( "SwitchPanel" , " Master key" ) ) ;
7563 else
76- init1 ( ORTS . Common . Input . UserCommand . ControlMasterKey , " Master Key" ) ;
64+ init1 ( ORTS . Common . Input . UserCommand . ControlMasterKey , GetParticularString ( "SwitchPanel" , " Master key" ) ) ;
7765 break ;
7866
7967 case ORTS . Common . Input . UserCommand . ControlCircuitBreakerClosingOrder :
8068 if ( ( locomotive as MSTSElectricLocomotive ) . ElectricPowerSupply . CircuitBreaker . ScriptName == "Automatic" )
81- init0 ( ORTS . Common . Input . UserCommand . ControlCircuitBreakerClosingOrder , " Circuit Breaker" ) ;
69+ init0 ( ORTS . Common . Input . UserCommand . ControlCircuitBreakerClosingOrder , GetParticularString ( "SwitchPanel" , " Circuit breaker" ) ) ;
8270 else
83- init1 ( ORTS . Common . Input . UserCommand . ControlCircuitBreakerClosingOrder , " Circuit Breaker" ) ;
71+ init1 ( ORTS . Common . Input . UserCommand . ControlCircuitBreakerClosingOrder , GetParticularString ( "SwitchPanel" , " Circuit breaker" ) ) ;
8472 break ;
8573
8674 case ORTS . Common . Input . UserCommand . ControlGearUp :
8775 if ( ( locomotive as MSTSDieselLocomotive ) . DieselEngines . HasGearBox )
88- init2 ( ORTS . Common . Input . UserCommand . ControlGearUp , ORTS . Common . Input . UserCommand . ControlGearDown , " Gear") ;
76+ init2 ( ORTS . Common . Input . UserCommand . ControlGearUp , ORTS . Common . Input . UserCommand . ControlGearDown , GetParticularString ( "SwitchPanel" , " Gear") ) ;
8977 else
90- init0 ( ORTS . Common . Input . UserCommand . ControlGearUp , " Gear") ;
78+ init0 ( ORTS . Common . Input . UserCommand . ControlGearUp , GetParticularString ( "SwitchPanel" , " Gear") ) ;
9179 break ;
9280
9381 case ORTS . Common . Input . UserCommand . ControlTractionCutOffRelayClosingOrder :
9482 if ( ( locomotive as MSTSDieselLocomotive ) . DieselPowerSupply . TractionCutOffRelay . ScriptName == "Automatic" )
95- init0 ( ORTS . Common . Input . UserCommand . ControlTractionCutOffRelayClosingOrder , "traction cut-off") ;
83+ init0 ( ORTS . Common . Input . UserCommand . ControlTractionCutOffRelayClosingOrder , GetParticularString ( "SwitchPanel" , "Traction cut-off") ) ;
9684 else
97- init1 ( ORTS . Common . Input . UserCommand . ControlTractionCutOffRelayClosingOrder , "traction cut-off") ;
85+ init1 ( ORTS . Common . Input . UserCommand . ControlTractionCutOffRelayClosingOrder , GetParticularString ( "SwitchPanel" , "Traction cut-off") ) ;
9886 break ;
9987
10088 case ORTS . Common . Input . UserCommand . DisplayNextStationWindow :
10189 Orts . Simulation . Activity act = Viewer . Simulator . ActivityRun ;
10290 if ( ( act != null ) && ( act . EventList . Count ) > 0 )
103- init1 ( ORTS . Common . Input . UserCommand . DisplayNextStationWindow , "Activity" ) ;
91+ init1 ( ORTS . Common . Input . UserCommand . DisplayNextStationWindow , GetParticularStringAttribute . GetParticularPrettyName ( userCommand , "SwitchPanel" ) ) ;
10492 else
105- init0 ( ORTS . Common . Input . UserCommand . DisplayNextStationWindow , "Activity" ) ;
93+ init0 ( ORTS . Common . Input . UserCommand . DisplayNextStationWindow , GetParticularStringAttribute . GetParticularPrettyName ( userCommand , "SwitchPanel" ) ) ;
10694 break ;
10795
10896 case ORTS . Common . Input . UserCommand . ControlHeadlightIncrease :
109- init2 ( ORTS . Common . Input . UserCommand . ControlHeadlightIncrease , ORTS . Common . Input . UserCommand . ControlHeadlightDecrease , " Front Light") ;
97+ init2 ( ORTS . Common . Input . UserCommand . ControlHeadlightIncrease , ORTS . Common . Input . UserCommand . ControlHeadlightDecrease , GetParticularString ( "SwitchPanel" , " Front Light") ) ;
11098 break ;
11199
112100 case ORTS . Common . Input . UserCommand . ControlForwards :
113- init2 ( ORTS . Common . Input . UserCommand . ControlForwards , ORTS . Common . Input . UserCommand . ControlBackwards , " Direction") ;
101+ init2 ( ORTS . Common . Input . UserCommand . ControlForwards , ORTS . Common . Input . UserCommand . ControlBackwards , GetParticularString ( "SwitchPanel" , " Direction") ) ;
114102 break ;
115103
116104 default :
117105 string description = determineDescription ( userCommand ) ;
106+
118107 init1 ( userCommand , description ) ;
119108 break ;
120109 }
@@ -127,43 +116,48 @@ public void initEmpty()
127116
128117 private string determineDescription ( UserCommand userCommand )
129118 {
130- string description = InputSettings . GetPrettyCommandName ( userCommand ) ;
131-
132- if ( description . StartsWith ( "Control " ) )
133- description = description . Substring ( "Control " . Length ) ;
134- if ( description . StartsWith ( "Game " ) )
135- description = description . Substring ( "Game " . Length ) ;
136- if ( description . StartsWith ( "Display " ) )
137- description = description . Substring ( "Display " . Length ) ;
138-
139- if ( description . EndsWith ( " Push Button" ) )
140- description = description . Substring ( 0 , description . Length - " Push Button" . Length ) ;
141- if ( description . EndsWith ( " Mode" ) )
142- description = description . Substring ( 0 , description . Length - " Mode" . Length ) ;
143- if ( description . EndsWith ( " Window" ) )
144- description = description . Substring ( 0 , description . Length - " Window" . Length ) ;
119+ string description = GetParticularStringAttribute . GetParticularPrettyName ( userCommand , "SwitchPanel" ) ;
120+
121+ description = capitalize ( Viewer . Catalog . GetParticularString ( "SwitchPanel" , description ) ) ;
145122
146123 return description ;
147124 }
148125
126+ private string GetParticularString ( string context , string description )
127+ {
128+ return capitalize ( Viewer . Catalog . GetParticularString ( context , description ) ) ;
129+ }
130+
131+ private string capitalize ( string value )
132+ {
133+ if ( value . Length > 0 )
134+ {
135+ return char . ToUpper ( value [ 0 ] ) + value . Substring ( 1 ) ;
136+ }
137+ else
138+ {
139+ return "" ;
140+ }
141+ }
142+
149143 // almost empty non functioning button
150- public void init0 ( UserCommand userCommand = ORTS . Common . Input . UserCommand . GamePauseMenu , string description = "" )
144+ private void init0 ( UserCommand userCommand = ORTS . Common . Input . UserCommand . GamePauseMenu , string description = "" )
151145 {
152146 NoOffButtons = 0 ;
153147 UserCommand = new UserCommand [ ] { userCommand } ;
154148 Description = description ;
155149 }
156150
157151 // 1 button
158- public void init1 ( UserCommand userCommand , string description )
152+ private void init1 ( UserCommand userCommand , string description )
159153 {
160154 NoOffButtons = 1 ;
161155 UserCommand = new UserCommand [ ] { userCommand } ;
162156 Description = description ;
163157 }
164158
165159 // 2 buttons
166- public void init2 ( UserCommand userCommandTop , UserCommand userCommandBottom , string description )
160+ private void init2 ( UserCommand userCommandTop , UserCommand userCommandBottom , string description )
167161 {
168162 NoOffButtons = 2 ;
169163 UserCommand = new UserCommand [ ] { userCommandTop , userCommandBottom } ;
@@ -212,9 +206,9 @@ public static void deepCopy(SwitchOnPanelDefinition to, SwitchOnPanelDefinition
212206 public override int GetHashCode ( )
213207 {
214208 var hashCode = 1410623761 ;
215- hashCode = hashCode * - 1521134295 + NoOffButtons . GetHashCode ( ) ;
216- hashCode = hashCode * - 1521134295 + EqualityComparer < UserCommand [ ] > . Default . GetHashCode ( UserCommand ) ;
217- hashCode = hashCode * - 1521134295 + EqualityComparer < string > . Default . GetHashCode ( Description ) ;
209+ hashCode = ( hashCode * - 1521134295 ) + NoOffButtons . GetHashCode ( ) ;
210+ hashCode = ( hashCode * - 1521134295 ) + EqualityComparer < UserCommand [ ] > . Default . GetHashCode ( UserCommand ) ;
211+ hashCode = ( hashCode * - 1521134295 ) + EqualityComparer < string > . Default . GetHashCode ( Description ) ;
218212 return hashCode ;
219213 }
220214 }
0 commit comments