[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 379 - trunk/src
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 379 - trunk/src |
Date: |
Wed, 02 Jun 2004 17:18:40 +0200 |
Author: grumbel
Date: 2004-06-02 17:18:40 +0200 (Wed, 02 Jun 2004)
New Revision: 379
Modified:
trunk/src/flexlay_wrap.i
trunk/src/object_brush.cxx
trunk/src/object_brush.hxx
trunk/src/object_layer.cxx
trunk/src/object_layer.hxx
trunk/src/object_selector.cxx
trunk/src/objmap_object.cxx
trunk/src/objmap_object.hxx
trunk/src/objmap_select_tool.cxx
trunk/src/objmap_select_tool.hxx
trunk/src/objmap_sprite_object.cxx
trunk/src/objmap_sprite_object.hxx
trunk/src/supertux.py
Log:
- fixed ObjMapObjects a bit more
- implemented loading/saving of objects for supertux
Modified: trunk/src/flexlay_wrap.i
===================================================================
--- trunk/src/flexlay_wrap.i 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/flexlay_wrap.i 2004-06-02 15:18:40 UTC (rev 379)
@@ -49,6 +49,8 @@
#include "tilemap_paint_tool.hxx"
#include "tilemap_select_tool.hxx"
#include "objmap_select_tool.hxx"
+#include "objmap_sprite_object.hxx"
+#include "objmap_object.hxx"
#include "zoom_tool.hxx"
#include "netpanzer.hxx"
@@ -57,6 +59,7 @@
%include "std_string.i"
%include "std_vector.i"
%template(std_vector_int) std::vector<int>;
+%template(std_vector_ObjMapObject) std::vector<ObjMapObject>;
%include "clanlib.i"
%include "scripting/editor.hxx"
@@ -98,6 +101,8 @@
%include "tilemap_paint_tool.hxx"
%include "tilemap_select_tool.hxx"
%include "objmap_select_tool.hxx"
+%include "objmap_sprite_object.hxx"
+%include "objmap_object.hxx"
%include "zoom_tool.hxx"
%include "graphic_context_state.hxx"
Modified: trunk/src/object_brush.cxx
===================================================================
--- trunk/src/object_brush.cxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/object_brush.cxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -50,14 +50,11 @@
return impl->sprite;
}
-ObjMapObject
-ObjectBrush::add_to_layer(ObjectLayer layer, const CL_Point& pos)
+ObjMapSpriteObject
+ObjectBrush::to_sprite_object(const CL_Point& pos)
{
- ObjMapSpriteObject obj(pos, impl->data, impl->sprite);
- ObjectAddCommand command(layer);
- command.add_object(obj.to_object());
- Workspace::current().get_map().execute(command.to_command());
- return obj.to_object();
+ ObjMapSpriteObject obj(impl->sprite, pos, impl->data);
+ return obj;
}
/* EOF */
Modified: trunk/src/object_brush.hxx
===================================================================
--- trunk/src/object_brush.hxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/object_brush.hxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -21,8 +21,10 @@
#define HEADER_OBJECT_BRUSH_HXX
#include <ClanLib/Display/sprite.h>
+#include <ClanLib/Core/Math/point.h>
#include "object_layer.hxx"
#include "objmap_object.hxx"
+#include "objmap_sprite_object.hxx"
#include "meta_data.hxx"
class ObjectBrushImpl;
@@ -36,7 +38,7 @@
CL_Sprite get_sprite();
- ObjMapObject add_to_layer(ObjectLayer layer, const CL_Point& pos);
+ ObjMapSpriteObject to_sprite_object(const CL_Point& pos);
private:
SharedPtr<ObjectBrushImpl> impl;
};
Modified: trunk/src/object_layer.cxx
===================================================================
--- trunk/src/object_layer.cxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/object_layer.cxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -32,7 +32,7 @@
class ObjectLayerImpl : public LayerImpl
{
public:
- ObjectLayer::Objs objects;
+ ObjectLayer::Objects objects;
CL_SlotContainer slots;
ObjectLayerImpl() {}
@@ -54,7 +54,7 @@
void
ObjectLayerImpl::draw(EditorMapComponent* parent)
{
- for(ObjectLayer::Objs::iterator i = objects.begin(); i != objects.end(); ++i)
+ for(ObjectLayer::Objects::iterator i = objects.begin(); i != objects.end();
++i)
{
(*i).draw();
}
@@ -63,7 +63,7 @@
ObjMapObject
ObjectLayer::find_object(const CL_Point& click_pos)
{
- for(Objs::reverse_iterator i = impl->objects.rbegin(); i !=
impl->objects.rend(); ++i)
+ for(Objects::reverse_iterator i = impl->objects.rbegin(); i !=
impl->objects.rend(); ++i)
{
CL_Rect rect = (*i).get_bound_rect();
@@ -76,7 +76,7 @@
void
ObjectLayer::delete_object(const ObjMapObject& obj)
{
- for(Objs::iterator i = impl->objects.begin(); i != impl->objects.end(); ++i)
+ for(Objects::iterator i = impl->objects.begin(); i != impl->objects.end();
++i)
{
if (obj == (*i))
{
@@ -86,12 +86,12 @@
}
}
-ObjectLayer::Objs
+ObjectLayer::Objects
ObjectLayer::get_selection(const CL_Rect& rect)
{
- Objs selection;
+ Objects selection;
- for(Objs::iterator i = impl->objects.begin(); i != impl->objects.end(); ++i)
+ for(Objects::iterator i = impl->objects.begin(); i != impl->objects.end();
++i)
{
// FIXME:
if (rect.is_inside((*i).get_pos()))
@@ -103,7 +103,7 @@
return selection;
}
-ObjectLayer::Objs
+ObjectLayer::Objects
ObjectLayer::get_objects()
{
return impl->objects;
Modified: trunk/src/object_layer.hxx
===================================================================
--- trunk/src/object_layer.hxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/object_layer.hxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -37,8 +37,7 @@
class ObjectLayer
{
public:
- typedef ObjMapObject Obj;
- typedef std::vector<ObjMapObject> Objs;
+ typedef std::vector<ObjMapObject> Objects;
static ObjectLayer current_;
@@ -53,7 +52,7 @@
ObjMapObject find_object(const CL_Point& pos);
std::vector<ObjMapObject> get_selection(const CL_Rect& rect);
- Objs get_objects();
+ std::vector<ObjMapObject> get_objects();
Layer to_layer();
Modified: trunk/src/object_selector.cxx
===================================================================
--- trunk/src/object_selector.cxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/object_selector.cxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -23,6 +23,7 @@
#include "editor_map.hxx"
#include "editor_map_component.hxx"
#include "object_selector.hxx"
+#include "object_add_command.hxx"
#include "editor.hxx"
ObjectSelector::ObjectSelector(const CL_Rect& rect,
@@ -69,9 +70,10 @@
CL_Point target(screen.x -
EditorMapComponent::current()->get_screen_rect().left,
screen.y -
EditorMapComponent::current()->get_screen_rect().top);
- ObjectLayer objmap = ObjectLayer::current();
- brushes[drag_obj].add_to_layer(objmap,
-
EditorMapComponent::current()->screen2world(target));
+ ObjectAddCommand command(ObjectLayer::current());
+ command.add_object(brushes[drag_obj].to_sprite_object
+
(EditorMapComponent::current()->screen2world(target)).to_object());
+ Workspace::current().get_map().execute(command.to_command());
}
drag_obj = -1;
}
Modified: trunk/src/objmap_object.cxx
===================================================================
--- trunk/src/objmap_object.cxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/objmap_object.cxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -53,7 +53,7 @@
}
MetaData
-ObjMapObject::get_data() const
+ObjMapObject::get_metadata() const
{
if (impl.get())
return impl->data;
Modified: trunk/src/objmap_object.hxx
===================================================================
--- trunk/src/objmap_object.hxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/objmap_object.hxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -38,10 +38,8 @@
CL_Point get_pos() const;
void set_pos(const CL_Point& p);
- MetaData get_data() const;
+ MetaData get_metadata() const;
- int get_handle() const;
-
void draw();
CL_Rect get_bound_rect() const;
Modified: trunk/src/objmap_select_tool.cxx
===================================================================
--- trunk/src/objmap_select_tool.cxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/objmap_select_tool.cxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -182,7 +182,7 @@
switch(state)
{
default:
- ObjectLayer::Obj obj = objmap.find_object(pos);
+ ObjMapObject obj = objmap.find_object(pos);
if (!obj.is_null())
{
Modified: trunk/src/objmap_select_tool.hxx
===================================================================
--- trunk/src/objmap_select_tool.hxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/objmap_select_tool.hxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -31,7 +31,7 @@
class ObjMapSelectTool
{
public:
- typedef std::vector<ObjectLayer::Obj> Selection;
+ typedef std::vector<ObjMapObject> Selection;
ObjMapSelectTool();
~ObjMapSelectTool();
Modified: trunk/src/objmap_sprite_object.cxx
===================================================================
--- trunk/src/objmap_sprite_object.cxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/objmap_sprite_object.cxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -32,9 +32,13 @@
ObjMapObject* duplicate(int handle_);
};
-ObjMapSpriteObject::ObjMapSpriteObject(const CL_Point& pos_,
- const MetaData& data_,
- const CL_Sprite& sprite_)
+ObjMapSpriteObject::ObjMapSpriteObject()
+{
+}
+
+ObjMapSpriteObject::ObjMapSpriteObject(const CL_Sprite& sprite_,
+ const CL_Point& pos_,
+ const MetaData& data_)
: impl(new ObjMapSpriteObjectImpl())
{
impl->pos = pos_;
Modified: trunk/src/objmap_sprite_object.hxx
===================================================================
--- trunk/src/objmap_sprite_object.hxx 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/objmap_sprite_object.hxx 2004-06-02 15:18:40 UTC (rev 379)
@@ -21,7 +21,9 @@
#define HEADER_OBJMAP_SPRITE_OBJECT_HXX
#include <ClanLib/Display/sprite.h>
+#include <ClanLib/Core/Math/point.h>
#include "shared_ptr.hxx"
+#include "meta_data.hxx"
#include "objmap_object.hxx"
class ObjMapSpriteObjectImpl;
@@ -30,9 +32,10 @@
class ObjMapSpriteObject
{
public:
- ObjMapSpriteObject(const CL_Point& pos_,
- const MetaData& data_,
- const CL_Sprite& s);
+ ObjMapSpriteObject();
+ ObjMapSpriteObject(const CL_Sprite& s,
+ const CL_Point& pos_,
+ const MetaData& data_);
void flip_horizontal();
void flip_vertical();
Modified: trunk/src/supertux.py
===================================================================
--- trunk/src/supertux.py 2004-06-02 13:12:44 UTC (rev 378)
+++ trunk/src/supertux.py 2004-06-02 15:18:40 UTC (rev 379)
@@ -78,6 +78,13 @@
Tile(config.datadir + 'images/tilesets/' +
image,
CL_Color(255, 0, 0, 128)))
+class BadGuy:
+ type = None
+
+ def __init__(self, type):
+ self.type = type
+
+
class SuperTuxLevel:
filename = None
@@ -118,7 +125,7 @@
tree = sexpr_read_from_file(self.filename)
if tree == None:
- raise "Couldn't load level"
+ raise ("Couldn't load level: ", filename)
data = tree[1:]
@@ -148,10 +155,10 @@
type = i[0]
x = get_value_from_tree(["x", "_"], i[1:], [])
y = get_value_from_tree(["y", "_"], i[1:], [])
- print "Got: ", type, x, y
object = find(game_objects, type)
- ObjectBrush(make_sprite(config.datadir + object[1]),
-
make_metadata(object[0])).add_to_layer(self.objects, CL_Point(x, y))
+
self.objects.add_object(ObjMapSpriteObject(make_sprite(config.datadir +
object[1]),
+ CL_Point(x, y),
+
make_metadata(BadGuy(object[0]))).to_object())
else:
raise "Wrong arguments for SuperTux::___init__"
@@ -197,9 +204,10 @@
f.write(" )\n\n")
f.write(" (objects\n")
- for (obj, data) in []:
- pos = obj.get_pos()
- f.write(" (%s (x %d) (y %d))" % (data, pos.x, pos.y))
+ for obj in self.objects.get_objects():
+ badguy = get_python_object(obj.get_metadata())
+ pos = obj.get_pos()
+ f.write(" (%s (x %d) (y %d))\n" % (badguy.type, pos.x, pos.y))
f.write(" )\n\n")
f.write(" )\n\n;; EOF ;;\n")
@@ -275,7 +283,7 @@
self.objectselector.show(True)
for object in game_objects:
self.objectselector.add_brush(ObjectBrush(make_sprite(config.datadir +
object[1]),
-
make_metadata(object[0])))
+
make_metadata(BadGuy(object[0]))))
def show_objects(self):
self.tileselector.show(False)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 379 - trunk/src,
Ingo Ruhnke <=