[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 362 - trunk/src
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 362 - trunk/src |
Date: |
Sat, 29 May 2004 18:42:06 +0200 |
Author: grumbel
Date: 2004-05-29 18:42:05 +0200 (Sat, 29 May 2004)
New Revision: 362
Modified:
trunk/src/clanlib.i
trunk/src/editor.py
trunk/src/python_meta_data.cxx
trunk/src/supertux.py
trunk/src/tilemap_paint_tool.cxx
trunk/src/tilemap_paint_tool.hxx
Log:
- added active layer switching
Modified: trunk/src/clanlib.i
===================================================================
--- trunk/src/clanlib.i 2004-05-29 01:03:35 UTC (rev 361)
+++ trunk/src/clanlib.i 2004-05-29 16:42:05 UTC (rev 362)
@@ -35,7 +35,7 @@
class CL_Color
{
public:
- CL_Color(unsigned int, unsigned int, unsigned int, unsigned int);
+ CL_Color(unsigned int, unsigned int, unsigned int, unsigned int = 255);
void set_red (unsigned int);
void set_blue (unsigned int);
Modified: trunk/src/editor.py
===================================================================
--- trunk/src/editor.py 2004-05-29 01:03:35 UTC (rev 361)
+++ trunk/src/editor.py 2004-05-29 16:42:05 UTC (rev 362)
@@ -27,6 +27,15 @@
editor = Editor()
gui = editor.get_gui_manager()
+def Editor_undo(self):
+ workspace.get_map().undo()
+def Editor_redo(self):
+ workspace.get_map().redo()
+Editor.undo = Editor_undo
+Editor.redo = Editor_redo
+del Editor_redo
+del Editor_undo
+
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())
@@ -46,7 +55,6 @@
gui.quit()
def draw_something():
- print "Draw something"
brush = TileBrush(2, 2)
brush.set_opaque()
_ = PaintCommand(tilemap, brush)
@@ -54,8 +62,7 @@
_.add_point(CL_Point(2,2))
_.add_point(CL_Point(3,3))
_.add_point(CL_Point(4,4))
- m.execute(_.to_command())
- print "Draw something done"
+ workspace.get_map().execute(_.to_command())
window = Window(CL_Rect(50, 50, 450, 400), "My Window", gui.get_component())
@@ -102,8 +109,8 @@
undo_icon = Icon(CL_Point(32*5.1+2, 2),
make_sprite("../data/images/icons24/stock_undo.png"), "Some tooltip", willow);
redo_icon = Icon(CL_Point(32*6.1+2, 2),
make_sprite("../data/images/icons24/stock_redo.png"), "Some tooltip", willow);
-undo_icon.set_callback(workspace.get_map().undo)
-redo_icon.set_callback(workspace.get_map().redo)
+undo_icon.set_callback(editor.undo)
+redo_icon.set_callback(editor.redo)
undo_icon.disable()
redo_icon.disable()
@@ -143,6 +150,7 @@
level =
SuperTuxLevel('/home/ingo/cvs/supertux/supertux/data/levels/world1/level2.stl')
print "Loading done"
level.activate(workspace)
+ connect(level.editormap.sig_change(), on_map_change)
print "Activation done"
def menu_file_save():
@@ -152,21 +160,54 @@
print "File/Save As"
menu = CL_Menu(gui.get_component())
-a = menu.add_item("File/Open...", menu_file_open)
-a = menu.add_item("File/Save...", menu_file_save)
-a = menu.add_item("File/Save As...", menu_file_save_as)
-a = menu.add_item("File/Quit", do_quit)
+menu.add_item("File/Open...", menu_file_open)
+menu.add_item("File/Save...", menu_file_save)
+menu.add_item("File/Save As...", menu_file_save_as)
+menu.add_item("File/Quit", do_quit)
-mysprite = make_sprite("../data/images/icons16/stock_paste-16.png")
+display_properties = DisplayProperties()
+def menu_show_foreground():
+ display_properties.layer = SuperTuxLevel.FOREGROUND
+
display_properties.set(get_python_object(workspace.get_map().get_metadata()))
+
TilemapLayer_set_current(get_python_object(workspace.get_map().get_metadata()).foreground)
+
+def menu_show_background():
+ display_properties.layer = SuperTuxLevel.BACKGROUND
+
display_properties.set(get_python_object(workspace.get_map().get_metadata()))
+
TilemapLayer_set_current(get_python_object(workspace.get_map().get_metadata()).background)
+
+def menu_show_interactive():
+ display_properties.layer = SuperTuxLevel.INTERACTIVE
+
display_properties.set(get_python_object(workspace.get_map().get_metadata()))
+
TilemapLayer_set_current(get_python_object(workspace.get_map().get_metadata()).interactive)
+
+def menu_show_all():
+ display_properties.show_all = True
+
display_properties.set(get_python_object(workspace.get_map().get_metadata()))
+
+def menu_show_only_current():
+ display_properties.show_all = False
+
display_properties.set(get_python_object(workspace.get_map().get_metadata()))
+
+menu.add_item("Layer/Background", menu_show_background)
+menu.add_item("Layer/Interactive", menu_show_interactive)
+menu.add_item("Layer/Foreground", menu_show_foreground)
+
+# Fixme: make me a toggle item
+menu.add_item("Layer/Show all", menu_show_all)
+menu.add_item("Layer/Show only current", menu_show_only_current)
+
def Menu_add_item(self, sprite, text, func):
- i = self.__add_item(mysprite, text)
+ i = self.__add_item(sprite, text)
if func != None:
connect(self.sig_clicked(i), func)
Menu.__add_item = Menu.add_item
Menu.add_item = Menu_add_item
del Menu_add_item
+mysprite = make_sprite("../data/images/icons16/stock_paste-16.png")
+
mymenu = Menu(CL_Point(100, 100), gui.get_component())
mymenu.add_item(mysprite, "Foobar aeuaeu", None)
mymenu.add_item(mysprite, "blub", do_something)
@@ -180,9 +221,6 @@
mymenu.run()
copy_icon.set_callback(show_menu)
-
-# _button = CL_Button(CL_Rect(100, 100, 200, 125), "Hello World",
gui.get_component())
-# connect(_button.sig_clicked(), show_menu)
minimap_panel = Panel(CL_Rect(CL_Point(0, 600-56), CL_Size(800-134, 56)),
gui.get_component())
minimap = Minimap(editor_map, CL_Rect(CL_Point(3, 3), CL_Size(794-134, 50)),
minimap_panel)
Modified: trunk/src/python_meta_data.cxx
===================================================================
--- trunk/src/python_meta_data.cxx 2004-05-29 01:03:35 UTC (rev 361)
+++ trunk/src/python_meta_data.cxx 2004-05-29 16:42:05 UTC (rev 362)
@@ -36,6 +36,7 @@
PythonMetaData* pyobj = dynamic_cast<PythonMetaData*>(data);
if (pyobj)
{
+ Py_XINCREF(pyobj->data.ptr());
return pyobj->data.ptr();
}
else
Modified: trunk/src/supertux.py
===================================================================
--- trunk/src/supertux.py 2004-05-29 01:03:35 UTC (rev 361)
+++ trunk/src/supertux.py 2004-05-29 16:42:05 UTC (rev 362)
@@ -79,14 +79,55 @@
self.objects = ObjectLayer()
self.editormap = EditorMap()
- self.editormap.add_layer(self.foreground.to_layer())
+ self.editormap.add_layer(self.background.to_layer())
self.editormap.add_layer(self.interactive.to_layer())
- self.editormap.add_layer(self.background.to_layer())
self.editormap.add_layer(self.objects.to_layer())
+ self.editormap.add_layer(self.foreground.to_layer())
+ # FIXME: Data might not get freed since its 'recursively' refcounted
+ self.editormap.set_metadata(make_metadata(self))
def activate(self, workspace):
workspace.set_map(self.editormap)
+ #(tilemap-paint-tool-set-tilemap (supertux:interactive-tm stlv))
+ #(editor-tilemap-set-current (supertux:interactive-tm stlv))
+ #(editor-objectmap-set-current (supertux:objmap stlv))
+ #(set! *tilemap* (supertux:interactive-tm stlv))
+ #(set! *objmap* (supertux:objmap stlv))
+ #(tileset-set-current *level-tileset*)
+ #(tile-selector-set-tileset *tileselector* *level-tileset*))
+SuperTuxLevel.BACKGROUND = 0
+SuperTuxLevel.INTERACTIVE = 1
+SuperTuxLevel.FOREGROUND = 2
+
+class DisplayProperties:
+ layer = SuperTuxLevel.INTERACTIVE
+ show_all = False
+
+ def set(self, map):
+ active = CL_Color(255, 255, 255)
+ deactive = CL_Color(150, 150, 250, 150)
+
+ if (self.show_all):
+ map.foreground.set_foreground_color(active)
+ map.interactive.set_foreground_color(active)
+ map.background.set_foreground_color(active)
+ else:
+ if (self.layer == SuperTuxLevel.FOREGROUND):
+ map.foreground.set_foreground_color(active)
+ else:
+ map.foreground.set_foreground_color(deactive)
+
+ if (self.layer == SuperTuxLevel.INTERACTIVE):
+ map.interactive.set_foreground_color(active)
+ else:
+ map.interactive.set_foreground_color(deactive)
+
+ if (self.layer == SuperTuxLevel.BACKGROUND):
+ map.background.set_foreground_color(active)
+ else:
+ map.background.set_foreground_color(deactive)
+
class SuperTuxGUI:
quit_button = None
menu = None
Modified: trunk/src/tilemap_paint_tool.cxx
===================================================================
--- trunk/src/tilemap_paint_tool.cxx 2004-05-29 01:03:35 UTC (rev 361)
+++ trunk/src/tilemap_paint_tool.cxx 2004-05-29 16:42:05 UTC (rev 362)
@@ -58,7 +58,8 @@
void
TileMapPaintTool::draw()
{
- // FIXME: no tile
+ TilemapLayer tilemap = TilemapLayer::current();
+
if (tilemap.is_null())
return;
@@ -114,7 +115,7 @@
void
TileMapPaintTool::on_mouse_down(const CL_InputEvent& event)
{
- tilemap = TilemapLayer::current();
+ TilemapLayer tilemap = TilemapLayer::current();
if (!tilemap.is_null())
{
@@ -152,6 +153,8 @@
void
TileMapPaintTool::on_mouse_move(const CL_InputEvent& event)
{
+ TilemapLayer tilemap = TilemapLayer::current();
+
if (!tilemap.is_null())
{
EditorMapComponent* parent = EditorMapComponent::current();
@@ -180,6 +183,8 @@
void
TileMapPaintTool::on_mouse_up (const CL_InputEvent& event)
{
+ TilemapLayer tilemap = TilemapLayer::current();
+
if (!tilemap.is_null())
{
EditorMapComponent::current()->get_workspace().get_map().modify();
Modified: trunk/src/tilemap_paint_tool.hxx
===================================================================
--- trunk/src/tilemap_paint_tool.hxx 2004-05-29 01:03:35 UTC (rev 361)
+++ trunk/src/tilemap_paint_tool.hxx 2004-05-29 16:42:05 UTC (rev 362)
@@ -40,8 +40,6 @@
PaintCommand* command;
- TilemapLayer tilemap;
-
static TileMapPaintTool* current_;
public:
static TileMapPaintTool* current() { return current_; }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 362 - trunk/src,
Ingo Ruhnke <=