comparison orpg/mapper/map.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 2f2bebe9c77f dcf4fbe09b70
comparison
equal deleted inserted replaced
75:f518bc709fd1 76:37a11fea3304
33 from map_prop_dialog import * 33 from map_prop_dialog import *
34 34
35 import random 35 import random
36 import os 36 import os
37 import thread 37 import thread
38 import gc 38 #import gc #Garbage Collecter Needed?
39 import traceback 39 import traceback
40 40
41 from miniatures_handler import * 41 from miniatures_handler import *
42 from whiteboard_handler import * 42 from whiteboard_handler import *
43 from background_handler import * 43 from background_handler import *
46 from fog_handler import * 46 from fog_handler import *
47 47
48 from orpg.dirpath import dir_struct 48 from orpg.dirpath import dir_struct
49 from images import ImageHandler 49 from images import ImageHandler
50 from orpg.orpgCore import component 50 from orpg.orpgCore import component
51 from orpg.tools.orpg_settings import settings
51 52
52 # Various marker modes for player tools on the map 53 # Various marker modes for player tools on the map
53 MARKER_MODE_NONE = 0 54 MARKER_MODE_NONE = 0
54 MARKER_MODE_MEASURE = 1 55 MARKER_MODE_MEASURE = 1
55 MARKER_MODE_TARGET = 2 56 MARKER_MODE_TARGET = 2
56 MARKER_MODE_AREA_TARGET = 3 57 MARKER_MODE_AREA_TARGET = 3
57 58
58 class MapCanvas(wx.ScrolledWindow): 59 class MapCanvas(wx.ScrolledWindow):
59 def __init__(self, parent, ID, isEditor=0): 60 def __init__(self, parent, ID, isEditor=0):
60 self.parent = parent 61 self.parent = parent
61 self.log = component.get('log')
62 self.settings = component.get("settings")
63 self.session = component.get("session") 62 self.session = component.get("session")
64 wx.ScrolledWindow.__init__(self, parent, ID, 63 wx.ScrolledWindow.__init__(self, parent, ID,
65 style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER ) 64 style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER )
66 self.frame = parent 65 self.frame = parent
67 self.MAP_MODE = 1 #Mode 1 = MINI, 2 = DRAW, 3 = TAPE MEASURE 66 self.MAP_MODE = 1 #Mode 1 = MINI, 2 = DRAW, 3 = TAPE MEASURE
154 self.parent.layer_tabs.EnableTab(cidx, True) 153 self.parent.layer_tabs.EnableTab(cidx, True)
155 cidx = self.parent.get_tab_index("General") 154 cidx = self.parent.get_tab_index("General")
156 self.parent.layer_tabs.EnableTab(cidx, True) 155 self.parent.layer_tabs.EnableTab(cidx, True)
157 if not self.cacheSizeSet: 156 if not self.cacheSizeSet:
158 self.cacheSizeSet = True 157 self.cacheSizeSet = True
159 cacheSize = self.settings.get_setting("ImageCacheSize") 158 cacheSize = component.get('settings').get_setting("ImageCacheSize")
160 if len(cacheSize): self.cacheSize = int(cacheSize) 159 if len(cacheSize): self.cacheSize = int(cacheSize)
161 else: pass 160 else: pass
162 if not ImageHandler.Queue.empty(): 161 if not ImageHandler.Queue.empty():
163 (path, image_type, imageId) = ImageHandler.Queue.get() 162 (path, image_type, imageId) = ImageHandler.Queue.get()
164 img = wx.ImageFromMime(path[1], path[2]).ConvertToBitmap() 163 img = wx.ImageFromMime(path[1], path[2]).ConvertToBitmap()
191 self.Refresh(True) 190 self.Refresh(True)
192 else: self.lastRefreshValue = self.requireRefresh 191 else: self.lastRefreshValue = self.requireRefresh
193 192
194 def on_scroll(self, evt): 193 def on_scroll(self, evt):
195 if self.drag: self.drag.Hide() 194 if self.drag: self.drag.Hide()
196 if self.settings.get_setting("AlwaysShowMapScale") == "1": self.printscale() 195 if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale()
197 evt.Skip() 196 evt.Skip()
198 197
199 def on_char(self, evt): 198 def on_char(self, evt):
200 if self.settings.get_setting("AlwaysShowMapScale") == "1": self.printscale() 199 if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale()
201 evt.Skip() 200 evt.Skip()
202 201
203 def printscale(self): 202 def printscale(self):
204 wx.BeginBusyCursor() 203 wx.BeginBusyCursor()
205 dc = wx.ClientDC(self) 204 dc = wx.ClientDC(self)
273 dc.SetBrush(wx.NullBrush) 272 dc.SetBrush(wx.NullBrush)
274 dc.SelectObject(wx.NullBitmap) 273 dc.SelectObject(wx.NullBitmap)
275 del dc 274 del dc
276 wdc = self.preppaint() 275 wdc = self.preppaint()
277 wdc.DrawBitmap(bmp, topleft[0], topleft[1]) 276 wdc.DrawBitmap(bmp, topleft[0], topleft[1])
278 if self.frame.settings.get_setting("AlwaysShowMapScale") == "1": 277 if settings.get_setting("AlwaysShowMapScale") == "1":
279 self.showmapscale(wdc) 278 self.showmapscale(wdc)
280 try: evt.Skip() 279 try: evt.Skip()
281 except: pass 280 except: pass
282 281
283 def preppaint(self): 282 def preppaint(self):
713 if xml_dom: xml_dom.unlink() 712 if xml_dom: xml_dom.unlink()
714 return str(new_xml) 713 return str(new_xml)
715 714
716 class map_wnd(wx.Panel): 715 class map_wnd(wx.Panel):
717 def __init__(self, parent, id): 716 def __init__(self, parent, id):
718 self.log = component.get('log')
719 wx.Panel.__init__(self, parent, id) 717 wx.Panel.__init__(self, parent, id)
720 self.canvas = MapCanvas(self, -1) 718 self.canvas = MapCanvas(self, -1)
721 self.session = component.get('session') 719 self.session = component.get('session')
722 self.settings = component.get('settings')
723 self.chat = component.get('chat') 720 self.chat = component.get('chat')
724 self.top_frame = component.get('frame') 721 self.top_frame = component.get('frame')
725 self.root_dir = os.getcwd() 722 self.root_dir = os.getcwd()
726 self.current_layer = 2 723 self.current_layer = 2
727 self.layer_tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS) 724 self.layer_tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS)