Skip to content

Commit

Permalink
Add a button to toggle developer mode in debug build
Browse files Browse the repository at this point in the history
  • Loading branch information
Districh-ru committed Jan 16, 2025
1 parent c58f6eb commit 8a217a6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/engine/localevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ namespace EventProcessing
return SDLK_AMPERSAND;
case fheroes2::Key::KEY_QUOTE:
return SDLK_QUOTE;
case fheroes2::Key::KEY_BACKQUOTE:
return SDLK_BACKQUOTE;
case fheroes2::Key::KEY_LEFT_PARENTHESIS:
return SDLK_LEFTPAREN;
case fheroes2::Key::KEY_RIGHT_PARENTHESIS:
Expand Down
1 change: 1 addition & 0 deletions src/engine/localevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace fheroes2
KEY_DOLLAR,
KEY_AMPERSAND,
KEY_QUOTE,
KEY_BACKQUOTE,
KEY_LEFT_PARENTHESIS,
KEY_RIGHT_PARENTHESIS,
KEY_ASTERISK,
Expand Down
7 changes: 7 additions & 0 deletions src/fheroes2/game/game_hotkeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ namespace
= { Game::HotKeyCategory::GLOBAL, gettext_noop( "hotkey|toggle fullscreen" ), fheroes2::Key::KEY_F4 };
hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::GLOBAL_TOGGLE_TEXT_SUPPORT_MODE )]
= { Game::HotKeyCategory::GLOBAL, gettext_noop( "hotkey|toggle text support mode" ), fheroes2::Key::KEY_F10 };
#if defined( WITH_DEBUG )
hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::DEBUG_TOGGLE_DEVELOPER_MODE )]
= { Game::HotKeyCategory::GLOBAL, gettext_noop( "hotkey|toggle developer mode" ), fheroes2::Key::KEY_BACKQUOTE };
#endif

hotKeyEventInfo[hotKeyEventToInt( Game::HotKeyEvent::MAIN_MENU_NEW_GAME )]
= { Game::HotKeyCategory::MAIN_MENU, gettext_noop( "hotkey|new game" ), fheroes2::Key::KEY_N };
Expand Down Expand Up @@ -533,6 +537,9 @@ void Game::globalKeyDownEvent( const fheroes2::Key key, const int32_t modifier )
}
}
}
else if ( key == hotKeyEventInfo[hotKeyEventToInt( HotKeyEvent::DEBUG_TOGGLE_DEVELOPER_MODE )].key ) {
Logging::setDebugLevel( DBG_DEVEL ^ Logging::getDebugLevel() );
}
#endif
}

Expand Down
6 changes: 5 additions & 1 deletion src/fheroes2/game/game_hotkeys.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***************************************************************************
* fheroes2: https://github.com/ihhub/fheroes2 *
* Copyright (C) 2022 - 2024 *
* Copyright (C) 2022 - 2025 *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
Expand Down Expand Up @@ -45,6 +45,10 @@ namespace Game

GLOBAL_TOGGLE_FULLSCREEN,
GLOBAL_TOGGLE_TEXT_SUPPORT_MODE,
#if defined( WITH_DEBUG )
// This hotkey is only for debug mode.
DEBUG_TOGGLE_DEVELOPER_MODE,
#endif

MAIN_MENU_NEW_GAME,
MAIN_MENU_LOAD_GAME,
Expand Down

0 comments on commit 8a217a6

Please sign in to comment.