diff orpg/mapper/grid.py @ 137:54446a995007 alpha

Traipse Alpha 'OpenRPG' {091018-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 Gametree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!!
author sirebral
date Wed, 18 Nov 2009 19:57:52 -0600
parents 449a8900f9ac
children 8e07c1a2c69b
line wrap: on
line diff
--- a/orpg/mapper/grid.py	Mon Nov 16 19:13:41 2009 -0600
+++ b/orpg/mapper/grid.py	Wed Nov 18 19:57:52 2009 -0600
@@ -33,6 +33,8 @@
 from miniatures import SNAPTO_ALIGN_TL
 from math import floor
 
+from xml.etree.ElementTree import ElementTree, Element, tostring
+
 # Grid mode constants
 GRID_RECTANGLE = 0
 GRID_HEXAGON = 1
@@ -61,7 +63,7 @@
         #size_ratio is the size ajustment for Hex and ISO to make them more accurate
         self.size_ratio = 1.5
         self.snap = True
-        self.color = wx.BLACK# = color.Get()
+        self.color = wx.BLACK # = color.Get()
         #self.color = cmpColour(r,g,b)
         self.r_h = RGBHex()
         self.mode = GRID_RECTANGLE
@@ -387,38 +389,37 @@
             # Disable pen/brush optimizations to prevent any odd effects elsewhere
 
     def layerToXML(self,action = "update"):
-        xml_str = "<grid"
+        xml = Element('grid')
         if self.color != None:
             (red,green,blue) = self.color.Get()
             hexcolor = self.r_h.hexstring(red, green, blue)
-            xml_str += " color='" + hexcolor + "'"
-        if self.unit_size != None: xml_str += " size='" + str(self.unit_size) + "'"
-        if self.iso_ratio != None: xml_str += " ratio='" + str(self.iso_ratio) + "'"
+            xml.set('color', hexcolor)
+        if self.unit_size != None: xml.set('size', str(self.unit_size))
+        if self.iso_ratio != None: xml.set('ratio', str(self.iso_ratio))
         if self.snap != None:
-            if self.snap: xml_str += " snap='1'"
-            else: xml_str += " snap='0'"
-        if self.mode != None: xml_str+= "  mode='" + str(self.mode) + "'"
-        if self.line != None: xml_str+= " line='" + str(self.line) + "'"
-        xml_str += "/>"
+            if self.snap: xml.set('snap', '1')
+            else: xml.set('snap', '0')
+        if self.mode != None: xml.set('mode', str(self.mode))
+        if self.line != None: xml.set('line', str(self.line))
         if (action == "update" and self.isUpdated) or action == "new":
             self.isUpdated = False
-            return xml_str
+            return tostring(xml)
         else: return ''
 
     def layerTakeDOM(self, xml_dom):
-        if xml_dom.hasAttribute("color"):
-            r,g,b = self.r_h.rgb_tuple(xml_dom.getAttribute("color"))
+        if xml_dom.get("color"):
+            r,g,b = self.r_h.rgb_tuple(xml_dom.get("color"))
             self.set_color(cmpColour(r,g,b))
         #backwards compatible with non-isometric map formated clients
         ratio = RATIO_DEFAULT
-        if xml_dom.hasAttribute("ratio"): ratio = xml_dom.getAttribute("ratio")
-        if xml_dom.hasAttribute("mode"):
-            self.SetMode(int(xml_dom.getAttribute("mode")))
-        if xml_dom.hasAttribute("size"):
-            self.unit_size = int(xml_dom.getAttribute("size"))
+        if xml_dom.get("ratio"): ratio = xml_dom.get("ratio")
+        if xml_dom.get("mode"):
+            self.SetMode(int(xml_dom.get("mode")))
+        if xml_dom.get("size"):
+            self.unit_size = int(xml_dom.get("size"))
             self.unit_size_y = self.unit_size
-        if xml_dom.hasAttribute("snap"):
-            if (xml_dom.getAttribute("snap") == 'True') or (xml_dom.getAttribute("snap") == "1"): self.snap = True
+        if xml_dom.get("snap"):
+            if (xml_dom.get("snap") == 'True') or (xml_dom.get("snap") == "1"): self.snap = True
             else: self.snap = False
-        if xml_dom.hasAttribute("line"):
-            self.SetLine(int(xml_dom.getAttribute("line")))
+        if xml_dom.get("line"):
+            self.SetLine(int(xml_dom.get("line")))