comparison orpg/mapper/miniatures.py @ 76:37a11fea3304 ornery-dev

More clean up. Images now posts a Chat Info post if image doesn't load.
author sirebral
date Sat, 22 Aug 2009 04:02:14 -0500
parents 449a8900f9ac
children 763a04270cf6
comparison
equal deleted inserted replaced
75:f518bc709fd1 76:37a11fea3304
31 from base import * 31 from base import *
32 import thread 32 import thread
33 import time 33 import time
34 import urllib 34 import urllib
35 import os.path 35 import os.path
36
37 from orpg.tools.orpg_settings import settings
36 38
37 MIN_STICKY_BACK = -0XFFFFFF 39 MIN_STICKY_BACK = -0XFFFFFF
38 MIN_STICKY_FRONT = 0xFFFFFF 40 MIN_STICKY_FRONT = 0xFFFFFF
39 41
40 ##---------------------------------------- 42 ##----------------------------------------
415 ## miniature layer 417 ## miniature layer
416 ##----------------------------- 418 ##-----------------------------
417 class miniature_layer(layer_base): 419 class miniature_layer(layer_base):
418 def __init__(self, canvas): 420 def __init__(self, canvas):
419 self.canvas = canvas 421 self.canvas = canvas
420 self.settings = self.canvas.settings
421 layer_base.__init__(self) 422 layer_base.__init__(self)
422 self.id = -1 #added. 423 self.id = -1 #added.
423 self.miniatures = [] 424 self.miniatures = []
424 self.serial_number = 0 425 self.serial_number = 0
425 426
426 # Set the font of the labels to be the same as the chat window 427 # Set the font of the labels to be the same as the chat window
427 # only smaller. 428 # only smaller.
428 font_size = int(self.settings.get_setting('defaultfontsize')) 429 font_size = int(settings.get_setting('defaultfontsize'))
429 if (font_size >= 10): font_size -= 2 430 if (font_size >= 10): font_size -= 2
430 self.label_font = wx.Font(font_size, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 431 self.label_font = wx.Font(font_size, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL,
431 False, self.settings.get_setting('defaultfont')) 432 False, settings.get_setting('defaultfont'))
432 433
433 def next_serial(self): 434 def next_serial(self):
434 self.serial_number += 1 435 self.serial_number += 1
435 return self.serial_number 436 return self.serial_number
436 437
581 mini = self.get_miniature_by_id(id) 582 mini = self.get_miniature_by_id(id)
582 if mini: mini.takedom(c) 583 if mini: mini.takedom(c)
583 584
584 def upload(self, postdata, filename, modify=False, pos=cmpPoint(0,0)): 585 def upload(self, postdata, filename, modify=False, pos=cmpPoint(0,0)):
585 self.lock.acquire() 586 self.lock.acquire()
586 url = self.settings.get_setting('ImageServerBaseURL') 587 url = settings.get_setting('ImageServerBaseURL')
587 file = urllib.urlopen(url, postdata) 588 file = urllib.urlopen(url, postdata)
588 recvdata = file.read() 589 recvdata = file.read()
589 file.close() 590 file.close()
590 try: 591 try:
591 xml_dom = minidom.parseString(recvdata)._get_documentElement() 592 xml_dom = minidom.parseString(recvdata)._get_documentElement()