comparison orpg/mapper/miniatures.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
comparison
equal deleted inserted replaced
138:1ed2feab0db9 139:8e07c1a2c69b
317 dc.SetPen(wx.NullPen) 317 dc.SetPen(wx.NullPen)
318 dc.SetBrush(wx.NullBrush) 318 dc.SetBrush(wx.NullBrush)
319 dc.DrawText(label,x+1,y+1) 319 dc.DrawText(label,x+1,y+1)
320 320
321 def toxml(self, action="update"): 321 def toxml(self, action="update"):
322 mini = Element('miniature') 322 if action == "del":
323 if action == 'del': 323 xml_str = "<miniature action='del' id='" + self.id + "'/>"
324 mini.set('action', action) 324 return xml_str
325 mini.set('id', str(self.id)) 325 xml_str = "<miniature"
326 return tostring(mini) 326 xml_str += " action='" + action + "'"
327 mini.set('action', action) 327 xml_str += " label='" + self.label + "'"
328 mini.set('id', str(self.id)) 328 xml_str+= " id='" + self.id + "'"
329 mini.set('label', self.label)
330 if self.pos != None: 329 if self.pos != None:
331 mini.set('posx', str(self.pos.x)) 330 xml_str += " posx='" + str(self.pos.x) + "'"
332 mini.set('posy', str(self.pos.y)) 331 xml_str += " posy='" + str(self.pos.y) + "'"
333 if self.heading != None: mini.set('heading', str(self.heading)) 332 if self.heading != None: xml_str += " heading='" + str(self.heading) + "'"
334 if self.face != None: mini.set('face', str(self.face)) 333 if self.face != None: xml_str += " face='" + str(self.face) + "'"
335 if self.path != None: mini.set('path', str(urllib.quote(self.path).replace('%3A', ':'))) 334 if self.path != None: xml_str += " path='" + urllib.quote(self.path).replace('%3A', ':') + "'"
336 mini.set('locked', '1') if self.locked else mini.set('locked', '0') 335 if self.locked: xml_str += " locked='1'"
337 mini.set('hide', '1') if self.hide else mini.set('hide', '0') 336 else: xml_str += " locked='0'"
338 if self.snap_to_align != None: mini.set('align', str(self.snap_to_align)) 337 if self.hide: xml_str += " hide='1'"
339 if self.id != None: mini.set('zorder', str(self.zorder)) 338 else: xml_str += " hide='0'"
340 if self.width != None: mini.set('width', str(self.width)) 339 if self.snap_to_align != None: xml_str += " align='" + str(self.snap_to_align) + "'"
341 if self.height != None: mini.set('height', str(self.height)) 340 if self.id != None: xml_str += " zorder='" + str(self.zorder) + "'"
341 if self.width != None: xml_str += " width='" + str(self.width) + "'"
342 if self.height != None: xml_str += " height='" + str(self.height) + "'"
342 if self.local: 343 if self.local:
343 mini.set('local', str(self.local)) 344 xml_str += ' local="' + str(self.local) + '"'
344 mini.set('localPath', str(urllib.quote(self.localPath).replace('%3A', ':'))) 345 xml_str += ' localPath="' + str(urllib.quote(self.localPath).replace('%3A', ':')) + '"'
345 mini.set('localTime', str(localTime)) 346 xml_str += ' localTime="' + str(self.localTime) + '"'
347 xml_str += " />"
346 if (action == "update" and self.isUpdated) or action == "new": 348 if (action == "update" and self.isUpdated) or action == "new":
347 self.isUpdated = False 349 self.isUpdated = False
348 return mini 350 print xml_str; return xml_str
349 else: return '' 351 else: return ''
350 352
351 def takedom(self, xml_dom): 353 def takedom(self, xml_dom):
352 self.id = xml_dom.get("id") 354 self.id = xml_dom.getAttribute("id")
353 if xml_dom.get("posx"): self.pos.x = int(xml_dom.get("posx")) 355 if xml_dom.hasAttribute("posx"):
354 if xml_dom.get("posy"): self.pos.y = int(xml_dom.get("posy")) 356 self.pos.x = int(xml_dom.getAttribute("posx"))
355 if xml_dom.get("heading"): self.heading = int(xml_dom.get("heading")) 357 if xml_dom.hasAttribute("posy"):
356 if xml_dom.get("face"): self.face = int(xml_dom.get("face")) 358 self.pos.y = int(xml_dom.getAttribute("posy"))
357 if xml_dom.get("path"): 359 if xml_dom.hasAttribute("heading"):
358 self.path = urllib.unquote(xml_dom.get("path")) 360 self.heading = int(xml_dom.getAttribute("heading"))
361 if xml_dom.hasAttribute("face"):
362 self.face = int(xml_dom.getAttribute("face"))
363 if xml_dom.hasAttribute("path"):
364 self.path = urllib.unquote(xml_dom.getAttribute("path"))
359 self.set_bmp(ImageHandler.load(self.path, 'miniature', self.id)) 365 self.set_bmp(ImageHandler.load(self.path, 'miniature', self.id))
360 if xml_dom.get("locked"): 366 if xml_dom.hasAttribute("locked"):
361 if xml_dom.get("locked") == '1' or xml_dom.get("locked") == 'True': self.locked = True 367 if xml_dom.getAttribute("locked") == '1' or xml_dom.getAttribute("locked") == 'True': self.locked = True
362 else: self.locked = False 368 else: self.locked = False
363 if xml_dom.get("hide"): 369 if xml_dom.hasAttribute("hide"):
364 if xml_dom.get("hide") == '1' or xml_dom.get("hide") == 'True': self.hide = True 370 if xml_dom.getAttribute("hide") == '1' or xml_dom.getAttribute("hide") == 'True': self.hide = True
365 else: self.hide = False 371 else: self.hide = False
366 if xml_dom.get("label"): self.label = xml_dom.get("label") 372 if xml_dom.hasAttribute("label"):
367 if xml_dom.get("zorder"): self.zorder = int(xml_dom.get("zorder")) 373 self.label = xml_dom.getAttribute("label")
368 if xml_dom.get("align"): 374 if xml_dom.hasAttribute("zorder"):
369 if xml_dom.get("align") == '1' or xml_dom.get("align") == 'True': self.snap_to_align = 1 375 self.zorder = int(xml_dom.getAttribute("zorder"))
376 if xml_dom.hasAttribute("align"):
377 if xml_dom.getAttribute("align") == '1' or xml_dom.getAttribute("align") == 'True': self.snap_to_align = 1
370 else: self.snap_to_align = 0 378 else: self.snap_to_align = 0
371 if xml_dom.get("width"): self.width = int(xml_dom.get("width")) 379 if xml_dom.hasAttribute("width"):
372 if xml_dom.get("height"): self.height = int(xml_dom.get("height")) 380 self.width = int(xml_dom.getAttribute("width"))
381 if xml_dom.hasAttribute("height"):
382 self.height = int(xml_dom.getAttribute("height"))
373 383
374 ##----------------------------- 384 ##-----------------------------
375 ## miniature layer 385 ## miniature layer
376 ##----------------------------- 386 ##-----------------------------
377 class miniature_layer(layer_base): 387 class miniature_layer(layer_base):
480 return min_list 490 return min_list
481 else: return None 491 else: return None
482 492
483 def layerToXML(self, action="update"): 493 def layerToXML(self, action="update"):
484 """ format """ 494 """ format """
485 mini_string = "" 495 minis_string = ""
486 if self.miniatures: 496 if self.miniatures:
487 for m in self.miniatures: mini_string = m.toxml(action) 497 for m in self.miniatures: minis_string += m.toxml(action)
488 if mini_string != '': 498 if minis_string != '':
489 s = Element('miniatures') 499 s = "<miniatures"
490 s.set('serial', str(self.serial_number)) 500 s += " serial='" + str(self.serial_number) + "'"
491 s.append(mini_string) 501 s += ">"
492 return tostring(s) 502 s += minis_string
503 s += "</miniatures>"
504 return s
493 else: return "" 505 else: return ""
494 506
495 def layerTakeDOM(self, xml_dom): 507 def layerTakeDOM(self, xml_dom):
496 if xml_dom.get('serial'): 508 if xml_dom.hasAttribute('serial'):
497 self.serial_number = int(xml_dom.get('serial')) 509 self.serial_number = int(xml_dom.getAttribute('serial'))
498 children = xml_dom.getchildren() 510 children = xml_dom._get_childNodes()
499 for c in children: 511 for c in children:
500 action = c.get("action") 512 action = c.getAttribute("action")
501 id = c.get('id') 513 id = c.getAttribute('id')
502 if action == "del": 514 if action == "del":
503 mini = self.get_miniature_by_id(id) 515 mini = self.get_miniature_by_id(id)
504 if mini: 516 if mini:
505 self.miniatures.remove(mini) 517 self.miniatures.remove(mini)
506 del mini 518 del mini
507 elif action == "new": 519 elif action == "new":
508 pos = cmpPoint(int(c.get('posx')),int(c.get('posy'))) 520 pos = cmpPoint(int(c.getAttribute('posx')),int(c.getAttribute('posy')))
509 path = urllib.unquote(c.get('path')) 521 path = urllib.unquote(c.getAttribute('path'))
510 label = c.get('label') 522 label = c.getAttribute('label')
511 height = width = heading = face = snap_to_align = zorder = 0 523 height = width = heading = face = snap_to_align = zorder = 0
512 locked = hide = False 524 locked = hide = False
513 if c.get('height'): height = int(c.get('height')) or 0 525 if c.hasAttribute('height'): height = int(c.getAttribute('height'))
514 if c.get('width'): width = int(c.get('width')) 526 if c.hasAttribute('width'): width = int(c.getAttribute('width'))
515 if c.get('locked') == 'True' or c.get('locked') == '1': locked = True 527 if c.getAttribute('locked') == 'True' or c.getAttribute('locked') == '1': locked = True
516 if c.get('hide') == 'True' or c.get('hide') == '1': hide = True 528 if c.getAttribute('hide') == 'True' or c.getAttribute('hide') == '1': hide = True
517 if c.get('heading'): heading = int(c.get('heading')) 529 if c.getAttribute('heading'): heading = int(c.getAttribute('heading'))
518 if c.get('face'): face = int(c.get('face')) 530 if c.hasAttribute('face'): face = int(c.getAttribute('face'))
519 if c.get('align'): snap_to_align = int(c.get('align')) 531 if c.hasAttribute('align'): snap_to_align = int(c.getAttribute('align'))
520 if c.get('zorder'): zorder = int(c.get('zorder')) 532 if c.getAttribute('zorder'): zorder = int(c.getAttribute('zorder'))
521 image = ImageHandler.load(path, 'miniature', id) 533 min = BmpMiniature(id, path, ImageHandler.load(path, 'miniature', id), pos, heading,
522 mini = BmpMiniature(id, path, image, pos, heading, face, label, locked, hide, snap_to_align, zorder, width, height, func='minis') 534 face, label, locked, hide, snap_to_align, zorder, width, height)
523 self.miniatures.append(mini) 535 self.miniatures.append(min)
524 if c.get('local') and c.get('local') == 'True' and os.path.exists(urllib.unquote(c.get('localPath'))): 536 if c.hasAttribute('local') and c.getAttribute('local') == 'True' and os.path.exists(urllib.unquote(c.getAttribute('localPath'))):
525 localPath = urllib.unquote(c.get('localPath')) 537 localPath = urllib.unquote(c.getAttribute('localPath'))
526 local = True 538 local = True
527 localTime = float(c.get('localTime')) 539 localTime = float(c.getAttribute('localTime'))
528 if localTime-time.time() <= 144000: 540 if localTime-time.time() <= 144000:
529 file = open(localPath, "rb") 541 file = open(localPath, "rb")
530 imgdata = file.read() 542 imgdata = file.read()
531 file.close() 543 file.close()
532 filename = os.path.split(localPath) 544 filename = os.path.split(localPath)
533 (imgtype,j) = mimetypes.guess_type(filename[1]) 545 (imgtype,j) = mimetypes.guess_type(filename[1])
534 postdata = urllib.urlencode({'filename':filename[1], 'imgdata':imgdata, 'imgtype':imgtype}) 546 postdata = urllib.urlencode({'filename':filename[1], 'imgdata':imgdata, 'imgtype':imgtype})
535 thread.start_new_thread(self.upload, (postdata, localPath, True)) 547 thread.start_new_thread(self.upload, (postdata, localPath, True))
536 # collapse the zorder. If the client behaved well, then nothing should change. 548 # collapse the zorder. If the client behaved well, then nothing should change.
537 # Otherwise, this will ensure that there's some kind of z-order 549 # Otherwise, this will ensure that there's some kind of z-order
538 self.collapse_zorder() 550 self.collapse_zorder()
539 else: 551 else:
540 mini = self.get_miniature_by_id(id) 552 mini = self.get_miniature_by_id(id)
541 if mini: mini.takedom(c) 553 if mini: mini.takedom(c)
542 554