Skip to content

Commit b96e181

Browse files
committed
fixed shellapi errors
1 parent ccbf1da commit b96e181

File tree

3 files changed

+71
-77
lines changed

3 files changed

+71
-77
lines changed

Adria/Adria.vcxproj.filters

+3-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@
173173
<ClCompile Include="Graphics\CommonStates.cpp">
174174
<Filter>Graphics</Filter>
175175
</ClCompile>
176-
<ClCompile Include="Graphics\RenderPass.cpp" />
176+
<ClCompile Include="Graphics\RenderPass.cpp">
177+
<Filter>Graphics</Filter>
178+
</ClCompile>
177179
</ItemGroup>
178180
<ItemGroup>
179181
<ClInclude Include="Utilities\RingBuffer.h">

Adria/Utilities/CommandLineParser.cpp

-74
This file was deleted.

Adria/Utilities/CommandLineParser.h

+68-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
2+
#include <shellapi.h>
23
#include <string>
34
#include "../Core/Definitions.h"
4-
#include <shellapi.h>
55

66
namespace adria
77
{
@@ -16,5 +16,71 @@ namespace adria
1616
std::string log_file = "adria.log";
1717
};
1818

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+
}
2086
}

0 commit comments

Comments
 (0)