[Super-tux-commit] supertux/src gameloop.cpp,1.42,1.43 gameloop.h,1.22,1.23 menu.cpp,1.25,1.26 menu.
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-10 19:09:50
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29477 Modified Files: gameloop.cpp gameloop.h menu.cpp menu.h setup.cpp setup.h title.cpp worldmap.cpp Log Message: - reorganized menu flow as descripted in the todo, this breaks returning from the game at the moment, since something in loading savegames is broken, but since savegames needs restructuring anyway, it shouldn't be much of a problem Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- menu.cpp 10 Apr 2004 14:53:42 -0000 1.25 +++ menu.cpp 10 Apr 2004 18:56:17 -0000 1.26 @@ -43,6 +43,7 @@ Menu* highscore_menu = 0; Menu* load_game_menu = 0; Menu* save_game_menu = 0; +Menu* contrib_menu = 0; Menu* current_menu = 0; Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- setup.cpp 10 Apr 2004 14:53:43 -0000 1.24 +++ setup.cpp 10 Apr 2004 18:56:17 -0000 1.25 @@ -11,6 +11,7 @@ */ #include <assert.h> +#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -358,15 +359,24 @@ save_game_menu = new Menu(); game_menu = new Menu(); highscore_menu = new Menu(); + contrib_menu = new Menu(); main_menu->set_pos(screen->w/2, 335); - main_menu->additem(MN_ACTION,"Start Game",0,0); - main_menu->additem(MN_GOTO,"Load Game",0,load_game_menu); - main_menu->additem(MN_GOTO,"Options",0,options_menu); + main_menu->additem(MN_GOTO, "Start Game",0,load_game_menu); + main_menu->additem(MN_GOTO, "Contrib Levels",0,contrib_menu); + main_menu->additem(MN_GOTO, "Options",0,options_menu); main_menu->additem(MN_ACTION,"Level editor",0,0); main_menu->additem(MN_ACTION,"Credits",0,0); main_menu->additem(MN_ACTION,"Quit",0,0); + contrib_menu->additem(MN_LABEL,"Contrib Levels",0,0); + contrib_menu->additem(MN_HL,"",0,0); + contrib_menu->additem(MN_ACTION, "Some Levelset", 0, 0); + contrib_menu->additem(MN_ACTION, "Someother Levelset", 0, 0); + contrib_menu->additem(MN_ACTION, "Yet another Levelset", 0, 0); + contrib_menu->additem(MN_HL,"",0,0); + contrib_menu->additem(MN_BACK,"Back",0,0); + options_menu->additem(MN_LABEL,"Options",0,0); options_menu->additem(MN_HL,"",0,0); options_menu->additem(MN_TOGGLE,"Fullscreen",use_fullscreen,0); @@ -391,7 +401,7 @@ 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_LABEL,"Start Game",0,0); load_game_menu->additem(MN_HL,"",0,0); load_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0); load_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0); @@ -427,43 +437,59 @@ { for(int i = 2; i < 7; ++i) { - char *tmp; - slotinfo(&tmp,i-1); - if(load && strlen(tmp) == strlen("Slot X - Free") ) - pmenu->item[i].kind = MN_DEACTIVE; + // FIXME: Insert a real savegame struct/class here instead of + // doing string vodoo + std::string tmp = slotinfo(i-1); + + if(load && tmp.length() == strlen("Slot X - Free")) + pmenu->item[i].kind = MN_ACTION; else pmenu->item[i].kind = MN_ACTION; - menu_item_change_text(&pmenu->item[i],tmp); - free(tmp); + menu_item_change_text(&pmenu->item[i], tmp.c_str()); } } -void process_save_load_game_menu(int save) +void process_save_game_menu() { - int slot; - switch (slot = (save ? save_game_menu->check() : load_game_menu->check())) + int slot = save_game_menu->check(); + if (slot != -1) + savegame(slot - 1); +} + +bool process_load_game_menu() +{ + int slot = load_game_menu->check(); + + if(slot != -1) { - default: - if(slot != -1) + // FIXME: Insert a real savegame struct/class here instead of + // doing string vodoo + std::string tmp = slotinfo(slot-1); + if (tmp.length() == strlen("Slot X - Free")) { - if(save) + gameloop("default", 1, ST_GL_PLAY); + show_menu = true; + Menu::set_current(main_menu); + } + else + { + if (game_started) { - savegame(slot - 1); + gameloop("default",slot - 1,ST_GL_LOAD_GAME); + show_menu = true; + Menu::set_current(main_menu); } else { - if (game_started) - { - gameloop("default",slot - 1,ST_GL_LOAD_GAME); - show_menu = true; - Menu::set_current(main_menu); - } - else - loadgame(slot - 1); + loadgame(slot - 1); } - st_pause_ticks_stop(); } - break; + st_pause_ticks_stop(); + return true; + } + else + { + return false; } } @@ -608,7 +634,7 @@ /* Set window manager stuff: */ - SDL_WM_SetCaption("Super Tux", "Super Tux"); + SDL_WM_SetCaption("SuperTux " VERSION, "SuperTux"); } @@ -941,8 +967,7 @@ else if (strcmp(argv[i], "--version") == 0) { /* Show version: */ - - printf("Super Tux - version " VERSION "\n"); + printf("SuperTux " VERSION "\n"); exit(0); } else if (strcmp(argv[i], "--disable-sound") == 0) Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- menu.h 10 Apr 2004 14:53:43 -0000 1.26 +++ menu.h 10 Apr 2004 18:56:17 -0000 1.27 @@ -64,7 +64,6 @@ int width(); int height(); - public: timer_type effect; int arrange_left; @@ -106,6 +105,7 @@ extern bool menu_change; extern texture_type checkbox, checkbox_checked, back, arrow_left, arrow_right; +extern Menu* contrib_menu; extern Menu* main_menu; extern Menu* game_menu; extern Menu* options_menu; Index: setup.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- setup.h 24 Mar 2004 14:35:11 -0000 1.14 +++ setup.h 10 Apr 2004 18:56:17 -0000 1.15 @@ -35,7 +35,12 @@ void st_menu(void); void st_abort(const std::string& reason, const std::string& details); void process_options_menu(void); -void process_save_load_game_menu(int save); + +void process_save_game_menu(); + +/** Return true if the gameloop() was entered, false otherwise */ +bool process_load_game_menu(); + void update_load_save_game_menu(Menu* pmenu, int load); void parseargs(int argc, char * argv[]); Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- gameloop.h 3 Apr 2004 13:31:14 -0000 1.22 +++ gameloop.h 10 Apr 2004 18:56:17 -0000 1.23 @@ -35,7 +35,7 @@ int gameloop(const char * subset, int levelnb, int mode); void savegame(int slot); void loadgame(int slot); -void slotinfo(char **pinfo, int slot); +std::string slotinfo(int slot); bool issolid(float x, float y); bool isbrick(float x, float y); bool isice(float x, float y); Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- title.cpp 10 Apr 2004 14:53:43 -0000 1.23 +++ title.cpp 10 Apr 2004 18:56:17 -0000 1.24 @@ -190,7 +190,7 @@ while (SDL_PollEvent(&event)) { - menu_event(event); + menu_event(event); if (event.type == SDL_QUIT) { /* Quit event - quit: */ @@ -231,10 +231,10 @@ /* Draw the high score: */ /* - sprintf(str, "High score: %d", hs_score); - text_drawf(&gold_text, str, 0, -40, A_HMIDDLE, A_BOTTOM, 1); - sprintf(str, "by %s", hs_name); - text_drawf(&gold_text, str, 0, -20, A_HMIDDLE, A_BOTTOM, 1); + sprintf(str, "High score: %d", hs_score); + text_drawf(&gold_text, str, 0, -40, A_HMIDDLE, A_BOTTOM, 1); + sprintf(str, "by %s", hs_name); + text_drawf(&gold_text, str, 0, -20, A_HMIDDLE, A_BOTTOM, 1); */ /* Don't draw menu, if quit is true */ @@ -245,7 +245,10 @@ { switch (main_menu->check()) { +#if 0 case 0: + // Quick Play + // FIXME: obsolete done = 0; i = 0; if(level_subsets.num_items != 0) @@ -278,8 +281,7 @@ quit = 1; break; case SDL_KEYDOWN: // key pressed - /* Keypress... */ - + // Keypress... key = event.key.keysym.sym; if(key == SDLK_LEFT) @@ -322,9 +324,14 @@ titletux.level_begin(); update_time = st_get_ticks(); break; - case 1: +#endif + case 0: + // Start Game, ie. goto the slots menu update_load_save_game_menu(load_game_menu, true); break; + case 1: + // Contrib Menu + break; case 3: done = 1; quit = leveleditor(1); @@ -343,7 +350,17 @@ } else if(current_menu == load_game_menu) { - process_save_load_game_menu(false); + if (process_load_game_menu()) + { + // reset tux + scroll_x = 0; + titletux.level_begin(); + update_time = st_get_ticks(); + } + } + else if(current_menu == contrib_menu) + { + } mouse_cursor->draw(); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- worldmap.cpp 3 Apr 2004 13:31:14 -0000 1.18 +++ worldmap.cpp 10 Apr 2004 18:56:17 -0000 1.19 @@ -105,8 +105,8 @@ texture_load(&sprite, datadir + "/images/worldmap/tux.png", USE_ALPHA); offset = 0; moving = false; - tile_pos.x = 0; - tile_pos.y = 0; + tile_pos.x = 5; + tile_pos.y = 5; direction = NONE; input_direction = NONE; } Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- gameloop.cpp 9 Apr 2004 02:19:09 -0000 1.42 +++ gameloop.cpp 10 Apr 2004 18:56:17 -0000 1.43 @@ -701,11 +701,11 @@ } else if(current_menu == save_game_menu ) { - process_save_load_game_menu(true); + process_save_game_menu(); } else if(current_menu == load_game_menu ) { - process_save_load_game_menu(false); + process_load_game_menu(); } } @@ -1619,7 +1619,7 @@ } -void slotinfo(char **pinfo, int slot) +std::string slotinfo(int slot) { FILE* fi; char slotfile[1024]; @@ -1648,7 +1648,6 @@ fclose(fi); } - *pinfo = (char*) malloc(sizeof(char) * (strlen(tmp)+1)); - strcpy(*pinfo,tmp); + return tmp; } |