[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 321 - in trunk/src: . scripting
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 321 - in trunk/src: . scripting |
Date: |
Sat, 15 May 2004 01:15:15 +0200 |
Author: grumbel
Date: 2004-05-15 01:15:14 +0200 (Sat, 15 May 2004)
New Revision: 321
Added:
trunk/src/clanlib.i
trunk/src/editor.py
trunk/src/editor2.py
trunk/src/flexlay.i
trunk/src/hellopy.cxx
trunk/src/scripting/SConstruct
Modified:
trunk/src/
Log:
stuff
Property changes on: trunk/src
___________________________________________________________________
Name: svn:ignore
- Makefile.in
libwindstille_editor.a
.deps
Makefile
netpanzer
collision
flexlay.semistatic
flexlay
averagecolor
flexlay.semistatic.tar.bz2
editor
+ Makefile.in
libwindstille_editor.a
.deps
Makefile
netpanzer
collision
flexlay.semistatic
flexlay
flexlay_wrap.cxx
averagecolor
flexlay.semistatic.tar.bz2
editor
*.os
lib_flexlay.so
flexlay.py
.sconsign
Added: trunk/src/clanlib.i
===================================================================
--- trunk/src/clanlib.i 2004-05-14 23:10:14 UTC (rev 320)
+++ trunk/src/clanlib.i 2004-05-14 23:15:14 UTC (rev 321)
@@ -0,0 +1,90 @@
+class CL_Point
+{
+public:
+ CL_Point(int x, int y)
+ : x(x), y(y) { }
+ int x;
+ int y;
+};
+
+class CL_Rect
+{
+public:
+ int left;
+ int right;
+ int top;
+ int bottom;
+
+ CL_Rect(int, int, int, int);
+
+ int get_width() const;
+ int get_height() const;
+};
+
+class CL_Color
+{
+public:
+ CL_Color(unsigned int, unsigned int, unsigned int, unsigned int);
+
+ void set_red (unsigned int);
+ void set_blue (unsigned int);
+ void set_green(unsigned int);
+ void set_alpha(unsigned int);
+
+ unsigned int get_red ();
+ unsigned int get_blue ();
+ unsigned int get_green();
+ unsigned int get_alpha();
+};
+
+class CL_Component
+{
+public:
+ CL_Component(CL_Component* parent, CL_StyleManager* style = NULL);
+
+};
+
+class CL_Window : public CL_Component
+{
+public:
+ CL_Window(
+ const CL_Rect &pos,
+ const std::string &title,
+ CL_Component *parent,
+ CL_StyleManager *style = NULL);
+};
+
+class CL_Button : public CL_Component
+{
+public:
+ CL_Button(
+ const CL_Rect &pos,
+ const std::string &text,
+ CL_Component *parent,
+ CL_StyleManager *style = NULL);
+
+ CL_Signal_v0 &sig_clicked();
+};
+
+class CL_Menu : public CL_Component
+{
+public:
+ CL_Menu(
+ const CL_Rect &rect,
+ CL_Component *parent,
+ CL_StyleManager *style = NULL,
+ bool vertical=false);
+
+ CL_Menu(
+ CL_Component *parent,
+ CL_StyleManager *style = NULL,
+ bool vertical=false);
+
+ CL_Menu *create_menu( const std::string &path, const std::string
&labels=std::string());
+ CL_MenuNode *create_item( const std::string &path, const std::string
&labels=std::string());
+};
+
+
+
+/* EOF */
+
Added: trunk/src/editor.py
===================================================================
--- trunk/src/editor.py 2004-05-14 23:10:14 UTC (rev 320)
+++ trunk/src/editor.py 2004-05-14 23:15:14 UTC (rev 321)
@@ -0,0 +1,71 @@
+## $Id$
+##
+## Flexlay - A Generic 2D Game Editor
+## Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+from flexlay import *
+
+flexlay_init()
+
+editor = Editor()
+gui = editor.get_gui()
+
+editor_map = EditorMapComponent(Rect(0, 0, 799, 599), gui.get_component())
+workspace = Workspace(799, 599)
+editor_map.set_workspace(workspace)
+
+m = EditorMap("Foobar")
+workspace.set_map(m)
+tileset = Tileset(32)
+tilemap = TileMap(tileset, 100, 50)
+m.add(tilemap)
+tile = Tile("/home/ingo/cvs/supertux/supertux/data/images/tilesets/bonus1.png",
+ Color(255, 255, 255, 255),
+ Color(255, 0, 0, 128))
+tileset.add_tile(0, tile)
+tileset.add_tile(1, tile)
+tileset.add_tile(2, tile)
+
+tilemap_set_current(tilemap)
+tilemap_paint_tool_set_tilemap(tilemap)
+
+editor_set_brush_tile(1)
+
+def foo():
+ print "---My Callback---"
+ gui.quit()
+
+window = Window(Rect(50, 50, 350, 250), "My Window", gui.get_component())
+
+gui.push_component(window)
+button = Button(Rect(50, 50, 200, 75), "Quit", gui.get_component())
+connect(button.sig_clicked(), foo)
+gui.pop_component()
+
+button2 = Button(Rect(0, 0, 100, 25), "Quit", gui.get_component())
+connect(button2.sig_clicked(), foo)
+
+menu = Menu(gui.get_component());
+a = menu.add_item("File/Open...", "File/Open...")
+a = menu.add_item("File/Save...", "File/Save...")
+a = menu.add_item("File/Save As...", "File/Save As...")
+c = menu.foobar()
+gui.run()
+
+flexlay_deinit()
+
+# EOF #
Added: trunk/src/editor2.py
===================================================================
--- trunk/src/editor2.py 2004-05-14 23:10:14 UTC (rev 320)
+++ trunk/src/editor2.py 2004-05-14 23:15:14 UTC (rev 321)
@@ -0,0 +1,87 @@
+## $Id$
+##
+## Flexlay - A Generic 2D Game Editor
+## Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+from flexlay import *
+
+flexlay = Flexlay()
+
+flexlay.init()
+
+editor = Editor()
+gui = editor.get_gui_manager()
+
+editor_map = EditorMapComponent(CL_Rect(0, 0, 799, 599), gui.get_component())
+workspace = Workspace(799, 599)
+editor_map.set_workspace(workspace)
+
+m = EditorMap("Foobar")
+workspace.set_current_map(m)
+tileset = Tileset(32)
+tilemap = EditorTileMap(tileset, 100, 50)
+m.add_layer(tilemap)
+tile = Tile("/home/ingo/cvs/supertux/supertux/data/images/tilesets/bonus1.png",
+ CL_Color(255, 255, 255, 255),
+ CL_Color(255, 0, 0, 128))
+tileset.add_tile(0, tile)
+tileset.add_tile(1, tile)
+tileset.add_tile(2, tile)
+
+editor_tilemap_set_current(tilemap)
+tilemap_paint_tool_set_tilemap(tilemap)
+
+editor_set_brush_tile(1)
+
+def foo():
+ print "---My Callback---"
+ gui.quit()
+
+g = None
+
+def draw_something():
+ print "Draw something"
+ brush = TileBrush(2, 2)
+ brush.set_opaque()
+ _ = PaintCommand(tilemap, brush)
+ _.add_point(CL_Point(1,1))
+ _.add_point(CL_Point(2,2))
+ _.add_point(CL_Point(3,3))
+ _.add_point(CL_Point(4,4))
+ _.execute()
+ g = _
+ print "Draw something done"
+
+window = CL_Window(CL_Rect(50, 50, 350, 250), "My Window", gui.get_component())
+
+gui.push_component(window)
+button1 = CL_Button(CL_Rect(50, 50, 200, 75), "Quit", gui.get_component())
+connect(button1.sig_clicked(), foo)
+
+button2 = CL_Button(CL_Rect(50, 100, 200, 125), "Draw", gui.get_component())
+connect(button2.sig_clicked(), draw_something)
+gui.pop_component()
+
+menu = CL_Menu(gui.get_component());
+a = menu.create_item("File/Open...", "File/Open...")
+a = menu.create_item("File/Save...", "File/Save...")
+a = menu.create_item("File/Save As...", "File/Save As...")
+gui.run()
+
+flexlay.deinit()
+
+# EOF #
Added: trunk/src/flexlay.i
===================================================================
--- trunk/src/flexlay.i 2004-05-14 23:10:14 UTC (rev 320)
+++ trunk/src/flexlay.i 2004-05-14 23:15:14 UTC (rev 321)
@@ -0,0 +1,54 @@
+%module flexlay
+
+%{
+#include <ClanLib/Display/color.h>
+#include <ClanLib/GUI/component.h>
+#include <ClanLib/GUI/button.h>
+#include <ClanLib/GUI/window.h>
+#include <ClanLib/Core/Math/rect.h>
+#include <ClanLib/Core/Math/point.h>
+#include "scripting/editor.hxx"
+#include "command.hxx"
+#include "paint_command.hxx"
+#include "object_move_command.hxx"
+#include "object_add_command.hxx"
+#include "scripting/editor.hxx"
+#include "tile.hxx"
+#include "tile_brush.hxx"
+#include "editor.hxx"
+#include "editor_map_layer.hxx"
+#include "editor_tilemap.hxx"
+#include "editor_map.hxx"
+#include "workspace.hxx"
+#include "tileset.hxx"
+#include "editor_map_component.hxx"
+#include "flexlay.hxx"
+#include "globals.hxx"
+#include "python_functor.hxx"
+#include "gui_manager.hxx"
+%}
+
+%include "std_string.i"
+%include "std_vector.i"
+%include "clanlib.i"
+%include "scripting/editor.hxx"
+%include "command.hxx"
+%include "paint_command.hxx"
+%include "object_move_command.hxx"
+%include "object_add_command.hxx"
+%include "scripting/editor.hxx"
+%include "tile.hxx"
+%include "tile_brush.hxx"
+%include "editor.hxx"
+%include "editor_map_layer.hxx"
+%include "editor_tilemap.hxx"
+%include "editor_map.hxx"
+%include "workspace.hxx"
+%include "tileset.hxx"
+%include "editor_map_component.hxx"
+%include "flexlay.hxx"
+%include "globals.hxx"
+%include "python_functor.hxx"
+%include "gui_manager.hxx"
+
+/* EOF */
Added: trunk/src/hellopy.cxx
===================================================================
--- trunk/src/hellopy.cxx 2004-05-14 23:10:14 UTC (rev 320)
+++ trunk/src/hellopy.cxx 2004-05-14 23:15:14 UTC (rev 321)
@@ -0,0 +1,45 @@
+#include <Python.h>
+#include <boost/python.hpp>
+#include <iostream>
+
+struct Callback
+{
+ PyObject* o;
+
+ Callback(PyObject* obj)
+ {
+ o = obj;
+ Py_INCREF(o);
+ std::cout << "is callable: " << PyCallable_Check(obj) << std::endl;
+ }
+
+ void operator()()
+ {
+ std::cout << "Callback: " << o << std::endl;
+ std::cout << " Return: " << PyEval_CallObject(o, PyTuple_New(0)) <<
std::endl;
+ }
+};
+
+PyObject* callback;
+
+void set_callback(PyObject* c)
+{
+ callback = c;
+}
+
+void call_callback()
+{
+ std::cout << "Calling callback" << std::endl;
+ std::cout << PyEval_CallObject(callback, PyTuple_New(0)) << std::endl;
+}
+
+BOOST_PYTHON_MODULE(hellopy)
+{
+ using namespace boost::python;
+
+ def("setcallback", &set_callback);
+ def("callcallback", &call_callback);
+}
+
+/* EOF */
+
Added: trunk/src/scripting/SConstruct
===================================================================
--- trunk/src/scripting/SConstruct 2004-05-14 23:10:14 UTC (rev 320)
+++ trunk/src/scripting/SConstruct 2004-05-14 23:15:14 UTC (rev 321)
@@ -0,0 +1 @@
+SConscript(['../SConstruct'])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 321 - in trunk/src: . scripting,
Ingo Ruhnke <=