mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 21:48:19 +00:00
Add quick action "Add front layer"
This commit is contained in:
parent
60624d5599
commit
3781f95190
|
@ -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;
|
||||
|
|
|
@ -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<CLayer> pFrontLayer = std::make_shared<CLayerFront>(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<CEditorActionAddLayer>(pEditor, pEditor->m_SelectedGroup, LayerIndex));
|
||||
pEditor->m_QuickActionAddFrontLayer.Call();
|
||||
return CUi::POPUP_CLOSE_CURRENT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,17 @@ void CEditor::AddTileLayer()
|
|||
m_EditorHistory.RecordAction(std::make_shared<CEditorActionAddLayer>(this, m_SelectedGroup, LayerIndex));
|
||||
}
|
||||
|
||||
void CEditor::AddFrontLayer()
|
||||
{
|
||||
std::shared_ptr<CLayer> pFrontLayer = std::make_shared<CLayerFront>(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<CEditorActionAddLayer>(this, m_SelectedGroup, LayerIndex));
|
||||
}
|
||||
|
||||
bool CEditor::IsNonGameTileLayerSelected() const
|
||||
{
|
||||
std::shared_ptr<CLayer> pLayer = GetSelectedLayer(0);
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue