windstille-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Windstille-devel] rev 344 - in trunk/src: . scripting


From: Ingo Ruhnke
Subject: [Windstille-devel] rev 344 - in trunk/src: . scripting
Date: Wed, 19 May 2004 01:26:29 +0200

Author: grumbel
Date: 2004-05-19 01:26:29 +0200 (Wed, 19 May 2004)
New Revision: 344

Added:
   trunk/src/icon.cxx
   trunk/src/icon.hxx
   trunk/src/simpleed.hxx
Removed:
   trunk/src/supertux-editor
Modified:
   trunk/src/SConstruct
   trunk/src/editor.py
   trunk/src/flexlay.i
   trunk/src/object_move_command.cxx
   trunk/src/object_move_command.hxx
   trunk/src/scripting/editor.cxx
   trunk/src/scripting/editor.hxx
   trunk/src/simpleed.cxx
   trunk/src/supertux.py
Log:
- added icon support
- moved stuff into a seperate lib

Modified: trunk/src/SConstruct
===================================================================
--- trunk/src/SConstruct        2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/SConstruct        2004-05-18 23:26:29 UTC (rev 344)
@@ -28,69 +28,26 @@
                              'gui_manager.hxx',
                              'tile_selector.hxx',
                              'object_brush.hxx',
-                             'object_selector.hxx']) 
+                             'object_selector.hxx'])
+
 env.Command('flexlay_wrap.cxx', 'flexlay.i', "swig -python -c++ $SOURCE")
 
 env.Program('sharedptrtest', 'sharedptrtest.cxx',
             
CPPPATH=['/home/ingo/run/ClanLib-0.7-current//include/ClanLib-0.7/'])
 
 env.Program('simpleed',
-            ['simpleed.cxx',
-             'blitter.cxx',
-             'command_group.cxx',
-             'editor.cxx',
-             'editor_map.cxx',
-             'editor_map_component.cxx',
-             'flexlay.cxx',
-             'globals.cxx',
-             'layer.cxx',
-             'graphic_context_state.cxx',
-             'gui_manager.cxx',
-             'minimap.cxx',
-             'object_layer.cxx',
-             'object_add_command.cxx',
-             'object_brush.cxx',
-             'object_delete_command.cxx',
-             'object_move_command.cxx',
-             'object_selector.cxx',
-             'object_transform_command.cxx',
-             'objmap_object.cxx',
-             'objmap_select_tool.cxx',
-             'objmap_sprite_object.cxx',
-             'paint_command.cxx',
-             'popup_menu.cxx',
-             'lispreader.cxx',
-             'tile.cxx',
-             'tile_brush.cxx',
-             'tile_editor.cxx',
-             'tile_selection.cxx',
-             'tile_selector.cxx',
-             'tilemap_paint_tool.cxx',
-             'tilemap_select_tool.cxx',
-             'tilemap_tool.cxx',
-             'tilemap_layer.cxx',
-             'tileset.cxx',
-             'tool_manager.cxx',
-             'workspace.cxx',
-             'zoom_tool.cxx'],
-            CPPPATH=['..', 
'/home/ingo/run/ClanLib-0.7-current//include/ClanLib-0.7/'],
+            ['simpleed.cxx'],
+            CPPPATH=['.', 
+                     
'/home/ingo/run/ClanLib-0.7-current//include/ClanLib-0.7/'],
             LIBPATH=['.', '/home/ingo/run/ClanLib-0.7-current//lib/'],
-            LIBS=['clanCore',
-                  'clanDisplay',
-                  'clanGL',
-                  'clanSignals',
-                  'clanGUI',
-                  'clanGUIStyleSilver'])
+            LIBS=['flexlay'])
 
-
 env.SharedLibrary(
-    target = '_flexlay.so',
+    target = 'libflexlay.so',
     source = [
     'blitter.cxx',
-    'flexlay_wrap.cxx',
     'command_group.cxx',
     'editor.cxx',
-    'scripting/editor.cxx',
     'editor_map.cxx',
     'editor_map_component.cxx',
     'flexlay.cxx',
@@ -98,6 +55,7 @@
     'layer.cxx',
     'graphic_context_state.cxx',
     'gui_manager.cxx',
+    'icon.cxx',
     'minimap.cxx',
     'object_layer.cxx',
     'object_add_command.cxx',
@@ -111,10 +69,6 @@
     'objmap_sprite_object.cxx',
     'paint_command.cxx',
     'popup_menu.cxx',
-    'python_functor.cxx',
-    'python_object.cxx',
-    'scripting/gui.cxx',
-    'sexpr_parser.cxx',
     'lispreader.cxx',
     'tile.cxx',
     'tile_brush.cxx',
@@ -130,9 +84,9 @@
     'workspace.cxx',
     '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/'],
+    LINKFLAGS = ['-Wl,-rpath', '/home/ingo/run/ClanLib-0.7-current/lib/'],
+    LIBPATH=['/home/ingo/run/ClanLib-0.7-current/lib/'],
     LIBS=['clanCore',
           'clanDisplay',
           'clanGL',
@@ -140,4 +94,18 @@
           'clanGUI',
           'clanGUIStyleSilver'])
 
+env.SharedLibrary(
+    target = '_flexlay.so',
+    source = [
+    'flexlay_wrap.cxx',
+    'scripting/editor.cxx',
+    'python_functor.cxx',
+    'python_object.cxx',
+    'sexpr_parser.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=['flexlay'])
+
 # EOF #

Modified: trunk/src/editor.py
===================================================================
--- trunk/src/editor.py 2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/editor.py 2004-05-18 23:26:29 UTC (rev 344)
@@ -33,13 +33,12 @@
 m = EditorMap()
 workspace.set_current_map(m)
 
+tileset = load_supertux_tiles()
 tilemap = TilemapLayer(tileset, 20, 10)
 m.add_layer(tilemap.to_layer())
     
 TilemapLayer_set_current(tilemap)
 
-editor_set_brush_tile(1)
-
 def foo():
     print "---My Callback---"
     gui.quit()
@@ -61,19 +60,30 @@
 
 window = CL_Window(CL_Rect(50, 50, 350, 300), "My Window", gui.get_component())
     
-gui.push_component(window)
+gui.push_component(window.get_client_area())
 button1 = CL_Button(CL_Rect(50, 50, 200, 75), "Quit", gui.get_component())
 connect(button1.sig_clicked(), foo)
 
 button2 = CL_Button(CL_Rect(CL_Point(50, 100), CL_Size(150, 25)), "Draw", 
gui.get_component())
 connect(button2.sig_clicked(), draw_something)
 
+load_icon    = Icon(CL_Point(34*0, 0), 
make_sprite("../data/images/icons/stock_open.png"), "Some tooltip", 
gui.get_component());
+save_icon    = Icon(CL_Point(34*1, 0), 
make_sprite("../data/images/icons/stock_save.png"), "Some tooltip", 
gui.get_component());
+save_as_icon = Icon(CL_Point(34*2, 0), 
make_sprite("../data/images/icons/stock_save_as.png"), "Some tooltip", 
gui.get_component());
+
+copy_icon    = Icon(CL_Point(34*3.1, 0), 
make_sprite("../data/images/icons/stock_copy.png"), "Some tooltip", 
gui.get_component());
+paste_icon   = Icon(CL_Point(34*4.1, 0), 
make_sprite("../data/images/icons/stock_paste.png"), "Some tooltip", 
gui.get_component());
+
+def foo():
+    print "Button pressed"
+
+connect(load_icon.sig_clicked(), foo)
+
+gui.get_component()
+
 gui.pop_component()
 
-tileselectorw = CL_Window(CL_Rect(CL_Point(150, 150), CL_Size(210, 210)), 
"Tile Selector", gui.get_component())
-tileselector = TileSelector(5, 3, tileselectorw.get_client_area())
-tileselector.set_tileset(tileset)
-tileselector.set_tiles(range(1,100))
+supertux = SuperTuxGUI(tileset, gui)
 
 class Menu(CL_Menu):
     def __init__(self):

Modified: trunk/src/flexlay.i
===================================================================
--- trunk/src/flexlay.i 2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/flexlay.i 2004-05-18 23:26:29 UTC (rev 344)
@@ -32,6 +32,7 @@
 #include "object_brush.hxx"
 #include "object_selector.hxx"
 #include "sexpr_parser.hxx"
+#include "icon.hxx"
 %}
 
 %include "std_string.i"
@@ -63,6 +64,7 @@
 %include "object_brush.hxx"
 %include "object_selector.hxx"
 %include "sexpr_parser.hxx"
+%include "icon.hxx"
 
 
 /* EOF */

Added: trunk/src/icon.cxx
===================================================================
--- trunk/src/icon.cxx  2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/icon.cxx  2004-05-18 23:26:29 UTC (rev 344)
@@ -0,0 +1,123 @@
+//  $Id$
+//
+//  Pingus - A free Lemmings clone
+//  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.
+
+#include <ClanLib/Display/display.h>
+#include "icon.hxx"
+
+class IconImpl
+{
+public:
+  IconImpl(Icon* p) : parent(p) {}
+
+  Icon* parent;
+
+  std::vector<CL_Slot> slots;
+  CL_Sprite sprite;
+  std::string tooltip;
+  bool draw_tooltip;
+  bool down;
+  CL_Signal_v0 sig_on_click;
+
+  void draw();
+
+  void mouse_up  (const CL_InputEvent& event);
+  void mouse_down(const CL_InputEvent& event);
+  void mouse_move(const CL_InputEvent& event);
+};
+
+Icon::Icon(const CL_Point& pos, const CL_Sprite& sprite, const std::string& 
tooltip, 
+           CL_Component* parent)
+  : CL_Component(CL_Rect(pos, CL_Size(34, 34)), parent),
+    impl(new IconImpl(this))
+{
+  impl->sprite       = sprite;
+  impl->tooltip      = tooltip;
+  impl->draw_tooltip = true;
+  impl->down         = false;
+
+  impl->slots.push_back(sig_paint().connect(impl.get(), &IconImpl::draw));
+  impl->slots.push_back(sig_mouse_down().connect(impl.get(), 
&IconImpl::mouse_down));
+  impl->slots.push_back(sig_mouse_up().connect(impl.get(),   
&IconImpl::mouse_up));
+}
+
+CL_Signal_v0&
+Icon::sig_clicked()
+{
+  return impl->sig_on_click;
+}
+  
+void
+IconImpl::draw()
+{
+  CL_Color background(220, 220, 220);
+  CL_Color background_hl(235, 235, 235);
+  CL_Color background_sw(200, 200, 200);
+  CL_Color highlight(255, 255, 255);
+  CL_Color shadow(0, 0, 0);
+
+  if (parent->has_mouse_over())
+    if (!down)
+      CL_Display::fill_rect(CL_Rect(CL_Point(0, 0), CL_Size(34, 34)), 
background_hl);
+    else
+      CL_Display::fill_rect(CL_Rect(CL_Point(0, 0), CL_Size(34, 34)), 
background_sw);
+  else
+    CL_Display::fill_rect(CL_Rect(CL_Point(0, 0), CL_Size(34, 34)), 
background);
+
+  if (parent->has_mouse_over() && down)
+    std::swap(highlight, shadow);
+
+  if (parent->has_mouse_over())
+    { 
+      CL_Display::draw_line(0, 0,  0, 33, highlight);
+      CL_Display::draw_line(0, 0, 33,  0, highlight);
+      
+      CL_Display::draw_line(33,  0, 33, 33, shadow);
+      CL_Display::draw_line( 0, 33, 33, 33, shadow);
+    }
+
+  sprite.set_alignment(origin_center);
+  sprite.draw(17, 17);
+}
+
+void
+IconImpl::mouse_up  (const CL_InputEvent& event)
+{
+  down         = false;
+  parent->release_mouse();  
+
+  if (parent->has_mouse_over())
+    {
+      sig_on_click();
+    }
+}
+
+void
+IconImpl::mouse_down(const CL_InputEvent& event)
+{
+  down         = true;
+  parent->capture_mouse();
+}
+
+void 
+IconImpl::mouse_move(const CL_InputEvent& event)
+{
+  
+}
+
+/* EOF */

Added: trunk/src/icon.hxx
===================================================================
--- trunk/src/icon.hxx  2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/icon.hxx  2004-05-18 23:26:29 UTC (rev 344)
@@ -0,0 +1,48 @@
+//  $Id$
+// 
+//  Pingus - A free Lemmings clone
+//  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.
+
+#ifndef HEADER_ICON_HXX
+#define HEADER_ICON_HXX
+
+#include <ClanLib/GUI/component.h>
+#include <ClanLib/Core/Math/point.h>
+#include <ClanLib/Display/sprite.h>
+#include "shared_ptr.hxx"
+
+class IconImpl;
+
+/** */
+class Icon : public CL_Component
+{
+private:
+public:
+  Icon(const CL_Point& pos, const CL_Sprite& sprite, const std::string& 
tooltip, CL_Component* parent);
+  
+  CL_Signal_v0& sig_clicked();
+
+private:
+  Icon (const Icon&);
+  Icon& operator= (const Icon&);
+
+  SharedPtr<IconImpl> impl;
+};
+
+#endif
+
+/* EOF */

Modified: trunk/src/object_move_command.cxx
===================================================================
--- trunk/src/object_move_command.cxx   2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/object_move_command.cxx   2004-05-18 23:26:29 UTC (rev 344)
@@ -21,20 +21,42 @@
 #include "objmap_object.hxx"
 #include "object_move_command.hxx"
 
+class ObjectMoveCommandImpl
+{
+public:
+  ObjectMoveCommandImpl() {}
+  ~ObjectMoveCommandImpl() {}
+
+  ObjectLayer* objmap;
+  
+  struct Obj {
+    CL_Point old_pos;
+    CL_Point new_pos;
+    int id;
+  };
+  
+  typedef std::vector<Obj> Objects;
+  Objects objects;
+};
+
 ObjectMoveCommand::ObjectMoveCommand(ObjectLayer* o)
-  : objmap(o)
+  : impl(new ObjectMoveCommandImpl())
 {
-  
+  impl->objmap = o;
 }
+
+ObjectMoveCommand::~ObjectMoveCommand()
+{
+}
   
 void
 ObjectMoveCommand::execute()
 {
-  for(Objects::iterator i = objects.begin(); 
-      i != objects.end();
+  for(ObjectMoveCommandImpl::Objects::iterator i = impl->objects.begin(); 
+      i != impl->objects.end();
       ++i)
     {
-      ObjMapObject* obj = objmap->get_object(i->id);
+      ObjMapObject* obj = impl->objmap->get_object(i->id);
       if (obj) 
         {
           i->new_pos = obj->get_pos();
@@ -45,25 +67,25 @@
 void
 ObjectMoveCommand::add_obj(int id)
 {
-  ObjMapObject* obj = objmap->get_object(id);
+  ObjMapObject* obj = impl->objmap->get_object(id);
 
   if (obj)
     {
-      Obj o;
+      ObjectMoveCommandImpl::Obj o;
       o.id      = id;
       o.old_pos = obj->get_pos();
-      objects.push_back(o);
+      impl->objects.push_back(o);
     }
 }
 
 void
 ObjectMoveCommand::redo()
 {
-  for(Objects::iterator i = objects.begin(); 
-      i != objects.end();
+  for(ObjectMoveCommandImpl::Objects::iterator i = impl->objects.begin(); 
+      i != impl->objects.end();
       ++i)
     {
-      ObjMapObject* obj = objmap->get_object(i->id);
+      ObjMapObject* obj = impl->objmap->get_object(i->id);
       if (obj)
         {
           obj->set_pos(i->new_pos);
@@ -74,11 +96,11 @@
 void
 ObjectMoveCommand::undo()
 {
-  for(Objects::iterator i = objects.begin(); 
-      i != objects.end();
+  for(ObjectMoveCommandImpl::Objects::iterator i = impl->objects.begin(); 
+      i != impl->objects.end();
       ++i)
     {
-      ObjMapObject* obj = objmap->get_object(i->id);
+      ObjMapObject* obj = impl->objmap->get_object(i->id);
       if (obj)
         {
           obj->set_pos(i->old_pos);

Modified: trunk/src/object_move_command.hxx
===================================================================
--- trunk/src/object_move_command.hxx   2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/object_move_command.hxx   2004-05-18 23:26:29 UTC (rev 344)
@@ -24,23 +24,14 @@
 
 class ObjectLayer;
 
+class ObjectMoveCommandImpl;
+
 /** */
 class ObjectMoveCommand : public Command
 {
-private:
-  ObjectLayer* objmap;
-
-  struct Obj {
-    CL_Point old_pos;
-    CL_Point new_pos;
-    int id;
-  };
-  
-  typedef std::vector<Obj> Objects;
-  Objects objects;
 public:
   ObjectMoveCommand(ObjectLayer* o);
-  virtual ~ObjectMoveCommand() {}
+  virtual ~ObjectMoveCommand();
 
   void add_obj(int id);
 
@@ -49,6 +40,9 @@
   void undo();
 
   std::string serialize();
+
+private:
+  SharedPtr<ObjectMoveCommandImpl> impl;
 };
 
 #endif

Modified: trunk/src/scripting/editor.cxx
===================================================================
--- trunk/src/scripting/editor.cxx      2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/scripting/editor.cxx      2004-05-18 23:26:29 UTC (rev 344)
@@ -17,6 +17,8 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <ClanLib/Display/sprite_description.h>
+#include <ClanLib/Display/Providers/provider_factory.h>
 #include <ClanLib/Signals/signal_v0.h>
 #include "../python_functor.hxx"
 #include "editor.hxx"
@@ -27,4 +29,12 @@
   new CL_Slot(sig.connect_functor(PythonFunctor(obj)));
 }
 
+CL_Sprite
+make_sprite(const std::string& filename)
+{
+  CL_SpriteDescription desc;
+  desc.add_frame(CL_ProviderFactory::load(filename), true);
+  return CL_Sprite(desc);
+}
+
 /* EOF */

Modified: trunk/src/scripting/editor.hxx
===================================================================
--- trunk/src/scripting/editor.hxx      2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/scripting/editor.hxx      2004-05-18 23:26:29 UTC (rev 344)
@@ -21,20 +21,17 @@
 #define HEADER_SCRIPTING_EDITOR_HXX
 
 #include <string>
-#include <vector>
 
+#include <ClanLib/Display/sprite.h>
+#include <ClanLib/Display/display.h>
 #include <ClanLib/Signals/signal_v0.h>
 
-#ifdef SWIGGUILE
-#  include <guile/gh.h>
-#endif
-
-#include "../tilemap_layer.hxx"
-
 #include "Python.h"
 
 void connect(CL_Signal_v0& sig, PyObject* obj);
 
+CL_Sprite make_sprite(const std::string& filename);
+
 #endif
 
 /* EOF */

Modified: trunk/src/simpleed.cxx
===================================================================
--- trunk/src/simpleed.cxx      2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/simpleed.cxx      2004-05-18 23:26:29 UTC (rev 344)
@@ -39,9 +39,9 @@
 
   GUIManager* gui = editor.get_gui_manager();
 
-  CL_Button* button = new CL_Button(CL_Rect(CL_Point(50, 50), 
-                                            CL_Size(100, 25)),
-                                    "Hello World", gui->get_component());
+  new CL_Button(CL_Rect(CL_Point(50, 50), 
+                        CL_Size(100, 25)),
+                "Hello World", gui->get_component());
 
   EditorMap m;
   Tileset tileset(32);
@@ -56,9 +56,9 @@
   editor_map.set_workspace(workspace);
   workspace.set_current_map(m);
  
-  CL_Button* button2 = new CL_Button(CL_Rect(CL_Point(50, 150), 
-                                             CL_Size(100, 25)),
-                                     "Quit", gui->get_component());
+  new CL_Button(CL_Rect(CL_Point(50, 150), 
+                        CL_Size(100, 25)),
+                "Quit", gui->get_component());
 
   gui->run();
  

Added: trunk/src/simpleed.hxx
===================================================================
--- trunk/src/simpleed.hxx      2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/simpleed.hxx      2004-05-18 23:26:29 UTC (rev 344)
@@ -0,0 +1,27 @@
+//  $Id$
+// 
+//  Pingus - A free Lemmings clone
+//  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.
+
+#ifndef HEADER_SIMPLEED_HXX
+#define HEADER_SIMPLEED_HXX
+
+
+
+#endif
+
+/* EOF */

Deleted: trunk/src/supertux-editor
===================================================================
--- trunk/src/supertux-editor   2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/supertux-editor   2004-05-18 23:26:29 UTC (rev 344)
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-export PATH=".:$PATH"
-exec flexlay --game supertux.scm "$@"
-
-# EOF #

Modified: trunk/src/supertux.py
===================================================================
--- trunk/src/supertux.py       2004-05-18 19:35:55 UTC (rev 343)
+++ trunk/src/supertux.py       2004-05-18 23:26:29 UTC (rev 344)
@@ -21,7 +21,7 @@
 from sexpr   import *
 import time
 
-time.sleep(1)
+supertux_datadir = "/home/ingo/cvs/supertux/supertux/data/"
 
 def load_game_tiles(tileset, filename):
     "Load game tiles from filename into tileset"
@@ -94,43 +94,45 @@
     tileselector_window = None
     tileselector = None
 
-    def __init__(self):
-        self.tileselector_window = CL_Window(CL_Rect(CL_Point(150, 150), 
CL_Size(210, 210)),
+    def __init__(self, tileset, gui):
+        self.tileselector_window = CL_Window(CL_Rect(CL_Point(580, 30), 
CL_Size(210, 560)),
                                              "Tile Selector", 
gui.get_component())
-        self.tileselector = TileSelector(5, 3, 
self.tileselector_window.get_client_area())
+        self.tileselector = TileSelector(6, 3, 
self.tileselector_window.get_client_area())
         self.tileselector.set_tileset(tileset)
         self.tileselector.set_tiles(range(1,100))
+
+def load_supertux_tiles():
+    tileset = Tileset(32)
+    load_game_tiles(tileset, 
"/home/ingo/cvs/supertux/supertux/data/images/tilesets/supertux.stgt")
+    return tileset 
         
-### Begin: 'Main Loop'
-supertux_datadir = "/home/ingo/cvs/supertux/supertux/data/"
+def main_loop():
+    flexlay = Flexlay()
+    flexlay.init()
 
-flexlay = Flexlay()
-flexlay.init()
+    editor = Editor()
+    gui = editor.get_gui_manager()
 
-editor = Editor()
-gui = editor.get_gui_manager()
+    tileset = load_supertux_tiles()
+    editor_map = EditorMapComponent(CL_Rect(0, 0, 799, 599), 
gui.get_component())
+    workspace  = Workspace(799, 599)
+    editor_map.set_workspace(workspace)
 
-tileset = Tileset(32)
-load_game_tiles(tileset, 
"/home/ingo/cvs/supertux/supertux/data/images/tilesets/supertux.stgt")
+    m = EditorMap()
+    workspace.set_current_map(m)
     
-editor_map = EditorMapComponent(CL_Rect(0, 0, 799, 599), gui.get_component())
-workspace  = Workspace(799, 599)
-editor_map.set_workspace(workspace)
+    tilemap = TilemapLayer(tileset, 20, 10)
+    m.add_layer(tilemap.to_layer())
+    
+    window = CL_Window(CL_Rect(50, 50, 350, 300), "My Window", 
gui.get_component())
+    
+    supertux_gui = SuperTuxGUI()
 
-m = EditorMap()
-workspace.set_current_map(m)
-
-tilemap = TilemapLayer(tileset, 20, 10)
-m.add_layer(tilemap.to_layer())
-
-window = CL_Window(CL_Rect(50, 50, 350, 300), "My Window", gui.get_component())
-
-supertux_gui = SuperTuxGUI()
-
-print "Launching GUI"
-gui.run()
-
-flexlay.deinit()
+    print "Launching GUI"
+    gui.run()
+    
+    flexlay.deinit()
+    
 ### End: 'Main Loop'
 
 # EOF #





reply via email to

[Prev in Thread] Current Thread [Next in Thread]