pingus-cvs
[Top][All Lists]
Advanced

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

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


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3448 - in trunk/pingus: . src src/editor
Date: Thu, 1 Nov 2007 09:37:50 +0100

Author: grumbel
Date: 2007-11-01 09:37:49 +0100 (Thu, 01 Nov 2007)
New Revision: 3448

Modified:
   trunk/pingus/NEWS
   trunk/pingus/src/editor/context_menu.cpp
   trunk/pingus/src/editor/editor_level.cpp
   trunk/pingus/src/editor/editor_level.hpp
   trunk/pingus/src/editor/editor_panel.cpp
   trunk/pingus/src/editor/editor_screen.cpp
   trunk/pingus/src/editor/level_properties.cpp
   trunk/pingus/src/editor/minimap.cpp
   trunk/pingus/src/editor/object_selector.cpp
   trunk/pingus/src/editor/object_selector_list.cpp
   trunk/pingus/src/editor/viewport.cpp
   trunk/pingus/src/editor/viewport.hpp
   trunk/pingus/src/pingus_main.cpp
   trunk/pingus/src/pingus_options.hpp
Log:
- added --save comand line options, useful to convert levels into the canonical 
format used by the editor

Modified: trunk/pingus/NEWS
===================================================================
--- trunk/pingus/NEWS   2007-11-01 08:37:14 UTC (rev 3447)
+++ trunk/pingus/NEWS   2007-11-01 08:37:49 UTC (rev 3448)
@@ -1,3 +1,8 @@
+0.7.3 (??/Nov/2007)
+===================
+* fixed game not starting when no soundcard is present
+
+
 0.7.2 (31/Oct/2007)
 ===================
 * added support for levelsets

Modified: trunk/pingus/src/editor/context_menu.cpp
===================================================================
--- trunk/pingus/src/editor/context_menu.cpp    2007-11-01 08:37:14 UTC (rev 
3447)
+++ trunk/pingus/src/editor/context_menu.cpp    2007-11-01 08:37:49 UTC (rev 
3448)
@@ -20,7 +20,7 @@
 
 #include "context_menu.hpp"
 #include "level_objs.hpp"
-#include "editor_viewport.hpp"
+#include "viewport.hpp"
 #include "editor_screen.hpp"
 #include "../gui/gui_manager.hpp"
 #include "../string_util.hpp"

Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp    2007-11-01 08:37:14 UTC (rev 
3447)
+++ trunk/pingus/src/editor/editor_level.cpp    2007-11-01 08:37:49 UTC (rev 
3448)
@@ -22,7 +22,7 @@
 #include <iostream>
 #include <string>
 #include <fstream>
-#include "editor_viewport.hpp"
+#include "viewport.hpp"
 #include "editor_level.hpp"
 #include "level_impl.hpp"
 #include "level_objs.hpp"
@@ -38,9 +38,8 @@
 }
 
 // Default constructor
-EditorLevel::EditorLevel(EditorScreen* editor_) 
-  : editor(editor_),
-    impl(new LevelImpl())
+EditorLevel::EditorLevel()
+  : impl(new LevelImpl())
 {
   clear();
 }
@@ -163,9 +162,8 @@
 
   // Write the objects
   fw.begin_section("objects");
-  std::vector<LevelObj*>* objects = editor->get_viewport()->get_objects();
-  for (unsigned i = 0; i < objects->size(); i++)
-    (*objects)[i]->write_properties(fw);
+  for (unsigned i = 0; i < impl->objects.size(); i++)
+    impl->objects[i]->write_properties(fw);
   fw.end_section();    // objects
 
   fw.end_section();    // pingus-level
@@ -187,8 +185,6 @@
     delete impl;
   impl = new LevelImpl();
 
-  editor->get_viewport()->clear();
-
   // Load the level from the file - we don't care what it's res_name is.
   PingusLevel level(pathname);
        
@@ -318,9 +314,7 @@
 EditorLevel::sort()
 {
   // Sort by Z coordinate
-  std::stable_sort(editor->get_viewport()->get_objects()->begin(),
-                   editor->get_viewport()->get_objects()->end(),
-                   LevelObjSort);
+  std::stable_sort(impl->objects.begin(), impl->objects.end(), LevelObjSort);
 }
 
 void

Modified: trunk/pingus/src/editor/editor_level.hpp
===================================================================
--- trunk/pingus/src/editor/editor_level.hpp    2007-11-01 08:37:14 UTC (rev 
3447)
+++ trunk/pingus/src/editor/editor_level.hpp    2007-11-01 08:37:49 UTC (rev 
3448)
@@ -33,12 +33,9 @@
 
 class EditorLevel
 {
-private:
-  EditorScreen* editor;
-  
 public:
   /** Construct new blank level */
-  EditorLevel(EditorScreen* editor);
+  EditorLevel();
 
   /** Destructor */
   ~EditorLevel();

Modified: trunk/pingus/src/editor/editor_panel.cpp
===================================================================
--- trunk/pingus/src/editor/editor_panel.cpp    2007-11-01 08:37:14 UTC (rev 
3447)
+++ trunk/pingus/src/editor/editor_panel.cpp    2007-11-01 08:37:49 UTC (rev 
3448)
@@ -29,7 +29,7 @@
 #include "../fonts.hpp"
 #include "editor_panel.hpp"
 #include "editor_screen.hpp"
-#include "editor_viewport.hpp"
+#include "viewport.hpp"
 #include "panel_buttons.hpp"
 
 

Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp   2007-11-01 08:37:14 UTC (rev 
3447)
+++ trunk/pingus/src/editor/editor_screen.cpp   2007-11-01 08:37:49 UTC (rev 
3448)
@@ -39,7 +39,7 @@
 #include "panel.hpp"
 #include "minimap.hpp"
 #include "editor_screen.hpp"
-#include "editor_viewport.hpp"
+#include "viewport.hpp"
 #include "level_objs.hpp"
 #include "object_selector.hpp"
 #include "object_properties.hpp"
@@ -50,7 +50,7 @@
 
 // Default constructor
 EditorScreen::EditorScreen()
-  : plf(new EditorLevel(this)), 
+  : plf(new EditorLevel()),
     panel(0),
     viewport(0),
     object_selector(0),
@@ -146,6 +146,7 @@
 EditorScreen::load(const Pathname& file)
 {
   level_pathname = file;
+  viewport->clear_selection();
   plf->load_level(level_pathname);
   level_properties->set_level(plf);
   action_properties->set_level(plf);
@@ -290,7 +291,7 @@
 {
   // FIXME: dialogs don't update
   level_pathname = Pathname();
-  viewport->clear();
+  viewport->clear_selection();
   plf->clear();
   level_properties->set_level(plf);
   action_properties->set_level(plf);

Modified: trunk/pingus/src/editor/level_properties.cpp
===================================================================
--- trunk/pingus/src/editor/level_properties.cpp        2007-11-01 08:37:14 UTC 
(rev 3447)
+++ trunk/pingus/src/editor/level_properties.cpp        2007-11-01 08:37:49 UTC 
(rev 3448)
@@ -24,7 +24,7 @@
 #include "inputbox.hpp"
 #include "gui_style.hpp"
 #include "editor_level.hpp"
-#include "editor_viewport.hpp"
+#include "viewport.hpp"
 #include "level_properties.hpp"
 
 /*

Modified: trunk/pingus/src/editor/minimap.cpp
===================================================================
--- trunk/pingus/src/editor/minimap.cpp 2007-11-01 08:37:14 UTC (rev 3447)
+++ trunk/pingus/src/editor/minimap.cpp 2007-11-01 08:37:49 UTC (rev 3448)
@@ -19,7 +19,7 @@
 
 #include "editor_level.hpp"
 #include "editor_screen.hpp"
-#include "editor_viewport.hpp"
+#include "viewport.hpp"
 #include "level_objs.hpp"
 #include "gui_style.hpp"
 #include "minimap.hpp"

Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2007-11-01 08:37:14 UTC (rev 
3447)
+++ trunk/pingus/src/editor/object_selector.cpp 2007-11-01 08:37:49 UTC (rev 
3448)
@@ -27,7 +27,7 @@
 #include "display/drawing_context.hpp"
 #include "fonts.hpp"
 #include "math.hpp"
-#include "editor_viewport.hpp"
+#include "viewport.hpp"
 #include "editor_level.hpp"
 #include "object_selector_list.hpp"
 #include "object_selector_set.hpp"

Modified: trunk/pingus/src/editor/object_selector_list.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector_list.cpp    2007-11-01 08:37:14 UTC 
(rev 3447)
+++ trunk/pingus/src/editor/object_selector_list.cpp    2007-11-01 08:37:49 UTC 
(rev 3448)
@@ -22,7 +22,7 @@
 #include "editor_screen.hpp"
 #include "object_selector_set.hpp"
 #include "object_selector.hpp"
-#include "editor_viewport.hpp"
+#include "viewport.hpp"
 #include "editor_level.hpp"
 #include "groundtype.hpp"
 #include "resource.hpp"

Modified: trunk/pingus/src/editor/viewport.cpp
===================================================================
--- trunk/pingus/src/editor/viewport.cpp        2007-11-01 08:37:14 UTC (rev 
3447)
+++ trunk/pingus/src/editor/viewport.cpp        2007-11-01 08:37:49 UTC (rev 
3448)
@@ -28,7 +28,7 @@
 #include "../graphic_context_state.hpp"
 #include "editor_level.hpp"
 #include "editor_screen.hpp"
-#include "editor_viewport.hpp"
+#include "viewport.hpp"
 #include "level_objs.hpp"
 
 namespace Editor {
@@ -513,16 +513,6 @@
     }
 }
 
-void
-Viewport::clear()
-{
-  selected_objs.clear();
-  for(std::vector<LevelObj*>::iterator i = (*get_objects()).begin(); i != 
(*get_objects()).end(); ++i)
-    delete *i;
-  (*get_objects()).clear();
-  selection_changed(selected_objs);
-}
-
 Vector2f
 Viewport::get_scroll_pos() const
 {

Modified: trunk/pingus/src/editor/viewport.hpp
===================================================================
--- trunk/pingus/src/editor/viewport.hpp        2007-11-01 08:37:14 UTC (rev 
3447)
+++ trunk/pingus/src/editor/viewport.hpp        2007-11-01 08:37:49 UTC (rev 
3448)
@@ -144,7 +144,6 @@
   std::vector<LevelObj*>* get_objects();
 
   void clear_selection();
-  void clear();
 
   boost::signal<void (const std::vector<LevelObj*>&)> selection_changed;
 private:

Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp    2007-11-01 08:37:14 UTC (rev 3447)
+++ trunk/pingus/src/pingus_main.cpp    2007-11-01 08:37:49 UTC (rev 3448)
@@ -32,6 +32,7 @@
 //#include <physfs.h>
 #include "lisp/lisp.hpp"
 #include "lisp/parser.hpp"
+#include "editor/editor_level.hpp"
 #include "string_util.hpp"
 #include "sexpr_file_reader.hpp"
 
@@ -287,6 +288,8 @@
   argp.add_group("Modes:");
   argp.add_option('e', "editor", "",
                   _("Loads the level editor"));
+  argp.add_option('S', "save", "FILENAME",
+                  _("Save the level given level to FILENAME and quit"));
   argp.add_option(363, "font", "",
                   _("Test a font"));
   argp.add_option(359, "credits", "",
@@ -361,6 +364,10 @@
             cmd_options.disable_sound.set(true);
             break;
 
+          case 'S':
+            cmd_options.save.set(argp.get_argument());
+            break;
+
           case 'm': // -m, --disable-music
             cmd_options.disable_music.set(true);
             break;
@@ -658,7 +665,23 @@
 void
 PingusMain::start_game ()
 {
-  if (cmd_options.credits.is_set() && cmd_options.credits.get())
+  if (cmd_options.save.is_set())
+    { // Load a level and save it again, useful to convert it in a new format
+      if (!cmd_options.rest.is_set())
+        {
+          std::cout << "Error: level argument required" << std::endl;
+        }
+      else
+        {
+          Pathname filename(cmd_options.rest.get(), Pathname::SYSTEM_PATH);
+          Editor::EditorLevel level;
+          std::cout << "Loading: " << filename.str() << std::endl;
+          level.load_level(filename);
+          std::cout << "Saving:  " << cmd_options.save.get() << std::endl;
+          level.save_level(cmd_options.save.get());
+        }
+    }
+  else if (cmd_options.credits.is_set() && cmd_options.credits.get())
     {
       ScreenManager::instance()->push_screen(Credits::instance(), false);
     }
@@ -687,7 +710,7 @@
       ScreenManager::instance()->push_screen
         (new 
StartScreen(PLFResMgr::load_plf_from_filename(Pathname(cmd_options.rest.get(),
                                                                     
Pathname::SYSTEM_PATH))),
-                         true);
+         true);
     }
   else // start a normal game
     {

Modified: trunk/pingus/src/pingus_options.hpp
===================================================================
--- trunk/pingus/src/pingus_options.hpp 2007-11-01 08:37:14 UTC (rev 3447)
+++ trunk/pingus/src/pingus_options.hpp 2007-11-01 08:37:49 UTC (rev 3448)
@@ -65,6 +65,7 @@
   Value<bool> editor;
   Value<bool> credits;
   Value<bool> font;
+  Value<std::string> save;
 
   // Display
   Value<bool> fullscreen;





reply via email to

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