[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/editor editor_groundpiece_obj.cxx,1.1
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/editor editor_groundpiece_obj.cxx,1.10,1.11 plfobj.cxx,1.10,1.11 sprite_editorobj.cxx,1.4,1.5 sprite_editorobj.hxx,1.4,1.5 start_pos.cxx,1.5,1.6 weather_obj.cxx,1.6,1.7 |
Date: |
10 Sep 2002 14:33:09 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/editor
In directory dark:/tmp/cvs-serv25283/editor
Modified Files:
editor_groundpiece_obj.cxx plfobj.cxx sprite_editorobj.cxx
sprite_editorobj.hxx start_pos.cxx weather_obj.cxx
Log Message:
well, not a nice fix for the SpriteObj reference problem, but a working one.
a better solution might be to sync the position data of spriteobj and the
editorobj on a write call, since its not needed before
Index: editor_groundpiece_obj.cxx
===================================================================
RCS file:
/usr/local/cvsroot/Games/Pingus/src/editor/editor_groundpiece_obj.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- editor_groundpiece_obj.cxx 4 Sep 2002 14:55:12 -0000 1.10
+++ editor_groundpiece_obj.cxx 10 Sep 2002 14:33:07 -0000 1.11
@@ -25,8 +25,9 @@
EditorGroundpieceObj::EditorGroundpieceObj(const GroundpieceData& data)
: GroundpieceData (data),
- SpriteEditorObj (desc, pos)
+ SpriteEditorObj (desc)
{
+ pos_ref = &pos;
}
EditorObj*
Index: plfobj.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/plfobj.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- plfobj.cxx 6 Sep 2002 17:33:29 -0000 1.10
+++ plfobj.cxx 10 Sep 2002 14:33:07 -0000 1.11
@@ -26,9 +26,10 @@
using namespace std;
EntranceObj::EntranceObj(const EntranceData& data)
- : SpriteEditorObj (pos),
- EntranceData (data)
+ : EntranceData (data)
{
+ pos_ref = &pos;
+
std::cout << "EntranceObj::EntranceObj(const EntranceData& data): "
<< type << std::endl;
@@ -97,7 +98,7 @@
}
ExitObj::ExitObj(const ExitData& data)
- : SpriteEditorObj (data.desc.res_name, data.desc.datafile, pos),
+ : SpriteEditorObj (data.desc.res_name, data.desc.datafile, &pos),
ExitData (data)
{
sprite.set_align_center_bottom ();
@@ -129,7 +130,7 @@
LiquidObj::LiquidObj(const LiquidData& data)
- : SpriteEditorObj (data.desc.res_name, data.desc.datafile, pos),
+ : SpriteEditorObj (data.desc.res_name, data.desc.datafile),
LiquidData (data)
{
if (old_width_handling)
@@ -137,6 +138,8 @@
width = (width + sprite.get_width ()) / sprite.get_width ();
old_width_handling = false;
}
+
+ pos_ref = &pos;
}
EditorObj*
Index: sprite_editorobj.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/sprite_editorobj.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sprite_editorobj.cxx 6 Sep 2002 17:33:29 -0000 1.4
+++ sprite_editorobj.cxx 10 Sep 2002 14:33:07 -0000 1.5
@@ -17,18 +17,23 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <assert.h>
#include <ClanLib/Display/Display/surfaceprovider.h>
#include "editor_view.hxx"
#include "sprite_editorobj.hxx"
+SpriteEditorObj::SpriteEditorObj ()
+ : pos_ref (0)
+{
+}
-SpriteEditorObj::SpriteEditorObj (CL_Vector& arg_pos)
+SpriteEditorObj::SpriteEditorObj (CL_Vector* arg_pos)
: pos_ref (arg_pos)
{
}
SpriteEditorObj::SpriteEditorObj (const ResDescriptor& desc,
- CL_Vector& arg_pos)
+ CL_Vector* arg_pos)
: sprite (desc),
pos_ref (arg_pos)
{
@@ -36,15 +41,16 @@
SpriteEditorObj::SpriteEditorObj (const std::string& sur_name,
const std::string& datafile,
- CL_Vector& arg_pos)
+ CL_Vector* arg_pos)
: sprite (sur_name, datafile),
pos_ref (arg_pos)
{
}
-SpriteEditorObj::SpriteEditorObj (const SpriteEditorObj& old) :
RectEditorObj(old),
-
sprite(old.sprite),
-
pos_ref(old.pos_ref)
+SpriteEditorObj::SpriteEditorObj (const SpriteEditorObj& old)
+ : RectEditorObj(old),
+ sprite(old.sprite),
+ pos_ref(old.pos_ref)
{
}
@@ -61,27 +67,32 @@
}
float
-SpriteEditorObj::get_z_pos() {
- return pos_ref.z;
+SpriteEditorObj::get_z_pos()
+{
+ assert (pos_ref);
+ return pos_ref->z;
}
void
SpriteEditorObj::draw(EditorView * view)
{
- view->draw (sprite, pos_ref);
+ assert (pos_ref);
+ view->draw (sprite, *pos_ref);
}
void
SpriteEditorObj::set_position_offset(const CL_Vector& offset)
{
- pos_ref += offset;
+ assert (pos_ref);
+ *pos_ref += offset;
}
CL_Vector
SpriteEditorObj::get_upper_left_corner()
{
- CL_Vector pos(pos_ref);
+ assert (pos_ref);
+ CL_Vector pos(*pos_ref);
return pos + CL_Vector(sprite.get_x_align (), sprite.get_y_align ());
}
@@ -98,11 +109,11 @@
float r, g, b, a;
// Position relative to the surface, not world
CL_Vector provider_pos = pos;
- provider_pos -= pos_ref;
+ provider_pos -= *pos_ref;
provider->get_pixel (int(provider_pos.x), int(provider_pos.y), &r, &g,
&b, &a);
//std::cout << "Color: " << r << " " << g << " " << b << " " << a <<
std::endl;
- return (a >= 0.5);
+ return (a >= 0.0f);
}
else
{
Index: sprite_editorobj.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/sprite_editorobj.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sprite_editorobj.hxx 6 Sep 2002 17:33:29 -0000 1.4
+++ sprite_editorobj.hxx 10 Sep 2002 14:33:07 -0000 1.5
@@ -29,17 +29,25 @@
{
protected:
Sprite sprite;
- CL_Vector& pos_ref;
+
+ /** Pointer to the position member of the child object
+
+ FIXME: A bit ugly, but requires less changes than a full blown
+ FIXME: get/set handling, it also looks nicer */
+ CL_Vector* pos_ref;
public:
- SpriteEditorObj (CL_Vector& arg_pos);
+ /** Empty constructor, you *must* initialise pos_ref manually */
+ SpriteEditorObj ();
+
+ SpriteEditorObj (CL_Vector* arg_pos);
SpriteEditorObj (const std::string& sur_name,
const std::string& datafile,
- CL_Vector& arg_pos);
+ CL_Vector* arg_pos = 0);
SpriteEditorObj (const ResDescriptor&,
- CL_Vector& arg_pos);
+ CL_Vector* arg_pos = 0);
/// Return the object width
virtual int get_width() { return sprite.get_width (); }
Index: start_pos.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/start_pos.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- start_pos.cxx 2 Jul 2002 13:36:07 -0000 1.5
+++ start_pos.cxx 10 Sep 2002 14:33:07 -0000 1.6
@@ -22,11 +22,13 @@
#include "start_pos.hxx"
StartPos::StartPos(int arg_x_pos, int arg_y_pos)
- : SpriteEditorObj("editor/start_pos", "core", pos)
+ : SpriteEditorObj("editor/start_pos", "core")
{
pos.x = arg_x_pos;
pos.y = arg_y_pos;
pos.z = 1000;
+
+ pos_ref = &pos;
}
void
Index: weather_obj.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/weather_obj.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- weather_obj.cxx 4 Sep 2002 14:55:12 -0000 1.6
+++ weather_obj.cxx 10 Sep 2002 14:33:07 -0000 1.7
@@ -23,7 +23,6 @@
#include "weather_obj.hxx"
WeatherObj::WeatherObj(const WeatherData& data)
- : SpriteEditorObj (pos)
{
type = data.type;
pos = CL_Vector(0,0,200);
@@ -42,6 +41,8 @@
std::cout << "WeatherObj: Unknown weather type: " << type << std::endl;
sprite = Sprite("editor/weather_rain", "core");
}
+
+ pos_ref = &pos;
}
WeatherObj::~WeatherObj()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/editor editor_groundpiece_obj.cxx,1.10,1.11 plfobj.cxx,1.10,1.11 sprite_editorobj.cxx,1.4,1.5 sprite_editorobj.hxx,1.4,1.5 start_pos.cxx,1.5,1.6 weather_obj.cxx,1.6,1.7,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/backgrounds starfield_background.hxx,1.8,1.9 surface_background_data.hxx,1.9,1.10 thunderstorm_background_data.hxx,1.8,1.9
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src pingus_resource.cxx,1.14,1.15
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/backgrounds starfield_background.hxx,1.8,1.9 surface_background_data.hxx,1.9,1.10 thunderstorm_background_data.hxx,1.8,1.9
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src pingus_resource.cxx,1.14,1.15
- Index(es):