Fixing SuperTux crashes when compiled on Mac OS X 10.9
[supertux.git] / src / supertux / textscroller.cpp
index 33002c3..be8fca5 100644 (file)
@@ -27,6 +27,9 @@
 #include "util/reader.hpp"
 #include "video/drawing_context.hpp"
 
+#include <sstream>
+#include <stdexcept>
+
 static const float DEFAULT_SPEED = 20;
 static const float LEFT_BORDER = 50;
 static const float SCROLL = 60;
@@ -90,18 +93,20 @@ TextScroller::setup()
 void
 TextScroller::update(float elapsed_time)
 {
-  if(g_main_controller->hold(Controller::UP)) {
+  Controller *controller = g_jk_controller->get_main_controller();
+  if(controller->hold(Controller::UP)) {
     speed = -defaultspeed*5;
-  } else if(g_main_controller->hold(Controller::DOWN)) {
+  } else if(controller->hold(Controller::DOWN)) {
     speed = defaultspeed*5;
   } else {
     speed = defaultspeed;
   }
-  if(g_main_controller->pressed(Controller::JUMP)
-     || g_main_controller->pressed(Controller::ACTION)
-     || g_main_controller->pressed(Controller::MENU_SELECT))
+  if((controller->pressed(Controller::JUMP)
+     || controller->pressed(Controller::ACTION)
+     || controller->pressed(Controller::MENU_SELECT)
+     )&& !(controller->pressed(Controller::UP))) // prevent skipping if jump with up is enabled
     scroll += SCROLL;
-  if(g_main_controller->pressed(Controller::PAUSE_MENU)) {
+  if(controller->pressed(Controller::PAUSE_MENU)) {
     g_screen_manager->exit_screen(new FadeOut(0.5));
   }