1
1
#pragma once
2
+ #include < shellapi.h>
2
3
#include < string>
3
4
#include " ../Core/Definitions.h"
4
- #include < shellapi.h>
5
5
6
6
namespace adria
7
7
{
@@ -16,5 +16,71 @@ namespace adria
16
16
std::string log_file = " adria.log" ;
17
17
};
18
18
19
- command_line_config_info_t ParseCommandLine (LPWSTR command_line);
19
+ static command_line_config_info_t ParseCommandLine (LPWSTR command_line)
20
+ {
21
+ command_line_config_info_t config{};
22
+
23
+ int argc = 0 ;
24
+ LPWSTR* argv = CommandLineToArgvW (command_line, &argc);
25
+ if (argv == NULL )
26
+ {
27
+ OutputDebugStringW (L" Cannot parse command line, returning default configuration\n " );
28
+ return config;
29
+ }
30
+
31
+ if (argc > 0 )
32
+ {
33
+ CHAR str[256 ];
34
+ INT32 i = 0 ;
35
+ while (i < argc)
36
+ {
37
+ wcstombs (str, argv[i], sizeof (str));
38
+
39
+ if (strcmp (str, " -width" ) == 0 )
40
+ {
41
+ i++;
42
+ wcstombs (str, argv[i], sizeof (str));
43
+ config.window_width = atoi (str);
44
+ }
45
+ else if (strcmp (str, " -height" ) == 0 )
46
+ {
47
+ i++;
48
+ wcstombs (str, argv[i], sizeof (str));
49
+ config.window_height = atoi (str);
50
+ }
51
+ else if (strcmp (str, " -title" ) == 0 )
52
+ {
53
+ i++;
54
+ wcstombs (str, argv[i], sizeof (str));
55
+ config.window_title = str;
56
+ }
57
+ else if (strcmp (str, " -max" ) == 0 )
58
+ {
59
+ i++;
60
+ wcstombs (str, argv[i], sizeof (str));
61
+ if (strcmp (str, " true" ) == 0 ) config.window_maximize = true ;
62
+ else if (strcmp (str, " false" ) == 0 ) config.window_maximize = false ;
63
+ // else use default
64
+ }
65
+ else if (strcmp (str, " -vsync" ) == 0 )
66
+ {
67
+ i++;
68
+ wcstombs (str, argv[i], sizeof (str));
69
+ if (strcmp (str, " true" ) == 0 ) config.vsync = true ;
70
+ else if (strcmp (str, " false" ) == 0 ) config.vsync = false ;
71
+ // else use default
72
+ }
73
+ else if (strcmp (str, " -log" ) == 0 )
74
+ {
75
+ i++;
76
+ wcstombs (str, argv[i], sizeof (str));
77
+ config.log_file = (atoi (str) > 0 );
78
+ }
79
+ i++;
80
+ }
81
+ }
82
+
83
+ LocalFree (argv);
84
+ return config;
85
+ }
20
86
}
0 commit comments