From 485be781aebde87af7572cffad1657828b8345c1 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Thu, 19 Sep 2024 07:53:33 +0800 Subject: [PATCH] Add confirm to layer deletion quick action --- src/game/editor/editor.h | 3 ++- src/game/editor/popups.cpp | 9 +++++++++ src/game/editor/quick_actions.h | 8 +++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index d1d3e04f9..ea9e8da0f 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -591,7 +591,8 @@ public: POPEVENT_PLACE_BORDER_TILES, POPEVENT_PIXELART_BIG_IMAGE, POPEVENT_PIXELART_MANY_COLORS, - POPEVENT_PIXELART_TOO_MANY_COLORS + POPEVENT_PIXELART_TOO_MANY_COLORS, + POPEVENT_DELETE_LAYER }; int m_PopupEventType; diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index a6db58dc1..7feaaed44 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -2035,6 +2035,11 @@ CUi::EPopupMenuFunctionResult CEditor::PopupEvent(void *pContext, CUIRect View, pTitle = "Too many colors"; pMessage = "The client only supports 64 images but more would be needed to add the selected image as tileart."; } + else if(pEditor->m_PopupEventType == POPEVENT_DELETE_LAYER) + { + pTitle = "Delete layer"; + pMessage = "This action can not be reverted.\n\nContinue anyway?"; + } else { dbg_assert(false, "m_PopupEventType invalid"); @@ -2141,6 +2146,10 @@ CUi::EPopupMenuFunctionResult CEditor::PopupEvent(void *pContext, CUIRect View, { pEditor->AddTileart(); } + else if(pEditor->m_PopupEventType == POPEVENT_DELETE_LAYER) + { + pEditor->DeleteSelectedLayer(); + } pEditor->m_PopupEventWasActivated = false; return CUi::POPUP_CLOSE_CURRENT; } diff --git a/src/game/editor/quick_actions.h b/src/game/editor/quick_actions.h index 237160f5d..c402d3f7b 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -279,7 +279,13 @@ REGISTER_QUICK_ACTION( REGISTER_QUICK_ACTION( DeleteLayer, "Delete layer", - [&]() { DeleteSelectedLayer(); }, + [&]() { + if(!m_PopupEventWasActivated) + { + m_PopupEventType = POPEVENT_DELETE_LAYER; + m_PopupEventActivated = true; + } + }, [&]() -> bool { std::shared_ptr pCurrentLayer = GetSelectedLayer(0); if(!pCurrentLayer)