[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src groundpiece_data.cxx,1.2,1.3 groundpi
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src groundpiece_data.cxx,1.2,1.3 groundpiece_data.hxx,1.3,1.4 worldobj_group_data.cxx,1.2,1.3 worldobj_group_data.hxx,1.1,1.2 xml_plf.cxx,1.3,1.4 |
Date: |
24 Jun 2002 18:53:16 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv4405
Modified Files:
groundpiece_data.cxx groundpiece_data.hxx
worldobj_group_data.cxx worldobj_group_data.hxx xml_plf.cxx
Log Message:
- added proof-of-concept prefabs save/load support
- fixed a crash bug, which was caused while duplicating some objects in the
editor
- moved some parsing code where it belongs
Index: groundpiece_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/groundpiece_data.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- groundpiece_data.cxx 13 Jun 2002 14:25:12 -0000 1.2
+++ groundpiece_data.cxx 24 Jun 2002 18:53:14 -0000 1.3
@@ -21,6 +21,51 @@
#include "xml_helper.hxx"
#include "editor/editor_groundpiece_obj.hxx"
#include "boost/smart_ptr.hpp"
+#include "xml_helper.hxx"
+
+GroundpieceData::GroundpieceData ()
+{
+ // do nothing
+}
+
+GroundpieceData::GroundpieceData (xmlDocPtr doc, xmlNodePtr cur)
+{
+ gptype = GroundpieceData::GP_GROUND;
+
+ char* gptype_c_str = (char*)xmlGetProp(cur, (xmlChar*)"type");
+ if (gptype_c_str)
+ {
+ gptype = GroundpieceData::string_to_type (gptype_c_str);
+ free(gptype_c_str);
+ }
+ else
+ std::cout << "XMLPLF: groundtype empty" << std::endl;
+
+ cur = cur->children;
+
+ while (cur != NULL)
+ {
+ if (xmlIsBlankNode(cur))
+ {
+ cur = cur->next;
+ continue;
+ }
+
+ if (strcmp((char*)cur->name, "position") == 0)
+ {
+ pos = XMLhelper::parse_vector(doc, cur);
+ }
+ else if (strcmp((char*)cur->name, "surface") == 0)
+ {
+ desc = XMLhelper::parse_surface(doc, cur);
+ }
+ else
+ {
+ printf("Unhandled: %s\n", (char*)cur->name);
+ }
+ cur = cur->next;
+ }
+}
GroundpieceData::GPType
GroundpieceData::string_to_type(const std::string& arg_type)
Index: groundpiece_data.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/groundpiece_data.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- groundpiece_data.hxx 20 Jun 2002 11:08:34 -0000 1.3
+++ groundpiece_data.hxx 24 Jun 2002 18:53:14 -0000 1.4
@@ -23,7 +23,7 @@
#include <iosfwd>
#include <ClanLib/Core/Math/cl_vector.h>
#include <ClanLib/Display/Display/surface.h>
-
+#include "libxmlfwd.hxx"
#include "res_descriptor.hxx"
class EditorObj;
@@ -53,6 +53,9 @@
/********************/
/* Static Functions */
/********************/
+
+ GroundpieceData ();
+ GroundpieceData (xmlDocPtr doc, xmlNodePtr cur);
std::list<boost::shared_ptr<EditorObj> > create_EditorObj();
void write_xml(std::ofstream* xml);
Index: worldobj_group_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobj_group_data.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- worldobj_group_data.cxx 13 Jun 2002 14:25:12 -0000 1.2
+++ worldobj_group_data.cxx 24 Jun 2002 18:53:14 -0000 1.3
@@ -19,13 +19,74 @@
#include <fstream>
#include "editor/editorobj_group.hxx"
+#include "xml_helper.hxx"
#include "worldobj_group_data.hxx"
+#include "worldobj_data_factory.hxx"
+
+// FIXME: Factory pattern for this would be nice
+#include "exit_data.hxx"
+#include "entrance_data.hxx"
+#include "trap_data.hxx"
+#include "hotspot_data.hxx"
+#include "liquid_data.hxx"
typedef EditorObjLst::iterator EditorObjLstIter;
WorldObjGroupData::WorldObjGroupData ()
{
+}
+
+WorldObjGroupData::WorldObjGroupData (xmlDocPtr doc, xmlNodePtr cur)
+{
+ cur = cur->children;
+
+ std::cout << "WorldObjGroupData::WorldObjGroupData (xmlDocPtr doc,
xmlNodePtr cur)" << std::endl;
+
+ while (cur != NULL)
+ {
+ if (xmlIsBlankNode(cur))
+ {
+ cur = cur->next;
+ continue;
+ }
+
+ std::cout << "Obj: " << cur->name << std::endl;
+
+ if (strcmp((char*)cur->name, "exit") == 0)
+ {
+ add (new ExitData (doc, cur));
+ }
+ else if (strcmp((char*)cur->name, "entrance") == 0)
+ {
+ add (new EntranceData (doc, cur));
+ }
+ else if (strcmp((char*)cur->name, "trap") == 0)
+ {
+ add (new TrapData (doc, cur));
+ }
+ else if (strcmp((char*)cur->name, "hotspot") == 0)
+ {
+ add(new HotspotData (doc, cur));
+ }
+ else if (strcmp((char*)cur->name, "liquid") == 0)
+ {
+ add(new LiquidData (doc, cur));
+ }
+ else if (strcmp((char*)cur->name, "group") == 0)
+ {
+ add(new WorldObjGroupData (doc, cur));
+ }
+ else if (strcmp ((char*)cur->name, "worldobj") == 0)
+ {
+ add(WorldObjDataFactory::instance ()->create (doc, cur));
+ }
+ else
+ {
+ printf("WorldObjGroupData: Unhandled: %s\n", (char*)cur->name);
+ }
+ cur = cur->next;
+ }
}
WorldObjGroupData::~WorldObjGroupData ()
Index: worldobj_group_data.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobj_group_data.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- worldobj_group_data.hxx 12 Jun 2002 19:09:38 -0000 1.1
+++ worldobj_group_data.hxx 24 Jun 2002 18:53:14 -0000 1.2
@@ -22,7 +22,7 @@
#include <vector>
#include "worldobj_data.hxx"
-
+#include "libxmlfwd.hxx"
class WorldObjGroupData : public WorldObjData
{
@@ -32,6 +32,7 @@
public:
WorldObjGroupData ();
+ WorldObjGroupData (xmlDocPtr doc, xmlNodePtr cur);
~WorldObjGroupData ();
void add (WorldObjData*);
Index: xml_plf.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/xml_plf.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- xml_plf.cxx 13 Jun 2002 14:25:12 -0000 1.3
+++ xml_plf.cxx 24 Jun 2002 18:53:14 -0000 1.4
@@ -427,44 +427,7 @@
void
XMLPLF::parse_groundpiece(xmlNodePtr cur)
{
- GroundpieceData surface;
-
- surface.gptype = GroundpieceData::GP_GROUND;
-
- char* gptype = (char*)xmlGetProp(cur, (xmlChar*)"type");
- if (gptype)
- {
- surface.gptype = GroundpieceData::string_to_type (gptype);
- free(gptype);
- }
- else
- std::cout << "XMLPLF: groundtype empty" << std::endl;
-
- cur = cur->children;
-
- while (cur != NULL)
- {
- if (xmlIsBlankNode(cur))
- {
- cur = cur->next;
- continue;
- }
-
- if (strcmp((char*)cur->name, "position") == 0)
- {
- surface.pos = XMLhelper::parse_vector(doc, cur);
- }
- else if (strcmp((char*)cur->name, "surface") == 0)
- {
- surface.desc = XMLhelper::parse_surface(doc, cur);
- }
- else
- {
- printf("Unhandled: %s\n", (char*)cur->name);
- }
- cur = cur->next;
- }
- groundpieces.push_back(surface);
+ groundpieces.push_back(GroundpieceData (doc, cur));
}
/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src groundpiece_data.cxx,1.2,1.3 groundpiece_data.hxx,1.3,1.4 worldobj_group_data.cxx,1.2,1.3 worldobj_group_data.hxx,1.1,1.2 xml_plf.cxx,1.3,1.4,
grumbel <=
- Prev by Date:
[Pingus-CVS] [Bug #743] Grouping of groundpieces isn't handled at level loading
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.5,1.6 editor_event.hxx,1.1,1.2 editorobj_group.cxx,1.1,1.2 editorobj_group.hxx,1.3,1.4 object_manager.hxx,1.1,1.2
- Previous by thread:
[Pingus-CVS] [Bug #743] Grouping of groundpieces isn't handled at level loading
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.5,1.6 editor_event.hxx,1.1,1.2 editorobj_group.cxx,1.1,1.2 editorobj_group.hxx,1.3,1.4 object_manager.hxx,1.1,1.2
- Index(es):