[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata worldobj_group_data.cxx
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata worldobj_group_data.cxx,NONE,1.1 worldobj_group_data.hxx,NONE,1.1 Makefile.am,1.7,1.8 prefab_obj_data.cxx,1.2,1.3 |
Date: |
15 Sep 2002 20:33:48 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/worldobjsdata
In directory dark:/tmp/cvs-serv21042/worldobjsdata
Modified Files:
Makefile.am prefab_obj_data.cxx
Added Files:
worldobj_group_data.cxx worldobj_group_data.hxx
Log Message:
- some more prefab stuff
--- NEW FILE: worldobj_group_data.cxx ---
// $Id: worldobj_group_data.cxx,v 1.1 2002/09/15 20:33:45 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 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 <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 "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)
{
cur = XMLhelper::skip_blank (cur->next);
std::cout << "WorldObjGroupData: " << cur->name << std::endl;
objs.push_back (WorldObjDataFactory::instance ()->create (doc, cur));
cur = cur->next;
}
}
WorldObjGroupData::~WorldObjGroupData ()
{
std::cout << "WorldObjGroupData::~WorldObjGroupData ()" << std::endl;
for (ObjsIter i = objs.begin (); i != objs.end (); ++i)
delete *i;
}
void
WorldObjGroupData::add (WorldObjData* data)
{
objs.push_back (data);
}
void
WorldObjGroupData::write_xml (std::ostream& xml)
{
xml << "<group>\n";
for (ObjsIter i = objs.begin (); i != objs.end (); ++i)
(*i)->write_xml (xml);
xml << "</group>\n\n";
}
/** Create an WorldObj from the given data object */
WorldObj*
WorldObjGroupData::create_WorldObj ()
{
std::cout << "WorldObjGroupData::create_WorldObj (): not implemented" <<
std::endl;
return NULL;
}
/** Create an EditorObj from the given data object */
EditorObjLst
WorldObjGroupData::create_EditorObj ()
{
EditorObjLst lst;
EditorObjGroup* group = new EditorObjGroup();
lst.push_back (group);
for (ObjsIter i = objs.begin (); i != objs.end (); ++i)
{
EditorObjLst sublst ((*i)->create_EditorObj ());
for (EditorObjLstIter j = sublst.begin (); j != sublst.end (); ++j)
{
group->add (*j);
}
}
return lst;
}
/* EOF */
--- NEW FILE: worldobj_group_data.hxx ---
// $Id: worldobj_group_data.hxx,v 1.1 2002/09/15 20:33:45 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 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_WORLDOBJ_GROUP_DATA_HXX
#define HEADER_PINGUS_WORLDOBJ_GROUP_DATA_HXX
#include "../worldobj_data.hxx"
#include "../libxmlfwd.hxx"
class WorldObjGroupData : public WorldObjData
{
private:
std::vector<WorldObjData*> objs;
typedef std::vector<WorldObjData*>::iterator ObjsIter;
public:
WorldObjGroupData ();
WorldObjGroupData (xmlDocPtr doc, xmlNodePtr cur);
~WorldObjGroupData ();
void add (WorldObjData*);
void write_xml (std::ostream& xml);
/** Create an WorldObj from the given data object */
WorldObj* create_WorldObj ();
/** Create an EditorObj from the given data object */
EditorObjLst create_EditorObj ();
private:
WorldObjGroupData (const WorldObjGroupData&);
WorldObjGroupData operator= (const WorldObjGroupData&);
};
#endif
/* EOF */
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Makefile.am 15 Sep 2002 16:49:20 -0000 1.7
+++ Makefile.am 15 Sep 2002 20:33:45 -0000 1.8
@@ -26,11 +26,12 @@
ice_block_data.cxx ice_block_data.hxx \
info_box_data.cxx info_box_data.hxx \
laser_exit_data.cxx laser_exit_data.hxx \
- prefab_obj_data.cxx prefab_obj_data.hxx \
+ prefab_obj_data.cxx prefab_obj_data.hxx \
smasher_data.cxx smasher_data.hxx \
solid_color_background_data.cxx solid_color_background_data.hxx \
spike_data.cxx spike_data.hxx \
switch_door_data.cxx switch_door_data.hxx \
- teleporter_data.cxx teleporter_data.hxx
+ teleporter_data.cxx teleporter_data.hxx \
+ worldobj_group_data.hxx worldobj_group_data.cxx
# EOF #
Index: prefab_obj_data.cxx
===================================================================
RCS file:
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/prefab_obj_data.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- prefab_obj_data.cxx 15 Sep 2002 16:49:20 -0000 1.2
+++ prefab_obj_data.cxx 15 Sep 2002 20:33:45 -0000 1.3
@@ -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 "../xml_helper.hxx"
#include "../prefab.hxx"
#include "prefab_obj_data.hxx"
@@ -24,6 +25,36 @@
PrefabObjData::PrefabObjData (xmlDocPtr doc, xmlNodePtr cur)
{
+ char* uid_cstr = XMLhelper::get_prop(cur, "type");
+ if (uid_cstr)
+ uid = uid_cstr;
+ else
+ {
+ std::cout << "PrefabObjData: missing type! Default to test" << std::endl;
+ uid = "test";
+ }
+ xmlFree (uid_cstr);
+
+ cur = cur->children;
+
+ while (cur)
+ {
+ cur = XMLhelper::skip_blank (cur);
+
+ if (XMLhelper::equal_str(cur->name, "position"))
+ {
+ pos = XMLhelper::parse_vector (doc, cur);
+ }
+ else
+ {
+ std::cout << "PrefabObjData(): Unhandled " << cur->name << std::endl;
+ }
+
+ cur = cur->next;
+ }
+
+ // try to load the data for this prefab-uid
+ data = Prefab::create (uid);
}
WorldObj*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata worldobj_group_data.cxx,NONE,1.1 worldobj_group_data.hxx,NONE,1.1 Makefile.am,1.7,1.8 prefab_obj_data.cxx,1.2,1.3,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.98,1.99 prefab.cxx,1.2,1.3 prefab.hxx,1.2,1.3 worldobj_data_factory.cxx,1.12,1.13 xml_helper.hxx,1.9,1.10 xml_plf.cxx,1.14,1.15 xml_plf.hxx,1.6,1.7
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/editor object_manager.cxx,1.31,1.32
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.98,1.99 prefab.cxx,1.2,1.3 prefab.hxx,1.2,1.3 worldobj_data_factory.cxx,1.12,1.13 xml_helper.hxx,1.9,1.10 xml_plf.cxx,1.14,1.15 xml_plf.hxx,1.6,1.7
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/editor object_manager.cxx,1.31,1.32
- Index(es):