[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 320 - in trunk/src: . scripting
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 320 - in trunk/src: . scripting |
Date: |
Sat, 15 May 2004 01:10:14 +0200 |
Author: grumbel
Date: 2004-05-15 01:10:14 +0200 (Sat, 15 May 2004)
New Revision: 320
Modified:
trunk/src/SConstruct
trunk/src/command.hxx
trunk/src/editor.cxx
trunk/src/field.hxx
trunk/src/object_add_command.cxx
trunk/src/object_add_command.hxx
trunk/src/object_move_command.cxx
trunk/src/object_move_command.hxx
trunk/src/paint_command.cxx
trunk/src/paint_command.hxx
trunk/src/python_functor.cxx
trunk/src/scripting/editor.cxx
trunk/src/tile_brush.cxx
trunk/src/tile_brush.hxx
trunk/src/tile_selector.cxx
trunk/src/tilemap_paint_tool.cxx
Log:
- added macro recorder
Modified: trunk/src/SConstruct
===================================================================
--- trunk/src/SConstruct 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/SConstruct 2004-05-14 23:10:14 UTC (rev 320)
@@ -4,12 +4,13 @@
CCFLAGS = '-g -O2 -Wall',
SWIGFLAGS='-c++ -python')
-Depends('flexlay_wrap.cc', ['flexlay.i', 'clanlib.i'])
-
+Depends('flexlay_wrap.cxx', ['flexlay.i', 'clanlib.i'])
+
+env.Command('flexlay_wrap.cxx', 'flexlay.i', "swig -python -c++ $SOURCE")
env.SharedLibrary(
target = '_flexlay',
source = [
- 'flexlay.i',
+ 'flexlay_wrap.cxx',
'command_group.cxx',
'editor.cxx',
'scripting/editor.cxx',
Modified: trunk/src/command.hxx
===================================================================
--- trunk/src/command.hxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/command.hxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -20,6 +20,8 @@
#ifndef HEADER_COMMAND_HXX
#define HEADER_COMMAND_HXX
+#include <iosfwd>
+
/** Command is an abstract base class for all data manipulating
operations on EditorLayer or even EditorMap metedata. Each Command
that manipulates data must provide a way to undo and redo the
@@ -37,6 +39,8 @@
/** Undo the effects caused by execute() */
virtual void undo() =0;
+
+ virtual std::string serialize() =0;
};
#endif
Modified: trunk/src/editor.cxx
===================================================================
--- trunk/src/editor.cxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/editor.cxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -73,6 +73,9 @@
redo_stack.clear();
command->execute();
+
+ //std::cout << command->serialize() << std::endl;
+
undo_stack.push_back(command);
}
Modified: trunk/src/field.hxx
===================================================================
--- trunk/src/field.hxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/field.hxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -44,6 +44,11 @@
{
}
+ Field(const Field<T>& copy)
+ : width(copy.width), height(copy.height), vec(copy.vec)
+ {
+ }
+
/** Creates a new field out of a subsection from an already excisting one
* @param pos_x The position of the old field in the new resized one
* @param pos_y The position of the old field in the new resized one */
@@ -61,6 +66,17 @@
at(pos_x + x, pos_y + y) = arg_field.at(x, y);
}
+ Field<T>& operator=(const Field<T>& copy)
+ {
+ if (this != ©)
+ {
+ width = copy.width;
+ height = copy.height;
+ vec = copy.vec;
+ }
+ return *this;
+ }
+
const T& operator[] (int i) const {
return vec[i];
}
@@ -82,7 +98,7 @@
}
inline const T& at (int x, int y) const {
- return (*this) (x, y);
+ return vec [width*y + x];
}
inline T& at (int x, int y) {
Modified: trunk/src/object_add_command.cxx
===================================================================
--- trunk/src/object_add_command.cxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/object_add_command.cxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -54,4 +54,10 @@
execute();
}
+std::string
+ObjectAddCommand::serialize()
+{
+ return "";
+}
+
/* EOF */
Modified: trunk/src/object_add_command.hxx
===================================================================
--- trunk/src/object_add_command.hxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/object_add_command.hxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -44,6 +44,8 @@
void execute();
void undo();
void redo();
+
+ std::string serialize();
};
#endif
Modified: trunk/src/object_move_command.cxx
===================================================================
--- trunk/src/object_move_command.cxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/object_move_command.cxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -86,4 +86,10 @@
}
}
+std::string
+ObjectMoveCommand::serialize()
+{
+ return "";
+}
+
/* EOF */
Modified: trunk/src/object_move_command.hxx
===================================================================
--- trunk/src/object_move_command.hxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/object_move_command.hxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -47,6 +47,8 @@
void execute();
void redo();
void undo();
+
+ std::string serialize();
};
#endif
Modified: trunk/src/paint_command.cxx
===================================================================
--- trunk/src/paint_command.cxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/paint_command.cxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -19,14 +19,15 @@
#include <assert.h>
#include <iostream>
+#include <sstream>
#include <ClanLib/Core/core_iostream.h>
#include <ClanLib/Core/Math/rect.h>
#include "editor_tilemap.hxx"
#include "paint_command.hxx"
PaintCommand::PaintCommand(EditorTileMap* t, const TileBrush& b)
- : field(t->get_map()), brush(b)
-{
+ : tilemap(t), field(t->get_map()), brush(b)
+{
undo_field = *field;
redo_brush = 0;
@@ -34,7 +35,7 @@
}
PaintCommand::PaintCommand(Field<int>* f, const TileBrush& b)
- : field(f), brush(b)
+ : tilemap(0), field(f), brush(b)
{
undo_field = *field;
@@ -52,6 +53,8 @@
PaintCommand::add_point(const CL_Point& pos)
{
points.push_back(pos);
+ if (tilemap)
+ tilemap->draw_tile(brush, pos);
}
void
@@ -97,4 +100,19 @@
EditorTileMap::draw_tile(field, *undo_brush, pos);
}
+std::string
+PaintCommand::serialize()
+{
+ std::stringstream s;
+
+ s << "_ = PaintCommand(" << tilemap << ", " << &brush << ")" << std::endl;
+ for(Points::iterator i = points.begin(); i != points.end(); ++i)
+ {
+ s << "_.add_paint(" << i->x << ", " << i->y << ")" << std::endl;
+ }
+ s << "_ = None" << std::endl;
+
+ return s.str();
+}
+
/* EOF */
Modified: trunk/src/paint_command.hxx
===================================================================
--- trunk/src/paint_command.hxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/paint_command.hxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -38,6 +38,7 @@
typedef std::vector<CL_Point> Points;
Points points;
+ EditorTileMap* tilemap;
Field<int>* field;
TileBrush brush;
Field<int> undo_field;
@@ -47,7 +48,7 @@
TileBrush* undo_brush;
public:
- PaintCommand(Field<int>* f, const TileBrush& b);
+ PaintCommand(Field<int>* f, const TileBrush& b);
PaintCommand(EditorTileMap* t, const TileBrush& b);
virtual ~PaintCommand();
@@ -57,6 +58,8 @@
void redo();
void undo();
+
+ std::string serialize();
};
#endif
Modified: trunk/src/python_functor.cxx
===================================================================
--- trunk/src/python_functor.cxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/python_functor.cxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -55,15 +55,18 @@
void
PythonFunctor::operator()()
{
- PyObject* arglist = PyTuple_New(0);
- if (PyEval_CallObject(obj, arglist) == 0)
+ if (obj)
{
- if (PyErr_Occurred())
+ PyObject* arglist = PyTuple_New(0);
+ if (PyEval_CallObject(obj, arglist) == 0)
{
- PyErr_Print();
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ }
}
+ Py_DECREF(arglist);
}
- Py_DECREF(arglist);
}
/* EOF */
Modified: trunk/src/scripting/editor.cxx
===================================================================
--- trunk/src/scripting/editor.cxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/scripting/editor.cxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -194,7 +194,7 @@
TileBrush brush(1, 1);
brush.set_opaque();
- brush(0, 0) = i;
+ brush.at(0, 0) = i;
TileMapPaintTool::current()->set_brush(brush);
}
@@ -512,7 +512,7 @@
// FIXME: replace this with a tile selector widget in the tile editor
const TileBrush& brush = TileMapPaintTool::current()->get_brush();
if (brush.get_width() > 0 && brush.get_height() > 0)
- return brush(0, 0);
+ return brush.at(0, 0);
else
return 0;
}
Modified: trunk/src/tile_brush.cxx
===================================================================
--- trunk/src/tile_brush.cxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/tile_brush.cxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -28,13 +28,13 @@
}
TileBrush::TileBrush(const Field<int>& f, int w, int h, int pos_x, int pos_y)
- : Field<int>(f, w, h, pos_x, pos_y)
+ : data(f, w, h, pos_x, pos_y)
{
opaque = false;
}
TileBrush::TileBrush(int w, int h)
- : Field<int>(w, h)
+ : data(w, h)
{
opaque = false;
}
Modified: trunk/src/tile_brush.hxx
===================================================================
--- trunk/src/tile_brush.hxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/tile_brush.hxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -23,12 +23,11 @@
#include "field.hxx"
/** */
-class TileBrush
-#ifndef SWIGPYTHON
- : public Field<int>
-#endif
+class TileBrush
{
private:
+ Field<int> data;
+
/** if true transparent tiles are drawn the same as opaque tiles, ie
erasing tiles formaly on the map and replacing them. If false
transparent tiles are not drawn at all, thus letting the old
@@ -38,11 +37,16 @@
public:
TileBrush();
TileBrush(int w, int h);
-
-#ifndef SWIGPYTHON
TileBrush(const Field<int>& f, int w, int h, int pos_x, int pos_y);
-#endif
+ int get_width() const { return data.get_width(); }
+ int get_height() const { return data.get_height(); }
+
+ const int& at(int x, int y) const { return data.at(x, y); }
+ int& at(int x, int y) { return data.at(x, y); }
+
+ void resize(int w, int h, int pos_x = 0, int pos_y = 0) { data.resize(w, h,
pos_x, pos_y); }
+
void set_opaque() { opaque = true; }
void set_transparent() { opaque = false; }
Modified: trunk/src/tile_selector.cxx
===================================================================
--- trunk/src/tile_selector.cxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/tile_selector.cxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -63,7 +63,7 @@
TileBrush brush(1, 1);
brush.set_opaque();
- brush(0, 0) = mouse_over_tile;
+ brush.at(0, 0) = mouse_over_tile;
TileMapPaintTool::current()->set_brush(brush);
}
@@ -135,7 +135,8 @@
CL_Display::draw_rect(rect, CL_Color(0,0,0,128));
}
- if (int(TileMapPaintTool::current()->get_brush().size()) == 1
+ if (TileMapPaintTool::current()->get_brush().get_width() == 1
+ && TileMapPaintTool::current()->get_brush().get_height() == 1
&& TileMapPaintTool::current()->get_brush().at(0, 0) == i)
{
CL_Display::fill_rect(rect,
Modified: trunk/src/tilemap_paint_tool.cxx
===================================================================
--- trunk/src/tilemap_paint_tool.cxx 2004-05-14 20:27:14 UTC (rev 319)
+++ trunk/src/tilemap_paint_tool.cxx 2004-05-14 23:10:14 UTC (rev 320)
@@ -78,7 +78,7 @@
for(int y = 0; y < brush.get_height(); ++y)
for(int x = 0; x < brush.get_width(); ++x)
{
- Tile* tile = Tileset::current()->create(brush(x, y));
+ Tile* tile = Tileset::current()->create(brush.at(x, y));
if (tile)
{
@@ -127,10 +127,8 @@
case CL_MOUSE_LEFT:
mode = PAINTING;
parent->capture_mouse();
- command = new PaintCommand(tilemap->get_field(), brush);
+ command = new PaintCommand(tilemap, brush);
command->add_point(pos);
-
- tilemap->draw_tile(brush, pos);
last_draw = pos;
break;
@@ -163,7 +161,6 @@
if (current_tile != last_draw)
{
command->add_point(current_tile);
- tilemap->draw_tile(brush, current_tile);
last_draw = current_tile;
}
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 320 - in trunk/src: . scripting,
Ingo Ruhnke <=