Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25281/src
Modified Files:
menu.cpp menu.h
Log Message:
Controls menu wasn't showing the keys until they were changed (fixed).
Also made a few internal changes regarding this.
Index: menu.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- menu.cpp 22 Apr 2004 17:51:03 -0000 1.48
+++ menu.cpp 22 Apr 2004 18:39:52 -0000 1.49
@@ -150,54 +150,50 @@
}
/* 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 */
@@ -430,7 +426,7 @@
int menu_width,
int menu_height)
{
- const MenuItem& pitem = item[index];
+ MenuItem& pitem = item[index];
int font_width = 16;
int effect_offset = 0;
@@ -504,6 +500,9 @@
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);
@@ -642,7 +641,7 @@
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;
}
Index: menu.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/menu.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- menu.h 22 Apr 2004 14:11:57 -0000 1.42
+++ menu.h 22 Apr 2004 18:39:52 -0000 1.43
@@ -59,8 +59,6 @@
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
@@ -132,6 +130,8 @@
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);
|