comparison orpg/mapper/grid.py @ 139:8e07c1a2c69b alpha

Traipse Alpha 'OpenRPG' {091123-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 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 Mon, 23 Nov 2009 03:22:50 -0600
parents 54446a995007
children 06f10429eedc
comparison
equal deleted inserted replaced
138:1ed2feab0db9 139:8e07c1a2c69b
30 from base import * 30 from base import *
31 from isometric import * 31 from isometric import *
32 from miniatures import SNAPTO_ALIGN_CENTER 32 from miniatures import SNAPTO_ALIGN_CENTER
33 from miniatures import SNAPTO_ALIGN_TL 33 from miniatures import SNAPTO_ALIGN_TL
34 from math import floor 34 from math import floor
35
36 from xml.etree.ElementTree import ElementTree, Element, tostring
37 35
38 # Grid mode constants 36 # Grid mode constants
39 GRID_RECTANGLE = 0 37 GRID_RECTANGLE = 0
40 GRID_HEXAGON = 1 38 GRID_HEXAGON = 1
41 GRID_ISOMETRIC = 2 39 GRID_ISOMETRIC = 2
61 self.unit_widest = 100 59 self.unit_widest = 100
62 self.unit_offset = 100 60 self.unit_offset = 100
63 #size_ratio is the size ajustment for Hex and ISO to make them more accurate 61 #size_ratio is the size ajustment for Hex and ISO to make them more accurate
64 self.size_ratio = 1.5 62 self.size_ratio = 1.5
65 self.snap = True 63 self.snap = True
66 self.color = wx.BLACK # = color.Get() 64 self.color = wx.BLACK# = color.Get()
67 #self.color = cmpColour(r,g,b) 65 #self.color = cmpColour(r,g,b)
68 self.r_h = RGBHex() 66 self.r_h = RGBHex()
69 self.mode = GRID_RECTANGLE 67 self.mode = GRID_RECTANGLE
70 self.line = LINE_NONE 68 self.line = LINE_NONE
71 # Keep logic for different modes in different functions 69 # Keep logic for different modes in different functions
387 dc.DrawLines(lineArray) 385 dc.DrawLines(lineArray)
388 dc.SetPen(wx.NullPen) 386 dc.SetPen(wx.NullPen)
389 # Disable pen/brush optimizations to prevent any odd effects elsewhere 387 # Disable pen/brush optimizations to prevent any odd effects elsewhere
390 388
391 def layerToXML(self,action = "update"): 389 def layerToXML(self,action = "update"):
392 xml = Element('grid') 390 xml_str = "<grid"
393 if self.color != None: 391 if self.color != None:
394 (red,green,blue) = self.color.Get() 392 (red,green,blue) = self.color.Get()
395 hexcolor = self.r_h.hexstring(red, green, blue) 393 hexcolor = self.r_h.hexstring(red, green, blue)
396 xml.set('color', hexcolor) 394 xml_str += " color='" + hexcolor + "'"
397 if self.unit_size != None: xml.set('size', str(self.unit_size)) 395 if self.unit_size != None: xml_str += " size='" + str(self.unit_size) + "'"
398 if self.iso_ratio != None: xml.set('ratio', str(self.iso_ratio)) 396 if self.iso_ratio != None: xml_str += " ratio='" + str(self.iso_ratio) + "'"
399 if self.snap != None: 397 if self.snap != None:
400 if self.snap: xml.set('snap', '1') 398 if self.snap: xml_str += " snap='1'"
401 else: xml.set('snap', '0') 399 else: xml_str += " snap='0'"
402 if self.mode != None: xml.set('mode', str(self.mode)) 400 if self.mode != None: xml_str+= " mode='" + str(self.mode) + "'"
403 if self.line != None: xml.set('line', str(self.line)) 401 if self.line != None: xml_str+= " line='" + str(self.line) + "'"
402 xml_str += "/>"
404 if (action == "update" and self.isUpdated) or action == "new": 403 if (action == "update" and self.isUpdated) or action == "new":
405 self.isUpdated = False 404 self.isUpdated = False
406 return tostring(xml) 405 return xml_str
407 else: return '' 406 else: return ''
408 407
409 def layerTakeDOM(self, xml_dom): 408 def layerTakeDOM(self, xml_dom):
410 if xml_dom.get("color"): 409 if xml_dom.hasAttribute("color"):
411 r,g,b = self.r_h.rgb_tuple(xml_dom.get("color")) 410 r,g,b = self.r_h.rgb_tuple(xml_dom.getAttribute("color"))
412 self.set_color(cmpColour(r,g,b)) 411 self.set_color(cmpColour(r,g,b))
413 #backwards compatible with non-isometric map formated clients 412 #backwards compatible with non-isometric map formated clients
414 ratio = RATIO_DEFAULT 413 ratio = RATIO_DEFAULT
415 if xml_dom.get("ratio"): ratio = xml_dom.get("ratio") 414 if xml_dom.hasAttribute("ratio"): ratio = xml_dom.getAttribute("ratio")
416 if xml_dom.get("mode"): 415 if xml_dom.hasAttribute("mode"):
417 self.SetMode(int(xml_dom.get("mode"))) 416 self.SetMode(int(xml_dom.getAttribute("mode")))
418 if xml_dom.get("size"): 417 if xml_dom.hasAttribute("size"):
419 self.unit_size = int(xml_dom.get("size")) 418 self.unit_size = int(xml_dom.getAttribute("size"))
420 self.unit_size_y = self.unit_size 419 self.unit_size_y = self.unit_size
421 if xml_dom.get("snap"): 420 if xml_dom.hasAttribute("snap"):
422 if (xml_dom.get("snap") == 'True') or (xml_dom.get("snap") == "1"): self.snap = True 421 if (xml_dom.getAttribute("snap") == 'True') or (xml_dom.getAttribute("snap") == "1"): self.snap = True
423 else: self.snap = False 422 else: self.snap = False
424 if xml_dom.get("line"): 423 if xml_dom.hasAttribute("line"):
425 self.SetLine(int(xml_dom.get("line"))) 424 self.SetLine(int(xml_dom.getAttribute("line")))