Skip to content

Commit

Permalink
update & fix hiding elements (Fluorohydride#2295)
Browse files Browse the repository at this point in the history
  • Loading branch information
mercury233 authored May 24, 2020
1 parent a4ee458 commit 697a6f7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 52 deletions.
2 changes: 2 additions & 0 deletions gframe/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,8 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
fadingList.push_back(fu);
}
void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
if(!win->isVisible() && !set_action)
return;
FadingUnit fu;
fu.fadingSize = win->getRelativePosition();
for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit)
Expand Down
39 changes: 9 additions & 30 deletions gframe/duelclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,24 +369,17 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dField.Clear();
mainGame->is_building = true;
mainGame->is_siding = true;
mainGame->CloseGameWindow();
mainGame->wChat->setVisible(false);
mainGame->wPhase->setVisible(false);
mainGame->wDeckEdit->setVisible(false);
mainGame->wFilter->setVisible(false);
mainGame->wSort->setVisible(false);
mainGame->stTip->setVisible(false);
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSideOK->setVisible(true);
mainGame->btnSideShuffle->setVisible(true);
mainGame->btnSideSort->setVisible(true);
mainGame->btnSideReload->setVisible(true);
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSpectatorSwap->setVisible(false);
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->btnShuffle->setVisible(false);
mainGame->deckBuilder.result_string[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0;
mainGame->deckBuilder.results.clear();
Expand Down Expand Up @@ -486,12 +479,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->SetStaticText(mainGame->stHostPrepRule, 180, mainGame->guiFont, str.c_str());
mainGame->RefreshDeck(mainGame->cbDeckSelect);
mainGame->cbDeckSelect->setEnabled(true);
if(mainGame->wCreateHost->isVisible())
mainGame->HideElement(mainGame->wCreateHost);
else if(mainGame->wLanWindow->isVisible())
mainGame->HideElement(mainGame->wLanWindow);
else if(mainGame->wSinglePlay->isVisible())
mainGame->HideElement(mainGame->wSinglePlay);
mainGame->HideElement(mainGame->wCreateHost);
mainGame->HideElement(mainGame->wLanWindow);
mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wHostPrepare);
if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true);
Expand Down Expand Up @@ -649,12 +639,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.lock();
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSpectatorSwap->setVisible(false);
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->wSurrender->setVisible(false);
mainGame->CloseGameButtons();
mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock();
Expand Down Expand Up @@ -688,14 +673,9 @@ 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);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->btnShuffle->setVisible(false);
mainGame->CloseGameButtons();
char* prep = pdata;
Replay new_replay;
memcpy(&new_replay.pheader, prep, sizeof(ReplayHeader));
Expand Down Expand Up @@ -2390,8 +2370,7 @@ 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);
mainGame->HideElement(mainGame->wSurrender);
if(!mainGame->dInfo.isReplay && mainGame->dInfo.player_type < 7) {
if(mainGame->gameConf.control_mode == 0) {
mainGame->btnChainIgnore->setVisible(true);
Expand Down
11 changes: 2 additions & 9 deletions gframe/event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false;
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->stTip->setVisible(false);
mainGame->wCardImg->setVisible(false);
mainGame->wInfos->setVisible(false);
mainGame->wPhase->setVisible(false);
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSpectatorSwap->setVisible(false);
mainGame->wChat->setVisible(false);
mainGame->CloseDuelWindow();
mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true);
Expand Down Expand Up @@ -1459,8 +1453,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->chain_when_avail = false;
UpdateChainButtons();
}
if(mainGame->wSurrender->isVisible())
mainGame->HideElement(mainGame->wSurrender);
mainGame->HideElement(mainGame->wSurrender);
mainGame->wCmdMenu->setVisible(false);
if(mainGame->fadingList.size())
break;
Expand Down
28 changes: 18 additions & 10 deletions gframe/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,17 @@ void Game::ClearTextures() {
}
imageManager.ClearTexture();
}
void Game::CloseDuelWindow() {
void Game::CloseGameButtons() {
btnChainIgnore->setVisible(false);
btnChainAlways->setVisible(false);
btnChainWhenAvail->setVisible(false);
btnCancelOrFinish->setVisible(false);
btnSpectatorSwap->setVisible(false);
btnShuffle->setVisible(false);
wSurrender->setVisible(false);
}
void Game::CloseGameWindow() {
CloseGameButtons();
for(auto wit = fadingList.begin(); wit != fadingList.end(); ++wit) {
if(wit->isFadein)
wit->autoFadeoutFrame = 1;
Expand All @@ -1488,34 +1498,32 @@ void Game::CloseDuelWindow() {
wANCard->setVisible(false);
wANNumber->setVisible(false);
wANRace->setVisible(false);
wCardImg->setVisible(false);
wCardSelect->setVisible(false);
wCardDisplay->setVisible(false);
wCmdMenu->setVisible(false);
wFTSelect->setVisible(false);
wHand->setVisible(false);
wInfos->setVisible(false);
wMessage->setVisible(false);
wOptions->setVisible(false);
wPhase->setVisible(false);
wPosSelect->setVisible(false);
wQuery->setVisible(false);
wSurrender->setVisible(false);
wReplayControl->setVisible(false);
wReplaySave->setVisible(false);
stHintMsg->setVisible(false);
stTip->setVisible(false);
}
void Game::CloseDuelWindow() {
CloseGameWindow();
wCardImg->setVisible(false);
wInfos->setVisible(false);
wChat->setVisible(false);
btnSideOK->setVisible(false);
btnSideShuffle->setVisible(false);
btnSideSort->setVisible(false);
btnSideReload->setVisible(false);
btnLeaveGame->setVisible(false);
btnSpectatorSwap->setVisible(false);
btnChainIgnore->setVisible(false);
btnChainAlways->setVisible(false);
btnChainWhenAvail->setVisible(false);
btnCancelOrFinish->setVisible(false);
btnShuffle->setVisible(false);
wChat->setVisible(false);
lstLog->clear();
logParam.clear();
lstHostList->clear();
Expand Down
4 changes: 3 additions & 1 deletion gframe/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ class Game {
void ClearChatMsg();
void AddDebugMsg(const char* msgbuf);
void ErrorLog(const char* msgbuf);
void ClearTextures();
void ClearTextures();
void CloseGameButtons();
void CloseGameWindow();
void CloseDuelWindow();

int LocalPlayer(int player);
Expand Down
3 changes: 1 addition & 2 deletions gframe/replay_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ void ReplayMode::EndDuel() {
mainGame->actionSignal.Reset();
mainGame->gMutex.lock();
mainGame->stMessage->setText(dataManager.GetSysString(1501));
if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect);
mainGame->HideElement(mainGame->wCardSelect);
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock();
mainGame->actionSignal.Wait();
Expand Down

0 comments on commit 697a6f7

Please sign in to comment.