diff orpg/gametree/nodehandlers/core.py @ 111:0c936d98f9eb alpha

Traipse Alpha 'OpenRPG' {091008-01} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary: {091006} 00: Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images! 03: Changes made to the map for increased portability. SnowDog has changes planned in Core, though. Added an initial push to the BCG. Not much to see, just shows off how it is re-writing Main code. {091007} 00: New images added to Plugin Control Panel for Auto Start. 01: Attempting to fix Deprecation warning from Main. 02: Second attempt, problem in gsclient with "s. 03: Fail. {091008} 00: Fix to remote admin commands 01: Minor fix to texted based server, works in /System/ folder Some Core changes to gametree to correctly disply Pretty Print, thanks David!
author sirebral
date Thu, 08 Oct 2009 09:10:55 -0500
parents 449a8900f9ac
children 217fb049bd00
line wrap: on
line diff
--- a/orpg/gametree/nodehandlers/core.py	Thu Oct 08 04:14:41 2009 -0500
+++ b/orpg/gametree/nodehandlers/core.py	Thu Oct 08 09:10:55 2009 -0500
@@ -36,6 +36,7 @@
     import webbrowser
     from orpg.mapper import map
     import os
+    from wx import DisplaySize
 except:
     import wx
 
@@ -75,23 +76,13 @@
     def on_ldclick(self,evt):
         return 0
 
-    def traverse(self, traverseroot, function, cookie=0, event=None, recursive=True):
-        """ walk tree control """
-        if traverseroot.IsOk():
-            # step in subtree if there are items or ...
-            if self.tree.ItemHasChildren(traverseroot) and recursive:
-                firstchild, cookie = self.tree.GetFirstChild(traverseroot)
-                obj = self.tree.GetPyData(firstchild)
-                function(obj, event)
-                self.traverse(firstchild, function, cookie, event, recursive)
-
-            # ... loop siblings
-            obj = self.tree.GetPyData(traverseroot)
-            function(obj, event)
-
-            child = self.tree.GetNextSibling(traverseroot)
-            if child.IsOk():
-                self.traverse(child, function, cookie, event, recursive)
+    def traverse(self, root, function, data=None, recurse=True):
+        child, cookie = self.tree.GetFirstChild(root)
+        while child.IsOk(): 
+            function(self.tree.GetPyData(child), data) 
+            if recurse: 
+                self.traverse(child, function, data) 
+            child, cookie = self.tree.GetNextChild(root, cookie) 
 
 
     def usefulness(self,text):
@@ -267,7 +258,7 @@
     def on_save(self,evt):
         f = wx.FileDialog(self.tree,"Select a file", dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE)
         if f.ShowModal() == wx.ID_OK:
-            type = f.GetFilterIndex()
+            type = f.GetFilterIndex()
             if f.GetPath()[:len(f.GetPath())-4] != '.xml': file = open(f.GetPath()+'.xml',"w")
             else: file = open(f.GetPath(),"w")
             file.write(self.toxml(1))
@@ -283,7 +274,7 @@
     def get_html_panel(self,parent):
         html_str = "<html><body bgcolor=\"#FFFFFF\" >"+self.tohtml()+"</body></html>"
         wnd = wx.html.HtmlWindow(parent,-1)
-        html_str = self.chat.ParseDice(html_str)
+        html_str = self.chat.ParseDice(html_str)
 	wnd.SetPage(html_str)
         return wnd
 
@@ -455,4 +446,4 @@
 
     def on_ldclick(self,evt):
         self.map.new_data(toxml(self.mapdata))
-        return 1
+        return 1