diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index c869439cc1b..86521f5618b 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -330,6 +330,7 @@ class CEditor : public IEditor void AddGroup(); void AddTileLayer(); void AddFrontLayer(); + void AddQuadsLayer(); void LayerSelectImage(); bool IsNonGameTileLayerSelected() const; void MapDetails(); diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 4acc033d20f..e251ff240db 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -565,15 +565,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View, // new quad layer View.HSplitBottom(5.0f, &View, nullptr); View.HSplitBottom(12.0f, &View, &Button); - static int s_NewQuadLayerButton = 0; - if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, "Add quads layer", 0, &Button, 0, "Creates a new quad layer")) + if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddQuadsLayer, pEditor->m_QuickActionAddQuadsLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddQuadsLayer.Description())) { - std::shared_ptr pQuadLayer = std::make_shared(pEditor); - pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pQuadLayer); - int LayerIndex = pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1; - pEditor->SelectLayer(LayerIndex); - pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_Collapse = false; - pEditor->m_EditorHistory.RecordAction(std::make_shared(pEditor, pEditor->m_SelectedGroup, LayerIndex)); + pEditor->m_QuickActionAddQuadsLayer.Call(); return CUi::POPUP_CLOSE_CURRENT; } diff --git a/src/game/editor/quick_actions.cpp b/src/game/editor/quick_actions.cpp index b683bc58b41..ce302e28786 100644 --- a/src/game/editor/quick_actions.cpp +++ b/src/game/editor/quick_actions.cpp @@ -75,6 +75,16 @@ void CEditor::AddFrontLayer() m_EditorHistory.RecordAction(std::make_shared(this, m_SelectedGroup, LayerIndex)); } +void CEditor::AddQuadsLayer() +{ + std::shared_ptr pQuadLayer = std::make_shared(this); + m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pQuadLayer); + int LayerIndex = m_Map.m_vpGroups[m_SelectedGroup]->m_vpLayers.size() - 1; + SelectLayer(LayerIndex); + m_Map.m_vpGroups[m_SelectedGroup]->m_Collapse = false; + m_EditorHistory.RecordAction(std::make_shared(this, m_SelectedGroup, LayerIndex)); +} + bool CEditor::IsNonGameTileLayerSelected() const { std::shared_ptr pLayer = GetSelectedLayer(0); diff --git a/src/game/editor/quick_actions.h b/src/game/editor/quick_actions.h index 8cefb872571..476d8124601 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -177,6 +177,8 @@ REGISTER_QUICK_ACTION( ALWAYS_FALSE, DEFAULT_BTN, "Creates a new item layer.") +REGISTER_QUICK_ACTION( + AddQuadsLayer, "Add quads layer", [&]() { AddQuadsLayer(); }, ALWAYS_FALSE, ALWAYS_FALSE, DEFAULT_BTN, "Creates a new quads layer.") REGISTER_QUICK_ACTION( SaveAs, "Save As",