Commit f35ecc7d authored by mercury233's avatar mercury233

update & fix

parent 9ca19022
...@@ -8,27 +8,21 @@ bool exit_on_return = false; ...@@ -8,27 +8,21 @@ bool exit_on_return = false;
bool open_file = false; bool open_file = false;
wchar_t open_file_name[256] = L""; wchar_t open_file_name[256] = L"";
const char* GetParameter(const char* arg) { void GetParameter(char* param, const char* arg) {
#ifdef _WIN32 #ifdef _WIN32
wchar_t arg1[260]; wchar_t arg1[260];
MultiByteToWideChar(CP_ACP, 0, arg, -1, arg1, 260); MultiByteToWideChar(CP_ACP, 0, arg, -1, arg1, 260);
char arg2[260]; BufferIO::EncodeUTF8(arg1, param);
BufferIO::EncodeUTF8(arg1, arg2);
return arg2;
#else #else
return arg; strcpy(param, arg1);
#endif #endif
} }
const wchar_t* GetParameterW(const char* arg) { void GetParameterW(wchar_t* param, const char* arg) {
#ifdef _WIN32 #ifdef _WIN32
wchar_t arg1[260]; MultiByteToWideChar(CP_ACP, 0, arg, -1, param, 260);
MultiByteToWideChar(CP_ACP, 0, arg, -1, arg1, 260);
return arg1;
#else #else
wchar_t arg2[260]; BufferIO::DecodeUTF8(arg, param);
BufferIO::DecodeUTF8(arg, arg2);
return arg2;
#endif #endif
} }
...@@ -58,41 +52,62 @@ int main(int argc, char* argv[]) { ...@@ -58,41 +52,62 @@ int main(int argc, char* argv[]) {
for(int i = 1; i < argc; ++i) { for(int i = 1; i < argc; ++i) {
if(!strcmp(argv[i], "-e")) { // extra database if(!strcmp(argv[i], "-e")) { // extra database
++i; ++i;
ygo::dataManager.LoadDB(GetParameter(&argv[i][0])); char param[128];
GetParameter(param, &argv[i][0]);
ygo::dataManager.LoadDB(param);
} else if(!strcmp(argv[i], "-n")) { // nickName } else if(!strcmp(argv[i], "-n")) { // nickName
++i; ++i;
ygo::mainGame->ebNickName->setText(GetParameterW(&argv[i][0])); wchar_t param[128];
GetParameterW(param, &argv[i][0]);
ygo::mainGame->ebNickName->setText(param);
} else if(!strcmp(argv[i], "-h")) { // Host address } else if(!strcmp(argv[i], "-h")) { // Host address
++i; ++i;
ygo::mainGame->ebJoinIP->setText(GetParameterW(&argv[i][0])); wchar_t param[128];
GetParameterW(param, &argv[i][0]);
ygo::mainGame->ebJoinIP->setText(param);
} else if(!strcmp(argv[i], "-p")) { // host Port } else if(!strcmp(argv[i], "-p")) { // host Port
++i; ++i;
ygo::mainGame->ebJoinPort->setText(GetParameterW(&argv[i][0])); wchar_t param[128];
GetParameterW(param, &argv[i][0]);
ygo::mainGame->ebJoinPort->setText(param);
} else if(!strcmp(argv[i], "-w")) { // host passWord } else if(!strcmp(argv[i], "-w")) { // host passWord
++i; ++i;
ygo::mainGame->ebJoinPass->setText(GetParameterW(&argv[i][0])); wchar_t param[128];
GetParameterW(param, &argv[i][0]);
ygo::mainGame->ebJoinPass->setText(param);
} else if(!strcmp(argv[i], "-x")) { // eXit on return } else if(!strcmp(argv[i], "-x")) { // eXit on return
exit_on_return = true; exit_on_return = true;
} else if(!strcmp(argv[i], "-j")) { // Join host } else if(!strcmp(argv[i], "-j")) { // Join host
ClickButton(ygo::mainGame->btnLanMode); ClickButton(ygo::mainGame->btnLanMode);
ClickButton(ygo::mainGame->btnJoinHost); ClickButton(ygo::mainGame->btnJoinHost);
break; break;
} else if(!strcmp(argv[i], "-o")) { // Open file
open_file = true;
++i;
wcscpy(open_file_name, GetParameterW(&argv[i][0]));
} else if(!strcmp(argv[i], "-d")) { // Deck } else if(!strcmp(argv[i], "-d")) { // Deck
if(i < argc) {
open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]);
}
ClickButton(ygo::mainGame->btnDeckEdit); ClickButton(ygo::mainGame->btnDeckEdit);
break; break;
} else if(!strcmp(argv[i], "-r")) { // Replay } else if(!strcmp(argv[i], "-r")) { // Replay
if(i < argc) {
open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]);
}
ClickButton(ygo::mainGame->btnReplayMode); ClickButton(ygo::mainGame->btnReplayMode);
ClickButton(ygo::mainGame->btnLoadReplay); if(open_file)
ClickButton(ygo::mainGame->btnLoadReplay);
break; break;
} else if(!strcmp(argv[i], "-s")) { // Single } else if(!strcmp(argv[i], "-s")) { // Single
if(i < argc) {
open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]);
}
ClickButton(ygo::mainGame->btnServerMode); ClickButton(ygo::mainGame->btnServerMode);
ClickButton(ygo::mainGame->btnLoadSinglePlay); if(open_file)
ClickButton(ygo::mainGame->btnLoadSinglePlay);
break; break;
} }
} }
ygo::mainGame->MainLoop(); ygo::mainGame->MainLoop();
#ifdef _WIN32 #ifdef _WIN32
......
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