Add confirm to layer deletion quick action

This commit is contained in:
ChillerDragon 2024-09-19 07:53:33 +08:00
parent 4874f75bc0
commit 485be781ae
3 changed files with 18 additions and 2 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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<CLayer> pCurrentLayer = GetSelectedLayer(0);
if(!pCurrentLayer)