1 namespace OpenBveApi.Interface
2 {
3 	/// <summary>Contains functions for providing translations</summary>
4 	public static partial class Translations
5 	{
6 		/// <summary>Information on an in-game command</summary>
7 		public struct CommandInfo
8 		{
9 			/// <summary>The actual command to be performed</summary>
10 			public readonly Command Command;
11 			/// <summary>Whether this is a digital or analog control</summary>
12 			public readonly CommandType Type;
13 			/// <summary>The command name</summary>
14 			public readonly string Name;
15 			/// <summary>The command's description</summary>
16 			public string Description;
17 			/// <summary>Whether to enable command options</summary>
18 			public readonly bool EnableOption;
19 
CommandInfoOpenBveApi.Interface.Translations.CommandInfo20 			internal CommandInfo(Command Command, CommandType Type, string Name)
21 			{
22 				this.Command = Command;
23 				this.Type = Type;
24 				this.Name = Name;
25 				this.Description = "N/A";
26 				this.EnableOption = false;
27 			}
28 
CommandInfoOpenBveApi.Interface.Translations.CommandInfo29 			internal CommandInfo(Command Command, CommandType Type, string Name, bool EnableOption)
30 			{
31 				this.Command = Command;
32 				this.Type = Type;
33 				this.Name = Name;
34 				this.Description = "N/A";
35 				this.EnableOption = EnableOption;
36 			}
37 
38 			/// <summary>Checks whether the two specified CommandInfo instances are equal</summary>
39 			/// <remarks>This ignores the translated command description</remarks>
operator ==OpenBveApi.Interface.Translations.CommandInfo40 			public static bool operator ==(CommandInfo a, CommandInfo b)
41 			{
42 				if (a.Command != b.Command)
43 				{
44 					return false;
45 				}
46 				if (a.Name != b.Name)
47 				{
48 					return false;
49 				}
50 				if (a.EnableOption != b.EnableOption)
51 				{
52 					return false;
53 				}
54 				return true;
55 			}
56 
57 			/// <summary>Checks whether the two specified CommandInfo instances are NOT equal</summary>
58 			/// <remarks>This ignores the translated command description</remarks>
operator !=OpenBveApi.Interface.Translations.CommandInfo59 			public static bool operator !=(CommandInfo a, CommandInfo b)
60 			{
61 				if (a.Command == b.Command)
62 				{
63 					return false;
64 				}
65 				if (a.Name == b.Name)
66 				{
67 					return false;
68 				}
69 				if (a.EnableOption == b.EnableOption)
70 				{
71 					return false;
72 				}
73 				return true;
74 			}
75 
76 			/// <summary>Returns whether this CommandInfo instance is equal to the specified object</summary>
77 			/// <remarks>This ignores the translated command description</remarks>
EqualsOpenBveApi.Interface.Translations.CommandInfo78 			public override bool Equals(object obj)
79 			{
80 				if (obj is CommandInfo)
81 				{
82 					CommandInfo newCommandInfo = (CommandInfo) obj;
83 					return newCommandInfo.Equals(this);
84 				}
85 				return false;
86 
87 			}
88 
89 			/// <summary>Returns whether this CommandInfo instance is equal to the specified CommandInfo</summary>
90 			/// <remarks>This ignores the translated command description</remarks>
EqualsOpenBveApi.Interface.Translations.CommandInfo91 			public bool Equals(CommandInfo other)
92 			{
93 				return Command == other.Command && Type == other.Type && Name == other.Name && EnableOption == other.EnableOption;
94 			}
95 
96 			/// <summary>Gets the HashCode for this CommandInfo instance</summary>
97 			/// <remarks>This ignores the translated command description</remarks>
GetHashCodeOpenBveApi.Interface.Translations.CommandInfo98 			public override int GetHashCode()
99 			{
100 				unchecked
101 				{
102 					var hashCode = (int) Command;
103 					hashCode = (hashCode * 397) ^ (int) Type;
104 					hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
105 					hashCode = (hashCode * 397) ^ EnableOption.GetHashCode();
106 					return hashCode;
107 				}
108 			}
109 		}
110 
111 		/// <summary>Gets the command info for the specified command</summary>
112 		/// <param name="commandInfos">The array of command infos</param>
113 		/// <param name="Value">The command</param>
114 		/// <returns>The command info for Value, or a new command info if this is not in the array</returns>
TryGetInfo(this CommandInfo[] commandInfos, Command Value)115 		public static CommandInfo TryGetInfo(this CommandInfo[] commandInfos, Command Value)
116 		{
117 			for (int i = 0; i < commandInfos.Length; i++) {
118 				if (commandInfos[i].Command == Value)
119 				{
120 					return commandInfos[i];
121 				}
122 			}
123 			return new CommandInfo(Value, CommandType.Digital, "N/A");
124 		}
125 
126 		/// <summary>Contains the list of all known command infos</summary>
127 		public static CommandInfo[] CommandInfos = {
128 			new CommandInfo(Command.PowerIncrease, CommandType.Digital, "POWER_INCREASE"),
129 			new CommandInfo(Command.PowerDecrease, CommandType.Digital, "POWER_DECREASE"),
130 			new CommandInfo(Command.PowerHalfAxis, CommandType.AnalogHalf, "POWER_HALFAXIS"),
131 			new CommandInfo(Command.PowerFullAxis, CommandType.AnalogFull, "POWER_FULLAXIS"),
132 			new CommandInfo(Command.BrakeDecrease, CommandType.Digital, "BRAKE_DECREASE"),
133 			new CommandInfo(Command.BrakeIncrease, CommandType.Digital, "BRAKE_INCREASE"),
134 			new CommandInfo(Command.LocoBrakeDecrease, CommandType.Digital, "LOCOBRAKE_DECREASE"),
135 			new CommandInfo(Command.LocoBrakeIncrease, CommandType.Digital, "LOCOBRAKE_INCREASE"),
136 			new CommandInfo(Command.BrakeHalfAxis, CommandType.AnalogHalf, "BRAKE_HALFAXIS"),
137 			new CommandInfo(Command.BrakeFullAxis, CommandType.AnalogFull, "BRAKE_FULLAXIS"),
138 			new CommandInfo(Command.BrakeEmergency, CommandType.Digital, "BRAKE_EMERGENCY"),
139 			new CommandInfo(Command.SinglePower, CommandType.Digital, "SINGLE_POWER"),
140 			new CommandInfo(Command.SingleNeutral, CommandType.Digital, "SINGLE_NEUTRAL"),
141 			new CommandInfo(Command.SingleBrake, CommandType.Digital, "SINGLE_BRAKE"),
142 			new CommandInfo(Command.SingleEmergency, CommandType.Digital, "SINGLE_EMERGENCY"),
143 			new CommandInfo(Command.SingleFullAxis, CommandType.AnalogFull, "SINGLE_FULLAXIS"),
144 			new CommandInfo(Command.PowerAnyNotch, CommandType.Digital, "POWER_ANY_NOTCH", true),
145 			new CommandInfo(Command.BrakeAnyNotch, CommandType.Digital, "BRAKE_ANY_NOTCH", true),
146 			new CommandInfo(Command.ReverserAnyPostion, CommandType.Digital, "REVERSER_ANY_POSITION", true),
147 			new CommandInfo(Command.HoldBrake,CommandType.Digital, "HOLD_BRAKE"),
148 			new CommandInfo(Command.ReverserForward, CommandType.Digital, "REVERSER_FORWARD"),
149 			new CommandInfo(Command.ReverserBackward, CommandType.Digital, "REVERSER_BACKWARD"),
150 			new CommandInfo(Command.ReverserFullAxis, CommandType.AnalogFull, "REVERSER_FULLAXIS"),
151 			new CommandInfo(Command.DoorsLeft, CommandType.Digital, "DOORS_LEFT"),
152 			new CommandInfo(Command.DoorsRight, CommandType.Digital, "DOORS_RIGHT"),
153 			new CommandInfo(Command.HornPrimary, CommandType.Digital, "HORN_PRIMARY"),
154 			new CommandInfo(Command.HornSecondary, CommandType.Digital, "HORN_SECONDARY"),
155 			new CommandInfo(Command.HornMusic, CommandType.Digital, "HORN_MUSIC"),
156 			new CommandInfo(Command.DeviceConstSpeed, CommandType.Digital, "DEVICE_CONSTSPEED"),
157 			new CommandInfo(Command.PlayMicSounds, CommandType.Digital, "PLAY_MIC_SOUNDS"),
158 
159 //We only want to mark these as obsolete for new users of the API
160 #pragma warning disable 618
161 			new CommandInfo(Command.SecurityS, CommandType.Digital, "SECURITY_S"),
162 			new CommandInfo(Command.SecurityA1, CommandType.Digital, "SECURITY_A1"),
163 			new CommandInfo(Command.SecurityA2, CommandType.Digital, "SECURITY_A2"),
164 			new CommandInfo(Command.SecurityB1, CommandType.Digital, "SECURITY_B1"),
165 			new CommandInfo(Command.SecurityB2, CommandType.Digital, "SECURITY_B2"),
166 			new CommandInfo(Command.SecurityC1, CommandType.Digital, "SECURITY_C1"),
167 			new CommandInfo(Command.SecurityC2, CommandType.Digital, "SECURITY_C2"),
168 			new CommandInfo(Command.SecurityD, CommandType.Digital, "SECURITY_D"),
169 			new CommandInfo(Command.SecurityE, CommandType.Digital, "SECURITY_E"),
170 			new CommandInfo(Command.SecurityF, CommandType.Digital, "SECURITY_F"),
171 			new CommandInfo(Command.SecurityG, CommandType.Digital, "SECURITY_G"),
172 			new CommandInfo(Command.SecurityH, CommandType.Digital, "SECURITY_H"),
173 			new CommandInfo(Command.SecurityI, CommandType.Digital, "SECURITY_I"),
174 			new CommandInfo(Command.SecurityJ, CommandType.Digital, "SECURITY_J"),
175 			new CommandInfo(Command.SecurityK, CommandType.Digital, "SECURITY_K"),
176 			new CommandInfo(Command.SecurityL, CommandType.Digital, "SECURITY_L"),
177 			new CommandInfo(Command.SecurityM, CommandType.Digital, "SECURITY_M"),
178 			new CommandInfo(Command.SecurityN, CommandType.Digital, "SECURITY_N"),
179 			new CommandInfo(Command.SecurityO, CommandType.Digital, "SECURITY_O"),
180 			new CommandInfo(Command.SecurityP, CommandType.Digital, "SECURITY_P"),
181 #pragma warning restore 618
182 
183 			//Common Keys
184 			new CommandInfo(Command.WiperSpeedUp, CommandType.Digital, "WIPER_SPEED_UP"),
185 			new CommandInfo(Command.WiperSpeedDown, CommandType.Digital, "WIPER_SPEED_DOWN"),
186 			new CommandInfo(Command.FillFuel, CommandType.Digital, "FILL_FUEL"),
187 			new CommandInfo(Command.Headlights, CommandType.Digital, "HEADLIGHTS"),
188 			//Steam locomotive
189 			new CommandInfo(Command.LiveSteamInjector, CommandType.Digital, "LIVE_STEAM_INJECTOR"),
190 			new CommandInfo(Command.ExhaustSteamInjector, CommandType.Digital, "EXHAUST_STEAM_INJECTOR"),
191 			new CommandInfo(Command.IncreaseCutoff, CommandType.Digital, "INCREASE_CUTOFF"),
192 			new CommandInfo(Command.DecreaseCutoff, CommandType.Digital, "DECREASE_CUTOFF"),
193 			new CommandInfo(Command.Blowers, CommandType.Digital, "BLOWERS"),
194 			//Diesel Locomotive
195 			new CommandInfo(Command.EngineStart, CommandType.Digital, "ENGINE_START"),
196 			new CommandInfo(Command.EngineStop, CommandType.Digital, "ENGINE_STOP"),
197 			new CommandInfo(Command.GearUp, CommandType.Digital, "GEAR_UP"),
198 			new CommandInfo(Command.GearDown, CommandType.Digital, "GEAR_DOWN"),
199 
200 			//Electric Locomotive
201 			new CommandInfo(Command.RaisePantograph, CommandType.Digital, "RAISE_PANTOGRAPH"),
202 			new CommandInfo(Command.LowerPantograph, CommandType.Digital, "LOWER_PANTOGRAPH"),
203 			new CommandInfo(Command.MainBreaker, CommandType.Digital, "MAIN_BREAKER"),
204 
205 			//Simulation controls
206 			new CommandInfo(Command.CameraInterior, CommandType.Digital, "CAMERA_INTERIOR"),
207 			new CommandInfo(Command.CameraInteriorNoPanel,CommandType.Digital,"CAMERA_INTERIOR_NOPANEL"),
208 			new CommandInfo(Command.CameraExterior, CommandType.Digital, "CAMERA_EXTERIOR"),
209 			new CommandInfo(Command.CameraTrack, CommandType.Digital, "CAMERA_TRACK"),
210 			new CommandInfo(Command.CameraFlyBy, CommandType.Digital, "CAMERA_FLYBY"),
211 			new CommandInfo(Command.CameraMoveForward, CommandType.AnalogHalf, "CAMERA_MOVE_FORWARD"),
212 			new CommandInfo(Command.CameraMoveBackward, CommandType.AnalogHalf, "CAMERA_MOVE_BACKWARD"),
213 			new CommandInfo(Command.CameraMoveLeft, CommandType.AnalogHalf, "CAMERA_MOVE_LEFT"),
214 			new CommandInfo(Command.CameraMoveRight, CommandType.AnalogHalf, "CAMERA_MOVE_RIGHT"),
215 			new CommandInfo(Command.CameraMoveUp, CommandType.AnalogHalf, "CAMERA_MOVE_UP"),
216 			new CommandInfo(Command.CameraMoveDown, CommandType.AnalogHalf, "CAMERA_MOVE_DOWN"),
217 			new CommandInfo(Command.CameraRotateLeft, CommandType.AnalogHalf, "CAMERA_ROTATE_LEFT"),
218 			new CommandInfo(Command.CameraRotateRight, CommandType.AnalogHalf, "CAMERA_ROTATE_RIGHT"),
219 			new CommandInfo(Command.CameraRotateUp, CommandType.AnalogHalf, "CAMERA_ROTATE_UP"),
220 			new CommandInfo(Command.CameraRotateDown, CommandType.AnalogHalf, "CAMERA_ROTATE_DOWN"),
221 			new CommandInfo(Command.CameraRotateCCW, CommandType.AnalogHalf, "CAMERA_ROTATE_CCW"),
222 			new CommandInfo(Command.CameraRotateCW, CommandType.AnalogHalf, "CAMERA_ROTATE_CW"),
223 			new CommandInfo(Command.CameraZoomIn, CommandType.AnalogHalf, "CAMERA_ZOOM_IN"),
224 			new CommandInfo(Command.CameraZoomOut, CommandType.AnalogHalf, "CAMERA_ZOOM_OUT"),
225 			new CommandInfo(Command.CameraPreviousPOI, CommandType.Digital, "CAMERA_POI_PREVIOUS"),
226 			new CommandInfo(Command.CameraNextPOI, CommandType.Digital, "CAMERA_POI_NEXT"),
227 			new CommandInfo(Command.CameraReset, CommandType.Digital, "CAMERA_RESET"),
228 			new CommandInfo(Command.CameraRestriction, CommandType.Digital, "CAMERA_RESTRICTION"),
229 			new CommandInfo(Command.TimetableToggle, CommandType.Digital, "TIMETABLE_TOGGLE"),
230 			new CommandInfo(Command.TimetableUp, CommandType.AnalogHalf, "TIMETABLE_UP"),
231 			new CommandInfo(Command.TimetableDown, CommandType.AnalogHalf, "TIMETABLE_DOWN"),
232 			new CommandInfo(Command.MenuActivate, CommandType.Digital, "MENU_ACTIVATE"),
233 			new CommandInfo(Command.MenuUp, CommandType.Digital, "MENU_UP"),
234 			new CommandInfo(Command.MenuDown, CommandType.Digital, "MENU_DOWN"),
235 			new CommandInfo(Command.MenuEnter, CommandType.Digital, "MENU_ENTER"),
236 			new CommandInfo(Command.MenuBack, CommandType.Digital, "MENU_BACK"),
237 			new CommandInfo(Command.MiscClock, CommandType.Digital, "MISC_CLOCK"),
238 			new CommandInfo(Command.MiscSpeed, CommandType.Digital, "MISC_SPEED"),
239 			new CommandInfo(Command.MiscGradient, CommandType.Digital, "MISC_GRADIENT"),
240 			new CommandInfo(Command.MiscDistanceToNextStation, CommandType.Digital, "MISC_DIST_NEXT_STATION"),
241 			new CommandInfo(Command.MiscFps, CommandType.Digital, "MISC_FPS"),
242 			new CommandInfo(Command.MiscAI, CommandType.Digital, "MISC_AI"),
243 			new CommandInfo(Command.MiscFullscreen, CommandType.Digital, "MISC_FULLSCREEN"),
244 			new CommandInfo(Command.MiscMute, CommandType.Digital, "MISC_MUTE"),
245 			new CommandInfo(Command.MiscPause, CommandType.Digital, "MISC_PAUSE"),
246 			new CommandInfo(Command.MiscTimeFactor, CommandType.Digital, "MISC_TIMEFACTOR"),
247 			new CommandInfo(Command.MiscQuit, CommandType.Digital, "MISC_QUIT"),
248 			new CommandInfo(Command.MiscInterfaceMode, CommandType.Digital, "MISC_INTERFACE"),
249 			new CommandInfo(Command.MiscBackfaceCulling, CommandType.Digital, "MISC_BACKFACE"),
250 			new CommandInfo(Command.MiscCPUMode, CommandType.Digital, "MISC_CPUMODE"),
251 			new CommandInfo(Command.DebugWireframe, CommandType.Digital, "DEBUG_WIREFRAME"),
252 			new CommandInfo(Command.DebugNormals, CommandType.Digital, "DEBUG_NORMALS"),
253 			new CommandInfo(Command.DebugBrakeSystems, CommandType.Digital, "DEBUG_BRAKE"),
254 			new CommandInfo(Command.DebugATS, CommandType.Digital, "DEBUG_ATS"),
255 			new CommandInfo(Command.DebugTouchMode, CommandType.Digital, "DEBUG_TOUCH_MODE"),
256 			new CommandInfo(Command.RouteInformation, CommandType.Digital, "ROUTE_INFORMATION"),
257 			new CommandInfo(Command.ShowEvents, CommandType.Digital, "SHOW_EVENTS"),
258 			new CommandInfo(Command.DebugRendererMode, CommandType.Digital, "DEBUG_RENDERER_MODE"),
259 			new CommandInfo(Command.RailDriverSpeedUnits, CommandType.Digital, "RAILDRIVER_SPEED_UNITS"),
260 			//Accessibility
261 			new CommandInfo(Command.AccessibilityCurrentSpeed, CommandType.Digital, "ACCESSIBILITY_CURRENT_SPEED"),
262 			new CommandInfo(Command.AccessibilityNextSignal, CommandType.Digital, "ACCESSIBILITY_NEXT_SIGNAL"),
263 			new CommandInfo(Command.AccessibilityNextStation, CommandType.Digital, "ACCESSIBILITY_NEXT_STATION"),
264 		};
265 	}
266 }
267