Remove bogus assert
[supertux.git] / src / gui / menu.cpp
index f2347cb..fd253e9 100644 (file)
@@ -23,6 +23,7 @@
 #include "gui/menu_item.hpp"
 #include "gui/menu_manager.hpp"
 #include "gui/mousecursor.hpp"
+#include "supertux/colorscheme.hpp"
 #include "supertux/globals.hpp"
 #include "supertux/resources.hpp"
 #include "supertux/screen_manager.hpp"
@@ -31,6 +32,7 @@
 #include "video/drawing_context.hpp"
 #include "video/font.hpp"
 #include "video/renderer.hpp"
+#include "video/video_system.hpp"
 
 static const float MENU_REPEAT_INITIAL = 0.4f;
 static const float MENU_REPEAT_RATE    = 0.1f;
@@ -179,7 +181,7 @@ Menu::process_input()
   }
 
   MenuAction menuaction = MENU_ACTION_NONE;
-  Controller* controller = g_input_manager->get_controller();
+  Controller* controller = InputManager::current()->get_controller();
   /** check main input controller... */
   if(controller->pressed(Controller::UP)) {
     menuaction = MENU_ACTION_UP;
@@ -225,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;
   }
 
@@ -380,7 +383,7 @@ Menu::draw_item(DrawingContext& context, int index)
 
   MenuItem& pitem = *(items[index]);
 
-  Color text_color = default_color;
+  Color text_color = ColorScheme::Menu::default_color;
   float x_pos       = pos.x;
   float y_pos       = pos.y + 24*index - menu_height/2 + 12;
   int text_width  = int(Resources::normal_font->get_text_width(pitem.text));
@@ -399,7 +402,7 @@ Menu::draw_item(DrawingContext& context, int index)
 
   if(index == active_item)
   {
-    text_color = active_color;
+    text_color = ColorScheme::Menu::active_color;
   }
 
   if(active_item == index)
@@ -423,7 +426,7 @@ Menu::draw_item(DrawingContext& context, int index)
     {
       context.draw_text(Resources::normal_font, pitem.text,
                         Vector(pos.x, y_pos - int(Resources::normal_font->get_height()/2)),
-                        ALIGN_CENTER, LAYER_GUI, inactive_color);
+                        ALIGN_CENTER, LAYER_GUI, ColorScheme::Menu::inactive_color);
       break;
     }
 
@@ -445,7 +448,7 @@ Menu::draw_item(DrawingContext& context, int index)
     {
       context.draw_text(Resources::big_font, pitem.text,
                         Vector(pos.x, y_pos - int(Resources::big_font->get_height()/2)),
-                        ALIGN_CENTER, LAYER_GUI, label_color);
+                        ALIGN_CENTER, LAYER_GUI, ColorScheme::Menu::label_color);
       break;
     }
     case MN_TEXTFIELD:
@@ -458,17 +461,17 @@ Menu::draw_item(DrawingContext& context, int index)
           context.draw_text(Resources::normal_font,
                             pitem.get_input_with_symbol(true),
                             Vector(right, y_pos - int(Resources::normal_font->get_height()/2)),
-                            ALIGN_RIGHT, LAYER_GUI, field_color);
+                            ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::field_color);
         else
           context.draw_text(Resources::normal_font,
                             pitem.get_input_with_symbol(false),
                             Vector(right, y_pos - int(Resources::normal_font->get_height()/2)),
-                            ALIGN_RIGHT, LAYER_GUI, field_color);
+                            ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::field_color);
       }
       else
         context.draw_text(Resources::normal_font, pitem.input,
                           Vector(right, y_pos - int(Resources::normal_font->get_height()/2)),
-                          ALIGN_RIGHT, LAYER_GUI, field_color);
+                          ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::field_color);
 
       context.draw_text(Resources::normal_font, pitem.text,
                         Vector(left, y_pos - int(Resources::normal_font->get_height()/2)),
@@ -622,7 +625,7 @@ Menu::get_item_by_id(int id)
     }
   }
 
-  throw std::runtime_error("MenuItem not found");
+  throw std::runtime_error("MenuItem not found: " + std::to_string(id));
 }
 
 const MenuItem&
@@ -663,7 +666,7 @@ Menu::event(const SDL_Event& ev)
     case SDL_MOUSEBUTTONDOWN:
     if(ev.button.button == SDL_BUTTON_LEFT)
     {
-      Vector mouse_pos = Renderer::instance()->to_logical(ev.motion.x, ev.motion.y);
+      Vector mouse_pos = VideoSystem::current()->get_renderer().to_logical(ev.motion.x, ev.motion.y);
       int x = int(mouse_pos.x);
       int y = int(mouse_pos.y);
 
@@ -679,7 +682,7 @@ Menu::event(const SDL_Event& ev)
 
     case SDL_MOUSEMOTION:
     {
-      Vector mouse_pos = Renderer::instance()->to_logical(ev.motion.x, ev.motion.y);
+      Vector mouse_pos = VideoSystem::current()->get_renderer().to_logical(ev.motion.x, ev.motion.y);
       float x = mouse_pos.x;
       float y = mouse_pos.y;