pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3667 - in trunk/pingus: . src src/worldmap


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3667 - in trunk/pingus: . src src/worldmap
Date: Fri, 4 Jul 2008 10:48:09 +0200

Author: grumbel
Date: 2008-07-04 10:48:07 +0200 (Fri, 04 Jul 2008)
New Revision: 3667

Added:
   trunk/pingus/src/worldmap/worldmap_component.cpp
   trunk/pingus/src/worldmap/worldmap_component.hpp
Modified:
   trunk/pingus/SConstruct
   trunk/pingus/src/pingus_main.cpp
   trunk/pingus/src/pingus_menu.cpp
   trunk/pingus/src/story_screen.cpp
   trunk/pingus/src/worldmap/manager.cpp
   trunk/pingus/src/worldmap/manager.hpp
   trunk/pingus/src/worldmap/surface_drawable.cpp
   trunk/pingus/src/worldmap/worldmap.hpp
   trunk/pingus/src/worldmap/worldmap_story.cpp
Log:
Splitting WorldMapComponent into seperate file and cleaning up the surrounding 
hierachy a bit

Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct     2008-07-04 07:12:43 UTC (rev 3666)
+++ trunk/pingus/SConstruct     2008-07-04 08:48:07 UTC (rev 3667)
@@ -259,6 +259,7 @@
 'src/worldmap/surface_drawable.cpp', 
 'src/worldmap/worldmap.cpp', 
 'src/worldmap/worldmap_story.cpp', 
+'src/worldmap/worldmap_component.cpp', 
 'src/worldobj.cpp', 
 'src/worldobj_factory.cpp', 
 'src/worldobjs/conveyor_belt.cpp', 

Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp    2008-07-04 07:12:43 UTC (rev 3666)
+++ trunk/pingus/src/pingus_main.cpp    2008-07-04 08:48:07 UTC (rev 3667)
@@ -807,8 +807,7 @@
   PingusMenuManager::init();
   Sound::PingusSound::init();
   PinguActionFactory::init();
-  WorldMapNS::WorldMapManager::instance();
-
+  
   fps_counter.init();
   console.init();
 }
@@ -824,7 +823,6 @@
   Sound::PingusSound::deinit();
   PingusMenuManager::deinit();
   WorldObjFactory::deinit();
-  WorldMapNS::WorldMapManager::deinit();
   ScreenManager::deinit();
   StatManager::deinit();
   SavegameManager::deinit();

Modified: trunk/pingus/src/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus_menu.cpp    2008-07-04 07:12:43 UTC (rev 3666)
+++ trunk/pingus/src/pingus_menu.cpp    2008-07-04 08:48:07 UTC (rev 3667)
@@ -97,17 +97,23 @@
 PingusMenu::do_start(const std::string &filename)
 { // Start the story or worldmap mode
   Sound::PingusSound::play_sound ("letsgo");
-  WorldMapNS::WorldMapManager::instance()->load(filename);
-  
+
+#if 0  // FIXME: Fri Jul  4 10:33:01 2008
   bool story_seen = false;
-  StatManager::instance()->get_bool(WorldMapNS::WorldMapManager::instance()->
-                                    get_worldmap()->get_shortname() + 
"-startstory-seen", story_seen);
+  StatManager::instance()->get_bool("tutorial-startstory-seen", story_seen); 
// FIXME: Hardcoding tutorial is evil
        
   if (!story_seen)
-    ScreenManager::instance()->push_screen
-      (new 
StoryScreen(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
 true);
+    {
+      ScreenManager::instance()->push_screen
+        (new 
StoryScreen(WorldMapNS::WorldMapScreen::instance()->get_worldmap()->get_intro_story()),
 true);
+    }
   else
-    
ScreenManager::instance()->push_screen(WorldMapNS::WorldMapManager::instance());
+#endif
+    {
+      std::auto_ptr<WorldMapScreen> worldmap_screen(new WorldMapScreen());
+      worldmap_screen->load(filename);
+      ScreenManager::instance()->push_screen(worldmap_screen.release(), true);
+    }
 }
 
 void PingusMenu::do_contrib(const std::string &levelfile)

Modified: trunk/pingus/src/story_screen.cpp
===================================================================
--- trunk/pingus/src/story_screen.cpp   2008-07-04 07:12:43 UTC (rev 3666)
+++ trunk/pingus/src/story_screen.cpp   2008-07-04 08:48:07 UTC (rev 3667)
@@ -189,7 +189,7 @@
 void
 StoryScreen::on_escape_press ()
 {
-  
ScreenManager::instance()->replace_screen(WorldMapNS::WorldMapManager::instance 
());
+  ScreenManager::instance()->replace_screen(new WorldMapScreen(), true);
 }
 
 void
@@ -228,33 +228,36 @@
         }
       else
         {
+          std::string which_story = "start";
+          
+#if 0 // FIXME: Fri Jul  4 10:34:19 2008
           //Out of story pages - figure out which one this was (start or end)
-          std::string which_story;
-          if (story == 
WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story())
+          if (story == 
WorldMapNS::WorldMapScreen::instance()->get_worldmap()->get_intro_story())
             which_story = "start";
           else
             which_story = "end";
 
           // Record that player has seen this story.
-          
StatManager::instance()->set_bool(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_shortname()
+          
StatManager::instance()->set_bool(WorldMapNS::WorldMapScreen::instance()->get_worldmap()->get_shortname()
                                             + "-" + which_story + 
"story-seen", true);
 
           bool credits_seen = false;
           //Check if this is the last worldmap
           if (which_story == "end" &&
-              
WorldMapNS::WorldMapManager::instance()->get_worldmap()->is_final_map())
+              
WorldMapNS::WorldMapScreen::instance()->get_worldmap()->is_final_map())
             {
               // Check if final credits have been seen
               StatManager::instance()->get_bool("credits-seen", credits_seen);
               if (!credits_seen)
                 ScreenManager::instance()->replace_screen(new Credits(), true);
               else
-                
ScreenManager::instance()->replace_screen(WorldMapNS::WorldMapManager::instance());
+                ScreenManager::instance()->replace_screen(new 
WorldMapNS::WorldMapScreen(), true);
             }
           else
             {
-              
ScreenManager::instance()->replace_screen(WorldMapNS::WorldMapManager::instance());
+              ScreenManager::instance()->replace_screen(new 
WorldMapNS::WorldMapScreen()), true);
             }
+#endif
         }
     }
 }

Modified: trunk/pingus/src/worldmap/manager.cpp
===================================================================
--- trunk/pingus/src/worldmap/manager.cpp       2008-07-04 07:12:43 UTC (rev 
3666)
+++ trunk/pingus/src/worldmap/manager.cpp       2008-07-04 08:48:07 UTC (rev 
3667)
@@ -27,170 +27,175 @@
 #include "../display/scene_context.hpp"
 #include "../math.hpp"
 #include "worldmap.hpp"
+#include "worldmap_component.hpp"
 #include "resource.hpp"
 #include "worldmap_story.hpp"
 #include "pingus.hpp"
 #include "manager.hpp"
 #include "../story_screen.hpp"
 
-namespace WorldMapNS {
-
-WorldMapManager* WorldMapManager::instance_ = 0;
-
-class WorldMapManagerCloseButton
+WorldMapScreen* WorldMapScreen::instance_ = 0;
+
+class WorldMapScreenCloseButton
   : public GUI::SurfaceButton
 {
+private: 
+  WorldMapScreen* worldmap_screen;
 public:
-  WorldMapManagerCloseButton();
+  WorldMapScreenCloseButton(WorldMapScreen* worldmap_screen);
   void on_click();
   void draw (DrawingContext& gc);
   void on_pointer_enter();
 };
-
-class WorldMapManagerStoryButton
+
+class WorldMapScreenStoryButton
   : public GUI::SurfaceButton
 {
+private:
+  WorldMapScreen* worldmap_screen;
 public:
-  WorldMapManagerStoryButton();
+  WorldMapScreenStoryButton(WorldMapScreen* worldmap_screen);
   void on_click();
   void draw (DrawingContext& gc);
   void on_pointer_enter();
 };
-
-
-class WorldMapManagerCreditsButton
+
+class WorldMapScreenCreditsButton
   : public GUI::SurfaceButton
 {
+private:
+  WorldMapScreen* worldmap_screen;
 public:
-  WorldMapManagerCreditsButton();
+  WorldMapScreenCreditsButton(WorldMapScreen* worldmap_screen);
   void on_click();
   void draw (DrawingContext& gc);
   void on_pointer_enter();
 };
-
-class WorldMapManagerEnterButton
+
+class WorldMapScreenEnterButton
   : public GUI::SurfaceButton
 {
+private:
+  WorldMapScreen* worldmap_screen;
 public:
-  WorldMapManagerEnterButton();
+  WorldMapScreenEnterButton(WorldMapScreen* worldmap_screen);
   void on_click();
   void draw (DrawingContext& gc);
   void on_pointer_enter();
 };
-
-
-WorldMapManagerCreditsButton::WorldMapManagerCreditsButton()
+
+WorldMapScreenCreditsButton::WorldMapScreenCreditsButton(WorldMapScreen* 
worldmap_screen)
   : GUI::SurfaceButton(Display::get_width() - 150, 0,
                        ResDescriptor("core/worldmap/credits_button_normal"),
                        ResDescriptor("core/worldmap/credits_button_pressed"),
-                       ResDescriptor("core/worldmap/credits_button_hover"))
+                       ResDescriptor("core/worldmap/credits_button_hover")),
+    worldmap_screen(worldmap_screen)
 {
 }
 
 void
-WorldMapManagerCreditsButton::on_pointer_enter()
+WorldMapScreenCreditsButton::on_pointer_enter()
 {
   SurfaceButton::on_pointer_enter();
   Sound::PingusSound::play_sound ("tick");
 }
 
-
-
 void
-WorldMapManagerCreditsButton::draw (DrawingContext& gc)
+WorldMapScreenCreditsButton::draw (DrawingContext& gc)
 {
   SurfaceButton::draw(gc);
   gc.print_center(Fonts::chalk_small, Display::get_width() - 59 - 24, 2, 
_("Show Ending?"));
 }
 
 void
-WorldMapManagerCreditsButton::on_click()
+WorldMapScreenCreditsButton::on_click()
 {
   ScreenManager::instance()->replace_screen
-    (new 
StoryScreen(WorldMapManager::instance()->get_worldmap()->get_end_story()), 
true);
+    (new StoryScreen(worldmap_screen->get_worldmap()->get_end_story()), true);
 }
 
-WorldMapManagerStoryButton::WorldMapManagerStoryButton()
+WorldMapScreenStoryButton::WorldMapScreenStoryButton(WorldMapScreen* 
worldmap_screen)
   : GUI::SurfaceButton(0, 0,
                        ResDescriptor("core/worldmap/story_button_normal"),
                        ResDescriptor("core/worldmap/story_button_pressed"),
-                       ResDescriptor("core/worldmap/story_button_hover"))
+                       ResDescriptor("core/worldmap/story_button_hover")),
+    worldmap_screen(worldmap_screen)
 {
 }
 
 void
-WorldMapManagerStoryButton::on_pointer_enter()
+WorldMapScreenStoryButton::on_pointer_enter()
 {
   SurfaceButton::on_pointer_enter();
   Sound::PingusSound::play_sound ("tick");
 }
 
-
-
 void
-WorldMapManagerStoryButton::draw (DrawingContext& gc)
+WorldMapScreenStoryButton::draw (DrawingContext& gc)
 {
   SurfaceButton::draw(gc);
   gc.print_center(Fonts::chalk_small, 59, 2, _("Show Story?"));
 }
 
 void
-WorldMapManagerStoryButton::on_click()
+WorldMapScreenStoryButton::on_click()
 {
   ScreenManager::instance()->replace_screen
-    (new 
StoryScreen(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
 true);
+    (new StoryScreen(worldmap_screen->get_worldmap()->get_intro_story()), 
true);
 }
-
-WorldMapManagerCloseButton::WorldMapManagerCloseButton()
+
+WorldMapScreenCloseButton::WorldMapScreenCloseButton(WorldMapScreen* 
worldmap_screen)
   : GUI::SurfaceButton(0, Display::get_height() - 37,
                        ResDescriptor("core/worldmap/leave_button_normal"),
                        ResDescriptor("core/worldmap/leave_button_pressed"),
-                       ResDescriptor("core/worldmap/leave_button_hover"))
+                       ResDescriptor("core/worldmap/leave_button_hover")),
+    worldmap_screen(worldmap_screen)
 {
 }
 
 void
-WorldMapManagerCloseButton::on_pointer_enter()
+WorldMapScreenCloseButton::on_pointer_enter()
 {
   SurfaceButton::on_pointer_enter();
   Sound::PingusSound::play_sound ("tick");
 }
 
 void
-WorldMapManagerCloseButton::draw (DrawingContext& gc)
+WorldMapScreenCloseButton::draw (DrawingContext& gc)
 {
   SurfaceButton::draw(gc);
   gc.print_center(Fonts::chalk_small, 44, Display::get_height() - 25, 
_("Leave?"));
 }
 
 void
-WorldMapManagerCloseButton::on_click()
+WorldMapScreenCloseButton::on_click()
 {
   ScreenManager::instance ()->pop_screen ();
 }
 
-WorldMapManagerEnterButton::WorldMapManagerEnterButton()
+WorldMapScreenEnterButton::WorldMapScreenEnterButton(WorldMapScreen* 
worldmap_screen)
   : GUI::SurfaceButton(Display::get_width() - 119, Display::get_height() - 37,
                        ResDescriptor("core/worldmap/enter_button_normal"),
                        ResDescriptor("core/worldmap/enter_button_pressed"),
-                       ResDescriptor("core/worldmap/enter_button_hover"))
+                       ResDescriptor("core/worldmap/enter_button_hover")),
+    worldmap_screen(worldmap_screen)
 {
 }
 
 void
-WorldMapManagerEnterButton::on_pointer_enter()
+WorldMapScreenEnterButton::on_pointer_enter()
 {
   SurfaceButton::on_pointer_enter();
-  if (!WorldMapManager::instance()->get_worldmap()->get_pingus()->is_walking())
+  if (!worldmap_screen->get_worldmap()->get_pingus()->is_walking())
     {
       Sound::PingusSound::play_sound ("tick");
     }
 }
 
 void
-WorldMapManagerEnterButton::draw (DrawingContext& gc)
+WorldMapScreenEnterButton::draw (DrawingContext& gc)
 {
-  if (WorldMapManager::instance()->get_worldmap()->get_pingus()->is_walking())
+  if (worldmap_screen->get_worldmap()->get_pingus()->is_walking())
     {
       gc.draw(button_surface, Vector2i(x_pos, y_pos));
     }
@@ -205,12 +210,12 @@
 }
 
 void
-WorldMapManagerEnterButton::on_click()
+WorldMapScreenEnterButton::on_click()
 {
-  WorldMapManager::instance()->get_worldmap()->enter_level();
+  worldmap_screen->get_worldmap()->enter_level();
 }
 
-WorldMapManager::WorldMapManager ()
+WorldMapScreen::WorldMapScreen ()
   : levelname_bg(Sprite("core/worldmap/levelname_bg")),
     is_init(false),
     exit_worldmap(false),
@@ -220,16 +225,15 @@
   // FIXME: a bit ugly because of the proteced member, but should work
   // FIXME: well enough. GUIScreen could also use multi-inheritage,
   // FIXME: but that could lead to member function name conflicts
-  worldmap_component = new WorldMapComponent();
+  worldmap_component = new WorldMapComponent(this);
   gui_manager->add (worldmap_component, true);
-  gui_manager->add(new WorldMapManagerCloseButton(), true);
-  gui_manager->add(new WorldMapManagerEnterButton(), true);
-
-  gui_manager->add(new WorldMapManagerStoryButton(), true);
+  gui_manager->add(new WorldMapScreenCloseButton(this), true);
+  gui_manager->add(new WorldMapScreenEnterButton(this), true);
+  gui_manager->add(new WorldMapScreenStoryButton(this), true);
 }
 
 void
-WorldMapManager::load (const std::string& filename)
+WorldMapScreen::load (const std::string& filename)
 {
   if (worldmap)
     delete worldmap;
@@ -241,12 +245,12 @@
                                     credits_unlocked);
   if (credits_unlocked)
     {
-      gui_manager->add(new WorldMapManagerCreditsButton(), true);
+      gui_manager->add(new WorldMapScreenCreditsButton(this), true);
     }
 }
 
 void
-WorldMapManager::on_startup ()
+WorldMapScreen::on_startup ()
 {
   exit_worldmap = false;
   Sound::PingusSound::stop_music();
@@ -255,21 +259,21 @@
     worldmap->on_startup ();
 }
 
-WorldMapManager::~WorldMapManager ()
+WorldMapScreen::~WorldMapScreen ()
 {
   delete worldmap;
   delete new_worldmap;
 }
 
 void
-WorldMapManager::on_escape_press ()
+WorldMapScreen::on_escape_press ()
 {
-  //std::cout << "WorldMapManager::on_escape_press ()..." << std::endl;
+  //std::cout << "WorldMapScreen::on_escape_press ()..." << std::endl;
   exit_worldmap = true;
 }
 
 void
-WorldMapManager::update (float delta)
+WorldMapScreen::update (float delta)
 {
   GUIScreen::update(delta);
 
@@ -286,64 +290,9 @@
     }
 }
 
-WorldMapComponent::WorldMapComponent()
-{
-  scene_context = new SceneContext();
-}
-
-WorldMapComponent::~WorldMapComponent()
-{
-  delete scene_context;
-}
-
 void
-WorldMapComponent::draw (DrawingContext& gc)
+WorldMapScreen::draw_foreground(DrawingContext& gc)
 {
-  WorldMap* worldmap = WorldMapManager::instance()->worldmap;
-
-  Rect cliprect = WorldMapManager::instance()->get_trans_rect();
-
-  scene_context->clear();
-  scene_context->push_modelview();
-  scene_context->translate((float)cliprect.left, (float)cliprect.top);
-
-  scene_context->set_cliprect(cliprect);
-
-  //scene_context->color().draw_fillrect(-100, -100, 2000, 2000, 
Color(255,0,0,0), -10000);
-  worldmap->draw(scene_context->color());
-
-  gc.draw(new SceneContextDrawingRequest(scene_context, Vector3f(0,0,-1000)));
-
-  scene_context->pop_modelview();
-
-  // Draw border
-  if (cliprect != Rect(Vector2i(0,0), Size(Display::get_width(), 
Display::get_height())))
-    {
-      Color border_color(50, 65, 75);
-      // top
-      gc.draw_fillrect(0, 0, Display::get_width(), cliprect.top,
-                       border_color);
-      // bottom
-      gc.draw_fillrect(0, cliprect.bottom, Display::get_width(), 
Display::get_height(),
-                       border_color);
-      // left
-      gc.draw_fillrect(0, cliprect.top, cliprect.left, cliprect.bottom,
-                       border_color);
-      // right
-      gc.draw_fillrect(cliprect.right, cliprect.top, Display::get_width(), 
cliprect.bottom,
-                       border_color);
-    }
-}
-
-void
-WorldMapComponent::update (float delta)
-{
-  WorldMapManager::instance()->worldmap->update(delta);
-}
-
-void
-WorldMapManager::draw_foreground(DrawingContext& gc)
-{
   // Draw the levelname
   gc.draw(levelname_bg,
           Vector2i(gc.get_width()/2 - levelname_bg.get_width()/2,
@@ -354,62 +303,20 @@
 }
 
 void
-WorldMapComponent::on_primary_button_press (int x, int y)
+WorldMapScreen::change_map (const std::string& filename, NodeId node)
 {
-  Rect cliprect = WorldMapManager::instance()->get_trans_rect();
-  WorldMapManager::instance ()->worldmap->on_primary_button_press(x - 
cliprect.left,
-                                                                  y - 
cliprect.top);
-}
-
-
-void
-WorldMapComponent::on_pointer_move (int x, int y)
-{
-  Rect cliprect = WorldMapManager::instance()->get_trans_rect();
-  WorldMapManager::instance ()->worldmap->on_pointer_move(x - cliprect.left,
-                                                          y - cliprect.top);
-}
-
-void
-WorldMapComponent::on_secondary_button_press (int x, int y)
-{
-  Rect cliprect = WorldMapManager::instance()->get_trans_rect();
-  WorldMapManager::instance ()->worldmap->on_secondary_button_press(x - 
cliprect.left,
-                                                                    y - 
cliprect.top);
-}
-
-void
-WorldMapManager::change_map (const std::string& filename, NodeId node)
-{
   // Create the new worldmap and make it the current one
   new_worldmap = new WorldMap (path_manager.complete("worldmaps/" + filename));
   new_worldmap->set_pingus (node);
 }
 
-WorldMapManager*
-WorldMapManager::instance ()
-{
-  if (instance_)
-    return instance_;
-  else
-    return instance_ = new WorldMapManager ();
-}
-
-void WorldMapManager::deinit()
-{
-  delete instance_;
-  instance_ = 0;
-}
-
 Rect
-WorldMapManager::get_trans_rect() const
+WorldMapScreen::get_trans_rect() const
 {
   return Rect(Vector2i(Math::max((Display::get_width()  - 
worldmap->get_width())/2,  0),
                        Math::max((Display::get_height() - 
worldmap->get_height())/2, 0)), 
               Size(Math::min(Display::get_width(),  worldmap->get_width()),
                    Math::min(Display::get_height(), worldmap->get_height())));
 }
-
-} // namespace WorldMapNS
-
+
 /* EOF */

Modified: trunk/pingus/src/worldmap/manager.hpp
===================================================================
--- trunk/pingus/src/worldmap/manager.hpp       2008-07-04 07:12:43 UTC (rev 
3666)
+++ trunk/pingus/src/worldmap/manager.hpp       2008-07-04 08:48:07 UTC (rev 
3667)
@@ -18,6 +18,7 @@
 #define HEADER_PINGUS_WORLDMAP_MANAGER_HPP
 
 #include <string>
+#include "../sprite.hpp"
 #include "../gui/gui_manager.hpp"
 #include "../screen/gui_screen.hpp"
 
@@ -27,41 +28,18 @@
 
 typedef int NodeId;
 class WorldMap;
-
-class WorldMapComponent : public GUI::Component
-{
-private:
-  SceneContext* scene_context;
-
-public:
-  WorldMapComponent();
-  ~WorldMapComponent();
-
-  void on_primary_button_press (int x, int y);
-  void on_secondary_button_press (int x, int y);
-  void on_pointer_move(int x, int y);
-
-  void draw (DrawingContext& gc);
-  void update (float delta);
-
-  bool is_at (int, int) { return true; }
-
-private:
-  WorldMapComponent (const WorldMapComponent&);
-  WorldMapComponent& operator= (const WorldMapComponent&);
-
-};
-
-/** The WorldMapManager manages the worldmaps and the translation
+class WorldMapComponent;
+
+/** The WorldMapScreen manages the worldmaps and the translation
     between two worldmaps, it also holds the GUI elements that are
     accessible in the WorldMap Screen */
-class WorldMapManager : public GUIScreen
+class WorldMapScreen : public GUIScreen
 {
   WorldMapComponent* worldmap_component;
 
   friend class WorldMapComponent;
 private:
-  static WorldMapManager* instance_;
+  static WorldMapScreen* instance_;
 
   Sprite levelname_bg;
 
@@ -71,9 +49,9 @@
   WorldMap* worldmap;
   WorldMap* new_worldmap;
 
-  WorldMapManager ();
 public:
-  ~WorldMapManager ();
+  WorldMapScreen ();
+  ~WorldMapScreen ();
 
   void load (const std::string& filename);
 
@@ -82,14 +60,14 @@
   void update (float);
   void draw_foreground(DrawingContext& gc);
 
-  /** @defgroup WorldMapManagerBindings Controller bindings of the 
WorldMapManager
+  /** @defgroup WorldMapScreenBindings Controller bindings of the 
WorldMapScreen
       @{*/
   /** Calculate the node that was clicked and set the pingu to walk
       to that node. If a node is double-cliked, the pingu should go
       faster. */
   void on_primary_button_press (int x, int y);
 
-  /** Exit the WorldMapManager and return to the previous screen */
+  /** Exit the WorldMapScreen and return to the previous screen */
   void on_escape_press ();
   /** @}*/
 
@@ -104,18 +82,14 @@
 
   Rect get_trans_rect() const;
 
-  /** Singleton access function */
-  static WorldMapManager* instance ();
-  static void deinit();
-
 private:
   /** Startup Hook of the Screen */
   void on_startup ();
 
-  WorldMapManager (const WorldMapManager&);
-  WorldMapManager& operator= (const WorldMapManager&);
+  WorldMapScreen (const WorldMapScreen&);
+  WorldMapScreen& operator= (const WorldMapScreen&);
 };
-
+
 } // namespace WorldMapNS
 
 #endif

Modified: trunk/pingus/src/worldmap/surface_drawable.cpp
===================================================================
--- trunk/pingus/src/worldmap/surface_drawable.cpp      2008-07-04 07:12:43 UTC 
(rev 3666)
+++ trunk/pingus/src/worldmap/surface_drawable.cpp      2008-07-04 08:48:07 UTC 
(rev 3667)
@@ -52,7 +52,8 @@
     {
       if (auto_uncover)
         {
-          Vector3f pingus_pos = 
WorldMapManager::instance()->get_worldmap()->get_pingus()->get_pos();
+#if 0 // FIXME: Fri Jul  4 10:42:06 2008
+          Vector3f pingus_pos = 
WorldMapScreen::instance()->get_worldmap()->get_pingus()->get_pos();
           // Pingu is not over the surface
           if (!(pingus_pos.x > pos.x && pingus_pos.x < pos.x + 
surface.get_width()
                 &&
@@ -64,6 +65,7 @@
             { // FIXME: Hack for the 0.6.0 release/tutorial world remove later
               gc.draw(surface, pos);
             }
+#endif
         }
       else
         {

Modified: trunk/pingus/src/worldmap/worldmap.hpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap.hpp      2008-07-04 07:12:43 UTC (rev 
3666)
+++ trunk/pingus/src/worldmap/worldmap.hpp      2008-07-04 08:48:07 UTC (rev 
3667)
@@ -35,7 +35,7 @@
 class PathGraph;
 class Drawable;
 class Pingus;
-
+
 /** A class for loading, displaying and managing the worldmap. The
     worldmap is basically a multi-layered image and a path
     (bidirectional graph) where a pingu can walk on. Parts of the
@@ -151,7 +151,7 @@
       or use the "default-node" option from the XML file */
   void set_starting_node();
 };
-
+
 } // namespace WorldMapNS
 
 #endif

Added: trunk/pingus/src/worldmap/worldmap_component.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_component.cpp    2008-07-04 07:12:43 UTC 
(rev 3666)
+++ trunk/pingus/src/worldmap/worldmap_component.cpp    2008-07-04 08:48:07 UTC 
(rev 3667)
@@ -0,0 +1,109 @@
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2008 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//  
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#include "../display/display.hpp"
+#include "../display/scene_context.hpp"
+#include "manager.hpp"
+#include "worldmap.hpp"
+#include "worldmap_component.hpp"
+
+namespace WorldMapNS {
+
+WorldMapComponent::WorldMapComponent(WorldMapScreen* worldmap_screen)
+  : worldmap_screen(worldmap_screen)
+{
+  scene_context = new SceneContext();
+}
+
+WorldMapComponent::~WorldMapComponent()
+{
+  delete scene_context;
+}
+
+void
+WorldMapComponent::draw (DrawingContext& gc)
+{
+  WorldMap* worldmap = worldmap_screen->worldmap;
+
+  Rect cliprect = worldmap_screen->get_trans_rect();
+
+  scene_context->clear();
+  scene_context->push_modelview();
+  scene_context->translate((float)cliprect.left, (float)cliprect.top);
+
+  scene_context->set_cliprect(cliprect);
+
+  //scene_context->color().draw_fillrect(-100, -100, 2000, 2000, 
Color(255,0,0,0), -10000);
+  worldmap->draw(scene_context->color());
+
+  gc.draw(new SceneContextDrawingRequest(scene_context, Vector3f(0,0,-1000)));
+
+  scene_context->pop_modelview();
+
+  // Draw border
+  if (cliprect != Rect(Vector2i(0,0), Size(Display::get_width(), 
Display::get_height())))
+    {
+      Color border_color(50, 65, 75);
+      // top
+      gc.draw_fillrect(0, 0, Display::get_width(), cliprect.top,
+                       border_color);
+      // bottom
+      gc.draw_fillrect(0, cliprect.bottom, Display::get_width(), 
Display::get_height(),
+                       border_color);
+      // left
+      gc.draw_fillrect(0, cliprect.top, cliprect.left, cliprect.bottom,
+                       border_color);
+      // right
+      gc.draw_fillrect(cliprect.right, cliprect.top, Display::get_width(), 
cliprect.bottom,
+                       border_color);
+    }
+}
+
+void
+WorldMapComponent::update (float delta)
+{
+  worldmap_screen->worldmap->update(delta);
+}
+
+
+void
+WorldMapComponent::on_primary_button_press (int x, int y)
+{
+  Rect cliprect = worldmap_screen->get_trans_rect();
+  worldmap_screen->worldmap->on_primary_button_press(x - cliprect.left,
+                                                     y - cliprect.top);
+}
+
+
+void
+WorldMapComponent::on_pointer_move (int x, int y)
+{
+  Rect cliprect = worldmap_screen->get_trans_rect();
+  worldmap_screen->worldmap->on_pointer_move(x - cliprect.left,
+                                             y - cliprect.top);
+}
+
+void
+WorldMapComponent::on_secondary_button_press (int x, int y)
+{
+  Rect cliprect = worldmap_screen->get_trans_rect();
+  worldmap_screen->worldmap->on_secondary_button_press(x - cliprect.left,
+                                                       y - cliprect.top);
+}
+
+} // namespace WorldMapNS
+
+/* EOF */


Property changes on: trunk/pingus/src/worldmap/worldmap_component.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/pingus/src/worldmap/worldmap_component.hpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_component.hpp    2008-07-04 07:12:43 UTC 
(rev 3666)
+++ trunk/pingus/src/worldmap/worldmap_component.hpp    2008-07-04 08:48:07 UTC 
(rev 3667)
@@ -0,0 +1,58 @@
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2008 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//  
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_WORLDMAP_COMPONENT_HPP
+#define HEADER_WORLDMAP_COMPONENT_HPP
+
+#include <string>
+#include "../gui/gui_manager.hpp"
+
+class SceneContext;
+
+namespace WorldMapNS {
+
+class WorldMapScreen;
+class WorldMap;
+
+class WorldMapComponent : public GUI::Component
+{
+private:
+  SceneContext*   scene_context;
+  WorldMapScreen* worldmap_screen;
+  
+public:
+  WorldMapComponent(WorldMapScreen* worldmap_screen);
+  ~WorldMapComponent();
+
+  void on_primary_button_press (int x, int y);
+  void on_secondary_button_press (int x, int y);
+  void on_pointer_move(int x, int y);
+
+  void draw (DrawingContext& gc);
+  void update (float delta);
+
+  bool is_at (int, int) { return true; }
+
+private:
+  WorldMapComponent (const WorldMapComponent&);
+  WorldMapComponent& operator= (const WorldMapComponent&);
+};
+
+} // namespace WorldMapNS
+
+#endif
+
+/* EOF */


Property changes on: trunk/pingus/src/worldmap/worldmap_component.hpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/pingus/src/worldmap/worldmap_story.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_story.cpp        2008-07-04 07:12:43 UTC 
(rev 3666)
+++ trunk/pingus/src/worldmap/worldmap_story.cpp        2008-07-04 08:48:07 UTC 
(rev 3667)
@@ -24,9 +24,7 @@
 #include "../string_format.hpp"
 #include "../fonts.hpp"
 #include "../gettext.h"
-
-namespace WorldMapNS {
-
+
 WorldMapStory::WorldMapStory(const FileReader &reader)
 {
   reader.read_string("title", title);
@@ -56,7 +54,5 @@
   if (pages.empty())
     PingusError::raise("WorldMapStory: WorldMap does not include a valid 
story");
 }
-
-}      // namespace WorldMapNS
-
+
 /* EOF */





reply via email to

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