pingus-cvs
[Top][All Lists]
Advanced

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

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


From: plouj at BerliOS
Subject: [Pingus-CVS] r3693 - in trunk/pingus: . src/editor
Date: Sat, 5 Jul 2008 17:08:10 +0200

Author: plouj
Date: 2008-07-05 17:08:08 +0200 (Sat, 05 Jul 2008)
New Revision: 3693

Modified:
   trunk/pingus/TODO
   trunk/pingus/src/editor/editor_level.cpp
   trunk/pingus/src/editor/editor_level.hpp
Log:
fixed bug: the editor "new level" button did not result in an empty level


Modified: trunk/pingus/TODO
===================================================================
--- trunk/pingus/TODO   2008-07-05 08:00:06 UTC (rev 3692)
+++ trunk/pingus/TODO   2008-07-05 15:08:08 UTC (rev 3693)
@@ -62,8 +62,6 @@
 
 * rename WorldMapManager to WorldMapScreen, split WorldMapComponent into 
seperate file
 
-* <Plouj> and the "new level" button doesn't do anything in the level editor 
after opening a level
-
 * intro/end credits are not properly displayed currently
 
 * do SurfaceButton with signals

Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp    2008-07-05 08:00:06 UTC (rev 
3692)
+++ trunk/pingus/src/editor/editor_level.cpp    2008-07-05 15:08:08 UTC (rev 
3693)
@@ -38,12 +38,23 @@
 EditorLevel::EditorLevel()
   : impl(new LevelImpl())
 {
-  clear();
+  set_impl_defaults();
 }
 
+/** simply replace the current level implementation with a new blank
+    one */
 void
-EditorLevel::clear()
+EditorLevel::clear_impl()
 {
+  if (impl)
+    delete impl;
+  impl = new LevelImpl();
+}
+
+/** assuming we have a valid implementation, set default values */
+void
+EditorLevel::set_impl_defaults()
+{
   impl->levelname   = "none";
   impl->description = "none";
   impl->author = "none";
@@ -71,6 +82,13 @@
   impl->time = -1;
   impl->difficulty = 0;
 }
+
+void
+EditorLevel::clear() {
+  clear_impl();
+  set_impl_defaults();
+}
+
 
 // Default Destructor
 EditorLevel::~EditorLevel()
@@ -178,9 +196,10 @@
 {
   std::cout << "EditorLevel::load_level: " << pathname.str() << std::endl;
 
-  if (impl)
-    delete impl;
-  impl = new LevelImpl();
+  // Get a new level implementation with default settings. It is a
+  // good idea to set the level defaults first, in case the level file
+  // doesn't set everything.
+  clear();
 
   // Load the level from the file - we don't care what it's res_name is.
   PingusLevel level(pathname);

Modified: trunk/pingus/src/editor/editor_level.hpp
===================================================================
--- trunk/pingus/src/editor/editor_level.hpp    2008-07-05 08:00:06 UTC (rev 
3692)
+++ trunk/pingus/src/editor/editor_level.hpp    2008-07-05 15:08:08 UTC (rev 
3693)
@@ -37,7 +37,14 @@
   /** Destructor */
   ~EditorLevel();
 
-  /** Sets default values */
+  /** get a new, blank level implementation without any valid settings */
+  void clear_impl();
+
+  /** Set valid default level implementation settings, assuming an
+      existing implementation */
+  void set_impl_defaults();
+
+  /** get a new implementation with default settings */
   void clear();
 
   /** Verify that level is valid */





reply via email to

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