From e20250cd6504e384d53bf256f81b6e740ed0e4b2 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 1 Sep 2024 08:15:58 +0800 Subject: [PATCH] Add quick action "Load Current Map" --- src/game/editor/popups.cpp | 12 ++---------- src/game/editor/quick_actions.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 45844b64a..0b070e301 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -68,17 +68,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupMenuFile(void *pContext, CUIRect Vie View.HSplitTop(2.0f, nullptr, &View); View.HSplitTop(12.0f, &Slot, &View); - if(pEditor->DoButton_MenuItem(&s_OpenCurrentMapButton, "Load Current Map", 0, &Slot, 0, "Opens the current in game map for editing (ctrl+alt+l)")) + if(pEditor->DoButton_MenuItem(&s_OpenCurrentMapButton, pEditor->m_QuickActionLoadCurrentMap.Label(), 0, &Slot, 0, pEditor->m_QuickActionLoadCurrentMap.Description())) { - if(pEditor->HasUnsavedData()) - { - pEditor->m_PopupEventType = POPEVENT_LOADCURRENT; - pEditor->m_PopupEventActivated = true; - } - else - { - pEditor->LoadCurrentMap(); - } + pEditor->m_QuickActionLoadCurrentMap.Call(); return CUi::POPUP_CLOSE_CURRENT; } diff --git a/src/game/editor/quick_actions.h b/src/game/editor/quick_actions.h index 8264b0432..d89dee77f 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -29,6 +29,24 @@ REGISTER_QUICK_ACTION( ALWAYS_FALSE, DEFAULT_BTN, "Saves the current map under a new name (ctrl+shift+s)") +REGISTER_QUICK_ACTION( + LoadCurrentMap, + "Load Current Map", + [&]() { + if(HasUnsavedData()) + { + m_PopupEventType = POPEVENT_LOADCURRENT; + m_PopupEventActivated = true; + } + else + { + LoadCurrentMap(); + } + }, + ALWAYS_FALSE, + ALWAYS_FALSE, + DEFAULT_BTN, + "Opens the current in game map for editing (ctrl+alt+l)") REGISTER_QUICK_ACTION( Envelopes, "Envelopes",