[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata starfield_background_da
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata starfield_background_data.cxx,NONE,1.1 starfield_background_data.hxx,NONE,1.1 surface_background_data.cxx,NONE,1.1 surface_background_data.hxx,NONE,1.1 Makefile.am,1.10,1.11 worldobj_group_data.cxx,1.3,1.4 |
Date: |
16 Sep 2002 20:52:24 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/worldobjsdata
In directory dark:/tmp/cvs-serv10634/worldobjsdata
Modified Files:
Makefile.am worldobj_group_data.cxx
Added Files:
starfield_background_data.cxx starfield_background_data.hxx
surface_background_data.cxx surface_background_data.hxx
Log Message:
splitted some more backgrounds
--- NEW FILE: starfield_background_data.cxx ---
// $Id: starfield_background_data.cxx,v 1.1 2002/09/16 20:52:22 torangan 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 <ostream>
#include "../string_converter.hxx"
#include "../xml_helper.hxx"
#include "../editorobjs/starfield_background_obj.hxx"
#include "../worldobjs/starfield_background.hxx"
#include "starfield_background_data.hxx"
namespace WorldObjsData {
StarfieldBackgroundData::StarfieldBackgroundData ()
: small_stars_count(400),
middle_stars_count(200),
large_stars_count(100)
{
}
StarfieldBackgroundData::StarfieldBackgroundData (const
StarfieldBackgroundData& old)
: WorldObjData(old),
small_stars_count(old. small_stars_count),
middle_stars_count(old.middle_stars_count),
large_stars_count(old. large_stars_count)
{
}
StarfieldBackgroundData::StarfieldBackgroundData (xmlDocPtr doc, xmlNodePtr cur)
{
small_stars_count = 100;
middle_stars_count = 50;
large_stars_count = 25;
cur = cur->children;
while (cur)
{
if (xmlIsBlankNode(cur))
{
cur = cur->next;
continue;
}
if (XMLhelper::equal_str(cur->name, "small-stars"))
{
char* count = XMLhelper::get_prop(cur, "count");
if (count)
{
small_stars_count = StringConverter::to_int(count);
xmlFree(count);
}
}
else if (XMLhelper::equal_str(cur->name, "middle-stars"))
{
char* count = XMLhelper::get_prop(cur, "count");
if (count)
{
middle_stars_count = StringConverter::to_int(count);
xmlFree(count);
}
}
else if (XMLhelper::equal_str(cur->name, "large-stars"))
{
char* count = XMLhelper::get_prop(cur, "count");
if (count)
{
large_stars_count = StringConverter::to_int(count);
xmlFree(count);
}
}
else
{
std::cout << "StarfildBackgroundData:create: Unhandled tag: " <<
cur->name << std::endl;
}
cur = cur->next;
}
UNUSED_ARG(doc);
}
void
StarfieldBackgroundData::write_xml(std::ostream& xml)
{
xml << "<background type=\"starfield\">\n"
<< " <small-stars count=\"" << small_stars_count << "\"/>\n"
<< " <middle-stars count=\"" << middle_stars_count << "\"/>\n"
<< " <large-stars count=\"" << large_stars_count << "\"/>\n"
<< "</background>\n"
<< std::endl;
}
WorldObj*
StarfieldBackgroundData::create_WorldObj ()
{
return new WorldObjs::StarfieldBackground(this);
}
EditorObjLst
StarfieldBackgroundData::create_EditorObj ()
{
return EditorObjLst(1, new EditorObjs::StarfieldBackgroundObj(this));
}
} // namespace WorldObjsData
/* EOF */
--- NEW FILE: starfield_background_data.hxx ---
// $Id: starfield_background_data.hxx,v 1.1 2002/09/16 20:52:22 torangan 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_WORLDOBJSDATA_STARFIELD_BACKGROUND_DATA_HXX
#define HEADER_PINGUS_WORLDOBJSDATA_STARFIELD_BACKGROUND_DATA_HXX
#include "../worldobj_data.hxx"
#include "../libxmlfwd.hxx"
namespace WorldObjsData {
class StarfieldBackgroundData : public WorldObjData
{
public:
int small_stars_count;
int middle_stars_count;
int large_stars_count;
StarfieldBackgroundData ();
StarfieldBackgroundData (const StarfieldBackgroundData& old);
StarfieldBackgroundData (xmlDocPtr doc, xmlNodePtr cur);
void write_xml (std::ostream& xml);
WorldObj* create_WorldObj ();
EditorObjLst create_EditorObj ();
private:
StarfieldBackgroundData operator= (const StarfieldBackgroundData&);
};
} // namespace WorldObjsData
#endif
/* EOF */
--- NEW FILE: surface_background_data.cxx ---
// $Id: surface_background_data.cxx,v 1.1 2002/09/16 20:52:22 torangan 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 <ostream>
#include "../xml_helper.hxx"
#include "../editorobjs/surface_background_obj.hxx"
#include "../worldobjs/surface_background.hxx"
#include "surface_background_data.hxx"
namespace WorldObjsData {
SurfaceBackgroundData::SurfaceBackgroundData () : para_x(0.5),
para_y(0.5),
pos(CL_Vector(0, 0, -150)),
scroll_x(0.0),
scroll_y(0.0),
color(Color(0,0,0,0)),
stretch_x(false),
stretch_y(false)
{
}
SurfaceBackgroundData::SurfaceBackgroundData (const SurfaceBackgroundData& old)
: WorldObjData(old),
desc(old.desc),
para_x(old.para_x),
para_y(old.para_y),
pos(old.pos),
scroll_x(old.scroll_x),
scroll_y(old.scroll_y),
color(old.color),
stretch_x(old.stretch_x),
stretch_y(old.stretch_y)
{
}
void
SurfaceBackgroundData::write_xml (std::ostream& xml)
{
xml << "<background type=\"surface\">\n";
XMLhelper::write_desc_xml(xml, desc);
xml << " <color>\n"
<< " <red>" << color.red << "</red>\n"
<< " <green>" << color.green << "</green>\n"
<< " <blue>" << color.blue << "</blue>\n"
<< " <alpha>" << color.alpha << "</alpha>\n"
<< " </color>\n"
<< " <scroll-x>" << scroll_x << "</scroll-x>\n"
<< " <scroll-y>" << scroll_y << "</scroll-y>\n"
<< " <para-x>" << para_x << "</para-x>\n"
<< " <para-y>" << para_y << "</para-y>\n"
<< " <stretch-x>" << stretch_x << "</stretch-x>\n"
<< " <stretch-y>" << stretch_y << "</stretch-y>\n";
XMLhelper::write_vector_xml(xml, pos);
xml << "</background>\n"
<< std::endl;
}
SurfaceBackgroundData::SurfaceBackgroundData (xmlDocPtr doc, xmlNodePtr cur)
{
pos.z = -150;
cur = cur->children;
while (cur)
{
if (xmlIsBlankNode(cur))
{
cur = cur->next;
continue;
}
if (XMLhelper::equal_str(cur->name, "surface"))
{
desc = XMLhelper::parse_surface(doc, cur);
}
else if (XMLhelper::equal_str(cur->name, "color"))
{
color = XMLhelper::parse_color(doc, cur);
}
else if (XMLhelper::equal_str(cur->name, "para-x"))
{
para_x = XMLhelper::parse_float(doc, cur);
}
else if (XMLhelper::equal_str(cur->name, "para-y"))
{
para_y = XMLhelper::parse_float(doc, cur);
}
else if (XMLhelper::equal_str(cur->name, "scroll-x"))
{
scroll_x = XMLhelper::parse_float(doc, cur);
}
else if (XMLhelper::equal_str(cur->name, "scroll-y"))
{
scroll_y = XMLhelper::parse_float(doc, cur);
}
else if (XMLhelper::equal_str(cur->name, "stretch-x"))
{
stretch_x = XMLhelper::parse_float(doc, cur);
}
else if (XMLhelper::equal_str(cur->name, "stretch-y"))
{
stretch_y = XMLhelper::parse_float(doc, cur);
}
else if (XMLhelper::equal_str(cur->name, "position"))
{
pos = XMLhelper::parse_vector(doc, cur);
}
else
{
std::cout << "XMLPLF::parse_background(): Unhandled: " << cur->name
<< std::endl;
}
cur = cur->next;
}
}
WorldObj*
SurfaceBackgroundData::create_WorldObj ()
{
return new WorldObjs::SurfaceBackground(this);
}
EditorObjLst
SurfaceBackgroundData::create_EditorObj ()
{
EditorObjLst lst;
lst.push_back(new EditorObjs::SurfaceBackgroundObj(this));
return lst;
}
} // namespace WorldObjsData
/* EOF */
--- NEW FILE: surface_background_data.hxx ---
// $Id: surface_background_data.hxx,v 1.1 2002/09/16 20:52:22 torangan 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_WORLDOBJSDATA_SURFACE_BACKGROUND_DATA_HXX
#define HEADER_PINGUS_WORLDOBJSDATA_SURFACE_BACKGROUND_DATA_HXX
#include <ClanLib/Core/Math/cl_vector.h>
#include "../worldobj_data.hxx"
#include "../color.hxx"
#include "../res_descriptor.hxx"
#include "../libxmlfwd.hxx"
namespace WorldObjsData {
class SurfaceBackgroundData : public WorldObjData
{
public:
ResDescriptor desc;
float para_x;
float para_y;
/** Position of the background, only the z_pos is really used. */
CL_Vector pos;
/** The amount of pixel the background is scrolled each frame in x
direction. */
float scroll_x;
/** The amount of pixel the background is scrolled each frame in x
direction. */
float scroll_y;
/** fill_rect() components
An fill_rect() can be drawn over the background, the following
for components are passed to the fill_rect() call. */
Color color;
/// Stretch the background to the full screen size in x direction
bool stretch_x;
/// Stretch the background to the full screen size in x direction
bool stretch_y;
public:
/// Init all fields with some usefull defaults values.
SurfaceBackgroundData ();
/** Parse the xml snip and return a newly allocated
SurfaceBackgroundData*, the user is responsible to delete the
object */
SurfaceBackgroundData (xmlDocPtr doc, xmlNodePtr cur);
SurfaceBackgroundData (const SurfaceBackgroundData& old);
/** Write the content of this object formated as xml to the given
stream */
void write_xml (std::ostream& xml);
WorldObj* create_WorldObj ();
EditorObjLst create_EditorObj ();
private:
SurfaceBackgroundData operator= (const SurfaceBackgroundData&);
};
} // namespace WorldObjsData
#endif
/* EOF */
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Makefile.am 16 Sep 2002 20:31:09 -0000 1.10
+++ Makefile.am 16 Sep 2002 20:52:22 -0000 1.11
@@ -31,6 +31,8 @@
smasher_data.cxx smasher_data.hxx \
solid_color_background_data.cxx solid_color_background_data.hxx \
spike_data.cxx spike_data.hxx \
+ starfield_background_data.cxx starfield_background_data.hxx \
+ surface_background_data.cxx surface_background_data.hxx \
switch_door_data.cxx switch_door_data.hxx \
teleporter_data.cxx teleporter_data.hxx \
worldobj_group_data.hxx worldobj_group_data.cxx \
Index: worldobj_group_data.cxx
===================================================================
RCS file:
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/worldobj_group_data.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- worldobj_group_data.cxx 15 Sep 2002 21:49:58 -0000 1.3
+++ worldobj_group_data.cxx 16 Sep 2002 20:52:22 -0000 1.4
@@ -51,7 +51,8 @@
}
WorldObjGroupData::WorldObjGroupData (const WorldObjGroupData& data)
- : objs (data.objs)
+ : WorldObjData(data),
+ objs (data.objs)
{
// FIXME: no deep copy
std::cout << "WorldObjGroupData::WorldObjGroupData (const
WorldObjGroupData&): fixme no deep copy" << std::endl;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata starfield_background_data.cxx,NONE,1.1 starfield_background_data.hxx,NONE,1.1 surface_background_data.cxx,NONE,1.1 surface_background_data.hxx,NONE,1.1 Makefile.am,1.10,1.11 worldobj_group_data.cxx,1.3,1.4,
torangan <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src plt_xml.hxx,1.5,1.6 worldobj_data_factory.cxx,1.18,1.19
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/editorobjs starfield_background_obj.cxx,NONE,1.1 starfield_background_obj.hxx,NONE,1.1 surface_background_obj.cxx,NONE,1.1 surface_background_obj.hxx,NONE,1.1 Makefile.am,1.7,1.8 solid_color_background_obj.cxx,1.1,1.2
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src plt_xml.hxx,1.5,1.6 worldobj_data_factory.cxx,1.18,1.19
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/editorobjs starfield_background_obj.cxx,NONE,1.1 starfield_background_obj.hxx,NONE,1.1 surface_background_obj.cxx,NONE,1.1 surface_background_obj.hxx,NONE,1.1 Makefile.am,1.7,1.8 solid_color_background_obj.cxx,1.1,1.2
- Index(es):