[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 315 - in trunk: . src src/scripting
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 315 - in trunk: . src src/scripting |
Date: |
Thu, 13 May 2004 20:48:45 +0200 |
Author: grumbel
Date: 2004-05-13 20:48:44 +0200 (Thu, 13 May 2004)
New Revision: 315
Added:
trunk/src/SConstruct
trunk/src/flexlay_python.cxx
Removed:
trunk/flexlay/
Modified:
trunk/Makefile.am
trunk/configure.ac
trunk/src/Makefile.am
trunk/src/editor.cxx
trunk/src/editor.hxx
trunk/src/editor_main.cxx
trunk/src/editor_main.hxx
trunk/src/editor_map.cxx
trunk/src/editor_map.hxx
trunk/src/editor_objmap.cxx
trunk/src/editor_objmap.hxx
trunk/src/globals.cxx
trunk/src/gui_manager.cxx
trunk/src/gui_manager.hxx
trunk/src/object_brush.cxx
trunk/src/object_brush.hxx
trunk/src/object_selector.cxx
trunk/src/objmap_object.cxx
trunk/src/objmap_object.hxx
trunk/src/objmap_sprite_object.cxx
trunk/src/objmap_sprite_object.hxx
trunk/src/scripting/Makefile.am
trunk/src/scripting/editor.hxx
trunk/src/scripting/editor.i
trunk/src/scripting/gui.cxx
trunk/src/scripting/gui.hxx
trunk/src/tileset.cxx
trunk/src/tileset.hxx
trunk/src/workspace.hxx
Log:
- fixed python support a bit more
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/Makefile.am 2004-05-13 18:48:44 UTC (rev 315)
@@ -1,7 +1,7 @@
## $Id: Makefile.am,v 1.6 2003/08/18 08:50:22 grumbel Exp $
##
-## Windstille - A free Lemmings clone
-## Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+## Flexlay - A Generic 2D Game Editor
+## Copyright (C) 2003 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
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/configure.ac 2004-05-13 18:48:44 UTC (rev 315)
@@ -1,4 +1,4 @@
-AC_INIT(Flexlay, 0.0.1)
+AC_INIT(Flexlay, 0.0.3)
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([src/editor_main.cxx])
AM_INIT_AUTOMAKE(dist-bzip2)
@@ -7,10 +7,11 @@
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_RANLIB
+#AC_PROG_LIBTOOL
AC_LANG(C++)
-AM_PATH_PYTHON
-AM_CHECK_PYTHON_HEADERS
+# AM_PATH_PYTHON(2.2)
+# AM_CHECK_PYTHON_HEADERS(2.2)
dnl Checking for libraries
AC_CHECK_LIB(qthreads, main)
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/Makefile.am 2004-05-13 18:48:44 UTC (rev 315)
@@ -1,13 +1,28 @@
+## $Id: Makefile.am,v 1.6 2003/08/18 08:50:22 grumbel Exp $
+##
+## Flexlay - A Generic 2D Game Editor
+## Copyright (C) 2003 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.
+
SUBDIRS = scripting
EXTRA_DIST = netpanzer-editor supertux-editor windstille-editor
-bin_PROGRAMS = flexlay averagecolor
+bin_PROGRAMS = flexlay
-averagecolor_SOURCES = averagecolor.cxx
-averagecolor_CPPFLAGS = @EDITOR_CFLAGS@
-averagecolor_LDADD = @EDITOR_LIBS@
-
-flexlay_CPPFLAGS = -I.. @EDITOR_CFLAGS@
+flexlay_CPPFLAGS = -I.. @EDITOR_CFLAGS@ -DSWIGGUILE
flexlay_LDADD = scripting/libeditor_scripting.a @EDITOR_LIBS@
flexlay_SOURCES = \
command.hxx \
@@ -32,6 +47,8 @@
editor_tilemap.cxx \
editor_tilemap.hxx \
field.hxx \
+ flexlay.hxx \
+ flexlay.cxx \
globals.cxx \
globals.hxx \
graphic_context_state.cxx \
@@ -96,6 +113,19 @@
zoom_tool.cxx \
zoom_tool.hxx
+#pkglib_LTLIBRARIES = libflexlay.la
+#libflexlay_la_SOURCES = \
+# flexlay_python.cxx \
+# globals.cxx \
+# globals.hxx \
+# scripting/gui.cxx \
+# scripting/gui.hxx \
+# gui_manager.cxx \
+# gui_manager.hxx
+
+#libflexlay_la_CPPFLAGS = -I/usr/include/python2.2/ @EDITOR_CFLAGS@
+#libflexlay_la_LDFLAGS = -lboost_python @EDITOR_LIBS@
+
# tilemap_diamond_tool.hxx tilemap_diamond_tool.cxx
STATICBIN_LIBS = \
-L/usr/X11R6/lib/ \
Added: trunk/src/SConstruct
===================================================================
--- trunk/src/SConstruct 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/SConstruct 2004-05-13 18:48:44 UTC (rev 315)
@@ -0,0 +1,69 @@
+## -*- mode: python -*-
+
+BuildDir('build', '.', duplicate=0)
+env = Environment(CC = 'g++',
+ CCFLAGS = '-O2 -Wall')
+
+env.SharedLibrary(
+ 'hellopy',
+ ['hellopy.cxx'],
+ CPPPATH=['/usr/include/python2.2/'],
+ LIBS=['boost_python'])
+
+env.SharedLibrary(
+ target = 'flexlay',
+ source = [
+ 'build/command_group.cxx',
+ 'build/editor.cxx',
+ 'build/editor_grid_layer.cxx',
+ 'build/editor_map.cxx',
+ 'build/editor_map_component.cxx',
+ 'build/editor_mapsize_layer.cxx',
+ 'build/editor_objmap.cxx',
+ 'build/editor_tilemap.cxx',
+ 'build/flexlay.cxx',
+ 'build/flexlay_python.cxx',
+ 'build/globals.cxx',
+ 'build/graphic_context_state.cxx',
+ 'build/gui_manager.cxx',
+ 'build/minimap.cxx',
+ 'build/object_add_command.cxx',
+ 'build/object_brush.cxx',
+ 'build/object_delete_command.cxx',
+ 'build/object_move_command.cxx',
+ 'build/object_selector.cxx',
+ 'build/object_transform_command.cxx',
+ 'build/objmap_object.cxx',
+ 'build/objmap_select_tool.cxx',
+ 'build/objmap_sprite_object.cxx',
+ 'build/paint_command.cxx',
+ 'build/popup_menu.cxx',
+ 'build/python_functor.cxx',
+ 'build/scripting/gui.cxx',
+ 'build/tile.cxx',
+ 'build/tile_brush.cxx',
+ 'build/tile_editor.cxx',
+ 'build/tile_selection.cxx',
+ 'build/tile_selector.cxx',
+ 'build/tilemap_diamond_tool.cxx',
+ 'build/tilemap_paint_tool.cxx',
+ 'build/tilemap_select_tool.cxx',
+ 'build/tilemap_tool.cxx',
+ 'build/tileset.cxx',
+ 'build/tool_manager.cxx',
+ 'build/workspace.cxx',
+ 'build/zoom_tool.cxx'],
+ CPPPATH=['/home/ingo/run/ClanLib-0.7-current//include/ClanLib-0.7/',
+ '/usr/include/python2.2/',
+ '..'],
+ LIBPATH=['/home/ingo/run/ClanLib-0.7-current//lib/'],
+ LIBS=['clanCore',
+ 'clanDisplay',
+ 'clanGL',
+ 'clanSignals',
+ 'clanGUI',
+ 'clanGUIStyleSilver',
+ 'boost_python'])
+
+
+# EOF #
Modified: trunk/src/editor.cxx
===================================================================
--- trunk/src/editor.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/editor.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -22,7 +22,9 @@
#include <ClanLib/display.h>
#include <ClanLib/gui.h>
#include <ClanLib/guistylesilver.h>
+#ifdef SWIGGUILE
#include <guile/gh.h>
+#endif
#include "gui_manager.hxx"
#include "command.hxx"
@@ -41,7 +43,10 @@
manager = new GUIManager();
tool_manager = new ToolManager();
+
+#ifdef SWIGGUILE
gh_load((datadir + "editor.scm").c_str());
+#endif
}
Editor::~Editor()
Modified: trunk/src/editor.hxx
===================================================================
--- trunk/src/editor.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/editor.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -47,7 +47,8 @@
~Editor();
ToolManager* get_tool_manager() const { return tool_manager; }
-
+ GUIManager* get_gui_manager() const { return manager; }
+
void run();
// FIXME: Move undo stuff to EditorMap or some other per map class
Modified: trunk/src/editor_main.cxx
===================================================================
--- trunk/src/editor_main.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/editor_main.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -27,19 +27,13 @@
#include "editor.hxx"
#include "globals.hxx"
#include "tileset.hxx"
+#include "flexlay.hxx"
#include "editor_main.hxx"
extern "C" void SWIG_init(void);
-CL_ResourceManager* resources;
-
EditorMain::EditorMain()
{
- screen_width = 800;
- screen_height = 600;
- fullscreen = false;
- allow_resize = true;
- use_opengl = true;
game_definition_file = "windstille.scm";
}
@@ -101,16 +95,17 @@
#endif
case opengl_flag:
- use_opengl = true;
+ flexlay.use_opengl = true;
break;
case 'f':
- fullscreen = true;
+ flexlay.fullscreen = true;
break;
case 'g':
- if (sscanf(argp.get_argument().c_str(), "%dx%d", &screen_width,
&screen_height) == 2)
- std::cout << "Geometry: " << screen_width << "x" << screen_height
<< std::endl;
+ if (sscanf(argp.get_argument().c_str(), "%dx%d",
+ &flexlay.screen_width, &flexlay.screen_height) == 2)
+ std::cout << "Geometry: " << flexlay.screen_width << "x" <<
flexlay.screen_height << std::endl;
else
throw CL_Error("Geometry option '-g' requires argument of type
{WIDTH}x{HEIGHT}");
break;
@@ -196,23 +191,8 @@
gh_define("*flexlay-package-string*", gh_str02scm(PACKAGE_STRING));
std::cout << "done" << std::endl;
- CL_SetupCore::init();
-#ifdef HAVE_LIBSDL
- if (use_opengl)
- CL_SetupGL::init();
- else
- CL_SetupSDL::init();
-#else
- CL_SetupGL::init();
-#endif
- CL_SetupDisplay::init();
-
- window = new CL_DisplayWindow(PACKAGE_STRING,
- screen_width, screen_height, fullscreen,
allow_resize);
-
- resources = new CL_ResourceManager();
- //resources->add_resources(CL_ResourceManager(datadir + "flexlay.xml",
false));
-
+ flexlay.init();
+
std::cout << "Loading Flexlay startup script: " << game_definition_file <<
std::flush;
gh_load((datadir + game_definition_file).c_str());
std::cout << "done" << std::endl;
@@ -227,19 +207,7 @@
editor.run();
- CL_SetupDisplay::deinit();
-
-#ifdef HAVE_LIBSDL
- if (use_opengl)
- CL_SetupGL::deinit();
- else
- CL_SetupSDL::init();
-#else
- CL_SetupGL::deinit();
-#endif
-
- CL_SetupCore::deinit();
-
+ flexlay.deinit();
} catch (CL_Error& error) {
std::cout << "CL_Error: " << error.message << std::endl;
} catch (std::exception& err) {
Modified: trunk/src/editor_main.hxx
===================================================================
--- trunk/src/editor_main.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/editor_main.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -27,14 +27,8 @@
class EditorMain : public CL_ClanApplication
{
private:
- int screen_width;
- int screen_height;
- bool fullscreen;
- bool allow_resize;
- bool use_opengl;
std::vector<std::string> levelfiles;
std::string game_definition_file;
- CL_DisplayWindow* window;
void parse_command_line(int argc, char** argv);
Modified: trunk/src/editor_map.cxx
===================================================================
--- trunk/src/editor_map.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/editor_map.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -77,6 +77,7 @@
return 0;
}
+#ifdef SWIGGUILE
void
EditorMap::set_metadata(const SCMObj& obj)
{
@@ -88,6 +89,7 @@
{
return metadata;
}
+#endif
CL_Rect
EditorMap::get_bounding_rect()
Modified: trunk/src/editor_map.hxx
===================================================================
--- trunk/src/editor_map.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/editor_map.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -56,7 +56,9 @@
CL_Color foreground_color;
/** Metadata attached to this map (ie. mapname, description, scripts, etc.)
*/
+#ifdef SWIGGUILE
SCMObj metadata;
+#endif
public:
EditorMap(const std::string& filename_);
~EditorMap();
@@ -78,8 +80,10 @@
EditorMapLayer* get_layer(int i);
void set_active_layer(int i);
+#ifdef SWIGGUILE
void set_metadata(const SCMObj& obj);
SCMObj get_metadata() const;
+#endif
bool has_bounding_rect() const { return true; }
CL_Rect get_bounding_rect();
Modified: trunk/src/editor_objmap.cxx
===================================================================
--- trunk/src/editor_objmap.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/editor_objmap.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -59,6 +59,7 @@
return newobj->get_handle();
}
+#ifdef SWIGGUILE
int
EditorObjMap::add_object(const CL_Sprite& sprite, const CL_Point& pos, const
SCMObj& data)
{
@@ -68,6 +69,7 @@
return obj->get_handle();
}
+#endif
ObjMapObject*
EditorObjMap::find_object(const CL_Point& click_pos)
Modified: trunk/src/editor_objmap.hxx
===================================================================
--- trunk/src/editor_objmap.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/editor_objmap.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -24,7 +24,9 @@
#include <ClanLib/Display/sprite.h>
#include <ClanLib/GUI/component.h>
#include <ClanLib/Core/Math/point.h>
+#ifdef SWIGGUILE
#include "scm_obj.hxx"
+#endif
#include "editor_map_layer.hxx"
class ObjMapObject;
@@ -53,7 +55,9 @@
void draw(EditorMapComponent* parent);
/** Add an object to the map and return a handle to it */
+#ifdef SWIGGUILE
int add_object(const CL_Sprite& sprite, const CL_Point& pos, const SCMObj&
data);
+#endif
void add_object(ObjMapObject* obj);
void delete_object(int id);
int duplicate_object(int id);
Added: trunk/src/flexlay_python.cxx
===================================================================
--- trunk/src/flexlay_python.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/flexlay_python.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -0,0 +1,111 @@
+#include <string>
+#include <ClanLib/display.h>
+#include <ClanLib/core.h>
+#include <ClanLib/gl.h>
+#include <ClanLib/gui.h>
+#include <Python.h>
+#include <boost/python.hpp>
+#include <iostream>
+
+#include "editor.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"
+
+void
+clerror_translator(CL_Error const& err)
+{
+ PyErr_SetString(PyExc_UserWarning, ("CL_Error: " + err.message).c_str());
+}
+
+void flexlay_init() { flexlay.init(); }
+void flexlay_deinit() { flexlay.deinit(); }
+
+void sig_connect(CL_Signal_v0& sig, PyObject* obj)
+{
+ std::cout << "Connecting functor: " << std::endl;
+ new CL_Slot(sig.connect_functor(PythonFunctor(obj)));
+}
+
+BOOST_PYTHON_MODULE(flexlay)
+{
+ using namespace boost::python;
+
+ def("flexlay_init", &flexlay_init);
+ def("flexlay_deinit", &flexlay_deinit);
+
+ register_exception_translator<CL_Error>(&clerror_translator);
+
+ class_<GUIManager>("GUIManager")
+ .def("run", &GUIManager::run)
+ .def("quit", &GUIManager::quit)
+ .def("push_component", &GUIManager::push_component)
+ .def("pop_component", &GUIManager::pop_component)
+ .def("get_component", &GUIManager::get_component,
+ return_value_policy<reference_existing_object>());
+
+ class_<CL_Size>("Size", init<int, int>())
+ .def_readwrite("width", &CL_Size::width)
+ .def_readwrite("height", &CL_Size::height);
+
+ class_<CL_Point>("Point", init<int, int>())
+ .def_readwrite("x", &CL_Point::x)
+ .def_readwrite("y", &CL_Point::y);
+
+ class_<CL_Rect>("Rect", init<int, int, int, int>())
+ .def(init<CL_Point, CL_Size>())
+ .def_readwrite("left", &CL_Rect::left)
+ .def_readwrite("right", &CL_Rect::right)
+ .def_readwrite("top", &CL_Rect::top)
+ .def_readwrite("bottom", &CL_Rect::bottom);
+
+ class_<CL_Signal_v0, boost::noncopyable>("Signal_v0", no_init);
+
+ class_<CL_Component, boost::noncopyable>("Component", no_init);
+
+ def("connect", &sig_connect);
+
+ class_<CL_Window, bases<CL_Component>, CL_Window, boost::noncopyable>
+ ("Window", init<CL_Rect, std::string, CL_Component*>());
+
+ class_<CL_Button, boost::noncopyable, bases<CL_Component> >
+ ("Button", init<CL_Rect, std::string, CL_Component*>())
+ .def("sig_clicked", &CL_Button::sig_clicked,
+ return_value_policy<reference_existing_object>());
+
+ class_<Workspace, bases<>, Workspace, boost::noncopyable>
+ ("Workspace", init<int, int>())
+ .def("set_map", &Workspace::set_current_map);
+
+ class_<Editor, bases<>, Editor, boost::noncopyable>
+ ("Editor", init<>())
+ .def("get_gui", &Editor::get_gui_manager,
+ return_value_policy<reference_existing_object>());
+
+ class_<EditorMap>
+ ("EditorMap", init<std::string>())
+ .def("add", &EditorMap::add_layer);
+
+ class_<EditorMapLayer, bases<>, EditorMapLayer, boost::noncopyable>
+ ("EditorMapLayer", no_init);
+
+ class_<EditorMapComponent, bases<CL_Component>, EditorMapComponent,
boost::noncopyable>
+ ("EditorMapComponent", init<CL_Rect, CL_Component*>())
+ .def("set_zoom", &EditorMapComponent::set_zoom)
+ .def("set_workspace", &EditorMapComponent::set_workspace);
+
+ class_<Tileset>("Tileset", init<int>())
+ .def("get_tilesize", &Tileset::get_tile_size);
+
+ class_<EditorTileMap, bases<EditorMapLayer>, EditorTileMap,
boost::noncopyable>
+ ("TileMap", init<Tileset*, int, int, int>())
+ .def("get_tile", &EditorTileMap::get_tile)
+ .def("resize", &EditorTileMap::resize);
+}
+
+/* EOF */
Modified: trunk/src/globals.cxx
===================================================================
--- trunk/src/globals.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/globals.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -25,4 +25,6 @@
int debug = 0;
+CL_ResourceManager* resources = 0;
+
/* EOF */
Modified: trunk/src/gui_manager.cxx
===================================================================
--- trunk/src/gui_manager.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/gui_manager.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -17,6 +17,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <iostream>
#include <ClanLib/gui.h>
#include <ClanLib/guistylesilver.h>
#include <ClanLib/core.h>
@@ -33,11 +34,10 @@
resources = new CL_ResourceManager(datadir + "gui/gui.xml", false);
style = new CL_StyleManager_Silver(resources);
manager = new CL_GUIManager(style);
+ current_ = this;
- current_ = this;
-
// Make the manager the first component on the stack
- gui_push_component(manager);
+ push_component(manager);
}
GUIManager::~GUIManager()
@@ -101,4 +101,10 @@
return manager->is_input_enabled();
}
+void
+GUIManager::quit()
+{
+ manager->quit();
+}
+
/* EOF */
Modified: trunk/src/gui_manager.hxx
===================================================================
--- trunk/src/gui_manager.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/gui_manager.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -49,6 +49,7 @@
void update();
void run();
+ void quit();
void push_component(CL_Component* c) { components.push(c); }
void pop_component() { components.pop(); }
Modified: trunk/src/object_brush.cxx
===================================================================
--- trunk/src/object_brush.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/object_brush.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -24,9 +24,15 @@
}
-ObjectBrush::ObjectBrush(const CL_Sprite& sprite_, const SCMObj& data_)
- : sprite(sprite_),
- data(data_)
+ObjectBrush::ObjectBrush(const CL_Sprite& sprite_
+#ifdef SWIGGUILE
+ , const SCMObj& data_
+#endif
+)
+ : sprite(sprite_)
+#ifdef SWIGGUILE
+ ,data(data_)
+#endif
{
}
Modified: trunk/src/object_brush.hxx
===================================================================
--- trunk/src/object_brush.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/object_brush.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -20,17 +20,25 @@
#ifndef HEADER_OBJECT_BRUSH_HXX
#define HEADER_OBJECT_BRUSH_HXX
+#ifdef SWIGGUILE
#include "scm_obj.hxx"
+#endif
#include <ClanLib/Display/sprite.h>
class ObjectBrush
{
public:
CL_Sprite sprite;
+#ifdef SWIGGUILE
SCMObj data;
+#endif
ObjectBrush();
- ObjectBrush(const CL_Sprite& sprite_, const SCMObj& data_);
+ ObjectBrush(const CL_Sprite& sprite_
+#ifdef SWIGGUILE
+ , const SCMObj& data_
+#endif
+);
};
#endif
Modified: trunk/src/object_selector.cxx
===================================================================
--- trunk/src/object_selector.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/object_selector.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -86,7 +86,9 @@
ObjMapObject* obj
= new
ObjMapSpriteObject(objmap->get_next_object_handle(),
EditorMapComponent::current()->screen2world(target),
+#ifdef SWIGGUILE
SCMObj(drag_obj.data),
+#endif
drag_obj.sprite);
ObjectAddCommand* command = new ObjectAddCommand(objmap,
obj);
Editor::current()->execute(command);
Modified: trunk/src/objmap_object.cxx
===================================================================
--- trunk/src/objmap_object.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/objmap_object.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -19,13 +19,23 @@
#include "objmap_object.hxx"
-ObjMapObject::ObjMapObject(int handle_, const CL_Point& pos_, const SCMObj&
data_)
- : handle(handle_), pos(pos_), data(data_)
+ObjMapObject::ObjMapObject(int handle_, const CL_Point& pos_
+#ifdef SWIGGUILE
+ , const SCMObj& data_
+#endif
+ )
+ : handle(handle_), pos(pos_)
+#ifdef SWIGGUILE
+ , data(data_)
+#endif
{
}
ObjMapObject::ObjMapObject(int handle_, const ObjMapObject& obj)
- : handle(handle_), pos(obj.pos), data(obj.data)
+ : handle(handle_), pos(obj.pos)
+#ifdef SWIGGUILE
+, data(obj.data)
+#endif
{
}
Modified: trunk/src/objmap_object.hxx
===================================================================
--- trunk/src/objmap_object.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/objmap_object.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -22,7 +22,9 @@
#include <ClanLib/Core/Math/point.h>
#include <ClanLib/Core/Math/rect.h>
+#ifdef SWIGGUILE
#include "scm_obj.hxx"
+#endif
/** */
class ObjMapObject
@@ -32,17 +34,24 @@
protected:
CL_Point pos;
+#ifdef SWIGGUILE
SCMObj data;
-
+#endif
public:
- ObjMapObject(int handle_, const CL_Point& pos, const SCMObj& data);
+ ObjMapObject(int handle_, const CL_Point& pos
+#ifdef SWIGGUILE
+ , const SCMObj& data
+#endif
+ );
ObjMapObject(int handle_, const ObjMapObject& obj);
virtual ~ObjMapObject() {}
CL_Point get_pos() const { return pos; }
void set_pos(const CL_Point& p) { pos = p; }
+#ifdef SWIGGUILE
SCMObj get_data() const { return data; }
+#endif
virtual void draw() =0;
virtual CL_Rect get_bound_rect() const =0;
Modified: trunk/src/objmap_sprite_object.cxx
===================================================================
--- trunk/src/objmap_sprite_object.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/objmap_sprite_object.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -20,9 +20,16 @@
#include <ClanLib/Display/display.h>
#include "objmap_sprite_object.hxx"
-ObjMapSpriteObject::ObjMapSpriteObject(int handle_, const CL_Point& pos_,
const SCMObj& data_,
+ObjMapSpriteObject::ObjMapSpriteObject(int handle_, const CL_Point& pos_,
+#ifdef SWIGGUILE
+ const SCMObj& data_,
+#endif
const CL_Sprite& sprite_)
- : ObjMapObject(handle_, pos_, data_), sprite(sprite_)
+ : ObjMapObject(handle_, pos_
+#ifdef SWIGGUILE
+ ,data_
+#endif
+ ), sprite(sprite_)
{
}
Modified: trunk/src/objmap_sprite_object.hxx
===================================================================
--- trunk/src/objmap_sprite_object.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/objmap_sprite_object.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -30,7 +30,12 @@
CL_Sprite sprite;
public:
- ObjMapSpriteObject(int handle_, const CL_Point& pos_, const SCMObj& data_,
const CL_Sprite& s);
+ ObjMapSpriteObject(int handle_,
+ const CL_Point& pos_,
+#ifdef SWIGGUILEconst
+ SCMObj& data_,
+#endif
+ const CL_Sprite& s);
ObjMapSpriteObject(int handle_, const ObjMapSpriteObject& obj);
void flip_horizontal();
Modified: trunk/src/scripting/Makefile.am
===================================================================
--- trunk/src/scripting/Makefile.am 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/scripting/Makefile.am 2004-05-13 18:48:44 UTC (rev 315)
@@ -25,7 +25,7 @@
noinst_LIBRARIES = libeditor_scripting.a
libeditor_scripting_a_CPPFLAGS = \
- -I.. @EDITOR_CFLAGS@
+ -I.. @EDITOR_CFLAGS@ -DSWIGGUILE
libeditor_scripting_a_SOURCES = \
editor_guile_wrap.cxx \
@@ -34,7 +34,7 @@
# Include editor_wrap.cxx in case the user doesn't have swig installed
EXTRA_DIST = editor_guile_wrap.cxx editor.i $(command_source)
-editor_python_wrap.cxx: editor.i $(command_source) Makefile
+editor_python_wrap.cxx: editor.i $(command_source)
$(SWIG) -python -c++ -o $@ $<
# We override the default compile command to skip all the warnings
@@ -42,12 +42,12 @@
libeditor_scripting_a-editor_python_wrap.o : editor_python_wrap.cxx
$(CXX) $(PYTHON_INCLUDES) @EDITOR_CFLAGS@ -c -O2 -o $@ $<
-editor_guile_wrap.cxx: editor.i $(command_source) Makefile
+editor_guile_wrap.cxx: editor.i $(command_source)
$(SWIG) -guile -c++ -o $@ $<
# We override the default compile command to skip all the warnings
# that compiling the wrappers causes.
libeditor_scripting_a-editor_guile_wrap.o : editor_guile_wrap.cxx
- $(CXX) @EDITOR_CFLAGS@ -c -O2 -o $@ $<
+ $(CXX) -DSWIGGUILE @EDITOR_CFLAGS@ -c -O2 -o $@ $<
# EOF #
Modified: trunk/src/scripting/editor.hxx
===================================================================
--- trunk/src/scripting/editor.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/scripting/editor.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -58,33 +58,18 @@
void editor_set_brush_tile(int i);
int editor_get_brush_tile();
void editor_set_tool(int i);
-SCM editor_get_tile_selection();
void tilemap_paint_tool_set_brush(TileBrush brush);
void tilemap_paint_tool_set_tilemap(EditorMapLayer* layer);
-void object_selector_add_brush(CL_Component* comp, const char* name, SCM
brush);
-
-int objectmap_add_object(EditorMapLayer* obj, const char* name, int x, int y,
SCM userdata);
-#if 0
-int objectmap_add_sprite_object (EditorMapLayer* layer, SCM desc, int x, int
y, SCM userdata);
-#endif
-
-void editor_objectmap_delete_objects (EditorMapLayer* layer,SCM selection);
int editor_objectmap_duplicate_object(EditorMapLayer* layer, int id);
-SCM editor_objectmap_get_objects (EditorMapLayer* layer);
-SCM editor_objectmap_get_object (EditorMapLayer* layer, int id);
void editor_objectmap_set_pos (EditorMapLayer* layer, int id, int x,
int y);
void editor_tilemap_set_current(EditorMapLayer* layer);
void editor_objectmap_set_current(EditorMapLayer* layer);
void objmap_sprite_object_flip(EditorMapLayer* layer, int id);
-SCM tilemap_object_tool_get_objects();
-void tilemap_object_tool_set_objects(EditorMapLayer* layer, SCM lst);
void tilemap_object_tool_clear_selection();
-void objectmap_tool_set_popupmenu_callback(SCM callback);
-
CL_Component* editor_add_tileeditor(int x, int y, int w, int h);
void tileeditor_set_tile(CL_Component* comp, int id);
@@ -92,14 +77,8 @@
int screen_get_width();
int screen_get_height();
-SCM get_tile_def(int id);
-SCM get_tile_defs();
-SCM load_xml(const char* filename);
-
// Map stuff
EditorMap* editor_map_create();
-void editor_map_set_metadata(EditorMap* m, SCM data);
-SCM editor_map_get_metadata(EditorMap* m);
void editor_map_add_layer(EditorMap* m, EditorMapLayer* layer);
bool editor_map_is_modified(EditorMap* m);
void editor_map_set_unmodified(EditorMap* m);
@@ -114,8 +93,6 @@
void editor_toggle_attributes(EditorMapLayer* layer);
EditorMapLayer* editor_tilemap_create(Tileset* tileset, int w, int h, int
tile_size);
void editor_tilemap_resize(EditorMapLayer* , int w, int h, int x,
int y);
-void editor_tilemap_set_data(EditorMapLayer* l, SCM data);
-SCM editor_tilemap_get_data(EditorMapLayer* l);
int editor_tilemap_get_width(EditorMapLayer* l);
int editor_tilemap_get_height(EditorMapLayer* l);
void editor_tilemap_set_bgcolor(EditorMapLayer* l, int r, int g,
int b, int a);
@@ -130,12 +107,31 @@
Tileset* tileset_create(int tile_size);
Tileset* tileset_create_from_file(const char* resourcefile);
-void tileset_add_tile(Tileset* tileset, SCM data);
void tileset_set_current(Tileset* tileset);
EditorMapLayer* editor_mapsize_layer_create(int w, int h);
void editor_mapsize_layer_set_size(EditorMapLayer*, int w, int h);
+// Guile Specific Stuff
+SCM editor_get_tile_selection();
+void object_selector_add_brush(CL_Component* comp, const char* name, SCM
brush);
+int objectmap_add_object(EditorMapLayer* obj, const char* name, int x, int y,
SCM userdata);
+//int objectmap_add_sprite_object (EditorMapLayer* layer, SCM desc, int x,
int y, SCM userdata);
+void editor_objectmap_delete_objects (EditorMapLayer* layer,SCM selection);
+SCM editor_objectmap_get_objects (EditorMapLayer* layer);
+SCM editor_objectmap_get_object (EditorMapLayer* layer, int id);
+SCM tilemap_object_tool_get_objects();
+void tilemap_object_tool_set_objects(EditorMapLayer* layer, SCM lst);
+void objectmap_tool_set_popupmenu_callback(SCM callback);
+SCM get_tile_def(int id);
+SCM get_tile_defs();
+SCM load_xml(const char* filename);
+void editor_map_set_metadata(EditorMap* m, SCM data);
+SCM editor_map_get_metadata(EditorMap* m);
+void editor_tilemap_set_data(EditorMapLayer* l, SCM data);
+SCM editor_tilemap_get_data(EditorMapLayer* l);
+void tileset_add_tile(Tileset* tileset, SCM data);
+
#endif
/* EOF */
Modified: trunk/src/scripting/editor.i
===================================================================
--- trunk/src/scripting/editor.i 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/scripting/editor.i 2004-05-13 18:48:44 UTC (rev 315)
@@ -11,6 +11,7 @@
#include "netpanzer.hxx"
#include "../tile_brush.hxx"
+#ifdef SWIGGUILE
TileBrush scm2brush(SCM s_brush);
SCM brush2scm(const TileBrush& brush);
//std::string scm2string(SCM s);
@@ -20,9 +21,11 @@
component2scm(CL_Component* comp) {
return SWIG_NewPointerObj(comp, SWIGTYPE_p_CL_Component, 0);
}
+#endif
%}
+#ifdef SWIGGUILE
%typemap(in) SCMFunctor {
$1 = SCMFunctor($input);
}
@@ -48,6 +51,7 @@
%typemap(out) std::string {
$result = gh_str02scm($1.c_str());
}
+#endif
%newobject tileset_create();
Modified: trunk/src/scripting/gui.cxx
===================================================================
--- trunk/src/scripting/gui.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/scripting/gui.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -22,10 +22,14 @@
#include <ClanLib/display.h>
#include <ClanLib/gui.h>
#include <ClanLib/GUI/gui_manager.h>
-#include "scm_functor.hxx"
#include "../gui_manager.hxx"
#include "gui.hxx"
+#ifdef SWIGGUILE
+# include "scm_functor.hxx"
+#endif
+
+#ifdef SWIGGUILE
template<class A>
SCM any2scm(const A& a);
@@ -76,28 +80,7 @@
}
};
-CL_Component*
-gui_add_button(int x, int y, int w, int h, const char* text)
-{
- CL_Component* manager = GUIManager::current()->get_component();
- return new CL_Button(CL_Rect(CL_Point(x, y), CL_Size(w, h)),
- text, manager);
-}
-
void
-gui_component_set_position(CL_Component* comp, int x, int y)
-{
- comp->set_position(x, y);
-}
-
-void
-gui_component_set_rect(CL_Component* comp, int x, int y, int w, int h)
-{
- comp->set_position(CL_Rect(CL_Point(x, y),
- CL_Size(w, h)));
-}
-
-void
gui_component_on_click(CL_Component* comp, SCM func)
{
CL_Button* button = dynamic_cast<CL_Button*>(comp);
@@ -115,14 +98,6 @@
new
CL_Slot(window->sig_close().connect_functor_virtual(SCMVirtualFunctor(SCMFunctor(func))));
}
-CL_Component*
-gui_create_menu()
-{
- CL_Component* manager = GUIManager::current()->get_component();
- CL_Menu* menu = new CL_Menu(manager);
- //menu->add_child(new CL_Label(CL_Point(250, 5), "Hello World", menu));
- return menu;
-}
CL_MenuNode*
gui_add_menu_toggle_item(CL_Component* c_menu, const char* name, SCM func)
@@ -165,21 +140,82 @@
}
CL_Component*
-gui_create_button(int x, int y, int w, int h, const char* text)
+gui_create_button_func(int x, int y, int w, int h, const char* text, SCM func)
{
+ CL_Component* comp = gui_create_button(x, y, w, h, text);
+ gui_component_on_click(comp, func);
+ return comp;
+}
+
+void
+gui_file_dialog(const char* filename, SCM func)
+{
+ try {
+ new CL_FileDialog("File Dialog", "/", "",
GUIManager::current()->get_component());
+ } catch (CL_Error& err) {
+ std::cout << "CL_Error: " << err.message << std::endl;
+ }
+}
+
+void
+gui_listbox_on_click(CL_Component* box, SCM func)
+{
+ CL_ListBox* listbox = dynamic_cast<CL_ListBox*>(box);
+ if (listbox)
+ {
+ new
CL_Slot(listbox->sig_highlighted().connect_functor(SCMGenericFunctor1<int>(func)));
+ }
+}
+
+void gui_add_on_resize_callback(SCM func)
+{
+ new CL_Slot(CL_Display::get_current_window()->sig_resize().
+ connect_functor(SCMGenericFunctor2<int, int>(func)));
+}
+
+#endif
+// ---------------------------------------------------------------
+
+CL_Component*
+gui_add_button(int x, int y, int w, int h, const char* text)
+{
CL_Component* manager = GUIManager::current()->get_component();
return new CL_Button(CL_Rect(CL_Point(x, y), CL_Size(w, h)),
text, manager);
}
+void
+gui_component_set_position(CL_Component* comp, int x, int y)
+{
+ comp->set_position(x, y);
+}
+
+void
+gui_component_set_rect(CL_Component* comp, int x, int y, int w, int h)
+{
+ comp->set_position(CL_Rect(CL_Point(x, y),
+ CL_Size(w, h)));
+}
+
+
CL_Component*
-gui_create_button_func(int x, int y, int w, int h, const char* text, SCM func)
+gui_create_menu()
{
- CL_Component* comp = gui_create_button(x, y, w, h, text);
- gui_component_on_click(comp, func);
- return comp;
+ CL_Component* manager = GUIManager::current()->get_component();
+ CL_Menu* menu = new CL_Menu(manager);
+ //menu->add_child(new CL_Label(CL_Point(250, 5), "Hello World", menu));
+ return menu;
}
+CL_Component*
+gui_create_button(int x, int y, int w, int h, const char* text)
+{
+ CL_Component* manager = GUIManager::current()->get_component();
+ return new CL_Button(CL_Rect(CL_Point(x, y), CL_Size(w, h)),
+ text, manager);
+}
+
+
CL_Component*
gui_create_label(int x, int y, const char* text)
{
@@ -273,15 +309,6 @@
return comp->get_client_area();
}
-void
-gui_file_dialog(const char* filename, SCM func)
-{
- try {
- new CL_FileDialog("File Dialog", "/", "",
GUIManager::current()->get_component());
- } catch (CL_Error& err) {
- std::cout << "CL_Error: " << err.message << std::endl;
- }
-}
void
gui_quit()
@@ -323,22 +350,7 @@
return -1;
}
-void
-gui_listbox_on_click(CL_Component* box, SCM func)
-{
- CL_ListBox* listbox = dynamic_cast<CL_ListBox*>(box);
- if (listbox)
- {
- new
CL_Slot(listbox->sig_highlighted().connect_functor(SCMGenericFunctor1<int>(func)));
- }
-}
-void gui_add_on_resize_callback(SCM func)
-{
- new CL_Slot(CL_Display::get_current_window()->sig_resize().
- connect_functor(SCMGenericFunctor2<int, int>(func)));
-}
-
int gui_component_get_width(CL_Component* comp)
{
return comp->get_width();
Modified: trunk/src/scripting/gui.hxx
===================================================================
--- trunk/src/scripting/gui.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/scripting/gui.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -20,7 +20,9 @@
#ifndef HEADER_SCRIPTING_GUI_HXX
#define HEADER_SCRIPTING_GUI_HXX
+#ifdef SWIGGUILE
#include <guile/gh.h>
+#endif
class CL_MenuNode;
class CL_Component;
@@ -38,13 +40,9 @@
/** Create a window at the given position \a x, \a y and with the
given dimensions \w and \h, all units in pixel */
CL_Component* gui_create_window(int x, int y,
- int w, int h,
- const char* title);
+ int w, int h,
+ const char* title);
-/** Create a button which launches func on click */
-CL_Component* gui_create_button_func(int x, int y, int w, int h, const char*
text,
- SCM func);
-
/** Create a button without attaching a callback directly to it,
attaching a callback can later be done with a signal function. */
CL_Component* gui_create_button(int x, int y, int w, int h, const char* text);
@@ -59,21 +57,10 @@
/** Create a menu */
CL_Component* gui_create_menu();
-/** Add an item to a menu */
-void gui_add_menu_item(CL_Component* menu, const char* name, SCM func);
-CL_MenuNode* gui_add_menu_toggle_item(CL_Component* c_menu, const char* name,
SCM func);
-
/** Remove the component \a comp from its parent
FIXME: Who deallocates?! */
void gui_remove_component(CL_Component* comp);
-/** Connect a function to an on_click event */
-void gui_component_on_click(CL_Component* comp, SCM func);
-
-/** Connect a function to an on_close event, mainly used to react on
- window closing */
-void gui_component_on_close(CL_Component* comp, SCM func);
-
int gui_component_get_width(CL_Component* comp);
int gui_component_get_height(CL_Component* comp);
@@ -98,13 +85,9 @@
std::string gui_inputbox_get_text(CL_Component* comp);
void gui_inputbox_set_text(CL_Component* comp, std::string str);
-/** Start a file dialog, call func once ok is pressed.
- @param filename The directory where to start the file manager in */
-void gui_file_dialog(const char* filename, SCM func);
CL_Component* gui_listbox_create(int x, int y, int w, int h);
int gui_listbox_add(CL_Component* box, const char* str);
-void gui_listbox_on_click(CL_Component* box, SCM func);
/** Quit the GUI manager, works only if the GUIManager is in a busy loop */
void gui_quit();
@@ -113,7 +96,29 @@
void gui_show();
bool gui_is_visible();
+#ifdef SWIGGUILE
+/** Create a button which launches func on click */
+CL_Component* gui_create_button_func(int x, int y, int w, int h, const char*
text,
+ SCM func);
+/** Add an item to a menu */
+void gui_add_menu_item(CL_Component* menu, const char* name, SCM func);
+CL_MenuNode* gui_add_menu_toggle_item(CL_Component* c_menu, const char* name,
SCM func);
+
+/** Connect a function to an on_click event */
+void gui_component_on_click(CL_Component* comp, SCM func);
+
+/** Connect a function to an on_close event, mainly used to react on
+ window closing */
+void gui_component_on_close(CL_Component* comp, SCM func);
+
+/** Start a file dialog, call func once ok is pressed.
+ @param filename The directory where to start the file manager in */
+void gui_file_dialog(const char* filename, SCM func);
+
+void gui_listbox_on_click(CL_Component* box, SCM func);
+
void gui_add_on_resize_callback(SCM func);
+#endif
#endif
Modified: trunk/src/tileset.cxx
===================================================================
--- trunk/src/tileset.cxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/tileset.cxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -42,6 +42,7 @@
std::cout << "Tileset: destroy" << std::endl;
}
+#ifdef SWIGGUILE
void
Tileset::load_tile_file(const std::string& filename)
{
@@ -88,7 +89,7 @@
Tileset::add_tile(SCM data)
{
// FIXME: Move this to scripting and add a Tileset::add()
- int id;
+ int id = 0;
std::string image;
CL_Color color(254, 254, 254, 254);
CL_Color attribute_color(255, 255, 255, 100);
@@ -175,6 +176,7 @@
tiles[id]->id = id;
}
}
+#endif
Tile*
Tileset::create (int id)
Modified: trunk/src/tileset.hxx
===================================================================
--- trunk/src/tileset.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/tileset.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -20,7 +20,9 @@
#ifndef TILESET_HXX
#define TILESET_HXX
+#ifdef SWIGGUILE
#include <libguile.h>
+#endif
#include <map>
#include <string>
@@ -72,8 +74,10 @@
static Tileset* current() { return current_; }
static void set_current(Tileset* c) { current_ = c; }
+#ifdef SWIGGUILE
void load_tile_file(const std::string& filename);
void add_tile(SCM data);
+#endif
};
#endif
Modified: trunk/src/workspace.hxx
===================================================================
--- trunk/src/workspace.hxx 2004-05-12 11:44:42 UTC (rev 314)
+++ trunk/src/workspace.hxx 2004-05-13 18:48:44 UTC (rev 315)
@@ -70,9 +70,6 @@
WorkspaceItem* get_current_item();
EditorMap* get_current_map();
void set_current_map(EditorMap* );
-private:
- Workspace (const Workspace&);
- Workspace& operator= (const Workspace&);
};
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 315 - in trunk: . src src/scripting,
Ingo Ruhnke <=