#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"
#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;
}
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;
|| 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;
}
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));
if(index == active_item)
{
- text_color = active_color;
+ text_color = ColorScheme::Menu::active_color;
}
if(active_item == 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;
}
{
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:
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)),
}
}
- throw std::runtime_error("MenuItem not found");
+ throw std::runtime_error("MenuItem not found: " + std::to_string(id));
}
const MenuItem&
}
void
-Menu::event(const SDL_Event& event)
+Menu::event(const SDL_Event& ev)
{
- switch(event.type) {
+ switch(ev.type) {
case SDL_MOUSEBUTTONDOWN:
- if(event.button.button == SDL_BUTTON_LEFT)
+ if(ev.button.button == SDL_BUTTON_LEFT)
{
- Vector mouse_pos = Renderer::instance()->to_logical(event.motion.x, event.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);
case SDL_MOUSEMOTION:
{
- Vector mouse_pos = Renderer::instance()->to_logical(event.motion.x, event.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;