Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5859/src
Modified Files:
configfile.cpp menu.cpp
Log Message:
Made the keys to be displayed when typed and also save them to the file.
Still to fix: display keys when menu is shown.
Index: menu.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- menu.cpp 21 Apr 2004 15:45:39 -0000 1.44
+++ menu.cpp 21 Apr 2004 17:45:17 -0000 1.45
@@ -443,6 +443,7 @@
}
case MN_TEXTFIELD:
case MN_NUMFIELD:
+ case MN_CONTROLFIELD:
{
int input_pos = input_width/2;
int text_pos = (text_width + font_width)/2;
@@ -463,10 +464,10 @@
A_HMIDDLE, A_VMIDDLE, shadow_size);
break;
}
- case MN_CONTROLFIELD:
- {
+// case MN_CONTROLFIELD:
+// {
/* display key */ // FIXME: the key number is not that obvious to the user :P
- char str[12];
+/* char str[12];
sprintf(str, "%i", *pitem.int_p);
input_width = strlen(str) * font_width;
@@ -488,7 +489,7 @@
x_pos - (input_width + font_width)/2, y_pos,
A_HMIDDLE, A_VMIDDLE, shadow_size);
break;
- }
+ }*/
case MN_STRINGSELECT:
{
int list_pos_2 = list_width + font_width;
@@ -619,6 +620,52 @@
if(item[active_item].kind == MN_CONTROLFIELD)
{
*item[active_item].int_p = event.key.keysym.unicode;
+ if(ch[0] != '\0')
+ strcpy(item[active_item].input, ch);
+ else
+ switch(key)
+ {
+ case SDLK_UP:
+ strcpy(item[active_item].input, "Up cursor");
+ break;
+ case SDLK_DOWN:
+ strcpy(item[active_item].input, "Down cursor");
+ break;
+ case SDLK_LEFT:
+ strcpy(item[active_item].input, "Left cursor");
+ break;
+ case SDLK_RIGHT:
+ strcpy(item[active_item].input, "Right cursor");
+ break;
+ case SDLK_RETURN:
+ strcpy(item[active_item].input, "Return");
+ break;
+ case SDLK_SPACE:
+ strcpy(item[active_item].input, "Space");
+ break;
+ case SDLK_RSHIFT:
+ strcpy(item[active_item].input, "Right Shift");
+ break;
+ case SDLK_LSHIFT:
+ strcpy(item[active_item].input, "Left Shift");
+ break;
+ case SDLK_RCTRL:
+ strcpy(item[active_item].input, "Right Control");
+ break;
+ case SDLK_LCTRL:
+ strcpy(item[active_item].input, "Left Control");
+ break;
+ case SDLK_RALT:
+ strcpy(item[active_item].input, "Right Alt");
+ break;
+ case SDLK_LALT:
+ strcpy(item[active_item].input, "Left Alt");
+ break;
+ default:
+ strcpy(item[active_item].input, "?");
+ break;
+ }
+
menuaction = MENU_ACTION_DOWN;
return;
}
Index: configfile.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/configfile.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- configfile.cpp 20 Apr 2004 16:50:18 -0000 1.2
+++ configfile.cpp 21 Apr 2004 17:45:17 -0000 1.3
@@ -23,6 +23,7 @@
#include "setup.h"
#include "globals.h"
#include "lispreader.h"
+#include "player.h"
#ifdef WIN32
const char * config_filename = "/st_config.dat";
@@ -97,6 +98,12 @@
reader.read_int ("joystick-b", &joystick_keymap.b_button);
reader.read_int ("joystick-start", &joystick_keymap.start_button);
reader.read_int ("joystick-deadzone", &joystick_keymap.dead_zone);
+
+ reader.read_int ("keyboard-jump", &keymap.jump);
+ reader.read_int ("keyboard-duck", &keymap.duck);
+ reader.read_int ("keyboard-left", &keymap.left);
+ reader.read_int ("keyboard-right", &keymap.right);
+ reader.read_int ("keyboard-fire", &keymap.fire);
}
void saveconfig (void)
@@ -127,6 +134,12 @@
fprintf(config, "\t(joystick-start %d)\n", joystick_keymap.start_button);
fprintf(config, "\t(joystick-deadzone %d)\n", joystick_keymap.dead_zone);
+ fprintf(config, "\t(keyboard-jump %d)\n", keymap.jump);
+ fprintf(config, "\t(keyboard-duck %d)\n", keymap.duck);
+ fprintf(config, "\t(keyboard-left %d)\n", keymap.left);
+ fprintf(config, "\t(keyboard-right %d)\n", keymap.right);
+ fprintf(config, "\t(keyboard-fire %d)\n", keymap.fire);
+
fprintf(config, ")\n");
}
}
|