Commit ce46da81 authored by edo9300's avatar edo9300

Changed master rule handling

parent 42b51d9c
...@@ -127,7 +127,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -127,7 +127,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
cscg.info.draw_count = _wtoi(mainGame->ebDrawCount->getText()); cscg.info.draw_count = _wtoi(mainGame->ebDrawCount->getText());
cscg.info.time_limit = _wtoi(mainGame->ebTimeLimit->getText()); cscg.info.time_limit = _wtoi(mainGame->ebTimeLimit->getText());
cscg.info.lflist = mainGame->cbLFlist->getItemData(mainGame->cbLFlist->getSelected()); cscg.info.lflist = mainGame->cbLFlist->getItemData(mainGame->cbLFlist->getSelected());
cscg.info.duel_rule = mainGame->cbDuelRule->getSelected() + 1; cscg.info.duel_rule = ((mainGame->cbDuelRule->getSelected() + 1) << 16) | mainGame->duel_param;
cscg.info.no_check_deck = mainGame->chkNoCheckDeck->isChecked(); cscg.info.no_check_deck = mainGame->chkNoCheckDeck->isChecked();
cscg.info.no_shuffle_deck = mainGame->chkNoShuffleDeck->isChecked(); cscg.info.no_shuffle_deck = mainGame->chkNoShuffleDeck->isChecked();
cscg.info.sealed = mainGame->chkRules[0]->isChecked() ? 2 : 0; cscg.info.sealed = mainGame->chkRules[0]->isChecked() ? 2 : 0;
...@@ -377,8 +377,17 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -377,8 +377,17 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
str.append(msgbuf); str.append(msgbuf);
myswprintf(msgbuf, L"%ls%d\n", dataManager.GetSysString(1233), pkt->info.draw_count); myswprintf(msgbuf, L"%ls%d\n", dataManager.GetSysString(1233), pkt->info.draw_count);
str.append(msgbuf); str.append(msgbuf);
if(pkt->info.duel_rule != DEFAULT_DUEL_RULE) { uint32 rule = pkt->info.duel_rule >> 16;
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1260 + pkt->info.duel_rule - 1)); if(rule == 5) {
uint32 flag = pkt->info.duel_rule & 0xffff, filter = 0x100;
for (int i = 0; i < 5; ++i, filter <<= 1)
if (flag & filter) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1265 + i));
str2.append(msgbuf);
host2 = true;
}
} else if(rule != DEFAULT_DUEL_RULE) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1260 + rule - 1));
str.append(msgbuf); str.append(msgbuf);
} }
if(pkt->info.no_check_deck) { if(pkt->info.no_check_deck) {
...@@ -512,7 +521,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -512,7 +521,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->ShowElement(mainGame->wHostPrepare2); mainGame->ShowElement(mainGame->wHostPrepare2);
mainGame->wChat->setVisible(true); mainGame->wChat->setVisible(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->dInfo.duel_rule = pkt->info.duel_rule; mainGame->dInfo.duel_rule = 4;
if(((pkt->info.duel_rule & 0xffff) & DUEL_NO_PZONE) && ((pkt->info.duel_rule & 0xffff) & DUEL_NO_EMZONE))
mainGame->dInfo.duel_rule = 2;
else if((pkt->info.duel_rule & 0xffff) & DUEL_NO_EMZONE)
mainGame->dInfo.duel_rule = 3;
mainGame->dInfo.speed = (pkt->info.speed == 2) ? 1 : 0; mainGame->dInfo.speed = (pkt->info.speed == 2) ? 1 : 0;
watching = 0; watching = 0;
connect_state |= 0x4; connect_state |= 0x4;
......
...@@ -162,12 +162,23 @@ bool Game::Initialize() { ...@@ -162,12 +162,23 @@ bool Game::Initialize() {
for(int i = 0; i < 14; ++i) for(int i = 0; i < 14; ++i)
chkRules[i] = env->addCheckBox(false, recti(10 + (i % 2) * 150, 10 + (i / 2) * 20, 200 + (i % 2) * 120, 30 + (i / 2) * 20), wRules, 353+i, dataManager.GetSysString(1132 + i)); chkRules[i] = env->addCheckBox(false, recti(10 + (i % 2) * 150, 10 + (i / 2) * 20, 200 + (i % 2) * 120, 30 + (i / 2) * 20), wRules, 353+i, dataManager.GetSysString(1132 + i));
env->addStaticText(dataManager.GetSysString(1236), rect<s32>(20, 180, 220, 200), false, false, wCreateHost); env->addStaticText(dataManager.GetSysString(1236), rect<s32>(20, 180, 220, 200), false, false, wCreateHost);
cbDuelRule = env->addComboBox(rect<s32>(140, 175, 300, 200), wCreateHost); cbDuelRule = env->addComboBox(rect<s32>(140, 175, 300, 200), wCreateHost, COMBOBOX_DUEL_RULE);
cbDuelRule->addItem(dataManager.GetSysString(1260)); cbDuelRule->addItem(dataManager.GetSysString(1260));
cbDuelRule->addItem(dataManager.GetSysString(1261)); cbDuelRule->addItem(dataManager.GetSysString(1261));
cbDuelRule->addItem(dataManager.GetSysString(1262)); cbDuelRule->addItem(dataManager.GetSysString(1262));
cbDuelRule->addItem(dataManager.GetSysString(1263)); cbDuelRule->addItem(dataManager.GetSysString(1263));
//cbDuelRule->addItem(dataManager.GetSysString(1264));
cbDuelRule->setSelected(DEFAULT_DUEL_RULE - 1); cbDuelRule->setSelected(DEFAULT_DUEL_RULE - 1);
btnCustomRule = env->addButton(rect<s32>(305, 175, 370, 200), wCreateHost, BUTTON_CUSTOM_RULE, dataManager.GetSysString(1626));
wCustomRules = env->addWindow(rect<s32>(700, 100, 910, 280), false, dataManager.strBuffer);
wCustomRules->getCloseButton()->setVisible(false);
wCustomRules->setDrawTitlebar(false);
wCustomRules->setDraggable(true);
wCustomRules->setVisible(false);
for(int i = 0; i < 5; ++i)
chkCustomRules[i] = env->addCheckBox(false, recti(10, 10 + i * 20, 200, 30 + i * 20), wCustomRules, 353+i, dataManager.GetSysString(1265 + i));
btnCustomRulesOK = env->addButton(rect<s32>(55, 130, 155, 155), wCustomRules, BUTTON_CUSTOM_RULE_OK, dataManager.GetSysString(1211));
duel_param = 0;
chkNoCheckDeck = env->addCheckBox(false, rect<s32>(20, 210, 170, 230), wCreateHost, -1, dataManager.GetSysString(1229)); chkNoCheckDeck = env->addCheckBox(false, rect<s32>(20, 210, 170, 230), wCreateHost, -1, dataManager.GetSysString(1229));
chkNoShuffleDeck = env->addCheckBox(false, rect<s32>(180, 210, 360, 230), wCreateHost, -1, dataManager.GetSysString(1230)); chkNoShuffleDeck = env->addCheckBox(false, rect<s32>(180, 210, 360, 230), wCreateHost, -1, dataManager.GetSysString(1230));
env->addStaticText(dataManager.GetSysString(1231), rect<s32>(20, 240, 320, 260), false, false, wCreateHost); env->addStaticText(dataManager.GetSysString(1231), rect<s32>(20, 240, 320, 260), false, false, wCreateHost);
...@@ -194,7 +205,7 @@ bool Game::Initialize() { ...@@ -194,7 +205,7 @@ bool Game::Initialize() {
wHostPrepare2 = env->addWindow(rect<s32>(750, 120, 950, 440), false, dataManager.GetSysString(1625)); wHostPrepare2 = env->addWindow(rect<s32>(750, 120, 950, 440), false, dataManager.GetSysString(1625));
wHostPrepare2->getCloseButton()->setVisible(false); wHostPrepare2->getCloseButton()->setVisible(false);
wHostPrepare2->setVisible(false); wHostPrepare2->setVisible(false);
stHostPrepRule2 = env->addStaticText(L"", rect<s32>(10, 30, 460, 230), false, true, wHostPrepare2); stHostPrepRule2 = env->addStaticText(L"", rect<s32>(10, 30, 460, 350), false, true, wHostPrepare2);
wHostPrepare = env->addWindow(rect<s32>(270, 120, 750, 440), false, dataManager.GetSysString(1250)); wHostPrepare = env->addWindow(rect<s32>(270, 120, 750, 440), false, dataManager.GetSysString(1250));
wHostPrepare->getCloseButton()->setVisible(false); wHostPrepare->getCloseButton()->setVisible(false);
wHostPrepare->setVisible(false); wHostPrepare->setVisible(false);
...@@ -1439,6 +1450,7 @@ void Game::OnResize() ...@@ -1439,6 +1450,7 @@ void Game::OnResize()
wHostPrepare->setRelativePosition(ResizeWin(270, 120, 750, 440)); wHostPrepare->setRelativePosition(ResizeWin(270, 120, 750, 440));
wHostPrepare2->setRelativePosition(ResizeWin(750, 120, 950, 440)); wHostPrepare2->setRelativePosition(ResizeWin(750, 120, 950, 440));
wRules->setRelativePosition(ResizeWin(630, 100, 1000, 310)); wRules->setRelativePosition(ResizeWin(630, 100, 1000, 310));
wCustomRules->setRelativePosition(ResizeWin(700, 100, 910, 280));
wReplay->setRelativePosition(ResizeWin(220, 100, 800, 520)); wReplay->setRelativePosition(ResizeWin(220, 100, 800, 520));
wSinglePlay->setRelativePosition(ResizeWin(220, 100, 800, 520)); wSinglePlay->setRelativePosition(ResizeWin(220, 100, 800, 520));
......
...@@ -184,6 +184,7 @@ public: ...@@ -184,6 +184,7 @@ public:
bool is_building; bool is_building;
bool is_siding; bool is_siding;
uint32 duel_param;
irr::core::dimension2d<irr::u32> window_size; irr::core::dimension2d<irr::u32> window_size;
...@@ -267,6 +268,10 @@ public: ...@@ -267,6 +268,10 @@ public:
irr::gui::IGUICheckBox* chkRules[14]; irr::gui::IGUICheckBox* chkRules[14];
irr::gui::IGUIButton* btnRulesOK; irr::gui::IGUIButton* btnRulesOK;
irr::gui::IGUIComboBox* cbDuelRule; irr::gui::IGUIComboBox* cbDuelRule;
irr::gui::IGUIButton* btnCustomRule;
irr::gui::IGUICheckBox* chkCustomRules[5];
irr::gui::IGUIWindow* wCustomRules;
irr::gui::IGUIButton* btnCustomRulesOK;
irr::gui::IGUICheckBox* chkNoCheckDeck; irr::gui::IGUICheckBox* chkNoCheckDeck;
irr::gui::IGUICheckBox* chkNoShuffleDeck; irr::gui::IGUICheckBox* chkNoShuffleDeck;
irr::gui::IGUIButton* btnHostConfirm; irr::gui::IGUIButton* btnHostConfirm;
...@@ -506,6 +511,7 @@ extern Game* mainGame; ...@@ -506,6 +511,7 @@ extern Game* mainGame;
#define BUTTON_LAN_REFRESH 116 #define BUTTON_LAN_REFRESH 116
#define BUTTON_RULE_CARDS 117 #define BUTTON_RULE_CARDS 117
#define BUTTON_RULE_OK 118 #define BUTTON_RULE_OK 118
#define BUTTON_CUSTOM_RULE 119
#define BUTTON_HP_DUELIST 120 #define BUTTON_HP_DUELIST 120
#define BUTTON_HP_OBSERVER 121 #define BUTTON_HP_OBSERVER 121
#define BUTTON_HP_START 122 #define BUTTON_HP_START 122
...@@ -514,6 +520,8 @@ extern Game* mainGame; ...@@ -514,6 +520,8 @@ extern Game* mainGame;
#define CHECKBOX_HP_READY 125 #define CHECKBOX_HP_READY 125
#define BUTTON_HP_READY 126 #define BUTTON_HP_READY 126
#define BUTTON_HP_NOTREADY 127 #define BUTTON_HP_NOTREADY 127
#define COMBOBOX_DUEL_RULE 128
#define BUTTON_CUSTOM_RULE_OK 129
#define LISTBOX_REPLAY_LIST 130 #define LISTBOX_REPLAY_LIST 130
#define BUTTON_LOAD_REPLAY 131 #define BUTTON_LOAD_REPLAY 131
#define BUTTON_CANCEL_REPLAY 132 #define BUTTON_CANCEL_REPLAY 132
......
...@@ -31,6 +31,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -31,6 +31,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
case irr::EET_GUI_EVENT: { case irr::EET_GUI_EVENT: {
irr::gui::IGUIElement* caller = event.GUIEvent.Caller; irr::gui::IGUIElement* caller = event.GUIEvent.Caller;
s32 id = caller->getID(); s32 id = caller->getID();
if(mainGame->wRules->isVisible() && (id != BUTTON_RULE_OK && (id <CHECK_SEALED_DUEL || id>CHECK_DECK_MASTER_DUEL)))
break;
if(mainGame->wCustomRules->isVisible() && id != BUTTON_CUSTOM_RULE_OK)
break;
switch(event.GUIEvent.EventType) { switch(event.GUIEvent.EventType) {
case irr::gui::EGET_ELEMENT_HOVERED: { case irr::gui::EGET_ELEMENT_HOVERED: {
// Set cursor to an I-Beam if hovering over an edit box // Set cursor to an I-Beam if hovering over an edit box
...@@ -120,17 +124,55 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -120,17 +124,55 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_RULE_CARDS: { case BUTTON_RULE_CARDS: {
if(mainGame->wRules->isVisible()){ mainGame->PopupElement(mainGame->wRules);
mainGame->HideElement(mainGame->wRules);
}else {
mainGame->PopupElement(mainGame->wRules);
}
break; break;
} }
case BUTTON_RULE_OK: { case BUTTON_RULE_OK: {
mainGame->HideElement(mainGame->wRules); mainGame->HideElement(mainGame->wRules);
break; break;
} }
case BUTTON_CUSTOM_RULE: {
mainGame->PopupElement(mainGame->wCustomRules);
break;
}
case BUTTON_CUSTOM_RULE_OK: {
uint32 flag = 0, filter = 0x100;
for(int i = 0; i < 5; ++i, filter <<= 1)
if(mainGame->chkCustomRules[i]->isChecked()) {
flag |= filter;
}
mainGame->cbDuelRule->clear();
mainGame->cbDuelRule->addItem(dataManager.GetSysString(1260));
mainGame->cbDuelRule->addItem(dataManager.GetSysString(1261));
mainGame->cbDuelRule->addItem(dataManager.GetSysString(1262));
mainGame->cbDuelRule->addItem(dataManager.GetSysString(1263));
switch (flag) {
case 0x1F00: {
mainGame->cbDuelRule->setSelected(0);
break;
}
case 0x1E00: {
mainGame->cbDuelRule->setSelected(1);
break;
}
case 0x1000: {
mainGame->cbDuelRule->setSelected(2);
break;
}
case 0: {
mainGame->cbDuelRule->setSelected(3);
break;
}
default: {
mainGame->cbDuelRule->addItem(dataManager.GetSysString(1264));
mainGame->cbDuelRule->setSelected(4);
break;
}
}
mainGame->duel_param = flag;
mainGame->HideElement(mainGame->wCustomRules);
break;
}
case BUTTON_HOST_CONFIRM: { case BUTTON_HOST_CONFIRM: {
BufferIO::CopyWStr(mainGame->ebServerName->getText(), mainGame->gameConf.gamename, 20); BufferIO::CopyWStr(mainGame->ebServerName->getText(), mainGame->gameConf.gamename, 20);
if(!NetServer::StartServer(mainGame->gameConf.serverport)) if(!NetServer::StartServer(mainGame->gameConf.serverport))
...@@ -139,7 +181,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -139,7 +181,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
NetServer::StopServer(); NetServer::StopServer();
break; break;
} }
mainGame->HideElement(mainGame->wRules);
mainGame->btnHostConfirm->setEnabled(false); mainGame->btnHostConfirm->setEnabled(false);
mainGame->btnHostCancel->setEnabled(false); mainGame->btnHostCancel->setEnabled(false);
break; break;
...@@ -202,7 +243,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -202,7 +243,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->HideElement(mainGame->wHostPrepare); mainGame->HideElement(mainGame->wHostPrepare);
mainGame->HideElement(mainGame->wHostPrepare2); if(mainGame->wHostPrepare2->isVisible())
mainGame->HideElement(mainGame->wHostPrepare2);
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
mainGame->wChat->setVisible(false); mainGame->wChat->setVisible(false);
if(exit_on_return) if(exit_on_return)
...@@ -495,6 +537,40 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -495,6 +537,40 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case irr::gui::EGET_COMBO_BOX_CHANGED: {
switch (id) {
case COMBOBOX_DUEL_RULE: {
switch (mainGame->cbDuelRule->getSelected()) {
case 0:{
mainGame->cbDuelRule->removeItem(4);
mainGame->duel_param = 0x1F00;
break;
}
case 1: {
mainGame->cbDuelRule->removeItem(4);
mainGame->duel_param = 0x1E00;
break;
}
case 2: {
mainGame->cbDuelRule->removeItem(4);
mainGame->duel_param = 0x1000;
break;
}
case 3: {
mainGame->cbDuelRule->removeItem(4);
mainGame->duel_param = 0;
break;
}
}
uint32 flag = 0, filter = 0x100;
for (int i = 0; i < 5; ++i, filter <<= 1)
if (mainGame->duel_param & filter)
mainGame->chkCustomRules[i]->setChecked(true);
else
mainGame->chkCustomRules[i]->setChecked(false);
}
}
}
default: break; default: break;
} }
break; break;
......
...@@ -15,7 +15,7 @@ struct HostInfo { ...@@ -15,7 +15,7 @@ struct HostInfo {
unsigned int lflist; unsigned int lflist;
unsigned char rule; unsigned char rule;
unsigned char mode; unsigned char mode;
unsigned char duel_rule; unsigned int duel_rule;
bool no_check_deck; bool no_check_deck;
bool no_shuffle_deck; bool no_shuffle_deck;
unsigned int start_lp; unsigned int start_lp;
......
...@@ -80,8 +80,11 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -80,8 +80,11 @@ int ReplayMode::ReplayThread(void* param) {
int start_hand = cur_replay.ReadInt32(); int start_hand = cur_replay.ReadInt32();
int draw_count = cur_replay.ReadInt32(); int draw_count = cur_replay.ReadInt32();
int opt = cur_replay.ReadInt32(); int opt = cur_replay.ReadInt32();
int duel_rule = opt >> 16; mainGame->dInfo.duel_rule = 4;
mainGame->dInfo.duel_rule = duel_rule; if (((opt & 0xffff) & DUEL_NO_PZONE) && ((opt & 0xffff) & DUEL_NO_EMZONE))
mainGame->dInfo.duel_rule = 2;
else if ((opt & 0xffff) & DUEL_NO_EMZONE)
mainGame->dInfo.duel_rule = 3;
mainGame->dInfo.speed = (opt & SPEED_DUEL) ? 1 : 0; mainGame->dInfo.speed = (opt & SPEED_DUEL) ? 1 : 0;
set_player_info(pduel, 0, start_lp, start_hand, draw_count); set_player_info(pduel, 0, start_lp, start_hand, draw_count);
set_player_info(pduel, 1, start_lp, start_hand, draw_count); set_player_info(pduel, 1, start_lp, start_hand, draw_count);
......
...@@ -413,7 +413,29 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -413,7 +413,29 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
pduel = create_duel(rnd.rand()); pduel = create_duel(rnd.rand());
set_player_info(pduel, 0, host_info.start_lp, host_info.start_hand, host_info.draw_count); set_player_info(pduel, 0, host_info.start_lp, host_info.start_hand, host_info.draw_count);
set_player_info(pduel, 1, host_info.start_lp, host_info.start_hand, host_info.draw_count); set_player_info(pduel, 1, host_info.start_lp, host_info.start_hand, host_info.draw_count);
int opt = (int)host_info.duel_rule << 16; int opt = host_info.duel_rule;
switch (opt) {
case 0x1F00: {
opt |= (1 << 16);
break;
}
case 0x1E00: {
opt |= (2 << 16);
break;
}
case 0x1000: {
opt |= (3 << 16);
break;
}
case 0: {
opt |= (4 << 16);
break;
}
default: {
opt |= (5 << 16);
break;
}
}
if(host_info.no_shuffle_deck) if(host_info.no_shuffle_deck)
opt |= DUEL_PSEUDO_SHUFFLE; opt |= DUEL_PSEUDO_SHUFFLE;
if(host_info.speed) if(host_info.speed)
......
...@@ -382,7 +382,29 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -382,7 +382,29 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
pduel = create_duel(rnd.rand()); pduel = create_duel(rnd.rand());
set_player_info(pduel, 0, host_info.start_lp, host_info.start_hand, host_info.draw_count); set_player_info(pduel, 0, host_info.start_lp, host_info.start_hand, host_info.draw_count);
set_player_info(pduel, 1, host_info.start_lp, host_info.start_hand, host_info.draw_count); set_player_info(pduel, 1, host_info.start_lp, host_info.start_hand, host_info.draw_count);
int opt = (int)host_info.duel_rule << 16; int opt = host_info.duel_rule;
switch (opt) {
case 0x1F00: {
opt |= (1 << 16);
break;
}
case 0x1E00: {
opt |= (2 << 16);
break;
}
case 0x1000: {
opt |= (3 << 16);
break;
}
case 0: {
opt |= (4 << 16);
break;
}
default: {
opt |= (5 << 16);
break;
}
}
if(host_info.no_shuffle_deck) if(host_info.no_shuffle_deck)
opt |= DUEL_PSEUDO_SHUFFLE; opt |= DUEL_PSEUDO_SHUFFLE;
if(host_info.speed) if(host_info.speed)
......
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