comparison orpg/mapper/map.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 2f2bebe9c77f
children 54446a995007
comparison
equal deleted inserted replaced
117:0f18d16f3fe7 118:217fb049bd00
60 def __init__(self, parent, ID, isEditor=0): 60 def __init__(self, parent, ID, isEditor=0):
61 self.parent = parent 61 self.parent = parent
62 self.session = component.get("session") 62 self.session = component.get("session")
63 wx.ScrolledWindow.__init__(self, parent, ID, 63 wx.ScrolledWindow.__init__(self, parent, ID,
64 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 )
65 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
65 self.frame = parent 66 self.frame = parent
66 self.MAP_MODE = 1 #Mode 1 = MINI, 2 = DRAW, 3 = TAPE MEASURE 67 self.MAP_MODE = 1 #Mode 1 = MINI, 2 = DRAW, 3 = TAPE MEASURE
67 self.layers = {} 68 self.layers = {}
68 self.layers['bg'] = layer_back_ground(self) 69 self.layers['bg'] = layer_back_ground(self)
69 self.layers['grid'] = grid_layer(self) 70 self.layers['grid'] = grid_layer(self)
123 def pre_destory_cleanup(self): 124 def pre_destory_cleanup(self):
124 self.layers["miniatures"].del_all_miniatures() 125 self.layers["miniatures"].del_all_miniatures()
125 126
126 def processImages(self, evt=None): 127 def processImages(self, evt=None):
127 self.session = component.get("session") 128 self.session = component.get("session")
129 tabs = ['Background', 'Grid', 'Miniatures', 'Whiteboard', 'Fog', 'General']
128 if self.session.my_role() == self.session.ROLE_LURKER or (str(self.session.group_id) == '0' and str(self.session.status) == '1'): 130 if self.session.my_role() == self.session.ROLE_LURKER or (str(self.session.group_id) == '0' and str(self.session.status) == '1'):
129 cidx = self.parent.get_tab_index("Background") 131 for tab in tabs:
130 self.parent.tabs.EnableTab(cidx, False) 132 cidx = self.parent.get_tab_index(tab)
131 cidx = self.parent.get_tab_index("Grid") 133 self.parent.tabs.EnableTab(cidx, False)
132 self.parent.tabs.EnableTab(cidx, False) 134 elif self.session.my_role() == self.session.ROLE_PLAYER:
133 cidx = self.parent.get_tab_index("Miniatures") 135 for tab in tabs:
134 self.parent.tabs.EnableTab(cidx, False) 136 cidx = self.parent.get_tab_index(tab)
135 cidx = self.parent.get_tab_index("Whiteboard") 137 if tab == "Miniatures" or tab == "Whiteboard":
136 self.parent.tabs.EnableTab(cidx, False) 138 self.parent.tabs.EnableTab(cidx, True)
137 cidx = self.parent.get_tab_index("Fog") 139 else: self.parent.tabs.EnableTab(cidx, False)
138 self.parent.tabs.EnableTab(cidx, False) 140 elif self.session.my_role() == self.session.ROLE_GM and str(self.session.group_id) != '0':
139 cidx = self.parent.get_tab_index("General") 141 for tab in tabs:
140 self.parent.tabs.EnableTab(cidx, False) 142 cidx = self.parent.get_tab_index(tab)
141 else:
142 cidx = self.parent.get_tab_index("Background")
143 if not self.parent.tabs.GetEnabled(cidx):
144 cidx = self.parent.get_tab_index("Miniatures")
145 self.parent.tabs.EnableTab(cidx, True) 143 self.parent.tabs.EnableTab(cidx, True)
146 cidx = self.parent.get_tab_index("Whiteboard")
147 self.parent.tabs.EnableTab(cidx, True)
148 cidx = self.parent.get_tab_index("Background")
149 self.parent.tabs.EnableTab(cidx, False)
150 cidx = self.parent.get_tab_index("Grid")
151 self.parent.tabs.EnableTab(cidx, False)
152 cidx = self.parent.get_tab_index("Fog")
153 self.parent.tabs.EnableTab(cidx, False)
154 cidx = self.parent.get_tab_index("General")
155 self.parent.tabs.EnableTab(cidx, False)
156 if self.session.my_role() == self.session.ROLE_GM:
157 cidx = self.parent.get_tab_index("Background")
158 self.parent.tabs.EnableTab(cidx, True)
159 cidx = self.parent.get_tab_index("Grid")
160 self.parent.tabs.EnableTab(cidx, True)
161 cidx = self.parent.get_tab_index("Fog")
162 self.parent.tabs.EnableTab(cidx, True)
163 cidx = self.parent.get_tab_index("General")
164 self.parent.tabs.EnableTab(cidx, True)
165 if not self.cacheSizeSet: 144 if not self.cacheSizeSet:
166 self.cacheSizeSet = True 145 self.cacheSizeSet = True
167 cacheSize = component.get('settings').get_setting("ImageCacheSize") 146 cacheSize = component.get('settings').get_setting("ImageCacheSize")
168 if len(cacheSize): self.cacheSize = int(cacheSize) 147 if len(cacheSize): self.cacheSize = int(cacheSize)
169 else: pass 148 else: pass
170 if not ImageHandler.Queue.empty(): 149 if not ImageHandler.Queue.empty():
171 (path, image_type, imageId) = ImageHandler.Queue.get() 150 (path, image_type, imageId) = ImageHandler.Queue.get()
172 img = wx.ImageFromMime(path[1], path[2]).ConvertToBitmap() 151 img = wx.ImageFromMime(path[1], path[2])
173 try: 152 # Now, apply the image to the proper object
174 # Now, apply the image to the proper object 153 if image_type == "miniature":
175 if image_type == "miniature": 154 min = self.layers['miniatures'].get_miniature_by_id(imageId)
176 min = self.layers['miniatures'].get_miniature_by_id(imageId) 155 if min: min.set_bmp(img)
177 min.set_bmp(img) 156 elif image_type == "background" or image_type == "texture":
178 elif image_type == "background" or image_type == "texture": 157 self.layers['bg'].bg_bmp = img.ConvertToBitmap()
179 self.layers['bg'].bg_bmp = img 158 if image_type == "background": self.set_size([img.GetWidth(), img.GetHeight()])
180 if image_type == "background": self.set_size([img.GetWidth(), img.GetHeight()])
181 except: pass
182 # Flag that we now need to refresh! 159 # Flag that we now need to refresh!
183 self.requireRefresh += 1 160 self.requireRefresh += 1
184 """ Randomly purge an item from the cache, while this is lamo, it does 161 """ Randomly purge an item from the cache, while this is lamo, it does
185 keep the cache from growing without bounds, which is pretty important!""" 162 keep the cache from growing without bounds, which is pretty important!"""
186 if len(ImageHandler.Cache) >= self.cacheSize: 163 if len(ImageHandler.Cache) >= self.cacheSize:
197 self.lastRefreshTime = time.time() 174 self.lastRefreshTime = time.time()
198 self.Refresh(True) 175 self.Refresh(True)
199 else: self.lastRefreshValue = self.requireRefresh 176 else: self.lastRefreshValue = self.requireRefresh
200 177
201 def on_scroll(self, evt): 178 def on_scroll(self, evt):
202 print 'scrolling'
203 if self.drag: self.drag.Hide() 179 if self.drag: self.drag.Hide()
204 if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale() 180 if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale()
205 evt.Skip() 181 evt.Skip()
206 182
207 def on_char(self, evt): 183 def on_char(self, evt):
260 scrollsize = self.GetScrollPixelsPerUnit() 236 scrollsize = self.GetScrollPixelsPerUnit()
261 clientsize = self.GetClientSize() 237 clientsize = self.GetClientSize()
262 topleft1 = self.GetViewStart() 238 topleft1 = self.GetViewStart()
263 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]] 239 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]]
264 if (clientsize[0] > 1) and (clientsize[1] > 1): 240 if (clientsize[0] > 1) and (clientsize[1] > 1):
265 dc = wx.MemoryDC() 241 #dc = wx.MemoryDC()
266 bmp = wx.EmptyBitmap(clientsize[0]+1, clientsize[1]+1) 242 #bmp = wx.EmptyBitmap(clientsize[0]+1, clientsize[1]+1)
267 dc.SelectObject(bmp) 243 #dc.SelectObject(bmp)
244 dc = wx.AutoBufferedPaintDC(self)
268 dc.SetPen(wx.TRANSPARENT_PEN) 245 dc.SetPen(wx.TRANSPARENT_PEN)
269 dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID)) 246 dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
270 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1) 247 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1)
271 dc.SetDeviceOrigin(-topleft[0], -topleft[1]) 248 dc.SetDeviceOrigin(-topleft[0], -topleft[1])
272 dc.SetUserScale(scale, scale) 249 dc.SetUserScale(scale, scale)
277 [clientsize[0]/scale, clientsize[1]/scale]) 254 [clientsize[0]/scale, clientsize[1]/scale])
278 self.layers['whiteboard'].layerDraw(dc) 255 self.layers['whiteboard'].layerDraw(dc)
279 self.layers['fog'].layerDraw(dc, topleft, clientsize) 256 self.layers['fog'].layerDraw(dc, topleft, clientsize)
280 dc.SetPen(wx.NullPen) 257 dc.SetPen(wx.NullPen)
281 dc.SetBrush(wx.NullBrush) 258 dc.SetBrush(wx.NullBrush)
282 dc.SelectObject(wx.NullBitmap) 259 #dc.SelectObject(wx.NullBitmap)
283 del dc 260 #del dc
284 wdc = self.preppaint() 261 #wdc = self.preppaint()
285 wdc.DrawBitmap(bmp, topleft[0], topleft[1]) 262 #wdc.DrawBitmap(bmp, topleft[0], topleft[1])
286 if settings.get_setting("AlwaysShowMapScale") == "1": 263 if settings.get_setting("AlwaysShowMapScale") == "1":
287 self.showmapscale(wdc) 264 self.showmapscale(dc)
288 try: evt.Skip() 265 try: evt.Skip()
289 except: pass 266 except: pass
290 267
291 def preppaint(self): 268 def preppaint(self):
292 dc = wx.PaintDC(self) 269 dc = wx.PaintDC(self)