Mercurial > traipse
comparison orpg/mapper/images.py @ 2:d5e81dac98ff grumpy-goblin
Made some changes to the way the player list colors. Also fixed an annoyence with images
and the Message box that no longer shows.
author | sirebral |
---|---|
date | Tue, 14 Jul 2009 20:52:56 -0500 |
parents | 4385a7d0efd1 |
children | 28ad6bd3ac71 |
comparison
equal
deleted
inserted
replaced
1:f24c6e431a15 | 2:d5e81dac98ff |
---|---|
73 # it was an image that we got back. | 73 # it was an image that we got back. |
74 if d[0] and d[1].getmaintype() == "image": | 74 if d[0] and d[1].getmaintype() == "image": |
75 self.__cache[path] = (path, d[0], d[1].gettype(), None) | 75 self.__cache[path] = (path, d[0], d[1].gettype(), None) |
76 return wx.ImageFromMime(self.__cache[path][1], self.__cache[path][2]).ConvertToBitmap() | 76 return wx.ImageFromMime(self.__cache[path][1], self.__cache[path][2]).ConvertToBitmap() |
77 else: | 77 else: |
78 open_rpg.get_component('log').log("Image refused to load or URI did not reference a valid image: " + path, ORPG_GENERAL, True) | 78 self.bad_url(path) |
79 return None | 79 return None |
80 except IOError: | 80 except IOError: |
81 open_rpg.get_component('log').log("Unable to resolve/open the specified URI; image was NOT loaded: " + path, ORPG_GENERAL, True) | 81 self.bad_url(path) |
82 return None | 82 return None |
83 | 83 |
84 def cleanCache(self): | 84 def cleanCache(self): |
85 # Shrinks the Cache down to the proper size | 85 # Shrinks the Cache down to the proper size |
86 try: | 86 try: |
115 self.__cache[path] = (path, d[0], d[1].gettype(), imageId) | 115 self.__cache[path] = (path, d[0], d[1].gettype(), imageId) |
116 self.__queue.put((self.__cache[path], image_type, imageId)) | 116 self.__queue.put((self.__cache[path], image_type, imageId)) |
117 if self.__fetching.has_key(path): | 117 if self.__fetching.has_key(path): |
118 del self.__fetching[path] | 118 del self.__fetching[path] |
119 else: | 119 else: |
120 open_rpg.get_component('log').log("Image refused to load or URI did not reference a valid image: " + path, ORPG_GENERAL, True) | |
121 self.__fetching[path] = False | 120 self.__fetching[path] = False |
121 self.bad_url(path) | |
122 except IOError: | 122 except IOError: |
123 self.__fetching[path] = False | 123 self.__fetching[path] = False |
124 open_rpg.get_component('log').log("Unable to resolve/open the specified URI; image was NOT laoded: " + path, ORPG_GENERAL, True) | 124 self.bad_url(path) |
125 finally: | 125 finally: |
126 self.__lock.release() | 126 self.__lock.release() |
127 | 127 |
128 def __loadCacheThread(self, path, image_type, imageId): | 128 def __loadCacheThread(self, path, image_type, imageId): |
129 try: | 129 try: |
133 if (time.time()-st) > 120: | 133 if (time.time()-st) > 120: |
134 open_rpg.get_component('log').log("Timeout: " + path, ORPG_GENERAL, True) | 134 open_rpg.get_component('log').log("Timeout: " + path, ORPG_GENERAL, True) |
135 break | 135 break |
136 except: | 136 except: |
137 self.__fetching[path] = False | 137 self.__fetching[path] = False |
138 open_rpg.get_component('log').log("Unable to resolve/open the specified URI; image was NOT loaded: " + path, ORPG_GENERAL, True) | 138 self.bad_url(path) |
139 return | 139 return |
140 self.__lock.acquire() | 140 self.__lock.acquire() |
141 try: | 141 try: |
142 open_rpg.get_component('log').log("Adding Image to Queue from Cache: " + str(self.__cache[path]), ORPG_DEBUG) | 142 open_rpg.get_component('log').log("Adding Image to Queue from Cache: " + str(self.__cache[path]), ORPG_DEBUG) |
143 self.__queue.put((self.__cache[path], image_type, imageId)) | 143 self.__queue.put((self.__cache[path], image_type, imageId)) |
149 return self.__cache | 149 return self.__cache |
150 | 150 |
151 def _getQueue(self): | 151 def _getQueue(self): |
152 return self.__queue | 152 return self.__queue |
153 | 153 |
154 #Error Messages | |
155 def bad_url(self, path): | |
156 open_rpg.get_component('log').log("Image refused to load or URL did not reference a valid image: " + path, ORPG_GENERAL, True) | |
157 wx.MessageBox("Image refused to load or URL did not reference a valid image: " + path) | |
158 return | |
159 | |
160 | |
154 #Properties | 161 #Properties |
155 Cache = property(_getCache) | 162 Cache = property(_getCache) |
156 Queue = property(_getQueue) | 163 Queue = property(_getQueue) |
157 | 164 |
158 ImageHandler = singleton(ImageHandlerClass) | 165 ImageHandler = singleton(ImageHandlerClass) |