pingus-cvs
[Top][All Lists]
Advanced

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

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


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3329 - in trunk/pingus: . src
Date: Fri, 26 Oct 2007 07:57:19 +0200

Author: grumbel
Date: 2007-10-26 07:57:18 +0200 (Fri, 26 Oct 2007)
New Revision: 3329

Added:
   trunk/pingus/src/levelset.cpp
   trunk/pingus/src/levelset.hpp
Modified:
   trunk/pingus/SConstruct
Log:
- simple class to handle a levelset

Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct     2007-10-26 04:19:25 UTC (rev 3328)
+++ trunk/pingus/SConstruct     2007-10-26 05:57:18 UTC (rev 3329)
@@ -146,6 +146,7 @@
 
 'src/line_iterator.cpp',
 'src/level_menu.cpp',
+'src/levelset.cpp',
 
 'src/lisp/getters.cpp',
 'src/lisp/lexer.cpp',

Added: trunk/pingus/src/levelset.cpp
===================================================================
--- trunk/pingus/src/levelset.cpp       2007-10-26 04:19:25 UTC (rev 3328)
+++ trunk/pingus/src/levelset.cpp       2007-10-26 05:57:18 UTC (rev 3329)
@@ -0,0 +1,87 @@
+//  $Id$
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2007 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 2
+//  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, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#include <iostream>
+#include "pingus_error.hpp"
+#include "file_reader.hpp"
+#include "levelset.hpp"
+
+Levelset::Levelset(const Pathname& pathname)
+{
+  FileReader reader = FileReader::parse(pathname);
+  if (reader.get_name() != "pingus-levelset")
+    {
+      PingusError::raise("Error: " + pathname.str() + ": not a 
'pingus-levelset' file");
+    }
+  else
+    {
+      reader.read_string("title",       title);
+      reader.read_string("description", description);
+      FileReader level_reader = reader.read_section("levels");
+      std::vector<FileReader> sections = level_reader.get_sections();
+      for(std::vector<FileReader>::iterator i = sections.begin(); i != 
sections.end(); ++i)
+        {
+          if (i->get_name() == "level")
+            {
+              std::string filename;
+              if (i->read_string("filename", filename))
+                {
+                  levels.push_back(filename);
+                }
+              else
+                {
+                  std::cout << "Levelset: " << pathname.str() << " is missing 
filename tag" << std::endl;
+                }
+            }
+        }
+    }
+}
+
+Levelset::~Levelset()
+{
+}
+
+std::string
+Levelset::get_title() const
+{
+  return title;
+}
+
+std::string
+Levelset::get_description() const
+{
+  return description;
+}
+
+std::string
+Levelset::get_level(int num) const
+{
+  if (num >= 0 && num < levels.size())
+    return levels[num];
+  else
+    return "";
+}
+
+int
+Levelset::get_level_count() const
+{
+  return levels.size();
+}
+
+/* EOF */


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

Added: trunk/pingus/src/levelset.hpp
===================================================================
--- trunk/pingus/src/levelset.hpp       2007-10-26 04:19:25 UTC (rev 3328)
+++ trunk/pingus/src/levelset.hpp       2007-10-26 05:57:18 UTC (rev 3329)
@@ -0,0 +1,51 @@
+//  $Id$
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2007 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 2
+//  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, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#ifndef HEADER_LEVELSET_HPP
+#define HEADER_LEVELSET_HPP
+
+#include <string>
+#include <vector>
+#include "pathname.hpp"
+
+/** */
+class Levelset
+{
+private:
+  std::string title;
+  std::string description;
+  std::vector<std::string> levels;
+
+public:
+  Levelset(const Pathname& pathname);
+  ~Levelset();
+
+  std::string get_title() const;
+  std::string get_description() const;
+  std::string get_level(int num) const;
+  int get_level_count() const;
+
+private:
+  Levelset (const Levelset&);
+  Levelset& operator= (const Levelset&);
+};
+
+#endif
+
+/* EOF */


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





reply via email to

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