Commit 8918a65c authored by DailyShana's avatar DailyShana

get unicode command args on Windows

parent 7a89eeb9
...@@ -12,21 +12,8 @@ bool open_file = false; ...@@ -12,21 +12,8 @@ bool open_file = false;
wchar_t open_file_name[256] = L""; wchar_t open_file_name[256] = L"";
bool bot_mode = false; bool bot_mode = false;
void GetParameter(char* param, const char* arg) {
#ifdef _WIN32
wchar_t arg1[260];
MultiByteToWideChar(CP_ACP, 0, arg, -1, arg1, 260);
BufferIO::EncodeUTF8(arg1, param);
#else
strcpy(param, arg);
#endif
}
void GetParameterW(wchar_t* param, const char* arg) { void GetParameterW(wchar_t* param, const char* arg) {
#ifdef _WIN32
MultiByteToWideChar(CP_ACP, 0, arg, -1, param, 260);
#else
BufferIO::DecodeUTF8(arg, param); BufferIO::DecodeUTF8(arg, param);
#endif
} }
void ClickButton(irr::gui::IGUIElement* btn) { void ClickButton(irr::gui::IGUIElement* btn) {
irr::SEvent event; irr::SEvent event;
...@@ -72,19 +59,24 @@ int main(int argc, char* argv[]) { ...@@ -72,19 +59,24 @@ int main(int argc, char* argv[]) {
if(!ygo::mainGame->Initialize()) if(!ygo::mainGame->Initialize())
return 0; return 0;
#ifdef _WIN32
wchar_t* command = GetCommandLineW();
char buffer[2048];
BufferIO::EncodeUTF8(command, buffer);
argv[0] = strtok(buffer, " ");
for(int i = 1; i < argc; ++i)
argv[i] = strtok(NULL, " ");
#endif // _WIN32
bool keep_on_return = false; bool keep_on_return = false;
for(int i = 1; i < argc; ++i) { for(int i = 1; i < argc; ++i) {
if(argv[i][0] == '-' && argv[i][1] == 'e') { if(argv[i][0] == '-' && argv[i][1] == 'e') {
char param[128]; ygo::dataManager.LoadDB(&argv[i][2]);
GetParameter(param, &argv[i][2]);
ygo::dataManager.LoadDB(param);
continue; continue;
} }
if(!strcmp(argv[i], "-e")) { // extra database if(!strcmp(argv[i], "-e")) { // extra database
++i; ++i;
char param[128]; ygo::dataManager.LoadDB(&argv[i][0]);
GetParameter(param, &argv[i][0]);
ygo::dataManager.LoadDB(param);
continue; continue;
} else if(!strcmp(argv[i], "-n")) { // nickName } else if(!strcmp(argv[i], "-n")) { // nickName
++i; ++i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment