comparison orpg/mapper/map.py @ 19:78407d627cba traipse_dev

Beginning of Code Clean-up. Some code untested, may break!
author sirebral
date Sat, 25 Jul 2009 17:24:40 -0500
parents 0b8b7e3ed78d
children 072ffc1d466f
comparison
equal deleted inserted replaced
18:67b900deb35c 19:78407d627cba
57 self.parent = parent 57 self.parent = parent
58 self.log = open_rpg.get_component("log") 58 self.log = open_rpg.get_component("log")
59 self.log.log("Enter MapCanvas", ORPG_DEBUG) 59 self.log.log("Enter MapCanvas", ORPG_DEBUG)
60 self.settings = open_rpg.get_component("settings") 60 self.settings = open_rpg.get_component("settings")
61 self.session = open_rpg.get_component("session") 61 self.session = open_rpg.get_component("session")
62 wx.ScrolledWindow.__init__(self, parent, ID, style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER ) 62 wx.ScrolledWindow.__init__(self, parent, ID,
63 style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER )
63 self.frame = parent 64 self.frame = parent
64 self.MAP_MODE = 1 #Mode 1 = MINI, 2 = DRAW, 3 = TAPE MEASURE 65 self.MAP_MODE = 1 #Mode 1 = MINI, 2 = DRAW, 3 = TAPE MEASURE
65 self.layers = {} 66 self.layers = {}
66 self.layers['bg'] = layer_back_ground(self) 67 self.layers['bg'] = layer_back_ground(self)
67 self.layers['grid'] = grid_layer(self) 68 self.layers['grid'] = grid_layer(self)
162 cacheSize = self.settings.get_setting("ImageCacheSize") 163 cacheSize = self.settings.get_setting("ImageCacheSize")
163 if len(cacheSize): 164 if len(cacheSize):
164 self.cacheSize = int(cacheSize) 165 self.cacheSize = int(cacheSize)
165 else: 166 else:
166 self.log.log("Default cache size being used.", ORPG_GENERAL) 167 self.log.log("Default cache size being used.", ORPG_GENERAL)
167 self.log.log("Current image cache size is set at " + str(self.cacheSize) + " images, using random purge.", ORPG_GENERAL) 168 self.log.log("Current image cache size is set at " + str(self.cacheSize) + " images, using random purge.",
169 ORPG_GENERAL)
168 if not ImageHandler.Queue.empty(): 170 if not ImageHandler.Queue.empty():
169 (path, image_type, imageId) = ImageHandler.Queue.get() 171 (path, image_type, imageId) = ImageHandler.Queue.get()
170 img = wx.ImageFromMime(path[1], path[2]).ConvertToBitmap() 172 img = wx.ImageFromMime(path[1], path[2]).ConvertToBitmap()
171 try: 173 try:
172 # Now, apply the image to the proper object 174 # Now, apply the image to the proper object
298 dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID)) 300 dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
299 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1) 301 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1)
300 dc.SetDeviceOrigin(-topleft[0], -topleft[1]) 302 dc.SetDeviceOrigin(-topleft[0], -topleft[1])
301 dc.SetUserScale(scale, scale) 303 dc.SetUserScale(scale, scale)
302 self.layers['bg'].layerDraw(dc, scale, topleft, clientsize) 304 self.layers['bg'].layerDraw(dc, scale, topleft, clientsize)
303 self.layers['grid'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale], [clientsize[0]/scale, clientsize[1]/scale]) 305 self.layers['grid'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
304 self.layers['miniatures'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale], [clientsize[0]/scale, clientsize[1]/scale]) 306 [clientsize[0]/scale, clientsize[1]/scale])
307 self.layers['miniatures'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
308 [clientsize[0]/scale, clientsize[1]/scale])
305 self.layers['whiteboard'].layerDraw(dc) 309 self.layers['whiteboard'].layerDraw(dc)
306 self.layers['fog'].layerDraw(dc, topleft, clientsize) 310 self.layers['fog'].layerDraw(dc, topleft, clientsize)
307 dc.SetPen(wx.NullPen) 311 dc.SetPen(wx.NullPen)
308 dc.SetBrush(wx.NullBrush) 312 dc.SetBrush(wx.NullBrush)
309 dc.SelectObject(wx.NullBitmap) 313 dc.SelectObject(wx.NullBitmap)
900 904
901 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.on_layer_change) 905 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.on_layer_change)
902 #self.Bind(wx.EVT_SIZE, self.on_size) 906 #self.Bind(wx.EVT_SIZE, self.on_size)
903 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) 907 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
904 self.load_default() 908 self.load_default()
905
906 """
907 # size of tabs is diffrent on windows and linux :(
908 if wx.Platform == '__WXMSW__':
909 self.toolbar_height = 50
910 else:
911 self.toolbar_height = 55
912 """
913
914 self.log.log("Exit map_wnd", ORPG_DEBUG) 909 self.log.log("Exit map_wnd", ORPG_DEBUG)
915 910
916 def OnLeave(self, evt): 911 def OnLeave(self, evt):
917 if "__WXGTK__" in wx.PlatformInfo: 912 if "__WXGTK__" in wx.PlatformInfo:
918 wx.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) 913 wx.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
1130 def get_hot_keys(self): 1125 def get_hot_keys(self):
1131 self.log.log("Enter map_wnd->get_hot_keys(self)", ORPG_DEBUG) 1126 self.log.log("Enter map_wnd->get_hot_keys(self)", ORPG_DEBUG)
1132 self.build_menu() 1127 self.build_menu()
1133 self.log.log("Exit map_wnd->get_hot_keys(self)", ORPG_DEBUG) 1128 self.log.log("Exit map_wnd->get_hot_keys(self)", ORPG_DEBUG)
1134 return [] 1129 return []
1135
1136 """
1137 def on_size(self, evt):
1138 self.log.log("Enter map_wnd->on_size(self, evt)", ORPG_DEBUG)
1139 s = self.GetClientSizeTuple()
1140 self.canvas.SetDimensions(0,0,s[0],s[1]-self.toolbar_height)
1141 self.layer_tabs.SetDimensions(0,s[1]-self.toolbar_height,s[0],self.toolbar_height)
1142 self.log.log("Exit map_wnd->on_size(self, evt)", ORPG_DEBUG)
1143 """