Skip to content

Commit

Permalink
Ability to open debug menu in editor (#2537)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusGuy authored Jul 21, 2023
1 parent 2ff06d4 commit f9e73da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,19 @@ Editor::update_keyboard(const Controller& controller)
return;
}


if (!MenuManager::instance().has_dialog())
if (MenuManager::instance().current_menu() == nullptr)
{
if (controller.pressed(Control::ESCAPE)) {
esc_press();
return;
}
if (controller.pressed(Control::DEBUG_MENU) && g_config->developer_mode)
{
m_enabled = false;
m_overlay_widget->delete_markers();
MenuManager::instance().set_menu(MenuStorage::DEBUG_MENU);
return;
}
if (controller.hold(Control::LEFT)) {
scroll({ -m_scroll_speed, 0.0f });
}
Expand Down Expand Up @@ -682,7 +688,6 @@ Editor::setup()
m_enabled = true;
m_toolbox_widget->update_mouse_icon();
}

}

void
Expand Down Expand Up @@ -741,8 +746,6 @@ Editor::event(const SDL_Event& ev)
}
}



if (ev.type == SDL_KEYDOWN && ev.key.keysym.sym == SDLK_F6) {
Compositor::s_render_lighting = !Compositor::s_render_lighting;
return;
Expand Down
9 changes: 9 additions & 0 deletions src/supertux/menu/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <algorithm>
#include <sstream>

#include "editor/editor.hpp"
#include "gui/item_stringselect.hpp"
#include "supertux/debug.hpp"
#include "supertux/gameconfig.hpp"
Expand Down Expand Up @@ -76,6 +77,14 @@ DebugMenu::DebugMenu() :
add_back(_("Back"));
}

DebugMenu::~DebugMenu()
{
auto editor = Editor::current();

if (editor == nullptr) return;
editor->m_reactivate_request = true;
}

void
DebugMenu::menu_action(MenuItem& item)
{
Expand Down
1 change: 1 addition & 0 deletions src/supertux/menu/debug_menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DebugMenu final : public Menu

public:
DebugMenu();
virtual ~DebugMenu() override;

virtual void menu_action(MenuItem& item) override;

Expand Down

0 comments on commit f9e73da

Please sign in to comment.