Added --developer option, also Ctrl-F2, which enabled cheats
authorIngo Ruhnke <grumbel@gmail.com>
Mon, 18 Aug 2014 22:08:48 +0000 (00:08 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Tue, 19 Aug 2014 00:35:17 +0000 (02:35 +0200)
src/supertux/command_line_arguments.cpp
src/supertux/command_line_arguments.hpp
src/supertux/game_session.cpp
src/supertux/gameconfig.cpp
src/supertux/gameconfig.hpp
src/supertux/screen_manager.cpp
src/worldmap/worldmap.cpp

index 37a3810..a26f8eb 100644 (file)
@@ -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
 }
index e76ebb7..7aa048b 100644 (file)
@@ -67,6 +67,8 @@ public:
   boost::optional<std::string> start_demo;
   boost::optional<std::string> record_demo;
 
+  boost::optional<bool> developer_mode;
+
   // boost::optional<std::string> locale;
 
 public:
index 0dd39b8..ce95ed4 100644 (file)
@@ -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())
     {
index 0a1a977..13408a7 100644 (file)
@@ -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");
index a160e2e..9f9ffd2 100644 (file)
@@ -73,6 +73,8 @@ public:
   JoystickConfig joystick_config;
 
   std::vector<std::string> disabled_addon_filenames;
+
+  bool developer_mode;
 };
 
 #endif
index 4e7b520..a2d2beb 100644 (file)
@@ -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;
     }
   }
index 0b9a477..fcf772e 100644 (file)
@@ -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);
     }