windstille-devel
[Top][All Lists]
Advanced

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

[Windstille-devel] rev 398 - trunk/src


From: Ingo Ruhnke
Subject: [Windstille-devel] rev 398 - trunk/src
Date: Sun, 06 Jun 2004 21:28:47 +0200

Author: grumbel
Date: 2004-06-06 21:28:47 +0200 (Sun, 06 Jun 2004)
New Revision: 398

Modified:
   trunk/src/flexlay.rb
   trunk/src/gui.rb
   trunk/src/supertux.rb
Log:
- more ruby fixes

Modified: trunk/src/flexlay.rb
===================================================================
--- trunk/src/flexlay.rb        2004-06-06 18:55:42 UTC (rev 397)
+++ trunk/src/flexlay.rb        2004-06-06 19:28:47 UTC (rev 398)
@@ -90,58 +90,55 @@
     @window = Window.new(CL_Rect.new(CL_Point.new(100, 100), CL_Size.new(400, 
100)), title, gui)
     @ok = CL_Button.new(CL_Rect.new(CL_Point.new(290, 35), CL_Size.new(50, 
25)), "Ok",
                     @window.get_client_area())
-    @cancel = CL_Button(CL_Rect.new(CL_Point.new(230, 35), CL_Size.new(50, 
25)), "Cancel",
-                        @window.get_client_area())
-    connect(@cancel.sig_clicked(), @on_cancel)
-    connect(@ok.sig_clicked(), @on_ok)
+    @cancel = CL_Button.new(CL_Rect.new(CL_Point.new(230, 35), CL_Size.new(50, 
25)), "Cancel",
+                            @window.get_client_area())
+    connect(@cancel.sig_clicked(), method(:on_cancel))
+    connect(@ok.sig_clicked(), method(:on_ok))
   end
 
   def on_cancel()
+    print "ON CANCEL\n"
     @window.hide()
   end
   
   def on_ok()
+    print "ON OK\n"
     @window.hide()
-    if @callback != nil
-      @callback.call(*get_values())
+    if @callback
+      vals = @items.map{|item|
+        (type, label, comp) = item
+        if type == "int"
+          comp.get_text().to_i
+        elsif type == "string"
+          comp.get_text()
+        else
+          nil
+        end
+      }
+      @callback.call(*vals)
     end
   end
 
   def set_callback(c)
     @callback = c
   end
-  
-  def get_values()
-    def get_value(item)
-      (type, label, comp) = item
-      if type == "int":
-               return int(comp.get_text())
-      elsif type == "string":
-                  return comp.get_text()
-      else
-        return nil
-      end
-    end
     
-    return map(get_value, @items)
-  end
-  
   def add_int(name, value = 0)
-    @items.append(["int",
-                   CL_Label.new(CL_Point.new(10, 10), name,
-                                @window.get_client_area()),
-                   CL_InputBox.new(CL_Rect.new(CL_Point.new(110, 10), 
CL_Size.new(200, 25)),
-                                   @window.get_client_area())])
-    @items[-1][2].set_text(str(value))
+    @items.push(["int",
+                 CL_Label.new(CL_Point.new(10, 10), name,
+                              @window.get_client_area()),
+                 CL_InputBox.new(CL_Rect.new(CL_Point.new(110, 10), 
CL_Size.new(200, 25)),
+                                 @window.get_client_area())])
+    @items[-1][2].set_text(value.to_s)
     update()
   end
   
   def add_string(name, value = "")
-    @items.append(["string",
-                   CL_Label.new(CL_Point.new(10, 10), name,
-                                @window.get_client_area()),
-                   CL_InputBox.new(CL_Rect.new(CL_Point.new(110, 10), 
CL_Size.new(200, 25)),
-                               @window.get_client_area())])
+    @items.push(["string",
+                 CL_Label.new(CL_Point.new(10, 10), name,
+                              @window.get_client_area()),
+                 CL_InputBox.new(CL_Rect.new(CL_Point.new(110, 10), 
CL_Size.new(200, 25)),
+                                 @window.get_client_area())])
     @items[-1][2].set_text(value)
     update()    
   end

Modified: trunk/src/gui.rb
===================================================================
--- trunk/src/gui.rb    2004-06-06 18:55:42 UTC (rev 397)
+++ trunk/src/gui.rb    2004-06-06 19:28:47 UTC (rev 398)
@@ -242,7 +242,7 @@
   level = 
Level('/home/ingo/cvs/supertux/supertux/data/levels/world1/level2.stl')
   print "Loading done"
   level.activate(workspace)
-  connect(level.editormap.sig_change(), on_map_change)
+  connect(level.editormap.sig_change(), proc{on_map_change()})
   print "Activation done"
 end
 

Modified: trunk/src/supertux.rb
===================================================================
--- trunk/src/supertux.rb       2004-06-06 18:55:42 UTC (rev 397)
+++ trunk/src/supertux.rb       2004-06-06 19:28:47 UTC (rev 398)
@@ -420,7 +420,7 @@
   objects   = nil
   editormap = nil
 
-  attr_reader :name, :background, :interactive, :foreground, :parent
+  attr_reader :name, :background, :interactive, :foreground, :parent, :width, 
:height
   attr_writer :name, :song, :gravity
  
   def initialize(parent)
@@ -591,7 +591,7 @@
     workspace.set_map(@editormap)
     TilemapLayer.set_current(@interactive)
     ObjectLayer.set_current(@objects)
-    #connect(@editormap.sig_change(), on_map_change)
+    connect(@editormap.sig_change(), proc{on_map_change()})
   end
 end
 





reply via email to

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