From 6cf15cf872cc9ce76990d83d380ca3c4b7485eb1 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sun, 12 Apr 2020 12:02:32 +0200 Subject: [PATCH] GUIFormSpecMenu: Add basic element highlighing debug feature (#9423) Activated using F5 --- src/gui/guiFormSpecMenu.cpp | 10 +++++++++- src/gui/guiFormSpecMenu.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 6a383a791..f3bf04275 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -3380,8 +3380,12 @@ void GUIFormSpecMenu::drawMenu() bool hovered_element_found = false; if (hovered != NULL) { - s32 id = hovered->getID(); + if (m_show_debug) { + core::rect rect = hovered->getAbsoluteClippingRect(); + driver->draw2DRectangle(0x22FFFF00, rect, &rect); + } + s32 id = hovered->getID(); u64 delta = 0; if (id == -1) { m_old_tooltip_id = id; @@ -3903,6 +3907,10 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event) (kp == getKeySetting("keymap_screenshot"))) { m_client->makeScreenshot(); } + + if (event.KeyInput.PressedDown && kp == getKeySetting("keymap_toggle_debug")) + m_show_debug = !m_show_debug; + if (event.KeyInput.PressedDown && (event.KeyInput.Key==KEY_RETURN || event.KeyInput.Key==KEY_UP || diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index b3bf67110..dc22e8b54 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -343,6 +343,7 @@ private: u16 m_formspec_version = 1; std::string m_focused_element = ""; JoystickController *m_joystick; + bool m_show_debug = false; typedef struct { bool explicit_size; -- 2.25.1