comparison orpg/mapper/miniatures.py @ 20:072ffc1d466f traipse_dev

2nd attempt. Still untested.
author sirebral
date Sat, 25 Jul 2009 19:23:25 -0500
parents 78407d627cba
children fdd70f11bc7e
comparison
equal deleted inserted replaced
19:78407d627cba 20:072ffc1d466f
54 SNAPTO_ALIGN_TL = 1 54 SNAPTO_ALIGN_TL = 1
55 55
56 def cmp_zorder(first,second): 56 def cmp_zorder(first,second):
57 f = first.zorder 57 f = first.zorder
58 s = second.zorder 58 s = second.zorder
59 if f == None: 59 if f == None: f = 0
60 f = 0 60 if s == None: s = 0
61 if s == None: 61 if f == s: value = 0
62 s = 0 62 elif f < s: value = -1
63 if f == s: 63 else: value = 1
64 value = 0
65 elif f < s:
66 value = -1
67 else:
68 value = 1
69 return value 64 return value
70 65
71 class BmpMiniature: 66 class BmpMiniature:
72 def __init__(self, id,path, bmp, pos=cmpPoint(0,0), heading=FACE_NONE, face=FACE_NONE, label="", 67 def __init__(self, id,path, bmp, pos=cmpPoint(0,0), heading=FACE_NONE, face=FACE_NONE, label="", locked=False, hide=False, snap_to_align=SNAPTO_ALIGN_CENTER, zorder=0, width=0, height=0, log=None, local=False, localPath='', localTime=-1):
73 locked=False, hide=False, snap_to_align=SNAPTO_ALIGN_CENTER, zorder=0, width=0, height=0,
74 log=None, local=False, localPath='', localTime=-1):
75 self.log = log 68 self.log = log
76 self.log.log("Enter BmpMiniature", ORPG_DEBUG) 69 self.log.log("Enter BmpMiniature", ORPG_DEBUG)
77 self.heading = heading 70 self.heading = heading
78 self.face = face 71 self.face = face
79 self.label = label 72 self.label = label
88 self.zorder = zorder 81 self.zorder = zorder
89 self.left = 0 82 self.left = 0
90 self.local = local 83 self.local = local
91 self.localPath = localPath 84 self.localPath = localPath
92 self.localTime = localTime 85 self.localTime = localTime
93 if not width: 86 if not width: self.width = 0
94 self.width = 0 87 else: self.width = width
95 else: 88 if not height: self.height = 0
96 self.width = width 89 else: self.height = height
97 if not height:
98 self.height = 0
99 else:
100 self.height = height
101 self.right = bmp.GetWidth() 90 self.right = bmp.GetWidth()
102 self.top = 0 91 self.top = 0
103 self.bottom = bmp.GetHeight() 92 self.bottom = bmp.GetHeight()
104 self.isUpdated = False 93 self.isUpdated = False
105 self.gray = False 94 self.gray = False
120 self.log.log("Enter BmpMiniature->set_min_props(self, heading, face, label, locked, hide, width, height)", 109 self.log.log("Enter BmpMiniature->set_min_props(self, heading, face, label, locked, hide, width, height)",
121 ORPG_DEBUG) 110 ORPG_DEBUG)
122 self.heading = heading 111 self.heading = heading
123 self.face = face 112 self.face = face
124 self.label = label 113 self.label = label
125 if locked: 114 if locked: self.locked = True
126 self.locked = True 115 else: self.locked = False
127 else: 116 if hide: self.hide = True
128 self.locked = False 117 else: self.hide = False
129 if hide:
130 self.hide = True
131 else:
132 self.hide = False
133 self.width = int(width) 118 self.width = int(width)
134 self.height = int(height) 119 self.height = int(height)
135 self.isUpdated = True 120 self.isUpdated = True
136 self.log.log("Exit BmpMiniature->set_min_props(self, heading, face, label, locked, hide, width, height)", 121 self.log.log("Exit BmpMiniature->set_min_props(self, heading, face, label, locked, hide, width, height)",
137 ORPG_DEBUG) 122 ORPG_DEBUG)
178 # grey outline 163 # grey outline
179 graypen = wx.Pen("gray", 1, wx.DOT) 164 graypen = wx.Pen("gray", 1, wx.DOT)
180 dc.SetPen(graypen) 165 dc.SetPen(graypen)
181 dc.SetBrush(wx.TRANSPARENT_BRUSH) 166 dc.SetBrush(wx.TRANSPARENT_BRUSH)
182 #if width or height < 20 then offset = 1 167 #if width or height < 20 then offset = 1
183 if self.bmp.GetWidth() <= 20: 168 if self.bmp.GetWidth() <= 20: xoffset = 1
184 xoffset = 1 169 else: xoffset = 5
185 else: 170 if self.bmp.GetHeight() <= 20: yoffset = 1
186 xoffset = 5 171 else: yoffset = 5
187 if self.bmp.GetHeight() <= 20:
188 yoffset = 1
189 else:
190 yoffset = 5
191 dc.DrawRectangle(self.pos.x + xoffset, 172 dc.DrawRectangle(self.pos.x + xoffset,
192 self.pos.y + yoffset, self.bmp.GetWidth() - (xoffset * 2), 173 self.pos.y + yoffset, self.bmp.GetWidth() - (xoffset * 2),
193 self.bmp.GetHeight() - (yoffset * 2)) 174 self.bmp.GetHeight() - (yoffset * 2))
194 dc.SetBrush(wx.NullBrush) 175 dc.SetBrush(wx.NullBrush)
195 dc.SetPen(wx.NullPen) 176 dc.SetPen(wx.NullPen)
218 dc.DrawRectangle(self.pos.x, self.pos.y, self.bmp.GetWidth(), self.bmp.GetHeight()) 199 dc.DrawRectangle(self.pos.x, self.pos.y, self.bmp.GetWidth(), self.bmp.GetHeight())
219 dc.SetBrush(wx.NullBrush) 200 dc.SetBrush(wx.NullBrush)
220 dc.SetPen(wx.NullPen) 201 dc.SetPen(wx.NullPen)
221 self.log.log("Exit BmpMiniature->draw->Draw Hidden", ORPG_DEBUG) 202 self.log.log("Exit BmpMiniature->draw->Draw Hidden", ORPG_DEBUG)
222 return True 203 return True
223 elif self.hide: 204 elif self.hide: self.log.log("Enter/Exit BmpMiniature->draw->Skip Hidden", ORPG_DEBUG); return True
224 self.log.log("Enter/Exit BmpMiniature->draw->Skip Hidden", ORPG_DEBUG)
225 return True
226 205
227 else: 206 else:
228 self.log.log("Enter BmpMiniature->draw->Not Hidden", ORPG_DEBUG) 207 self.log.log("Enter BmpMiniature->draw->Not Hidden", ORPG_DEBUG)
229 # set the width and height of the image 208 # set the width and height of the image
230 bmp = self.bmp 209 bmp = self.bmp
237 tmp_image.GetMaskGreen(), tmp_image.GetMaskBlue())) 216 tmp_image.GetMaskGreen(), tmp_image.GetMaskBlue()))
238 self.bmp.SetMask(mask) 217 self.bmp.SetMask(mask)
239 if self.gray: 218 if self.gray:
240 tmp_image = tmp_image.ConvertToGreyscale() 219 tmp_image = tmp_image.ConvertToGreyscale()
241 bmp = tmp_image.ConvertToBitmap() 220 bmp = tmp_image.ConvertToBitmap()
242 else: 221 else: bmp = self.bmp
243 bmp = self.bmp
244 dc.DrawBitmap(bmp, self.pos.x, self.pos.y, True) 222 dc.DrawBitmap(bmp, self.pos.x, self.pos.y, True)
245 self.left = 0 223 self.left = 0
246 self.right = self.bmp.GetWidth() 224 self.right = self.bmp.GetWidth()
247 self.top = 0 225 self.top = 0
248 self.bottom = self.bmp.GetHeight() 226 self.bottom = self.bmp.GetHeight()
384 self.bottom+=5 362 self.bottom+=5
385 self.left-=5 363 self.left-=5
386 self.right+=5 364 self.right+=5
387 self.log.log("Exit BmpMiniature->draw->Not Hidden", ORPG_DEBUG) 365 self.log.log("Exit BmpMiniature->draw->Not Hidden", ORPG_DEBUG)
388 return True 366 return True
389 else: 367 else: self.log.log("Exit BmpMiniature->draw(self, dc, mini_layer, op) return False", ORPG_DEBUG); return False
390 self.log.log("Exit BmpMiniature->draw(self, dc, mini_layer, op) return False", ORPG_DEBUG)
391 return False
392 self.log.log("Exit BmpMiniature->draw(self, dc, mini_layer, op)", ORPG_DEBUG) 368 self.log.log("Exit BmpMiniature->draw(self, dc, mini_layer, op)", ORPG_DEBUG)
393 369
394 def toxml(self, action="update"): 370 def toxml(self, action="update"):
395 self.log.log("Enter BmpMiniature->toxml(self, " + action + ")", ORPG_DEBUG) 371 self.log.log("Enter BmpMiniature->toxml(self, " + action + ")", ORPG_DEBUG)
396 if action == "del": 372 if action == "del":
403 xml_str += " label='" + self.label + "'" 379 xml_str += " label='" + self.label + "'"
404 xml_str+= " id='" + self.id + "'" 380 xml_str+= " id='" + self.id + "'"
405 if self.pos != None: 381 if self.pos != None:
406 xml_str += " posx='" + str(self.pos.x) + "'" 382 xml_str += " posx='" + str(self.pos.x) + "'"
407 xml_str += " posy='" + str(self.pos.y) + "'" 383 xml_str += " posy='" + str(self.pos.y) + "'"
408 if self.heading != None: 384 if self.heading != None: xml_str += " heading='" + str(self.heading) + "'"
409 xml_str += " heading='" + str(self.heading) + "'" 385 if self.face != None: xml_str += " face='" + str(self.face) + "'"
410 if self.face != None: 386 if self.path != None: xml_str += " path='" + urllib.quote(self.path).replace('%3A', ':') + "'"
411 xml_str += " face='" + str(self.face) + "'" 387 if self.locked: xml_str += " locked='1'"
412 if self.path != None: 388 else: xml_str += " locked='0'"
413 xml_str += " path='" + urllib.quote(self.path).replace('%3A', ':') + "'" 389 if self.hide: xml_str += " hide='1'"
414 if self.locked: 390 else: xml_str += " hide='0'"
415 xml_str += " locked='1'" 391 if self.snap_to_align != None: xml_str += " align='" + str(self.snap_to_align) + "'"
416 else: 392 if self.id != None: xml_str += " zorder='" + str(self.zorder) + "'"
417 xml_str += " locked='0'" 393 if self.width != None: xml_str += " width='" + str(self.width) + "'"
418 if self.hide: 394 if self.height != None: xml_str += " height='" + str(self.height) + "'"
419 xml_str += " hide='1'"
420 else:
421 xml_str += " hide='0'"
422 if self.snap_to_align != None:
423 xml_str += " align='" + str(self.snap_to_align) + "'"
424 if self.id != None:
425 xml_str += " zorder='" + str(self.zorder) + "'"
426 if self.width != None:
427 xml_str += " width='" + str(self.width) + "'"
428 if self.height != None:
429 xml_str += " height='" + str(self.height) + "'"
430 if self.local: 395 if self.local:
431 xml_str += ' local="' + str(self.local) + '"' 396 xml_str += ' local="' + str(self.local) + '"'
432 xml_str += ' localPath="' + str(urllib.quote(self.localPath).replace('%3A', ':')) + '"' 397 xml_str += ' localPath="' + str(urllib.quote(self.localPath).replace('%3A', ':')) + '"'
433 xml_str += ' localTime="' + str(self.localTime) + '"' 398 xml_str += ' localTime="' + str(self.localTime) + '"'
434 xml_str += " />" 399 xml_str += " />"
435 self.log.log(xml_str, ORPG_DEBUG) 400 self.log.log(xml_str, ORPG_DEBUG)
436 self.log.log("Exit BmpMiniature->toxml(self, " + action + ")", ORPG_DEBUG) 401 self.log.log("Exit BmpMiniature->toxml(self, " + action + ")", ORPG_DEBUG)
437 if (action == "update" and self.isUpdated) or action == "new": 402 if (action == "update" and self.isUpdated) or action == "new":
438 self.isUpdated = False 403 self.isUpdated = False
439 return xml_str 404 return xml_str
440 else: 405 else: return ''
441 return ''
442 406
443 def takedom(self, xml_dom): 407 def takedom(self, xml_dom):
444 self.log.log("Enter BmpMiniature->takedom(self, xml_dom)", ORPG_DEBUG) 408 self.log.log("Enter BmpMiniature->takedom(self, xml_dom)", ORPG_DEBUG)
445 self.id = xml_dom.getAttribute("id") 409 self.id = xml_dom.getAttribute("id")
446 self.log.log("self.id=" + str(self.id), ORPG_DEBUG) 410 self.log.log("self.id=" + str(self.id), ORPG_DEBUG)
459 if xml_dom.hasAttribute("path"): 423 if xml_dom.hasAttribute("path"):
460 self.path = urllib.unquote(xml_dom.getAttribute("path")) 424 self.path = urllib.unquote(xml_dom.getAttribute("path"))
461 self.set_bmp(ImageHandler.load(self.path, 'miniature', self.id)) 425 self.set_bmp(ImageHandler.load(self.path, 'miniature', self.id))
462 self.log.log("self.path=" + self.path, ORPG_DEBUG) 426 self.log.log("self.path=" + self.path, ORPG_DEBUG)
463 if xml_dom.hasAttribute("locked"): 427 if xml_dom.hasAttribute("locked"):
464 if xml_dom.getAttribute("locked") == '1' or xml_dom.getAttribute("locked") == 'True': 428 if xml_dom.getAttribute("locked") == '1' or xml_dom.getAttribute("locked") == 'True': self.locked = True
465 self.locked = True 429 else: self.locked = False
466 else:
467 self.locked = False
468 self.log.log("self.locked=" + str(self.locked), ORPG_DEBUG) 430 self.log.log("self.locked=" + str(self.locked), ORPG_DEBUG)
469 if xml_dom.hasAttribute("hide"): 431 if xml_dom.hasAttribute("hide"):
470 if xml_dom.getAttribute("hide") == '1' or xml_dom.getAttribute("hide") == 'True': 432 if xml_dom.getAttribute("hide") == '1' or xml_dom.getAttribute("hide") == 'True': self.hide = True
471 self.hide = True 433 else: self.hide = False
472 else:
473 self.hide = False
474 self.log.log("self.hide=" + str(self.hide), ORPG_DEBUG) 434 self.log.log("self.hide=" + str(self.hide), ORPG_DEBUG)
475 if xml_dom.hasAttribute("label"): 435 if xml_dom.hasAttribute("label"):
476 self.label = xml_dom.getAttribute("label") 436 self.label = xml_dom.getAttribute("label")
477 self.log.log("self.label=" + self.label, ORPG_DEBUG) 437 self.log.log("self.label=" + self.label, ORPG_DEBUG)
478 if xml_dom.hasAttribute("zorder"): 438 if xml_dom.hasAttribute("zorder"):
479 self.zorder = int(xml_dom.getAttribute("zorder")) 439 self.zorder = int(xml_dom.getAttribute("zorder"))
480 self.log.log("self.zorder=" + str(self.zorder), ORPG_DEBUG) 440 self.log.log("self.zorder=" + str(self.zorder), ORPG_DEBUG)
481 if xml_dom.hasAttribute("align"): 441 if xml_dom.hasAttribute("align"):
482 if xml_dom.getAttribute("align") == '1' or xml_dom.getAttribute("align") == 'True': 442 if xml_dom.getAttribute("align") == '1' or xml_dom.getAttribute("align") == 'True': self.snap_to_align = 1
483 self.snap_to_align = 1 443 else: self.snap_to_align = 0
484 else:
485 self.snap_to_align = 0
486 self.log.log("self.snap_to_align=" + str(self.snap_to_align), ORPG_DEBUG) 444 self.log.log("self.snap_to_align=" + str(self.snap_to_align), ORPG_DEBUG)
487 if xml_dom.hasAttribute("width"): 445 if xml_dom.hasAttribute("width"):
488 self.width = int(xml_dom.getAttribute("width")) 446 self.width = int(xml_dom.getAttribute("width"))
489 self.log.log("self.width=" + str(self.width), ORPG_DEBUG) 447 self.log.log("self.width=" + str(self.width), ORPG_DEBUG)
490 if xml_dom.hasAttribute("height"): 448 if xml_dom.hasAttribute("height"):
500 self.canvas = canvas 458 self.canvas = canvas
501 self.log = self.canvas.log 459 self.log = self.canvas.log
502 self.log.log("Enter miniature_layer", ORPG_DEBUG) 460 self.log.log("Enter miniature_layer", ORPG_DEBUG)
503 self.settings = self.canvas.settings 461 self.settings = self.canvas.settings
504 layer_base.__init__(self) 462 layer_base.__init__(self)
505
506 self.id = -1 #added. 463 self.id = -1 #added.
507
508 self.miniatures = [] 464 self.miniatures = []
509 self.serial_number = 0 465 self.serial_number = 0
510 466
511 # Set the font of the labels to be the same as the chat window 467 # Set the font of the labels to be the same as the chat window
512 # only smaller. 468 # only smaller.
513 font_size = int(self.settings.get_setting('defaultfontsize')) 469 font_size = int(self.settings.get_setting('defaultfontsize'))
514 if (font_size >= 10): 470 if (font_size >= 10): font_size -= 2
515 font_size -= 2
516 self.label_font = wx.Font(font_size, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 471 self.label_font = wx.Font(font_size, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL,
517 False, self.settings.get_setting('defaultfont')) 472 False, self.settings.get_setting('defaultfont'))
518
519 self.log.log("Exit miniature_layer", ORPG_DEBUG) 473 self.log.log("Exit miniature_layer", ORPG_DEBUG)
520 474
521 def next_serial(self): 475 def next_serial(self):
522 self.log.log("Enter miniature_layer->next_serial(self)", ORPG_DEBUG) 476 self.log.log("Enter miniature_layer->next_serial(self)", ORPG_DEBUG)
523 self.serial_number += 1 477 self.serial_number += 1
547 # lock the zorder stuff 501 # lock the zorder stuff
548 sorted_miniatures = self.miniatures[:] 502 sorted_miniatures = self.miniatures[:]
549 sorted_miniatures.sort(cmp_zorder) 503 sorted_miniatures.sort(cmp_zorder)
550 i = 0 504 i = 0
551 for mini in sorted_miniatures: 505 for mini in sorted_miniatures:
552 if (mini.zorder != MIN_STICKY_BACK) and (mini.zorder != MIN_STICKY_FRONT): 506 if (mini.zorder != MIN_STICKY_BACK) and (mini.zorder != MIN_STICKY_FRONT): mini.zorder = i
553 mini.zorder = i 507 else: pass
554 else:
555 pass
556 i = i + 1 508 i = i + 1
557 self.log.log("Exit miniature_layer->collapse_zorder(self)", ORPG_DEBUG) 509 self.log.log("Exit miniature_layer->collapse_zorder(self)", ORPG_DEBUG)
558 # unlock the zorder stuff 510 # unlock the zorder stuff
559 511
560 def rollback_serial(self): 512 def rollback_serial(self):
577 self.log.log("After mini addition:" + str(self.get_next_highest_z()), ORPG_DEBUG) 529 self.log.log("After mini addition:" + str(self.get_next_highest_z()), ORPG_DEBUG)
578 xml_str = "<map><miniatures>" 530 xml_str = "<map><miniatures>"
579 xml_str += mini.toxml("new") 531 xml_str += mini.toxml("new")
580 xml_str += "</miniatures></map>" 532 xml_str += "</miniatures></map>"
581 self.canvas.frame.session.send(xml_str) 533 self.canvas.frame.session.send(xml_str)
582 else: 534 else: self.log.log("Invalid image " + path + " has been ignored!", ORPG_DEBUG)
583 self.log.log("Invalid image " + path + " has been ignored!", ORPG_DEBUG)
584 self.log.log("Exit miniature_layer->add_miniature(self, id, path, pos, label, heading, face, width, height)", 535 self.log.log("Exit miniature_layer->add_miniature(self, id, path, pos, label, heading, face, width, height)",
585 ORPG_DEBUG) 536 ORPG_DEBUG)
586 537
587 def get_miniature_by_id(self, id): 538 def get_miniature_by_id(self, id):
588 self.log.log("Enter miniature_layer->get_miniature_by_id(self, id)", ORPG_DEBUG) 539 self.log.log("Enter miniature_layer->get_miniature_by_id(self, id)", ORPG_DEBUG)
628 def find_miniature(self, pt, only_unlocked=False): 579 def find_miniature(self, pt, only_unlocked=False):
629 self.log.log("Enter miniature_layer->find_miniature(self, pt, only_unlocked)", ORPG_DEBUG) 580 self.log.log("Enter miniature_layer->find_miniature(self, pt, only_unlocked)", ORPG_DEBUG)
630 min_list = [] 581 min_list = []
631 for m in self.miniatures: 582 for m in self.miniatures:
632 if m.hit_test(pt): 583 if m.hit_test(pt):
633 if m.hide and self.canvas.frame.session.my_role() != self.canvas.frame.session.ROLE_GM: 584 if m.hide and self.canvas.frame.session.my_role() != self.canvas.frame.session.ROLE_GM: continue
634 continue 585 if only_unlocked and not m.locked: min_list.append(m)
635 if only_unlocked and not m.locked: 586 elif not only_unlocked and m.locked: min_list.append(m)
636 min_list.append(m) 587 else: continue
637 elif not only_unlocked and m.locked:
638 min_list.append(m)
639 else:
640 continue
641 if len(min_list) > 0: 588 if len(min_list) > 0:
642 self.log.log("Exit miniature_layer->find_miniature(self, pt, only_unlocked)", ORPG_DEBUG) 589 self.log.log("Exit miniature_layer->find_miniature(self, pt, only_unlocked)", ORPG_DEBUG)
643 return min_list 590 return min_list
644 else: 591 else: self.log.log("Exit miniature_layer->find_miniature(self, pt, only_unlocked)", ORPG_DEBUG); return None
645 self.log.log("Exit miniature_layer->find_miniature(self, pt, only_unlocked)", ORPG_DEBUG)
646 return None
647 592
648 def layerToXML(self, action="update"): 593 def layerToXML(self, action="update"):
649 """ format """ 594 """ format """
650 self.log.log("Enter miniature_layer->layerToXML(self, " + action + ")", ORPG_DEBUG) 595 self.log.log("Enter miniature_layer->layerToXML(self, " + action + ")", ORPG_DEBUG)
651 minis_string = "" 596 minis_string = ""
652 if self.miniatures: 597 if self.miniatures:
653 for m in self.miniatures: 598 for m in self.miniatures: minis_string += m.toxml(action)
654 minis_string += m.toxml(action)
655 if minis_string != '': 599 if minis_string != '':
656 s = "<miniatures" 600 s = "<miniatures"
657 s += " serial='" + str(self.serial_number) + "'" 601 s += " serial='" + str(self.serial_number) + "'"
658 s += ">" 602 s += ">"
659 s += minis_string 603 s += minis_string
660 s += "</miniatures>" 604 s += "</miniatures>"
661 self.log.log("Exit miniature_layer->layerToXML(self, " + action + ")", ORPG_DEBUG) 605 self.log.log("Exit miniature_layer->layerToXML(self, " + action + ")", ORPG_DEBUG)
662 return s 606 return s
663 else: 607 else: self.log.log("Exit miniature_layer->layerToXML(self, " + action + ") return None", ORPG_DEBUG); return ""
664 self.log.log("Exit miniature_layer->layerToXML(self, " + action + ") return None", ORPG_DEBUG)
665 return ""
666 608
667 def layerTakeDOM(self, xml_dom): 609 def layerTakeDOM(self, xml_dom):
668 self.log.log("Enter miniature_layer->layerTakeDOM(self, xml_dom)", ORPG_DEBUG) 610 self.log.log("Enter miniature_layer->layerTakeDOM(self, xml_dom)", ORPG_DEBUG)
669 if xml_dom.hasAttribute('serial'): 611 if xml_dom.hasAttribute('serial'):
670 self.serial_number = int(xml_dom.getAttribute('serial')) 612 self.serial_number = int(xml_dom.getAttribute('serial'))
671 children = xml_dom._get_childNodes() 613 children = xml_dom._get_childNodes()
672 for c in children: 614 for c in children:
673 action = c.getAttribute("action") 615 action = c.getAttribute("action")
674 id = c.getAttribute('id') 616 id = c.getAttribute('id')
675 if action == "del": 617 if action == "del": mini = self.get_miniature_by_id(id)
676 mini = self.get_miniature_by_id(id)
677 if mini: 618 if mini:
678 self.miniatures.remove(mini) 619 self.miniatures.remove(mini)
679 del mini 620 del mini
680 else: 621 else: self.log.log("Map Synchronization Error :: Update of unknown mini attempted", ORPG_DEBUG)
681 self.log.log("Map Synchronization Error :: Update of unknown mini attempted", ORPG_DEBUG)
682 #wx.MessageBox("Deletion of unknown mini attempted","Map Synchronization Error")
683 elif action == "new": 622 elif action == "new":
684 pos = cmpPoint(int(c.getAttribute('posx')),int(c.getAttribute('posy'))) 623 pos = cmpPoint(int(c.getAttribute('posx')),int(c.getAttribute('posy')))
685 path = urllib.unquote(c.getAttribute('path')) 624 path = urllib.unquote(c.getAttribute('path'))
686 label = c.getAttribute('label') 625 label = c.getAttribute('label')
687 height = width = heading = face = snap_to_align = zorder = 0 626 height = width = heading = face = snap_to_align = zorder = 0
688 locked = hide = False 627 locked = hide = False
689 if c.hasAttribute('height'): 628 if c.hasAttribute('height'): height = int(c.getAttribute('height'))
690 height = int(c.getAttribute('height')) 629 if c.hasAttribute('width'): width = int(c.getAttribute('width'))
691 if c.hasAttribute('width'): 630 if c.getAttribute('locked') == 'True' or c.getAttribute('locked') == '1': locked = True
692 width = int(c.getAttribute('width')) 631 if c.getAttribute('hide') == 'True' or c.getAttribute('hide') == '1': hide = True
693 if c.getAttribute('locked') == 'True' or c.getAttribute('locked') == '1': 632 if c.getAttribute('heading'): heading = int(c.getAttribute('heading'))
694 locked = True 633 if c.hasAttribute('face'): face = int(c.getAttribute('face'))
695 if c.getAttribute('hide') == 'True' or c.getAttribute('hide') == '1': 634 if c.hasAttribute('align'): snap_to_align = int(c.getAttribute('align'))
696 hide = True 635 if c.getAttribute('zorder'): zorder = int(c.getAttribute('zorder'))
697 if c.getAttribute('heading'):
698 heading = int(c.getAttribute('heading'))
699 if c.hasAttribute('face'):
700 face = int(c.getAttribute('face'))
701 if c.hasAttribute('align'):
702 snap_to_align = int(c.getAttribute('align'))
703 if c.getAttribute('zorder'):
704 zorder = int(c.getAttribute('zorder'))
705 min = BmpMiniature(id, path, ImageHandler.load(path, 'miniature', id), pos, heading, 636 min = BmpMiniature(id, path, ImageHandler.load(path, 'miniature', id), pos, heading,
706 face, label, locked, hide, snap_to_align, zorder, width, height, self.log) 637 face, label, locked, hide, snap_to_align, zorder, width, height, self.log)
707 self.miniatures.append(min) 638 self.miniatures.append(min)
708 if c.hasAttribute('local') and c.getAttribute('local') == 'True' and os.path.exists(urllib.unquote(c.getAttribute('localPath'))): 639 if c.hasAttribute('local') and c.getAttribute('local') == 'True' and os.path.exists(urllib.unquote(c.getAttribute('localPath'))):
709 localPath = urllib.unquote(c.getAttribute('localPath')) 640 localPath = urllib.unquote(c.getAttribute('localPath'))
720 # collapse the zorder. If the client behaved well, then nothing should change. 651 # collapse the zorder. If the client behaved well, then nothing should change.
721 # Otherwise, this will ensure that there's some kind of z-order 652 # Otherwise, this will ensure that there's some kind of z-order
722 self.collapse_zorder() 653 self.collapse_zorder()
723 else: 654 else:
724 mini = self.get_miniature_by_id(id) 655 mini = self.get_miniature_by_id(id)
725 if mini: 656 if mini: mini.takedom(c)
726 mini.takedom(c) 657 else: self.log.log("Map Synchronization Error :: Update of unknown mini attempted", ORPG_DEBUG)
727 else:
728 self.log.log("Map Synchronization Error :: Update of unknown mini attempted", ORPG_DEBUG)
729 #wx.MessageBox("Update of unknown mini attempted","Map Synchronization Error")
730 self.log.log("Exit miniature_layer->layerTakeDOM(self, xml_dom)", ORPG_DEBUG) 658 self.log.log("Exit miniature_layer->layerTakeDOM(self, xml_dom)", ORPG_DEBUG)
731 659
732 def upload(self, postdata, filename, modify=False, pos=cmpPoint(0,0)): 660 def upload(self, postdata, filename, modify=False, pos=cmpPoint(0,0)):
733 self.lock.acquire() 661 self.lock.acquire()
734 url = self.settings.get_setting('ImageServerBaseURL') 662 url = self.settings.get_setting('ImageServerBaseURL')
740 if xml_dom.nodeName == 'path': 668 if xml_dom.nodeName == 'path':
741 path = xml_dom.getAttribute('url') 669 path = xml_dom.getAttribute('url')
742 path = urllib.unquote(path) 670 path = urllib.unquote(path)
743 if not modify: 671 if not modify:
744 start = path.rfind("/") + 1 672 start = path.rfind("/") + 1
745 if self.canvas.parent.layer_handlers[2].auto_label: 673 if self.canvas.parent.layer_handlers[2].auto_label: min_label = path[start:len(path)-4]
746 min_label = path[start:len(path)-4] 674 else: min_label = ""
747 else:
748 min_label = ""
749 id = 'mini-' + self.canvas.frame.session.get_next_id() 675 id = 'mini-' + self.canvas.frame.session.get_next_id()
750 self.add_miniature(id, path, pos=pos, label=min_label, local=True, 676 self.add_miniature(id, path, pos=pos, label=min_label, local=True,
751 localPath=filename, localTime=time.time()) 677 localPath=filename, localTime=time.time())
752 else: 678 else:
753 self.miniatures[len(self.miniatures)-1].local = True 679 self.miniatures[len(self.miniatures)-1].local = True