diff orpg/gametree/nodehandlers/containers.py @ 152:6081bdc2b8d5 beta

Traipse Beta 'OpenRPG' {091125-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 (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 Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops return error instead of freezing the software! New Syntax added for custom PC sheets Tip of the Day added, from Core and community Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix.
author sirebral
date Wed, 25 Nov 2009 06:16:35 -0600
parents e842a5f1b775
children 3b6888bb53b5
line wrap: on
line diff
--- a/orpg/gametree/nodehandlers/containers.py	Tue Nov 24 17:18:40 2009 -0600
+++ b/orpg/gametree/nodehandlers/containers.py	Wed Nov 25 06:16:35 2009 -0600
@@ -28,11 +28,12 @@
 
 
 from core import *
-from wx.lib.splitter import MultiSplitterWindow
-
+from wx.lib.splitter import MultiSplitterWindow
+from orpg.tools.orpg_log import logger
+from orpg.orpgCore import component
 
 ##########################
-##  base contiainer
+##  base container
 ##########################
 
 class container_handler(node_handler):
@@ -44,21 +45,18 @@
         self.load_children()
 
     def load_children(self):
-        for child_xml in self.xml:
-            self.tree.load_xml(child_xml,self.mytree_node)
+        for child_xml in self.xml: self.tree.load_xml(child_xml,self.mytree_node)
 
     def check_map_aware(self, treenode, evt):
         node = self.tree.GetPyData(treenode)
-        if hasattr(node,"map_aware") and node.map_aware():
-            node.on_send_to_map(evt)
+        if hasattr(node,"map_aware") and node.map_aware(): node.on_send_to_map(evt)
 
     def on_send_to_map(self, evt):
         self.tree.traverse(self.mytree_node, self.check_map_aware, evt) 
 
     def checkChildToMap(self, treenode, evt):
         node = self.tree.GetPyData(treenode)
-        if hasattr(node,"map_aware") and node.map_aware():
-            self.mapcheck = True
+        if hasattr(node,"map_aware") and node.map_aware(): self.mapcheck = True
 
     def checkToMapMenu(self):
         self.mapcheck = False
@@ -67,29 +65,25 @@
 
     def on_drop(self,evt):
         drag_obj = self.tree.drag_obj
-        if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node):
-            return
+        if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node): return
         opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL)
         if opt == wx.YES:
             drop_xml = self.tree.drag_obj.delete()
             self.xml.insert(0, drop_xml)
             self.tree.load_xml(drop_xml, self.mytree_node)
             self.tree.Expand(self.mytree_node)
-        elif opt == wx.NO:
-            node_handler.on_drop(self,evt)
+        elif opt == wx.NO: node_handler.on_drop(self,evt)
 
     def gen_html(self, treenode, evt):
         node = self.tree.GetPyData(treenode)
         self.html_str += "<p>" + node.tohtml()
         
     def tohtml(self):
-        self.html_str = "<table border=\"1\" ><tr><td>"
+        self.html_str = "<table border='1' ><tr><td>"
         self.html_str += "<b>"+self.xml.get("name") + "</b>"
         self.html_str += "</td></tr>\n"
         self.html_str += "<tr><td>"
-
         self.tree.traverse(self.mytree_node, self.gen_html, recurse=False)
-
         self.html_str += "</td></tr></table>"
         return self.html_str
 
@@ -113,16 +107,9 @@
         for child_xml in self.xml:
             if child_xml.get == "group_atts": #having the group attributes as a child is bad!
                 self.xml.remove(child_xml)
-            elif child_xml:
-                self.tree.load_xml(child_xml, self.mytree_node)
+            elif child_xml: self.tree.load_xml(child_xml, self.mytree_node)
         if not self.xml.get('cols'): self.xml.set('cols', '1')
         if not self.xml.get('border'): self.xml.set('border', '1')
-        """
-        if not self.atts:
-            self.atts = Element('group_atts')
-            self.atts.set("cols","1")
-            self.atts.set("border","1")
-            self.xml.append(self.atts)"""
 
     def get_design_panel(self,parent):
         return group_edit_panel(parent,self)
@@ -132,25 +119,22 @@
 
     def gen_html(self, treenode, evt):
         node = self.tree.GetPyData(treenode)
-        if self.i  not in self.tdatas:
-            self.tdatas[self.i] = ''
+        if self.i  not in self.tdatas: self.tdatas[self.i] = ''
         self.tdatas[self.i] += "<P>" + node.tohtml()
         self.i += 1
-        if self.i >= self.cols:
-            self.i = 0
+        if self.i >= self.cols: self.i = 0
 
     def tohtml(self):
         cols = self.xml.get("cols")
         border = self.xml.get("border")
-        self.html_str = "<table border=\""+border+"\" ><tr><td colspan=\""+cols+"\">"
+        self.html_str = "<table border='"+border+"' ><tr><td colspan='"+cols+"'>"
         self.html_str += "<font size=4>"+self.xml.get("name") + "</font>"
         self.html_str += "</td></tr>\n<tr>"
         self.cols = int(cols)
         self.i = 0
         self.tdatas = {}
         self.tree.traverse(self.mytree_node, self.gen_html, recurse=False)
-        for td in self.tdatas:
-            self.html_str += "<td valign=\"top\" >" + self.tdatas[td] + "</td>\n";
+        for td in self.tdatas: self.html_str += "<td valign='top' >" + self.tdatas[td] + "</td>\n";
         self.html_str += "</tr></table>"
         return self.html_str
 
@@ -171,13 +155,11 @@
 
         radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"])
         cols = handler.xml.get("cols")
-        if cols != "":
-            radio_c.SetSelection(int(cols)-1)
+        if cols != "": radio_c.SetSelection(int(cols)-1)
 
         radio_b = wx.RadioBox(self, GROUP_BOR, "Border", choices=["no","yes"])
         border = handler.xml.get("border")
-        if border != "":
-            radio_b.SetSelection(int(border))
+        if border != "": radio_b.SetSelection(int(border))
 
         sizer.Add(radio_c, 0, wx.EXPAND)
         sizer.Add(wx.Size(10,10))
@@ -196,10 +178,8 @@
     def on_radio_box(self,evt):
         id = evt.GetId()
         index = evt.GetInt()
-        if id == GROUP_COLS:
-            self.handler.xml.set("cols",str(index+1))
-        elif id == GROUP_BOR:
-            self.handler.xml.set("border",str(index))
+        if id == GROUP_COLS: self.handler.xml.set("cols",str(index+1))
+        elif id == GROUP_BOR: self.handler.xml.set("border",str(index))
 
     def on_text(self,evt):
         id = evt.GetId()
@@ -239,7 +219,13 @@
         node = self.handler.tree.GetPyData(treenode)
         if mode == 1: panel = node.get_design_panel(self)
         else: panel = node.get_use_panel(self)
-        name = node.xml.get("name")
+        name = node.xml.get("name")
+        if name == None: ## Fixes broken 3e Inventory child
+            if node.xml.tag == 'inventory':
+                node.xml.set('name', 'Inventory')
+                name = "Inventory"
+                logger.info('A corrective action was take to a 3e PC Sheet', True)
+                component.get('frame').TraipseSuiteWarn('item')
         if panel: self.AddPage(panel, name, False)
 
 class tabbed_edit_panel(orpgTabberWnd):
@@ -314,13 +300,11 @@
         if self.split == '1':
             sash = tmp.GetBestSize()[1]+1
             self.bestSizey += sash+11
-            if self.bestSizex < tmp.GetBestSize()[0]:
-                self.bestSizex = tmp.GetBestSize()[0]+10
+            if self.bestSizex < tmp.GetBestSize()[0]: self.bestSizex = tmp.GetBestSize()[0]+10
         else:
             sash = tmp.GetBestSize()[0]+1
             self.bestSizex += sash
-            if self.bestSizey < tmp.GetBestSize()[1]:
-                self.bestSizey = tmp.GetBestSize()[1]+31
+            if self.bestSizey < tmp.GetBestSize()[1]: self.bestSizey = tmp.GetBestSize()[1]+31
         self.splitter.AppendWindow(tmp, sash)
     def get_size_constraint(self):
         return 1
@@ -342,7 +326,6 @@
         sizer.Add(self.title, 0)
         sizer.Add(self.hozCheck, 0, wx.EXPAND)
         sizer.Add(wx.Size(10,0))
-        #sizer.Add(self.splitsize,  1, wx.EXPAND)
 
         self.sizer = sizer
         self.SetSizer(self.sizer)