5
5
using System . Windows . Forms ;
6
6
using ObjectViewer . Graphics ;
7
7
using OpenBveApi . Graphics ;
8
+ using OpenBveApi . Input ;
8
9
using OpenBveApi . Objects ;
9
10
using Path = OpenBveApi . Path ;
10
11
@@ -17,32 +18,38 @@ internal static void LoadOptions()
17
18
Interface . CurrentOptions = new Interface . Options
18
19
{
19
20
ViewingDistance = 1000 , // fixed
21
+ CameraMoveLeft = Key . A ,
22
+ CameraMoveRight = Key . D ,
23
+ CameraMoveUp = Key . W ,
24
+ CameraMoveDown = Key . S ,
25
+ CameraMoveForward = Key . Q ,
26
+ CameraMoveBackward = Key . E
20
27
} ;
21
28
string optionsFolder = Path . CombineDirectory ( Program . FileSystem . SettingsFolder , "1.5.0" ) ;
22
- if ( ! System . IO . Directory . Exists ( optionsFolder ) )
29
+ if ( ! Directory . Exists ( optionsFolder ) )
23
30
{
24
- System . IO . Directory . CreateDirectory ( optionsFolder ) ;
31
+ Directory . CreateDirectory ( optionsFolder ) ;
25
32
}
26
33
CultureInfo Culture = CultureInfo . InvariantCulture ;
27
34
string configFile = Path . CombineFile ( optionsFolder , "options_ov.cfg" ) ;
28
- if ( ! System . IO . File . Exists ( configFile ) )
35
+ if ( ! File . Exists ( configFile ) )
29
36
{
30
37
//Attempt to load and upgrade a prior configuration file
31
38
string assemblyFolder = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
32
39
configFile = Path . CombineFile ( Path . CombineDirectory ( Path . CombineDirectory ( assemblyFolder , "UserData" ) , "Settings" ) , "options_ov.cfg" ) ;
33
40
34
- if ( ! System . IO . File . Exists ( configFile ) )
41
+ if ( ! File . Exists ( configFile ) )
35
42
{
36
43
//If no route viewer specific configuration file exists, then try the main OpenBVE configuration file
37
44
//Write out to a new routeviewer specific file though
38
45
configFile = Path . CombineFile ( Program . FileSystem . SettingsFolder , "1.5.0/options.cfg" ) ;
39
46
}
40
47
}
41
48
42
- if ( System . IO . File . Exists ( configFile ) )
49
+ if ( File . Exists ( configFile ) )
43
50
{
44
51
// load options
45
- string [ ] Lines = System . IO . File . ReadAllLines ( configFile , new System . Text . UTF8Encoding ( ) ) ;
52
+ string [ ] Lines = File . ReadAllLines ( configFile , new System . Text . UTF8Encoding ( ) ) ;
46
53
string Section = "" ;
47
54
for ( int i = 0 ; i < Lines . Length ; i ++ )
48
55
{
@@ -184,6 +191,47 @@ internal static void LoadOptions()
184
191
break ;
185
192
}
186
193
break ;
194
+ case "keys" :
195
+ switch ( Key )
196
+ {
197
+ case "left" :
198
+ if ( ! Enum . TryParse ( Value , out Interface . CurrentOptions . CameraMoveLeft ) )
199
+ {
200
+ Interface . CurrentOptions . CameraMoveLeft = OpenBveApi . Input . Key . A ;
201
+ }
202
+ break ;
203
+ case "right" :
204
+ if ( ! Enum . TryParse ( Value , out Interface . CurrentOptions . CameraMoveRight ) )
205
+ {
206
+ Interface . CurrentOptions . CameraMoveRight = OpenBveApi . Input . Key . D ;
207
+ }
208
+ break ;
209
+ case "up" :
210
+ if ( ! Enum . TryParse ( Value , out Interface . CurrentOptions . CameraMoveUp ) )
211
+ {
212
+ Interface . CurrentOptions . CameraMoveUp = OpenBveApi . Input . Key . W ;
213
+ }
214
+ break ;
215
+ case "down" :
216
+ if ( ! Enum . TryParse ( Value , out Interface . CurrentOptions . CameraMoveDown ) )
217
+ {
218
+ Interface . CurrentOptions . CameraMoveDown = OpenBveApi . Input . Key . S ;
219
+ }
220
+ break ;
221
+ case "forward" :
222
+ if ( ! Enum . TryParse ( Value , out Interface . CurrentOptions . CameraMoveForward ) )
223
+ {
224
+ Interface . CurrentOptions . CameraMoveForward = OpenBveApi . Input . Key . Q ;
225
+ }
226
+ break ;
227
+ case "backward" :
228
+ if ( ! Enum . TryParse ( Value , out Interface . CurrentOptions . CameraMoveBackward ) )
229
+ {
230
+ Interface . CurrentOptions . CameraMoveBackward = OpenBveApi . Input . Key . E ;
231
+ }
232
+ break ;
233
+ }
234
+ break ;
187
235
}
188
236
}
189
237
}
@@ -234,8 +282,15 @@ internal static void SaveOptions()
234
282
Builder . AppendLine ( ) ;
235
283
Builder . AppendLine ( "[Folders]" ) ;
236
284
Builder . AppendLine ( $ "objectsearch = { Interface . CurrentOptions . ObjectSearchDirectory } ") ;
285
+ Builder . AppendLine ( "[Keys]" ) ;
286
+ Builder . AppendLine ( "left = " + Interface . CurrentOptions . CameraMoveLeft ) ;
287
+ Builder . AppendLine ( "right = " + Interface . CurrentOptions . CameraMoveRight ) ;
288
+ Builder . AppendLine ( "up = " + Interface . CurrentOptions . CameraMoveUp ) ;
289
+ Builder . AppendLine ( "down = " + Interface . CurrentOptions . CameraMoveDown ) ;
290
+ Builder . AppendLine ( "forward = " + Interface . CurrentOptions . CameraMoveForward ) ;
291
+ Builder . AppendLine ( "backward = " + Interface . CurrentOptions . CameraMoveBackward ) ;
237
292
string configFile = Path . CombineFile ( Program . FileSystem . SettingsFolder , "1.5.0/options_ov.cfg" ) ;
238
- System . IO . File . WriteAllText ( configFile , Builder . ToString ( ) , new System . Text . UTF8Encoding ( true ) ) ;
293
+ File . WriteAllText ( configFile , Builder . ToString ( ) , new System . Text . UTF8Encoding ( true ) ) ;
239
294
}
240
295
catch
241
296
{
0 commit comments