[Super-tux-commit] supertux/src gameloop.cpp,1.33,1.34 high_scores.cpp,1.6,1.7 leveleditor.cpp,1.21,
Brought to you by:
wkendrick
From: Tobias Gl??er <to...@us...> - 2004-03-27 17:35:26
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv634/src Modified Files: gameloop.cpp high_scores.cpp leveleditor.cpp menu.cpp menu.h setup.cpp title.cpp Log Message: more kinds of menu_event are handled directly in the menu-code now. Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- menu.cpp 27 Mar 2004 13:04:39 -0000 1.18 +++ menu.cpp 27 Mar 2004 17:24:14 -0000 1.19 @@ -214,6 +214,7 @@ case MN_ACTION: case MN_TEXTFIELD: case MN_NUMFIELD: + case MN_CONTROLFIELD: item[active_item].toggled = true; break; @@ -376,6 +377,7 @@ } case MN_TEXTFIELD: case MN_NUMFIELD: + case MN_CONTROLFIELD: { int input_pos = input_width/2; int text_pos = (text_width + font_width)/2; @@ -517,76 +519,94 @@ } /* Check for menu event */ -void menu_event(SDL_keysym* keysym) +void menu_event(SDL_Event& event) { - SDLKey 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 ( (keysym->unicode & 0xFF80) == 0 ) - { - ch[0] = keysym->unicode & 0x7F; - ch[1] = '\0'; - } - else + SDLKey key; + switch(event.type) { - /* An International Character. */ - } + case SDL_KEYDOWN: + key = event.key.keysym.sym; + SDLMod keymod; + char ch[2]; + keymod = SDL_GetModState(); - switch(key) - { - case SDLK_UP: /* Menu Up */ - menuaction = MENU_ACTION_UP; - menu_change = true; - break; - case SDLK_DOWN: /* Menu Down */ - menuaction = MENU_ACTION_DOWN; - menu_change = true; - break; - case SDLK_LEFT: /* Menu Up */ - menuaction = MENU_ACTION_LEFT; - menu_change = true; - break; - case SDLK_RIGHT: /* Menu Down */ - menuaction = MENU_ACTION_RIGHT; - menu_change = true; - break; - case SDLK_SPACE: - if(current_menu->item[current_menu->active_item].kind == MN_TEXTFIELD) + /* If the current unicode character is an ASCII character, + assign it to ch. */ + if ( (event.key.keysym.unicode & 0xFF80) == 0 ) { - menuaction = MENU_ACTION_INPUT; - menu_change = true; - mn_input_char = ' '; - break; + ch[0] = event.key.keysym.unicode & 0x7F; + ch[1] = '\0'; } - case SDLK_RETURN: /* Menu Hit */ - menuaction = MENU_ACTION_HIT; - menu_change = true; - break; - case SDLK_DELETE: - case SDLK_BACKSPACE: - menuaction = MENU_ACTION_REMOVE; - menu_change = true; - delete_character++; - break; - default: - if( (key >= SDLK_0 && key <= SDLK_9) || (key >= SDLK_a && key <= SDLK_z) || (key >= SDLK_SPACE && key <= SDLK_SLASH)) + else { - menuaction = MENU_ACTION_INPUT; + /* An International Character. */ + } + + switch(key) + { + case SDLK_UP: /* Menu Up */ + menuaction = MENU_ACTION_UP; menu_change = true; - mn_input_char = *ch; + break; + case SDLK_DOWN: /* Menu Down */ + menuaction = MENU_ACTION_DOWN; + menu_change = true; + break; + case SDLK_LEFT: /* Menu Up */ + menuaction = MENU_ACTION_LEFT; + menu_change = true; + break; + case SDLK_RIGHT: /* Menu Down */ + menuaction = MENU_ACTION_RIGHT; + menu_change = true; + break; + case SDLK_SPACE: + if(current_menu->item[current_menu->active_item].kind == MN_TEXTFIELD) + { + menuaction = MENU_ACTION_INPUT; + menu_change = true; + mn_input_char = ' '; + break; + } + case SDLK_RETURN: /* Menu Hit */ + menuaction = MENU_ACTION_HIT; + menu_change = true; + break; + case SDLK_DELETE: + case SDLK_BACKSPACE: + menuaction = MENU_ACTION_REMOVE; + menu_change = true; + delete_character++; + 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; + menu_change = true; + mn_input_char = *ch; + } + else + { + mn_input_char = '\0'; + } + break; } - else + break; + case SDL_JOYAXISMOTION: + if(event.jaxis.axis == JOY_Y) { - mn_input_char = '\0'; + if (event.jaxis.value > 1024) + menuaction = MENU_ACTION_DOWN; + else if (event.jaxis.value < -1024) + menuaction = MENU_ACTION_UP; } break; + case SDL_JOYBUTTONDOWN: + menuaction = MENU_ACTION_HIT; + break; + default: + break; } - - /* FIXME: NO JOYSTICK SUPPORT */ /*#ifdef JOY_YES else if (event.type == SDL_JOYBUTTONDOWN) Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- setup.cpp 27 Mar 2004 11:27:45 -0000 1.19 +++ setup.cpp 27 Mar 2004 17:24:14 -0000 1.20 @@ -38,6 +38,7 @@ #include "menu.h" #include "gameloop.h" #include "configfile.h" +#include "scene.h" #ifdef WIN32 #define mkdir(dir, mode) mkdir(dir) @@ -352,6 +353,7 @@ { main_menu = new Menu(); options_menu = new Menu(); + options_controls_menu = new Menu(); load_game_menu = new Menu(); save_game_menu = new Menu(); game_menu = new Menu(); @@ -381,8 +383,15 @@ options_menu->additem(MN_DEACTIVE,"Music ",use_music,0); } options_menu->additem(MN_TOGGLE,"Show FPS ",show_fps,0); + options_menu->additem(MN_GOTO,"Controls ",0,options_controls_menu); options_menu->additem(MN_HL,"",0,0); options_menu->additem(MN_BACK,"Back",0,0); + + options_controls_menu->additem(MN_LABEL,"Controls",0,0); + options_controls_menu->additem(MN_HL,"",0,0); + options_controls_menu->additem(MN_CONTROLFIELD,"Move Right",tux.keymap.right,0); + options_controls_menu->additem(MN_HL,"",0,0); + options_controls_menu->additem(MN_BACK,"Back",0,0); load_game_menu->additem(MN_LABEL,"Load Game",0,0); load_game_menu->additem(MN_HL,"",0,0); Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- menu.h 27 Mar 2004 13:04:39 -0000 1.21 +++ menu.h 27 Mar 2004 17:24:14 -0000 1.22 @@ -27,9 +27,10 @@ MN_DEACTIVE, MN_TEXTFIELD, MN_NUMFIELD, + MN_CONTROLFIELD, MN_STRINGSELECT, MN_LABEL, - MN_HL /* horizontal line */ + MN_HL, /* horizontal line */ }; class Menu; @@ -116,7 +117,7 @@ void menu_process_current(void); /* Check for a menu event */ -void menu_event(SDL_keysym* keysym); +void menu_event(SDL_Event& event); #endif /*SUPERTUX_MENU_H*/ Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- leveleditor.cpp 27 Mar 2004 00:38:47 -0000 1.21 +++ leveleditor.cpp 27 Mar 2004 17:24:14 -0000 1.22 @@ -860,7 +860,7 @@ key = event.key.keysym.sym; if(show_menu) { - menu_event(&event.key.keysym); + menu_event(event); if(key == SDLK_ESCAPE) { show_menu = false; Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- title.cpp 26 Mar 2004 22:08:12 -0000 1.13 +++ title.cpp 27 Mar 2004 17:24:14 -0000 1.14 @@ -134,6 +134,7 @@ while (SDL_PollEvent(&event)) { + menu_event(event); if (event.type == SDL_QUIT) { /* Quit event - quit: */ @@ -146,7 +147,7 @@ key = event.key.keysym.sym; /* Check for menu events */ - menu_event(&event.key.keysym); + //menu_event(event); if (key == SDLK_ESCAPE) { @@ -155,18 +156,6 @@ quit = 1; } } - else if (event.type == SDL_JOYAXISMOTION && event.jaxis.axis == JOY_Y) - { - if (event.jaxis.value > 1024) - menuaction = MENU_ACTION_DOWN; - else if (event.jaxis.value < -1024) - menuaction = MENU_ACTION_UP; - } - else if (event.type == SDL_JOYBUTTONDOWN) - { - /* Joystick button: Continue: */ - menuaction = MENU_ACTION_HIT; - } } /* Draw the background: */ Index: high_scores.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/high_scores.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- high_scores.cpp 24 Mar 2004 14:35:11 -0000 1.6 +++ high_scores.cpp 27 Mar 2004 17:24:14 -0000 1.7 @@ -115,7 +115,7 @@ while(SDL_PollEvent(&event)) if(event.type == SDL_KEYDOWN) - menu_event(&event.key.keysym); + menu_event(event); switch (highscore_menu->check()) { Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- gameloop.cpp 27 Mar 2004 00:38:47 -0000 1.33 +++ gameloop.cpp 27 Mar 2004 17:24:14 -0000 1.34 @@ -130,6 +130,9 @@ { while (SDL_PollEvent(&event)) { + /* Check for menu-events, if the menu is shown */ + if(show_menu) + menu_event(event); switch(event.type) { case SDL_QUIT: /* Quit event - quit: */ @@ -138,10 +141,6 @@ case SDL_KEYDOWN: /* A keypress! */ key = event.key.keysym.sym; - /* Check for menu-events, if the menu is shown */ - if(show_menu) - menu_event(&event.key.keysym); - if(tux.key_event(key,DOWN)) break; @@ -266,16 +265,8 @@ tux.input.down = UP; else tux.input.down = UP; - - /* Handle joystick for the menu */ - if(show_menu) - { - if(tux.input.down == DOWN) - menuaction = MENU_ACTION_DOWN; - else - menuaction = MENU_ACTION_UP; - } - break; + + break; default: break; } @@ -291,9 +282,7 @@ tux.input.up = UP; else if (event.jbutton.button == JOY_B) tux.input.fire = UP; - - if(show_menu) - menuaction = MENU_ACTION_HIT; + break; default: |