diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 86521f561..ef85855c5 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -331,6 +331,7 @@ public: void AddTileLayer(); void AddFrontLayer(); void AddQuadsLayer(); + void DeleteSelectedLayer(); void LayerSelectImage(); bool IsNonGameTileLayerSelected() const; void MapDetails(); diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index e251ff240..b74f77bdc 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -708,23 +708,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 ce302e287..e7b6abf30 100644 --- a/src/game/editor/quick_actions.cpp +++ b/src/game/editor/quick_actions.cpp @@ -135,3 +135,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 476d81246..0541e3ca0 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -278,6 +278,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",