#include "timer.hpp"
#include "control/joystickkeyboardcontroller.hpp"
-static const float MENU_REPEAT_INITIAL = 0.4;
-static const float MENU_REPEAT_RATE = 0.2;
-static const float FLICK_CURSOR_TIME = 0.5;
+static const float MENU_REPEAT_INITIAL = 0.4f;
+static const float MENU_REPEAT_RATE = 0.2f;
+static const float FLICK_CURSOR_TIME = 0.5f;
extern SDL_Surface* screen;
}
if(background == NULL)
- context.draw_gradient(Color(0.8, 0.95, 0.85), Color(0.8, 0.8, 0.8),
+ context.draw_gradient(Color(0.8f, 0.95f, 0.85f), Color(0.8f, 0.8f, 0.8f),
LAYER_BACKGROUND0);
else
context.draw_surface(background, Vector(0,0), LAYER_BACKGROUND0);
menuaction = MENU_ACTION_DOWN;
menu_repeat_time = real_time + MENU_REPEAT_RATE;
}
- if(main_controller->pressed(Controller::JUMP)
- || main_controller->pressed(Controller::ACTION)
+ if(main_controller->pressed(Controller::ACTION)
|| main_controller->pressed(Controller::MENU_SELECT)) {
menuaction = MENU_ACTION_HIT;
}
Menu::draw_item(DrawingContext& context, int index)
{
float menu_height = get_height();
- float menu_width = get_width();
+ float menu_width = get_width();
MenuItem& pitem = *(items[index]);
text_font = active_font;
}
+ if(active_item == index)
+ {
+ context.draw_filled_rect(Rect(Vector(pos_x - menu_width/2 + 10 - 2, y_pos - 12 - 2),
+ Vector(pos_x + menu_width/2 - 10 + 2, y_pos + 12 + 2)),
+ Color(1.0f, 1.0f, 1.0f, 0.5f),
+ 16.0f,
+ LAYER_GUI-10);
+ context.draw_filled_rect(Rect(Vector(pos_x - menu_width/2 + 10, y_pos - 12),
+ Vector(pos_x + menu_width/2 - 10, y_pos + 12)),
+ Color(1.0f, 1.0f, 1.0f, 0.5f),
+ 16.0f,
+ LAYER_GUI-10);
+ }
+
switch (pitem.kind)
{
case MN_DEACTIVE:
{
context.draw_text(deactive_font, pitem.text,
Vector(SCREEN_WIDTH/2, y_pos - int(deactive_font->get_height()/2)),
- CENTER_ALLIGN, LAYER_GUI);
+ ALIGN_CENTER, LAYER_GUI);
break;
}
{
context.draw_text(label_font, pitem.text,
Vector(SCREEN_WIDTH/2, y_pos - int(label_font->get_height()/2)),
- CENTER_ALLIGN, LAYER_GUI);
+ ALIGN_CENTER, LAYER_GUI);
break;
}
case MN_TEXTFIELD:
context.draw_text(field_font,
pitem.get_input_with_symbol(true),
Vector(input_pos, y_pos - int(field_font->get_height()/2)),
- LEFT_ALLIGN, LAYER_GUI);
+ ALIGN_LEFT, LAYER_GUI);
else
context.draw_text(field_font,
pitem.get_input_with_symbol(false),
Vector(input_pos, y_pos - int(field_font->get_height()/2)),
- LEFT_ALLIGN, LAYER_GUI);
+ ALIGN_LEFT, LAYER_GUI);
}
else
context.draw_text(field_font, pitem.input,
Vector(input_pos, y_pos - int(field_font->get_height()/2)),
- LEFT_ALLIGN, LAYER_GUI);
+ ALIGN_LEFT, LAYER_GUI);
context.draw_text(text_font, pitem.text,
Vector(text_pos, y_pos - int(text_font->get_height()/2)),
- LEFT_ALLIGN, LAYER_GUI);
+ ALIGN_LEFT, LAYER_GUI);
break;
}
case MN_STRINGSELECT:
context.draw_text(text_font, pitem.list[pitem.selected],
Vector(SCREEN_WIDTH/2 + text_pos, y_pos - int(text_font->get_height()/2)),
- CENTER_ALLIGN, LAYER_GUI);
+ ALIGN_CENTER, LAYER_GUI);
context.draw_text(text_font, pitem.text,
Vector(SCREEN_WIDTH/2 + list_pos_2/2, y_pos - int(text_font->get_height()/2)),
- CENTER_ALLIGN, LAYER_GUI);
+ ALIGN_CENTER, LAYER_GUI);
break;
}
case MN_BACK:
{
context.draw_text(text_font, pitem.text,
Vector(SCREEN_WIDTH/2, y_pos - int(text_font->get_height()/2)),
- CENTER_ALLIGN, LAYER_GUI);
+ ALIGN_CENTER, LAYER_GUI);
context.draw_surface(back.get(),
Vector(x_pos + text_width/2 + 16, y_pos - 8),
LAYER_GUI);
{
context.draw_text(text_font, pitem.text,
Vector(SCREEN_WIDTH/2, y_pos - (text_font->get_height()/2)),
- CENTER_ALLIGN, LAYER_GUI);
+ ALIGN_CENTER, LAYER_GUI);
if(pitem.toggled)
context.draw_surface(checkbox_checked.get(),
case MN_ACTION:
context.draw_text(text_font, pitem.text,
Vector(SCREEN_WIDTH/2, y_pos - int(text_font->get_height()/2)),
- CENTER_ALLIGN, LAYER_GUI);
+ ALIGN_CENTER, LAYER_GUI);
break;
case MN_GOTO:
context.draw_text(text_font, pitem.text,
Vector(SCREEN_WIDTH/2, y_pos - int(text_font->get_height()/2)),
- CENTER_ALLIGN, LAYER_GUI);
+ ALIGN_CENTER, LAYER_GUI);
break;
}
}
}
float menu_height = get_height();
- float menu_width = get_width();
+ float menu_width = get_width();
/* Draw a transparent background */
- context.draw_filled_rect(
- Vector(pos_x - menu_width/2, pos_y - 24*items.size()/2 - 10),
- Vector(menu_width,menu_height + 20),
- Color(0.6f, 0.7f, 0.8f, 0.5f), LAYER_GUI-10);
+ context.draw_filled_rect(Rect(Vector(pos_x - menu_width/2-4, pos_y - 24*items.size()/2 - 10-4),
+ Vector(pos_x + menu_width/2+4, pos_y - 24*items.size()/2 + 10 + menu_height+4)),
+ Color(0.2f, 0.3f, 0.4f, 0.8f),
+ 16.0f,
+ LAYER_GUI-10);
+
+ context.draw_filled_rect(Rect(Vector(pos_x - menu_width/2, pos_y - 24*items.size()/2 - 10),
+ Vector(pos_x + menu_width/2, pos_y - 24*items.size()/2 + 10 + menu_height)),
+ Color(0.6f, 0.7f, 0.8f, 0.5f),
+ 16.0f,
+ LAYER_GUI-10);
for(unsigned int i = 0; i < items.size(); ++i)
{