Mercurial > traipse_dev
comparison orpg/mapper/whiteboard.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 | 1ed2feab0db9 |
children | 06f10429eedc |
comparison
equal
deleted
inserted
replaced
138:1ed2feab0db9 | 139:8e07c1a2c69b |
---|---|
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 | |
35 | |
36 ## I added tr_ to the line and text ID. This should help prevent Traipse's lines from being randomly deleted. ## | |
37 | 33 |
38 def cmp_zorder(first,second): | 34 def cmp_zorder(first,second): |
39 f = first.zorder | 35 f = first.zorder |
40 s = second.zorder | 36 s = second.zorder |
41 if f == None: f = 0 | 37 if f == None: f = 0 |
101 dc.SetFont(self.font) | 97 dc.SetFont(self.font) |
102 dc.DrawText(self.text_string, self.posx, self.posy) | 98 dc.DrawText(self.text_string, self.posx, self.posy) |
103 dc.SetTextForeground(wx.Colour(0,0,0)) | 99 dc.SetTextForeground(wx.Colour(0,0,0)) |
104 | 100 |
105 def toxml(self, action="update"): | 101 def toxml(self, action="update"): |
106 xml = Element('text') | 102 if action == "del": |
107 xml.set('action', action) | 103 xml_str = "<text action='del' id='" + str(self.id) + "'/>" |
108 xml.set('id', str(self.id)) | 104 return xml_str |
109 if action == 'del': return tostring(xml) | 105 xml_str = "<text" |
110 if self.pointsize != None: xml.set('pointsize', str(self.pointsize)) | 106 xml_str += " action='" + action + "'" |
111 if self.style != None: xml.set('style', str(self.style)) | 107 xml_str += " id='" + str(self.id) + "'" |
112 if self.weight != None: xml.set('weight', str(self.weight)) | 108 if self.pointsize != None: xml_str += " pointsize='" + str(self.pointsize) + "'" |
113 if self.posx != None: xml.set('posx', str(self.posx)) | 109 if self.style != None: xml_str += " style='" + str(self.style) + "'" |
114 if not (self.posy is None): xml.set('posy', str(self.posy)) | 110 if self.weight != None: xml_str += " weight='" + str(self.weight) + "'" |
115 if self.text_string != None: xml.set('text_string', self.text_string) | 111 if self.posx != None: xml_str+= " posx='" + str(self.posx) + "'" |
116 if self.textcolor != None: xml.set('color', self.textcolor) | 112 if not (self.posy is None): xml_str += " posy='" + str(self.posy) + "'" |
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 += "/>" | |
117 if (action == "update" and self.isUpdated) or action == "new": | 116 if (action == "update" and self.isUpdated) or action == "new": |
118 self.isUpdated = False | 117 self.isUpdated = False |
119 return tostring(xml) | 118 return xml_str |
120 else: return '' | 119 else: return '' |
121 | 120 |
122 def takedom(self, xml_dom): | 121 def takedom(self, xml_dom): |
123 self.text_string = xml_dom.get("text_string") | 122 self.text_string = xml_dom.getAttribute("text_string") |
124 self.id = xml_dom.get("id") | 123 self.id = xml_dom.getAttribute("id") |
125 if xml_dom.get("posy"): self.posy = int(xml_dom.get("posy")) | 124 if xml_dom.hasAttribute("posy"): |
126 if xml_dom.get("posx"): self.posx = int(xml_dom.get("posx")) | 125 self.posy = int(xml_dom.getAttribute("posy")) |
127 if xml_dom.get("weight"): | 126 if xml_dom.hasAttribute("posx"): |
128 self.weight = int(xml_dom.get("weight")) | 127 self.posx = int(xml_dom.getAttribute("posx")) |
128 if xml_dom.hasAttribute("weight"): | |
129 self.weight = int(xml_dom.getAttribute("weight")) | |
129 self.font.SetWeight(self.weight) | 130 self.font.SetWeight(self.weight) |
130 if xml_dom.get("style"): | 131 if xml_dom.hasAttribute("style"): |
131 self.style = int(xml_dom.get("style")) | 132 self.style = int(xml_dom.getAttribute("style")) |
132 self.font.SetStyle(self.style) | 133 self.font.SetStyle(self.style) |
133 if xml_dom.get("pointsize"): | 134 if xml_dom.hasAttribute("pointsize"): |
134 self.pointsize = int(xml_dom.get("pointsize")) | 135 self.pointsize = int(xml_dom.getAttribute("pointsize")) |
135 self.font.SetPointSize(self.pointsize) | 136 self.font.SetPointSize(self.pointsize) |
136 if xml_dom.get("color") and xml_dom.get("color") != '': | 137 if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '': |
137 self.textcolor = xml_dom.get("color") | 138 self.textcolor = xml_dom.getAttribute("color") |
138 if self.textcolor == '#0000000': self.textcolor = '#000000' | 139 if self.textcolor == '#0000000': self.textcolor = '#000000' |
139 | 140 |
140 class WhiteboardLine: | 141 class WhiteboardLine: |
141 def __init__(self, id, line_string, upperleft, lowerright, color="#000000", width=1, log=None): | 142 def __init__(self, id, line_string, upperleft, lowerright, color="#000000", width=1, log=None): |
142 self.scale = 1 | 143 self.scale = 1 |
209 dc.SetPen(wx.NullPen) | 210 dc.SetPen(wx.NullPen) |
210 dc.SetBrush(wx.NullBrush) | 211 dc.SetBrush(wx.NullBrush) |
211 #selected outline | 212 #selected outline |
212 | 213 |
213 def toxml(self, action="update"): | 214 def toxml(self, action="update"): |
214 xml = Element('line') | 215 if action == "del": |
215 xml.set('action', action) | 216 xml_str = "<line action='del' id='" + str(self.id) + "'/>" |
216 xml.set('id', str(self.id)) | 217 return xml_str |
217 if action == "del": return tostring(xml) | |
218 # if there are any changes, make sure id is one of them | 218 # if there are any changes, make sure id is one of them |
219 xml.set('line_string', self.line_string) | 219 xml_str = "<line" |
220 xml_str += " action='" + action + "'" | |
221 xml_str += " id='" + str(self.id) + "'" | |
222 xml_str+= " line_string='" + self.line_string + "'" | |
220 if self.upperleft != None: | 223 if self.upperleft != None: |
221 xml.set('upperleftx', str(self.upperleft.x)) | 224 xml_str += " upperleftx='" + str(self.upperleft.x) + "'" |
222 xml.set('upperlefty', str(self.upperleft.y)) | 225 xml_str += " upperlefty='" + str(self.upperleft.y) + "'" |
223 if self.lowerright != None: | 226 if self.lowerright != None: |
224 xml.set('lowerrightx', str(self.lowerright.x)) | 227 xml_str+= " lowerrightx='" + str(self.lowerright.x) + "'" |
225 xml.set('lowerrighty', str(self.lowerright.y)) | 228 xml_str+= " lowerrighty='" + str(self.lowerright.y) + "'" |
226 if self.linecolor != None: | 229 if self.linecolor != None: |
227 xml.set('color', str(self.linecolor)) | 230 xml_str += " color='" + str(self.linecolor) + "'" |
228 if self.linewidth != None: | 231 if self.linewidth != None: |
229 xml.set('width', str(self.linewidth)) | 232 xml_str += " width='" + str(self.linewidth) + "'" |
230 if action == "new": return tostring(xml) | 233 xml_str += "/>" |
234 if action == "new": return xml_str | |
231 return '' | 235 return '' |
232 | 236 |
233 def takedom(self, xml_dom): | 237 def takedom(self, xml_dom): |
234 self.line_string = xml_dom.get("line_string") | 238 self.line_string = xml_dom.getAttribute("line_string") |
235 self.id = xml_dom.get("id") | 239 self.id = xml_dom.getAttribute("id") |
236 if xml_dom.get("upperleftx"): | 240 if xml_dom.hasAttribute("upperleftx"): |
237 self.upperleft.x = int(xml_dom.get("upperleftx")) | 241 self.upperleft.x = int(xml_dom.getAttribute("upperleftx")) |
238 if xml_dom.get("upperlefty"): | 242 if xml_dom.hasAttribute("upperlefty"): |
239 self.upperleft.y = int(xml_dom.get("upperlefty")) | 243 self.upperleft.y = int(xml_dom.getAttribute("upperlefty")) |
240 if xml_dom.get("lowerrightx"): | 244 if xml_dom.hasAttribute("lowerrightx"): |
241 self.lowerright.x = int(xml_dom.get("lowerrightx")) | 245 self.lowerright.x = int(xml_dom.getAttribute("lowerrightx")) |
242 if xml_dom.get("lowerrighty"): | 246 if xml_dom.hasAttribute("lowerrighty"): |
243 self.lowerright.y = int(xml_dom.get("lowerrighty")) | 247 self.lowerright.y = int(xml_dom.getAttribute("lowerrighty")) |
244 if xml_dom.get("color") and xml_dom.get("color") != '': | 248 if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '': |
245 self.linecolor = xml_dom.get("color") | 249 self.linecolor = xml_dom.getAttribute("color") |
246 if self.linecolor == '#0000000': | 250 if self.linecolor == '#0000000': |
247 self.linecolor = '#000000' | 251 self.linecolor = '#000000' |
248 if xml_dom.get("width"): | 252 if xml_dom.hasAttribute("width"): |
249 self.linewidth = int(xml_dom.get("width")) | 253 self.linewidth = int(xml_dom.getAttribute("width")) |
250 | 254 |
251 ##----------------------------- | 255 ##----------------------------- |
252 ## whiteboard layer | 256 ## whiteboard layer |
253 ##----------------------------- | 257 ##----------------------------- |
254 class whiteboard_layer(layer_base): | 258 class whiteboard_layer(layer_base): |
281 | 285 |
282 def rollback_serial(self): | 286 def rollback_serial(self): |
283 self.serial_number -= 1 | 287 self.serial_number -= 1 |
284 | 288 |
285 def add_line(self, line_string="", upperleft=cmpPoint(0,0), lowerright=cmpPoint(0,0), color="#000000", width=1): | 289 def add_line(self, line_string="", upperleft=cmpPoint(0,0), lowerright=cmpPoint(0,0), color="#000000", width=1): |
286 id = 'tr_line-' + str(self.next_serial()) | 290 id = 'line ' + str(self.next_serial()) |
287 line = WhiteboardLine(id, line_string, upperleft, lowerright, color=self.color, width=self.width) | 291 line = WhiteboardLine(id, line_string, upperleft, lowerright, color=self.color, width=self.width) |
288 self.lines.append(line) | 292 self.lines.append(line) |
289 xml_str = "<map><whiteboard>" | 293 xml_str = "<map><whiteboard>" |
290 xml_str += line.toxml("new") | 294 xml_str += line.toxml("new") |
291 xml_str += "</whiteboard></map>" | 295 xml_str += "</whiteboard></map>" |
323 self.canvas.Refresh(True) | 327 self.canvas.Refresh(True) |
324 | 328 |
325 def del_all_lines(self): | 329 def del_all_lines(self): |
326 for i in xrange(len(self.lines)): | 330 for i in xrange(len(self.lines)): |
327 self.del_line(self.lines[0]) | 331 self.del_line(self.lines[0]) |
332 print self.lines | |
328 | 333 |
329 def del_text(self, text): | 334 def del_text(self, text): |
330 xml_str = "<map><whiteboard>" | 335 xml_str = "<map><whiteboard>" |
331 xml_str += text.toxml("del") | 336 xml_str += text.toxml("del") |
332 xml_str += "</whiteboard></map>" | 337 xml_str += "</whiteboard></map>" |
380 | 385 |
381 def set_font(self, font): | 386 def set_font(self, font): |
382 self.font = font | 387 self.font = font |
383 | 388 |
384 def add_text(self, text_string, pos, style, pointsize, weight, color="#000000"): | 389 def add_text(self, text_string, pos, style, pointsize, weight, color="#000000"): |
385 id = 'tr_text-' + str(self.next_serial()) | 390 id = 'text ' + str(self.next_serial()) |
386 text = WhiteboardText(id,text_string, pos, style, pointsize, weight, color) | 391 text = WhiteboardText(id,text_string, pos, style, pointsize, weight, color) |
387 self.texts.append(text) | 392 self.texts.append(text) |
388 xml_str = "<map><whiteboard>" | 393 xml_str = "<map><whiteboard>" |
389 xml_str += text.toxml("new") | 394 xml_str += text.toxml("new") |
390 xml_str += "</whiteboard></map>" | 395 xml_str += "</whiteboard></map>" |
430 return s | 435 return s |
431 else: | 436 else: |
432 return "" | 437 return "" |
433 | 438 |
434 def layerTakeDOM(self, xml_dom): | 439 def layerTakeDOM(self, xml_dom): |
435 serial_number = xml_dom.get('serial') | 440 serial_number = xml_dom.getAttribute('serial') |
436 if serial_number != "": self.serial_number = int(serial_number) | 441 if serial_number != "": self.serial_number = int(serial_number) |
437 children = xml_dom.getchildren() | 442 children = xml_dom._get_childNodes() |
438 for l in children: | 443 for l in children: |
439 nodename = l.tag | 444 nodename = l._get_nodeName() |
440 action = l.get("action") | 445 action = l.getAttribute("action") |
441 id = l.get('id') | 446 id = l.getAttribute('id') |
442 if self.serial_number < int(id[5:]): self.serial_number = int(id[5:]) | 447 if self.serial_number < int(id[5:]): self.serial_number = int(id[5:]) |
443 if action == "del": | 448 if action == "del": |
444 if nodename == 'line': | 449 if nodename == 'line': |
445 line = self.get_line_by_id(id) | 450 line = self.get_line_by_id(id) |
446 if line != None: self.lines.remove(line) | 451 if line != None: self.lines.remove(line) |
448 text = self.get_text_by_id(id) | 453 text = self.get_text_by_id(id) |
449 if text != None: self.texts.remove(text) | 454 if text != None: self.texts.remove(text) |
450 elif action == "new": | 455 elif action == "new": |
451 if nodename == "line": | 456 if nodename == "line": |
452 try: | 457 try: |
453 line_string = l.get('line_string') | 458 line_string = l.getAttribute('line_string') |
454 upperleftx = l.get('upperleftx') | 459 upperleftx = l.getAttribute('upperleftx') |
455 upperlefty = l.get('upperlefty') | 460 upperlefty = l.getAttribute('upperlefty') |
456 lowerrightx = l.get('lowerrightx') | 461 lowerrightx = l.getAttribute('lowerrightx') |
457 lowerrighty = l.get('lowerrighty') | 462 lowerrighty = l.getAttribute('lowerrighty') |
458 upperleft = wx.Point(int(upperleftx),int(upperlefty)) | 463 upperleft = wx.Point(int(upperleftx),int(upperlefty)) |
459 lowerright = wx.Point(int(lowerrightx),int(lowerrighty)) | 464 lowerright = wx.Point(int(lowerrightx),int(lowerrighty)) |
460 color = l.get('color') | 465 color = l.getAttribute('color') |
461 if color == '#0000000': color = '#000000' | 466 if color == '#0000000': color = '#000000' |
462 id = l.get('id') | 467 id = l.getAttribute('id') |
463 width = int(l.get('width')) | 468 width = int(l.getAttribute('width')) |
464 except: | 469 except: |
465 line_string = upperleftx = upperlefty = lowerrightx = lowerrighty = color = 0 | 470 line_string = upperleftx = upperlefty = lowerrightx = lowerrighty = color = 0 |
466 continue | 471 continue |
467 line = WhiteboardLine(id, line_string, upperleft, lowerright, color, width) | 472 line = WhiteboardLine(id, line_string, upperleft, lowerright, color, width) |
468 self.lines.append(line) | 473 self.lines.append(line) |
469 elif nodename == "text": | 474 elif nodename == "text": |
470 try: | 475 try: |
471 text_string = l.get('text_string') | 476 text_string = l.getAttribute('text_string') |
472 style = l.get('style') | 477 style = l.getAttribute('style') |
473 pointsize = l.get('pointsize') | 478 pointsize = l.getAttribute('pointsize') |
474 weight = l.get('weight') | 479 weight = l.getAttribute('weight') |
475 color = l.get('color') | 480 color = l.getAttribute('color') |
476 if color == '#0000000': color = '#000000' | 481 if color == '#0000000': color = '#000000' |
477 id = l.get('id') | 482 id = l.getAttribute('id') |
478 posx = l.get('posx') | 483 posx = l.getAttribute('posx') |
479 posy = l.get('posy') | 484 posy = l.getAttribute('posy') |
480 pos = wx.Point(0,0) | 485 pos = wx.Point(0,0) |
481 pos.x = int(posx) | 486 pos.x = int(posx) |
482 pos.y = int(posy) | 487 pos.y = int(posy) |
483 except: | 488 except: |
484 continue | 489 continue |