pingus-cvs
[Top][All Lists]
Advanced

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

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


From: jave27
Subject: [Pingus-CVS] r2508 - in trunk: . src/editor
Date: Thu, 17 Nov 2005 18:42:40 +0100

Author: jave27
Date: 2005-11-17 18:42:26 +0100 (Thu, 17 Nov 2005)
New Revision: 2508

Modified:
   trunk/Pingus.vcproj
   trunk/src/editor/editor_screen.cxx
   trunk/src/editor/editor_screen.hxx
   trunk/src/editor/editor_viewport.cxx
   trunk/src/editor/level_objs.cxx
   trunk/src/editor/level_objs.hxx
   trunk/src/editor/panel_buttons.cxx
   trunk/src/editor/xml_level.cxx
   trunk/src/editor/xml_level.hxx
Log:
More editor stuff.  The editor can successfully load a level into memory and 
save it back out.  Some objects may be incomplete (such as traps) at the 
moment.  It can also now do a very basic (incorrect) drawing of each of the 
sprites represented by the level object.

Modified: trunk/Pingus.vcproj
===================================================================
--- trunk/Pingus.vcproj 2005-11-16 06:43:54 UTC (rev 2507)
+++ trunk/Pingus.vcproj 2005-11-17 17:42:26 UTC (rev 2508)
@@ -1780,11 +1780,26 @@
                                        
RelativePath=".\src\editor\editor_viewport.hxx">
                                </File>
                                <File
+                                       
RelativePath=".\src\editor\level_impl.hxx">
+                               </File>
+                               <File
+                                       
RelativePath=".\src\editor\level_objs.cxx">
+                               </File>
+                               <File
+                                       
RelativePath=".\src\editor\level_objs.hxx">
+                               </File>
+                               <File
                                        
RelativePath=".\src\editor\panel_buttons.cxx">
                                </File>
                                <File
                                        
RelativePath=".\src\editor\panel_buttons.hxx">
                                </File>
+                               <File
+                                       
RelativePath=".\src\editor\xml_level.cxx">
+                               </File>
+                               <File
+                                       
RelativePath=".\src\editor\xml_level.hxx">
+                               </File>
                        </Filter>
                </Filter>
                <File

Modified: trunk/src/editor/editor_screen.cxx
===================================================================
--- trunk/src/editor/editor_screen.cxx  2005-11-16 06:43:54 UTC (rev 2507)
+++ trunk/src/editor/editor_screen.cxx  2005-11-17 17:42:26 UTC (rev 2508)
@@ -31,6 +31,7 @@
 #include "editor_panel.hxx"
 #include "editor_viewport.hxx"
 #include "xml_level.hxx"
+#include "level_objs.hxx"
 
 namespace Pingus {
 
@@ -113,6 +114,7 @@
        gc.draw_fillrect(0, 0, (float)CL_Display::get_width(), 
                (float)CL_Display::get_height(), CL_Color::black, -10000);
        gui_manager->draw(gc);
+
        gc.print_center(Fonts::pingus_large, (float)(CL_Display::get_width() / 
2), 
                (float)(CL_Display::get_height() / 2), "Not yet functional");
        return true;

Modified: trunk/src/editor/editor_screen.hxx
===================================================================
--- trunk/src/editor/editor_screen.hxx  2005-11-16 06:43:54 UTC (rev 2507)
+++ trunk/src/editor/editor_screen.hxx  2005-11-17 17:42:26 UTC (rev 2508)
@@ -67,8 +67,11 @@
        bool draw (DrawingContext& gc);
 
        /** Return the gui_manager */
-       GUI::GUIManager* get_gui_manager() { return gui_manager; }
+       GUI::GUIManager* get_gui_manager() const { return gui_manager; }
 
+       /** Return a pointer to the current level */
+       XMLLevel* get_level() const { return plf; }
+
        /** Saves the currently loaded level */
        void save_level(const std::string levelfile);
 

Modified: trunk/src/editor/editor_viewport.cxx
===================================================================
--- trunk/src/editor/editor_viewport.cxx        2005-11-16 06:43:54 UTC (rev 
2507)
+++ trunk/src/editor/editor_viewport.cxx        2005-11-17 17:42:26 UTC (rev 
2508)
@@ -25,6 +25,9 @@
 #include "../display/drawing_context.hxx"
 #include "../graphic_context_state.hxx"
 #include "editor_viewport.hxx"
+#include "editor_screen.hxx"
+#include "xml_level.hxx"
+#include "level_objs.hxx"
 
 namespace Pingus {
 namespace Editor {
@@ -85,9 +88,13 @@
                gc.draw_fillrect(start_pos.x, start_pos.y, 
                        end_pos.x, end_pos.y, CL_Color::darkgray, -5000);
 
-       // Added this to test translate scrolling.
-       gc.draw_fillrect(300, 250, 400, 300, CL_Color::white);
 
+       // FIXME: This is obviously not correct, but it's just a proof of 
concept now.
+       // Draw the level objects
+       std::vector<LevelObj*> objs = editor->get_level()->get_objects();
+       for (unsigned i = 0; i < objs.size(); i++)
+               objs[i]->draw(gc);
+
        //state.pop(*scene_context);
 
        //gc.draw(new SceneContextDrawingRequest(scene_context, 0));

Modified: trunk/src/editor/level_objs.cxx
===================================================================
--- trunk/src/editor/level_objs.cxx     2005-11-16 06:43:54 UTC (rev 2507)
+++ trunk/src/editor/level_objs.cxx     2005-11-17 17:42:26 UTC (rev 2508)
@@ -21,26 +21,55 @@
 #include <iostream>
 #include "level_objs.hxx"
 #include "../resource.hxx"
-#include "../resource_modifier.hxx"
+#include "../res_descriptor.hxx"
 #include "../display/drawing_context.hxx"
+#include "../xml_file_writer.hxx"
 
 namespace Pingus {
 
 namespace Editor {
 
 // Default constructor
-LevelObj::LevelObj(const std::string res_name) :
-       sprite(Resource::load_sprite(res_name)),
-       modifier("ROT0")
+LevelObj::LevelObj(std::string obj_name) :
+       section_name(obj_name),
+       width(0),
+       speed(0),
+       parallax(0.0),
+       owner_id(-1),
+       color(0,0,0,0),
+       scroll_x(0),
+       scroll_y(0),
+       stretch_x(false),
+       stretch_y(false),
+       keep_aspect(false),
+       para_x(0),
+       para_y(0),
+       attribs(get_attributes(obj_name))
 {
+       
+}
 
+void 
+LevelObj::set_res_desc(const ResDescriptor d)
+{
+       desc = d;
+       sprite = Resource::load_sprite(desc);
 }
 
 // Draw the sprite
 void
 LevelObj::draw(DrawingContext &gc)
 {
-       gc.draw(sprite, pos);
+       if (attribs & HAS_SURFACE)
+       {
+               if (attribs & HAS_WIDTH)
+               {
+                       for(int x = static_cast<int>(pos.x); x < pos.x + width; 
x += sprite.get_width())
+                               gc.draw(sprite, Vector(static_cast<float>(x), 
pos.y));
+               }
+               else
+                       gc.draw(sprite, pos);
+       }
 }
 
 // Set the modifier and actually modify the sprite loaded in memory
@@ -48,16 +77,74 @@
 LevelObj::set_modifier(const std::string m)
 {
        // Set modifier
-       modifier = m;
+       desc.modifier = ResourceModifierNS::rs_from_string(m);
 
        // Apply modifier, then change the sprite loaded for this object in 
memory.
-       CL_Surface sur = Resource::apply_modifier(sprite.get_frame_surface(0), 
-                ResDescriptor(res_name, 
ResourceModifierNS::rs_from_string(modifier)));
+       CL_Surface sur = Resource::apply_modifier(sprite.get_frame_surface(0), 
desc);
        CL_SpriteDescription desc;
        desc.add_frame(sur.get_pixeldata());
        sprite = CL_Sprite(desc);
 }
 
+// Writes the XML attributes for the file
+void
+LevelObj::write_properties(XMLFileWriter &xml)
+{
+       xml.begin_section(section_name.c_str());
+
+       const unsigned attribs = get_attributes(section_name);
+
+       // Write information about the main sprite
+       if (attribs & HAS_SURFACE)
+       {
+               xml.begin_section("surface");
+               xml.write_string("image", desc.res_name);
+               xml.write_string("modifier", 
ResourceModifierNS::rs_to_string(desc.modifier));
+               xml.end_section();      // surface
+       }
+       // Write the optional information
+       if (attribs & HAS_TYPE)
+               xml.write_string("type", object_type);
+       if (attribs & HAS_SPEED)
+               xml.write_int("speed", speed);
+       if (attribs & HAS_PARALLAX)
+               xml.write_float("parallax", parallax);
+       if (attribs & HAS_WIDTH)
+               xml.write_int("width", width);
+       if (attribs & HAS_OWNER)
+               xml.write_int("owner-id", owner_id);
+       if (attribs & HAS_DIRECTION)
+               xml.write_string("direction", direction);
+       if (attribs & HAS_RELEASE_RATE)
+               xml.write_int("release-rate", release_rate);
+       if (attribs & HAS_COLOR)
+               xml.write_color("color", color);
+       if (attribs & HAS_STRETCH)
+       {
+               xml.write_bool("stretch-x", stretch_x);
+               xml.write_bool("stretch-y", stretch_y);
+               xml.write_bool("keep-aspect", keep_aspect);
+       }
+       if (attribs & HAS_SCROLL)
+       {
+               xml.write_float("scroll-x", scroll_x);
+               xml.write_float("scroll-y", scroll_y);
+       }
+       if (attribs & HAS_PARA)
+       {
+               xml.write_float("para-x", para_x);
+               xml.write_float("para-y", para_y);
+       }
+
+       // Writes any extra properties that may be necessary (virtual function)
+       write_extra_properties(xml);
+
+       // Write the Vector position - all objects have this
+       xml.write_vector("position", pos);
+
+       xml.end_section();      // object's section_name
+}
+
 }              // Editor namespace
 }              // Pingus namespace
 

Modified: trunk/src/editor/level_objs.hxx
===================================================================
--- trunk/src/editor/level_objs.hxx     2005-11-16 06:43:54 UTC (rev 2507)
+++ trunk/src/editor/level_objs.hxx     2005-11-17 17:42:26 UTC (rev 2508)
@@ -22,6 +22,7 @@
 
 #include <ClanLib/Display/sprite.h>
 #include "../vector.hxx"
+#include "../res_descriptor.hxx"
 #include <string>
 
 namespace Pingus {
@@ -31,6 +32,41 @@
 
 namespace Editor {
 
+       const unsigned HAS_TYPE = 1;
+       const unsigned HAS_SPEED = 2;
+       const unsigned HAS_PARALLAX = 4;
+       const unsigned HAS_WIDTH = 8;
+       const unsigned HAS_OWNER = 16;
+       const unsigned HAS_COLOR = 32;
+       const unsigned HAS_SCROLL = 64;
+       const unsigned HAS_PARA = 128;
+       const unsigned HAS_STRETCH = 256;
+       const unsigned HAS_DIRECTION = 512;
+       const unsigned HAS_RELEASE_RATE = 1024;
+       const unsigned HAS_SURFACE = 2048;
+
+       /** Returns a number representing which attributes this object 
possesses */
+       static unsigned get_attributes(std::string obj_type)
+       {
+               unsigned val;
+               if (obj_type == "groundpiece")
+                       val = HAS_TYPE | HAS_SURFACE;
+               else if (obj_type == "hotspot")
+                       val = HAS_SPEED | HAS_PARALLAX | HAS_SURFACE;
+               else if (obj_type == "liquid")
+                       val = HAS_SPEED | HAS_WIDTH | HAS_SURFACE;
+               else if (obj_type == "surface-background")
+                       val = HAS_COLOR | HAS_STRETCH | HAS_PARA | HAS_SCROLL | 
HAS_SURFACE;
+               else if (obj_type == "entrance")
+                       val = HAS_TYPE | HAS_DIRECTION | HAS_RELEASE_RATE | 
HAS_OWNER;
+               else if (obj_type == "exit")
+                       val = HAS_OWNER | HAS_SURFACE;
+               else
+                       val = 0;
+
+               return val;
+       }
+
 /** Generic Level Object (groundpiece, sign, etc.)  Only special objects will 
have
                to inherit from this class - most objects will be able to use 
this class alone */
 class LevelObj
@@ -39,48 +75,134 @@
        /** Sprite used to draw this object */
        CL_Sprite sprite;
 
-       /** Resource name of this object's sprite */
-       std::string res_name;
+       /** Resource Desciptor of this object */
+  ResDescriptor desc;
 
-       /** Modifier used on the sprite (ROT90, ROT180, etc.) */
-       std::string modifier;
-
        /** Location of this object in the World */
        Vector pos;
 
        /** Name of the section header for this object (hotspot, groundpiece, 
etc.) */
        std::string section_name;
 
-       /** Optional type field to further describe the resource */
+       /** Optional type field for certain objects */
        std::string object_type;
 
+       /** Optional speed field for certain objects */
+       int speed;
+
+       /** Optional parallax field for certain objects */
+       float parallax;
+
+       /** Optional width field for certain objects */
+       int width;
+
+       /** Optional owner id field for certain objects */
+       int owner_id;
+
+       /** Optional release rate field for certain objects (entrances) */
+       int release_rate;
+
+       /** Optional direction field for certain objects */
+       std::string direction;
+
+       /** Optional scroll field in the x direction for certain objects */
+       float scroll_x;
+
+       /** Optional scroll field in the y direction for certain objects */
+       float scroll_y;
+
+       /** Optional stretch field in the x direction for certain objects */
+       bool stretch_x;
+
+       /** Optional stretch field in the y direction for certain objects */
+       bool stretch_y;
+
+       /** Optional field for keeping the aspect ratio of stretched objects */
+       bool keep_aspect;
+
+       /** Optional parallax field in the x direction for certain objects */
+       float para_x;
+
+       /** Optional parallax field in the y direction for certain objects */
+       float para_y;
+
+       /** Optional color field for certain objects */
+       CL_Colorf color;
+
+       /** Number representing which attributes this object possesses */
+       unsigned attribs;
+
+       /** Write any additional properties to the XML file for this type */
+       virtual void write_extra_properties(XMLFileWriter& xml) { }
+
+
+
 /////////////////////////////////////////////////////////
 /// Retrieve info
 public:
        /** Retrieve the object's position */
        Vector get_pos() const { return pos; }
 
+       /** Retrieve this object's attribute number */
+       unsigned get_attribs() const { return attribs; }
+
        /** Retrieve the object's resource name */
-       std::string get_res_name() const { return res_name; }
+       ResDescriptor get_res_desc() const { return desc; }
 
-       /** Retrieve the object's resource modifier */
-       std::string get_modifier() const { return modifier; }
-
        /** Retrieve the name of the section header for this object */
        std::string get_section_name() const { return section_name; }
 
        /** Retrieve the object's type */
        std::string get_type() const { return object_type; }
 
+       /** Retrieve the object's speed */
+       int get_speed() const { return speed; }
 
+       /** Retrive the object's parallax (is this even used???) */
+       float get_parallax() const { return parallax; }
+
+       /** Retrieve the object's owner */
+       int get_owner() const { return owner_id; }
+
+       /** Retrieve the object's width */
+       int get_width() const { return width; }
+
+       /** Retrieve the object's color */
+       CL_Colorf get_color() const { return color; }
+
+       /** Returns true if the object is stretched in the x direction */
+       bool get_stretch_x() const { return stretch_x; }
+
+       /** Returns true if the object is stretched in the y direction */
+       bool get_stretch_y() const { return stretch_y; }
+
+       /** Returns true if the object is to maintain it's aspect ratio if 
stretched */
+       bool get_aspect() const { return keep_aspect; }
+
+       /** Retrive the objects scroll value in the x direction */
+       float get_scroll_x() const { return scroll_x; }
+
+       /** Retrive the objects scroll value in the y direction */
+       float get_scroll_y() const { return scroll_y; }
+
+       /** Returns the parallax speed multiplier in the x direction */
+       float get_para_x() const { return para_x; }
+
+       /** Returns the parallax speed multiplier in the y direction */
+       float get_para_y() const { return para_y; }
+
+       /** Retrieve the object's direction */
+       std::string get_direction() { return direction; }
+
+
 /////////////////////////////////////////////////////////
 /// Operations
 public:
        /** Set the object's position */
-       void set_pos(Vector p) { pos = p; }
+       void set_pos(const Vector p) { pos = p; }
 
        /** Set the object's resource name */
-       void set_res_name(const std::string res) { res_name = res; }
+       void set_res_desc(const ResDescriptor d);
 
        /** Set the object's modifier */
        void set_modifier(const std::string m);
@@ -91,21 +213,60 @@
        /** Set the object's type */
        void set_type(const std::string t) { object_type = t; }
 
-       /** Write any additional properties to the XML file for this type */
-       virtual void write_extra_properties(XMLFileWriter& xml) { }
+       /** Set the object's speed */
+       void set_speed(const int s) { speed = s; }
 
+       /** Set the object's parallax */
+       void set_parallax(const float para) { parallax = para; }
+
+       /** Set the object's width */
+       void set_width(const int w) { width = w; }
+
+       /** Set the object's owner_id */
+       void set_owner(const int id) { owner_id = id; }
+
+       /** Set the object's scroll rate in the x direction */
+       void set_scroll_x(const float s) { scroll_x = s; }
+
+       /** Set the object's scroll rate in the y direction */
+       void set_scroll_y(const float s) { scroll_y = s; }
+
+       /** Set the objects stretch in the x direction value */
+       void set_stretch_x(const bool s) { stretch_x = s; }
+
+       /** Set the objects stretch in the y direction value */
+       void set_stretch_y(bool s) { stretch_y = s; }
+
+       /** Set whether or not the object should maintain it's aspect ratio 
when stretched */
+       void set_aspect(const bool a) { keep_aspect = a; }
+
+       /** Set the objects color if applicable */
+       void set_color(const CL_Colorf c) 
+       { color.alpha = c.alpha; color.blue = c.blue;  
+               color.green = c.green; color.red = c.red; }
+
+       /** Set the object's parallax scroll multiplier in the x direction */
+       void set_para_x(const float p) { para_x = p; }
+
+       /** Set the object's parallax scroll multiplier in the y direction */
+       void set_para_y(const float p) { para_y = p; }
+
+       /** Set the object's direction if applicable */
+       void set_direction(const std::string d) { direction = d; }
+
+       /** Write basic properties to the XML file for this type */
+       virtual void write_properties(XMLFileWriter &xml);
+
        /** Draws the sprite with the modifier applied */
        virtual void draw(DrawingContext &gc);
 
-       /** Default Constructor
-                       @param res_name The name of the resource for the main 
sprite */
-       LevelObj(const std::string res_name);
+       /** Default Constructor */
+       LevelObj(const std::string obj_name);
 
        /** Destructor */
        virtual ~LevelObj() { }
 
 private:
-       LevelObj();
        LevelObj (const LevelObj&);
   LevelObj& operator= (const LevelObj&);
 

Modified: trunk/src/editor/panel_buttons.cxx
===================================================================
--- trunk/src/editor/panel_buttons.cxx  2005-11-16 06:43:54 UTC (rev 2507)
+++ trunk/src/editor/panel_buttons.cxx  2005-11-17 17:42:26 UTC (rev 2508)
@@ -104,8 +104,6 @@
 PanelButtonLoad::on_primary_button_click(int x, int y)
 {
        // TODO: Open a file dialog box to load a level.
-       std::cout << "Load a level" << std::endl;
-
        
panel->get_screen()->load_level(path_manager.complete("levels/tutorial/miner-tutorial2-grumbel.pingus"));
 }
 
@@ -121,9 +119,7 @@
 void
 PanelButtonSave::on_primary_button_click(int x, int y)
 {
-       // TODO: Open a file dialog box to load a level.
-       std::cout << "Save the level" << std::endl;
-
+       // TODO: Open a file dialog box to save the level.
        
panel->get_screen()->save_level(path_manager.complete("levels/test.pingus"));
 }
 

Modified: trunk/src/editor/xml_level.cxx
===================================================================
--- trunk/src/editor/xml_level.cxx      2005-11-16 06:43:54 UTC (rev 2507)
+++ trunk/src/editor/xml_level.cxx      2005-11-17 17:42:26 UTC (rev 2508)
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <ClanLib/Display/color.h>
 #include <iostream>
 #include <string>
 #include <fstream>
@@ -25,6 +26,8 @@
 #include "level_objs.hxx"
 #include "../xml_pingus_level.hxx"
 #include "../xml_file_writer.hxx"
+#include "../xml_file_reader.hxx"
+#include "../res_descriptor.hxx"
 
 namespace Pingus {
 
@@ -53,8 +56,6 @@
 // Save the level to a file.  Returns true if successful
 bool XMLLevel::save_level(const std::string& filename)
 {
-       std::cout << "XMLLevel::save_level() - Not fully implemented" << 
std::endl;
-       
        // Make sure level is valid
        if (!is_valid())
                return false;
@@ -94,8 +95,10 @@
        xml.end_section();      // levelsize
        xml.end_section();      // head
 
+       // Write the objects
        xml.begin_section("objects");
-       // TODO: Write the objects
+       for (unsigned i = 0; i < impl->objects.size(); i++)
+               impl->objects[i]->write_properties(xml);
        xml.end_section();      // objects
 
        xml.end_section();      // pingus-level
@@ -108,8 +111,6 @@
 // Load an existing level from a file
 void XMLLevel::load_level(const std::string& filename)
 {
-       std::cout << "XMLLevel::load_level() - Not yet implemented" << 
std::endl;
-       
        // Load the level from the file - we don't care what it's res_name is.
        XMLPingusLevel existing_level("", filename);
        
@@ -126,11 +127,94 @@
        impl->author = existing_level.get_author();
        impl->music = existing_level.get_music();
        
+       // Temporary objects
+       unsigned attribs;
+       Vector p;
+       CL_Colorf tmp_color;
+       ResDescriptor desc;
+       std::string tmp_str;
+       int tmp_int;
+       float tmp_float;
+       bool tmp_bool;
+
        // Get the objects
        std::vector<FileReader> objs = existing_level.get_objects();
        for (std::vector<FileReader>::const_iterator i = objs.begin(); i != 
objs.end(); i++)
        {
-               // TODO: Load information about each object
+               // Create new object
+               LevelObj* obj = new LevelObj(i->get_name());
+               attribs = obj->get_attribs();
+
+               // All objects have a position - get that.
+               i->read_vector("position", p);
+
+               // Get optional attributes based on the attribs value
+               if (attribs & HAS_SURFACE)
+               {
+                       i->read_desc("surface", desc);
+                       obj->set_res_desc(desc);
+                       obj->set_pos(p);
+               }
+               if (attribs & HAS_TYPE)
+               {       
+                       i->read_string("type", tmp_str);
+                       obj->set_type(tmp_str);
+               }
+               if (attribs & HAS_SPEED)
+               {
+                       i->read_int("speed", tmp_int);
+                       obj->set_speed(tmp_int);
+               }
+               if (attribs & HAS_WIDTH)
+               {
+                       i->read_int("width", tmp_int);
+                       obj->set_width(tmp_int);
+               }
+               if (attribs & HAS_PARALLAX)
+               {
+                       i->read_float("parallax", tmp_float);
+                       obj->set_parallax(tmp_float);
+               }
+               if (attribs & HAS_OWNER)
+               {
+                       i->read_int("owner-id", tmp_int);
+                       obj->set_owner(tmp_int);
+               }
+               if (attribs & HAS_DIRECTION)
+               {
+                       i->read_string("direction", tmp_str);
+                       obj->set_direction(tmp_str);
+               }
+               if (attribs & HAS_COLOR)
+               {
+                       i->read_color("color", tmp_color);
+                       obj->set_color(tmp_color);
+               }
+               if (attribs & HAS_SCROLL)
+               {
+                       i->read_float("scroll-x", tmp_float);
+                       obj->set_scroll_x(tmp_float);
+                       i->read_float("scroll-y", tmp_float);
+                       obj->set_scroll_y(tmp_float);
+               }
+               if (attribs & HAS_STRETCH)
+               {
+                       i->read_bool("stretch-x", tmp_bool);
+                       obj->set_stretch_x(tmp_bool);
+                       i->read_bool("stretch-y", tmp_bool);
+                       obj->set_stretch_y(tmp_bool);
+                       i->read_bool("keep-aspect", tmp_bool);
+                       obj->set_aspect(tmp_bool);
+               }
+               if (attribs & HAS_PARA)
+               {
+                       i->read_float("para-x", tmp_float);
+                       obj->set_para_x(tmp_float);
+                       i->read_float("para-y", tmp_float);
+                       obj->set_para_y(tmp_float);
+               }
+
+               impl->objects.push_back((LevelObj*)obj);
        }
 }
 

Modified: trunk/src/editor/xml_level.hxx
===================================================================
--- trunk/src/editor/xml_level.hxx      2005-11-16 06:43:54 UTC (rev 2507)
+++ trunk/src/editor/xml_level.hxx      2005-11-17 17:42:26 UTC (rev 2508)
@@ -20,11 +20,14 @@
 #ifndef HEADER_PINGUS_EDITOR_XMLLEVEL_HXX
 #define HEADER_PINGUS_EDITOR_XMLLEVEL_HXX
 
+#include <vector>
+#include "level_impl.hxx"
+
 namespace Pingus {
 
 namespace Editor {
 
-       class LevelImpl;
+       class LevelObj;
 
 class XMLLevel
 {
@@ -48,6 +51,8 @@
        /** Load an existing level from a file */
        void load_level(const std::string& filename);
 
+       std::vector<LevelObj*> get_objects() const { return impl->objects; }
+
 private:
        XMLLevel (const XMLLevel&);
   XMLLevel& operator= (const XMLLevel&);





reply via email to

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