diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 6206cea25..2587321cd 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -328,6 +328,7 @@ public: bool CanFillGameTiles() const; void AddGroup(); void AddTileLayer(); + void AddFrontLayer(); void LayerSelectImage(); bool IsNonGameTileLayerSelected() const; #define REGISTER_QUICK_ACTION(name, text, callback, disabled, active, button_color, description) CQuickAction m_QuickAction##name; diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index d1f0d8ab3..22805ba41 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -543,16 +543,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View, // new front layer View.HSplitBottom(5.0f, &View, nullptr); View.HSplitBottom(12.0f, &View, &Button); - static int s_NewFrontLayerButton = 0; - if(pEditor->DoButton_Editor(&s_NewFrontLayerButton, "Add front layer", 0, &Button, 0, "Creates a new item layer")) + if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddFrontLayer, pEditor->m_QuickActionAddFrontLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddFrontLayer.Description())) { - std::shared_ptr pFrontLayer = std::make_shared(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height); - pEditor->m_Map.MakeFrontLayer(pFrontLayer); - pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pFrontLayer); - int LayerIndex = pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_vpLayers.size() - 1; - pEditor->SelectLayer(LayerIndex); - pEditor->m_pBrush->Clear(); - pEditor->m_EditorHistory.RecordAction(std::make_shared(pEditor, pEditor->m_SelectedGroup, LayerIndex)); + pEditor->m_QuickActionAddFrontLayer.Call(); return CUi::POPUP_CLOSE_CURRENT; } } diff --git a/src/game/editor/quick_actions.cpp b/src/game/editor/quick_actions.cpp index d1a063949..6bdc8b16b 100644 --- a/src/game/editor/quick_actions.cpp +++ b/src/game/editor/quick_actions.cpp @@ -37,6 +37,17 @@ void CEditor::AddTileLayer() m_EditorHistory.RecordAction(std::make_shared(this, m_SelectedGroup, LayerIndex)); } +void CEditor::AddFrontLayer() +{ + std::shared_ptr pFrontLayer = std::make_shared(this, m_Map.m_pGameLayer->m_Width, m_Map.m_pGameLayer->m_Height); + m_Map.MakeFrontLayer(pFrontLayer); + m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pFrontLayer); + int LayerIndex = m_Map.m_vpGroups[m_SelectedGroup]->m_vpLayers.size() - 1; + SelectLayer(LayerIndex); + m_pBrush->Clear(); + 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 5e1a04fe8..418dfe7fd 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -169,6 +169,14 @@ REGISTER_QUICK_ACTION( "Toggles proof borders. These borders represent the area that a player can see with default zoom.") REGISTER_QUICK_ACTION( AddTileLayer, "Add tile layer", [&]() { AddTileLayer(); }, ALWAYS_FALSE, ALWAYS_FALSE, DEFAULT_BTN, "Creates a new tile layer.") +REGISTER_QUICK_ACTION( + AddFrontLayer, + "Add front layer", + [&]() { AddFrontLayer(); }, + [&]() -> bool { return !GetSelectedGroup()->m_GameGroup || m_Map.m_pFrontLayer; }, + ALWAYS_FALSE, + DEFAULT_BTN, + "Creates a new item layer.") REGISTER_QUICK_ACTION( SaveAs, "Save As",