#include <iostream>
#include <sstream>
-#include <stdlib.h>
-#include <stdio.h>
+#include <cstdlib>
+#include <cstdio>
#include <string>
-#include <assert.h>
+#include <cassert>
#include "defines.h"
#include "globals.h"
#include "leveleditor.h"
#include "timer.h"
#include "high_scores.h"
+#include "gettext.h"
#define FLICK_CURSOR_TIME 500
Menu* dialog = new Menu;
dialog->additem(MN_DEACTIVE, text,0,0);
dialog->additem(MN_HL,"",0,0);
- dialog->additem(MN_ACTION,"Yes",0,0,true);
- dialog->additem(MN_ACTION,"No",0,0,false);
+ dialog->additem(MN_ACTION,_("Yes"),0,0,true);
+ dialog->additem(MN_ACTION,_("No"),0,0,false);
dialog->additem(MN_HL,"",0,0);
Menu::set_current(dialog);
dialog->event(event);
}
- context.draw_surface(background, Vector(0,0), LAYER_BACKGROUND0);
+ if(background == NULL)
+ context.draw_gradient(Color(200, 100, 200), Color(100, 200, 100), LAYER_BACKGROUND0);
+ else
+ context.draw_surface(background, Vector(0,0), LAYER_BACKGROUND0);
dialog->draw(context);
dialog->action();
switch(*item->int_p)
{
case SDLK_UP:
- item->change_input("Up cursor");
+ item->change_input(_("Up cursor"));
break;
case SDLK_DOWN:
- item->change_input("Down cursor");
+ item->change_input(_("Down cursor"));
break;
case SDLK_LEFT:
- item->change_input("Left cursor");
+ item->change_input(_("Left cursor"));
break;
case SDLK_RIGHT:
- item->change_input("Right cursor");
+ item->change_input(_("Right cursor"));
break;
case SDLK_RETURN:
- item->change_input("Return");
+ item->change_input(_("Return"));
break;
case SDLK_SPACE:
- item->change_input("Space");
+ item->change_input(_("Space"));
break;
case SDLK_RSHIFT:
- item->change_input("Right Shift");
+ item->change_input(_("Right Shift"));
break;
case SDLK_LSHIFT:
- item->change_input("Left Shift");
+ item->change_input(_("Left Shift"));
break;
case SDLK_RCTRL:
- item->change_input("Right Control");
+ item->change_input(_("Right Control"));
break;
case SDLK_LCTRL:
- item->change_input("Left Control");
+ item->change_input(_("Left Control"));
break;
case SDLK_RALT:
- item->change_input("Right Alt");
+ item->change_input(_("Right Alt"));
break;
case SDLK_LALT:
- item->change_input("Left Alt");
+ item->change_input(_("Left Alt"));
break;
default:
{
{
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);
break;
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;
- }
}