diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 47fc71c41..30c9730a2 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -1096,7 +1096,7 @@ public: void UiInvokePopupMenu(void *pID, int Flags, float X, float Y, float W, float H, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect, void *pContext), void *pContext = nullptr); void UiDoPopupMenu(); - void UiClosePopupMenus(); + void UiClosePopupMenus(int Menus = 0); bool UiPopupExists(void *pID); bool UiPopupOpen(); diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index a935276e5..f60554f72 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -86,29 +86,20 @@ void CEditor::UiDoPopupMenu() r.Draw(ColorRGBA(0, 0, 0, 0.75f), Corners, 3.0f); r.Margin(4.0f, &r); - if(s_UiPopups[i].m_pfnFunc(this, r, s_UiPopups[i].m_pContext)) - { - m_LockMouse = false; - UI()->SetActiveItem(nullptr); - g_UiNumPopups--; - m_PopupEventWasActivated = false; - } - - if(Input()->KeyPress(KEY_ESCAPE)) - { - m_LockMouse = false; - UI()->SetActiveItem(nullptr); - g_UiNumPopups--; - m_PopupEventWasActivated = false; - } + if(s_UiPopups[i].m_pfnFunc(this, r, s_UiPopups[i].m_pContext) || Input()->KeyPress(KEY_ESCAPE)) + UiClosePopupMenus(1); } } -void CEditor::UiClosePopupMenus() +void CEditor::UiClosePopupMenus(int Menus) { + if(Menus <= 0) + Menus = g_UiNumPopups; + if(Menus <= 0) + return; m_LockMouse = false; UI()->SetActiveItem(nullptr); - g_UiNumPopups = 0; + g_UiNumPopups = maximum(0, g_UiNumPopups - Menus); m_PopupEventWasActivated = false; } @@ -1252,7 +1243,7 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View, void *pContext) if(pEditor->m_PopupEventType != POPEVENT_LARGELAYER && pEditor->m_PopupEventType != POPEVENT_PREVENTUNUSEDTILES && pEditor->m_PopupEventType != POPEVENT_IMAGEDIV16 && pEditor->m_PopupEventType != POPEVENT_IMAGE_MAX) { static int s_AbortButton = 0; - if(pEditor->DoButton_Editor(&s_AbortButton, "Abort", 0, &Label, 0, nullptr) || pEditor->Input()->KeyPress(KEY_ESCAPE)) + if(pEditor->DoButton_Editor(&s_AbortButton, "Abort", 0, &Label, 0, nullptr)) { pEditor->m_PopupEventWasActivated = false; return 1;