comparison orpg/mapper/images.py @ 118:217fb049bd00 alpha

Traipse Alpha 'OpenRPG' {091028-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: Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images! Changes made to the map for increased portability. SnowDog has changes planned in Core, though. Added an initial push to the BCG. Not much to see, just shows off how it is re-writing Main code. Fix to remote admin commands Minor fix to texted based server, works in /System/ folder Some Core changes to gametree to correctly disply Pretty Print, thanks David! Fix to Splitter Nodes not being created. Added images to Plugin Control panel for Autostart feature Fix to massive amounts of images loading; from Core fix to gsclient so with_statement imports Added 'boot' command to remote admin Prep work in Pass tool for remote admin rankings and different passwords, ei, Server, Admin, Moderator, etc. Remote Admin Commands more organized, more prep work. Added Confirmation window for sent nodes. Minor changes to allow for portability to an OpenSUSE linux OS (hopefully without breaking) {091028} 00: Made changes to gametree to start working with Element Tree, mostly from Core Minor changes to Map to start working with Element Tree, from Core Preliminary changes to map efficiency, from FlexiRPG Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Changes to main.py to start working with Element Tree
author sirebral
date Wed, 28 Oct 2009 14:24:54 -0500
parents 61fc775862f7
children 37d26a98883f
comparison
equal deleted inserted replaced
117:0f18d16f3fe7 118:217fb049bd00
54 54
55 def load(self, path, image_type, imageId): 55 def load(self, path, image_type, imageId):
56 # Load an image, with a intermideary fetching image shown while it loads in a background thread 56 # Load an image, with a intermideary fetching image shown while it loads in a background thread
57 if self.__cache.has_key(path): 57 if self.__cache.has_key(path):
58 return wx.ImageFromMime(self.__cache[path][1], 58 return wx.ImageFromMime(self.__cache[path][1],
59 self.__cache[path][2]).ConvertToBitmap() 59 self.__cache[path][2])
60 if path not in self.__fetching: 60 if path not in self.__fetching:
61 self.__fetching[path] = True 61 self.__fetching[path] = True
62 #Start Image Loading Thread 62 #Start Image Loading Thread
63 thread.start_new_thread(self.__loadThread, 63 thread.start_new_thread(self.__loadThread,
64 (path, image_type, imageId)) 64 (path, image_type, imageId))
65 else: 65 else:
66 if self.__fetching[path]: 66 if self.__fetching[path]:
67 thread.start_new_thread(self.__loadCacheThread, 67 thread.start_new_thread(self.__loadCacheThread,
68 (path, image_type, imageId)) 68 (path, image_type, imageId))
69 return wx.Bitmap(dir_struct["icon"] + "fetching.png", 69 return wx.Bitmap(dir_struct["icon"] + "fetching.png", wx.BITMAP_TYPE_PNG)
70 wx.BITMAP_TYPE_PNG)
71 70
72 def directLoad(self, path): 71 def directLoad(self, path):
73 # Directly load an image, no threads 72 # Directly load an image, no threads
74 if path in self.__cache: 73 if path in self.__cache:
75 return wx.ImageFromMime(self.__cache[path][1], 74 return wx.ImageFromMime(self.__cache[path][1],
76 self.__cache[path][2]).ConvertToBitmap() 75 self.__cache[path][2])
77
78 uriPath = urllib.unquote(path) 76 uriPath = urllib.unquote(path)
79 try: 77 try:
80 d = urllib.urlretrieve(uriPath) 78 d = urllib.urlretrieve(uriPath)
81 # We have to make sure that not only did we fetch something, but that 79 # We have to make sure that not only did we fetch something, but that
82 # it was an image that we got back. 80 # it was an image that we got back.
83 if d[0] and d[1].getmaintype() == "image": 81 if d[0] and d[1].getmaintype() == "image":
84 with self.__lock: 82 with self.__lock:
85 self.__cache[path] = (path, d[0], d[1].gettype(), None) 83 self.__cache[path] = (path, d[0], d[1].gettype(), None)
86 return wx.ImageFromMime(self.__cache[path][1], 84 return wx.ImageFromMime(self.__cache[path][1], self.__cache[path][2])
87 self.__cache[path][2]).ConvertToBitmap()
88 else: 85 else:
89 logger.general("Image refused to load or URI did not " 86 logger.general("Image refused to load or URI did not "
90 "reference a valid image: " + path, True) 87 "reference a valid image: " + path, True)
91 return None 88 return None
92 except IOError: 89 except IOError:
113 urllib.urlcleanup() 110 urllib.urlcleanup()
114 111
115 #Private Methods 112 #Private Methods
116 def __loadThread(self, path, image_type, imageId): 113 def __loadThread(self, path, image_type, imageId):
117 uriPath = urllib.unquote(path) 114 uriPath = urllib.unquote(path)
118
119 try: 115 try:
120 d = urllib.urlretrieve(uriPath) 116 d = urllib.urlretrieve(uriPath)
121 # We have to make sure that not only did we fetch something, but that 117 # We have to make sure that not only did we fetch something, but that
122 # it was an image that we got back. 118 # it was an image that we got back.
123 if d[0] and d[1].getmaintype() == "image": 119 if d[0] and d[1].getmaintype() == "image":
124 with self.__lock: 120 with self.__lock:
125 self.__cache[path] = (path, d[0], d[1].gettype(), imageId) 121 self.__cache[path] = (path, d[0], d[1].gettype(), imageId)
126 self.__queue.put((self.__cache[path], image_type, imageId)) 122 self.__queue.put((self.__cache[path], image_type, imageId))
127 123 if path in self.__fetching: del self.__fetching[path]
128 if path in self.__fetching:
129 del self.__fetching[path]
130 else: 124 else:
131 logger.general("Image refused to load or URI did not " 125 logger.general("Image refused to load or URI did not "
132 "reference a valid image: " + path, True) 126 "reference a valid image: " + path, True)
133 del self.__fetching[path] 127 del self.__fetching[path]
134 except IOError: 128 except IOError:
148 except: 142 except:
149 del self.__fetching[path] 143 del self.__fetching[path]
150 logger.general("Unable to resolve/open the specified URI; " 144 logger.general("Unable to resolve/open the specified URI; "
151 "image was NOT loaded: " + path, True) 145 "image was NOT loaded: " + path, True)
152 return 146 return
153
154 with self.__lock: 147 with self.__lock:
155 if path in self.__cache: 148 if path in self.__cache:
156 logger.debug("Adding Image to Queue from Cache: " + str(self.__cache[path])) 149 logger.debug("Adding Image to Queue from Cache: " + str(self.__cache[path]))
157 self.__queue.put((self.__cache[path], image_type, imageId)) 150 self.__queue.put((self.__cache[path], image_type, imageId))
158 else: 151 else: self.__loadThread(path, image_type, imageId)
159 self.__loadThread(path, image_type, imageId)
160 152
161 #Property Methods 153 #Property Methods
162 def _getCache(self): 154 def _getCache(self):
163 return self.__cache 155 return self.__cache
164 156