diff orpg/gametree/gametree.py @ 133:37d26a98883f alpha

Traipse Alpha 'OpenRPG' {091010-00} 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 (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana **Pretty important update that can help remove thousands of dead children from your gametree. **Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! **New Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!! Dead Node Children, now that's a O O -v-v- Happy Halloween!
author sirebral
date Tue, 10 Nov 2009 12:11:13 -0600
parents fe4dc5817d5e
children b4e02e8cd314
line wrap: on
line diff
--- a/orpg/gametree/gametree.py	Thu Nov 05 12:15:19 2009 -0600
+++ b/orpg/gametree/gametree.py	Tue Nov 10 12:11:13 2009 -0600
@@ -370,12 +370,7 @@
         return ret_string
 
     
-    def on_receive_data(self, data, player):
-        if iselement(data):
-            tostring(data)
-        beg = string.find(data,"<tree>")
-        end = string.rfind(data,"</tree>")
-        data = data[6:end]
+    def on_receive_data(self, data):
         self.insert_xml(data)
     
     def on_send_to_chat(self, evt):
@@ -531,8 +526,8 @@
 
     
     def save_tree(self, filename=dir_struct["user"]+'tree.xml'):
-        self.xml_root.set("version",GAMETREE_VERSION)
-        settings.change("gametree",filename)
+        self.xml_root.set("version", GAMETREE_VERSION)
+        settings.change("gametree", filename)
         ElementTree(self.xml_root).write(filename)
 
     
@@ -634,13 +629,11 @@
         about = MyAboutBox(self,obj.about())
         about.ShowModal()
         about.Destroy()
-
     
     def on_send_to_map(self, evt):
         item = self.GetSelection()
         obj = self.GetPyData(item)
         if hasattr(obj,"on_send_to_map"): obj.on_send_to_map(evt)
-
     
     def insert_xml(self, txt):
         #Updated to allow safe merging of gametree files
@@ -654,16 +647,21 @@
         except ExpatError:
             wx.MessageBox("Error Importing Node or Tree")
             logger.general("Error Importing Node or Tree")
-            return
+            return
 
         if new_xml.tag == "gametree":
             for xml_child in new_xml:
                 self.load_xml(xml_child, self.root)
             return
+
+        if new_xml.tag == "tree":
+            self.xml_root.append(new_xml.find('nodehandler'))
+            for xml_child in new_xml:
+                self.load_xml(xml_child, self.root)
+            return
 
         self.xml_root.append(new_xml)
         self.load_xml(new_xml, self.root, self.root)
-
     
     def build_img_list(self):
         """make image list"""
@@ -688,9 +686,9 @@
             family_tree.append(parent)
         return family_tree
     
-    def load_xml(self, xml_element, parent_node, prev_node=None):
+    def load_xml(self, xml_element, parent_node, prev_node=None):
         if parent_node != self.root:
-            ## Loading XML seems to lag on Grids ##
+            ## Loading XML seems to lag on Grids and Images need a cache for load speed ##
             family_tree = self.get_tree_map(parent_node)
             family_tree.reverse()
             map_str = '' #'!@'
@@ -727,12 +725,10 @@
                 self.id = self.id + 1
             except Exception, er:
                 logger.exception(traceback.format_exc())
-
                 # was deleted -- should we delete non-nodehandler nodes then?
                 #self.Delete(new_tree_node)
                 #parent = xml_dom._get_parentNode()
                 #parent.removeChild(xml_dom)
-
         return new_tree_node
     
     def cached_load_of_image(self, bmp_in, new_tree_node):
@@ -760,7 +756,6 @@
             if(isinstance(obj,core.node_handler)): obj.on_rclick(evt)
             else: self.PopupMenu(self.top_menu)
         else: self.PopupMenu(self.top_menu,pt)
-
     
     def on_ldclick(self, evt):
         self.rename_flag = 0
@@ -776,7 +771,6 @@
                     elif action == "design": obj.on_design(evt)
                     elif action == "print": obj.on_html_view(evt)
                     elif action == "chat": self.on_send_to_chat(evt)
-
     
     def on_left_down(self, evt):
         pt = evt.GetPosition()
@@ -790,7 +784,6 @@
             self.rename_flag = 1
         else: self.SelectItem(item)
         evt.Skip()
-
     
     def on_left_up(self, evt):
         if self.dragging:
@@ -813,7 +806,6 @@
             if recurse:
                 self.traverse(child, function, data)
             child, cookie = self.GetNextChild(root, cookie)
-
     
     def on_label_change(self, evt):
         item = evt.GetItem()
@@ -824,7 +816,6 @@
             obj = self.GetPyData(item)
             obj.xml_root.setAttribute('name',txt)
         else: evt.Veto()
-
     
     def on_label_begin(self, evt):
         if not self.rename_flag: evt.Veto()
@@ -833,7 +824,6 @@
             item = evt.GetItem()
             if item == self.GetRootItem():
                 evt.Veto()
-
     
     def on_drag(self, evt):
         self.rename_flag = 0
@@ -845,7 +835,6 @@
             cur = wx.StockCursor(wx.CURSOR_HAND)
             self.SetCursor(cur)
             self.drag_obj = obj
-
     
     def is_parent_node(self, node, compare_node):
         parent_node = self.GetItemParent(node)