Add quick action "Map details"

This commit is contained in:
ChillerDragon 2024-09-18 19:13:29 +08:00
parent 60624d5599
commit 32e8bb1f05
4 changed files with 29 additions and 9 deletions

View file

@ -330,6 +330,7 @@ public:
void AddTileLayer();
void LayerSelectImage();
bool IsNonGameTileLayerSelected() const;
void MapDetails();
#define REGISTER_QUICK_ACTION(name, text, callback, disabled, active, button_color, description) CQuickAction m_QuickAction##name;
#include <game/editor/quick_actions.h>
#undef REGISTER_QUICK_ACTION

View file

@ -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;
}

View file

@ -69,3 +69,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);
}

View file

@ -276,6 +276,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