windstille-devel
[Top][All Lists]
Advanced

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

[Windstille-devel] rev 327 - trunk/src


From: Ingo Ruhnke
Subject: [Windstille-devel] rev 327 - trunk/src
Date: Sat, 15 May 2004 03:05:27 +0200

Author: grumbel
Date: 2004-05-15 03:05:27 +0200 (Sat, 15 May 2004)
New Revision: 327

Modified:
   trunk/src/editor.py
   trunk/src/editor_tilemap.hxx
   trunk/src/field.hxx
   trunk/src/flexlay.i
Log:
- added get/set_data for tilemap

Modified: trunk/src/editor.py
===================================================================
--- trunk/src/editor.py 2004-05-15 00:42:22 UTC (rev 326)
+++ trunk/src/editor.py 2004-05-15 01:05:27 UTC (rev 327)
@@ -33,7 +33,7 @@
 m = EditorMap("Foobar")
 workspace.set_current_map(m)
 tileset = Tileset(32)
-tilemap = EditorTileMap(tileset, 100, 50)
+tilemap = EditorTileMap(tileset, 20, 10)
 m.add_layer(tilemap)
 tile = Tile("/home/ingo/cvs/supertux/supertux/data/images/tilesets/bonus1.png",
             CL_Color(255, 255, 255, 255),
@@ -66,7 +66,7 @@
     g = _
     print "Draw something done"
 
-window = CL_Window(CL_Rect(50, 50, 350, 250), "My Window", gui.get_component())
+window = CL_Window(CL_Rect(50, 50, 350, 300), "My Window", gui.get_component())
 
 gui.push_component(window)
 button1 = CL_Button(CL_Rect(50, 50, 200, 75), "Quit", gui.get_component())
@@ -74,12 +74,25 @@
 
 button2 = CL_Button(CL_Rect(CL_Point(50, 100), CL_Size(150, 25)), "Draw", 
gui.get_component())
 connect(button2.sig_clicked(), draw_something)
+
+def get_data():
+    print tilemap.get_data()
+
+def set_data():
+    tilemap.set_data((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0))
+
+button3 = CL_Button(CL_Rect(CL_Point(50, 150), CL_Size(150, 25)), "Get Data", 
gui.get_component())
+connect(button3.sig_clicked(), get_data)
+
+button4 = CL_Button(CL_Rect(CL_Point(50, 180), CL_Size(150, 25)), "Get Data", 
gui.get_component())
+connect(button4.sig_clicked(), set_data)
+
 gui.pop_component()
 
 class Menu(CL_Menu):
     def __init__(self):
         CL_Menu.__init__(self, gui.get_component())
-    
+
     def add_item(self, name, func):
         item = self.create_item(name)
         connect(item.sig_clicked(), func)

Modified: trunk/src/editor_tilemap.hxx
===================================================================
--- trunk/src/editor_tilemap.hxx        2004-05-15 00:42:22 UTC (rev 326)
+++ trunk/src/editor_tilemap.hxx        2004-05-15 01:05:27 UTC (rev 327)
@@ -72,6 +72,9 @@
 
   Field<int>* get_map() { return &field; }
 
+  std::vector<int> get_data() { return field.get_data(); }
+  void set_data(std::vector<int> d) { field.set_data(d); }
+
   /** Draw the gives brush to the map */
   void draw_tile(const TileBrush& brush, const CL_Point& pos);
 

Modified: trunk/src/field.hxx
===================================================================
--- trunk/src/field.hxx 2004-05-15 00:42:22 UTC (rev 326)
+++ trunk/src/field.hxx 2004-05-15 01:05:27 UTC (rev 327)
@@ -121,6 +121,12 @@
     vec.clear();
   }
 
+  std::vector<T>& get_data() { return vec; }
+  void set_data(const std::vector<T>& d) { 
+    for(typename std::vector<T>::size_type i = 0; i < vec.size() && i < 
d.size(); ++i)
+      vec[i] = d[i]; 
+  }
+
   iterator begin () { return vec.begin (); }
   iterator end () { return vec.end (); }
 

Modified: trunk/src/flexlay.i
===================================================================
--- trunk/src/flexlay.i 2004-05-15 00:42:22 UTC (rev 326)
+++ trunk/src/flexlay.i 2004-05-15 01:05:27 UTC (rev 327)
@@ -1,5 +1,5 @@
 %module flexlay
-
+ 
 %{
 #include <ClanLib/Display/color.h>
 #include <ClanLib/GUI/component.h>
@@ -33,6 +33,8 @@
 
 %include "std_string.i"
 %include "std_vector.i"
+%template(std_vector_int) std::vector<int>;
+
 %include "clanlib.i"
 %include "scripting/editor.hxx"
 %include "command.hxx"
@@ -57,4 +59,5 @@
 %include "object_brush.hxx"
 %include "object_selector.hxx"
 
+
 /* EOF */





reply via email to

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