From 44fc87146398bfa68a133142de4a2559ba442bc0 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Mon, 2 Sep 2024 09:13:03 +0800 Subject: [PATCH] Add quick action "Pipette" --- src/game/editor/editor.cpp | 4 ++-- src/game/editor/quick_actions.h | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 3ba8add6c..53d1b46ab 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1228,10 +1228,10 @@ void CEditor::DoToolbarLayers(CUIRect ToolBar) static char s_PipetteButton; ColorPalette.VSplitLeft(PipetteButtonWidth, &Button, &ColorPalette); ColorPalette.VSplitLeft(Spacing, nullptr, &ColorPalette); - if(DoButton_FontIcon(&s_PipetteButton, FONT_ICON_EYE_DROPPER, m_ColorPipetteActive ? 1 : 0, &Button, 0, "[Ctrl+Shift+C] Color pipette. Pick a color from the screen by clicking on it.", IGraphics::CORNER_ALL) || + if(DoButton_FontIcon(&s_PipetteButton, FONT_ICON_EYE_DROPPER, m_QuickActionPipette.Active(), &Button, 0, m_QuickActionPipette.Description(), IGraphics::CORNER_ALL) || (CLineInput::GetActiveInput() == nullptr && ModPressed && ShiftPressed && Input()->KeyPress(KEY_C))) { - m_ColorPipetteActive = !m_ColorPipetteActive; + m_QuickActionPipette.Call(); } // Palette color pickers diff --git a/src/game/editor/quick_actions.h b/src/game/editor/quick_actions.h index cfba08e4b..2044300c7 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -228,6 +228,14 @@ REGISTER_QUICK_ACTION( [&]() -> bool { return m_ShowTileInfo == SHOW_TILE_HEXADECIMAL; }, DEFAULT_BTN, "[Ctrl+Shift+I] Show tile information in hexadecimal.") +REGISTER_QUICK_ACTION( + Pipette, + "Pipette", + [&]() { m_ColorPipetteActive = !m_ColorPipetteActive; }, + ALWAYS_FALSE, + [&]() -> bool { return m_ColorPipetteActive; }, + DEFAULT_BTN, + "[Ctrl+Shift+C] Color pipette. Pick a color from the screen by clicking on it.") #undef ALWAYS_FALSE #undef DEFAULT_BTN