comparison orpg/mapper/whiteboard.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 1ed2feab0db9
comparison
equal deleted inserted replaced
136:b4e02e8cd314 137:54446a995007
28 # 28 #
29 __version__ = "$Id: whiteboard.py,v 1.47 2007/03/09 14:11:55 digitalxero Exp $" 29 __version__ = "$Id: whiteboard.py,v 1.47 2007/03/09 14:11:55 digitalxero Exp $"
30 30
31 from base import * 31 from base import *
32 from orpg.mapper.map_utils import * 32 from orpg.mapper.map_utils import *
33 from orpg.tools.orpg_log import debug
34 from xml.etree.ElementTree import ElementTree, Element, tostring
33 35
34 def cmp_zorder(first,second): 36 def cmp_zorder(first,second):
35 f = first.zorder 37 f = first.zorder
36 s = second.zorder 38 s = second.zorder
37 if f == None: f = 0 39 if f == None: f = 0
97 dc.SetFont(self.font) 99 dc.SetFont(self.font)
98 dc.DrawText(self.text_string, self.posx, self.posy) 100 dc.DrawText(self.text_string, self.posx, self.posy)
99 dc.SetTextForeground(wx.Colour(0,0,0)) 101 dc.SetTextForeground(wx.Colour(0,0,0))
100 102
101 def toxml(self, action="update"): 103 def toxml(self, action="update"):
102 if action == "del": 104 xml = Element('text')
103 xml_str = "<text action='del' id='" + str(self.id) + "'/>" 105 xml.set('action', action)
104 return xml_str 106 xml.set('id', str(self.id))
105 xml_str = "<text" 107 if action == 'del': return tostring(xml)
106 xml_str += " action='" + action + "'" 108 if self.pointsize != None: xml.set('pointsize', str(self.pointsize))
107 xml_str += " id='" + str(self.id) + "'" 109 if self.style != None: xml.set('style', str(self.style))
108 if self.pointsize != None: xml_str += " pointsize='" + str(self.pointsize) + "'" 110 if self.weight != None: xml.set('weight', str(self.weight))
109 if self.style != None: xml_str += " style='" + str(self.style) + "'" 111 if self.posx != None: xml.set('posx', str(self.posx))
110 if self.weight != None: xml_str += " weight='" + str(self.weight) + "'" 112 if not (self.posy is None): xml.set('posy', str(self.posy))
111 if self.posx != None: xml_str+= " posx='" + str(self.posx) + "'" 113 if self.text_string != None: xml.set('text_string', self.text_string)
112 if not (self.posy is None): xml_str += " posy='" + str(self.posy) + "'" 114 if self.textcolor != None: xml.set('color', self.textcolor)
113 if self.text_string != None: xml_str+= " text_string='" + self.text_string + "'"
114 if self.textcolor != None: xml_str += " color='" + self.textcolor + "'"
115 xml_str += "/>"
116 if (action == "update" and self.isUpdated) or action == "new": 115 if (action == "update" and self.isUpdated) or action == "new":
117 self.isUpdated = False 116 self.isUpdated = False
118 return xml_str 117 return tostring(xml)
119 else: return '' 118 else: return ''
120 119
121 def takedom(self, xml_dom): 120 def takedom(self, xml_dom):
122 self.text_string = xml_dom.getAttribute("text_string") 121 self.text_string = xml_dom.get("text_string")
123 self.id = xml_dom.getAttribute("id") 122 self.id = xml_dom.get("id")
124 if xml_dom.hasAttribute("posy"): 123 if xml_dom.get("posy"): self.posy = int(xml_dom.get("posy"))
125 self.posy = int(xml_dom.getAttribute("posy")) 124 if xml_dom.get("posx"): self.posx = int(xml_dom.get("posx"))
126 if xml_dom.hasAttribute("posx"): 125 if xml_dom.get("weight"):
127 self.posx = int(xml_dom.getAttribute("posx")) 126 self.weight = int(xml_dom.get("weight"))
128 if xml_dom.hasAttribute("weight"):
129 self.weight = int(xml_dom.getAttribute("weight"))
130 self.font.SetWeight(self.weight) 127 self.font.SetWeight(self.weight)
131 if xml_dom.hasAttribute("style"): 128 if xml_dom.get("style"):
132 self.style = int(xml_dom.getAttribute("style")) 129 self.style = int(xml_dom.get("style"))
133 self.font.SetStyle(self.style) 130 self.font.SetStyle(self.style)
134 if xml_dom.hasAttribute("pointsize"): 131 if xml_dom.get("pointsize"):
135 self.pointsize = int(xml_dom.getAttribute("pointsize")) 132 self.pointsize = int(xml_dom.get("pointsize"))
136 self.font.SetPointSize(self.pointsize) 133 self.font.SetPointSize(self.pointsize)
137 if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '': 134 if xml_dom.get("color") and xml_dom.get("color") != '':
138 self.textcolor = xml_dom.getAttribute("color") 135 self.textcolor = xml_dom.get("color")
139 if self.textcolor == '#0000000': self.textcolor = '#000000' 136 if self.textcolor == '#0000000': self.textcolor = '#000000'
140 137
141 class WhiteboardLine: 138 class WhiteboardLine:
142 def __init__(self, id, line_string, upperleft, lowerright, color="#000000", width=1, log=None): 139 def __init__(self, id, line_string, upperleft, lowerright, color="#000000", width=1, log=None):
143 self.scale = 1 140 self.scale = 1
210 dc.SetPen(wx.NullPen) 207 dc.SetPen(wx.NullPen)
211 dc.SetBrush(wx.NullBrush) 208 dc.SetBrush(wx.NullBrush)
212 #selected outline 209 #selected outline
213 210
214 def toxml(self, action="update"): 211 def toxml(self, action="update"):
215 if action == "del": 212 xml = Element('line')
216 xml_str = "<line action='del' id='" + str(self.id) + "'/>" 213 xml.set('action', action)
217 return xml_str 214 xml.set('id', str(self.id))
215 if action == "del": return tostring(xml)
218 # if there are any changes, make sure id is one of them 216 # if there are any changes, make sure id is one of them
219 xml_str = "<line" 217 xml.set('line_string', self.line_string)
220 xml_str += " action='" + action + "'"
221 xml_str += " id='" + str(self.id) + "'"
222 xml_str+= " line_string='" + self.line_string + "'"
223 if self.upperleft != None: 218 if self.upperleft != None:
224 xml_str += " upperleftx='" + str(self.upperleft.x) + "'" 219 xml.set('upperleftx', str(self.upperleft.x))
225 xml_str += " upperlefty='" + str(self.upperleft.y) + "'" 220 xml.set('upperlefty', str(self.upperleft.y))
226 if self.lowerright != None: 221 if self.lowerright != None:
227 xml_str+= " lowerrightx='" + str(self.lowerright.x) + "'" 222 xml.set('lowerrightx', str(self.lowerright.x))
228 xml_str+= " lowerrighty='" + str(self.lowerright.y) + "'" 223 xml.set('lowerrighty', str(self.lowerright.y))
229 if self.linecolor != None: 224 if self.linecolor != None:
230 xml_str += " color='" + str(self.linecolor) + "'" 225 xml.set('color', str(self.linecolor))
231 if self.linewidth != None: 226 if self.linewidth != None:
232 xml_str += " width='" + str(self.linewidth) + "'" 227 xml.set('width', str(self.linewidth))
233 xml_str += "/>" 228 if action == "new": return tostring(xml)
234 if action == "new": return xml_str
235 return '' 229 return ''
236 230
237 def takedom(self, xml_dom): 231 def takedom(self, xml_dom):
238 self.line_string = xml_dom.getAttribute("line_string") 232 self.line_string = xml_dom.get("line_string")
239 self.id = xml_dom.getAttribute("id") 233 self.id = xml_dom.get("id")
240 if xml_dom.hasAttribute("upperleftx"): 234 if xml_dom.get("upperleftx"):
241 self.upperleft.x = int(xml_dom.getAttribute("upperleftx")) 235 self.upperleft.x = int(xml_dom.get("upperleftx"))
242 if xml_dom.hasAttribute("upperlefty"): 236 if xml_dom.get("upperlefty"):
243 self.upperleft.y = int(xml_dom.getAttribute("upperlefty")) 237 self.upperleft.y = int(xml_dom.get("upperlefty"))
244 if xml_dom.hasAttribute("lowerrightx"): 238 if xml_dom.get("lowerrightx"):
245 self.lowerright.x = int(xml_dom.getAttribute("lowerrightx")) 239 self.lowerright.x = int(xml_dom.get("lowerrightx"))
246 if xml_dom.hasAttribute("lowerrighty"): 240 if xml_dom.get("lowerrighty"):
247 self.lowerright.y = int(xml_dom.getAttribute("lowerrighty")) 241 self.lowerright.y = int(xml_dom.get("lowerrighty"))
248 if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '': 242 if xml_dom.get("color") and xml_dom.get("color") != '':
249 self.linecolor = xml_dom.getAttribute("color") 243 self.linecolor = xml_dom.get("color")
250 if self.linecolor == '#0000000': 244 if self.linecolor == '#0000000':
251 self.linecolor = '#000000' 245 self.linecolor = '#000000'
252 if xml_dom.hasAttribute("width"): 246 if xml_dom.get("width"):
253 self.linewidth = int(xml_dom.getAttribute("width")) 247 self.linewidth = int(xml_dom.get("width"))
254 248
255 ##----------------------------- 249 ##-----------------------------
256 ## whiteboard layer 250 ## whiteboard layer
257 ##----------------------------- 251 ##-----------------------------
258 class whiteboard_layer(layer_base): 252 class whiteboard_layer(layer_base):
327 self.canvas.Refresh(True) 321 self.canvas.Refresh(True)
328 322
329 def del_all_lines(self): 323 def del_all_lines(self):
330 for i in xrange(len(self.lines)): 324 for i in xrange(len(self.lines)):
331 self.del_line(self.lines[0]) 325 self.del_line(self.lines[0])
332 print self.lines
333 326
334 def del_text(self, text): 327 def del_text(self, text):
335 xml_str = "<map><whiteboard>" 328 xml_str = "<map><whiteboard>"
336 xml_str += text.toxml("del") 329 xml_str += text.toxml("del")
337 xml_str += "</whiteboard></map>" 330 xml_str += "</whiteboard></map>"
435 return s 428 return s
436 else: 429 else:
437 return "" 430 return ""
438 431
439 def layerTakeDOM(self, xml_dom): 432 def layerTakeDOM(self, xml_dom):
440 serial_number = xml_dom.getAttribute('serial') 433 serial_number = xml_dom.get('serial')
441 if serial_number != "": self.serial_number = int(serial_number) 434 if serial_number != "": self.serial_number = int(serial_number)
442 children = xml_dom._get_childNodes() 435 children = xml_dom.getchildren()
443 for l in children: 436 for l in children:
444 nodename = l._get_nodeName() 437 nodename = l.tag
445 action = l.getAttribute("action") 438 action = l.get("action")
446 id = l.getAttribute('id') 439 id = l.get('id')
440 if self.serial_number < int(id[5:]): self.serial_number = int(id[5:])
447 if action == "del": 441 if action == "del":
448 if nodename == 'line': 442 if nodename == 'line':
449 line = self.get_line_by_id(id) 443 line = self.get_line_by_id(id)
450 if line != None: self.lines.remove(line) 444 if line != None: self.lines.remove(line)
451 elif nodename == 'text': 445 elif nodename == 'text':
452 text = self.get_text_by_id(id) 446 text = self.get_text_by_id(id)
453 if text != None: self.texts.remove(text) 447 if text != None: self.texts.remove(text)
454 elif action == "new": 448 elif action == "new":
455 if nodename == "line": 449 if nodename == "line":
456 try: 450 try:
457 line_string = l.getAttribute('line_string') 451 line_string = l.get('line_string')
458 upperleftx = l.getAttribute('upperleftx') 452 upperleftx = l.get('upperleftx')
459 upperlefty = l.getAttribute('upperlefty') 453 upperlefty = l.get('upperlefty')
460 lowerrightx = l.getAttribute('lowerrightx') 454 lowerrightx = l.get('lowerrightx')
461 lowerrighty = l.getAttribute('lowerrighty') 455 lowerrighty = l.get('lowerrighty')
462 upperleft = wx.Point(int(upperleftx),int(upperlefty)) 456 upperleft = wx.Point(int(upperleftx),int(upperlefty))
463 lowerright = wx.Point(int(lowerrightx),int(lowerrighty)) 457 lowerright = wx.Point(int(lowerrightx),int(lowerrighty))
464 color = l.getAttribute('color') 458 color = l.get('color')
465 if color == '#0000000': color = '#000000' 459 if color == '#0000000': color = '#000000'
466 id = l.getAttribute('id') 460 id = l.get('id')
467 width = int(l.getAttribute('width')) 461 width = int(l.get('width'))
468 except: 462 except:
469 line_string = upperleftx = upperlefty = lowerrightx = lowerrighty = color = 0 463 line_string = upperleftx = upperlefty = lowerrightx = lowerrighty = color = 0
470 continue 464 continue
471 line = WhiteboardLine(id, line_string, upperleft, lowerright, color, width) 465 line = WhiteboardLine(id, line_string, upperleft, lowerright, color, width)
472 self.lines.append(line) 466 self.lines.append(line)
473 elif nodename == "text": 467 elif nodename == "text":
474 try: 468 try:
475 text_string = l.getAttribute('text_string') 469 text_string = l.get('text_string')
476 style = l.getAttribute('style') 470 style = l.get('style')
477 pointsize = l.getAttribute('pointsize') 471 pointsize = l.get('pointsize')
478 weight = l.getAttribute('weight') 472 weight = l.get('weight')
479 color = l.getAttribute('color') 473 color = l.get('color')
480 if color == '#0000000': color = '#000000' 474 if color == '#0000000': color = '#000000'
481 id = l.getAttribute('id') 475 id = l.get('id')
482 posx = l.getAttribute('posx') 476 posx = l.get('posx')
483 posy = l.getAttribute('posy') 477 posy = l.get('posy')
484 pos = wx.Point(0,0) 478 pos = wx.Point(0,0)
485 pos.x = int(posx) 479 pos.x = int(posx)
486 pos.y = int(posy) 480 pos.y = int(posy)
487 except: 481 except:
488 continue 482 continue