Commit f101dc1b authored by fallenstardust's avatar fallenstardust Committed by GitHub

Merge pull request #47 from mercury233/patch-bot-deck

add select bot deck
parents dd58b547 035f9eab
...@@ -1019,14 +1019,18 @@ bool Game::Initialize(ANDROID_APP app) { ...@@ -1019,14 +1019,18 @@ bool Game::Initialize(ANDROID_APP app) {
ChangeToIGUIImageButton(btnBotCancel, imageManager.tButton_S, imageManager.tButton_S_pressed); ChangeToIGUIImageButton(btnBotCancel, imageManager.tButton_S, imageManager.tButton_S_pressed);
env->addStaticText(dataManager.GetSysString(1382), rect<s32>(310 * xScale, 10 * yScale, 500 * xScale, 30 * yScale), false, true, tabBot); env->addStaticText(dataManager.GetSysString(1382), rect<s32>(310 * xScale, 10 * yScale, 500 * xScale, 30 * yScale), false, true, tabBot);
stBotInfo = env->addStaticText(L"", rect<s32>(310 * xScale, 40 * yScale, 560 * xScale, 80 * yScale), false, true, tabBot); stBotInfo = env->addStaticText(L"", rect<s32>(310 * xScale, 40 * yScale, 560 * xScale, 80 * yScale), false, true, tabBot);
cbBotRule = CAndroidGUIComboBox::addAndroidComboBox(env, rect<s32>(310 * xScale, 90 * yScale, 530 * xScale, 120 * yScale), tabBot, COMBOBOX_BOT_RULE); cbBotDeckCategory = CAndroidGUIComboBox::addAndroidComboBox(env, rect<s32>(310 * xScale, 90 * yScale, 530 * xScale, 120 * yScale), tabBot, COMBOBOX_BOT_DECKCATEGORY);
cbBotDeckCategory->setVisible(false);
cbBotDeck = CAndroidGUIComboBox::addAndroidComboBox(env, rect<s32>(310 * xScale, 130 * yScale, 530 * xScale, 160 * yScale), tabBot);
cbBotDeck->setVisible(false);
cbBotRule = CAndroidGUIComboBox::addAndroidComboBox(env, rect<s32>(310 * xScale, 170 * yScale, 530 * xScale, 200 * yScale), tabBot, COMBOBOX_BOT_RULE);
cbBotRule->addItem(dataManager.GetSysString(1262)); cbBotRule->addItem(dataManager.GetSysString(1262));
cbBotRule->addItem(dataManager.GetSysString(1263)); cbBotRule->addItem(dataManager.GetSysString(1263));
cbBotRule->addItem(dataManager.GetSysString(1264)); cbBotRule->addItem(dataManager.GetSysString(1264));
cbBotRule->setSelected(gameConf.default_rule - 3); cbBotRule->setSelected(gameConf.default_rule - 3);
chkBotHand = env->addCheckBox(false, rect<s32>(310 * xScale, 130 * yScale, 500 * xScale, 160 * yScale), tabBot, -1, dataManager.GetSysString(1384)); chkBotHand = env->addCheckBox(false, rect<s32>(310 * xScale, 210 * yScale, 410 * xScale, 240 * yScale), tabBot, -1, dataManager.GetSysString(1384));
chkBotNoCheckDeck = env->addCheckBox(false, rect<s32>(310 * xScale, 170 * yScale, 500 * xScale, 200 * yScale), tabBot, -1, dataManager.GetSysString(1229)); chkBotNoCheckDeck = env->addCheckBox(false, rect<s32>(310 * xScale, 250 * yScale, 410 * xScale, 280 * yScale), tabBot, -1, dataManager.GetSysString(1229));
chkBotNoShuffleDeck = env->addCheckBox(false, rect<s32>(310 * xScale, 210 * yScale, 500 * xScale, 240 * yScale), tabBot, -1, dataManager.GetSysString(1230)); chkBotNoShuffleDeck = env->addCheckBox(false, rect<s32>(310 * xScale, 290 * yScale, 410 * xScale, 320 * yScale), tabBot, -1, dataManager.GetSysString(1230));
} else { // avoid null object reference } else { // avoid null object reference
btnStartBot = env->addButton(rect<s32>(0, 0, 0, 0), wSinglePlay); btnStartBot = env->addButton(rect<s32>(0, 0, 0, 0), wSinglePlay);
btnBotCancel = env->addButton(rect<s32>(0, 0, 0, 0), wSinglePlay); btnBotCancel = env->addButton(rect<s32>(0, 0, 0, 0), wSinglePlay);
...@@ -1601,6 +1605,7 @@ void Game::RefreshBot() { ...@@ -1601,6 +1605,7 @@ void Game::RefreshBot() {
newinfo.support_master_rule_3 = !!strstr(linebuf, "SUPPORT_MASTER_RULE_3"); newinfo.support_master_rule_3 = !!strstr(linebuf, "SUPPORT_MASTER_RULE_3");
newinfo.support_new_master_rule = !!strstr(linebuf, "SUPPORT_NEW_MASTER_RULE"); newinfo.support_new_master_rule = !!strstr(linebuf, "SUPPORT_NEW_MASTER_RULE");
newinfo.support_master_rule_2020 = !!strstr(linebuf, "SUPPORT_MASTER_RULE_2020"); newinfo.support_master_rule_2020 = !!strstr(linebuf, "SUPPORT_MASTER_RULE_2020");
newinfo.select_deckfile = !!strstr(linebuf, "SELECT_DECKFILE");
int rule = cbBotRule->getSelected() + 3; int rule = cbBotRule->getSelected() + 3;
if((rule == 3 && newinfo.support_master_rule_3) if((rule == 3 && newinfo.support_master_rule_3)
|| (rule == 4 && newinfo.support_new_master_rule) || (rule == 4 && newinfo.support_new_master_rule)
...@@ -1613,11 +1618,16 @@ void Game::RefreshBot() { ...@@ -1613,11 +1618,16 @@ void Game::RefreshBot() {
} }
lstBotList->clear(); lstBotList->clear();
stBotInfo->setText(L""); stBotInfo->setText(L"");
cbBotDeckCategory->setVisible(false);
cbBotDeck->setVisible(false);
for(unsigned int i = 0; i < botInfo.size(); ++i) { for(unsigned int i = 0; i < botInfo.size(); ++i) {
lstBotList->addItem(botInfo[i].name); lstBotList->addItem(botInfo[i].name);
} }
if(botInfo.size() == 0) if(botInfo.size() == 0) {
SetStaticText(stBotInfo, 200, guiFont, dataManager.GetSysString(1385)); SetStaticText(stBotInfo, 200, guiFont, dataManager.GetSysString(1385));
} else {
RefreshCategoryDeck(cbBotDeckCategory, cbBotDeck);
}
} }
void Game::LoadConfig() { void Game::LoadConfig() {
wchar_t wstr[256]; wchar_t wstr[256];
......
...@@ -102,6 +102,7 @@ struct BotInfo { ...@@ -102,6 +102,7 @@ struct BotInfo {
bool support_master_rule_3; bool support_master_rule_3;
bool support_new_master_rule; bool support_new_master_rule;
bool support_master_rule_2020; bool support_master_rule_2020;
bool select_deckfile;
}; };
struct FadingUnit { struct FadingUnit {
...@@ -389,6 +390,8 @@ public: ...@@ -389,6 +390,8 @@ public:
irr::gui::IGUIStaticText* stBotInfo; irr::gui::IGUIStaticText* stBotInfo;
irr::gui::IGUIButton* btnStartBot;// irr::gui::IGUIButton* btnStartBot;//
irr::gui::IGUIButton* btnBotCancel;// irr::gui::IGUIButton* btnBotCancel;//
irr::gui::IGUIComboBox* cbBotDeckCategory;
irr::gui::IGUIComboBox* cbBotDeck;
irr::gui::IGUIComboBox* cbBotRule; irr::gui::IGUIComboBox* cbBotRule;
irr::gui::IGUICheckBox* chkBotHand; irr::gui::IGUICheckBox* chkBotHand;
irr::gui::IGUICheckBox* chkBotNoCheckDeck; irr::gui::IGUICheckBox* chkBotNoCheckDeck;
...@@ -735,6 +738,7 @@ private: ...@@ -735,6 +738,7 @@ private:
#define LISTBOX_BOT_LIST 153 #define LISTBOX_BOT_LIST 153
#define BUTTON_BOT_START 154 #define BUTTON_BOT_START 154
#define COMBOBOX_BOT_RULE 155 #define COMBOBOX_BOT_RULE 155
#define COMBOBOX_BOT_DECKCATEGORY 156
#define EDITBOX_CHAT 199 #define EDITBOX_CHAT 199
#define BUTTON_MSG_OK 200 #define BUTTON_MSG_OK 200
......
...@@ -345,9 +345,17 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -345,9 +345,17 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
si.cb = sizeof(si); si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi)); ZeroMemory(&pi, sizeof(pi));
wchar_t cmd[MAX_PATH]; wchar_t cmd[MAX_PATH];
wchar_t arg1[512];
if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
myswprintf(arg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
}
else
myswprintf(arg1, L"%ls", mainGame->botInfo[sel].command);
int flag = 0; int flag = 0;
flag += (mainGame->chkBotHand->isChecked() ? 0x1 : 0); flag += (mainGame->chkBotHand->isChecked() ? 0x1 : 0);
myswprintf(cmd, L"Bot.exe \"%ls\" %d %d", mainGame->botInfo[sel].command, flag, mainGame->gameConf.serverport); myswprintf(cmd, L"Bot.exe \"%ls\" %d %d", arg1, flag, mainGame->gameConf.serverport);
if(!CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) if(!CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{ {
NetServer::StopServer(); NetServer::StopServer();
...@@ -355,8 +363,16 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -355,8 +363,16 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
#elif defined(_IRR_ANDROID_PLATFORM_) #elif defined(_IRR_ANDROID_PLATFORM_)
char args[512]; char args[512];
wchar_t warg1[512];
if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
myswprintf(warg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
}
else
myswprintf(warg1, L"%ls", mainGame->botInfo[sel].command);
char arg1[512]; char arg1[512];
BufferIO::EncodeUTF8(mainGame->botInfo[sel].command, arg1); BufferIO::EncodeUTF8(warg1, arg1);
char arg2[32]; char arg2[32];
arg2[0]=0; arg2[0]=0;
if(mainGame->chkBotHand->isChecked()) if(mainGame->chkBotHand->isChecked())
...@@ -374,8 +390,16 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -374,8 +390,16 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
#else #else
if(fork() == 0) { if(fork() == 0) {
usleep(100000); usleep(100000);
wchar_t warg1[512];
if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
myswprintf(warg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
}
else
myswprintf(warg1, L"%ls", mainGame->botInfo[sel].command);
char arg1[512]; char arg1[512];
BufferIO::EncodeUTF8(mainGame->botInfo[sel].command, arg1); BufferIO::EncodeUTF8(warg1, arg1);
int flag = 0; int flag = 0;
flag += (mainGame->chkBotHand->isChecked() ? 0x1 : 0); flag += (mainGame->chkBotHand->isChecked() ? 0x1 : 0);
char arg2[8]; char arg2[8];
...@@ -573,6 +597,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -573,6 +597,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(sel == -1) if(sel == -1)
break; break;
mainGame->SetStaticText(mainGame->stBotInfo, 200 * mainGame->xScale, mainGame->guiFont, mainGame->botInfo[sel].desc); mainGame->SetStaticText(mainGame->stBotInfo, 200 * mainGame->xScale, mainGame->guiFont, mainGame->botInfo[sel].desc);
mainGame->cbBotDeckCategory->setVisible(mainGame->botInfo[sel].select_deckfile);
mainGame->cbBotDeck->setVisible(mainGame->botInfo[sel].select_deckfile);
break; break;
} }
} }
...@@ -596,6 +622,18 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -596,6 +622,18 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case COMBOBOX_BOT_DECKCATEGORY: {
int catesel = mainGame->cbBotDeckCategory->getSelected();
if(catesel == 3) {
catesel = 2;
mainGame->cbBotDeckCategory->setSelected(2);
}
if(catesel >= 0) {
mainGame->RefreshDeck(mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
mainGame->cbBotDeck->setSelected(0);
}
break;
}
} }
break; break;
} }
......
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