Skip to content

Commit

Permalink
Use member instead of static variables for confirm popup buttons
Browse files Browse the repository at this point in the history
Otherwise this would cause issues when showing multiple confirm popups at the same time.
  • Loading branch information
Robyt3 committed Jul 15, 2023
1 parent cfdc696 commit 104e74a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/game/client/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,15 +1463,13 @@ CUI::EPopupMenuFunctionResult CUI::PopupConfirm(void *pContext, CUIRect View, bo

pUI->TextRender()->Text(Label.x, Label.y, SConfirmPopupContext::POPUP_FONT_SIZE, pConfirmPopup->m_aMessage, Label.w);

static CButtonContainer s_CancelButton;
if(pUI->DoButton_PopupMenu(&s_CancelButton, pConfirmPopup->m_aNegativeButtonLabel, &CancelButton, SConfirmPopupContext::POPUP_FONT_SIZE, TEXTALIGN_MC))
if(pUI->DoButton_PopupMenu(&pConfirmPopup->m_CancelButton, pConfirmPopup->m_aNegativeButtonLabel, &CancelButton, SConfirmPopupContext::POPUP_FONT_SIZE, TEXTALIGN_MC))
{
pConfirmPopup->m_Result = SConfirmPopupContext::CANCELED;
return CUI::POPUP_CLOSE_CURRENT;
}

static CButtonContainer s_ConfirmButton;
if(pUI->DoButton_PopupMenu(&s_ConfirmButton, pConfirmPopup->m_aPositiveButtonLabel, &ConfirmButton, SConfirmPopupContext::POPUP_FONT_SIZE, TEXTALIGN_MC) || (Active && pUI->ConsumeHotkey(HOTKEY_ENTER)))
if(pUI->DoButton_PopupMenu(&pConfirmPopup->m_ConfirmButton, pConfirmPopup->m_aPositiveButtonLabel, &ConfirmButton, SConfirmPopupContext::POPUP_FONT_SIZE, TEXTALIGN_MC) || (Active && pUI->ConsumeHotkey(HOTKEY_ENTER)))
{
pConfirmPopup->m_Result = SConfirmPopupContext::CONFIRMED;
return CUI::POPUP_CLOSE_CURRENT;
Expand Down
3 changes: 3 additions & 0 deletions src/game/client/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ class CUI
char m_aMessage[1024];
EConfirmationResult m_Result;

CButtonContainer m_CancelButton;
CButtonContainer m_ConfirmButton;

SConfirmPopupContext();
void Reset();
void YesNoButtons();
Expand Down

0 comments on commit 104e74a

Please sign in to comment.