changeset 76:37a11fea3304 ornery-dev

More clean up. Images now posts a Chat Info post if image doesn't load.
author sirebral
date Sat, 22 Aug 2009 04:02:14 -0500
parents f518bc709fd1
children 6226a5f9a4b3
files orpg/gametree/gametree.py orpg/gametree/nodehandlers/rpg_grid.py orpg/mapper/background.py orpg/mapper/background_handler.py orpg/mapper/images.py orpg/mapper/map.py orpg/mapper/miniatures.py orpg/mapper/miniatures_handler.py orpg/orpg_version.py orpg/tools/decorators.py
diffstat 10 files changed, 172 insertions(+), 237 deletions(-) [+]
line wrap: on
line diff
--- a/orpg/gametree/gametree.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/gametree/gametree.py	Sat Aug 22 04:02:14 2009 -0500
@@ -38,6 +38,8 @@
 import time
 import os
 
+from orpg.orpg_xml import xml
+from orpg.tools.validate import validate
 from orpg.tools.orpg_log import logger
 from orpg.tools.decorators import debugging
 from orpg.gametree.nodehandlers import containers, forms, dnd3e, dnd35, chatmacro
@@ -79,9 +81,7 @@
     def __init__(self, parent, id):
         wx.TreeCtrl.__init__(self,parent,id,  wx.DefaultPosition, 
                 wx.DefaultSize,style=wx.TR_EDIT_LABELS | wx.TR_HAS_BUTTONS)
-        self.orpgLog = component.get('log')
-        self.validate = component.get('validate')
-        self.xml = component.get('xml')
+        #self.xml = component.get('xml') #
         self.settings = component.get('settings')
         self.session = component.get('session')
         self.chat = component.get('chat')
@@ -105,28 +105,25 @@
         self.last_save_dir = dir_struct["user"]
 
         #Create tree from default if it does not exist
-        self.validate.config_file("tree.xml","default_tree.xml")
+        validate.config_file("tree.xml","default_tree.xml")
         component.add("tree", self)
         #build tree
         self.root = self.AddRoot("Game Tree",self.icons['gear'])
         self.was_labeling = 0
         self.rename_flag = 0
         self.image_cache = {}
-        self.orpgLog.log("Exit game_tree", ORPG_DEBUG)
+        logger.debug("Exit game_tree")
 
     @debugging
     def add_nodehandler(self, nodehandler, nodeclass):
-        if not self.nodehandlers.has_key(nodehandler):
-            self.nodehandlers[nodehandler] = nodeclass
-        else:
-            self.orpgLog.log("Nodehandler for " + nodehandler + " already exists!", ORPG_DEBUG, True)
+        if not self.nodehandlers.has_key(nodehandler): self.nodehandlers[nodehandler] = nodeclass
+        else: logger.debug("Nodehandler for " + nodehandler + " already exists!")
 
     @debugging
     def remove_nodehandler(self, nodehandler):
         if self.nodehandlers.has_key(nodehandler):
             del self.nodehandlers[nodehandler]
-        else:
-            self.orpgLog.log("No nodehandler for " + nodehandler + " exists!", ORPG_DEBUG, True)
+        else: logger.debug("No nodehandler for " + nodehandler + " exists!")
 
     @debugging
     def init_nodehandlers(self):
@@ -183,17 +180,14 @@
                 cur = wx.StockCursor(wx.CURSOR_HAND)
                 self.SetCursor(cur)
                 self.drag_obj = obj
-        elif key_code == wx.WXK_LEFT:
-            self.Collapse(curSelection)
+        elif key_code == wx.WXK_LEFT: self.Collapse(curSelection)
         elif key_code == wx.WXK_DELETE:                          #  Handle the delete key
             if curSelection:
                 nextSelect = self.GetItemParent(curSelection)
                 self.on_del(evt)
                 try:
-                    if self.GetItemText(nextSelect) != "":
-                        self.SelectItem(nextSelect)
-                except:
-                    pass
+                    if self.GetItemText(nextSelect) != "": self.SelectItem(nextSelect)
+                except: pass
         elif key_code == wx.WXK_F2:
             self.rename_flag = 1
             self.EditLabel(curSelection)
@@ -213,7 +207,7 @@
             else: self.load_tree(file)
             return
         else:
-            self.validate.config_file("tree.xml","default_tree.xml")
+            validate.config_file("tree.xml","default_tree.xml")
             self.load_tree(error=1)
             return
 
@@ -224,15 +218,13 @@
         xml_dom = None
         xml_doc = None
         try:
-            self.orpgLog.log("Reading Gametree file: " + filename + "...", ORPG_INFO, True)
+            logger.info("Reading Gametree file: " + filename + "...", True)
             tmp = open(filename,"r")
-            xml_doc = self.xml.parseXml(tmp.read())
+            xml_doc = xml.parseXml(tmp.read())
             tmp.close()
-            if xml_doc == None:
-                pass
-            else:
-                xml_dom = xml_doc._get_documentElement()
-            self.orpgLog.log("done.", ORPG_INFO, True)
+            if xml_doc == None: pass
+            else: xml_dom = xml_doc._get_documentElement()
+            logger.info("done.", True)
 
         except IOError:
             emsg = "Gametree Missing!\n"+filename+" cannot be found.\n\n"\
@@ -240,7 +232,7 @@
                    "(Selecting 'No' will cause a new default gametree to be generated)"
             fn = filename[ ((filename.rfind(os.sep))+len(os.sep)):]
             self.locate_valid_tree("Gametree Error", emsg, dir_struct["user"], fn)
-            self.orpgLog.log(emsg, ORPG_GENERAL)
+            logger.general(emsg)
             return
 
         if not xml_dom:
@@ -255,7 +247,7 @@
                    "Would you like to select a different gametree file to use?\n"\
                    "(Selecting 'No' will cause a new default gametree to be generated)"
             self.locate_valid_tree("Corrupt Gametree!", emsg, dir_struct["user"], fn)
-            self.orpgLog.log(emsg, ORPG_GENERAL)
+            logger.general(emsg)
             return
 
         if xml_dom._get_tagName() != "gametree":
@@ -264,47 +256,45 @@
                    "Would you like to select a different gametree file to use?\n"\
                    "(Selecting 'No' will cause a new default gametree to be generated)"
             self.locate_valid_tree("Invalid Gametree!", emsg, dir_struct["user"], fn)
-            self.orpgLog.log(emsg, ORPG_DEBUG)
-            self.orpgLog.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG)
+            logger.debug(emsg)
             return
 
         # get gametree version - we could write conversion code here!
         self.master_dom = xml_dom
-        self.orpgLog.log("Master Dom Set", ORPG_DEBUG)
+        logger.debug("Master Dom Set")
 
         try:
             version = self.master_dom.getAttribute("version")
             # see if we should load the gametree
             loadfeatures = int(self.settings.get_setting("LoadGameTreeFeatures"))
             if loadfeatures:
-                xml_dom = self.xml.parseXml(open(dir_struct["template"]+"feature.xml","r").read())
+                xml_dom = xml.parseXml(open(dir_struct["template"]+"feature.xml","r").read())
                 xml_dom = xml_dom._get_documentElement()
                 xml_dom = self.master_dom.appendChild(xml_dom)
                 self.settings.set_setting("LoadGameTreeFeatures","0")
 
             ## load tree
-            self.orpgLog.log("Features loaded (if required)", ORPG_DEBUG)
+            logger.debug("Features loaded (if required)")
             self.CollapseAndReset(self.root)
             children = self.master_dom._get_childNodes()
-            self.orpgLog.log("Parsing Gametree Nodes ", ORPG_INFO, True)
+            logger.info("Parsing Gametree Nodes ", True)
             for c in children:
                 print '.',
                 self.load_xml(c,self.root)
-            self.orpgLog.log("done", ORPG_INFO, True)
+            logger.info("done", True)
             self.Expand(self.root)
             self.SetPyData(self.root,self.master_dom)
             if error != 1:
                 infile = open(filename, "rb")
                 outfile = open(dir_struct["user"]+"lastgood.xml", "wb")
                 outfile.write(infile.read())
-            else:
-                self.orpgLog.log("Not overwriting lastgood.xml file.", ORPG_INFO, True)
+            else: logger.info("Not overwriting lastgood.xml file.", True)
 
         except Exception, e:
-            self.orpgLog.log(traceback.format_exc(), ORPG_GENERAL)
+            logger.general(traceback.format_exc())
             wx.MessageBox("Corrupt Tree!\nYour game tree is being regenerated. To\nsalvage a recent version of your gametree\nexit OpenRPG and copy the lastgood.xml\nfile in your myfiles directory\nto "+filename+ "\nin your myfiles directory.\nlastgood.xml WILL BE OVERWRITTEN NEXT TIME YOU RUN OPENRPG.")
             os.rename(filename,filename+".corrupt")
-            self.validate.config_file("tree.xml","default_tree.xml")
+            validate.config_file("tree.xml","default_tree.xml")
             self.load_tree(error=1)
 
     @debugging
@@ -383,15 +373,11 @@
         in_tag = 0
         for x in xrange(len(player[0])) :
             if player[0][x] == "<" or player[0][x] == ">" or in_tag == 1 :
-                if player[0][x] == "<" :
-                    in_tag = 1
-                elif player[0][x] == ">" :
-                    in_tag = 0
-                else :
-                    pass
-            else :
-                ret_string = ret_string + player[0][x]
-        self.orpgLog.log(ret_string, ORPG_DEBUG)
+                if player[0][x] == "<" : in_tag = 1
+                elif player[0][x] == ">" : in_tag = 0
+                else: pass
+            else: ret_string = ret_string + player[0][x]
+        logger.debug(ret_string)
         return ret_string
 
     @debugging
@@ -414,20 +400,16 @@
         myid = self.session.get_id()
         me = None
         for p in players:
-            if p[2] != myid:
-                opts.append("("+p[2]+") " + self.strip_html(p))
-            else:
-                me = p
-        if len(opts):
-            players.remove(me)
+            if p[2] != myid: opts.append("("+p[2]+") " + self.strip_html(p))
+            else: me = p
+        if len(opts): players.remove(me)
         if len(opts):
             dlg = orpgMultiCheckBoxDlg( self.GetParent(),opts,"Select Players:","Whisper To",[] )
             if dlg.ShowModal() == wx.ID_OK:
                 item = self.GetSelection()
                 obj = self.GetPyData(item)
                 selections = dlg.get_selections()
-                if len(selections) == len(opts):
-                    self.chat.ParsePost(obj.tohtml(),True,True)
+                if len(selections) == len(opts): self.chat.ParsePost(obj.tohtml(),True,True)
                 else:
                     player_ids = []
                     for s in selections:
@@ -481,23 +463,19 @@
         myid = self.session.get_id()
         me = None
         for p in players:
-            if p[2] != myid:
-                opts.append("("+p[2]+") " + self.strip_html(p))
-            else:
-                me = p
+            if p[2] != myid: opts.append("("+p[2]+") " + self.strip_html(p))
+            else: me = p
         if len(opts):
             players.remove(me)
             dlg = orpgMultiCheckBoxDlg( None, opts, "Select Players:", "Send To", [] )
             if dlg.ShowModal() == wx.ID_OK:
                 item = self.GetSelection()
                 obj = self.GetPyData(item)
-                xmldata = "<tree>" + self.xml.toxml(obj) + "</tree>"
+                xmldata = "<tree>" + xml.toxml(obj) + "</tree>"
                 selections = dlg.get_selections()
-                if len(selections) == len(opts):
-                    self.session.send(xmldata)
+                if len(selections) == len(opts): self.session.send(xmldata)
                 else:
-                    for s in selections:
-                        self.session.send(xmldata,players[s][2])
+                    for s in selections: self.session.send(xmldata,players[s][2])
             dlg.Destroy()
 
     @debugging
@@ -519,10 +497,10 @@
         name = "New " + obj.master_dom.getAttribute("name")
         icon = obj.master_dom.getAttribute("icon")
         xml_data = "<nodehandler name=\""+name+"\" icon=\"" + icon + "\" module=\"core\" class=\"node_loader\" >"
-        xml_data += self.xml.toxml(obj)
+        xml_data += xml.toxml(obj)
         xml_data += "</nodehandler>"
         self.insert_xml(xml_data)
-        self.orpgLog.log(xml_data, ORPG_DEBUG)
+        logger.debug(xml_data)
 
     @debugging
     def on_clone(self, evt):
@@ -531,9 +509,8 @@
         if obj.can_clone():
             parent_node = self.GetItemParent(item)
             prev_sib = self.GetPrevSibling(item)
-            if not prev_sib.IsOk():
-                prev_sib = parent_node
-            xml_dom = self.xml.parseXml(self.xml.toxml(obj))
+            if not prev_sib.IsOk(): prev_sib = parent_node
+            xml_dom = xml.parseXml(xml.toxml(obj))
             xml_dom = xml_dom._get_firstChild()
             parent = obj.master_dom._get_parentNode()
             xml_dom = parent.insertBefore(xml_dom, obj.master_dom)
@@ -566,7 +543,7 @@
         self.master_dom.setAttribute("version",GAMETREE_VERSION)
         self.settings.set_setting("gametree",filename)
         file = open(filename,"w")
-        file.write(self.xml.toxml(self.master_dom,1))
+        file.write(xml.toxml(self.master_dom,1))
         file.close()
 
     @debugging
@@ -607,8 +584,7 @@
     @debugging
     def on_tree_prop(self, evt):
         dlg = gametree_prop_dlg(self, self.settings)
-        if dlg.ShowModal() == wx.ID_OK:
-            pass
+        if dlg.ShowModal() == wx.ID_OK: pass
         dlg.Destroy()
 
     @debugging
@@ -640,34 +616,25 @@
                 try:
                     status_value = parent_obj.master_dom.getAttribute('status')
                     name = parent_obj.master_dom.getAttribute('name')
-                except:
-                    status_value = "none"
+                except: status_value = "none"
                 parent_obj = parent_obj.master_dom._get_parentNode()
                 while status_value!="useful" and status_value!="useless":
                     try:
                         status_value = parent_obj.getAttribute('status')
                         name = parent_obj.getAttribute('name')
-                        if status_value == "useless":
-                            break
-                        elif status_value == "useful":
-                            break
-                    except:
-                        status_value = "none"
-                    try:
-                        parent_obj = parent_obj._get_parentNode()
-                    except:
-                        break
+                        if status_value == "useless": break
+                        elif status_value == "useful": break
+                    except: status_value = "none"
+                    try: parent_obj = parent_obj._get_parentNode()
+                    except: break
                 if status_value == "useful":
                     dlg = wx.MessageDialog(self, `name` + "  And everything beneath it are considered useful.  \n\nAre you sure you want to delete this item?",'Important Item',wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
-                    if dlg.ShowModal() == wx.ID_YES:
-                        obj.delete()
-                else:
-                    obj.delete()
+                    if dlg.ShowModal() == wx.ID_YES: obj.delete()
+                else: obj.delete()
         except:
             if self.GetSelection() == self.GetRootItem():
                 msg = wx.MessageDialog(None,"You can't delete the root item.","Delete Error",wx.OK)
-            else:
-                msg = wx.MessageDialog(None,"Unknown error deleting node.","Delete Error",wx.OK)
+            else: msg = wx.MessageDialog(None,"Unknown error deleting node.","Delete Error",wx.OK)
             msg.ShowModal()
             msg.Destroy()
 
@@ -683,40 +650,37 @@
     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)
+        if hasattr(obj,"on_send_to_map"): obj.on_send_to_map(evt)
 
     @debugging
     def insert_xml(self, txt):
-        self.orpgLog.log("Enter game_tree->insert_xml(self, txt)", ORPG_DEBUG)
         #Updated to allow safe merging of gametree files
         #without leaving an unusable and undeletable node.
         #                               -- Snowdog 8/03
-        xml_dom = self.xml.parseXml(txt)
+        xml_dom = xml.parseXml(txt)
         if xml_dom == None:
             wx.MessageBox("Import Failed: Invalid or missing node data")
-            self.orpgLog.log("Import Failed: Invalid or missing node data", ORPG_DEBUG)
-            self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG)
+            logger.debug("Import Failed: Invalid or missing node data")
+            logger.debug("Exit game_tree->insert_xml(self, txt)")
             return
         xml_temp = xml_dom._get_documentElement()
 
         if not xml_temp:
             wx.MessageBox("Error Importing Node or Tree")
-            self.orpgLog.log("Error Importing Node or Tree", ORPG_DEBUG)
-            self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG)
+            logger.debug("Error Importing Node or Tree")
+            logger.debug("Exit game_tree->insert_xml(self, txt)")
             return
 
         if xml_temp._get_tagName() == "gametree":
             children = xml_temp._get_childNodes()
-            for c in children:
-                self.load_xml(c, self.root)
-            self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG)
+            for c in children: self.load_xml(c, self.root)
+            logger.debug("Exit game_tree->insert_xml(self, txt)")
             return
 
         if not xml_dom:
             wx.MessageBox("XML Error")
-            self.orpgLog.log("XML Error", ORPG_DEBUG)
-            self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG)
+            logger.debug("XML Error")
+            logger.debug("Exit game_tree->insert_xml(self, txt)")
             return
 
         xml_dom = xml_dom._get_firstChild()
@@ -731,7 +695,7 @@
         self.icons = { }
         self._imageList= wx.ImageList(16,16,False)
         man = open(dir_struct["icon"]+"icons.xml","r")
-        xml_dom = self.xml.parseXml(man.read())
+        xml_dom = xml.parseXml(man.read())
         man.close()
         xml_dom = xml_dom._get_documentElement()
         node_list = xml_dom._get_childNodes()
@@ -748,39 +712,34 @@
         i = 0
         text = xml_dom.getAttribute("name")
         icon = xml_dom.getAttribute("icon")
-        if self.icons.has_key(icon):
-            i = self.icons[icon]
+        if self.icons.has_key(icon): i = self.icons[icon]
         name = xml_dom._get_nodeName()
-        self.orpgLog.log("Text, icon and name set\n" + text + "\n" + icon + "\n" + name, ORPG_DEBUG)
+        logger.debug("Text, icon and name set\n" + text + "\n" + icon + "\n" + name)
         if prev_node:
-            if prev_node == parent_node:
-                new_tree_node = self.PrependItem(parent_node, text, i, i)
-            else:
-                new_tree_node = self.InsertItem(parent_node,prev_node, text, i, i)
-        else:
-            new_tree_node = self.AppendItem(parent_node, text, i, i)
+            if prev_node == parent_node: new_tree_node = self.PrependItem(parent_node, text, i, i)
+            else: new_tree_node = self.InsertItem(parent_node,prev_node, text, i, i)
+        else: new_tree_node = self.AppendItem(parent_node, text, i, i)
 
-        self.orpgLog.log("Node Added to tree", ORPG_DEBUG)
+        logger.debug("Node Added to tree")
         #create a nodehandler or continue loading xml into tree
         if name == "nodehandler":
             #wx.BeginBusyCursor()
-            self.orpgLog.log("We have a Nodehandler", ORPG_DEBUG)
+            logger.debug("We have a Nodehandler")
             try:
                 py_class = xml_dom.getAttribute("class")
-                self.orpgLog.log("nodehandler class: " + py_class, ORPG_DEBUG)
+                logger.debug("nodehandler class: " + py_class)
                 if not self.nodehandlers.has_key(py_class):
                     raise Exception, "Unknown Nodehandler for " + py_class
                 self.nodes[self.id] = self.nodehandlers[py_class](xml_dom, new_tree_node)
                 self.SetPyData(new_tree_node, self.nodes[self.id])
-                self.orpgLog.log("Node Data set", ORPG_DEBUG)
+                logger.debug("Node Data set")
                 bmp = self.nodes[self.id].get_scaled_bitmap(16,16)
-                if bmp:
-                    self.cached_load_of_image(bmp,new_tree_node,)
-                self.orpgLog.log("Node Icon loaded", ORPG_DEBUG)
+                if bmp: self.cached_load_of_image(bmp,new_tree_node,)
+                logger.debug("Node Icon loaded")
                 self.id = self.id + 1
             except Exception, er:
-                self.orpgLog.log(traceback.format_exc(), ORPG_GENERAL)
- 		        #self.orpgLog.log("Error Info: " + xml_dom.getAttribute("class") + "\n" + str(er), ORPG_GENERAL, True)?indent?
+                logger.general(traceback.format_exc())
+ 		        #logger.debug("Error Info: " + xml_dom.getAttribute("class") + "\n" + str(er), True)?indent?
                 self.Delete(new_tree_node)
                 parent = xml_dom._get_parentNode()
                 parent.removeChild(xml_dom)
@@ -811,12 +770,9 @@
         if item.IsOk():
             obj = self.GetPyData(item)
             self.SelectItem(item)
-            if(isinstance(obj,core.node_handler)):
-                obj.on_rclick(evt)
-            else:
-                self.PopupMenu(self.top_menu)
-        else:
-            self.PopupMenu(self.top_menu,pt)
+            if(isinstance(obj,core.node_handler)): obj.on_rclick(evt)
+            else: self.PopupMenu(self.top_menu)
+        else: self.PopupMenu(self.top_menu,pt)
 
     @debugging
     def on_ldclick(self, evt):
@@ -829,14 +785,10 @@
             if(isinstance(obj,core.node_handler)):
                 if not obj.on_ldclick(evt):
                     action = self.settings.get_setting("treedclick")
-                    if action == "use":
-                        obj.on_use(evt)
-                    elif action == "design":
-                        obj.on_design(evt)
-                    elif action == "print":
-                        obj.on_html_view(evt)
-                    elif action == "chat":
-                        self.on_send_to_chat(evt)
+                    if action == "use": obj.on_use(evt)
+                    elif action == "design": obj.on_design(evt)
+                    elif action == "print": obj.on_html_view(evt)
+                    elif action == "chat": self.on_send_to_chat(evt)
 
     @debugging
     def on_left_down(self, evt):
@@ -849,8 +801,7 @@
         elif (flag & wx.TREE_HITTEST_ONITEMLABEL) == wx.TREE_HITTEST_ONITEMLABEL and self.IsSelected(item):
             #  this next if tests to ensure that the mouse up occurred over a label, and not the icon
             self.rename_flag = 1
-        else:
-            self.SelectItem(item)
+        else: self.SelectItem(item)
         evt.Skip()
 
     @debugging
@@ -877,13 +828,11 @@
         if txt != "":
             obj = self.GetPyData(item)
             obj.master_dom.setAttribute('name',txt)
-        else:
-            evt.Veto()
+        else: evt.Veto()
 
     @debugging
     def on_label_begin(self, evt):
-        if not self.rename_flag:
-            evt.Veto()
+        if not self.rename_flag: evt.Veto()
         else:
             self.was_labeling = 1
             item = evt.GetItem()
@@ -906,13 +855,12 @@
     def is_parent_node(self, node, compare_node):
         parent_node = self.GetItemParent(node)
         if compare_node == parent_node:
-            self.orpgLog.log("parent node", ORPG_DEBUG)
+            logger.debug("parent node")
             return 1
         elif parent_node == self.root:
-            self.orpgLog.log("not parent", ORPG_DEBUG)
+            logger.debug("not parent")
             return 0
-        else:
-            return self.is_parent_node(parent_node, compare_node)
+        else: return self.is_parent_node(parent_node, compare_node)
 
 CTRL_TREE_FILE = wx.NewId()
 CTRL_YES = wx.NewId()
@@ -986,12 +934,8 @@
     def on_ok(self,evt):
         self.settings.set_setting("gametree",self.ctrls[CTRL_TREE_FILE].GetValue())
         self.settings.set_setting("SaveGameTreeOnExit",str(self.ctrls[CTRL_YES].GetValue()))
-        if self.ctrls[CTRL_USE].GetValue():
-            self.settings.set_setting("treedclick","use")
-        elif self.ctrls[CTRL_DESIGN].GetValue():
-            self.settings.set_setting("treedclick","design")
-        elif self.ctrls[CTRL_PRINT].GetValue():
-            self.settings.set_setting("treedclick","print")
-        elif self.ctrls[CTRL_CHAT].GetValue():
-            self.settings.set_setting("treedclick","chat")
+        if self.ctrls[CTRL_USE].GetValue(): self.settings.set_setting("treedclick","use")
+        elif self.ctrls[CTRL_DESIGN].GetValue(): self.settings.set_setting("treedclick","design")
+        elif self.ctrls[CTRL_PRINT].GetValue(): self.settings.set_setting("treedclick","print")
+        elif self.ctrls[CTRL_CHAT].GetValue(): self.settings.set_setting("treedclick","chat")
         self.EndModal(wx.ID_OK)
--- a/orpg/gametree/nodehandlers/rpg_grid.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/gametree/nodehandlers/rpg_grid.py	Sat Aug 22 04:02:14 2009 -0500
@@ -29,7 +29,8 @@
 __version__ = "$Id: rpg_grid.py,v 1.20 2006/11/15 12:11:24 digitalxero Exp $"
 
 from core import *
-from forms import *
+from forms import *
+from orpg.minidom import Element, Text
 
 class rpg_grid_handler(node_handler):
     """ Node handler for rpg grid tool
@@ -196,12 +197,12 @@
         self._tc.SetDimensions(rect.x+1, rect.y+1, rect.width+2, rect.height+2)
 
 
-    def Show(self, show, attr):
-        """
-        Show or hide the edit control.  You can use the attr (if not None)
-        to set colours or fonts for the control.
-        """
-        self.base_Show(show, attr) #deprecated DeprecationWarning: Please use PyGridCellEditor.Show instead.
+    #def Show(self, show, attr): #deprecated DeprecationWarning: Please use PyGridCellEditor.Show instead.
+    #    """
+    #    Show or hide the edit control.  You can use the attr (if not None)
+    #    to set colours or fonts for the control.
+    #    """
+    #    self.base_Show(show, attr) # Removed to prevent recursive error type.
 
 
     def BeginEdit(self, row, col, grid):
@@ -283,7 +284,6 @@
             evt.Skip()
 
 
-
     def Destroy(self):
         """final cleanup"""
         self.base_Destroy()
@@ -341,7 +341,6 @@
         value = self.GetCellValue(row,col)
         cells = self.rows[row].getElementsByTagName('cell')
         t_node = cells[col]._get_firstChild()
-        print t_node
         t_node._set_nodeValue(value)
         if col == 0:
             self.handler.refresh_rows()
@@ -362,7 +361,7 @@
             if t_node == None:
                 #doc = cells[i].ownerDocument
                 #t_node = doc.createTextNode("")
-                t_node = minidom.Text("")
+                t_node = Text("")
                 t_node = cells[i].appendChild(t_node)
             self.SetCellValue(rowi,i,t_node._get_nodeValue())
 
@@ -370,12 +369,12 @@
         cols = self.GetNumberCols()
         #doc = self.handler.grid.ownerDocument
         #row = doc.createElement('row')
-        row = minidom.Element('row')
+        row = Element('row')
         for i in range(0,cols):
             #cell = doc.createElement('cell')
-            cell = minidom.Element('cell')
+            cell = Element('cell')
             #t_node = doc.createTextNode("")
-            t_node = minidom.Text("")
+            t_node = Text("")
             t_node = cell.appendChild(t_node)
             row.appendChild(cell)
         self.handler.grid.appendChild(row)
@@ -387,9 +386,9 @@
         #doc = self.handler.grid.ownerDocument
         for r in self.rows:
             #cell = doc.createElement('cell')
-            cell = minidom.Element('cell')
+            cell = Element('cell')
             #t_node = doc.createTextNode("")
-            t_node = minidom.Text("")
+            t_node = Text("")
             t_node = cell.appendChild(t_node)
             r.appendChild(cell)
         self.AppendCols(1)
--- a/orpg/mapper/background.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/mapper/background.py	Sat Aug 22 04:02:14 2009 -0500
@@ -34,6 +34,11 @@
 import os.path
 import time
 
+from orpg.orpgCore import component
+from orpg.tools.orpg_log import logger
+from orpg.tools.decorators import debugging
+from orpg.tools.orpg_settings import settings
+
 ##-----------------------------
 ## background layer
 ##-----------------------------
@@ -44,27 +49,24 @@
 BG_COLOR = 3
 
 class layer_back_ground(layer_base):
+    @debugging
     def __init__(self, canvas):
         self.canvas = canvas
-        self.log = self.canvas.log
-        self.log.log("Enter layer_back_ground", ORPG_DEBUG)
-        self.settings = self.canvas.settings
+        self.log = component.get('log')
         layer_base.__init__(self)
         self.canvas = canvas
         self.r_h = RGBHex()
         self.clear()
-        self.log.log("Exit layer_back_ground", ORPG_DEBUG)
 
+    @debugging
     def error_loading_image(self, image):
-        self.log.log("Enter layer_back_ground->error_loading_image(self, image)", ORPG_DEBUG)
         msg = "Unable to load image:" + `image`
         dlg = wx.MessageDialog(self.canvas,msg,'File not Found',wx.ICON_EXCLAMATION)
         dlg.ShowModal()
         dlg.Destroy()
-        self.log.log("Exit layer_back_ground->error_loading_image(self, image)", ORPG_DEBUG)
 
+    @debugging
     def clear(self):
-        self.log.log("Enter layer_back_ground->clear(self)", ORPG_DEBUG)
         self.type = BG_NONE
         self.bg_bmp = None
         self.bg_color = None
@@ -73,75 +75,62 @@
         self.localPath = ''
         self.localTime = -1
         self.isUpdated = True
-        self.log.log("Exit layer_back_ground->clear(self)", ORPG_DEBUG)
 
+    @debugging
     def get_type(self):
-        self.log.log("Enter layer_back_ground->get_type(self)", ORPG_DEBUG)
-        self.log.log("Exit layer_back_ground->get_type(self)", ORPG_DEBUG)
         return self.type
 
+    @debugging
     def get_img_path(self):
-        self.log.log("Enter layer_back_ground->get_type(self)", ORPG_DEBUG)
-        if self.img_path:
-            self.log.log("Exit layer_back_ground->get_type(self) return " + self.img_path, ORPG_DEBUG)
-            return self.img_path
-        else:
-            self.log.log("Exit layer_back_ground->get_type(self) return None", ORPG_DEBUG)
-            return ""
+        if self.img_path: return self.img_path
+        else: return ""
 
+    @debugging
     def get_color(self):
-        self.log.log("Enter layer_back_ground->get_color(self)", ORPG_DEBUG)
         hexcolor = "#FFFFFF"
         if self.bg_color:
             (red,green,blue) = self.bg_color.Get()
             hexcolor = self.r_h.hexstring(red, green, blue)
-        self.log.log("Exit layer_back_ground->get_color(self)", ORPG_DEBUG)
         return hexcolor
 
+    @debugging
     def set_texture(self, path):
-        self.log.log("Enter layer_back_ground->set_texture(self, path)", ORPG_DEBUG)
         self.isUpdated = True
-
         self.type = BG_TEXTURE
         if self.img_path != path:
             try:
                 self.bg_bmp = ImageHandler.load(path, "texture", 0)
                 if self.bg_bmp == None:
-                    self.log.log("Invalid image type!", ORPG_GENERAL)
+                    logger.general("Invalid image type!")
                     raise Exception, "Invalid image type!"
             except: self.error_loading_image(path)
         self.img_path = path
-        self.log.log("Enter layer_back_ground->set_texture(self, path)", ORPG_DEBUG)
 
+    @debugging
     def set_image(self, path, scale):
-        self.log.log("Enter layer_back_ground->set_image(self, path, scale)", ORPG_DEBUG)
         self.isUpdated = True
-
         self.type = BG_IMAGE
         if self.img_path != path:
             self.bg_bmp = ImageHandler.load(path, "background", 0)
             try:
                 if self.bg_bmp == None:
-                    self.log.log("Invalid image type!", ORPG_GENERAL)
+                    logger.general("Invalid image type!")
                     raise Exception, "Invalid image type!"
             except: self.error_loading_image(path)
         self.img_path = path
-        self.log.log("Exit layer_back_ground->set_image(self, path, scale)", ORPG_DEBUG)
         return (self.bg_bmp.GetWidth(),self.bg_bmp.GetHeight())
 
+    @debugging
     def set_color(self, color):
-        self.log.log("Enter layer_back_ground->set_color(self, color)", ORPG_DEBUG)
         self.isUpdated = True
         self.type = BG_COLOR
         (r,g,b) = color.Get()
         self.bg_color = cmpColour(r,g,b)
         self.canvas.SetBackgroundColour(self.bg_color)
-        self.log.log("Exit layer_back_ground->set_color(self, color)", ORPG_DEBUG)
 
+    @debugging
     def layerDraw(self, dc, scale, topleft, size):
-        self.log.log("Enter layer_back_ground->layerDraw(self, dc, scale, topleft, size)", ORPG_DEBUG)
         if self.bg_bmp == None or not self.bg_bmp.Ok() or ((self.type != BG_TEXTURE) and (self.type != BG_IMAGE)):
-            self.log.log("Exit layer_back_ground->layerDraw(self, dc, scale, topleft, size) return False", ORPG_DEBUG)
             return False
         dc2 = wx.MemoryDC()
         dc2.SelectObject(self.bg_bmp)
@@ -212,11 +201,10 @@
             dc.Blit(posx, posy, newW, newH, dc2, cl, ct)
         dc2.SelectObject(wx.NullBitmap)
         del dc2
-        self.log.log("Exit layer_back_ground->layerDraw(self, dc, scale, topleft, size)", ORPG_DEBUG)
         return True
 
+    @debugging
     def layerToXML(self, action="update"):
-        self.log.log("Enter layer_back_ground->layerToXML(self, " + action + ")", ORPG_DEBUG)
         xml_str = "<bg"
         if self.bg_color != None:
             (red,green,blue) = self.bg_color.Get()
@@ -229,21 +217,19 @@
             xml_str += ' localPath="' + urllib.quote(self.localPath).replace('%3A', ':') + '"'
             xml_str += ' localTime="' + str(self.localTime) + '"'
         xml_str += "/>"
-        self.log.log(xml_str, ORPG_DEBUG)
-        self.log.log("Exit layer_back_ground->layerToXML(self, " + action + ")", ORPG_DEBUG)
+        logger.debug(xml_str)
         if (action == "update" and self.isUpdated) or action == "new":
             self.isUpdated = False
             return xml_str
         else: return ''
 
+    @debugging
     def layerTakeDOM(self, xml_dom):
-        self.log.log("Enter layer_back_ground->layerTakeDOM(self, xml_dom)", ORPG_DEBUG)
         type = BG_COLOR
         color = xml_dom.getAttribute("color")
-        self.log.log("color=" + color, ORPG_DEBUG)
+        logger.debug("color=" + color)
         path = urllib.unquote(xml_dom.getAttribute("path"))
-        self.log.log("path=" + path, ORPG_DEBUG)
-
+        logger.debug("path=" + path)
         # Begin ted's map changes
         if xml_dom.hasAttribute("color"):
             r,g,b = self.r_h.rgb_tuple(xml_dom.getAttribute("color"))
@@ -251,16 +237,12 @@
         # End ted's map changes
         if xml_dom.hasAttribute("type"):
             type = int(xml_dom.getAttribute("type"))
-            self.log.log("type=" + str(type), ORPG_DEBUG)
-
+            logger.debug("type=" + str(type))
         if type == BG_TEXTURE:
             if path != "": self.set_texture(path)
-
         elif type == BG_IMAGE:
             if path != "": self.set_image(path, 1)
-
         elif type == BG_NONE: self.clear()
-
         if xml_dom.hasAttribute('local') and xml_dom.getAttribute('local') == 'True' and os.path.exists(urllib.unquote(xml_dom.getAttribute('localPath'))):
             self.localPath = urllib.unquote(xml_dom.getAttribute('localPath'))
             self.local = True
@@ -273,12 +255,12 @@
                 (imgtype,j) = mimetypes.guess_type(filename[1])
                 postdata = urllib.urlencode({'filename':filename[1], 'imgdata':imgdata, 'imgtype':imgtype})
                 thread.start_new_thread(self.upload, (postdata, self.localPath, type))
-        self.log.log("Exit layer_back_ground->layerTakeDOM(self, xml_dom)", ORPG_DEBUG)
 
+    @debugging
     def upload(self, postdata, filename, type):
         self.lock.acquire()
         if type == 'Image' or type == 'Texture':
-            url = self.settings.get_setting('ImageServerBaseURL')
+            url = component.get('settings').get_setting('ImageServerBaseURL')
             file = urllib.urlopen(url, postdata)
             recvdata = file.read()
             file.close()
--- a/orpg/mapper/background_handler.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/mapper/background_handler.py	Sat Aug 22 04:02:14 2009 -0500
@@ -35,10 +35,12 @@
 import os
 from base import *
 
+from orpg.tools.orpg_settings import settings
+
 class background_handler(base_layer_handler):
     def __init__(self, parent, id, canvas):
         base_layer_handler.__init__(self, parent, id, canvas)
-        self.settings = self.canvas.settings
+        self.settings = settings
 
     def build_ctrls(self):
         base_layer_handler.build_ctrls(self)
--- a/orpg/mapper/images.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/mapper/images.py	Sat Aug 22 04:02:14 2009 -0500
@@ -32,6 +32,7 @@
 import thread
 from threading import Lock
 import time
+
 from orpg.orpg_wx import *
 from orpg.orpgCore import component
 from orpg.dirpath import dir_struct
@@ -50,6 +51,7 @@
     __fetching = {}
     __queue = Queue.Queue(0)
     __lock = Lock()
+    chat = component.get("chat")
 
     def load(self, path, image_type, imageId):
         """Load an image, with a intermideary fetching image shown while it loads in a background thread"""
@@ -76,10 +78,12 @@
                 self.__cache[path] = (path, d[0], d[1].gettype(), None)
                 return wx.ImageFromMime(self.__cache[path][1], self.__cache[path][2]).ConvertToBitmap()
             else:
-                logger.general("Image refused to load or URI did not reference a valid image: " + path) ##logger.general
+                logger.general("Image refused to load or URI did not reference a valid image: " + path)
+                component.get('chat').InfoPost("<font color='#FF0000'>Image refused to load or URI did not reference a valid image: " + path + "</font>")
                 return None
         except IOError:
-            logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path) ##logger.general
+            logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path)
+            component.get('chat').InfoPost("<font color='#FF0000'>Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>")
             return None
 
     def cleanCache(self):
@@ -112,11 +116,13 @@
                 self.__queue.put((self.__cache[path], image_type, imageId))
                 if self.__fetching.has_key(path): self.__fetching[path] = False #Fix for failed multi-load?
             else:
-                logger.general("Image refused to load or URI did not reference a valid image: " + path) ##logger.general
+                logger.general("Image refused to load or URI did not reference a valid image: " + path)
+                component.get('chat').InfoPost("<font color='#FF0000'>Image refused to load or URI did not reference a valid image: " + path +"</font>")
                 del self.__fetching[path]
         except IOError:
             del self.__fetching[path]
-            logger.general("Unable to resolve/open the specified URI; image was NOT laoded: " + path) ##logger.general
+            logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path)
+            component.get('chat').InfoPost("<font color='#FF0000'> Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>")
         finally: self.__lock.release()
 
     def __loadCacheThread(self, path, image_type, imageId):
@@ -130,11 +136,13 @@
                         break
             except:
                 del self.__fetching[path]
-                logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path) ##logger.general
+                logger.general("Unable to resolve/open the specified URI; image was NOT loaded: " + path)
+                component.get('chat').InfoPost("<font color='#FF0000'>Unable to resolve/open the specified URI; image was NOT loaded: " + path + "</font>")
                 return 
             self.__lock.acquire()
             try:
                 logger.debug("Adding Image to Queue from Cache: " + str(self.__cache[path]))
+                component.debug('chat').InfoPost("<font color='#FF0000'>Adding Image to Queue from Cache: " + str(self.__cache[path]) + "</font>)
                 self.__queue.put((self.__cache[path], image_type, imageId))
             finally: self.__lock.release()
 
--- a/orpg/mapper/map.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/mapper/map.py	Sat Aug 22 04:02:14 2009 -0500
@@ -35,7 +35,7 @@
 import random
 import os
 import thread
-import gc
+#import gc #Garbage Collecter Needed?
 import traceback
 
 from miniatures_handler import *
@@ -48,6 +48,7 @@
 from orpg.dirpath import dir_struct
 from images import ImageHandler
 from orpg.orpgCore import component
+from orpg.tools.orpg_settings import settings
 
 # Various marker modes for player tools on the map
 MARKER_MODE_NONE = 0
@@ -58,8 +59,6 @@
 class MapCanvas(wx.ScrolledWindow):
     def __init__(self, parent, ID, isEditor=0):
         self.parent = parent
-        self.log = component.get('log')
-        self.settings = component.get("settings")
         self.session = component.get("session")
         wx.ScrolledWindow.__init__(self, parent, ID, 
             style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER )
@@ -156,7 +155,7 @@
                     self.parent.layer_tabs.EnableTab(cidx, True)
         if not self.cacheSizeSet:
             self.cacheSizeSet = True
-            cacheSize = self.settings.get_setting("ImageCacheSize")
+            cacheSize = component.get('settings').get_setting("ImageCacheSize")
             if len(cacheSize): self.cacheSize = int(cacheSize)
             else: pass
         if not ImageHandler.Queue.empty():
@@ -193,11 +192,11 @@
 
     def on_scroll(self, evt):
         if self.drag: self.drag.Hide()
-        if self.settings.get_setting("AlwaysShowMapScale") == "1": self.printscale()
+        if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale()
         evt.Skip()
 
     def on_char(self, evt):
-        if self.settings.get_setting("AlwaysShowMapScale") == "1": self.printscale()
+        if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale()
         evt.Skip()
 
     def printscale(self):
@@ -275,7 +274,7 @@
             del dc
             wdc = self.preppaint()
             wdc.DrawBitmap(bmp, topleft[0], topleft[1])
-            if self.frame.settings.get_setting("AlwaysShowMapScale") == "1":
+            if settings.get_setting("AlwaysShowMapScale") == "1":
                 self.showmapscale(wdc)
         try: evt.Skip()
         except: pass
@@ -715,11 +714,9 @@
 
 class map_wnd(wx.Panel):
     def __init__(self, parent, id):
-        self.log = component.get('log')
         wx.Panel.__init__(self, parent, id)
         self.canvas = MapCanvas(self, -1)
         self.session = component.get('session')
-        self.settings = component.get('settings')
         self.chat = component.get('chat')
         self.top_frame = component.get('frame')
         self.root_dir = os.getcwd()
--- a/orpg/mapper/miniatures.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/mapper/miniatures.py	Sat Aug 22 04:02:14 2009 -0500
@@ -34,6 +34,8 @@
 import urllib
 import os.path
 
+from orpg.tools.orpg_settings import settings
+
 MIN_STICKY_BACK = -0XFFFFFF
 MIN_STICKY_FRONT = 0xFFFFFF
 
@@ -417,7 +419,6 @@
 class miniature_layer(layer_base):
     def __init__(self, canvas):
         self.canvas = canvas
-        self.settings = self.canvas.settings
         layer_base.__init__(self)
         self.id = -1 #added.
         self.miniatures = []
@@ -425,10 +426,10 @@
 
         # Set the font of the labels to be the same as the chat window
         # only smaller.
-        font_size = int(self.settings.get_setting('defaultfontsize'))
+        font_size = int(settings.get_setting('defaultfontsize'))
         if (font_size >= 10): font_size -= 2
         self.label_font = wx.Font(font_size, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL,
-                                  False, self.settings.get_setting('defaultfont'))
+                                  False, settings.get_setting('defaultfont'))
 
     def next_serial(self):
         self.serial_number += 1
@@ -583,7 +584,7 @@
 
     def upload(self, postdata, filename, modify=False, pos=cmpPoint(0,0)):
         self.lock.acquire()
-        url = self.settings.get_setting('ImageServerBaseURL')
+        url = settings.get_setting('ImageServerBaseURL')
         file = urllib.urlopen(url, postdata)
         recvdata = file.read()
         file.close()
--- a/orpg/mapper/miniatures_handler.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/mapper/miniatures_handler.py	Sat Aug 22 04:02:14 2009 -0500
@@ -40,6 +40,8 @@
 from grid import GRID_ISOMETRIC
 import os
 
+from orpg.tools.orpg_settings import settings
+
 LABEL_TOOL = wx.NewId()
 LAYER_TOOL = wx.NewId()
 MIN_LIST_TOOL = wx.NewId()
@@ -103,7 +105,7 @@
         self.use_serial = 1
         self.auto_label_cb = None
         self.canvas = canvas
-        self.settings = self.canvas.settings
+        self.settings = settings
         self.mini_rclick_menu_extra_items = {}
         self.background_rclick_menu_extra_items = {}
         base_layer_handler.__init__(self, parent, id, canvas)
--- a/orpg/orpg_version.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/orpg_version.py	Sat Aug 22 04:02:14 2009 -0500
@@ -4,7 +4,7 @@
 #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed)
 DISTRO = "Traipse Dev"
 DIS_VER = "Ornery Orc"
-BUILD = "090821-01"
+BUILD = "090822-00"
 
 # This version is for network capability.
 PROTOCOL_VERSION = "1.2"
--- a/orpg/tools/decorators.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/tools/decorators.py	Sat Aug 22 04:02:14 2009 -0500
@@ -100,7 +100,7 @@
 
     @functools.wraps(func)
     def new_func(*args, **kwargs):
-        from orpg.tools.orpg_log import logger
+        from orpg_log import logger
 
         if not ORPG_DEBUG & logger.log_level:
             return func(*args, **kwargs)