diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 2587321cd..4fe6498ff 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -331,6 +331,7 @@ public: void AddFrontLayer(); void LayerSelectImage(); bool IsNonGameTileLayerSelected() const; + void MapDetails(); #define REGISTER_QUICK_ACTION(name, text, callback, disabled, active, button_color, description) CQuickAction m_QuickAction##name; #include #undef REGISTER_QUICK_ACTION diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 22805ba41..4acc033d2 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -32,7 +32,6 @@ CUi::EPopupMenuFunctionResult CEditor::PopupMenuFile(void *pContext, CUIRect Vie static int s_OpenButton = 0; static int s_OpenCurrentMapButton = 0; static int s_AppendButton = 0; - static int s_MapInfoButton = 0; static int s_ExitButton = 0; CUIRect Slot; @@ -115,15 +114,9 @@ CUi::EPopupMenuFunctionResult CEditor::PopupMenuFile(void *pContext, CUIRect Vie View.HSplitTop(10.0f, nullptr, &View); View.HSplitTop(12.0f, &Slot, &View); - if(pEditor->DoButton_MenuItem(&s_MapInfoButton, "Map details", 0, &Slot, 0, "Adjust the map details of the current map")) + if(pEditor->DoButton_MenuItem(&pEditor->m_QuickActionMapDetails, pEditor->m_QuickActionMapDetails.Label(), 0, &Slot, 0, pEditor->m_QuickActionMapDetails.Description())) { - const CUIRect *pScreen = pEditor->Ui()->Screen(); - pEditor->m_Map.m_MapInfoTmp.Copy(pEditor->m_Map.m_MapInfo); - static SPopupMenuId s_PopupMapInfoId; - constexpr float PopupWidth = 400.0f; - constexpr float PopupHeight = 170.0f; - pEditor->Ui()->DoPopupMenu(&s_PopupMapInfoId, pScreen->w / 2.0f - PopupWidth / 2.0f, pScreen->h / 2.0f - PopupHeight / 2.0f, PopupWidth, PopupHeight, pEditor, PopupMapInfo); - pEditor->Ui()->SetActiveItem(nullptr); + pEditor->m_QuickActionMapDetails.Call(); return CUi::POPUP_CLOSE_CURRENT; } diff --git a/src/game/editor/quick_actions.cpp b/src/game/editor/quick_actions.cpp index 6bdc8b16b..1ea46c45d 100644 --- a/src/game/editor/quick_actions.cpp +++ b/src/game/editor/quick_actions.cpp @@ -80,3 +80,21 @@ void CEditor::LayerSelectImage() Ui()->DoPopupMenu(&s_LayerPopupContext, Ui()->MouseX(), Ui()->MouseY(), 120, 270, &s_LayerPopupContext, PopupLayer); PopupSelectImageInvoke(pTiles->m_Image, Ui()->MouseX(), Ui()->MouseY()); } + +void CEditor::MapDetails() +{ + const CUIRect *pScreen = Ui()->Screen(); + m_Map.m_MapInfoTmp.Copy(m_Map.m_MapInfo); + static SPopupMenuId s_PopupMapInfoId; + constexpr float PopupWidth = 400.0f; + constexpr float PopupHeight = 170.0f; + Ui()->DoPopupMenu( + &s_PopupMapInfoId, + pScreen->w / 2.0f - PopupWidth / 2.0f, + pScreen->h / 2.0f - PopupHeight / 2.0f, + PopupWidth, + PopupHeight, + this, + PopupMapInfo); + Ui()->SetActiveItem(nullptr); +} diff --git a/src/game/editor/quick_actions.h b/src/game/editor/quick_actions.h index 418dfe7fd..cf5d49333 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -284,6 +284,14 @@ REGISTER_QUICK_ACTION( [&]() -> bool { return m_ColorPipetteActive; }, DEFAULT_BTN, "[Ctrl+Shift+C] Color pipette. Pick a color from the screen by clicking on it.") +REGISTER_QUICK_ACTION( + MapDetails, + "Map details", + [&]() { MapDetails(); }, + ALWAYS_FALSE, + ALWAYS_FALSE, + DEFAULT_BTN, + "Adjust the map details of the current map.") #undef ALWAYS_FALSE #undef DEFAULT_BTN