pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2669 - branches/pingus_sdl/src


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2669 - branches/pingus_sdl/src
Date: Tue, 16 Jan 2007 07:56:06 +0100

Author: grumbel
Date: 2007-01-16 07:56:05 +0100 (Tue, 16 Jan 2007)
New Revision: 2669

Modified:
   branches/pingus_sdl/src/game_session.cxx
   branches/pingus_sdl/src/pingus_level.cxx
   branches/pingus_sdl/src/pingus_level.hxx
   branches/pingus_sdl/src/pingus_main.cxx
   branches/pingus_sdl/src/plf_res_mgr.cxx
   branches/pingus_sdl/src/resource_manager.cpp
   branches/pingus_sdl/src/world.cxx
Log:
- some level parsing code

Modified: branches/pingus_sdl/src/game_session.cxx
===================================================================
--- branches/pingus_sdl/src/game_session.cxx    2007-01-16 06:13:55 UTC (rev 
2668)
+++ branches/pingus_sdl/src/game_session.cxx    2007-01-16 06:56:05 UTC (rev 
2669)
@@ -31,7 +31,6 @@
 #include "savegame_manager.hxx"
 #include "globals.hxx"
 
-
 PingusGameSession::PingusGameSession (const PingusLevel& arg_plf, bool 
arg_show_result_screen)
   : plf(arg_plf),
     show_result_screen(arg_show_result_screen)
@@ -52,6 +51,7 @@
   number_of_updates = 0;
 
   left_over_time = 0;
+  std::cout << "PingusGameSession" << std::endl;
 }
 
 PingusGameSession::~PingusGameSession ()

Modified: branches/pingus_sdl/src/pingus_level.cxx
===================================================================
--- branches/pingus_sdl/src/pingus_level.cxx    2007-01-16 06:13:55 UTC (rev 
2668)
+++ branches/pingus_sdl/src/pingus_level.cxx    2007-01-16 06:56:05 UTC (rev 
2669)
@@ -17,14 +17,74 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <iostream>
 #include "file_reader.hxx"
 #include "pingus_level.hxx"
+#include "pingus_error.hxx"
 #include "pingus_level_impl.hxx"
 
+PingusLevel::PingusLevel()
+  : impl(new PingusLevelImpl())  
+{
+}
 
-PingusLevel::PingusLevel()
+
+PingusLevel::PingusLevel(const std::string& resname,
+                         const std::string& filename)
   : impl(new PingusLevelImpl())
 {
+  impl->resname = resname;
+  FileReader reader = FileReader::parse(filename);
+
+  if (reader.get_name() != "pingus-level")
+    {
+      PingusError::raise("Error: " + filename + ": not a 'pingus-level' file");
+    }
+  else
+    {
+      int version;
+      if (reader.read_int("version", version))
+        std::cout << "Levelfile Version: " << version << std::endl;
+      else
+        std::cout << "Unknown Levelfile Version: " << version << std::endl;
+
+      FileReader head;
+      if (reader.read_section("head", head))
+        {
+          head.read_string("levelname",        impl->levelname);
+          head.read_string("description",      impl->description);
+          head.read_size  ("levelsize",        impl->size);
+          head.read_string("music",            impl->music);
+          head.read_int   ("time",             impl->time);
+          head.read_int   ("difficulty",       impl->difficulty);
+          head.read_int   ("number-of-pingus", impl->number_of_pingus);
+          head.read_int   ("number-to-save",   impl->number_to_save);
+          head.read_color ("ambient-light",    impl->ambient_light);
+          head.read_string("author",           impl->author);
+          
+          FileReader actions;
+          if (reader.read_section("actions", actions))
+            {
+              std::vector<std::string> lst = reader.get_section_names();
+              for(std::vector<std::string>::iterator i = lst.begin(); i != 
lst.end(); ++i)
+                {
+                  int count = 0;
+                  if (actions.read_int(i->c_str(), count))
+                    impl->actions[*i] = count;
+                }
+            }
+        }
+      
+      FileReader objects;
+      if (reader.read_section("objects", objects))
+        {
+          std::vector<FileReader> object_lst = reader.get_sections();
+          for(std::vector<FileReader>::iterator i = object_lst.begin(); i != 
object_lst.end(); ++i)
+            {
+              impl->objects.push_back(*i);
+            }
+        }
+    }
 }
 
 const std::string&

Modified: branches/pingus_sdl/src/pingus_level.hxx
===================================================================
--- branches/pingus_sdl/src/pingus_level.hxx    2007-01-16 06:13:55 UTC (rev 
2668)
+++ branches/pingus_sdl/src/pingus_level.hxx    2007-01-16 06:56:05 UTC (rev 
2669)
@@ -37,6 +37,9 @@
 public:
   PingusLevel();
 
+  PingusLevel(const std::string& resname,
+              const std::string& filename);
+
   /** Returns the name of the current level, {\em not} the level file name. */
   const std::string& get_levelname() const;
 

Modified: branches/pingus_sdl/src/pingus_main.cxx
===================================================================
--- branches/pingus_sdl/src/pingus_main.cxx     2007-01-16 06:13:55 UTC (rev 
2668)
+++ branches/pingus_sdl/src/pingus_main.cxx     2007-01-16 06:56:05 UTC (rev 
2669)
@@ -60,8 +60,8 @@
 #include "console.hxx"
 // #include "fps_counter.hxx"
 #include "plf_res_mgr.hxx"
-// #include "game_session.hxx"
-// #include "story_screen.hxx"
+#include "game_session.hxx"
+#include "story_screen.hxx"
 
 #include "start_screen.hxx"
 // #include "savegame_manager.hxx"
@@ -736,9 +736,12 @@
 
       if (successfull)
         {
+          ////ScreenManager::instance()->push_screen
+          ////(new StartScreen(PLFResMgr::load_plf_from_filename(levelfile)),
+          ////true);
           ScreenManager::instance()->push_screen
-            (new StartScreen(PLFResMgr::load_plf_from_filename(levelfile)),
-             true);
+            (new 
PingusGameSession(PLFResMgr::load_plf_from_filename(levelfile), false),
+           true);
         }
     }
   else if (!demo_file.empty()) // start a demo
@@ -758,7 +761,7 @@
     {
       std::cout << "starting normal game" << std::endl;
       ScreenManager::instance()->push_screen(PingusMenuManager::instance (), 
false);
-      ////ScreenManager::instance()->push_screen(new StoryScreen(), true);
+      ///ScreenManager::instance()->push_screen(new StoryScreen(), true);
       //ScreenManager::instance()->push_screen(new DummyScreen(), true);
       std::cout << "done: starting normal game" << std::endl;
     }

Modified: branches/pingus_sdl/src/plf_res_mgr.cxx
===================================================================
--- branches/pingus_sdl/src/plf_res_mgr.cxx     2007-01-16 06:13:55 UTC (rev 
2668)
+++ branches/pingus_sdl/src/plf_res_mgr.cxx     2007-01-16 06:56:05 UTC (rev 
2669)
@@ -31,17 +31,16 @@
 PLFResMgr::load_plf_raw(const std::string& res_name,
                         const std::string& filename)
 {
-  //std::cout << "PLFResMgr: " << res_name << "\n   " << filename << std::endl;
+  std::cout << "PLFResMgr: '" << res_name << "'  -> '" << filename << "'" << 
std::endl;
 
   PLFMap::iterator i = plf_map.find(res_name);
 
   if (i == plf_map.end())
     { // Entry not cached, so load it and add it to cache
       pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: Loading level from DISK: '" << 
res_name << "' -> '" << filename << "'" << std::endl;
-#if 0
-      PingusLevel plf = XMLPingusLevel(res_name, filename);
-#endif
 
+      //PingusLevel plf = XMLPingusLevel(res_name, filename);
+
       PLFEntry entry;
       ////entry.plf   = plf;
       entry.mtime = System::get_mtime(filename);
@@ -60,13 +59,11 @@
         {
           pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: level changed on DISK, 
reloading: '" << res_name << "' -> '" << filename << "'" << std::endl;
 
-#if 0
           // Reload the file since it has changed on disk
-          PingusLevel plf = XMLPingusLevel(res_name, filename);
-#endif
+          PingusLevel plf(res_name, filename);
           PLFEntry entry;
 
-          ////entry.plf   = plf;
+          entry.plf   = plf;
           entry.mtime = System::get_mtime(filename);
 
           plf_map[res_name]  = entry;

Modified: branches/pingus_sdl/src/resource_manager.cpp
===================================================================
--- branches/pingus_sdl/src/resource_manager.cpp        2007-01-16 06:13:55 UTC 
(rev 2668)
+++ branches/pingus_sdl/src/resource_manager.cpp        2007-01-16 06:56:05 UTC 
(rev 2669)
@@ -91,7 +91,7 @@
       std::string link;
       reader.read_string("name", name);
       reader.read_string("link", link);
-      std::cout << "alias: " << name << " -> " << link << std::endl;
+      //std::cout << "alias: " << name << " -> " << link << std::endl;
     }
   else if (reader.get_name() == "name")
     {

Modified: branches/pingus_sdl/src/world.cxx
===================================================================
--- branches/pingus_sdl/src/world.cxx   2007-01-16 06:13:55 UTC (rev 2668)
+++ branches/pingus_sdl/src/world.cxx   2007-01-16 06:56:05 UTC (rev 2669)
@@ -55,6 +55,8 @@
 {
   WorldObj::set_world(this);
 
+  std::cout << "create particle holder" << std::endl;
+
   // These get deleted via the world_obj vector in the destructor
   pingu_particle_holder = new Particles::PinguParticleHolder();
   rain_particle_holder  = new Particles::RainParticleHolder();





reply via email to

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