diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 4fe6498ff..a52c9d73c 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -329,6 +329,7 @@ public: void AddGroup(); void AddTileLayer(); void AddFrontLayer(); + void DeleteSelectedLayer(); void LayerSelectImage(); bool IsNonGameTileLayerSelected() const; void MapDetails(); diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 4acc033d2..a6db58dc1 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -714,23 +714,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupLayer(void *pContext, CUIRect View, { CUIRect DeleteButton; View.HSplitBottom(12.0f, &View, &DeleteButton); - static int s_DeleteButton = 0; - if(pEditor->DoButton_Editor(&s_DeleteButton, "Delete layer", 0, &DeleteButton, 0, "Deletes the layer")) + if(pEditor->DoButton_Editor(&pEditor->m_QuickActionDeleteLayer, pEditor->m_QuickActionDeleteLayer.Label(), 0, &DeleteButton, 0, pEditor->m_QuickActionDeleteLayer.Description())) { - pEditor->m_EditorHistory.RecordAction(std::make_shared(pEditor, pEditor->m_SelectedGroup, pEditor->m_vSelectedLayers[0])); - - if(pCurrentLayer == pEditor->m_Map.m_pFrontLayer) - pEditor->m_Map.m_pFrontLayer = nullptr; - if(pCurrentLayer == pEditor->m_Map.m_pTeleLayer) - pEditor->m_Map.m_pTeleLayer = nullptr; - if(pCurrentLayer == pEditor->m_Map.m_pSpeedupLayer) - pEditor->m_Map.m_pSpeedupLayer = nullptr; - if(pCurrentLayer == pEditor->m_Map.m_pSwitchLayer) - pEditor->m_Map.m_pSwitchLayer = nullptr; - if(pCurrentLayer == pEditor->m_Map.m_pTuneLayer) - pEditor->m_Map.m_pTuneLayer = nullptr; - pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->DeleteLayer(pEditor->m_vSelectedLayers[0]); - + pEditor->m_QuickActionDeleteLayer.Call(); return CUi::POPUP_CLOSE_CURRENT; } } diff --git a/src/game/editor/quick_actions.cpp b/src/game/editor/quick_actions.cpp index 1ea46c45d..59b1b48e9 100644 --- a/src/game/editor/quick_actions.cpp +++ b/src/game/editor/quick_actions.cpp @@ -98,3 +98,26 @@ void CEditor::MapDetails() PopupMapInfo); Ui()->SetActiveItem(nullptr); } + +void CEditor::DeleteSelectedLayer() +{ + std::shared_ptr pCurrentLayer = GetSelectedLayer(0); + if(!pCurrentLayer) + return; + if(m_Map.m_pGameLayer == pCurrentLayer) + return; + + m_EditorHistory.RecordAction(std::make_shared(this, m_SelectedGroup, m_vSelectedLayers[0])); + + if(pCurrentLayer == m_Map.m_pFrontLayer) + m_Map.m_pFrontLayer = nullptr; + if(pCurrentLayer == m_Map.m_pTeleLayer) + m_Map.m_pTeleLayer = nullptr; + if(pCurrentLayer == m_Map.m_pSpeedupLayer) + m_Map.m_pSpeedupLayer = nullptr; + if(pCurrentLayer == m_Map.m_pSwitchLayer) + m_Map.m_pSwitchLayer = nullptr; + if(pCurrentLayer == m_Map.m_pTuneLayer) + m_Map.m_pTuneLayer = nullptr; + m_Map.m_vpGroups[m_SelectedGroup]->DeleteLayer(m_vSelectedLayers[0]); +} diff --git a/src/game/editor/quick_actions.h b/src/game/editor/quick_actions.h index cf5d49333..237160f5d 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -276,6 +276,19 @@ REGISTER_QUICK_ACTION( [&]() -> bool { return m_ShowTileInfo == SHOW_TILE_HEXADECIMAL; }, DEFAULT_BTN, "[Ctrl+Shift+I] Show tile information in hexadecimal.") +REGISTER_QUICK_ACTION( + DeleteLayer, + "Delete layer", + [&]() { DeleteSelectedLayer(); }, + [&]() -> bool { + std::shared_ptr pCurrentLayer = GetSelectedLayer(0); + if(!pCurrentLayer) + return true; + return m_Map.m_pGameLayer == pCurrentLayer; + }, + ALWAYS_FALSE, + DEFAULT_BTN, + "Deletes the layer.") REGISTER_QUICK_ACTION( Pipette, "Pipette",