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:
Dennis Felsing 2024-09-24 02:08:43 +00:00 committed by GitHub
commit 09203aee78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 108 additions and 49 deletions

View file

@ -332,9 +332,14 @@ public:
bool CanFillGameTiles() const; bool CanFillGameTiles() const;
void AddQuadOrSound(); void AddQuadOrSound();
void AddGroup(); void AddGroup();
void AddSoundLayer();
void AddTileLayer(); void AddTileLayer();
void AddFrontLayer();
void AddQuadsLayer(); void AddQuadsLayer();
void AddSwitchLayer();
void AddFrontLayer();
void AddTuneLayer();
void AddSpeedupLayer();
void AddTeleLayer();
void DeleteSelectedLayer(); void DeleteSelectedLayer();
void LayerSelectImage(); void LayerSelectImage();
bool IsNonGameTileLayerSelected() const; bool IsNonGameTileLayerSelected() const;

View file

@ -479,16 +479,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
// new tele layer // new tele layer
View.HSplitBottom(5.0f, &View, nullptr); View.HSplitBottom(5.0f, &View, nullptr);
View.HSplitBottom(12.0f, &View, &Button); View.HSplitBottom(12.0f, &View, &Button);
static int s_NewTeleLayerButton = 0; if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddTeleLayer, pEditor->m_QuickActionAddTeleLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddTeleLayer.Description()))
if(pEditor->DoButton_Editor(&s_NewTeleLayerButton, "Add tele layer", 0, &Button, 0, "Creates a new tele layer"))
{ {
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_QuickActionAddTeleLayer.Call();
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));
return CUi::POPUP_CLOSE_CURRENT; return CUi::POPUP_CLOSE_CURRENT;
} }
} }
@ -498,16 +491,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
// new speedup layer // new speedup layer
View.HSplitBottom(5.0f, &View, nullptr); View.HSplitBottom(5.0f, &View, nullptr);
View.HSplitBottom(12.0f, &View, &Button); View.HSplitBottom(12.0f, &View, &Button);
static int s_NewSpeedupLayerButton = 0; if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddSpeedupLayer, pEditor->m_QuickActionAddSpeedupLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddSpeedupLayer.Description()))
if(pEditor->DoButton_Editor(&s_NewSpeedupLayerButton, "Add speedup layer", 0, &Button, 0, "Creates a new speedup layer"))
{ {
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_QuickActionAddSpeedupLayer.Call();
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));
return CUi::POPUP_CLOSE_CURRENT; return CUi::POPUP_CLOSE_CURRENT;
} }
} }
@ -517,16 +503,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
// new tune layer // new tune layer
View.HSplitBottom(5.0f, &View, nullptr); View.HSplitBottom(5.0f, &View, nullptr);
View.HSplitBottom(12.0f, &View, &Button); View.HSplitBottom(12.0f, &View, &Button);
static int s_NewTuneLayerButton = 0; if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddTuneLayer, pEditor->m_QuickActionAddTuneLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddTuneLayer.Description()))
if(pEditor->DoButton_Editor(&s_NewTuneLayerButton, "Add tune layer", 0, &Button, 0, "Creates a new tuning layer"))
{ {
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_QuickActionAddTuneLayer.Call();
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));
return CUi::POPUP_CLOSE_CURRENT; return CUi::POPUP_CLOSE_CURRENT;
} }
} }
@ -548,16 +527,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
// new Switch layer // new Switch layer
View.HSplitBottom(5.0f, &View, nullptr); View.HSplitBottom(5.0f, &View, nullptr);
View.HSplitBottom(12.0f, &View, &Button); View.HSplitBottom(12.0f, &View, &Button);
static int s_NewSwitchLayerButton = 0; if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddSwitchLayer, pEditor->m_QuickActionAddSwitchLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddSwitchLayer.Description()))
if(pEditor->DoButton_Editor(&s_NewSwitchLayerButton, "Add switch layer", 0, &Button, 0, "Creates a new switch layer"))
{ {
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_QuickActionAddSwitchLayer.Call();
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));
return CUi::POPUP_CLOSE_CURRENT; return CUi::POPUP_CLOSE_CURRENT;
} }
} }
@ -583,15 +555,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
// new sound layer // new sound layer
View.HSplitBottom(5.0f, &View, nullptr); View.HSplitBottom(5.0f, &View, nullptr);
View.HSplitBottom(12.0f, &View, &Button); View.HSplitBottom(12.0f, &View, &Button);
static int s_NewSoundLayerButton = 0; if(pEditor->DoButton_Editor(&pEditor->m_QuickActionAddSoundLayer, pEditor->m_QuickActionAddSoundLayer.Label(), 0, &Button, 0, pEditor->m_QuickActionAddSoundLayer.Description()))
if(pEditor->DoButton_Editor(&s_NewSoundLayerButton, "Add sound layer", 0, &Button, 0, "Creates a new sound layer"))
{ {
std::shared_ptr<CLayer> pSoundLayer = std::make_shared<CLayerSounds>(pEditor); pEditor->m_QuickActionAddSoundLayer.Call();
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));
return CUi::POPUP_CLOSE_CURRENT; return CUi::POPUP_CLOSE_CURRENT;
} }

View file

@ -53,6 +53,16 @@ void CEditor::AddGroup()
m_EditorHistory.RecordAction(std::make_shared<CEditorActionGroup>(this, m_SelectedGroup, false)); 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() 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); 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)); 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() 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); 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)); 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); std::shared_ptr<CLayer> pTuneLayer = std::make_shared<CLayerTune>(this, m_Map.m_pGameLayer->m_Width, m_Map.m_pGameLayer->m_Height);
m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pQuadLayer); m_Map.MakeTuneLayer(pTuneLayer);
m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pTuneLayer);
int LayerIndex = m_Map.m_vpGroups[m_SelectedGroup]->m_vpLayers.size() - 1; int LayerIndex = m_Map.m_vpGroups[m_SelectedGroup]->m_vpLayers.size() - 1;
SelectLayer(LayerIndex); 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)); m_EditorHistory.RecordAction(std::make_shared<CEditorActionAddLayer>(this, m_SelectedGroup, LayerIndex));
} }

View file

@ -169,6 +169,38 @@ REGISTER_QUICK_ACTION(
"Toggles proof borders. These borders represent the area that a player can see with default zoom.") "Toggles proof borders. These borders represent the area that a player can see with default zoom.")
REGISTER_QUICK_ACTION( REGISTER_QUICK_ACTION(
AddTileLayer, "Add tile layer", [&]() { AddTileLayer(); }, ALWAYS_FALSE, ALWAYS_FALSE, DEFAULT_BTN, "Creates a new tile layer.") 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( REGISTER_QUICK_ACTION(
AddFrontLayer, AddFrontLayer,
"Add front layer", "Add front layer",
@ -179,6 +211,8 @@ REGISTER_QUICK_ACTION(
"Creates a new item layer.") "Creates a new item layer.")
REGISTER_QUICK_ACTION( REGISTER_QUICK_ACTION(
AddQuadsLayer, "Add quads layer", [&]() { AddQuadsLayer(); }, ALWAYS_FALSE, ALWAYS_FALSE, DEFAULT_BTN, "Creates a new quads layer.") 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( REGISTER_QUICK_ACTION(
SaveAs, SaveAs,
"Save As", "Save As",