Mercurial > traipse_dev
changeset 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 | b4e02e8cd314 |
children | 1ed2feab0db9 |
files | orpg/mapper/background.py orpg/mapper/fog.py orpg/mapper/fog_msg.py orpg/mapper/grid.py orpg/mapper/map.py orpg/mapper/map_msg.py orpg/mapper/miniatures.py orpg/mapper/miniatures_handler.py orpg/mapper/whiteboard.py orpg/mapper/whiteboard_handler.py orpg/mapper/whiteboard_msg.py orpg/orpg_version.py |
diffstat | 12 files changed, 244 insertions(+), 293 deletions(-) [+] |
line wrap: on
line diff
--- a/orpg/mapper/background.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/background.py Wed Nov 18 19:57:52 2009 -0600 @@ -40,6 +40,8 @@ from orpg.tools.decorators import debugging from orpg.tools.orpg_settings import settings +from xml.etree.ElementTree import ElementTree, Element, tostring, fromstring, parse + ##----------------------------- ## background layer ##----------------------------- @@ -50,7 +52,7 @@ BG_COLOR = 3 class layer_back_ground(layer_base): - @debugging + def __init__(self, canvas): self.canvas = canvas self.log = component.get('log') @@ -59,14 +61,14 @@ self.r_h = RGBHex() self.clear() - @debugging + def error_loading_image(self, image): msg = "Unable to load image:" + `image` dlg = wx.MessageDialog(self.canvas,msg,'File not Found',wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() - @debugging + def clear(self): self.type = BG_NONE self.bg_bmp = None @@ -77,16 +79,16 @@ self.localTime = -1 self.isUpdated = True - @debugging + def get_type(self): return self.type - @debugging + def get_img_path(self): if self.img_path: return self.img_path else: return "" - @debugging + def get_color(self): hexcolor = "#FFFFFF" if self.bg_color: @@ -94,7 +96,7 @@ hexcolor = self.r_h.hexstring(red, green, blue) return hexcolor - @debugging + def set_texture(self, path): self.isUpdated = True self.type = BG_TEXTURE @@ -107,7 +109,7 @@ except: self.error_loading_image(path) self.img_path = path - @debugging + def set_image(self, path, scale): self.isUpdated = True self.type = BG_IMAGE @@ -121,7 +123,7 @@ self.img_path = path return (self.bg_bmp.GetWidth(),self.bg_bmp.GetHeight()) - @debugging + def set_color(self, color): self.isUpdated = True self.type = BG_COLOR @@ -129,7 +131,7 @@ self.bg_color = cmpColour(r,g,b) self.canvas.SetBackgroundColour(self.bg_color) - @debugging + def layerDraw(self, dc, scale, topleft, size): if self.bg_bmp == None or not self.bg_bmp.Ok() or ((self.type != BG_TEXTURE) and (self.type != BG_IMAGE)): return False @@ -210,71 +212,67 @@ del dc2 return True - @debugging + def layerToXML(self, action="update"): - xml_str = "<bg" + xml = Element('bg') if self.bg_color != None: (red,green,blue) = self.bg_color.Get() hexcolor = self.r_h.hexstring(red, green, blue) - xml_str += ' color="' + hexcolor + '"' - if self.img_path != None: xml_str += ' path="' + urllib.quote(self.img_path).replace('%3A', ':') + '"' - if self.type != None: xml_str += ' type="' + str(self.type) + '"' + xml.set('color', hexcolor) + if self.img_path != None: xml.set('path', urllib.quote(self.img_path).replace('%3A', ':')) + if self.type != None: xml.set('type', str(self.type)) if self.local and self.img_path != None: - xml_str += ' local="True"' - xml_str += ' localPath="' + urllib.quote(self.localPath).replace('%3A', ':') + '"' - xml_str += ' localTime="' + str(self.localTime) + '"' - xml_str += "/>" - logger.debug(xml_str) + xml.set('local', 'True') + xml.set('localPath', urllib.quote(self.localPath).replace('%3A', ':')) + xml.set('localTime', str(self.localTime)) if (action == "update" and self.isUpdated) or action == "new": self.isUpdated = False - return xml_str + return tostring(xml) else: return '' - @debugging + def layerTakeDOM(self, xml_dom): type = BG_COLOR - color = xml_dom.getAttribute("color") - logger.debug("color=" + color) - path = urllib.unquote(xml_dom.getAttribute("path")) - logger.debug("path=" + path) + color = xml_dom.get("color") # Begin ted's map changes - 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)) # End ted's map changes - if xml_dom.hasAttribute("type"): - type = int(xml_dom.getAttribute("type")) + if xml_dom.get("type"): + type = int(xml_dom.get("type")) 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) + if type == BG_TEXTURE: + if xml_dom.get('path') != "": self.set_texture(xml_dom.get('path')) + elif type == BG_IMAGE: + if xml_dom.get('path') != "": self.set_image(xml_dom.get('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')) + if xml_dom.get('local') and xml_dom.get('local') == 'True' and os.path.exists(urllib.unquote(xml_dom.get('localPath'))): + self.localPath = urllib.unquote(xml_dom.get('localPath')) self.local = True - self.localTime = int(xml_dom.getAttribute('localTime')) + self.localTime = int(xml_dom.get('localTime')) if self.localTime-time.time() <= 144000: file = open(self.localPath, "rb") imgdata = file.read() file.close() filename = os.path.split(self.localPath) (imgtype,j) = mimetypes.guess_type(filename[1]) - postdata = urllib.urlencode({'filename':filename[1], 'imgdata':imgdata, 'imgtype':imgtype}) + postdata = urllib.urlencode({'filename':filename[1], + 'imgdata':imgdata, + 'imgtype':imgtype}) thread.start_new_thread(self.upload, (postdata, self.localPath, type)) - @debugging + def upload(self, postdata, filename, type): self.lock.acquire() if type == 'Image' or type == 'Texture': url = component.get('settings').get_setting('ImageServerBaseURL') - file = urllib.urlopen(url, postdata) - recvdata = file.read() - file.close() + recvdata = parse(urllib.urlopen(url, postdata)) try: - xml_dom = minidom.parseString(recvdata)._get_documentElement() - if xml_dom.nodeName == 'path': - path = xml_dom.getAttribute('url') + xml_dom = fromstring(recvdata).getroot() + xml_dom = fromstring(recvdata) + if xml_dom.tag == 'path': + path = xml_dom.get('url') path = urllib.unquote(path) if type == 'Image': self.set_image(path, 1) else: self.set_texture(path) @@ -282,7 +280,7 @@ self.local = True self.localTime = time.time() else: - print xml_dom.getAttribute('msg') + print xml_dom.get('msg') except Exception, e: print e print recvdata
--- a/orpg/mapper/fog.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/fog.py Wed Nov 18 19:57:52 2009 -0600 @@ -209,8 +209,7 @@ if show == "Yes": self.canvas.frame.session.send(xml_str) def layerToXML(self, action="update"): - if not self.use_fog: - return "" + if not self.use_fog: return "" fog_string = "" ri = wx.RegionIterator(self.fogregion) if not (ri.HaveRects()): fog_string = FogArea("all", self.log).toxml("del") @@ -245,11 +244,11 @@ if not self.use_fog: self.use_fog = True self.recompute_fog() - if xml_dom.hasAttribute('serial'): self.serial_number = int(xml_dom.getAttribute('serial')) - children = xml_dom._get_childNodes() + if xml_dom.get('serial'): self.serial_number = int(xml_dom.get('serial')) + children = xml_dom.getchildren() for l in children: - action = l.getAttribute("action") - outline = l.getAttribute("outline") + action = l.get("action") + outline = l.get("outline") if (outline == "all"): polyline = [IPoint().make(0,0), IPoint().make(self.width-1, 0), IPoint().make(self.width-1, self.height-1), @@ -262,10 +261,10 @@ polyline = [] lastx = None lasty = None - list = l._get_childNodes() + list = l.getchildren() for point in list: - x = point.getAttribute( "x" ) - y = point.getAttribute( "y" ) + x = point.get( "x" ) + y = point.get( "y" ) if (x != lastx or y != lasty): polyline.append(IPoint().make(int(x), int(y))) lastx = x
--- a/orpg/mapper/fog_msg.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/fog_msg.py Wed Nov 18 19:57:52 2009 -0600 @@ -94,13 +94,10 @@ def interpret_dom(self,xml_dom): self.use_fog=1 - #print 'fog_msg.interpret_dom called' children = xml_dom.getchildren() - #print "children",children for l in children: action = l.get("action") outline = l.get("outline") - #print "action/outline",action, outline if (outline=="all"): polyline=[] self.fogregion.Clear() @@ -113,11 +110,6 @@ list = l.getchildren() for node in list: polyline.append( IPoint().make( int(node.get("x")), int(node.get("y")) ) ) - # pointarray = outline.split(";") - # for m in range(len(pointarray)): - # pt=pointarray[m].split(",") - # polyline.append(IPoint().make(int(pt[0]),int(pt[1]))) - #print "length of polyline", len(polyline) if (len(polyline)>2): if action=="del": self.fogregion.FromPolygon(polyline,0) else: self.fogregion.FromPolygon(polyline,1)
--- 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")))
--- a/orpg/mapper/map.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/map.py Wed Nov 18 19:57:52 2009 -0600 @@ -35,7 +35,6 @@ import random import os import thread -#import gc #Garbage Collecter Needed? import traceback from miniatures_handler import * @@ -49,6 +48,7 @@ from images import ImageHandler from orpg.orpgCore import component from orpg.tools.orpg_settings import settings +from xml.etree.ElementTree import ElementTree, Element, tostring, parse # Various marker modes for player tools on the map MARKER_MODE_NONE = 0 @@ -113,7 +113,6 @@ def MouseWheel(self, evt): if evt.CmdDown(): - print evt.GetWheelRotation() if evt.GetWheelRotation() > 0: self.on_zoom_in(None) elif evt.GetWheelRotation() < 0: self.on_zoom_out(None) else: pass @@ -606,68 +605,54 @@ else: return "" def takexml(self, xml): - """ - Added Process Dialog to display during long map parsings - as well as a try block with an exception traceback to try - and isolate some of the map related problems users have been - experiencing --Snowdog 5/15/03 - - Apparently Process Dialog causes problems with linux.. commenting it out. sheez. - --Snowdog 5/27/03 - """ try: - #parse the map DOM - xml_dom = parseXml(xml) + xml_dom = fromstring(xml) if xml_dom == None: return - node_list = xml_dom.getElementsByTagName("map") - if len(node_list) < 1: pass - else: - # set map version to incoming data so layers can convert - self.map_version = node_list[0].getAttribute("version") - action = node_list[0].getAttribute("action") - if action == "new": - self.layers = {} - try: self.layers['bg'] = layer_back_ground(self) - except: pass - try: self.layers['grid'] = grid_layer(self) - except: pass - try: self.layers['miniatures'] = miniature_layer(self) - except: pass - try: self.layers['whiteboard'] = whiteboard_layer(self) - except: pass - try: self.layers['fog'] = fog_layer(self) - except: pass - sizex = node_list[0].getAttribute("sizex") - if sizex != "": - sizex = int(float(sizex)) - sizey = self.size[1] - self.set_size((sizex,sizey)) - self.size_changed = 0 - sizey = node_list[0].getAttribute("sizey") - if sizey != "": - sizey = int(float(sizey)) - sizex = self.size[0] - self.set_size((sizex,sizey)) - self.size_changed = 0 - children = node_list[0]._get_childNodes() - #fog layer must be computed first, so that no data is inadvertently revealed - for c in children: - name = c._get_nodeName() - if name == "fog": self.layers[name].layerTakeDOM(c) - for c in children: - name = c._get_nodeName() - if name != "fog": self.layers[name].layerTakeDOM(c) - # all map data should be converted, set map version to current version - self.map_version = MAP_VERSION - self.Refresh(False) - xml_dom.unlink() # eliminate circular refs - except: pass + if xml_dom.tag != 'map': node_list = xml_dom.find("map") + else: node_list = xml_dom + # set map version to incoming data so layers can convert + self.map_version = node_list.get("version") + action = node_list.get("action") + if action == "new": + self.layers = {} + try: self.layers['bg'] = layer_back_ground(self) + except: pass + try: self.layers['grid'] = grid_layer(self) + except: pass + try: self.layers['miniatures'] = miniature_layer(self) + except: pass + try: self.layers['whiteboard'] = whiteboard_layer(self) + except: pass + try: self.layers['fog'] = fog_layer(self) + except: pass + sizex = node_list.get("sizex") if node_list.get("sizex") != None else '' + if sizex != "": + sizex = int(float(sizex)) + sizey = self.size[1] + self.set_size((sizex,sizey)) + self.size_changed = 0 + sizey = node_list.get("sizey") if node_list.get('sizey') != None else '' + if sizey != "": + sizey = int(float(sizey)) + sizex = self.size[0] + self.set_size((sizex,sizey)) + self.size_changed = 0 + children = node_list.getchildren() + #fog layer must be computed first, so that no data is inadvertently revealed + for c in children: + if c.tag == "fog": self.layers[c.tag].layerTakeDOM(c) + for c in children: + if c.tag != "fog": self.layers[c.tag].layerTakeDOM(c) + # all map data should be converted, set map version to current version + self.map_version = MAP_VERSION + self.Refresh(False) + except Exception, e: print 'failed', e; pass def re_ids_in_xml(self, xml): new_xml = "" tmp_map = map_msg() - xml_dom = parseXml(str(xml)) - node_list = xml_dom.getElementsByTagName("map") + xml_dom = fromstring(str(xml)) + node_list = xml_dom.findall("map") if len(node_list) < 1: pass else: tmp_map.init_from_dom(node_list[0]) @@ -690,9 +675,9 @@ if lines: for line in lines: l = whiteboard_layer.children[line] - if l.tagname == 'line': id = 'line-' + self.frame.session.get_next_id() - elif l.tagname == 'text': id = 'text-' + self.frame.session.get_next_id() - elif l.tagname == 'circle': id = 'circle-' + self.frame.session.get_next_id() + if l.tag == 'line': id = 'line-' + self.frame.session.get_next_id() + elif l.tag == 'text': id = 'text-' + self.frame.session.get_next_id() + elif l.tag == 'circle': id = 'circle-' + self.frame.session.get_next_id() l.init_prop("id", id) new_xml = tmp_map.get_all_xml() if xml_dom: xml_dom.unlink()
--- a/orpg/mapper/map_msg.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/map_msg.py Wed Nov 18 19:57:52 2009 -0600 @@ -64,12 +64,10 @@ class map_msg(map_element_msg_base): def __init__(self,reentrant_lock_object = None): - print 'class map_msg' self.tagname = "map" map_element_msg_base.__init__(self, reentrant_lock_object) def init_from_dom(self, xml_dom): - print 'init_from_dom', self.tagname self.p_lock.acquire() if xml_dom.tag == self.tagname: # If this is a map message, look for the "action=new" @@ -101,7 +99,6 @@ self.p_lock.release() def set_from_dom(self,xml_dom): - print 'set_from_dom' self.p_lock.acquire() if xml_dom.tag == self.tagname: # If this is a map message, look for the "action=new"
--- a/orpg/mapper/miniatures.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/miniatures.py Wed Nov 18 19:57:52 2009 -0600 @@ -99,7 +99,6 @@ self.bottom = bmp.GetHeight() self.isUpdated = False self.gray = False - print bmp self.set_bmp(bmp) def __del__(self): @@ -350,31 +349,27 @@ else: return '' def takedom(self, xml_dom): - self.id = xml_dom.getAttribute("id") - if xml_dom.hasAttribute("posx"): self.pos.x = int(xml_dom.getAttribute("posx")) - if xml_dom.hasAttribute("posy"): self.pos.y = int(xml_dom.getAttribute("posy")) - if xml_dom.hasAttribute("heading"): self.heading = int(xml_dom.getAttribute("heading")) - if xml_dom.hasAttribute("face"): self.face = int(xml_dom.getAttribute("face")) - if xml_dom.hasAttribute("path"): - self.path = urllib.unquote(xml_dom.getAttribute("path")) + self.id = xml_dom.get("id") + if xml_dom.get("posx"): self.pos.x = int(xml_dom.get("posx")) + if xml_dom.get("posy"): self.pos.y = int(xml_dom.get("posy")) + if xml_dom.get("heading"): self.heading = int(xml_dom.get("heading")) + if xml_dom.get("face"): self.face = int(xml_dom.get("face")) + if xml_dom.get("path"): + self.path = urllib.unquote(xml_dom.get("path")) self.set_bmp(ImageHandler.load(self.path, 'miniature', self.id)) - if xml_dom.hasAttribute("locked"): - if xml_dom.getAttribute("locked") == '1' or xml_dom.getAttribute("locked") == 'True': self.locked = True + if xml_dom.get("locked"): + if xml_dom.get("locked") == '1' or xml_dom.get("locked") == 'True': self.locked = True else: self.locked = False - if xml_dom.hasAttribute("hide"): - if xml_dom.getAttribute("hide") == '1' or xml_dom.getAttribute("hide") == 'True': self.hide = True + if xml_dom.get("hide"): + if xml_dom.get("hide") == '1' or xml_dom.get("hide") == 'True': self.hide = True else: self.hide = False - if xml_dom.hasAttribute("label"): - self.label = xml_dom.getAttribute("label") - if xml_dom.hasAttribute("zorder"): - self.zorder = int(xml_dom.getAttribute("zorder")) - if xml_dom.hasAttribute("align"): - if xml_dom.getAttribute("align") == '1' or xml_dom.getAttribute("align") == 'True': self.snap_to_align = 1 + if xml_dom.get("label"): self.label = xml_dom.get("label") + if xml_dom.get("zorder"): self.zorder = int(xml_dom.get("zorder")) + if xml_dom.get("align"): + if xml_dom.get("align") == '1' or xml_dom.get("align") == 'True': self.snap_to_align = 1 else: self.snap_to_align = 0 - if xml_dom.hasAttribute("width"): - self.width = int(xml_dom.getAttribute("width")) - if xml_dom.hasAttribute("height"): - self.height = int(xml_dom.getAttribute("height")) + if xml_dom.get("width"): self.width = int(xml_dom.get("width")) + if xml_dom.get("height"): self.height = int(xml_dom.get("height")) ##----------------------------- ## miniature layer @@ -391,7 +386,9 @@ # only smaller. 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, + self.label_font = wx.Font(font_size, + wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, + wx.FONTWEIGHT_NORMAL, False, settings.get_setting('defaultfont')) def next_serial(self): @@ -496,38 +493,38 @@ else: return "" def layerTakeDOM(self, xml_dom): - if xml_dom.hasAttribute('serial'): - self.serial_number = int(xml_dom.getAttribute('serial')) - children = xml_dom._get_childNodes() + if xml_dom.get('serial'): + self.serial_number = int(xml_dom.get('serial')) + children = xml_dom.getchildren() for c in children: - action = c.getAttribute("action") - id = c.getAttribute('id') + action = c.get("action") + id = c.get('id') if action == "del": mini = self.get_miniature_by_id(id) if mini: self.miniatures.remove(mini) del mini elif action == "new": - pos = cmpPoint(int(c.getAttribute('posx')),int(c.getAttribute('posy'))) - path = urllib.unquote(c.getAttribute('path')) - label = c.getAttribute('label') + pos = cmpPoint(int(c.get('posx')),int(c.get('posy'))) + path = urllib.unquote(c.get('path')) + label = c.get('label') height = width = heading = face = snap_to_align = zorder = 0 locked = hide = False - if c.hasAttribute('height'): height = int(c.getAttribute('height')) - if c.hasAttribute('width'): width = int(c.getAttribute('width')) - if c.getAttribute('locked') == 'True' or c.getAttribute('locked') == '1': locked = True - if c.getAttribute('hide') == 'True' or c.getAttribute('hide') == '1': hide = True - if c.getAttribute('heading'): heading = int(c.getAttribute('heading')) - if c.hasAttribute('face'): face = int(c.getAttribute('face')) - if c.hasAttribute('align'): snap_to_align = int(c.getAttribute('align')) - if c.getAttribute('zorder'): zorder = int(c.getAttribute('zorder')) + if c.get('height'): height = int(c.get('height')) or 0 + if c.get('width'): width = int(c.get('width')) + if c.get('locked') == 'True' or c.get('locked') == '1': locked = True + if c.get('hide') == 'True' or c.get('hide') == '1': hide = True + if c.get('heading'): heading = int(c.get('heading')) + if c.get('face'): face = int(c.get('face')) + if c.get('align'): snap_to_align = int(c.get('align')) + if c.get('zorder'): zorder = int(c.get('zorder')) image = ImageHandler.load(path, 'miniature', id) mini = BmpMiniature(id, path, image, pos, heading, face, label, locked, hide, snap_to_align, zorder, width, height, func='minis') self.miniatures.append(mini) - if c.hasAttribute('local') and c.getAttribute('local') == 'True' and os.path.exists(urllib.unquote(c.getAttribute('localPath'))): - localPath = urllib.unquote(c.getAttribute('localPath')) + if c.get('local') and c.get('local') == 'True' and os.path.exists(urllib.unquote(c.get('localPath'))): + localPath = urllib.unquote(c.get('localPath')) local = True - localTime = float(c.getAttribute('localTime')) + localTime = float(c.get('localTime')) if localTime-time.time() <= 144000: file = open(localPath, "rb") imgdata = file.read() @@ -537,7 +534,7 @@ postdata = urllib.urlencode({'filename':filename[1], 'imgdata':imgdata, 'imgtype':imgtype}) thread.start_new_thread(self.upload, (postdata, localPath, True)) # collapse the zorder. If the client behaved well, then nothing should change. - # Otherwise, this will ensure that there's some kind of z-order + # Otherwise, this will ensure that there's some kind of z-order self.collapse_zorder() else: mini = self.get_miniature_by_id(id) @@ -550,13 +547,13 @@ recvdata = file.read() file.close() try: - xml_dom = minidom.parseString(recvdata)._get_documentElement() - if xml_dom.nodeName == 'path': - path = xml_dom.getAttribute('url') + xml_dom = fromstring(recvdata) + if xml_dom.tag == 'path': + path = xml_dom.get('url') path = urllib.unquote(path) if not modify: start = path.rfind("/") + 1 - if self.canvas.parent.layer_handlers[2].auto_label: min_label = path[start:len(path)-4] + if self.canvas.parent.handlers[2].auto_label: min_label = path[start:len(path)-4] else: min_label = "" id = 'mini-' + self.canvas.frame.session.get_next_id() self.add_miniature(id, path, pos=pos, label=min_label, local=True, @@ -567,7 +564,7 @@ self.miniatures[len(self.miniatures)-1].localTime = time.time() self.miniatures[len(self.miniatures)-1].path = path else: - print xml_dom.getAttribute('msg') + print xml_dom.get('msg') except Exception, e: print e print recvdata
--- a/orpg/mapper/miniatures_handler.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/miniatures_handler.py Wed Nov 18 19:57:52 2009 -0600 @@ -420,7 +420,6 @@ oldz = self.sel_rmin.zorder # Make sure the mini isn't sticky front or back if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT): - ## print "old z-order = " + str(oldz) self.sel_rmin.zorder -= 1 # Re-collapse to normalize # Note: only one update (with the final values) will be sent @@ -434,7 +433,6 @@ # before getting the oldz to test # Save the selected minis current z-order oldz = self.sel_rmin.zorder - ## print "old z-order = " + str(oldz) self.sel_rmin.zorder += 1 # Re-collapse to normalize @@ -452,10 +450,8 @@ # Make sure the mini isn't sticky front or back if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT): - ## print "old z-order = " + str(oldz) # The new z-order will be one more than the last index newz = len(self.canvas.layers['miniatures'].miniatures) - ## print "new z-order = " + str(newz) self.sel_rmin.zorder = newz # Re-collapse to normalize # Note: only one update (with the final values) will be sent @@ -471,18 +467,15 @@ oldz = self.sel_rmin.zorder # Make sure the mini isn't sticky front or back if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT): - ## print "old z-order = " + str(oldz) # Since 0 is the lowest in a normalized order, be one less newz = -1 - ## print "new z-order = " + str(newz) self.sel_rmin.zorder = newz # Re-collapse to normalize # Note: only one update (with the final values) will be sent self.canvas.layers['miniatures'].collapse_zorder() elif id == MIN_FRONTBACK_UNLOCK: - #print "Unlocked/ unstickified..." if self.sel_rmin.zorder == MIN_STICKY_BACK: self.sel_rmin.zorder = MIN_STICKY_BACK + 1 elif self.sel_rmin.zorder == MIN_STICKY_FRONT: self.sel_rmin.zorder = MIN_STICKY_FRONT - 1 elif id == MIN_LOCK_BACK: self.sel_rmin.zorder = MIN_STICKY_BACK @@ -497,7 +490,6 @@ def on_miniature(self, evt): session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER) and (session.use_roles()): - print session.my_role() self.infoPost("You must be either a player or GM to use the miniature Layer") return min_url = self.min_url.GetValue() @@ -505,8 +497,6 @@ if min_url == "" or min_url == "http://": return if min_url[:7] != "http://" : min_url = "http://" + min_url # make label - if self.auto_label: print 'auto-label' - if not self.auto_label: print 'False' if self.auto_label and min_url[-4:-3] == '.': start = min_url.rfind("/") + 1 min_label = min_url[start:len(min_url)-4] @@ -517,7 +507,6 @@ try: id = 'mini-' + self.canvas.frame.session.get_next_id() # make the new mini appear in top left of current viewable map - print id dc = wx.ClientDC(self.canvas) self.canvas.PrepareDC(dc) dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale) @@ -527,7 +516,6 @@ except: # When there is an exception here, we should be decrementing the serial_number for reuse!! unablemsg= "Unable to load/resolve URL: " + min_url + " on resource \"" + min_label + "\"!!!\n\n" - #print unablemsg dlg = wx.MessageDialog(self,unablemsg, 'Url not found',wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() @@ -771,9 +759,7 @@ def role_is_gm_or_player(self): session = self.canvas.frame.session - print session.my_role(), session.ROLE_GM if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER) and (session.use_roles()): - print 'role is gm or player' self.infoPost("You must be either a player or GM to use the miniature Layer") return False return True
--- a/orpg/mapper/whiteboard.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/whiteboard.py Wed Nov 18 19:57:52 2009 -0600 @@ -30,6 +30,8 @@ from base import * from orpg.mapper.map_utils import * +from orpg.tools.orpg_log import debug +from xml.etree.ElementTree import ElementTree, Element, tostring def cmp_zorder(first,second): f = first.zorder @@ -99,43 +101,38 @@ dc.SetTextForeground(wx.Colour(0,0,0)) def toxml(self, action="update"): - if action == "del": - xml_str = "<text action='del' id='" + str(self.id) + "'/>" - return xml_str - xml_str = "<text" - xml_str += " action='" + action + "'" - xml_str += " id='" + str(self.id) + "'" - if self.pointsize != None: xml_str += " pointsize='" + str(self.pointsize) + "'" - if self.style != None: xml_str += " style='" + str(self.style) + "'" - if self.weight != None: xml_str += " weight='" + str(self.weight) + "'" - if self.posx != None: xml_str+= " posx='" + str(self.posx) + "'" - if not (self.posy is None): xml_str += " posy='" + str(self.posy) + "'" - if self.text_string != None: xml_str+= " text_string='" + self.text_string + "'" - if self.textcolor != None: xml_str += " color='" + self.textcolor + "'" - xml_str += "/>" + xml = Element('text') + xml.set('action', action) + xml.set('id', str(self.id)) + if action == 'del': return tostring(xml) + if self.pointsize != None: xml.set('pointsize', str(self.pointsize)) + if self.style != None: xml.set('style', str(self.style)) + if self.weight != None: xml.set('weight', str(self.weight)) + if self.posx != None: xml.set('posx', str(self.posx)) + if not (self.posy is None): xml.set('posy', str(self.posy)) + if self.text_string != None: xml.set('text_string', self.text_string) + if self.textcolor != None: xml.set('color', self.textcolor) if (action == "update" and self.isUpdated) or action == "new": self.isUpdated = False - return xml_str + return tostring(xml) else: return '' def takedom(self, xml_dom): - self.text_string = xml_dom.getAttribute("text_string") - self.id = xml_dom.getAttribute("id") - if xml_dom.hasAttribute("posy"): - self.posy = int(xml_dom.getAttribute("posy")) - if xml_dom.hasAttribute("posx"): - self.posx = int(xml_dom.getAttribute("posx")) - if xml_dom.hasAttribute("weight"): - self.weight = int(xml_dom.getAttribute("weight")) + self.text_string = xml_dom.get("text_string") + self.id = xml_dom.get("id") + if xml_dom.get("posy"): self.posy = int(xml_dom.get("posy")) + if xml_dom.get("posx"): self.posx = int(xml_dom.get("posx")) + if xml_dom.get("weight"): + self.weight = int(xml_dom.get("weight")) self.font.SetWeight(self.weight) - if xml_dom.hasAttribute("style"): - self.style = int(xml_dom.getAttribute("style")) + if xml_dom.get("style"): + self.style = int(xml_dom.get("style")) self.font.SetStyle(self.style) - if xml_dom.hasAttribute("pointsize"): - self.pointsize = int(xml_dom.getAttribute("pointsize")) + if xml_dom.get("pointsize"): + self.pointsize = int(xml_dom.get("pointsize")) self.font.SetPointSize(self.pointsize) - if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '': - self.textcolor = xml_dom.getAttribute("color") + if xml_dom.get("color") and xml_dom.get("color") != '': + self.textcolor = xml_dom.get("color") if self.textcolor == '#0000000': self.textcolor = '#000000' class WhiteboardLine: @@ -212,45 +209,42 @@ #selected outline def toxml(self, action="update"): - if action == "del": - xml_str = "<line action='del' id='" + str(self.id) + "'/>" - return xml_str + xml = Element('line') + xml.set('action', action) + xml.set('id', str(self.id)) + if action == "del": return tostring(xml) # if there are any changes, make sure id is one of them - xml_str = "<line" - xml_str += " action='" + action + "'" - xml_str += " id='" + str(self.id) + "'" - xml_str+= " line_string='" + self.line_string + "'" + xml.set('line_string', self.line_string) if self.upperleft != None: - xml_str += " upperleftx='" + str(self.upperleft.x) + "'" - xml_str += " upperlefty='" + str(self.upperleft.y) + "'" + xml.set('upperleftx', str(self.upperleft.x)) + xml.set('upperlefty', str(self.upperleft.y)) if self.lowerright != None: - xml_str+= " lowerrightx='" + str(self.lowerright.x) + "'" - xml_str+= " lowerrighty='" + str(self.lowerright.y) + "'" + xml.set('lowerrightx', str(self.lowerright.x)) + xml.set('lowerrighty', str(self.lowerright.y)) if self.linecolor != None: - xml_str += " color='" + str(self.linecolor) + "'" + xml.set('color', str(self.linecolor)) if self.linewidth != None: - xml_str += " width='" + str(self.linewidth) + "'" - xml_str += "/>" - if action == "new": return xml_str + xml.set('width', str(self.linewidth)) + if action == "new": return tostring(xml) return '' def takedom(self, xml_dom): - self.line_string = xml_dom.getAttribute("line_string") - self.id = xml_dom.getAttribute("id") - if xml_dom.hasAttribute("upperleftx"): - self.upperleft.x = int(xml_dom.getAttribute("upperleftx")) - if xml_dom.hasAttribute("upperlefty"): - self.upperleft.y = int(xml_dom.getAttribute("upperlefty")) - if xml_dom.hasAttribute("lowerrightx"): - self.lowerright.x = int(xml_dom.getAttribute("lowerrightx")) - if xml_dom.hasAttribute("lowerrighty"): - self.lowerright.y = int(xml_dom.getAttribute("lowerrighty")) - if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '': - self.linecolor = xml_dom.getAttribute("color") + self.line_string = xml_dom.get("line_string") + self.id = xml_dom.get("id") + if xml_dom.get("upperleftx"): + self.upperleft.x = int(xml_dom.get("upperleftx")) + if xml_dom.get("upperlefty"): + self.upperleft.y = int(xml_dom.get("upperlefty")) + if xml_dom.get("lowerrightx"): + self.lowerright.x = int(xml_dom.get("lowerrightx")) + if xml_dom.get("lowerrighty"): + self.lowerright.y = int(xml_dom.get("lowerrighty")) + if xml_dom.get("color") and xml_dom.get("color") != '': + self.linecolor = xml_dom.get("color") if self.linecolor == '#0000000': self.linecolor = '#000000' - if xml_dom.hasAttribute("width"): - self.linewidth = int(xml_dom.getAttribute("width")) + if xml_dom.get("width"): + self.linewidth = int(xml_dom.get("width")) ##----------------------------- ## whiteboard layer @@ -329,7 +323,6 @@ def del_all_lines(self): for i in xrange(len(self.lines)): self.del_line(self.lines[0]) - print self.lines def del_text(self, text): xml_str = "<map><whiteboard>" @@ -437,13 +430,14 @@ return "" def layerTakeDOM(self, xml_dom): - serial_number = xml_dom.getAttribute('serial') + serial_number = xml_dom.get('serial') if serial_number != "": self.serial_number = int(serial_number) - children = xml_dom._get_childNodes() + children = xml_dom.getchildren() for l in children: - nodename = l._get_nodeName() - action = l.getAttribute("action") - id = l.getAttribute('id') + nodename = l.tag + action = l.get("action") + id = l.get('id') + if self.serial_number < int(id[5:]): self.serial_number = int(id[5:]) if action == "del": if nodename == 'line': line = self.get_line_by_id(id) @@ -454,17 +448,17 @@ elif action == "new": if nodename == "line": try: - line_string = l.getAttribute('line_string') - upperleftx = l.getAttribute('upperleftx') - upperlefty = l.getAttribute('upperlefty') - lowerrightx = l.getAttribute('lowerrightx') - lowerrighty = l.getAttribute('lowerrighty') + line_string = l.get('line_string') + upperleftx = l.get('upperleftx') + upperlefty = l.get('upperlefty') + lowerrightx = l.get('lowerrightx') + lowerrighty = l.get('lowerrighty') upperleft = wx.Point(int(upperleftx),int(upperlefty)) lowerright = wx.Point(int(lowerrightx),int(lowerrighty)) - color = l.getAttribute('color') + color = l.get('color') if color == '#0000000': color = '#000000' - id = l.getAttribute('id') - width = int(l.getAttribute('width')) + id = l.get('id') + width = int(l.get('width')) except: line_string = upperleftx = upperlefty = lowerrightx = lowerrighty = color = 0 continue @@ -472,15 +466,15 @@ self.lines.append(line) elif nodename == "text": try: - text_string = l.getAttribute('text_string') - style = l.getAttribute('style') - pointsize = l.getAttribute('pointsize') - weight = l.getAttribute('weight') - color = l.getAttribute('color') + text_string = l.get('text_string') + style = l.get('style') + pointsize = l.get('pointsize') + weight = l.get('weight') + color = l.get('color') if color == '#0000000': color = '#000000' - id = l.getAttribute('id') - posx = l.getAttribute('posx') - posy = l.getAttribute('posy') + id = l.get('id') + posx = l.get('posx') + posy = l.get('posy') pos = wx.Point(0,0) pos.x = int(posx) pos.y = int(posy)
--- a/orpg/mapper/whiteboard_handler.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/whiteboard_handler.py Wed Nov 18 19:57:52 2009 -0600 @@ -30,6 +30,8 @@ from base_handler import * from math import floor from math import sqrt +from orpg.tools.orpg_log import debug +from xml.etree.ElementTree import ElementTree, Element, tostring class whiteboard_handler(base_layer_handler): def __init__(self, parent, id, canvas):
--- a/orpg/mapper/whiteboard_msg.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/mapper/whiteboard_msg.py Wed Nov 18 19:57:52 2009 -0600 @@ -29,7 +29,7 @@ __version__ = "$Id: whiteboard_msg.py,v 1.12 2007/03/09 14:11:56 digitalxero Exp $" from base_msg import * -from xml.etree.ElementTree import ElementTree +from xml.etree.ElementTree import ElementTree, Element, tostring class item_msg(map_element_msg_base):
--- a/orpg/orpg_version.py Mon Nov 16 19:13:41 2009 -0600 +++ b/orpg/orpg_version.py Wed Nov 18 19:57:52 2009 -0600 @@ -4,7 +4,7 @@ #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed) DISTRO = "Traipse Alpha" DIS_VER = "Ornery Orc" -BUILD = "091016-00" +BUILD = "091018-00" # This version is for network capability. PROTOCOL_VERSION = "1.2"