Mercurial > traipse_dev
comparison orpg/mapper/fog.py @ 228:24769389a7ba alpha
Traipse Alpha 'OpenRPG' {100612-01}
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 (Preparing to close updates)
New Features:
New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order
Fixes:
Fix to InterParse that was causing an Infernal Loop with Namespace Internal
Fix to XML data, removed old Minidom and switched to Element Tree
Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread
Fix to metaservers.xml file not being created
author | sirebral |
---|---|
date | Sat, 12 Jun 2010 04:38:29 -0500 |
parents | 06f10429eedc |
children |
comparison
equal
deleted
inserted
replaced
225:2c6db2043764 | 228:24769389a7ba |
---|---|
25 | 25 |
26 import sys | 26 import sys |
27 from base import * | 27 from base import * |
28 from random import Random | 28 from random import Random |
29 from region import * | 29 from region import * |
30 from orpg.minidom import Element | 30 from xml.etree.ElementTree import Element, tostring |
31 import traceback | 31 import traceback |
32 COURSE = 10 | 32 COURSE = 10 |
33 | 33 |
34 class FogArea: | 34 class FogArea: |
35 def __init__(self, outline, log): | 35 def __init__(self, outline, log): |
45 return result | 45 return result |
46 | 46 |
47 for pairs in string.split( points, ';' ): | 47 for pairs in string.split( points, ';' ): |
48 pair = string.split( pairs, ',' ) | 48 pair = string.split( pairs, ',' ) |
49 p = Element( "point" ) | 49 p = Element( "point" ) |
50 p.setAttribute( "x", pair[0] ) | 50 p.set( "x", pair[0] ) |
51 p.setAttribute( "y", pair[1] ) | 51 p.set( "y", pair[1] ) |
52 result.append( p ) | 52 result.append( p ) |
53 return result | 53 return result |
54 | 54 |
55 def toxml(self, action="update"): | 55 def toxml(self, action="update"): |
56 xml_str = "" | 56 xml_str = "" |
57 localOutline = self.outline | 57 localOutline = self.outline |
58 if localOutline != None and localOutline != "all" and localOutline != "none": | 58 if localOutline != None and localOutline != "all" and localOutline != "none": |
59 localOutline = "points" | 59 localOutline = "points" |
60 elem = Element( "poly" ) | 60 elem = Element( "poly" ) |
61 if action == "del": | 61 if action == "del": |
62 elem.setAttribute( "action", action ) | 62 elem.set( "action", action ) |
63 elem.setAttribute( "outline", localOutline ) | 63 elem.set( "outline", localOutline ) |
64 if localOutline == 'points': | 64 if localOutline == 'points': |
65 list = self.points_to_elements( self.outline ) | 65 foglist = self.points_to_elements( self.outline ) |
66 for p in list: elem.appendChild( p ) | 66 for p in foglist: elem.append( p ) |
67 str = elem.toxml() | 67 return tostring(elem) |
68 elem.unlink() | 68 elem.set( "action", action ) |
69 return str | |
70 elem.setAttribute( "action", action ) | |
71 if localOutline != None: | 69 if localOutline != None: |
72 elem.setAttribute( "outline", localOutline ) | 70 elem.set( "outline", localOutline ) |
73 if localOutline == 'points': | 71 if localOutline == 'points': |
74 list = self.points_to_elements( self.outline ) | 72 foglist = self.points_to_elements( self.outline ) |
75 for p in list: elem.appendChild( p ) | 73 for p in foglist: elem.append( p ) |
76 xml_str = elem.toxml() | 74 #xml_str = elem.toxml() |
77 elem.unlink() | 75 return tostring(elem) |
78 return xml_str | |
79 | 76 |
80 class fog_layer(layer_base): | 77 class fog_layer(layer_base): |
81 def __init__(self, canvas): | 78 def __init__(self, canvas): |
82 self.canvas = canvas | 79 self.canvas = canvas |
83 self.log = component.get('log') | 80 self.log = component.get('log') |
221 def layerTakeDOM(self, xml_dom): | 218 def layerTakeDOM(self, xml_dom): |
222 try: | 219 try: |
223 if not self.use_fog: | 220 if not self.use_fog: |
224 self.use_fog = True | 221 self.use_fog = True |
225 self.recompute_fog() | 222 self.recompute_fog() |
226 if xml_dom.hasAttribute('serial'): self.serial_number = int(xml_dom.getAttribute('serial')) | 223 serial = xml_dom.get('serial') |
227 children = xml_dom._get_childNodes() | 224 if serial != None: self.serial_number = int(serial) |
225 children = xml_dom.getchildren() | |
228 for l in children: | 226 for l in children: |
229 action = l.getAttribute("action") | 227 action = l.get("action") |
230 outline = l.getAttribute("outline") | 228 outline = l.get("outline") |
231 if (outline == "all"): | 229 if (outline == "all"): |
232 polyline = [IPoint().make(0,0), IPoint().make(self.width-1, 0), | 230 polyline = [IPoint().make(0,0), IPoint().make(self.width-1, 0), |
233 IPoint().make(self.width-1, self.height-1), | 231 IPoint().make(self.width-1, self.height-1), |
234 IPoint().make(0, self.height-1)] | 232 IPoint().make(0, self.height-1)] |
235 elif (outline == "none"): | 233 elif (outline == "none"): |
238 self.fog_bmp = None | 236 self.fog_bmp = None |
239 else: | 237 else: |
240 polyline = [] | 238 polyline = [] |
241 lastx = None | 239 lastx = None |
242 lasty = None | 240 lasty = None |
243 list = l._get_childNodes() | 241 list = l.getchildren() |
244 for point in list: | 242 for point in list: |
245 x = point.getAttribute( "x" ) | 243 x = point.get( "x" ) |
246 y = point.getAttribute( "y" ) | 244 y = point.get( "y" ) |
247 if (x != lastx or y != lasty): | 245 if (x != lastx or y != lasty): |
248 polyline.append(IPoint().make(int(x), int(y))) | 246 polyline.append(IPoint().make(int(x), int(y))) |
249 lastx = x | 247 lastx = x |
250 lasty = y | 248 lasty = y |
251 if (len(polyline) > 1): self.createregn2(polyline, action, "No") | 249 if (len(polyline) > 1): self.createregn2(polyline, action, "No") |