Commit 2cedcbb9 authored by mercury233's avatar mercury233 Committed by GitHub

fix card showing popup menu may be inaccurate (#2342)

parent 05d362b4
......@@ -15,6 +15,7 @@ ClientField::ClientField() {
hovered_card = 0;
clicked_card = 0;
highlighting_card = 0;
menu_card = 0;
hovered_controler = 0;
hovered_location = 0;
hovered_sequence = 0;
......@@ -83,6 +84,7 @@ void ClientField::Clear() {
hovered_card = 0;
clicked_card = 0;
highlighting_card = 0;
menu_card = 0;
hovered_controler = 0;
hovered_location = 0;
hovered_sequence = 0;
......
......@@ -132,6 +132,7 @@ public:
ClientCard* clicked_card;
ClientCard* command_card;
ClientCard* highlighting_card;
ClientCard* menu_card;
int list_command;
virtual bool OnEvent(const irr::SEvent& event);
......
......@@ -366,10 +366,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->wCmdMenu->setVisible(false);
ShowCancelOrFinishButton(0);
if(!list_command) {
if(!menu_card)
break;
select_options.clear();
select_options_index.clear();
for (size_t i = 0; i < activatable_cards.size(); ++i) {
if (activatable_cards[i] == clicked_card) {
if (activatable_cards[i] == menu_card) {
if(activatable_descs[i].second == EDESC_OPERATION)
continue;
else if(activatable_descs[i].second == EDESC_RESET) {
......@@ -392,7 +394,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
DuelClient::SendResponse();
} else {
command_card = clicked_card;
command_card = menu_card;
ShowSelectOption();
select_ready = false;
ShowCancelOrFinishButton(1);
......@@ -448,10 +450,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
case BUTTON_CMD_SUMMON: {
mainGame->wCmdMenu->setVisible(false);
if(!clicked_card)
if(!menu_card)
break;
for(size_t i = 0; i < summonable_cards.size(); ++i) {
if(summonable_cards[i] == clicked_card) {
if(summonable_cards[i] == menu_card) {
ClearCommandFlag();
DuelClient::SetResponseI(i << 16);
DuelClient::SendResponse();
......@@ -463,10 +465,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_CMD_SPSUMMON: {
mainGame->wCmdMenu->setVisible(false);
if(!list_command) {
if(!clicked_card)
if(!menu_card)
break;
for(size_t i = 0; i < spsummonable_cards.size(); ++i) {
if(spsummonable_cards[i] == clicked_card) {
if(spsummonable_cards[i] == menu_card) {
ClearCommandFlag();
DuelClient::SetResponseI((i << 16) + 1);
DuelClient::SendResponse();
......@@ -505,10 +507,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
case BUTTON_CMD_MSET: {
mainGame->wCmdMenu->setVisible(false);
if(!clicked_card)
if(!menu_card)
break;
for(size_t i = 0; i < msetable_cards.size(); ++i) {
if(msetable_cards[i] == clicked_card) {
if(msetable_cards[i] == menu_card) {
DuelClient::SetResponseI((i << 16) + 3);
DuelClient::SendResponse();
break;
......@@ -518,10 +520,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
case BUTTON_CMD_SSET: {
mainGame->wCmdMenu->setVisible(false);
if(!clicked_card)
if(!menu_card)
break;
for(size_t i = 0; i < ssetable_cards.size(); ++i) {
if(ssetable_cards[i] == clicked_card) {
if(ssetable_cards[i] == menu_card) {
DuelClient::SetResponseI((i << 16) + 4);
DuelClient::SendResponse();
break;
......@@ -531,10 +533,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
case BUTTON_CMD_REPOS: {
mainGame->wCmdMenu->setVisible(false);
if(!clicked_card)
if(!menu_card)
break;
for(size_t i = 0; i < reposable_cards.size(); ++i) {
if(reposable_cards[i] == clicked_card) {
if(reposable_cards[i] == menu_card) {
DuelClient::SetResponseI((i << 16) + 2);
DuelClient::SendResponse();
break;
......@@ -544,10 +546,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
case BUTTON_CMD_ATTACK: {
mainGame->wCmdMenu->setVisible(false);
if(!clicked_card)
if(!menu_card)
break;
for(size_t i = 0; i < attackable_cards.size(); ++i) {
if(attackable_cards[i] == clicked_card) {
if(attackable_cards[i] == menu_card) {
DuelClient::SetResponseI((i << 16) + 1);
DuelClient::SendResponse();
break;
......@@ -1560,7 +1562,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
SetShowMark(hovered_card, false);
}
if(mcard) {
if(mcard != clicked_card)
if(mcard != menu_card)
mainGame->wCmdMenu->setVisible(false);
if(hovered_location == LOCATION_HAND) {
mcard->is_hovered = true;
......@@ -2249,6 +2251,7 @@ void ClientField::ShowMenu(int flag, int x, int y) {
mainGame->wCmdMenu->setVisible(false);
return;
}
menu_card = clicked_card;
int height = 1;
int offset = mainGame->gameConf.resize_popup_menu ? ((mainGame->yScale >= 0.666) ? 21 * mainGame->yScale : 14) : 21;
if(flag & COMMAND_ACTIVATE) {
......
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