- added menu to worldmap
authorIngo Ruhnke <grumbel@gmx.de>
Mon, 12 Apr 2004 01:55:30 +0000 (01:55 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Mon, 12 Apr 2004 01:55:30 +0000 (01:55 +0000)
SVN-Revision: 502

src/menu.cpp
src/menu.h
src/setup.cpp
src/worldmap.cpp

index 7d59a90..97ea5fc 100644 (file)
@@ -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;
index 58e09e9..4301d4e 100644 (file)
@@ -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;
index 9865bfa..a1c8af9 100644 (file)
@@ -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);
 }
 
index b329d87..ae83fed 100644 (file)
@@ -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);
   }