Commit 16c1daf3 authored by Fluorohydride's avatar Fluorohydride

Merge pull request #47 from zh99998/master

command line support
parents 5cd246e4 cbf15224
......@@ -62,5 +62,6 @@ using namespace gui;
extern const unsigned short PRO_VERSION;
extern bool enable_log;
extern bool exit_on_return;
#endif
......@@ -71,7 +71,9 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->scrFilter->setVisible(false);
if(mainGame->cbDBDecks->getSelected() != -1) {
BufferIO::CopyWStr(mainGame->cbDBDecks->getItem(mainGame->cbDBDecks->getSelected()), mainGame->gameConf.lastdeck, 64);
}
}
if(exit_on_return)
mainGame->device->closeDevice();
break;
}
case BUTTON_EFFECT_FILTER: {
......
......@@ -432,6 +432,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->ShowElement(mainGame->wLanWindow);
mainGame->gMutex.Unlock();
event_base_loopbreak(client_base);
if(exit_on_return)
mainGame->device->closeDevice();
break;
}
case STOC_REPLAY: {
......
......@@ -83,7 +83,7 @@ bool Game::Initialize() {
ebJoinPort = env->addEditBox(gameConf.lastport, rect<s32>(260, 355, 320, 380), true, wLanWindow);
ebJoinPort->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
env->addStaticText(dataManager.GetSysString(1222), rect<s32>(10, 390, 220, 410), false, false, wLanWindow);
ebJoinPass = env->addEditBox(L"", rect<s32>(110, 385, 250, 410), true, wLanWindow);
ebJoinPass = env->addEditBox(gameConf.roompass, rect<s32>(110, 385, 250, 410), true, wLanWindow);
ebJoinPass->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
btnJoinHost = env->addButton(rect<s32>(460, 355, 570, 380), wLanWindow, BUTTON_JOIN_HOST, dataManager.GetSysString(1223));
btnJoinCancel = env->addButton(rect<s32>(460, 385, 570, 410), wLanWindow, BUTTON_JOIN_CANCEL, dataManager.GetSysString(1212));
......@@ -643,6 +643,7 @@ void Game::LoadConfig() {
gameConf.textfont[0] = 0;
gameConf.lastip[0] = 0;
gameConf.lastport[0] = 0;
gameConf.roompass[0] = 0;
fseek(fp, 0, SEEK_END);
size_t fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
......@@ -675,6 +676,9 @@ void Game::LoadConfig() {
} else if(!strcmp(strbuf, "lastport")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastport, 20);
} else if(!strcmp(strbuf, "roompass")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.roompass, 20);
}
}
fclose(fp);
......
......@@ -22,6 +22,7 @@ struct Config {
wchar_t lastdeck[64];
wchar_t textfont[256];
wchar_t numfont[256];
wchar_t roompass[20];
};
struct DuelInfo {
......@@ -82,10 +83,10 @@ public:
void ShowCardInfo(int code);
void ClearTextures();
void CloseDuelWindow();
int LocalPlayer(int player);
const wchar_t* LocalName(int local_player);
Mutex gMutex;
Mutex gBuffer;
Signal frameSignal;
......@@ -93,7 +94,7 @@ public:
Signal replaySignal;
Config gameConf;
DuelInfo dInfo;
std::list<FadingUnit> fadingList;
std::vector<int> logParam;
unsigned short linePattern;
......@@ -119,7 +120,7 @@ public:
bool is_building;
bool is_siding;
ClientField dField;
DeckBuilder deckBuilder;
MenuHandler menuHandler;
......
......@@ -3,6 +3,7 @@
#include <event2/thread.h>
bool enable_log = false;
bool exit_on_return = false;
int main(int argc, char* argv[]) {
#ifdef _WIN32
......@@ -18,8 +19,34 @@ int main(int argc, char* argv[]) {
ygo::mainGame = &_game;
if(!ygo::mainGame->Initialize())
return 0;
if(argc >= 2 && !strcmp(argv[1], "-debug"))
enable_log = true;
if(argc >= 2)
if(!strcmp(argv[1], "-debug"))
enable_log = true;
/*command line args:
* -j: join host (host info from system.conf)
* -d: deck edit
* -r: replay */
else if(!strcmp(argv[1], "-j") or !strcmp(argv[1], "-d") or !strcmp(argv[1], "-r")){
exit_on_return = true;
irr::SEvent event;
event.EventType = irr::EET_GUI_EVENT;
event.GUIEvent.EventType = irr::gui::EGET_BUTTON_CLICKED;
if(!strcmp(argv[1], "-j")){
event.GUIEvent.Caller = ygo::mainGame->btnLanMode;
ygo::mainGame->device->postEventFromUser(event);
event.GUIEvent.Caller = ygo::mainGame->btnJoinHost;
ygo::mainGame->device->postEventFromUser(event);
}else if(!strcmp(argv[1], "-d")){
event.GUIEvent.Caller = ygo::mainGame->btnDeckEdit;
ygo::mainGame->device->postEventFromUser(event);
}else if(!strcmp(argv[1], "-r")){
event.GUIEvent.Caller = ygo::mainGame->btnReplayMode;
ygo::mainGame->device->postEventFromUser(event);
ygo::mainGame->lstReplayList->setSelected(0);
event.GUIEvent.Caller = ygo::mainGame->btnLoadReplay;
}
}
ygo::mainGame->MainLoop();
#ifdef _WIN32
WSACleanup();
......
......@@ -115,6 +115,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->btnJoinCancel->setEnabled(true);
mainGame->HideElement(mainGame->wHostSingle);
mainGame->ShowElement(mainGame->wLanWindow);
if(exit_on_return)
mainGame->device->closeDevice();
break;
}
case BUTTON_REPLAY_MODE: {
......
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