@@ -140,15 +140,11 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)
140
140
{
141
141
Controls [ Length ] . Command = Translations . CommandInfos [ j ] . Command ;
142
142
Controls [ Length ] . InheritedType = Translations . CommandInfos [ j ] . Type ;
143
- ControlMethod Method ;
144
- Enum . TryParse ( Terms [ 1 ] , true , out Method ) ;
143
+ Enum . TryParse ( Terms [ 1 ] , true , out ControlMethod Method ) ;
145
144
bool Valid = false ;
146
145
if ( Method == ControlMethod . Keyboard & Terms . Length >= 4 )
147
146
{
148
- Key CurrentKey ;
149
- // ReSharper disable once NotAccessedVariable
150
- int SDLTest ;
151
- if ( int . TryParse ( Terms [ 2 ] , out SDLTest ) )
147
+ if ( int . TryParse ( Terms [ 2 ] , out _ ) )
152
148
{
153
149
//We've discovered a SDL keybinding is present, so reset the loading process with the default keyconfig & show an appropriate error message
154
150
if ( ControlsReset == false )
@@ -185,19 +181,17 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)
185
181
return ;
186
182
}
187
183
188
- if ( Enum . TryParse ( Terms [ 2 ] , true , out CurrentKey ) )
184
+ if ( Enum . TryParse ( Terms [ 2 ] , true , out Key CurrentKey ) )
189
185
{
190
- int Modifiers ;
191
- if ( int . TryParse ( Terms [ 3 ] , NumberStyles . Integer , Culture , out Modifiers ) )
186
+ if ( int . TryParse ( Terms [ 3 ] , NumberStyles . Integer , Culture , out int Modifiers ) )
192
187
{
193
188
Controls [ Length ] . Method = Method ;
194
189
Controls [ Length ] . Device = Guid . Empty ;
195
190
Controls [ Length ] . Component = JoystickComponent . Invalid ;
196
191
Controls [ Length ] . Key = ( OpenBveApi . Input . Key ) CurrentKey ;
197
192
Controls [ Length ] . Direction = 0 ;
198
193
Controls [ Length ] . Modifier = ( KeyboardModifier ) Modifiers ;
199
- int Option ;
200
- if ( Terms . Length >= 5 && int . TryParse ( Terms [ 4 ] , NumberStyles . Integer , Culture , out Option ) )
194
+ if ( Terms . Length >= 5 && int . TryParse ( Terms [ 4 ] , NumberStyles . Integer , Culture , out int Option ) )
201
195
{
202
196
Controls [ Length ] . Option = Option ;
203
197
}
@@ -208,26 +202,22 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)
208
202
}
209
203
else if ( Method == ControlMethod . Joystick & Terms . Length >= 4 )
210
204
{
211
- int oldDevice ;
212
205
Guid Device = Guid . Empty ;
213
- if ( int . TryParse ( Terms [ 2 ] , NumberStyles . Integer , Culture , out oldDevice ) )
206
+ if ( int . TryParse ( Terms [ 2 ] , NumberStyles . Integer , Culture , out int oldDevice ) )
214
207
{
215
208
Device = Joystick . GetGuid ( oldDevice ) ;
216
209
}
217
210
218
- JoystickComponent Component ;
219
- Enum . TryParse ( Terms [ 3 ] , true , out Component ) ;
211
+ Enum . TryParse ( Terms [ 3 ] , true , out JoystickComponent Component ) ;
220
212
221
213
if ( Device != Guid . Empty || Guid . TryParse ( Terms [ 2 ] , out Device ) )
222
214
{
223
215
224
216
if ( Component == JoystickComponent . Axis & Terms . Length >= 6 )
225
217
{
226
- int CurrentAxis ;
227
- if ( int . TryParse ( Terms [ 4 ] , out CurrentAxis ) )
218
+ if ( int . TryParse ( Terms [ 4 ] , out int CurrentAxis ) )
228
219
{
229
- int Direction ;
230
- if ( int . TryParse ( Terms [ 5 ] , NumberStyles . Integer , Culture , out Direction ) )
220
+ if ( int . TryParse ( Terms [ 5 ] , NumberStyles . Integer , Culture , out int Direction ) )
231
221
{
232
222
233
223
Controls [ Length ] . Method = Method ;
@@ -236,8 +226,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)
236
226
Controls [ Length ] . Element = CurrentAxis ;
237
227
Controls [ Length ] . Direction = Direction ;
238
228
Controls [ Length ] . Modifier = KeyboardModifier . None ;
239
- int Option ;
240
- if ( Terms . Length >= 7 && int . TryParse ( Terms [ 6 ] , NumberStyles . Integer , Culture , out Option ) )
229
+ if ( Terms . Length >= 7 && int . TryParse ( Terms [ 6 ] , NumberStyles . Integer , Culture , out int Option ) )
241
230
{
242
231
Controls [ Length ] . Option = Option ;
243
232
}
@@ -248,20 +237,17 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)
248
237
}
249
238
else if ( Component == JoystickComponent . Hat & Terms . Length >= 6 )
250
239
{
251
- int CurrentHat ;
252
- if ( int . TryParse ( Terms [ 4 ] , out CurrentHat ) )
240
+ if ( int . TryParse ( Terms [ 4 ] , out int CurrentHat ) )
253
241
{
254
- int HatDirection ;
255
- if ( int . TryParse ( Terms [ 5 ] , out HatDirection ) )
242
+ if ( int . TryParse ( Terms [ 5 ] , out int HatDirection ) )
256
243
{
257
244
Controls [ Length ] . Method = Method ;
258
245
Controls [ Length ] . Device = Device ;
259
246
Controls [ Length ] . Component = JoystickComponent . Hat ;
260
247
Controls [ Length ] . Element = CurrentHat ;
261
248
Controls [ Length ] . Direction = HatDirection ;
262
249
Controls [ Length ] . Modifier = KeyboardModifier . None ;
263
- int Option ;
264
- if ( Terms . Length >= 7 && int . TryParse ( Terms [ 6 ] , NumberStyles . Integer , Culture , out Option ) )
250
+ if ( Terms . Length >= 7 && int . TryParse ( Terms [ 6 ] , NumberStyles . Integer , Culture , out int Option ) )
265
251
{
266
252
Controls [ Length ] . Option = Option ;
267
253
}
@@ -273,17 +259,15 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)
273
259
}
274
260
else if ( Component == JoystickComponent . Button & Terms . Length >= 5 )
275
261
{
276
- int CurrentButton ;
277
- if ( int . TryParse ( Terms [ 4 ] , out CurrentButton ) )
262
+ if ( int . TryParse ( Terms [ 4 ] , out int CurrentButton ) )
278
263
{
279
264
Controls [ Length ] . Method = Method ;
280
265
Controls [ Length ] . Device = Device ;
281
266
Controls [ Length ] . Component = JoystickComponent . Button ;
282
267
Controls [ Length ] . Element = CurrentButton ;
283
268
Controls [ Length ] . Direction = 0 ;
284
269
Controls [ Length ] . Modifier = KeyboardModifier . None ;
285
- int Option ;
286
- if ( Terms . Length >= 6 && int . TryParse ( Terms [ 5 ] , NumberStyles . Integer , Culture , out Option ) )
270
+ if ( Terms . Length >= 6 && int . TryParse ( Terms [ 5 ] , NumberStyles . Integer , Culture , out int Option ) )
287
271
{
288
272
Controls [ Length ] . Option = Option ;
289
273
}
@@ -296,24 +280,20 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)
296
280
}
297
281
else if ( Method == ControlMethod . RailDriver & Terms . Length >= 4 )
298
282
{
299
- int oldDevice ;
300
283
Guid Device = Guid . Empty ;
301
- if ( int . TryParse ( Terms [ 2 ] , NumberStyles . Integer , Culture , out oldDevice ) )
284
+ if ( int . TryParse ( Terms [ 2 ] , NumberStyles . Integer , Culture , out int oldDevice ) )
302
285
{
303
286
Device = Joystick . GetGuid ( oldDevice ) ;
304
287
}
305
288
306
289
if ( Device != Guid . Empty || Guid . TryParse ( Terms [ 2 ] , out Device ) )
307
290
{
308
- JoystickComponent Component ;
309
- Enum . TryParse ( Terms [ 3 ] , true , out Component ) ;
291
+ Enum . TryParse ( Terms [ 3 ] , true , out JoystickComponent Component ) ;
310
292
if ( Component == JoystickComponent . Axis & Terms . Length >= 6 )
311
293
{
312
- int CurrentAxis ;
313
- if ( int . TryParse ( Terms [ 4 ] , out CurrentAxis ) )
294
+ if ( int . TryParse ( Terms [ 4 ] , out int CurrentAxis ) )
314
295
{
315
- int Direction ;
316
- if ( int . TryParse ( Terms [ 5 ] , NumberStyles . Integer , Culture , out Direction ) )
296
+ if ( int . TryParse ( Terms [ 5 ] , NumberStyles . Integer , Culture , out int Direction ) )
317
297
{
318
298
319
299
Controls [ Length ] . Method = Method ;
@@ -322,8 +302,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)
322
302
Controls [ Length ] . Element = CurrentAxis ;
323
303
Controls [ Length ] . Direction = Direction ;
324
304
Controls [ Length ] . Modifier = KeyboardModifier . None ;
325
- int Option ;
326
- if ( Terms . Length >= 7 && int . TryParse ( Terms [ 6 ] , NumberStyles . Integer , Culture , out Option ) )
305
+ if ( Terms . Length >= 7 && int . TryParse ( Terms [ 6 ] , NumberStyles . Integer , Culture , out int Option ) )
327
306
{
328
307
Controls [ Length ] . Option = Option ;
329
308
}
@@ -334,17 +313,15 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)
334
313
}
335
314
else if ( Component == JoystickComponent . Button & Terms . Length >= 5 )
336
315
{
337
- int CurrentButton ;
338
- if ( int . TryParse ( Terms [ 4 ] , out CurrentButton ) )
316
+ if ( int . TryParse ( Terms [ 4 ] , out int CurrentButton ) )
339
317
{
340
318
Controls [ Length ] . Method = ControlMethod . RailDriver ;
341
319
Controls [ Length ] . Device = Device ;
342
320
Controls [ Length ] . Component = JoystickComponent . Button ;
343
321
Controls [ Length ] . Element = CurrentButton ;
344
322
Controls [ Length ] . Direction = 0 ;
345
323
Controls [ Length ] . Modifier = KeyboardModifier . None ;
346
- int Option ;
347
- if ( Terms . Length >= 6 && int . TryParse ( Terms [ 5 ] , NumberStyles . Integer , Culture , out Option ) )
324
+ if ( Terms . Length >= 6 && int . TryParse ( Terms [ 5 ] , NumberStyles . Integer , Culture , out int Option ) )
348
325
{
349
326
Controls [ Length ] . Option = Option ;
350
327
}
0 commit comments