Add quick action "Toggle Grid"

This commit is contained in:
ChillerDragon 2024-09-01 16:23:04 +08:00
parent 30acedaac5
commit 8b304cab23
2 changed files with 10 additions and 2 deletions

View file

@ -1102,10 +1102,10 @@ void CEditor::DoToolbarLayers(CUIRect ToolBar)
// grid button
TB_Top.VSplitLeft(25.0f, &Button, &TB_Top);
static int s_GridButton = 0;
if(DoButton_FontIcon(&s_GridButton, FONT_ICON_BORDER_ALL, MapView()->MapGrid()->IsEnabled(), &Button, 0, "[ctrl+g] Toggle Grid", IGraphics::CORNER_L) ||
if(DoButton_FontIcon(&s_GridButton, FONT_ICON_BORDER_ALL, m_QuickActionToggleGrid.Active(), &Button, 0, m_QuickActionToggleGrid.Description(), IGraphics::CORNER_L) ||
(m_Dialog == DIALOG_NONE && CLineInput::GetActiveInput() == nullptr && Input()->KeyPress(KEY_G) && ModPressed && !ShiftPressed))
{
MapView()->MapGrid()->Toggle();
m_QuickActionToggleGrid.Call();
}
// grid settings button

View file

@ -7,6 +7,14 @@
#define ALWAYS_FALSE []() -> bool { return false; }
#define DEFAULT_BTN []() -> int { return -1; }
REGISTER_QUICK_ACTION(
ToggleGrid,
"Toggle Grid",
[&]() { MapView()->MapGrid()->Toggle(); },
ALWAYS_FALSE,
[&]() -> bool { return MapView()->MapGrid()->IsEnabled(); },
DEFAULT_BTN,
"[ctrl+g] Toggle Grid")
REGISTER_QUICK_ACTION(
GameTilesAir,
"Game tiles: Air",