mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 21:48:19 +00:00
Merge pull request #9026 from ChillerDragon/pr_qas_add_layers
Add quick actions for adding sound, switch, front, tune, speedup and tele layers
This commit is contained in:
commit
09203aee78
|
@ -332,9 +332,14 @@ public:
|
|||
bool CanFillGameTiles() const;
|
||||
void AddQuadOrSound();
|
||||
void AddGroup();
|
||||
void AddSoundLayer();
|
||||
void AddTileLayer();
|
||||
void AddFrontLayer();
|
||||
void AddQuadsLayer();
|
||||
void AddSwitchLayer();
|
||||
void AddFrontLayer();
|
||||
void AddTuneLayer();
|
||||
void AddSpeedupLayer();
|
||||
void AddTeleLayer();
|
||||
void DeleteSelectedLayer();
|
||||
void LayerSelectImage();
|
||||
bool IsNonGameTileLayerSelected() const;
|
||||
|
|
|
@ -479,16 +479,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
|||
// new tele layer
|
||||
View.HSplitBottom(5.0f, &View, nullptr);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewTeleLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewTeleLayerButton, "Add tele layer", 0, &Button, 0, "Creates a new tele layer"))
|
||||
if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddTeleLayer, pEditor->m_QuickActionAddTeleLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddTeleLayer.Description()))
|
||||
{
|
||||
std::shared_ptr<CLayer> pTeleLayer = std::make_shared<CLayerTele>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||
pEditor->m_Map.MakeTeleLayer(pTeleLayer);
|
||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pTeleLayer);
|
||||
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_QuickActionAddTeleLayer.Call();
|
||||
return CUi::POPUP_CLOSE_CURRENT;
|
||||
}
|
||||
}
|
||||
|
@ -498,16 +491,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
|||
// new speedup layer
|
||||
View.HSplitBottom(5.0f, &View, nullptr);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewSpeedupLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewSpeedupLayerButton, "Add speedup layer", 0, &Button, 0, "Creates a new speedup layer"))
|
||||
if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddSpeedupLayer, pEditor->m_QuickActionAddSpeedupLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddSpeedupLayer.Description()))
|
||||
{
|
||||
std::shared_ptr<CLayer> pSpeedupLayer = std::make_shared<CLayerSpeedup>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||
pEditor->m_Map.MakeSpeedupLayer(pSpeedupLayer);
|
||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pSpeedupLayer);
|
||||
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_QuickActionAddSpeedupLayer.Call();
|
||||
return CUi::POPUP_CLOSE_CURRENT;
|
||||
}
|
||||
}
|
||||
|
@ -517,16 +503,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
|||
// new tune layer
|
||||
View.HSplitBottom(5.0f, &View, nullptr);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewTuneLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewTuneLayerButton, "Add tune layer", 0, &Button, 0, "Creates a new tuning layer"))
|
||||
if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddTuneLayer, pEditor->m_QuickActionAddTuneLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddTuneLayer.Description()))
|
||||
{
|
||||
std::shared_ptr<CLayer> pTuneLayer = std::make_shared<CLayerTune>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||
pEditor->m_Map.MakeTuneLayer(pTuneLayer);
|
||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pTuneLayer);
|
||||
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_QuickActionAddTuneLayer.Call();
|
||||
return CUi::POPUP_CLOSE_CURRENT;
|
||||
}
|
||||
}
|
||||
|
@ -548,16 +527,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
|||
// new Switch layer
|
||||
View.HSplitBottom(5.0f, &View, nullptr);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewSwitchLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewSwitchLayerButton, "Add switch layer", 0, &Button, 0, "Creates a new switch layer"))
|
||||
if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddSwitchLayer, pEditor->m_QuickActionAddSwitchLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddSwitchLayer.Description()))
|
||||
{
|
||||
std::shared_ptr<CLayer> pSwitchLayer = std::make_shared<CLayerSwitch>(pEditor, pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||
pEditor->m_Map.MakeSwitchLayer(pSwitchLayer);
|
||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pSwitchLayer);
|
||||
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_QuickActionAddSwitchLayer.Call();
|
||||
return CUi::POPUP_CLOSE_CURRENT;
|
||||
}
|
||||
}
|
||||
|
@ -583,15 +555,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
|||
// new sound layer
|
||||
View.HSplitBottom(5.0f, &View, nullptr);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewSoundLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewSoundLayerButton, "Add sound layer", 0, &Button, 0, "Creates a new sound layer"))
|
||||
if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddSoundLayer, pEditor->m_QuickActionAddSoundLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddSoundLayer.Description()))
|
||||
{
|
||||
std::shared_ptr<CLayer> pSoundLayer = std::make_shared<CLayerSounds>(pEditor);
|
||||
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->AddLayer(pSoundLayer);
|
||||
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_QuickActionAddSoundLayer.Call();
|
||||
return CUi::POPUP_CLOSE_CURRENT;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,16 @@ void CEditor::AddGroup()
|
|||
m_EditorHistory.RecordAction(std::make_shared<CEditorActionGroup>(this, m_SelectedGroup, false));
|
||||
}
|
||||
|
||||
void CEditor::AddSoundLayer()
|
||||
{
|
||||
std::shared_ptr<CLayer> pSoundLayer = std::make_shared<CLayerSounds>(this);
|
||||
m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pSoundLayer);
|
||||
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));
|
||||
}
|
||||
|
||||
void CEditor::AddTileLayer()
|
||||
{
|
||||
std::shared_ptr<CLayer> pTileLayer = std::make_shared<CLayerTiles>(this, m_Map.m_pGameLayer->m_Width, m_Map.m_pGameLayer->m_Height);
|
||||
|
@ -64,6 +74,27 @@ void CEditor::AddTileLayer()
|
|||
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));
|
||||
}
|
||||
|
||||
void CEditor::AddSwitchLayer()
|
||||
{
|
||||
std::shared_ptr<CLayer> pSwitchLayer = std::make_shared<CLayerSwitch>(this, m_Map.m_pGameLayer->m_Width, m_Map.m_pGameLayer->m_Height);
|
||||
m_Map.MakeSwitchLayer(pSwitchLayer);
|
||||
m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pSwitchLayer);
|
||||
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));
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -75,13 +106,36 @@ void CEditor::AddFrontLayer()
|
|||
m_EditorHistory.RecordAction(std::make_shared<CEditorActionAddLayer>(this, m_SelectedGroup, LayerIndex));
|
||||
}
|
||||
|
||||
void CEditor::AddQuadsLayer()
|
||||
void CEditor::AddTuneLayer()
|
||||
{
|
||||
std::shared_ptr<CLayer> pQuadLayer = std::make_shared<CLayerQuads>(this);
|
||||
m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pQuadLayer);
|
||||
std::shared_ptr<CLayer> pTuneLayer = std::make_shared<CLayerTune>(this, m_Map.m_pGameLayer->m_Width, m_Map.m_pGameLayer->m_Height);
|
||||
m_Map.MakeTuneLayer(pTuneLayer);
|
||||
m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pTuneLayer);
|
||||
int LayerIndex = m_Map.m_vpGroups[m_SelectedGroup]->m_vpLayers.size() - 1;
|
||||
SelectLayer(LayerIndex);
|
||||
m_Map.m_vpGroups[m_SelectedGroup]->m_Collapse = false;
|
||||
m_pBrush->Clear();
|
||||
m_EditorHistory.RecordAction(std::make_shared<CEditorActionAddLayer>(this, m_SelectedGroup, LayerIndex));
|
||||
}
|
||||
|
||||
void CEditor::AddSpeedupLayer()
|
||||
{
|
||||
std::shared_ptr<CLayer> pSpeedupLayer = std::make_shared<CLayerSpeedup>(this, m_Map.m_pGameLayer->m_Width, m_Map.m_pGameLayer->m_Height);
|
||||
m_Map.MakeSpeedupLayer(pSpeedupLayer);
|
||||
m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pSpeedupLayer);
|
||||
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));
|
||||
}
|
||||
|
||||
void CEditor::AddTeleLayer()
|
||||
{
|
||||
std::shared_ptr<CLayer> pTeleLayer = std::make_shared<CLayerTele>(this, m_Map.m_pGameLayer->m_Width, m_Map.m_pGameLayer->m_Height);
|
||||
m_Map.MakeTeleLayer(pTeleLayer);
|
||||
m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pTeleLayer);
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,38 @@ 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(
|
||||
AddSwitchLayer,
|
||||
"Add switch layer",
|
||||
[&]() { AddSwitchLayer(); },
|
||||
[&]() -> bool { return !GetSelectedGroup()->m_GameGroup || m_Map.m_pSwitchLayer; },
|
||||
ALWAYS_FALSE,
|
||||
DEFAULT_BTN,
|
||||
"Creates a new switch layer.")
|
||||
REGISTER_QUICK_ACTION(
|
||||
AddTuneLayer,
|
||||
"Add tune layer",
|
||||
[&]() { AddTuneLayer(); },
|
||||
[&]() -> bool { return !GetSelectedGroup()->m_GameGroup || m_Map.m_pTuneLayer; },
|
||||
ALWAYS_FALSE,
|
||||
DEFAULT_BTN,
|
||||
"Creates a new tuning layer.")
|
||||
REGISTER_QUICK_ACTION(
|
||||
AddSpeedupLayer,
|
||||
"Add speedup layer",
|
||||
[&]() { AddSpeedupLayer(); },
|
||||
[&]() -> bool { return !GetSelectedGroup()->m_GameGroup || m_Map.m_pSpeedupLayer; },
|
||||
ALWAYS_FALSE,
|
||||
DEFAULT_BTN,
|
||||
"Creates a new speedup layer.")
|
||||
REGISTER_QUICK_ACTION(
|
||||
AddTeleLayer,
|
||||
"Add tele layer",
|
||||
[&]() { AddTeleLayer(); },
|
||||
[&]() -> bool { return !GetSelectedGroup()->m_GameGroup || m_Map.m_pTeleLayer; },
|
||||
ALWAYS_FALSE,
|
||||
DEFAULT_BTN,
|
||||
"Creates a new tele layer.")
|
||||
REGISTER_QUICK_ACTION(
|
||||
AddFrontLayer,
|
||||
"Add front layer",
|
||||
|
@ -179,6 +211,8 @@ REGISTER_QUICK_ACTION(
|
|||
"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(
|
||||
AddSoundLayer, "Add sound layer", [&]() { AddSoundLayer(); }, ALWAYS_FALSE, ALWAYS_FALSE, DEFAULT_BTN, "Creates a new sound layer.")
|
||||
REGISTER_QUICK_ACTION(
|
||||
SaveAs,
|
||||
"Save As",
|
||||
|
|
Loading…
Reference in a new issue