pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2925 - branches/pingus_sdl/src/worldmap


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2925 - branches/pingus_sdl/src/worldmap
Date: Wed, 15 Aug 2007 15:45:17 +0200

Author: grumbel
Date: 2007-08-15 15:45:16 +0200 (Wed, 15 Aug 2007)
New Revision: 2925

Modified:
   branches/pingus_sdl/src/worldmap/manager.cpp
   branches/pingus_sdl/src/worldmap/manager.hpp
   branches/pingus_sdl/src/worldmap/worldmap.cpp
   branches/pingus_sdl/src/worldmap/worldmap.hpp
Log:
- fixed issue with levelname not being displayed on larger resolutions

Modified: branches/pingus_sdl/src/worldmap/manager.cpp
===================================================================
--- branches/pingus_sdl/src/worldmap/manager.cpp        2007-08-15 13:31:01 UTC 
(rev 2924)
+++ branches/pingus_sdl/src/worldmap/manager.cpp        2007-08-15 13:45:16 UTC 
(rev 2925)
@@ -30,6 +30,7 @@
 #include "../display/scene_context.hpp"
 #include "../math.hpp"
 #include "worldmap.hpp"
+#include "resource.hpp"
 #include "worldmap_story.hpp"
 #include "pingus.hpp"
 #include "metamap.hpp"
@@ -214,9 +215,10 @@
 }
 
 WorldMapManager::WorldMapManager ()
-  : is_init(false),
-               exit_worldmap(false),
-               worldmap(0),
+  : levelname_bg(Resource::load_sprite("core/worldmap/levelname_bg")),
+    is_init(false),
+    exit_worldmap(false),
+    worldmap(0),
     new_worldmap(0)
     ////metamap(new MetaMap(path_manager.complete("metamap/metamap.xml")))
 {
@@ -357,6 +359,18 @@
 }
 
 void
+WorldMapManager::draw_foreground(DrawingContext& gc)
+{
+  // Draw the levelname
+  gc.draw(levelname_bg,
+          Vector3f(gc.get_width()/2 - levelname_bg.get_width()/2,
+                   gc.get_height() - levelname_bg.get_height()));
+
+  gc.print_center(Fonts::chalk_small, gc.get_width()/2, gc.get_height() - 20,
+                  worldmap->get_levelname());
+}
+
+void
 WorldMapComponent::on_primary_button_press (int x, int y)
 {
   WorldMap* worldmap = WorldMapManager::instance ()->worldmap;

Modified: branches/pingus_sdl/src/worldmap/manager.hpp
===================================================================
--- branches/pingus_sdl/src/worldmap/manager.hpp        2007-08-15 13:31:01 UTC 
(rev 2924)
+++ branches/pingus_sdl/src/worldmap/manager.hpp        2007-08-15 13:45:16 UTC 
(rev 2925)
@@ -66,6 +66,8 @@
 private:
   static WorldMapManager* instance_;
 
+  Sprite levelname_bg;
+
   bool is_init;
   bool exit_worldmap;
 
@@ -83,6 +85,7 @@
   /** Check if WorldMap manager still needs to run and exit if if
       not */
   void update (float);
+  void draw_foreground(DrawingContext& gc);
 
   /** @defgroup WorldMapManagerBindings Controller bindings of the 
WorldMapManager
       @{*/

Modified: branches/pingus_sdl/src/worldmap/worldmap.cpp
===================================================================
--- branches/pingus_sdl/src/worldmap/worldmap.cpp       2007-08-15 13:31:01 UTC 
(rev 2924)
+++ branches/pingus_sdl/src/worldmap/worldmap.cpp       2007-08-15 13:45:16 UTC 
(rev 2925)
@@ -64,7 +64,6 @@
   set_starting_node();
   add_drawable(pingus);
 
-  levelname_bg = Resource::load_sprite("core/worldmap/levelname_bg");
   gc_state.set_limit(Rect(Vector2i(0, 0), Size(width, height)));
 }
 
@@ -184,7 +183,7 @@
   
   
   for (DrawableLst::iterator i = drawables.begin (); i != drawables.end (); 
++i)
-      (*i)->draw(gc);
+    (*i)->draw(gc);
 
   Vector3f mpos = gc.screen_to_world(Vector3f((float)mouse_x, (float)mouse_y));
   Dot* dot = path_graph->get_dot(mpos.x, mpos.y);
@@ -192,38 +191,6 @@
     dot->draw_hover(gc);
   
   gc_state.pop(gc);
-
-  // Draw the levelname
-  // FIXME: Should be moved to a higher level
-  gc.draw(levelname_bg,
-          Vector3f(gc.get_width()/2 - levelname_bg.get_width()/2,
-                   gc.get_height() - levelname_bg.get_height()));
-
-  if (pingus->get_node() != NoNode)
-    {
-      LevelDot* leveldot = 
dynamic_cast<LevelDot*>(path_graph->get_dot(pingus->get_node()));
-
-      if (leveldot)
-        {
-          gc.print_center(Fonts::chalk_small, gc.get_width()/2, 
gc.get_height() - 20,
-                          _(leveldot->get_plf().get_levelname()));
-          
-        }
-      else
-        {
-          gc.print_center(Fonts::chalk_small,
-                          gc.get_width()/2,
-                          gc.get_height() - 20,
-                          "---");
-        }
-    }
-  else
-    {
-      gc.print_center(Fonts::chalk_small,
-                      gc.get_width()/2,
-                      gc.get_height() - 20,
-                      _("...walking..."));
-    }
 }
 
 void
@@ -441,6 +408,23 @@
   return false; 
////(WorldMapManager::instance()->get_metamap()->get_final_worldmap() == 
short_name);
 }
 
+std::string
+WorldMap::get_levelname()
+{
+  if (pingus->get_node() != NoNode)
+    {
+      LevelDot* leveldot = 
dynamic_cast<LevelDot*>(path_graph->get_dot(pingus->get_node()));
+      if (leveldot)
+        return _(leveldot->get_plf().get_levelname());
+      else 
+        return "---";
+    }
+  else
+    {
+      return _("...walking...");
+    }
+}
+
 } // namespace WorldMapNS
 
 /* EOF */

Modified: branches/pingus_sdl/src/worldmap/worldmap.hpp
===================================================================
--- branches/pingus_sdl/src/worldmap/worldmap.hpp       2007-08-15 13:31:01 UTC 
(rev 2924)
+++ branches/pingus_sdl/src/worldmap/worldmap.hpp       2007-08-15 13:45:16 UTC 
(rev 2925)
@@ -47,8 +47,6 @@
 class WorldMap
 {
 private:
-  Sprite levelname_bg;
-
   /** name of the file to parse */
   std::string filename;
 
@@ -112,6 +110,9 @@
   /** Enters the level on which the Pingu is currently standing */
   void enter_level();
 
+  /** Return the current levelname for use in GUI */
+  std::string get_levelname();
+
   /** The the pingu to the given Node */
   void set_pingus(NodeId id);
 





reply via email to

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