diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 84d1f38d8..adc132bf4 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -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; diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 6fc4d503c..98835d8ef 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -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 pTeleLayer = std::make_shared(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(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 pSpeedupLayer = std::make_shared(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(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 pTuneLayer = std::make_shared(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(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 pSwitchLayer = std::make_shared(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(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 pSoundLayer = std::make_shared(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(pEditor, pEditor->m_SelectedGroup, LayerIndex)); + pEditor->m_QuickActionAddSoundLayer.Call(); return CUi::POPUP_CLOSE_CURRENT; } diff --git a/src/game/editor/quick_actions.cpp b/src/game/editor/quick_actions.cpp index a06a81eba..852ce48d6 100644 --- a/src/game/editor/quick_actions.cpp +++ b/src/game/editor/quick_actions.cpp @@ -53,6 +53,16 @@ void CEditor::AddGroup() m_EditorHistory.RecordAction(std::make_shared(this, m_SelectedGroup, false)); } +void CEditor::AddSoundLayer() +{ + std::shared_ptr pSoundLayer = std::make_shared(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(this, m_SelectedGroup, LayerIndex)); +} + void CEditor::AddTileLayer() { std::shared_ptr pTileLayer = std::make_shared(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(this, m_SelectedGroup, LayerIndex)); } +void CEditor::AddQuadsLayer() +{ + std::shared_ptr pQuadLayer = std::make_shared(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(this, m_SelectedGroup, LayerIndex)); +} + +void CEditor::AddSwitchLayer() +{ + std::shared_ptr pSwitchLayer = std::make_shared(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(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); @@ -75,13 +106,36 @@ void CEditor::AddFrontLayer() m_EditorHistory.RecordAction(std::make_shared(this, m_SelectedGroup, LayerIndex)); } -void CEditor::AddQuadsLayer() +void CEditor::AddTuneLayer() { - std::shared_ptr pQuadLayer = std::make_shared(this); - m_Map.m_vpGroups[m_SelectedGroup]->AddLayer(pQuadLayer); + std::shared_ptr pTuneLayer = std::make_shared(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(this, m_SelectedGroup, LayerIndex)); +} + +void CEditor::AddSpeedupLayer() +{ + std::shared_ptr pSpeedupLayer = std::make_shared(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(this, m_SelectedGroup, LayerIndex)); +} + +void CEditor::AddTeleLayer() +{ + std::shared_ptr pTeleLayer = std::make_shared(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(this, m_SelectedGroup, LayerIndex)); } diff --git a/src/game/editor/quick_actions.h b/src/game/editor/quick_actions.h index 0541e3ca0..f1e1b282f 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -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",