Split Controller::PAUSE_MENU into ESCAPE and START, as they need to act different...
authorIngo Ruhnke <grumbel@gmail.com>
Wed, 27 Aug 2014 08:12:05 +0000 (10:12 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Wed, 27 Aug 2014 08:12:05 +0000 (10:12 +0200)
12 files changed:
src/control/controller.hpp
src/control/game_controller_manager.cpp
src/control/joystick_config.cpp
src/control/keyboard_config.cpp
src/control/keyboard_manager.cpp
src/gui/dialog.cpp
src/gui/menu.cpp
src/supertux/game_session.cpp
src/supertux/levelintro.cpp
src/supertux/menu/joystick_menu.cpp
src/supertux/textscroller.cpp
src/worldmap/worldmap.cpp

index ab9decd..210159d 100644 (file)
@@ -31,7 +31,8 @@ public:
     JUMP,
     ACTION,
 
-    PAUSE_MENU,
+    START,
+    ESCAPE,
     MENU_SELECT,
     MENU_BACK,
 
index 4c9ccbf..6680c04 100644 (file)
@@ -75,7 +75,7 @@ GameControllerManager::process_button_event(const SDL_ControllerButtonEvent& ev)
       break;
 
     case SDL_CONTROLLER_BUTTON_START:
-      set_control(Controller::PAUSE_MENU, ev.state);
+      set_control(Controller::START, ev.state);
       break;
 
     case SDL_CONTROLLER_BUTTON_LEFTSTICK:
index 6a0db69..b7d8b78 100644 (file)
@@ -35,7 +35,7 @@ JoystickConfig::JoystickConfig() :
   bind_joybutton(0, 1, Controller::ACTION);
   bind_joybutton(0, 4, Controller::PEEK_LEFT);
   bind_joybutton(0, 5, Controller::PEEK_RIGHT);
-  bind_joybutton(0, 6, Controller::PAUSE_MENU);
+  bind_joybutton(0, 6, Controller::START);
 
   // Default joystick axis configuration
   bind_joyaxis(0, -1, Controller::LEFT);
index dd2bf12..db6114a 100644 (file)
@@ -31,9 +31,9 @@ KeyboardConfig::KeyboardConfig() :
   keymap[SDLK_SPACE]    = Controller::JUMP;
   keymap[SDLK_LCTRL]    = Controller::ACTION;
   keymap[SDLK_LALT]     = Controller::ACTION;
-  keymap[SDLK_ESCAPE]   = Controller::PAUSE_MENU;
-  keymap[SDLK_p]        = Controller::PAUSE_MENU;
-  keymap[SDLK_PAUSE]    = Controller::PAUSE_MENU;
+  keymap[SDLK_ESCAPE]   = Controller::ESCAPE;
+  keymap[SDLK_p]        = Controller::START;
+  keymap[SDLK_PAUSE]    = Controller::START;
   keymap[SDLK_RETURN]   = Controller::MENU_SELECT;
   keymap[SDLK_KP_ENTER] = Controller::MENU_SELECT;
   keymap[SDLK_CARET]    = Controller::CONSOLE;
index d088dc0..7818dc8 100644 (file)
@@ -190,8 +190,10 @@ KeyboardManager::process_menu_key_event(const SDL_KeyboardEvent& event)
       control = Controller::MENU_SELECT;
       break;
     case SDLK_ESCAPE:
+      control = Controller::ESCAPE;
+      break;
     case SDLK_PAUSE:
-      control = Controller::PAUSE_MENU;
+      control = Controller::START;
       break;
     default:
       return;
index d489911..e536c9c 100644 (file)
@@ -164,7 +164,8 @@ Dialog::process_input(const Controller& controller)
   }
 
   if (m_cancel_button != -1 &&
-      controller.pressed(Controller::MENU_BACK))
+      (controller.pressed(Controller::ESCAPE) ||
+       controller.pressed(Controller::MENU_BACK)))
   {
     on_button_click(m_cancel_button);
   }
index e17764d..1a636ee 100644 (file)
@@ -227,8 +227,9 @@ Menu::process_input()
      || controller->pressed(Controller::MENU_SELECT)) {
     menuaction = MENU_ACTION_HIT;
   }
-  if(controller->pressed(Controller::PAUSE_MENU)
-    || controller->pressed(Controller::MENU_BACK)) {
+  if(controller->pressed(Controller::ESCAPE) ||
+     controller->pressed(Controller::START) ||
+     controller->pressed(Controller::MENU_BACK)) {
     menuaction = MENU_ACTION_BACK;
   }
 
index ce95ed4..9c06460 100644 (file)
@@ -419,7 +419,8 @@ void
 GameSession::update(float elapsed_time)
 {
   // handle controller
-  if(InputManager::current()->get_controller()->pressed(Controller::PAUSE_MENU))
+  if(InputManager::current()->get_controller()->pressed(Controller::ESCAPE) ||
+     InputManager::current()->get_controller()->pressed(Controller::START))
   {
     on_escape_press();
   }
index 82b9651..f4b77ac 100644 (file)
@@ -59,7 +59,8 @@ LevelIntro::update(float elapsed_time)
   if(controller->pressed(Controller::JUMP)
      || controller->pressed(Controller::ACTION)
      || controller->pressed(Controller::MENU_SELECT)
-     || controller->pressed(Controller::PAUSE_MENU)) {
+     || controller->pressed(Controller::START)
+     || controller->pressed(Controller::ESCAPE)) {
     ScreenManager::current()->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.1)));
   }
 
index fa4545a..c60bd71 100644 (file)
@@ -70,7 +70,7 @@ JoystickMenu::recreate_menu()
       add_controlfield(Controller::RIGHT,       _("Right"));
       add_controlfield(Controller::JUMP,        _("Jump"));
       add_controlfield(Controller::ACTION,      _("Action"));
-      add_controlfield(Controller::PAUSE_MENU,  _("Pause/Menu"));
+      add_controlfield(Controller::START,       _("Pause/Menu"));
       add_controlfield(Controller::PEEK_LEFT,   _("Peek Left"));
       add_controlfield(Controller::PEEK_RIGHT,  _("Peek Right"));
       add_controlfield(Controller::PEEK_UP,     _("Peek Up"));
@@ -219,7 +219,7 @@ JoystickMenu::refresh()
 
     refresh_menu_item(Controller::JUMP);
     refresh_menu_item(Controller::ACTION);
-    refresh_menu_item(Controller::PAUSE_MENU);
+    refresh_menu_item(Controller::START);
     refresh_menu_item(Controller::PEEK_LEFT);
     refresh_menu_item(Controller::PEEK_RIGHT);
     refresh_menu_item(Controller::PEEK_UP);
index d09e32e..491e1dd 100644 (file)
@@ -106,7 +106,8 @@ TextScroller::update(float elapsed_time)
      || controller->pressed(Controller::MENU_SELECT)
      )&& !(controller->pressed(Controller::UP))) // prevent skipping if jump with up is enabled
     scroll += SCROLL;
-  if(controller->pressed(Controller::PAUSE_MENU)) {
+  if(controller->pressed(Controller::START) ||
+     controller->pressed(Controller::ESCAPE)) {
     ScreenManager::current()->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.5)));
   }
 
index fcf772e..e6b479a 100644 (file)
@@ -643,7 +643,8 @@ WorldMap::update(float delta)
       if(!controller->pressed(Controller::UP))
         enter_level = true;
     }
-    if(controller->pressed(Controller::PAUSE_MENU))
+    if(controller->pressed(Controller::START) ||
+       controller->pressed(Controller::ESCAPE))
     {
       on_escape_press();
     }