[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 355 - trunk/src
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 355 - trunk/src |
Date: |
Fri, 28 May 2004 19:50:39 +0200 |
Author: grumbel
Date: 2004-05-28 19:50:39 +0200 (Fri, 28 May 2004)
New Revision: 355
Modified:
trunk/src/SConstruct
trunk/src/box.cxx
trunk/src/box.hxx
trunk/src/command.hxx
trunk/src/command_group.cxx
trunk/src/command_group.hxx
trunk/src/directory_view.cxx
trunk/src/editor.cxx
trunk/src/editor.hxx
trunk/src/editor.py
trunk/src/flexlay.i
trunk/src/fonts.cxx
trunk/src/fonts.hxx
trunk/src/menu.cxx
trunk/src/menu.hxx
trunk/src/menubar.cxx
trunk/src/menubar.hxx
trunk/src/object_add_command.cxx
trunk/src/object_add_command.hxx
trunk/src/object_delete_command.cxx
trunk/src/object_delete_command.hxx
trunk/src/object_layer.cxx
trunk/src/object_layer.hxx
trunk/src/object_move_command.cxx
trunk/src/object_move_command.hxx
trunk/src/object_selector.cxx
trunk/src/object_transform_command.cxx
trunk/src/object_transform_command.hxx
trunk/src/objmap_object.hxx
trunk/src/objmap_select_tool.cxx
trunk/src/paint_command.cxx
trunk/src/paint_command.hxx
trunk/src/panel.cxx
trunk/src/panel.hxx
trunk/src/scrollbar.cxx
trunk/src/scrollbar.hxx
trunk/src/tilemap_paint_tool.cxx
trunk/src/titlebar.cxx
trunk/src/titlebar.hxx
trunk/src/viewport.cxx
trunk/src/viewport.hxx
trunk/src/window.cxx
trunk/src/window.hxx
Log:
- some command cleanup
Modified: trunk/src/SConstruct
===================================================================
--- trunk/src/SConstruct 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/SConstruct 2004-05-28 17:50:39 UTC (rev 355)
@@ -67,6 +67,7 @@
'blitter.cxx',
'box.cxx',
'command_group.cxx',
+ 'command.cxx',
'editor.cxx',
'editor_map.cxx',
'editor_map_component.cxx',
Modified: trunk/src/box.cxx
===================================================================
--- trunk/src/box.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/box.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/box.hxx
===================================================================
--- trunk/src/box.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/box.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/command.hxx
===================================================================
--- trunk/src/command.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/command.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -21,6 +21,8 @@
#define HEADER_COMMAND_HXX
#include <iosfwd>
+#include "shared_ptr.hxx"
+#include "command_impl.hxx"
/** Command is an abstract base class for all data manipulating
operations on EditorLayer or even EditorMap metedata. Each Command
@@ -30,17 +32,23 @@
{
private:
public:
+ Command();
+ Command(const SharedPtr<CommandImpl>& impl_);
+
/** Execute the command */
- virtual void execute() =0;
-
+ void execute();
+
/** Execute the command a second time after the command got
undo'ed */
- virtual void redo() =0;
+ void redo();
/** Undo the effects caused by execute() */
- virtual void undo() =0;
+ void undo();
- virtual std::string serialize() =0;
+ std::string serialize();
+
+private:
+ SharedPtr<CommandImpl> impl;
};
#endif
Modified: trunk/src/command_group.cxx
===================================================================
--- trunk/src/command_group.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/command_group.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -19,6 +19,11 @@
#include "command_group.hxx"
+class CommandGroupImpl : public CommandImpl
+{
+public:
+};
+
CommandGroup::CommandGroup()
{
Modified: trunk/src/command_group.hxx
===================================================================
--- trunk/src/command_group.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/command_group.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -24,7 +24,7 @@
#include "command.hxx"
/** */
-class CommandGroup : public Command
+class CommandGroup
{
private:
typedef std::vector<Command*> Commands;
Modified: trunk/src/directory_view.cxx
===================================================================
--- trunk/src/directory_view.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/directory_view.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -59,6 +59,7 @@
Items items;
int current_item;
int column_width;
+ int num_columns;
void update_items();
void draw();
@@ -105,10 +106,11 @@
int horizontal_spacing = 10;
int vertical_spacing = 5;
- int num_columns = 4;
int x_pos = 0;
int y_pos = 0;
+ CL_Display::clear(CL_Color(255, 255, 0));
+
int j = 0;
for(Items::iterator i = items.begin(); i != items.begin()+50 && i !=
items.end(); ++i)
{
@@ -153,7 +155,6 @@
int horizontal_spacing = 10;
int vertical_spacing = 5;
- int num_columns = 4;
return (pos.x / (column_width + horizontal_spacing))
+ num_columns * (pos.y / (font.get_height() + vertical_spacing));
@@ -202,6 +203,8 @@
CL_Rect rect = font.bounding_rect(0, 0, i->name + "[]");
column_width = std::max(column_width, rect.get_width());
}
+
+ num_columns = parent->get_width()/column_width;
}
/* EOF */
Modified: trunk/src/editor.cxx
===================================================================
--- trunk/src/editor.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/editor.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -59,14 +59,11 @@
}
void
-Editor::execute(Command* command)
+Editor::execute(Command command)
{
- for(std::vector<Command*>::iterator i = redo_stack.begin();
- i != redo_stack.end(); ++i)
- delete (*i);
redo_stack.clear();
- command->execute();
+ command.execute();
//std::cout << command->serialize() << std::endl;
@@ -78,9 +75,9 @@
{
if (!undo_stack.empty())
{
- Command* command = undo_stack.back();
+ Command command = undo_stack.back();
undo_stack.pop_back();
- command->undo();
+ command.undo();
redo_stack.push_back(command);
}
}
@@ -90,9 +87,9 @@
{
if (!redo_stack.empty())
{
- Command* command = redo_stack.back();
+ Command command = redo_stack.back();
redo_stack.pop_back();
- command->redo();
+ command.redo();
undo_stack.push_back(command);
}
}
Modified: trunk/src/editor.hxx
===================================================================
--- trunk/src/editor.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/editor.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -36,9 +36,11 @@
ToolManager* tool_manager;
- std::vector<Command*> undo_stack;
- std::vector<Command*> redo_stack;
+ typedef std::vector<Command> Commands;
+ Commands undo_stack;
+ Commands redo_stack;
+
static Editor* current_;
public:
static Editor* current() { return current_; }
@@ -56,7 +58,7 @@
/** Execute a command and place it on the undo stack, commands given
to this function will be deleted by the Editor class, so they
have to be new'ed */
- void execute(Command* command);
+ void execute(Command command);
/** Move backward in the undo stack */
void undo();
Modified: trunk/src/editor.py
===================================================================
--- trunk/src/editor.py 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/editor.py 2004-05-28 17:50:39 UTC (rev 355)
@@ -26,7 +26,7 @@
editor = Editor()
gui = editor.get_gui_manager()
-myrect = CL_Rect(128, 128, 600, 400)
+myrect = CL_Rect(CL_Point(0, 56), CL_Size(665, 488))
editor_map = EditorMapComponent(myrect, gui.get_component())
workspace = Workspace(myrect.get_width(), myrect.get_height())
editor_map.set_workspace(workspace)
@@ -44,8 +44,6 @@
print "---My Callback---"
gui.quit()
-g = None
-
def draw_something():
print "Draw something"
brush = TileBrush(2, 2)
@@ -56,7 +54,6 @@
_.add_point(CL_Point(3,3))
_.add_point(CL_Point(4,4))
_.execute()
- g = _
print "Draw something done"
window = Window(CL_Rect(50, 50, 450, 400), "My Window", gui.get_component())
Modified: trunk/src/flexlay.i
===================================================================
--- trunk/src/flexlay.i 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/flexlay.i 2004-05-28 17:50:39 UTC (rev 355)
@@ -12,6 +12,7 @@
#include "paint_command.hxx"
#include "object_move_command.hxx"
#include "object_add_command.hxx"
+#include "object_delete_command.hxx"
#include "scripting/editor.hxx"
#include "tile.hxx"
#include "tile_brush.hxx"
@@ -52,6 +53,7 @@
%include "paint_command.hxx"
%include "object_move_command.hxx"
%include "object_add_command.hxx"
+%include "object_delete_command.hxx"
%include "scripting/editor.hxx"
%include "tile.hxx"
%include "tile_brush.hxx"
@@ -79,5 +81,5 @@
%include "menu.hxx"
%include "menubar.hxx"
%include "scrollbar.hxx"
-
+
/* EOF */
Modified: trunk/src/fonts.cxx
===================================================================
--- trunk/src/fonts.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/fonts.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/fonts.hxx
===================================================================
--- trunk/src/fonts.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/fonts.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/menu.cxx
===================================================================
--- trunk/src/menu.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/menu.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/menu.hxx
===================================================================
--- trunk/src/menu.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/menu.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/menubar.cxx
===================================================================
--- trunk/src/menubar.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/menubar.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/menubar.hxx
===================================================================
--- trunk/src/menubar.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/menubar.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/object_add_command.cxx
===================================================================
--- trunk/src/object_add_command.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/object_add_command.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -21,14 +21,23 @@
#include "objmap_object.hxx"
#include "object_add_command.hxx"
-class ObjectAddCommandImpl
+class ObjectAddCommandImpl : public CommandImpl
{
public:
- ObjectLayer* objmap;
+ ObjectLayer objmap;
ObjMapObject* obj;
+
+ ObjectAddCommandImpl() {}
+ virtual ~ObjectAddCommandImpl() {}
+
+ void execute();
+ void undo();
+ void redo();
+
+ std::string serialize();
};
-ObjectAddCommand::ObjectAddCommand(ObjectLayer* objmap_, ObjMapObject* obj_)
+ObjectAddCommand::ObjectAddCommand(const ObjectLayer& objmap_, ObjMapObject*
obj_)
: impl(new ObjectAddCommandImpl())
{
impl->objmap = objmap_;
@@ -46,27 +55,33 @@
}
void
-ObjectAddCommand::execute()
+ObjectAddCommandImpl::execute()
{
- impl->objmap->add_object(impl->obj);
+ objmap.add_object(obj);
}
void
-ObjectAddCommand::undo()
+ObjectAddCommandImpl::undo()
{
- impl->objmap->delete_object(impl->obj->get_handle());
+ objmap.delete_object(obj->get_handle());
}
void
-ObjectAddCommand::redo()
+ObjectAddCommandImpl::redo()
{
execute();
}
std::string
-ObjectAddCommand::serialize()
+ObjectAddCommandImpl::serialize()
{
return "";
}
+Command
+ObjectAddCommand::to_command()
+{
+ return Command(impl);
+}
+
/* EOF */
Modified: trunk/src/object_add_command.hxx
===================================================================
--- trunk/src/object_add_command.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/object_add_command.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -30,20 +30,16 @@
to supply an Object together with the \a ObjectLayer to which it
should be added. FIXME: position should be part of the command,
not the object */
-class ObjectAddCommand : public Command
+class ObjectAddCommand
{
public:
- ObjectAddCommand(ObjectLayer* o, ObjMapObject* ob);
+ ObjectAddCommand(const ObjectLayer& o, ObjMapObject* ob);
virtual ~ObjectAddCommand();
int get_handle() const;
- void execute();
- void undo();
- void redo();
+ Command to_command();
- std::string serialize();
-
private:
SharedPtr<ObjectAddCommandImpl> impl;
};
Modified: trunk/src/object_delete_command.cxx
===================================================================
--- trunk/src/object_delete_command.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/object_delete_command.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -19,41 +19,64 @@
#include "object_layer.hxx"
#include "objmap_object.hxx"
+#include "command_impl.hxx"
#include "object_delete_command.hxx"
-ObjectDeleteCommand::ObjectDeleteCommand(ObjectLayer* o)
- : objmap(o)
+class ObjectDeleteCommandImpl : public CommandImpl
{
+public:
+ typedef std::vector<ObjMapObject*> Objects;
+
+ ObjectLayer object_layer;
+ Objects objects;
+
+ ObjectDeleteCommandImpl() {}
+ virtual ~ObjectDeleteCommandImpl() {}
+
+ void execute();
+ void redo();
+ void undo();
+};
+
+ObjectDeleteCommand::ObjectDeleteCommand(const ObjectLayer& o)
+{
+ impl->object_layer = o;
}
void
ObjectDeleteCommand::add_object(int id)
{
- objects.push_back(objmap->get_object(id));
+ impl->objects.push_back(impl->object_layer.get_object(id));
}
void
-ObjectDeleteCommand::execute()
+ObjectDeleteCommandImpl::execute()
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
{
- objmap->delete_object((*i)->get_handle());
+ object_layer.delete_object((*i)->get_handle());
}
}
void
-ObjectDeleteCommand::redo()
+ObjectDeleteCommandImpl::redo()
{
execute();
}
void
-ObjectDeleteCommand::undo()
+ObjectDeleteCommandImpl::undo()
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
{
- objmap->add_object(*i);
+ object_layer.add_object(*i);
}
}
+Command
+ObjectDeleteCommand::to_command()
+{
+ return Command(impl);
+}
+
/* EOF */
Modified: trunk/src/object_delete_command.hxx
===================================================================
--- trunk/src/object_delete_command.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/object_delete_command.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -23,26 +23,21 @@
#include <vector>
#include "command.hxx"
-class ObjMapObject;
+class ObjectDeleteCommandImpl;
class ObjectLayer;
-/** */
-class ObjectDeleteCommand : public Command
+/** Delete all objects added with add_object() on the ObjectLayer
+ given at construction time */
+class ObjectDeleteCommand
{
-private:
- ObjectLayer* objmap;
-
- typedef std::vector<ObjMapObject*> Objects;
- Objects objects;
public:
- ObjectDeleteCommand(ObjectLayer* o);
- virtual ~ObjectDeleteCommand() {}
+ ObjectDeleteCommand(const ObjectLayer& o);
void add_object(int id);
- void execute();
- void redo();
- void undo();
+ Command to_command();
+private:
+ SharedPtr<ObjectDeleteCommandImpl> impl;
};
#endif
Modified: trunk/src/object_layer.cxx
===================================================================
--- trunk/src/object_layer.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/object_layer.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -26,7 +26,7 @@
#include "object_layer.hxx"
extern CL_ResourceManager* resources;
-ObjectLayer* ObjectLayer::current_ = 0;
+ObjectLayer ObjectLayer::current_;
class ObjectLayerImpl
{
Modified: trunk/src/object_layer.hxx
===================================================================
--- trunk/src/object_layer.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/object_layer.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -39,10 +39,10 @@
typedef ObjMapObject Obj;
typedef std::vector<ObjMapObject*> Objs;
- static ObjectLayer* current_;
+ static ObjectLayer current_;
- static ObjectLayer* current() { return current_; }
- static void set_current(ObjectLayer* c) { current_ = c; }
+ static ObjectLayer current() { return current_; }
+ static void set_current(ObjectLayer c) { current_ = c; }
ObjectLayer();
~ObjectLayer();
Modified: trunk/src/object_move_command.cxx
===================================================================
--- trunk/src/object_move_command.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/object_move_command.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -21,13 +21,13 @@
#include "objmap_object.hxx"
#include "object_move_command.hxx"
-class ObjectMoveCommandImpl
+class ObjectMoveCommandImpl : public CommandImpl
{
public:
ObjectMoveCommandImpl() {}
- ~ObjectMoveCommandImpl() {}
+ virtual ~ObjectMoveCommandImpl() {}
- ObjectLayer* objmap;
+ ObjectLayer objmap;
struct Obj {
CL_Point old_pos;
@@ -37,9 +37,15 @@
typedef std::vector<Obj> Objects;
Objects objects;
+
+ void execute();
+ void redo();
+ void undo();
+
+ std::string serialize();
};
-ObjectMoveCommand::ObjectMoveCommand(ObjectLayer* o)
+ObjectMoveCommand::ObjectMoveCommand(const ObjectLayer& o)
: impl(new ObjectMoveCommandImpl())
{
impl->objmap = o;
@@ -50,13 +56,13 @@
}
void
-ObjectMoveCommand::execute()
+ObjectMoveCommandImpl::execute()
{
- for(ObjectMoveCommandImpl::Objects::iterator i = impl->objects.begin();
- i != impl->objects.end();
+ for(ObjectMoveCommandImpl::Objects::iterator i = objects.begin();
+ i != objects.end();
++i)
{
- ObjMapObject* obj = impl->objmap->get_object(i->id);
+ ObjMapObject* obj = objmap.get_object(i->id);
if (obj)
{
i->new_pos = obj->get_pos();
@@ -67,7 +73,7 @@
void
ObjectMoveCommand::add_obj(int id)
{
- ObjMapObject* obj = impl->objmap->get_object(id);
+ ObjMapObject* obj = impl->objmap.get_object(id);
if (obj)
{
@@ -79,13 +85,13 @@
}
void
-ObjectMoveCommand::redo()
+ObjectMoveCommandImpl::redo()
{
- for(ObjectMoveCommandImpl::Objects::iterator i = impl->objects.begin();
- i != impl->objects.end();
+ for(ObjectMoveCommandImpl::Objects::iterator i = objects.begin();
+ i != objects.end();
++i)
{
- ObjMapObject* obj = impl->objmap->get_object(i->id);
+ ObjMapObject* obj = objmap.get_object(i->id);
if (obj)
{
obj->set_pos(i->new_pos);
@@ -94,13 +100,13 @@
}
void
-ObjectMoveCommand::undo()
+ObjectMoveCommandImpl::undo()
{
- for(ObjectMoveCommandImpl::Objects::iterator i = impl->objects.begin();
- i != impl->objects.end();
+ for(ObjectMoveCommandImpl::Objects::iterator i = objects.begin();
+ i != objects.end();
++i)
{
- ObjMapObject* obj = impl->objmap->get_object(i->id);
+ ObjMapObject* obj = objmap.get_object(i->id);
if (obj)
{
obj->set_pos(i->old_pos);
@@ -109,9 +115,15 @@
}
std::string
-ObjectMoveCommand::serialize()
+ObjectMoveCommandImpl::serialize()
{
return "";
}
+Command
+ObjectMoveCommand::to_command()
+{
+ return Command(impl);
+}
+
/* EOF */
Modified: trunk/src/object_move_command.hxx
===================================================================
--- trunk/src/object_move_command.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/object_move_command.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -27,20 +27,15 @@
class ObjectMoveCommandImpl;
/** */
-class ObjectMoveCommand : public Command
+class ObjectMoveCommand
{
public:
- ObjectMoveCommand(ObjectLayer* o);
+ ObjectMoveCommand(const ObjectLayer& o);
virtual ~ObjectMoveCommand();
void add_obj(int id);
- void execute();
- void redo();
- void undo();
-
- std::string serialize();
-
+ Command to_command();
private:
SharedPtr<ObjectMoveCommandImpl> impl;
};
Modified: trunk/src/object_selector.cxx
===================================================================
--- trunk/src/object_selector.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/object_selector.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -79,17 +79,15 @@
CL_Point target(screen.x -
EditorMapComponent::current()->get_screen_rect().left,
screen.y -
EditorMapComponent::current()->get_screen_rect().top);
- ObjectLayer* objmap = ObjectLayer::current();
- if (objmap)
- {
- ObjMapObject* obj
- = new
ObjMapSpriteObject(objmap->get_next_object_handle(),
-
EditorMapComponent::current()->screen2world(target),
- drag_obj.data,
- drag_obj.sprite);
- ObjectAddCommand* command = new ObjectAddCommand(objmap,
obj);
- Editor::current()->execute(command);
- }
+ ObjectLayer objmap = ObjectLayer::current();
+
+ ObjMapObject* obj
+ = new ObjMapSpriteObject(objmap.get_next_object_handle(),
+
EditorMapComponent::current()->screen2world(target),
+ drag_obj.data,
+ drag_obj.sprite);
+ ObjectAddCommand command(objmap, obj);
+ Editor::current()->execute(command.to_command());
}
drag_obj.sprite = CL_Sprite();
}
Modified: trunk/src/object_transform_command.cxx
===================================================================
--- trunk/src/object_transform_command.cxx 2004-05-27 20:15:45 UTC (rev
354)
+++ trunk/src/object_transform_command.cxx 2004-05-28 17:50:39 UTC (rev
355)
@@ -19,6 +19,16 @@
#include "object_transform_command.hxx"
+class ObjectTransformCommandImpl : public CommandImpl
+{
+public:
+ typedef std::vector<ObjMapObject*> Objects;
+ Objects objects;
+
+ ObjectTransformCommandImpl() {}
+ virtual ~ObjectTransformCommandImpl() {}
+};
+
ObjectTransformCommand::ObjectTransformCommand()
{
}
Modified: trunk/src/object_transform_command.hxx
===================================================================
--- trunk/src/object_transform_command.hxx 2004-05-27 20:15:45 UTC (rev
354)
+++ trunk/src/object_transform_command.hxx 2004-05-28 17:50:39 UTC (rev
355)
@@ -26,12 +26,8 @@
class ObjMapObject;
/** */
-class ObjectTransformCommand : public Command
+class ObjectTransformCommand
{
-private:
- typedef std::vector<ObjMapObject*> Objects;
- Objects objects;
-
public:
ObjectTransformCommand();
virtual ~ObjectTransformCommand();
Modified: trunk/src/objmap_object.hxx
===================================================================
--- trunk/src/objmap_object.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/objmap_object.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -33,6 +33,7 @@
protected:
CL_Point pos;
MetaData data;
+
public:
ObjMapObject(int handle_, const CL_Point& pos, const MetaData& data);
ObjMapObject(int handle_, const ObjMapObject& obj);
Modified: trunk/src/objmap_select_tool.cxx
===================================================================
--- trunk/src/objmap_select_tool.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/objmap_select_tool.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -69,115 +69,111 @@
void
ObjMapSelectTool::on_mouse_up(const CL_InputEvent& event)
{
- ObjectLayer* objmap = ObjectLayer::current();
- if (objmap)
- {
- EditorMapComponent* parent = EditorMapComponent::current();
+ ObjectLayer objmap = ObjectLayer::current();
- CL_Point pos = parent->screen2world(event.mouse_pos);
+ EditorMapComponent* parent = EditorMapComponent::current();
- switch (event.id)
+ CL_Point pos = parent->screen2world(event.mouse_pos);
+
+ switch (event.id)
+ {
+ case CL_MOUSE_LEFT:
+ switch(state)
{
- case CL_MOUSE_LEFT:
- switch(state)
+ case DRAG:
+ if (move_command)
{
- case DRAG:
- if (move_command)
- {
- Editor::current()->execute(move_command);
- move_command = 0;
- }
- state = NONE;
- parent->release_mouse();
- break;
+ Editor::current()->execute(move_command->to_command());
+ move_command = 0;
+ }
+ state = NONE;
+ parent->release_mouse();
+ break;
- case SELECT:
- state = NONE;
- selection_rect.right = pos.x;
- selection_rect.bottom = pos.y;
- selection_rect.normalize();
+ case SELECT:
+ state = NONE;
+ selection_rect.right = pos.x;
+ selection_rect.bottom = pos.y;
+ selection_rect.normalize();
- selection = objmap->get_selection(selection_rect);
- parent->release_mouse();
- break;
-
- default:
- break;
- }
+ selection = objmap.get_selection(selection_rect);
+ parent->release_mouse();
break;
- case CL_MOUSE_RIGHT:
- {
- PopupMenu* menu = new PopupMenu(CL_Point(event.mouse_pos.x +
parent->get_screen_rect().left,
- event.mouse_pos.y +
parent->get_screen_rect().top),
-
GUIManager::current()->get_component());
- on_popup_menu_display(menu->get_menu());
- }
+ default:
break;
}
+ break;
+
+ case CL_MOUSE_RIGHT:
+ {
+ PopupMenu* menu = new PopupMenu(CL_Point(event.mouse_pos.x +
parent->get_screen_rect().left,
+ event.mouse_pos.y +
parent->get_screen_rect().top),
+
GUIManager::current()->get_component());
+ on_popup_menu_display(menu->get_menu());
+ }
+ break;
}
}
void
ObjMapSelectTool::on_mouse_down(const CL_InputEvent& event)
{
- ObjectLayer* objmap = ObjectLayer::current();
- if (objmap)
- {
- EditorMapComponent* parent = EditorMapComponent::current();
- CL_Point pos = parent->screen2world(event.mouse_pos);
+ ObjectLayer objmap = ObjectLayer::current();
+
+ EditorMapComponent* parent = EditorMapComponent::current();
+ CL_Point pos = parent->screen2world(event.mouse_pos);
- switch (event.id)
+ switch (event.id)
+ {
+ case CL_MOUSE_LEFT:
+ switch(state)
{
- case CL_MOUSE_LEFT:
- switch(state)
- {
- default:
- ObjectLayer::Obj* obj = objmap->find_object(pos);
+ default:
+ ObjectLayer::Obj* obj = objmap.find_object(pos);
- if (obj)
+ if (obj)
+ {
+ if (CL_Keyboard::get_keycode(CL_KEY_LSHIFT))
{
- if (CL_Keyboard::get_keycode(CL_KEY_LSHIFT))
- {
- Selection::iterator i = std::find(selection.begin(),
selection.end(), obj);
- if (i == selection.end())
- selection.push_back(obj);
- else
- selection.erase(i);
- }
+ Selection::iterator i = std::find(selection.begin(),
selection.end(), obj);
+ if (i == selection.end())
+ selection.push_back(obj);
else
- {
- state = DRAG;
- parent->capture_mouse();
- offset = pos - obj->get_pos();
- drag_start = pos;
-
- if (std::find(selection.begin(), selection.end(), obj)
== selection.end())
- { // Clicked object is not in the selection, so we add
it
- selection.clear();
- selection.push_back(obj);
- }
-
- move_command = new ObjectMoveCommand(objmap);
- for (Selection::iterator i = selection.begin(); i !=
selection.end(); ++i)
- {
- move_command->add_obj((*i)->get_handle());
- }
- }
+ selection.erase(i);
}
else
{
- state = SELECT;
- selection_rect = CL_Rect(pos.x, pos.y, pos.x, pos.y);
+ state = DRAG;
parent->capture_mouse();
+ offset = pos - obj->get_pos();
+ drag_start = pos;
+
+ if (std::find(selection.begin(), selection.end(), obj) ==
selection.end())
+ { // Clicked object is not in the selection, so we add it
+ selection.clear();
+ selection.push_back(obj);
+ }
+
+ move_command = new ObjectMoveCommand(objmap);
+ for (Selection::iterator i = selection.begin(); i !=
selection.end(); ++i)
+ {
+ move_command->add_obj((*i)->get_handle());
+ }
}
- break;
}
+ else
+ {
+ state = SELECT;
+ selection_rect = CL_Rect(pos.x, pos.y, pos.x, pos.y);
+ parent->capture_mouse();
+ }
break;
-
- case CL_MOUSE_RIGHT:
- break;
}
+ break;
+
+ case CL_MOUSE_RIGHT:
+ break;
}
}
Modified: trunk/src/paint_command.cxx
===================================================================
--- trunk/src/paint_command.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/paint_command.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -27,7 +27,7 @@
#include "tilemap_layer.hxx"
#include "paint_command.hxx"
-class PaintCommandImpl
+class PaintCommandImpl : public CommandImpl
{
public:
typedef std::vector<CL_Point> Points;
@@ -42,6 +42,13 @@
CL_Point pos;
TileBrush* redo_brush;
TileBrush* undo_brush;
+
+ void execute();
+
+ void redo();
+ void undo();
+
+ std::string serialize();
};
PaintCommand::PaintCommand(TilemapLayer t, const TileBrush& b)
@@ -70,57 +77,57 @@
}
void
-PaintCommand::execute()
+PaintCommandImpl::execute()
{
- assert(!impl->points.empty());
+ assert(!points.empty());
// Calc bounding rect
- CL_Rect rect(impl->points.front().x,
- impl->points.front().y,
- impl->points.front().x + impl->brush.get_width(),
- impl->points.front().y + impl->brush.get_height());
+ CL_Rect rect(points.front().x,
+ points.front().y,
+ points.front().x + brush.get_width(),
+ points.front().y + brush.get_height());
- for(PaintCommandImpl::Points::iterator i = impl->points.begin(); i !=
impl->points.end(); ++i)
+ for(PaintCommandImpl::Points::iterator i = points.begin(); i !=
points.end(); ++i)
{
rect.left = std::min(rect.left, (*i).x);
rect.top = std::min(rect.top, (*i).y);
- rect.right = std::max(rect.right, (*i).x + impl->brush.get_width());
- rect.bottom = std::max(rect.bottom, (*i).y + impl->brush.get_height());
+ rect.right = std::max(rect.right, (*i).x + brush.get_width());
+ rect.bottom = std::max(rect.bottom, (*i).y + brush.get_height());
}
- impl->pos.x = rect.left;
- impl->pos.y = rect.top;
+ pos.x = rect.left;
+ pos.y = rect.top;
- impl->redo_brush = new TileBrush(*(impl->tilemap.get_field()),
rect.get_width(), rect.get_height(),
- -impl->pos.x, -impl->pos.y);
- impl->undo_brush = new TileBrush(impl->undo_field, rect.get_width(),
rect.get_height(),
- -impl->pos.x, -impl->pos.y);
+ redo_brush = new TileBrush(*(tilemap.get_field()), rect.get_width(),
rect.get_height(),
+ -pos.x, -pos.y);
+ undo_brush = new TileBrush(undo_field, rect.get_width(), rect.get_height(),
+ -pos.x, -pos.y);
- impl->redo_brush->set_opaque();
- impl->undo_brush->set_opaque();
+ redo_brush->set_opaque();
+ undo_brush->set_opaque();
- impl->undo_field.clear();
+ undo_field.clear();
}
void
-PaintCommand::redo()
+PaintCommandImpl::redo()
{
- TilemapLayer::draw_tile(impl->tilemap.get_field(), *impl->redo_brush,
impl->pos);
+ TilemapLayer::draw_tile(tilemap.get_field(), *redo_brush, pos);
}
void
-PaintCommand::undo()
+PaintCommandImpl::undo()
{
- TilemapLayer::draw_tile(impl->tilemap.get_field(), *impl->undo_brush,
impl->pos);
+ TilemapLayer::draw_tile(tilemap.get_field(), *undo_brush, pos);
}
std::string
-PaintCommand::serialize()
+PaintCommandImpl::serialize()
{
std::stringstream s;
- s << "_ = PaintCommand(" << &impl->tilemap << ", " << &impl->brush << ")" <<
std::endl;
- for(PaintCommandImpl::Points::iterator i = impl->points.begin(); i !=
impl->points.end(); ++i)
+ s << "_ = PaintCommand(" << &tilemap << ", " << &brush << ")" << std::endl;
+ for(PaintCommandImpl::Points::iterator i = points.begin(); i !=
points.end(); ++i)
{
s << "_.add_paint(" << i->x << ", " << i->y << ")" << std::endl;
}
@@ -129,4 +136,10 @@
return s.str();
}
+Command
+PaintCommand::to_command()
+{
+ return Command(impl);
+}
+
/* EOF */
Modified: trunk/src/paint_command.hxx
===================================================================
--- trunk/src/paint_command.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/paint_command.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -32,21 +32,15 @@
The user needs to supply a brush and a map to draw to and the
points to which should be drawn, undo, redo and the internals of
drawing are handled by the PaintCommand itself. */
-class PaintCommand : public Command
+class PaintCommand
{
public:
PaintCommand(TilemapLayer t, const TileBrush& b);
- virtual ~PaintCommand();
+ ~PaintCommand();
void add_point(const CL_Point& pos);
-
- void execute();
-
- void redo();
- void undo();
- std::string serialize();
-
+ Command to_command();
private:
SharedPtr<PaintCommandImpl> impl;
};
Modified: trunk/src/panel.cxx
===================================================================
--- trunk/src/panel.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/panel.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/panel.hxx
===================================================================
--- trunk/src/panel.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/panel.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/scrollbar.cxx
===================================================================
--- trunk/src/scrollbar.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/scrollbar.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
@@ -93,8 +93,6 @@
parent->get_height()-1));
CL_Display::fill_rect(rect,
CL_Color(255, 255, 255));
- CL_Display::draw_rect(rect,
- CL_Color(155, 155, 155));
if (orientation == Scrollbar::HORIZONTAL)
{
@@ -112,6 +110,9 @@
int(pagesize*scale))),
CL_Color(0, 0, 0));
}
+
+ CL_Display::draw_rect(rect,
+ CL_Color(155, 155, 155));
}
void
Modified: trunk/src/scrollbar.hxx
===================================================================
--- trunk/src/scrollbar.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/scrollbar.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/tilemap_paint_tool.cxx
===================================================================
--- trunk/src/tilemap_paint_tool.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/tilemap_paint_tool.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -196,7 +196,7 @@
mode = NONE;
command->add_point(pos);
- Editor::current()->execute(command);
+ Editor::current()->execute(command->to_command());
command = 0;
tilemap.draw_tile(brush, pos);
Modified: trunk/src/titlebar.cxx
===================================================================
--- trunk/src/titlebar.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/titlebar.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/titlebar.hxx
===================================================================
--- trunk/src/titlebar.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/titlebar.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/viewport.cxx
===================================================================
--- trunk/src/viewport.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/viewport.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/viewport.hxx
===================================================================
--- trunk/src/viewport.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/viewport.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -1,6 +1,6 @@
// $Id$
//
-// Pingus - A free Lemmings clone
+// Flexlay - A Generic 2D Game Editor
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
Modified: trunk/src/window.cxx
===================================================================
--- trunk/src/window.cxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/window.cxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -149,4 +149,16 @@
return impl->client_area;
}
+void
+Window::hide()
+{
+ CL_Component::show(false);
+}
+
+void
+Window::show()
+{
+ CL_Component::show(true);
+}
+
/* EOF */
Modified: trunk/src/window.hxx
===================================================================
--- trunk/src/window.hxx 2004-05-27 20:15:45 UTC (rev 354)
+++ trunk/src/window.hxx 2004-05-28 17:50:39 UTC (rev 355)
@@ -34,6 +34,9 @@
Window(const CL_Rect& rect, const std::string& title, CL_Component* parent);
virtual ~Window();
+ void hide();
+ void show();
+
CL_Component* get_client_area();
private:
Window (const Window&);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 355 - trunk/src,
Ingo Ruhnke <=