windstille-devel
[Top][All Lists]
Advanced

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

[Windstille-devel] rev 402 - trunk/src


From: Ingo Ruhnke
Subject: [Windstille-devel] rev 402 - trunk/src
Date: Mon, 07 Jun 2004 22:59:10 +0200

Author: grumbel
Date: 2004-06-07 22:59:10 +0200 (Mon, 07 Jun 2004)
New Revision: 402

Added:
   trunk/src/gameobj.rb
Modified:
   trunk/src/gui2.rb
Log:
- fixed path tool a bit

Added: trunk/src/gameobj.rb
===================================================================
--- trunk/src/gameobj.rb        2004-06-07 20:56:24 UTC (rev 401)
+++ trunk/src/gameobj.rb        2004-06-07 20:59:10 UTC (rev 402)
@@ -0,0 +1,79 @@
+class GameObj
+  def property_dialog()
+    print "No PropertyDialog Implemented for type: ", self.class(), "\n"
+  end
+end
+
+class BadGuy<GameObj
+  def initialize(type)
+    @type = type
+  end
+
+  def save(f, obj)
+    pos = obj.get_pos()
+    f.write("       (%s (x %d) (y %d))\n" % address@hidden, pos.x, pos.y])
+  end  
+end
+
+class SpawnPoint<GameObj
+  attr_accessor :name
+
+  def initialize()
+    @name = "start"
+  end
+
+  def save(f, obj)
+    pos = obj.get_pos()
+    f.write("       (spawnpoint (name \"%s\") (x %d) (y %d))\n" % 
address@hidden, pos.x, pos.y])
+  end
+
+  def property_dialog()
+    dialog = GenericDialog.new("SpawnPoint Property Dialog", 
$gui.get_component())
+    dialog.add_string("Name: ", @name)
+    dialog.set_callback(proc{|name| 
+                          @name = name
+                        })
+  end
+end
+
+class Door<GameObj
+  attr_accessor :sector, :spawnpoint
+
+  def initialize(data = [])
+    @sector     = get_value_from_tree(["sector", "_"], data, "main")
+    @spawnpoint = get_value_from_tree(["spawnpoint", "_"], data, "start")
+  end
+
+  def save(f, obj)
+    pos = obj.get_pos()
+    f.write("       (door\n")
+    f.write("         (x %d) (y %d)" % [pos.x, pos.y])
+    f.write("         (sector \"%s\")\n" % @sector)
+    f.write("         (spawnpoint \"%s\")\n" % @spawnpoint)
+    f.write("         )\n")
+  end  
+
+  def property_dialog()
+    dialog = GenericDialog.new("Door Property Dialog", $gui.get_component())
+    dialog.add_string("Sector: ", @sector)
+    dialog.add_string("Spawnpoint: ", @spawnpoint)
+    dialog.set_callback(proc{|sector, spawnpoint| 
+                          @sector = sector
+                          @spawnpoint = spawnpoint
+                        })
+  end
+end
+
+class PathNode<GameObj
+  attr_accessor :node
+  
+  def initialize(node)
+    @node = node
+  end
+
+  def save(f, obj)
+  end
+end
+
+
+# EOF #

Modified: trunk/src/gui2.rb
===================================================================
--- trunk/src/gui2.rb   2004-06-07 20:56:24 UTC (rev 401)
+++ trunk/src/gui2.rb   2004-06-07 20:59:10 UTC (rev 402)
@@ -148,18 +148,18 @@
 def insert_path_node(x,y)
   print "Insert path Node"
   m = $workspace.get_map().get_metadata()
-  pathnode = ObjMapPathNode($editor_map.screen2world(CL_Point.new(x, y)),
-                            make_metadata("PathNode"))
-  pathnode.to_object().set_metadata(make_metadata(PathNode(pathnode)))
+  pathnode = ObjMapPathNode.new($editor_map.screen2world(CL_Point.new(x, y)),
+                                make_metadata("PathNode"))
+  pathnode.to_object().set_metadata(make_metadata(PathNode.new(pathnode)))
   m.objects.add_object(pathnode.to_object())
 end
 
 def connect_path_nodes()
   print "Connecting path nodes"
   pathnodes = []
-  for i in objmap_select_tool.get_selection()
+  for i in $objmap_select_tool.get_selection()
     obj = get_ruby_object(i.get_metadata())
-    if obj.class == PathNode
+    if obj.is_a?(PathNode)
       pathnodes.push(obj.node)
     end
   end





reply via email to

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