Mercurial > traipse_dev
diff orpg/mapper/background.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 |
line wrap: on
line diff
--- a/orpg/mapper/background.py Sat Nov 21 03:19:34 2009 -0600 +++ b/orpg/mapper/background.py Mon Nov 23 03:22:50 2009 -0600 @@ -40,8 +40,6 @@ 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 ##----------------------------- @@ -102,7 +100,7 @@ self.type = BG_TEXTURE if self.img_path != path: try: - self.bg_bmp = ImageHandler.load(path, "texture", 0) + self.bg_bmp = ImageHandler.load(path, "texture", 0).ConvertToBitmap() if self.bg_bmp == None: logger.general("Invalid image type!") raise Exception, "Invalid image type!" @@ -114,7 +112,7 @@ self.isUpdated = True self.type = BG_IMAGE if self.img_path != path: - self.bg_bmp = ImageHandler.load(path, "background", 0) + self.bg_bmp = ImageHandler.load(path, "background", 0).ConvertToBitmap() try: if self.bg_bmp == None: logger.general("Invalid image type!") @@ -136,12 +134,6 @@ if self.bg_bmp == None or not self.bg_bmp.Ok() or ((self.type != BG_TEXTURE) and (self.type != BG_IMAGE)): return False dc2 = wx.MemoryDC() - - ### Temporary ### - try: self.bg_bmp = self.bg_bmp.ConvertToBitmap() - except: pass - ################# - dc2.SelectObject(self.bg_bmp) topLeft = [int(topleft[0]/scale), int(topleft[1]/scale)] topRight = [int((topleft[0]+size[0]+1)/scale)+1, int((topleft[1]+size[1]+1)/scale)+1] @@ -214,52 +206,55 @@ def layerToXML(self, action="update"): - xml = Element('bg') + xml_str = "<bg" if self.bg_color != None: (red,green,blue) = self.bg_color.Get() hexcolor = self.r_h.hexstring(red, green, blue) - 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)) + 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) + '"' if self.local and self.img_path != None: - xml.set('local', 'True') - xml.set('localPath', urllib.quote(self.localPath).replace('%3A', ':')) - xml.set('localTime', str(self.localTime)) + 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) if (action == "update" and self.isUpdated) or action == "new": self.isUpdated = False - return tostring(xml) + return xml_str else: return '' def layerTakeDOM(self, xml_dom): type = BG_COLOR - color = xml_dom.get("color") + color = xml_dom.getAttribute("color") + logger.debug("color=" + color) + path = urllib.unquote(xml_dom.getAttribute("path")) + logger.debug("path=" + path) # Begin ted's map changes - if xml_dom.get("color"): - r,g,b = self.r_h.rgb_tuple(xml_dom.get("color")) + if xml_dom.hasAttribute("color"): + r,g,b = self.r_h.rgb_tuple(xml_dom.getAttribute("color")) self.set_color(cmpColour(r,g,b)) # End ted's map changes - if xml_dom.get("type"): - type = int(xml_dom.get("type")) + if xml_dom.hasAttribute("type"): + type = int(xml_dom.getAttribute("type")) logger.debug("type=" + str(type)) - 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) + 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.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')) + 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 - self.localTime = int(xml_dom.get('localTime')) + self.localTime = int(xml_dom.getAttribute('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)) @@ -267,12 +262,13 @@ self.lock.acquire() if type == 'Image' or type == 'Texture': url = component.get('settings').get_setting('ImageServerBaseURL') - recvdata = parse(urllib.urlopen(url, postdata)) + file = urllib.urlopen(url, postdata) + recvdata = file.read() + file.close() try: - xml_dom = fromstring(recvdata).getroot() - xml_dom = fromstring(recvdata) - if xml_dom.tag == 'path': - path = xml_dom.get('url') + xml_dom = minidom.parseString(recvdata)._get_documentElement() + if xml_dom.nodeName == 'path': + path = xml_dom.getAttribute('url') path = urllib.unquote(path) if type == 'Image': self.set_image(path, 1) else: self.set_texture(path) @@ -280,7 +276,7 @@ self.local = True self.localTime = time.time() else: - print xml_dom.get('msg') + print xml_dom.getAttribute('msg') except Exception, e: print e print recvdata