Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUIFormSpecMenu: Add basic element highlighing debug feature #9423

Merged
merged 2 commits into from Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/gui/guiFormSpecMenu.cpp
Expand Up @@ -3314,8 +3314,12 @@ void GUIFormSpecMenu::drawMenu()
bool hovered_element_found = false;

if (hovered != NULL) {
s32 id = hovered->getID();
if (m_show_debug) {
core::rect<s32> rect = hovered->getAbsoluteClippingRect();
driver->draw2DRectangle(0x22FFFF00, rect, &rect);
}

s32 id = hovered->getID();
u64 delta = 0;
if (id == -1) {
m_old_tooltip_id = id;
Expand Down Expand Up @@ -3837,6 +3841,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 ||
Expand Down
1 change: 1 addition & 0 deletions src/gui/guiFormSpecMenu.h
Expand Up @@ -341,6 +341,7 @@ class GUIFormSpecMenu : public GUIModalMenu
u16 m_formspec_version = 1;
std::string m_focused_element = "";
JoystickController *m_joystick;
bool m_show_debug = false;

typedef struct {
bool explicit_size;
Expand Down