Commit ca11c21b authored by mercury233's avatar mercury233 Committed by GitHub

add surrender confirm (#2144)

parent 8c4e6544
......@@ -641,6 +641,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->wSurrender->setVisible(false);
mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock();
......@@ -674,6 +675,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
case STOC_REPLAY: {
mainGame->gMutex.Lock();
mainGame->wPhase->setVisible(false);
mainGame->wSurrender->setVisible(false);
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnChainIgnore->setVisible(false);
......@@ -2272,6 +2274,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1351));
mainGame->btnLeaveGame->setVisible(true);
}
if(mainGame->wSurrender->isVisible())
mainGame->HideElement(mainGame->wSurrender);
if(!mainGame->dInfo.isReplay && mainGame->dInfo.player_type < 7) {
if(mainGame->gameConf.control_mode == 0) {
mainGame->btnChainIgnore->setVisible(true);
......
......@@ -147,8 +147,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(exit_on_return)
mainGame->device->closeDevice();
} else {
mainGame->PopupElement(mainGame->wSurrender);
}
break;
}
case BUTTON_SURRENDER_YES: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
DuelClient::SendPacketToServer(CTOS_SURRENDER);
mainGame->HideElement(mainGame->wSurrender);
break;
}
case BUTTON_SURRENDER_NO: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->HideElement(mainGame->wSurrender);
break;
}
case BUTTON_CHAIN_IGNORE: {
......@@ -1422,6 +1433,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->chain_when_avail = false;
UpdateChainButtons();
}
if(mainGame->wSurrender->isVisible())
mainGame->HideElement(mainGame->wSurrender);
mainGame->wCmdMenu->setVisible(false);
if(mainGame->fadingList.size())
break;
......
......@@ -385,6 +385,14 @@ bool Game::Initialize() {
stQMessage->setTextAlignment(irr::gui::EGUIA_UPPERLEFT, irr::gui::EGUIA_CENTER);
btnYes = env->addButton(rect<s32>(100, 105, 150, 130), wQuery, BUTTON_YES, dataManager.GetSysString(1213));
btnNo = env->addButton(rect<s32>(200, 105, 250, 130), wQuery, BUTTON_NO, dataManager.GetSysString(1214));
//surrender yes/no (310)
wSurrender = env->addWindow(rect<s32>(490, 200, 840, 340), false, dataManager.GetSysString(560));
wSurrender->getCloseButton()->setVisible(false);
wSurrender->setVisible(false);
stSurrenderMessage = env->addStaticText(dataManager.GetSysString(1359), rect<s32>(20, 20, 350, 100), false, true, wSurrender, -1, false);
stSurrenderMessage->setTextAlignment(irr::gui::EGUIA_UPPERLEFT, irr::gui::EGUIA_CENTER);
btnSurrenderYes = env->addButton(rect<s32>(100, 105, 150, 130), wSurrender, BUTTON_SURRENDER_YES, dataManager.GetSysString(1213));
btnSurrenderNo = env->addButton(rect<s32>(200, 105, 250, 130), wSurrender, BUTTON_SURRENDER_NO, dataManager.GetSysString(1214));
//options (310)
wOptions = env->addWindow(rect<s32>(490, 200, 840, 340), false, L"");
wOptions->getCloseButton()->setVisible(false);
......@@ -1458,6 +1466,7 @@ void Game::CloseDuelWindow() {
wPhase->setVisible(false);
wPosSelect->setVisible(false);
wQuery->setVisible(false);
wSurrender->setVisible(false);
wReplayControl->setVisible(false);
wReplaySave->setVisible(false);
stHintMsg->setVisible(false);
......
......@@ -381,6 +381,11 @@ public:
irr::gui::IGUIStaticText* stQMessage;
irr::gui::IGUIButton* btnYes;
irr::gui::IGUIButton* btnNo;
//surrender yes/no
irr::gui::IGUIWindow* wSurrender;
irr::gui::IGUIStaticText* stSurrenderMessage;
irr::gui::IGUIButton* btnSurrenderYes;
irr::gui::IGUIButton* btnSurrenderNo;
//options
irr::gui::IGUIWindow* wOptions;
irr::gui::IGUIStaticText* stOptions;
......@@ -655,6 +660,8 @@ extern Game* mainGame;
#define BUTTON_DISPLAY_4 294
#define SCROLL_CARD_DISPLAY 295
#define BUTTON_CARD_DISP_OK 296
#define BUTTON_SURRENDER_YES 297
#define BUTTON_SURRENDER_NO 298
#define COMBOBOX_DBLFLIST 301
#define COMBOBOX_DBDECKS 302
......
......@@ -181,6 +181,8 @@ void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
PlaySoundEffect(SOUND_INFO);
} else if(element == mainGame->wQuery) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wSurrender) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wOptions) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANAttribute) {
......
......@@ -392,6 +392,7 @@
!system 1356 是否要放弃对卡组的修改?
!system 1357 不提示保留对卡组的修改
!system 1358 键入关键字后自动进行搜索
!system 1359 是否确定投降?
!system 1360 上一步
!system 1361 删除录像
!system 1362 重命名
......
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