Add quick action "Add quads layer"

This commit is contained in:
ChillerDragon 2024-09-18 19:23:11 +08:00
parent e72ace24f2
commit ec6ddc5ef7
4 changed files with 15 additions and 8 deletions

View file

@ -329,6 +329,7 @@ public:
void AddGroup();
void AddTileLayer();
void AddFrontLayer();
void AddQuadsLayer();
void LayerSelectImage();
bool IsNonGameTileLayerSelected() const;
void MapDetails();

View file

@ -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<CLayer> pQuadLayer = std::make_shared<CLayerQuads>(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<CEditorActionAddLayer>(pEditor, pEditor->m_SelectedGroup, LayerIndex));
pEditor->m_QuickActionAddQuadsLayer.Call();
return CUi::POPUP_CLOSE_CURRENT;
}

View file

@ -48,6 +48,16 @@ void CEditor::AddFrontLayer()
m_EditorHistory.RecordAction(std::make_shared<CEditorActionAddLayer>(this, m_SelectedGroup, LayerIndex));
}
void CEditor::AddQuadsLayer()
{
std::shared_ptr<CLayer> pQuadLayer = std::make_shared<CLayerQuads>(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<CEditorActionAddLayer>(this, m_SelectedGroup, LayerIndex));
}
bool CEditor::IsNonGameTileLayerSelected() const
{
std::shared_ptr<CLayer> pLayer = GetSelectedLayer(0);

View file

@ -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",