}
if(background == NULL)
- context.draw_gradient(Color(200, 100, 200), Color(100, 200, 100), LAYER_BACKGROUND0);
+ context.draw_gradient(Color(200,240,220), Color(200,200,220), LAYER_BACKGROUND0);
else
context.draw_surface(background, Vector(0,0), LAYER_BACKGROUND0);
char str[1024];
if(input_flickering)
- sprintf(str,"%s_",input);
- else
sprintf(str,"%s ",input);
+ else
+ sprintf(str,"%s_",input);
std::string string = str;
{
case MN_DEACTIVE:
{
- context.draw_text_center(blue_text, pitem.text,
+ context.draw_text_center(gray_text, pitem.text,
Vector(0, y_pos - int(blue_text->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
break;
}
int y = y_pos - 12 - effect_offset;
/* Draw a horizontal line with a little 3d effect */
context.draw_filled_rect(Vector(x, y + 6),
- Vector(menu_width, 4), Color(150,200,255,225), LAYER_FOREGROUND1);
+ Vector(menu_width, 4), Color(150,200,255,225), LAYER_GUI);
context.draw_filled_rect(Vector(x, y + 6),
- Vector(menu_width, 2), Color(255,255,255,255), LAYER_FOREGROUND1);
+ Vector(menu_width, 2), Color(255,255,255,255), LAYER_GUI);
break;
}
case MN_LABEL:
{
context.draw_text_center(white_big_text,
pitem.text, Vector(0, y_pos - int(white_big_text->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
break;
}
case MN_TEXTFIELD:
context.draw_filled_rect(
Vector(input_pos - 5, y_pos - 10),
Vector(input_width + 10, 20),
- Color(255,255,255,255), LAYER_FOREGROUND1-5);
+ Color(255,255,255,255), LAYER_GUI-5);
context.draw_filled_rect(
Vector(input_pos - 4, y_pos - 9),
Vector(input_width + 8, 18),
- Color(0,0,0,128), LAYER_FOREGROUND1-4);
+ Color(0,0,0,128), LAYER_GUI-4);
if(pitem.kind == MN_CONTROLFIELD_KB)
get_controlfield_key_into_input(&pitem);
context.draw_text(gold_text,
pitem.get_input_with_symbol(true),
Vector(input_pos, y_pos - int(gold_text->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
else
context.draw_text(gold_text,
pitem.get_input_with_symbol(false),
Vector(input_pos, y_pos - int(gold_text->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
}
else
context.draw_text(gold_text, pitem.input,
Vector(input_pos, y_pos - int(gold_text->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
context.draw_text(text_font, pitem.text,
Vector(text_pos, y_pos - int(text_font->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
break;
}
case MN_STRINGSELECT:
/* Draw arrows */
context.draw_surface(arrow_left,
Vector(x_pos - list_pos + text_pos - 17, y_pos - 8),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
context.draw_surface(arrow_right,
Vector(x_pos - list_pos + text_pos - 1 + list_pos_2, y_pos - 8),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
/* Draw input background */
context.draw_filled_rect(
Vector(x_pos - list_pos + text_pos - 1, y_pos - 10),
Vector(list_pos_2 + 2, 20),
- Color(255,255,255,255), LAYER_FOREGROUND1 - 4);
+ Color(255,255,255,255), LAYER_GUI - 4);
context.draw_filled_rect(
Vector(x_pos - list_pos + text_pos, y_pos - 9),
Vector(list_pos_2, 18),
- Color(0,0,0,128), LAYER_FOREGROUND1 - 5);
+ Color(0,0,0,128), LAYER_GUI - 5);
context.draw_text_center(text_font, string_list_active(pitem.list),
Vector(text_pos, y_pos - int(text_font->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
context.draw_text_center(text_font, pitem.text,
Vector(list_pos_2/2, y_pos - int(text_font->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
break;
}
case MN_BACK:
{
context.draw_text_center(text_font, pitem.text,
Vector(0, y_pos - int(text_font->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
context.draw_surface(back,
Vector(x_pos + text_width/2 + 16, y_pos - 8),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
break;
}
{
context.draw_text_center(text_font, pitem.text,
Vector(0, y_pos - (text_font->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
if(pitem.toggled)
context.draw_surface(checkbox_checked,
Vector(x_pos + (text_width+16)/2, y_pos - 8),
- LAYER_FOREGROUND1 + 1);
+ LAYER_GUI + 1);
else
context.draw_surface(checkbox,
Vector(x_pos + (text_width+16)/2, y_pos - 8),
- LAYER_FOREGROUND1 + 1);
+ LAYER_GUI + 1);
break;
}
case MN_ACTION:
context.draw_text_center(text_font, pitem.text,
Vector(0, y_pos - int(text_font->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
break;
case MN_GOTO:
context.draw_text_center(text_font, pitem.text,
Vector(0, y_pos - int(text_font->get_height()/2)),
- LAYER_FOREGROUND1);
+ LAYER_GUI);
break;
}
}
context.draw_filled_rect(
Vector(pos_x - menu_width/2, pos_y - 24*item.size()/2 - 10),
Vector(menu_width,menu_height + 20),
- Color(150,180,200,125), LAYER_FOREGROUND1-10);
+ Color(150,180,200,125), LAYER_GUI-10);
for(unsigned int i = 0; i < item.size(); ++i)
{
void
Menu::event(SDL_Event& event)
{
- SDLKey key;
switch(event.type)
- {
- case SDL_KEYDOWN:
- key = event.key.keysym.sym;
- SDLMod keymod;
- char ch[2];
- keymod = SDL_GetModState();
- int x,y;
-
- /* If the current unicode character is an ASCII character,
- assign it to ch. */
- if ( (event.key.keysym.unicode & 0xFF80) == 0 )
- {
- ch[0] = event.key.keysym.unicode & 0x7F;
- ch[1] = '\0';
- }
- else
- {
- /* An International Character. */
- }
-
- if(item[active_item].kind == MN_CONTROLFIELD_KB)
{
- if(key == SDLK_ESCAPE)
+ case SDL_KEYDOWN:
{
- Menu::pop_current();
- return;
- }
- *item[active_item].int_p = key;
- menuaction = MENU_ACTION_DOWN;
- return;
- }
+ SDLKey key = key = event.key.keysym.sym;
+ SDLMod keymod;
+ char ch[2];
+ keymod = SDL_GetModState();
+
+ /* If the current unicode character is an ASCII character,
+ assign it to ch. */
+ if ( (event.key.keysym.unicode & 0xFF80) == 0 )
+ {
+ ch[0] = event.key.keysym.unicode & 0x7F;
+ ch[1] = '\0';
+ }
+ else
+ {
+ /* An International Character. */
+ }
+ if(item[active_item].kind == MN_CONTROLFIELD_KB)
+ {
+ if(key == SDLK_ESCAPE)
+ {
+ Menu::pop_current();
+ return;
+ }
+ *item[active_item].int_p = key;
+ menuaction = MENU_ACTION_DOWN;
+ return;
+ }
- switch(key)
- {
- case SDLK_UP: /* Menu Up */
- menuaction = MENU_ACTION_UP;
- break;
- case SDLK_DOWN: /* Menu Down */
- menuaction = MENU_ACTION_DOWN;
- break;
- case SDLK_LEFT: /* Menu Up */
- menuaction = MENU_ACTION_LEFT;
- break;
- case SDLK_RIGHT: /* Menu Down */
- menuaction = MENU_ACTION_RIGHT;
- break;
- case SDLK_SPACE:
- if(item[active_item].kind == MN_TEXTFIELD)
- {
- menuaction = MENU_ACTION_INPUT;
- mn_input_char = ' ';
- break;
+
+ switch(key)
+ {
+ case SDLK_UP: /* Menu Up */
+ menuaction = MENU_ACTION_UP;
+ break;
+ case SDLK_DOWN: /* Menu Down */
+ menuaction = MENU_ACTION_DOWN;
+ break;
+ case SDLK_LEFT: /* Menu Up */
+ menuaction = MENU_ACTION_LEFT;
+ break;
+ case SDLK_RIGHT: /* Menu Down */
+ menuaction = MENU_ACTION_RIGHT;
+ break;
+ case SDLK_SPACE:
+ if(item[active_item].kind == MN_TEXTFIELD)
+ {
+ menuaction = MENU_ACTION_INPUT;
+ mn_input_char = ' ';
+ break;
+ }
+ case SDLK_RETURN: /* Menu Hit */
+ menuaction = MENU_ACTION_HIT;
+ break;
+ case SDLK_DELETE:
+ case SDLK_BACKSPACE:
+ menuaction = MENU_ACTION_REMOVE;
+ delete_character++;
+ break;
+ case SDLK_ESCAPE:
+ Menu::pop_current();
+ break;
+ default:
+ if( (key >= SDLK_0 && key <= SDLK_9) || (key >= SDLK_a && key <= SDLK_z) || (key >= SDLK_SPACE && key <= SDLK_SLASH))
+ {
+ menuaction = MENU_ACTION_INPUT;
+ mn_input_char = *ch;
+ }
+ else
+ {
+ mn_input_char = '\0';
+ }
+ break;
+ }
}
- case SDLK_RETURN: /* Menu Hit */
- menuaction = MENU_ACTION_HIT;
break;
- case SDLK_DELETE:
- case SDLK_BACKSPACE:
- menuaction = MENU_ACTION_REMOVE;
- delete_character++;
+
+ case SDL_JOYAXISMOTION:
+ if(event.jaxis.axis == joystick_keymap.y_axis)
+ {
+ if (event.jaxis.value > joystick_keymap.dead_zone && !joystick_timer.started())
+ {
+ menuaction = MENU_ACTION_DOWN;
+ joystick_timer.start(JOYSTICK_MENU_DELAY);
+ }
+ else if (event.jaxis.value < -joystick_keymap.dead_zone && !joystick_timer.started())
+ {
+ menuaction = MENU_ACTION_UP;
+ joystick_timer.start(JOYSTICK_MENU_DELAY);
+ }
+ else
+ joystick_timer.stop();
+ }
break;
- case SDLK_ESCAPE:
- Menu::pop_current();
+ case SDL_JOYBUTTONDOWN:
+ if (item[active_item].kind == MN_CONTROLFIELD_JS)
+ {
+ // FIXME: This next line does nothing useable, right?
+ // *item[active_item].int_p = key;
+ menuaction = MENU_ACTION_DOWN;
+ }
+ menuaction = MENU_ACTION_HIT;
break;
- default:
- if( (key >= SDLK_0 && key <= SDLK_9) || (key >= SDLK_a && key <= SDLK_z) || (key >= SDLK_SPACE && key <= SDLK_SLASH))
- {
- menuaction = MENU_ACTION_INPUT;
- mn_input_char = *ch;
- }
- else
+
+ case SDL_MOUSEBUTTONDOWN:
{
- mn_input_char = '\0';
+ int x = event.motion.x;
+ int y = event.motion.y;
+
+ if(x > pos_x - get_width()/2 &&
+ x < pos_x + get_width()/2 &&
+ y > pos_y - get_height()/2 &&
+ y < pos_y + get_height()/2)
+ {
+ menuaction = MENU_ACTION_HIT;
+ }
}
break;
- }
- break;
- case SDL_JOYAXISMOTION:
- if(event.jaxis.axis == joystick_keymap.y_axis)
- {
- if (event.jaxis.value > joystick_keymap.dead_zone && !joystick_timer.started())
- {
- menuaction = MENU_ACTION_DOWN;
- joystick_timer.start(JOYSTICK_MENU_DELAY);
- }
- else if (event.jaxis.value < -joystick_keymap.dead_zone && !joystick_timer.started())
+
+ case SDL_MOUSEMOTION:
{
- menuaction = MENU_ACTION_UP;
- joystick_timer.start(JOYSTICK_MENU_DELAY);
+ int x = event.motion.x;
+ int y = event.motion.y;
+
+ if(x > pos_x - get_width()/2 &&
+ x < pos_x + get_width()/2 &&
+ y > pos_y - get_height()/2 &&
+ y < pos_y + get_height()/2)
+ {
+ active_item = (y - (pos_y - get_height()/2)) / 24;
+ mouse_cursor->set_state(MC_LINK);
+ }
+ else
+ {
+ mouse_cursor->set_state(MC_NORMAL);
+ }
}
- else
- joystick_timer.stop();
- }
- break;
- case SDL_JOYBUTTONDOWN:
- if (item[active_item].kind == MN_CONTROLFIELD_JS)
- {
- *item[active_item].int_p = key;
- menuaction = MENU_ACTION_DOWN;
- }
- menuaction = MENU_ACTION_HIT;
- break;
- case SDL_MOUSEBUTTONDOWN:
- x = event.motion.x;
- y = event.motion.y;
- if(x > pos_x - get_width()/2 &&
- x < pos_x + get_width()/2 &&
- y > pos_y - get_height()/2 &&
- y < pos_y + get_height()/2)
- {
- menuaction = MENU_ACTION_HIT;
- }
- break;
- case SDL_MOUSEMOTION:
- x = event.motion.x;
- y = event.motion.y;
- if(x > pos_x - get_width()/2 &&
- x < pos_x + get_width()/2 &&
- y > pos_y - get_height()/2 &&
- y < pos_y + get_height()/2)
- {
- active_item = (y - (pos_y - get_height()/2)) / 24;
- mouse_cursor->set_state(MC_LINK);
- }
- else
- {
- mouse_cursor->set_state(MC_NORMAL);
+ break;
+
+ default:
+ break;
}
- break;
- default:
- break;
- }
}