pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/worldmap graph.hxx,1.12,1.13 worldmap


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/worldmap graph.hxx,1.12,1.13 worldmap.cxx,1.14,1.15 worldmap.hxx,1.13,1.14
Date: 1 Oct 2002 19:53:48 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/worldmap
In directory dark:/tmp/cvs-serv24138/worldmap

Modified Files:
        graph.hxx worldmap.cxx worldmap.hxx 
Log Message:
- riped 'float delta' out of the engine code
- some worldmap stuff


Index: graph.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/graph.hxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- graph.hxx   28 Sep 2002 11:52:26 -0000      1.12
+++ graph.hxx   1 Oct 2002 19:53:45 -0000       1.13
@@ -26,27 +26,7 @@
 
 namespace WorldMapNS {
 
-#if 0
-/** This class manages the path of the WorldMap where the pingu can
-    walk on. */
-class Graph
-{
-public:
-  /** Load a graph from file */
-  Graph (const std::string& filename);
-  ~Graph ();
-    
-  /** Draw the graph to the given GC 
-      @param gc The GraphicContext to draw on */
-  void draw (GraphicContext& gc);
-    
-  /** @return a reference to the nodes of this graph */
-  const std::vector<>& get_nodes ();
-
-  /** @return a reference to the edges of this graph */
-  const std::vector<>& get_edges ();
-};
-#endif 
+//FIXME: #warring "Don't touch me, a rewritten version is somewhere around..."
 
 /** The path on the WorldMap is a bidirectional graph, this class
     managed it FIXME: needs a complete rewrite, EmptyNodes need to

Index: worldmap.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/worldmap.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- worldmap.cxx        28 Sep 2002 11:52:26 -0000      1.14
+++ worldmap.cxx        1 Oct 2002 19:53:45 -0000       1.15
@@ -33,6 +33,107 @@
 
 namespace WorldMapNS {
 
+#if TODO
+
+WorldMap::WorldMap(const std::string& filename) 
+{
+  doc = xmlParseFile(filename.c_str());
+  
+  if (!doc) 
+    {
+      PingusError::raise (_("WorldMap: File not found: ") + filename);
+    }    
+
+  xmlNodePtr cur = doc->ROOT;
+  cur = XMLhelper::skip_blank(cur);
+
+  parse_file(cur);
+}
+
+void 
+WorldMap::parse_file(xmlNodePtr cur)
+{
+  if (cur && XMLhelper::equal_str(cur->name, "pingus-worldmap"))
+    {
+      cur = cur->children;
+      cur = XMLhelper::skip_blank(cur);
+         
+      while (cur)
+       {
+         if (XMLhelper::equal_str(cur->name, "graph"))
+           {
+             parse_graph(cur);
+           }
+         else if (XMLhelper::equal_str(cur->name, "objects"))
+           {
+             parse_objects(cur);
+           }
+         else if (XMLhelper::equal_str(cur->name, "properties"))
+           {
+             parse_properties(cur);
+           }
+         else
+           {
+             perr(PINGUS_DEBUG_WORLDMAP) << "WorldMap: Unknown node name: " << 
cur->name << std::endl;
+           }
+
+         cur = cur->next;
+         cur = XMLhelper::skip_blank(cur);
+       }
+    }
+  else
+    {
+      PingusError::raise ("WorldMap:" + filename + ": not a Worldmap file");
+    }
+}
+
+void
+WorldMap::parse_objects(xmlNodePtr cur)
+{
+  cur = cur->children;
+  cur = XMLhelper::skip_blank(cur);
+
+
+}
+
+void
+WorldMap::parse_graph(xmlNodePtr cur)
+{
+  cur = cur->children;
+  cur = XMLhelper::skip_blank(cur);
+
+
+}
+
+void
+WorldMap::parse_properties(xmlNodePtr cur)
+{
+  cur = cur->children;
+  cur = XMLhelper::skip_blank(cur);
+
+  
+}
+
+void
+WorldMap::draw (GraphicContext& gc)
+{
+  for (iterator drawables.begin (); i != drawables.end (); ++i)
+    {
+      i->draw (gc);
+    }
+}
+
+void
+WorldMap::update (float delta)
+{
+  for (iterator drawables.begin (); i != drawables.end (); ++i)
+    {
+      i->update (delta);
+    }
+}
+
+#endif
+
 WorldMap::WorldMap (std::string filename) 
   : green_dot ("worldmap/dot_green", "core"),
     red_dot ("worldmap/dot_red", "core"),
@@ -190,17 +291,17 @@
 
 
   /** 
-    case CL_MOUSE_MIDDLEBUTTON:
-    {
-    if (maintainer_mode)
-    {
-    std::cout << "<position>" << std::endl;
-    std::cout << "  <x-pos>" << key.x - offset.x << "</x-pos>" << std::endl;
-    std::cout << "  <y-pos>" << key.y - offset.y << "</y-pos>" << std::endl;
-    std::cout << "</position>" << std::endl;
-    }
-    }
-    break;*/
+      case CL_MOUSE_MIDDLEBUTTON:
+      {
+      if (maintainer_mode)
+      {
+      std::cout << "<position>" << std::endl;
+      std::cout << "  <x-pos>" << key.x - offset.x << "</x-pos>" << std::endl;
+      std::cout << "  <y-pos>" << key.y - offset.y << "</y-pos>" << std::endl;
+      std::cout << "</position>" << std::endl;
+      }
+      }
+      break;*/
 }
  
 void

Index: worldmap.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/worldmap.hxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- worldmap.hxx        28 Sep 2002 11:52:26 -0000      1.13
+++ worldmap.hxx        1 Oct 2002 19:53:45 -0000       1.14
@@ -35,37 +35,39 @@
     worldmap is basically a multi-layered image and a path
     (bidirectional graph) where a pingu can walk on. Parts of the
     worldmap are hidable and will only get displayed at specific
-    events (successfull level completions). */
+    events (successfull level completions, etc.). */
 class WorldMap
 {
 #if TODO
-  WorldMap () {
-    load_graph ();
-    load_objects ();
-  }
+public:
+  /** Load the given*/
+  WorldMap (const std::string& filename);
   
-  void draw (GraphicContext& gc) 
-  {
-    for (iterator drawables.begin (); i != drawables.end (); ++i)
-      {
-       i->draw (gc);
-      }
-  }
-
+  void draw (GraphicContext& gc);
   void update (float delta)
-  {
-    for (iterator drawables.begin (); i != drawables.end (); ++i)
-      {
-       i->update (delta);
-      }
-  }
   
   /** @return the shortest path between node1 and node2  */
   std::vector<Edge*> find_path (Node* node1, Node* node2);
   
-  /** @return the node as the given position. x and y are in
+  /** @return the node at the given position. x and y are in
       world-COs, not screen. */
   Node* get_node (int x, int y);
+private:
+  /** Parses a WorldMap XML file */
+  void parse_file(xmlNodePtr cur);
+  
+  /** Parse the object section of the Worldmap XML file, it contains 
+      Sprites, Backgrounds and other things */
+  void parse_objects(xmlNodePtr cur);
+
+  /** Parse the graph section of the WorldMap XML file, it contains
+      the path where the Pingu can walk on. */
+  void parse_graph(xmlNodePtr cur);
+  
+  /** Parse the propertie section of a WorldMap XML file, it contains
+      meta data such as the author or the name of the Worldmap */
+  void parse_properties(xmlNodePtr cur);
+
 #endif
 private:
   CL_Surface background;





reply via email to

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