From 002fa22d915522b661886eaa88e0042095fb5b1f Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Tue, 19 Aug 2014 00:08:48 +0200 Subject: [PATCH] Added --developer option, also Ctrl-F2, which enabled cheats --- src/supertux/command_line_arguments.cpp | 9 ++++++++- src/supertux/command_line_arguments.hpp | 2 ++ src/supertux/game_session.cpp | 3 ++- src/supertux/gameconfig.cpp | 5 ++++- src/supertux/gameconfig.hpp | 2 ++ src/supertux/screen_manager.cpp | 6 ++++++ src/worldmap/worldmap.cpp | 5 +++-- 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/supertux/command_line_arguments.cpp b/src/supertux/command_line_arguments.cpp index 37a38107c..a26f8eb77 100644 --- a/src/supertux/command_line_arguments.cpp +++ b/src/supertux/command_line_arguments.cpp @@ -44,7 +44,8 @@ CommandLineArguments::CommandLineArguments() : start_level(), enable_script_debugger(), start_demo(), - record_demo() + record_demo(), + developer_mode() { } @@ -96,6 +97,7 @@ CommandLineArguments::print_help(const char* arg0) " --noconsole Disable ingame scripting console\n" " --show-fps Display framerate in levels\n" " --no-show-fps Do not display framerate in levels\n" + " --developer Switch on developer feature\n" " -s, --debug-scripts Enable script debugger.\n" "\n" "Demo Recording Options:\n" @@ -268,6 +270,10 @@ CommandLineArguments::parse_args(int argc, char** argv) { show_fps = false; } + else if (arg == "--developer") + { + developer_mode = true; + } else if (arg == "--console") { console_enabled = true; @@ -340,6 +346,7 @@ CommandLineArguments::merge_into(Config& config) merge_option(enable_script_debugger); merge_option(start_demo); merge_option(record_demo); + merge_option(developer_mode); #undef merge_option } diff --git a/src/supertux/command_line_arguments.hpp b/src/supertux/command_line_arguments.hpp index e76ebb76c..7aa048b86 100644 --- a/src/supertux/command_line_arguments.hpp +++ b/src/supertux/command_line_arguments.hpp @@ -67,6 +67,8 @@ public: boost::optional start_demo; boost::optional record_demo; + boost::optional developer_mode; + // boost::optional locale; public: diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index 0dd39b829..ce95ed4df 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -424,7 +424,8 @@ GameSession::update(float elapsed_time) on_escape_press(); } - if(InputManager::current()->get_controller()->pressed(Controller::CHEAT_MENU)) + if(InputManager::current()->get_controller()->pressed(Controller::CHEAT_MENU) && + g_config->developer_mode) { if (!MenuManager::instance().is_active()) { diff --git a/src/supertux/gameconfig.cpp b/src/supertux/gameconfig.cpp index 0a1a9773c..13408a787 100644 --- a/src/supertux/gameconfig.cpp +++ b/src/supertux/gameconfig.cpp @@ -47,7 +47,8 @@ Config::Config() : locale(), keyboard_config(), joystick_config(), - disabled_addon_filenames() + disabled_addon_filenames(), + developer_mode(false) { } @@ -69,6 +70,7 @@ Config::load() config_lisp->get("profile", profile); config_lisp->get("show_fps", show_fps); config_lisp->get("console", console_enabled); + config_lisp->get("developer", developer_mode); config_lisp->get("locale", locale); config_lisp->get("random_seed", random_seed); @@ -133,6 +135,7 @@ Config::save() writer.write("profile", profile); writer.write("show_fps", show_fps); writer.write("console", console_enabled); + writer.write("developer", developer_mode); writer.write("locale", locale); writer.start_list("video"); diff --git a/src/supertux/gameconfig.hpp b/src/supertux/gameconfig.hpp index a160e2e0c..9f9ffd28a 100644 --- a/src/supertux/gameconfig.hpp +++ b/src/supertux/gameconfig.hpp @@ -73,6 +73,8 @@ public: JoystickConfig joystick_config; std::vector disabled_addon_filenames; + + bool developer_mode; }; #endif diff --git a/src/supertux/screen_manager.cpp b/src/supertux/screen_manager.cpp index 4e7b520d3..a2d2beb75 100644 --- a/src/supertux/screen_manager.cpp +++ b/src/supertux/screen_manager.cpp @@ -239,6 +239,12 @@ ScreenManager::process_events() g_config->console_enabled = true; g_config->save(); } + else if (event.key.keysym.sym == SDLK_F2 && + event.key.keysym.mod & KMOD_CTRL) + { + g_config->developer_mode = !g_config->developer_mode; + log_info << "developer mode: " << g_config->developer_mode << std::endl; + } break; } } diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index 0b9a47751..fcf772e5f 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -46,6 +46,7 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" #include "supertux/game_session.hpp" +#include "supertux/gameconfig.hpp" #include "supertux/globals.hpp" #include "supertux/menu/menu_storage.hpp" #include "supertux/menu/options_menu.hpp" @@ -73,7 +74,6 @@ #include "worldmap/tux.hpp" #include "worldmap/worldmap.hpp" - static const float CAMERA_PAN_SPEED = 5.0; namespace worldmap { @@ -648,7 +648,8 @@ WorldMap::update(float delta) on_escape_press(); } - if(controller->pressed(Controller::CHEAT_MENU)) + if(controller->pressed(Controller::CHEAT_MENU) && + g_config->developer_mode) { MenuManager::instance().set_menu(MenuStorage::WORLDMAP_CHEAT_MENU); } -- 2.11.0