}
/* Set ControlField a key */
-void MenuItem::set_controlfield_key(SDLKey key, char ch[])
+void Menu::get_controlfield_key_into_input(MenuItem *item)
{
-*int_p = key;
-if(ch[0] != '\0')
- strcpy(input, ch);
-else
- switch(key)
- {
- case SDLK_UP:
- strcpy(input, "Up cursor");
- break;
- case SDLK_DOWN:
- strcpy(input, "Down cursor");
- break;
- case SDLK_LEFT:
- strcpy(input, "Left cursor");
- break;
- case SDLK_RIGHT:
- strcpy(input, "Right cursor");
- break;
- case SDLK_RETURN:
- strcpy(input, "Return");
- break;
- case SDLK_SPACE:
- strcpy(input, "Space");
- break;
- case SDLK_RSHIFT:
- strcpy(input, "Right Shift");
- break;
- case SDLK_LSHIFT:
- strcpy(input, "Left Shift");
- break;
- case SDLK_RCTRL:
- strcpy(input, "Right Control");
- break;
- case SDLK_LCTRL:
- strcpy(input, "Left Control");
- break;
- case SDLK_RALT:
- strcpy(input, "Right Alt");
- break;
- case SDLK_LALT:
- strcpy(input, "Left Alt");
- break;
- default:
- strcpy(input, "?");
- break;
- }
+switch(*item->int_p)
+ {
+ case SDLK_UP:
+ strcpy(item->input, "Up cursor");
+ break;
+ case SDLK_DOWN:
+ strcpy(item->input, "Down cursor");
+ break;
+ case SDLK_LEFT:
+ strcpy(item->input, "Left cursor");
+ break;
+ case SDLK_RIGHT:
+ strcpy(item->input, "Right cursor");
+ break;
+ case SDLK_RETURN:
+ strcpy(item->input, "Return");
+ break;
+ case SDLK_SPACE:
+ strcpy(item->input, "Space");
+ break;
+ case SDLK_RSHIFT:
+ strcpy(item->input, "Right Shift");
+ break;
+ case SDLK_LSHIFT:
+ strcpy(item->input, "Left Shift");
+ break;
+ case SDLK_RCTRL:
+ strcpy(item->input, "Right Control");
+ break;
+ case SDLK_LCTRL:
+ strcpy(item->input, "Left Control");
+ break;
+ case SDLK_RALT:
+ strcpy(item->input, "Right Alt");
+ break;
+ case SDLK_LALT:
+ strcpy(item->input, "Left Alt");
+ break;
+ default:
+ strcpy(item->input, (char*)item->int_p);
+ break;
+ }
}
/* Free a menu and all its items */
int menu_width,
int menu_height)
{
- const MenuItem& pitem = item[index];
+ MenuItem& pitem = item[index];
int font_width = 16;
int effect_offset = 0;
input_width + font_width, 18,
0,0,0,128);
+ if(pitem.kind == MN_CONTROLFIELD)
+ get_controlfield_key_into_input(&pitem);
+
gold_text->draw_align(pitem.input,
x_pos + text_pos, y_pos,
A_HMIDDLE, A_VMIDDLE, 2);
if(item[active_item].kind == MN_CONTROLFIELD)
{
- item[active_item].set_controlfield_key(key, ch);
+ *item[active_item].int_p = key;
menuaction = MENU_ACTION_DOWN;
return;
}
void change_input(const char *text);
static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu, int* int_p);
-
- void set_controlfield_key(SDLKey key, char ch[]);
};
class Menu
MenuItem& get_item(int index) { return item[index]; }
+ void Menu::get_controlfield_key_into_input(MenuItem *item);
+
void draw ();
void draw_item(int index, int menu_width, int menu_height);
void set_pos(int x, int y, float rw = 0, float rh = 0);