From: Ingo Ruhnke Date: Mon, 12 Apr 2004 01:55:30 +0000 (+0000) Subject: - added menu to worldmap X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=989b4b7cf6eb648bc2395742e23f0cdba6574427;p=supertux.git - added menu to worldmap SVN-Revision: 502 --- diff --git a/src/menu.cpp b/src/menu.cpp index 7d59a9053..97ea5fc1a 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -38,6 +38,7 @@ texture_type checkbox, checkbox_checked, back, arrow_left, arrow_right; Menu* main_menu = 0; Menu* game_menu = 0; +Menu* worldmap_menu = 0; Menu* options_menu = 0; Menu* options_controls_menu = 0; Menu* highscore_menu = 0; diff --git a/src/menu.h b/src/menu.h index 58e09e95a..4301d4e9b 100644 --- a/src/menu.h +++ b/src/menu.h @@ -120,6 +120,7 @@ extern Menu* contrib_menu; extern Menu* contrib_subset_menu; extern Menu* main_menu; extern Menu* game_menu; +extern Menu* worldmap_menu; extern Menu* options_menu; extern Menu* options_controls_menu; extern Menu* highscore_menu; diff --git a/src/setup.cpp b/src/setup.cpp index 9865bfa5a..a1c8af96c 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -361,6 +361,7 @@ void st_menu(void) highscore_menu = new Menu(); contrib_menu = new Menu(); contrib_subset_menu = new Menu(); + worldmap_menu = new Menu(); main_menu->set_pos(screen->w/2, 335); main_menu->additem(MN_GOTO, "Start Game",0,load_game_menu); @@ -423,6 +424,13 @@ void st_menu(void) game_menu->additem(MN_HL,"",0,0); game_menu->additem(MN_ACTION,"Quit Game",0,0); + worldmap_menu->additem(MN_LABEL,"Worldmap Menu",0,0); + worldmap_menu->additem(MN_HL,"",0,0); + worldmap_menu->additem(MN_ACTION,"Return To Game",0,0); + worldmap_menu->additem(MN_GOTO,"Options",0,options_menu); + worldmap_menu->additem(MN_HL,"",0,0); + worldmap_menu->additem(MN_ACTION,"Quit Game",0,0); + highscore_menu->additem(MN_TEXTFIELD,"Enter your name:",0,0); } diff --git a/src/worldmap.cpp b/src/worldmap.cpp index b329d8700..ae83fed7a 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -283,72 +283,82 @@ WorldMap::load_map() void WorldMap::get_input() { - SDL_Event event; - enter_level = false; input_direction = NONE; - + + SDL_Event event; while (SDL_PollEvent(&event)) { - switch(event.type) + if(show_menu) { - case SDL_QUIT: - quit = true; - break; - - case SDL_KEYDOWN: - switch(event.key.keysym.sym) + current_menu->event(event); + } + else + { + switch(event.type) { - case SDLK_ESCAPE: + case SDL_QUIT: quit = true; break; - case SDLK_LCTRL: - case SDLK_RETURN: - enter_level = true; - break; - default: - break; - } - break; - case SDL_JOYAXISMOTION: - switch(event.jaxis.axis) - { - case JOY_X: - if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) - input_direction = WEST; - else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) - input_direction = EAST; + 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; + break; + default: + break; + } break; - case JOY_Y: - if (event.jaxis.value > JOYSTICK_DEAD_ZONE) - input_direction = SOUTH; - else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) - input_direction = NORTH; + + case SDL_JOYAXISMOTION: + switch(event.jaxis.axis) + { + case JOY_X: + if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + input_direction = WEST; + else if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + input_direction = EAST; + break; + case JOY_Y: + if (event.jaxis.value > JOYSTICK_DEAD_ZONE) + input_direction = SOUTH; + else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE) + input_direction = NORTH; + break; + } break; - } - break; - case SDL_JOYBUTTONDOWN: - if (event.jbutton.button == JOY_B) - enter_level = true; - break; + case SDL_JOYBUTTONDOWN: + if (event.jbutton.button == JOY_B) + enter_level = true; + break; - default: - break; + default: + break; + } } } - Uint8 *keystate = SDL_GetKeyState(NULL); + if (!show_menu) + { + Uint8 *keystate = SDL_GetKeyState(NULL); - if (keystate[SDLK_LEFT]) - input_direction = WEST; - else if (keystate[SDLK_RIGHT]) - input_direction = EAST; - else if (keystate[SDLK_UP]) - input_direction = NORTH; - else if (keystate[SDLK_DOWN]) - input_direction = SOUTH; + if (keystate[SDLK_LEFT]) + input_direction = WEST; + else if (keystate[SDLK_RIGHT]) + input_direction = EAST; + else if (keystate[SDLK_UP]) + input_direction = NORTH; + else if (keystate[SDLK_DOWN]) + input_direction = SOUTH; + } } Point @@ -434,6 +444,22 @@ WorldMap::update() tux->set_direction(input_direction); tux->update(0.33f); } + + if(show_menu) + { + if(current_menu == worldmap_menu) + { + switch (worldmap_menu->check()) + { + case 2: // Return to game + menu_reset(); + break; + case 5: // Quit Worldmap + quit = true; + break; + } + } + } } Tile* @@ -462,7 +488,6 @@ WorldMap::draw() } tux->draw(); - flipscreen(); } void @@ -477,6 +502,10 @@ WorldMap::display() draw(); get_input(); update(); + + menu_process_current(); + flipscreen(); + SDL_Delay(20); }