pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r2685 - in branches/pingus_sdl/src: . components


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2685 - in branches/pingus_sdl/src: . components
Date: Thu, 18 Jan 2007 03:52:23 +0100

Author: grumbel
Date: 2007-01-18 03:52:22 +0100 (Thu, 18 Jan 2007)
New Revision: 2685

Modified:
   branches/pingus_sdl/src/components/action_button.cxx
   branches/pingus_sdl/src/components/menu_button.cxx
   branches/pingus_sdl/src/components/menu_button.hxx
   branches/pingus_sdl/src/pingus_menu.cxx
   branches/pingus_sdl/src/pingus_menu.hxx
Log:
- fixed input handling in the main menu

Modified: branches/pingus_sdl/src/components/action_button.cxx
===================================================================
--- branches/pingus_sdl/src/components/action_button.cxx        2007-01-17 
22:19:41 UTC (rev 2684)
+++ branches/pingus_sdl/src/components/action_button.cxx        2007-01-18 
02:52:22 UTC (rev 2685)
@@ -48,7 +48,6 @@
   font_b = Fonts::pingus_large;
 
   sprite = Resource::load_sprite("pingus/player0/" + action_to_string(name) + 
"/right");
-  ////sprite.set_play_loop(true);
 }
 
 bool

Modified: branches/pingus_sdl/src/components/menu_button.cxx
===================================================================
--- branches/pingus_sdl/src/components/menu_button.cxx  2007-01-17 22:19:41 UTC 
(rev 2684)
+++ branches/pingus_sdl/src/components/menu_button.cxx  2007-01-18 02:52:22 UTC 
(rev 2685)
@@ -22,18 +22,15 @@
 #include "../sound/sound.hxx"
 #include "../resource.hxx"
 #include "../pingus_menu_manager.hxx"
-////#include "../theme_selector.hxx"
-////#include "../gui/screen_manager.hxx"
-////#include "../worldmap/manager.hxx"
-////#include "../story_screen.hxx"
 #include "../gettext.h"
-////#include "../stat_manager.hxx"
 
 #include "menu_button.hxx"
 
 
-MenuButton::MenuButton(const Vector2i& pos_, const Sprite& sprite_, 
+MenuButton::MenuButton(PingusMenu* menu_,
+                       const Vector2i& pos_, const Sprite& sprite_, 
                        const std::string& text_, const std::string& desc_)
+  : menu(menu_)
 {
   text = text_;
   desc  = desc_;
@@ -47,7 +44,7 @@
   font_large = Fonts::pingus_large;
 
   mouse_over = false;
-  pressed = false;
+  pressed    = false;
 }
 
 MenuButton::MenuButton ()
@@ -72,7 +69,8 @@
 void
 MenuButton::on_click ()
 {
-  ////click();
+  std::cout << "MenuButton: Click" << std::endl;
+  menu->on_click(this);
 }
 
 void

Modified: branches/pingus_sdl/src/components/menu_button.hxx
===================================================================
--- branches/pingus_sdl/src/components/menu_button.hxx  2007-01-17 22:19:41 UTC 
(rev 2684)
+++ branches/pingus_sdl/src/components/menu_button.hxx  2007-01-18 02:52:22 UTC 
(rev 2685)
@@ -33,6 +33,7 @@
 class MenuButton : public GUI::Component
 {
 protected:
+  PingusMenu* menu;
   Sprite surface_p;
   Font   font;
   Font   font_large;
@@ -49,7 +50,7 @@
   ////CL_Signal_v0 click;
 
 public:
-  MenuButton(const Vector2i& pos, const Sprite& sprite, 
+  MenuButton(PingusMenu* menu, const Vector2i& pos, const Sprite& sprite, 
              const std::string& text, const std::string& desc);
   MenuButton();
   virtual ~MenuButton();

Modified: branches/pingus_sdl/src/pingus_menu.cxx
===================================================================
--- branches/pingus_sdl/src/pingus_menu.cxx     2007-01-17 22:19:41 UTC (rev 
2684)
+++ branches/pingus_sdl/src/pingus_menu.cxx     2007-01-18 02:52:22 UTC (rev 
2685)
@@ -27,8 +27,8 @@
 #include "stat_manager.hxx"
 #include "start_screen.hxx"
 #include "story_screen.hxx"
-////#include "worldmap/worldmap.hxx"
-////#include "worldmap/manager.hxx"
+#include "worldmap/worldmap.hxx"
+#include "worldmap/manager.hxx"
 #include "gui/screen_manager.hxx"
 #include "pingus_menu_manager.hxx"
 #include "gui/gui_manager.hxx"
@@ -44,52 +44,41 @@
 {
   is_init = false;
     
-  start_button = new MenuButton(Vector2i(Display::get_width() * 400 / 800,
+  start_button = new MenuButton(this, Vector2i(Display::get_width() * 400 / 
800,
                                         Display::get_height() * 450 / 600),
                                 Resource::load_sprite("core/menu/play_on"),
                                 _("Start"),
                                 _("..:: Start the game ::.."));
   
-  quit_button = new MenuButton(Vector2i(Display::get_width() * 650 / 800,
+  quit_button = new MenuButton(this, Vector2i(Display::get_width() * 650 / 800,
                                        Display::get_height() * 450 / 600),
                                Resource::load_sprite("core/menu/exit_on"),
                                _("Exit"),
                                _("..:: Bye, bye ::.."));
 
-  contrib_button = new MenuButton(Vector2i(Display::get_width() * 150 / 800,
+  contrib_button = new MenuButton(this, Vector2i(Display::get_width() * 150 / 
800,
                                           Display::get_height() * 450 / 600),
                                   
Resource::load_sprite("core/menu/options_on"),
                                   _("Contrib\nLevels"),
                                   _("..:: Play User Build levels ::.."));
 
-  story_button  = new MenuButton(Vector2i(Display::get_width() * 400 / 800,
+  story_button  = new MenuButton(this, Vector2i(Display::get_width() * 400 / 
800,
                                          Display::get_height() * 340 / 600),
                                  Resource::load_sprite("core/menu/credits_on"),
                                  _("Story"),
                                  _("..:: Start the story ::.."));
   
-  multiplayer_button = new MenuButton(Vector2i(Display::get_width() * 150 / 
800,
+  multiplayer_button = new MenuButton(this, Vector2i(Display::get_width() * 
150 / 800,
                                               Display::get_height() * 340 / 
600),
                                       
Resource::load_sprite("core/menu/multi_on"),
                                       _("Multiplayer"),
                                       _("..:: Multiplayer Match ::.."));
 
-  editor_button = new MenuButton(Vector2i(Display::get_width() * 400 / 800,
+  editor_button = new MenuButton(this, Vector2i(Display::get_width() * 400 / 
800,
                                          Display::get_height() * 450 / 600),
                                  Resource::load_sprite("core/menu/create_on"),
                                  _("Level Editor"),
                                  _("..:: Create your own levels ::.."));
-
-#if 0
-  slots.push_back(start_button->sig_click().connect(this, 
&PingusMenu::setup_game_menu));
-  slots.push_back(quit_button->sig_click().connect(this, 
&PingusMenu::do_quit));
-
-  slots.push_back(story_button->sig_click().connect(this, 
&PingusMenu::setup_worldmap_menu));
-  slots.push_back(multiplayer_button->sig_click().connect(this, 
&PingusMenu::setup_main_menu));
-  
-  slots.push_back(contrib_button->sig_click().connect(this, 
&PingusMenu::setup_contrib_menu));
-  slots.push_back(editor_button->sig_click().connect(this, 
&PingusMenu::do_edit));
-#endif
 }
 
 void
@@ -121,25 +110,21 @@
 void
 PingusMenu::setup_contrib_menu()
 {
-#if 0
   if (filedialog)
     delete filedialog;
   filedialog = new FileDialog(this, ".pingus", 
                               path_manager.complete("levels/"), true);
   manager->push_menu (filedialog);
-#endif
 }
 
 void
 PingusMenu::setup_worldmap_menu()
 {
-#if 0
   if (filedialog)
     delete filedialog;
   filedialog = new FileDialog(this, ".xml", 
                               path_manager.complete("worldmaps/"), true);
   manager->push_menu (filedialog);
-#endif
 }
 
 void
@@ -175,7 +160,6 @@
 void
 PingusMenu::do_start(const std::string &filename)
 { // Start the story or worldmap mode
-#if 0
   Sound::PingusSound::play_sound ("letsgo");
   WorldMapNS::WorldMapManager::instance()->load(filename);
   
@@ -188,23 +172,20 @@
       (new 
StoryScreen(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
 true);
   else
     
ScreenManager::instance()->push_screen(WorldMapNS::WorldMapManager::instance());
-#endif
 }
 
 void PingusMenu::do_contrib(const std::string &levelfile)
 { // Launch the specified level - don't bother checking for it, it has to exist
-#if 0
   Sound::PingusSound::play_sound ("letsgo");
   ScreenManager::instance()->push_screen
     (new StartScreen(PLFResMgr::load_plf_from_filename(levelfile)),
      true);
-#endif 
 }
 
 void PingusMenu::do_edit()
 {      // Launch the level editor
   Sound::PingusSound::stop_music();
-  ////  ScreenManager::instance()->push_screen (new Editor::EditorScreen());
+  ScreenManager::instance()->push_screen (new Editor::EditorScreen());
 }
 
 void
@@ -267,5 +248,33 @@
   manager->pop_menu();
 }
 
+void
+PingusMenu::on_click(MenuButton* button)
+{
+  if (button == start_button)
+    {
+      setup_game_menu();
+    }
+  else if (button == quit_button)
+    {
+      do_quit();
+    }
+  else if (button == contrib_button)
+    {
+      setup_contrib_menu();
+    }
+  else if (button == story_button)
+    {
+      setup_worldmap_menu();
+    }
+  else if (button == multiplayer_button)
+    {
+      setup_main_menu();
+    }
+  else if (button == editor_button)
+    {
+      do_edit();
+    }
+}
 
 /* EOF */

Modified: branches/pingus_sdl/src/pingus_menu.hxx
===================================================================
--- branches/pingus_sdl/src/pingus_menu.hxx     2007-01-17 22:19:41 UTC (rev 
2684)
+++ branches/pingus_sdl/src/pingus_menu.hxx     2007-01-18 02:52:22 UTC (rev 
2685)
@@ -26,11 +26,6 @@
 #include "file_dialog_listener.hxx"
 #include "layer_manager.hxx"
 
-class CL_Key;
-class CL_InputDevice;
-class CL_Slot;
-
-
 class SurfaceButton;
 class GameDelta;
 class FileDialog;
@@ -46,8 +41,6 @@
 public:
   bool is_init;
 private:
-  ////std::vector<CL_Slot> slots;
-
   Sprite background;
   LayerManager layer_manager;
 
@@ -87,6 +80,8 @@
   PingusMenu (PingusMenuManager* m);
   ~PingusMenu();
 
+  void on_click(MenuButton* button);
+
   /// Load all images and other stuff for the menu
   void preload ();
   void do_contrib(const std::string&);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]