[Super-tux-commit] supertux/src gameloop.cpp,1.74,1.75 leveleditor.cpp,1.49,1.50 menu.cpp,1.35,1.36
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-04-18 12:03:18
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25291/src Modified Files: gameloop.cpp leveleditor.cpp menu.cpp menu.h timer.cpp title.cpp worldmap.cpp Log Message: Finally!! This makes the Back button to be used in case there is one (when Esc is pressed). Because of that, the menu is now much more independent. Currently, everything seems to be working just fine and smooth. Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- menu.cpp 13 Apr 2004 12:25:22 -0000 1.35 +++ menu.cpp 18 Apr 2004 12:03:06 -0000 1.36 @@ -144,6 +144,7 @@ { pos_x = screen->w/2; pos_y = screen->h/2; + has_backitem = false; last_menu = 0; arrange_left = 0; active_item = 0; @@ -160,6 +161,9 @@ void Menu::additem(MenuItemKind kind_, const std::string& text_, int toggle_, Menu* menu_) { + if(kind_ == MN_BACK) + has_backitem = true; + additem(MenuItem::create(kind_, text_.c_str(), toggle_, menu_)); } @@ -167,6 +171,9 @@ void Menu::additem(MenuItem* pmenu_item) { + if(pmenu_item->kind == MN_BACK) + has_backitem = true; + item.push_back(*pmenu_item); delete pmenu_item; } @@ -540,6 +547,9 @@ /* Draw the current menu and execute the (menu)events */ void menu_process_current(void) { + if(!show_menu) + return; + menu_change = false; if(current_menu != NULL) @@ -555,6 +565,9 @@ void Menu::event(SDL_Event& event) { + if(show_menu == false && event.key.keysym.sym != SDLK_ESCAPE) + return; + SDLKey key; switch(event.type) { @@ -613,6 +626,13 @@ menu_change = true; delete_character++; break; + case SDLK_ESCAPE: + if(show_menu && has_backitem == true && last_menu != NULL) + Menu::set_current(last_menu); + else if(show_menu) + show_menu = false; + else + show_menu = true; default: if( (key >= SDLK_0 && key <= SDLK_9) || (key >= SDLK_a && key <= SDLK_z) || (key >= SDLK_SPACE && key <= SDLK_SLASH)) { Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- menu.h 13 Apr 2004 12:25:22 -0000 1.34 +++ menu.h 18 Apr 2004 12:03:07 -0000 1.35 @@ -59,6 +59,7 @@ // position of the menu (ie. center of the menu, not top/left) int pos_x; int pos_y; + bool has_backitem; Menu* last_menu; int width(); Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- leveleditor.cpp 17 Apr 2004 13:29:38 -0000 1.49 +++ leveleditor.cpp 18 Apr 2004 12:03:06 -0000 1.50 @@ -40,7 +40,6 @@ /* definitions to aid development */ #define DONE_LEVELEDITOR 1 #define DONE_QUIT 2 -#define DONE_CHANGELEVEL 3 /* definitions that affect gameplay */ #define KEY_CURSOR_SPEED 32 @@ -340,12 +339,6 @@ return 0; } - if(done == DONE_QUIT) - { - le_quit(); - return 1; - } - ++global_frame_counter; SDL_Delay(25); @@ -791,9 +784,8 @@ while(SDL_PollEvent(&event)) { - if(show_menu) - current_menu->event(event); - else + current_menu->event(event); + if(!show_menu) mouse_cursor->set_state(MC_NORMAL); /* testing SDL_KEYDOWN, SDL_KEYUP and SDL_QUIT events*/ @@ -804,23 +796,8 @@ { case SDL_KEYDOWN: // key pressed key = event.key.keysym.sym; - if(show_menu) - { - if(key == SDLK_ESCAPE) - { - show_menu = false; - Menu::set_current(leveleditor_menu); - } - break; - } switch(key) { - case SDLK_ESCAPE: - if(!show_menu) - show_menu = true; - else - show_menu = false; - break; case SDLK_LEFT: if(fire == DOWN) cursor_x -= KEY_CURSOR_SPEED; Index: timer.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/timer.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- timer.cpp 11 Apr 2004 16:38:58 -0000 1.9 +++ timer.cpp 18 Apr 2004 12:03:07 -0000 1.10 @@ -32,7 +32,8 @@ void st_pause_ticks_start(void) { - st_pause_count = SDL_GetTicks(); + if(st_pause_count == 0) + st_pause_count = SDL_GetTicks(); } void st_pause_ticks_stop(void) Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- title.cpp 17 Apr 2004 13:56:48 -0000 1.44 +++ title.cpp 18 Apr 2004 12:03:07 -0000 1.45 @@ -285,7 +285,7 @@ /* Check for menu events */ //menu_event(event); - if (key == SDLK_ESCAPE) + if (!show_menu) { /* Escape: Quit: */ done = true; Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- worldmap.cpp 17 Apr 2004 21:24:02 -0000 1.31 +++ worldmap.cpp 18 Apr 2004 12:03:07 -0000 1.32 @@ -370,11 +370,11 @@ SDL_Event event; while (SDL_PollEvent(&event)) { - if(show_menu) - { - current_menu->event(event); - } - else + if(!show_menu && event.key.keysym.sym == SDLK_ESCAPE) + Menu::set_current(worldmap_menu); + + current_menu->event(event); + if(!show_menu) { switch(event.type) { @@ -385,10 +385,6 @@ case SDL_KEYDOWN: switch(event.key.keysym.sym) { - case SDLK_ESCAPE: - Menu::set_current(worldmap_menu); - show_menu = !show_menu; - break; case SDLK_LCTRL: case SDLK_RETURN: enter_level = true; @@ -643,8 +639,7 @@ void WorldMap::display() { - show_menu = 0; - menu_reset(); + show_menu = false; quit = false; @@ -669,7 +664,11 @@ get_input(); update(); - menu_process_current(); + if(show_menu) + { + menu_process_current(); + mouse_cursor->draw(); + } flipscreen(); SDL_Delay(20); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- gameloop.cpp 17 Apr 2004 13:56:47 -0000 1.74 +++ gameloop.cpp 18 Apr 2004 12:03:06 -0000 1.75 @@ -134,8 +134,7 @@ while (SDL_PollEvent(&event)) { /* Check for menu-events, if the menu is shown */ - if(show_menu) - current_menu->event(event); + current_menu->event(event); switch(event.type) { @@ -159,7 +158,7 @@ { exit_status = LEVEL_ABORT; } - else if(show_menu) + else if(!show_menu) { Menu::set_current(game_menu); show_menu = 0; |