[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2507 - trunk/src/editor
From: |
jave27 |
Subject: |
[Pingus-CVS] r2507 - trunk/src/editor |
Date: |
Wed, 16 Nov 2005 07:44:00 +0100 |
Author: jave27
Date: 2005-11-16 07:43:54 +0100 (Wed, 16 Nov 2005)
New Revision: 2507
Added:
trunk/src/editor/level_objs.cxx
trunk/src/editor/level_objs.hxx
Modified:
trunk/src/editor/Makefile.am
trunk/src/editor/level_impl.hxx
trunk/src/editor/xml_level.cxx
Log:
Right, it actually helps to mark the files you want to add. :-) More editor
stuff.
Modified: trunk/src/editor/Makefile.am
===================================================================
--- trunk/src/editor/Makefile.am 2005-11-16 03:57:40 UTC (rev 2506)
+++ trunk/src/editor/Makefile.am 2005-11-16 06:43:54 UTC (rev 2507)
@@ -22,11 +22,12 @@
libpingus_editor_a_CPPFLAGS = @PINGUS_CFLAGS@
libpingus_editor_a_SOURCES = \
- editor_screen.cxx editor_screen.hxx \
- editor_panel.cxx editor_panel.hxx \
- panel_button.cxx panel_button.hxx \
- editor_viewport.cxx editor_viewport.hxx \
- xml_level.cxx xml_level.hxx \
- level_impl.hxx
+editor_screen.cxx editor_screen.hxx \
+editor_panel.cxx editor_panel.hxx \
+panel_button.cxx panel_button.hxx \
+editor_viewport.cxx editor_viewport.hxx \
+xml_level.cxx xml_level.hxx \
+level_objs.cxx level_objs.hxx \
+level_impl.hxx \
-# EOF #
\ No newline at end of file
+# EOF #
Modified: trunk/src/editor/level_impl.hxx
===================================================================
--- trunk/src/editor/level_impl.hxx 2005-11-16 03:57:40 UTC (rev 2506)
+++ trunk/src/editor/level_impl.hxx 2005-11-16 06:43:54 UTC (rev 2507)
@@ -17,16 +17,17 @@
// 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_PINGUS_EDITOR_LEVEL_IMPL_HXX
+#define HEADER_PINGUS_EDITOR_LEVEL_IMPL_HXX
+
#include <ClanLib/Core/System/sharedptr.h>
#include <ClanLib/Core/Math/size.h>
#include <ClanLib/Display/color.h>
#include <string>
#include <vector>
#include <map>
+#include "level_objs.hxx"
-#ifndef HEADER_PINGUS_EDITOR_LEVEL_IMPL_HXX
-#define HEADER_PINGUS_EDITOR_LEVEL_IMPL_HXX
-
namespace Pingus {
namespace Editor {
@@ -43,6 +44,14 @@
{
// Do nothing
}
+
+ /** Destructor */
+ ~LevelImpl()
+ {
+ for (unsigned i = 0; i < objects.size(); i++)
+ delete objects[i];
+ objects.clear();
+ }
std::string resname;
Added: trunk/src/editor/level_objs.cxx
===================================================================
--- trunk/src/editor/level_objs.cxx 2005-11-16 03:57:40 UTC (rev 2506)
+++ trunk/src/editor/level_objs.cxx 2005-11-16 06:43:54 UTC (rev 2507)
@@ -0,0 +1,64 @@
+// $Id: level_objs.cxx,v 1.00 2005/11/15 23:41:12 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2005 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 <string>
+#include <iostream>
+#include "level_objs.hxx"
+#include "../resource.hxx"
+#include "../resource_modifier.hxx"
+#include "../display/drawing_context.hxx"
+
+namespace Pingus {
+
+namespace Editor {
+
+// Default constructor
+LevelObj::LevelObj(const std::string res_name) :
+ sprite(Resource::load_sprite(res_name)),
+ modifier("ROT0")
+{
+
+}
+
+// Draw the sprite
+void
+LevelObj::draw(DrawingContext &gc)
+{
+ gc.draw(sprite, pos);
+}
+
+// Set the modifier and actually modify the sprite loaded in memory
+void
+LevelObj::set_modifier(const std::string m)
+{
+ // Set modifier
+ modifier = 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_SpriteDescription desc;
+ desc.add_frame(sur.get_pixeldata());
+ sprite = CL_Sprite(desc);
+}
+
+} // Editor namespace
+} // Pingus namespace
+
+/* EOF */
\ No newline at end of file
Added: trunk/src/editor/level_objs.hxx
===================================================================
--- trunk/src/editor/level_objs.hxx 2005-11-16 03:57:40 UTC (rev 2506)
+++ trunk/src/editor/level_objs.hxx 2005-11-16 06:43:54 UTC (rev 2507)
@@ -0,0 +1,119 @@
+// $Id: level_objs.hxx,v 1.00 2005/11/15 23:41:12 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2005 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_PINGUS_EDITOR_LEVEL_OBJS_HXX
+#define HEADER_PINGUS_EDITOR_LEVEL_OBJS_HXX
+
+#include <ClanLib/Display/sprite.h>
+#include "../vector.hxx"
+#include <string>
+
+namespace Pingus {
+
+ class XMLFileWriter;
+ class DrawingContext;
+
+namespace Editor {
+
+/** 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
+{
+protected:
+ /** Sprite used to draw this object */
+ CL_Sprite sprite;
+
+ /** Resource name of this object's sprite */
+ std::string res_name;
+
+ /** 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 */
+ std::string object_type;
+
+/////////////////////////////////////////////////////////
+/// Retrieve info
+public:
+ /** Retrieve the object's position */
+ Vector get_pos() const { return pos; }
+
+ /** Retrieve the object's resource name */
+ std::string get_res_name() const { return res_name; }
+
+ /** 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; }
+
+
+/////////////////////////////////////////////////////////
+/// Operations
+public:
+ /** Set the object's position */
+ void set_pos(Vector p) { pos = p; }
+
+ /** Set the object's resource name */
+ void set_res_name(const std::string res) { res_name = res; }
+
+ /** Set the object's modifier */
+ void set_modifier(const std::string m);
+
+ /** Set the object's section header name */
+ void set_section_name(const std::string sn) { section_name = sn; }
+
+ /** 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) { }
+
+ /** 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);
+
+ /** Destructor */
+ virtual ~LevelObj() { }
+
+private:
+ LevelObj();
+ LevelObj (const LevelObj&);
+ LevelObj& operator= (const LevelObj&);
+
+}; // LevelObj class
+
+} // Editor namespace
+} // Pingus namespace
+
+#endif
+
+/* EOF */
\ No newline at end of file
Modified: trunk/src/editor/xml_level.cxx
===================================================================
--- trunk/src/editor/xml_level.cxx 2005-11-16 03:57:40 UTC (rev 2506)
+++ trunk/src/editor/xml_level.cxx 2005-11-16 06:43:54 UTC (rev 2507)
@@ -22,6 +22,7 @@
#include <fstream>
#include "xml_level.hxx"
#include "level_impl.hxx"
+#include "level_objs.hxx"
#include "../xml_pingus_level.hxx"
#include "../xml_file_writer.hxx"
@@ -125,7 +126,12 @@
impl->author = existing_level.get_author();
impl->music = existing_level.get_music();
- // TODO: Get the objects
+ // 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
+ }
}
} // Editor namespace
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2507 - trunk/src/editor,
jave27 <=