Commit fef019ac authored by 独孤朲's avatar 独孤朲 Committed by GitHub

Merge pull request #1836 from mercury233/patch-cancel-button

add button for cancel or finish selecting
parents 9c69a7a8 62674b86
......@@ -1131,6 +1131,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
if(CheckSelectSum()) {
if(selectsum_cards.size() == 0 || selectable_cards.size() == 0) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true);
else {
......@@ -1151,6 +1152,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
if(CheckSelectSum()) {
if(selectsum_cards.size() == 0 || selectable_cards.size() == 0) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
DuelClient::SendResponse();
return true;
} else {
......@@ -1165,6 +1167,11 @@ bool ClientField::ShowSelectSum(bool panelmode) {
} else
select_ready = false;
}
if (select_ready) {
ShowCancelOrFinishButton(1);
} else {
ShowCancelOrFinishButton(0);
}
return false;
}
bool ClientField::CheckSelectSum() {
......
......@@ -126,7 +126,8 @@ public:
virtual bool OnEvent(const irr::SEvent& event);
void GetHoverField(int x, int y);
void ShowMenu(int flag, int x, int y);
void UpdateChainButtons();
void UpdateChainButtons();
void ShowCancelOrFinishButton(int buttonOp);
void SetResponseSelectedCards() const;
};
......
......@@ -288,6 +288,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->deckBuilder.result_string[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0;
mainGame->deckBuilder.results.clear();
......@@ -510,6 +511,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock();
......@@ -539,6 +541,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime);
char timebuf[40];
......@@ -1179,6 +1182,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
}
if (mainGame->dField.select_cancelable) {
mainGame->dField.ShowCancelOrFinishButton(1);
}
return false;
}
case MSG_SELECT_CHAIN: {
......@@ -1412,6 +1418,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
if (mainGame->dField.select_cancelable) {
mainGame->dField.ShowCancelOrFinishButton(1);
}
mainGame->gMutex.Unlock();
return false;
}
......@@ -1875,6 +1884,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
}
}
if(mainGame->dInfo.isTag && mainGame->dInfo.turn != 1) {
......
......@@ -148,6 +148,137 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
UpdateChainButtons();
break;
}
case BUTTON_CANCEL_OR_FINISH: {
switch (mainGame->dInfo.curMsg) {
case MSG_WAITING: {
if (mainGame->wCardSelect->isVisible()) {
mainGame->HideElement(mainGame->wCardSelect);
ShowCancelOrFinishButton(0);
}
break;
}
case MSG_SELECT_BATTLECMD: {
if (mainGame->wCardSelect->isVisible()) {
mainGame->HideElement(mainGame->wCardSelect);
ShowCancelOrFinishButton(0);
}
if (mainGame->wOptions->isVisible()) {
mainGame->HideElement(mainGame->wOptions);
ShowCancelOrFinishButton(0);
}
break;
}
case MSG_SELECT_IDLECMD: {
if (mainGame->wCardSelect->isVisible()) {
mainGame->HideElement(mainGame->wCardSelect);
ShowCancelOrFinishButton(0);
}
if (mainGame->wOptions->isVisible()) {
mainGame->HideElement(mainGame->wOptions);
ShowCancelOrFinishButton(0);
}
break;
}
case MSG_SELECT_YESNO:
case MSG_SELECT_EFFECTYN: {
if (highlighting_card)
highlighting_card->is_highlighting = false;
highlighting_card = 0;
DuelClient::SetResponseI(0);
mainGame->HideElement(mainGame->wQuery, true);
break;
}
case MSG_SELECT_CARD: {
if (selected_cards.size() == 0) {
if (select_cancelable) {
DuelClient::SetResponseI(-1);
ShowCancelOrFinishButton(0);
if (mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true);
else
DuelClient::SendResponse();
}
break;
}
if (mainGame->wQuery->isVisible()) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wQuery, true);
break;
}
if (select_ready) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
if (mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true);
else
DuelClient::SendResponse();
}
break;
}
case MSG_SELECT_TRIBUTE: {
if (selected_cards.size() == 0) {
if (select_cancelable) {
DuelClient::SetResponseI(-1);
if (mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true);
else
DuelClient::SendResponse();
}
break;
}
if (mainGame->wQuery->isVisible()) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wQuery, true);
break;
}
break;
}
case MSG_SELECT_SUM: {
if (mainGame->wQuery->isVisible()) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wQuery, true);
break;
}
break;
}
case MSG_SELECT_CHAIN: {
if (chain_forced)
break;
if (mainGame->wCardSelect->isVisible()) {
mainGame->HideElement(mainGame->wCardSelect);
ShowCancelOrFinishButton(0);
break;
}
if (mainGame->wQuery->isVisible()) {
DuelClient::SetResponseI(-1);
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wQuery, true);
}
else {
mainGame->PopupElement(mainGame->wQuery);
ShowCancelOrFinishButton(0);
}
if (mainGame->wOptions->isVisible()) {
DuelClient::SetResponseI(-1);
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wOptions);
}
break;
}
case MSG_SORT_CHAIN:
case MSG_SORT_CARD: {
if (mainGame->wCardSelect->isVisible()) {
DuelClient::SetResponseI(-1);
mainGame->HideElement(mainGame->wCardSelect, true);
}
break;
}
}
break;
}
case BUTTON_MSG_OK: {
mainGame->HideElement(mainGame->wMessage);
mainGame->actionSignal.Set();
......@@ -164,13 +295,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->HideElement(mainGame->wQuery, true);
break;
}
case MSG_SELECT_CHAIN:
case MSG_SELECT_CARD:
case MSG_SELECT_TRIBUTE:
case MSG_SELECT_SUM: {
mainGame->HideElement(mainGame->wQuery);
break;
}
case MSG_SELECT_CHAIN: {
mainGame->HideElement(mainGame->wQuery);
if (!chain_forced) {
ShowCancelOrFinishButton(1);
}
break;
}
default: {
mainGame->HideElement(mainGame->wQuery);
break;
......@@ -192,12 +329,14 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case MSG_SELECT_CHAIN: {
DuelClient::SetResponseI(-1);
mainGame->HideElement(mainGame->wQuery, true);
ShowCancelOrFinishButton(0);
break;
}
case MSG_SELECT_CARD:
case MSG_SELECT_TRIBUTE:
case MSG_SELECT_SUM: {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wQuery, true);
break;
}
......@@ -285,6 +424,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_CMD_ACTIVATE:
case BUTTON_CMD_RESET: {
mainGame->wCmdMenu->setVisible(false);
ShowCancelOrFinishButton(0);
if(!list_command) {
int index = -1;
select_options.clear();
......@@ -412,6 +552,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
list_command = COMMAND_SPSUMMON;
mainGame->wCardSelect->setText(dataManager.GetSysString(509));
ShowSelectCard();
ShowCancelOrFinishButton(1);
}
break;
}
......@@ -607,13 +748,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
int sel = selected_cards.size();
if (sel >= select_max) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wCardSelect, true);
} else if (sel >= select_min) {
select_ready = true;
mainGame->btnSelectOK->setVisible(true);
ShowCancelOrFinishButton(2);
} else {
select_ready = false;
mainGame->btnSelectOK->setVisible(false);
if (select_cancelable && sel == 0)
ShowCancelOrFinishButton(1);
else
ShowCancelOrFinishButton(0);
}
break;
}
......@@ -670,6 +817,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(mainGame->dInfo.curMsg == MSG_SELECT_CARD || mainGame->dInfo.curMsg == MSG_SELECT_SUM) {
if(select_ready) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wCardSelect, true);
}
break;
......@@ -1253,13 +1401,16 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
if (min >= select_max) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
DuelClient::SendResponse();
} else if (max >= select_min) {
if(selected_cards.size() == selectable_cards.size()) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
DuelClient::SendResponse();
} else {
select_ready = true;
ShowCancelOrFinishButton(2);
if(mainGame->dInfo.curMsg == MSG_SELECT_TRIBUTE) {
wchar_t wbuf[256], *pwbuf = wbuf;
BufferIO::CopyWStrRef(dataManager.GetSysString(209), pwbuf, 256);
......@@ -1271,6 +1422,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
} else {
select_ready = false;
if (select_cancelable && min == 0)
ShowCancelOrFinishButton(1);
else
ShowCancelOrFinishButton(0);
}
break;
}
......@@ -1326,24 +1481,29 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case MSG_WAITING: {
if(mainGame->wCardSelect->isVisible()) {
mainGame->HideElement(mainGame->wCardSelect);
ShowCancelOrFinishButton(0);
}
break;
}
case MSG_SELECT_BATTLECMD: {
if(mainGame->wCardSelect->isVisible()) {
mainGame->HideElement(mainGame->wCardSelect);
ShowCancelOrFinishButton(0);
}
if(mainGame->wOptions->isVisible()) {
mainGame->HideElement(mainGame->wOptions);
ShowCancelOrFinishButton(0);
}
break;
}
case MSG_SELECT_IDLECMD: {
if(mainGame->wCardSelect->isVisible()) {
mainGame->HideElement(mainGame->wCardSelect);
ShowCancelOrFinishButton(0);
}
if(mainGame->wOptions->isVisible()) {
mainGame->HideElement(mainGame->wOptions);
ShowCancelOrFinishButton(0);
}
break;
}
......@@ -1360,6 +1520,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(selected_cards.size() == 0) {
if(select_cancelable) {
DuelClient::SetResponseI(-1);
ShowCancelOrFinishButton(0);
if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true);
else
......@@ -1369,11 +1530,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
if(mainGame->wQuery->isVisible()) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wQuery, true);
break;
}
if(select_ready) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true);
else
......@@ -1394,6 +1557,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
if(mainGame->wQuery->isVisible()) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wQuery, true);
break;
}
......@@ -1402,6 +1566,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case MSG_SELECT_SUM: {
if(mainGame->wQuery->isVisible()) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wQuery, true);
break;
}
......@@ -1412,16 +1577,20 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
if(mainGame->wCardSelect->isVisible()) {
mainGame->HideElement(mainGame->wCardSelect);
ShowCancelOrFinishButton(0);
break;
}
if(mainGame->wQuery->isVisible()) {
DuelClient::SetResponseI(-1);
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wQuery, true);
} else {
mainGame->PopupElement(mainGame->wQuery);
ShowCancelOrFinishButton(0);
}
if(mainGame->wOptions->isVisible()) {
DuelClient::SetResponseI(-1);
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wOptions);
}
break;
......@@ -2006,6 +2175,26 @@ void ClientField::UpdateChainButtons() {
mainGame->btnChainWhenAvail->setPressed(mainGame->chain_when_avail);
}
}
void ClientField::ShowCancelOrFinishButton(int buttonOp) {
if (!mainGame->chkHideChainButton->isChecked() && !mainGame->dInfo.isReplay) {
switch (buttonOp) {
case 1:
mainGame->btnCancelOrFinish->setText(dataManager.GetSysString(1295));
mainGame->btnCancelOrFinish->setVisible(true);
break;
case 2:
mainGame->btnCancelOrFinish->setText(dataManager.GetSysString(1296));
mainGame->btnCancelOrFinish->setVisible(true);
break;
case 0:
default:
mainGame->btnCancelOrFinish->setVisible(false);
break;
}
} else {
mainGame->btnCancelOrFinish->setVisible(false);
}
}
void ClientField::SetResponseSelectedCards() const {
unsigned char respbuf[64];
respbuf[0] = selected_cards.size();
......
......@@ -541,6 +541,9 @@ bool Game::Initialize() {
btnChainIgnore->setVisible(false);
btnChainAlways->setVisible(false);
btnChainWhenAvail->setVisible(false);
//cancel or finish
btnCancelOrFinish = env->addButton(rect<s32>(205, 230, 295, 265), 0, BUTTON_CANCEL_OR_FINISH, dataManager.GetSysString(1295));
btnCancelOrFinish->setVisible(false);
//leave/surrender/exit
btnLeaveGame = env->addButton(rect<s32>(205, 5, 295, 80), 0, BUTTON_LEAVE_GAME, L"");
btnLeaveGame->setVisible(false);
......@@ -1122,6 +1125,7 @@ void Game::CloseDuelWindow() {
btnChainIgnore->setVisible(false);
btnChainAlways->setVisible(false);
btnChainWhenAvail->setVisible(false);
btnCancelOrFinish->setVisible(false);
wChat->setVisible(false);
lstLog->clear();
logParam.clear();
......
......@@ -395,7 +395,8 @@ public:
irr::gui::IGUIButton* btnChainIgnore;
irr::gui::IGUIButton* btnChainAlways;
irr::gui::IGUIButton* btnChainWhenAvail;
//cancel or finish
irr::gui::IGUIButton* btnCancelOrFinish;
};
extern Game* mainGame;
......@@ -486,6 +487,7 @@ extern Game* mainGame;
#define BUTTON_CHAIN_IGNORE 264
#define BUTTON_CHAIN_ALWAYS 265
#define BUTTON_CHAIN_WHENAVAIL 266
#define BUTTON_CANCEL_OR_FINISH 267
#define BUTTON_CLEAR_LOG 270
#define LISTBOX_LOG 271
#define SCROLL_CARDTEXT 280
......
......@@ -286,6 +286,8 @@
!system 1292 忽略时点
!system 1293 显示时点
!system 1294 可用时点
!system 1295 取消操作
!system 1296 完成选择
!system 1300 禁限卡表:
!system 1301 卡组列表:
!system 1302 保存
......
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