comparison orpg/mapper/map.py @ 28:ff154cf3350c ornery-orc

Traipse 'OpenRPG' {100203-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 (Stable) New Features: New Bookmarks Feature New 'boot' command to remote admin New confirmation window for sent nodes Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG New Zoom Mouse plugin added New Images added to Plugin UI Switching to Element Tree New Map efficiency, from FlexiRPG New Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) New Portable Mercurial New Tip of the Day, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added New Dieroller structure from Core New DieRoller portability for odd Dice New 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added New vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) New Grids act more like Spreadsheets in Use mode, with Auto Calc Fixes: Fix to allow for portability to an OpenSUSE linux OS Fix to mplay_client for Fedora and OpenSUSE Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Fix to whiteboard ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Wed, 03 Feb 2010 22:16:49 -0600
parents 97265586402b
children fc48380f0c9f
comparison
equal deleted inserted replaced
27:51428d30c59e 28:ff154cf3350c
19 # 19 #
20 # File: mapper/map.py 20 # File: mapper/map.py
21 # Author: OpenRPG 21 # Author: OpenRPG
22 # Maintainer: 22 # Maintainer:
23 # Version: 23 # Version:
24 # $Id: map.py,v 1.73 2007/12/07 20:39:49 digitalxero Exp $ 24 # $Id: map.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
25 # 25 #
26 # Description: 26 # Description:
27 # 27 #
28 __version__ = "$Id: map.py,v 1.73 2007/12/07 20:39:49 digitalxero Exp $" 28 __version__ = "$Id: map.py,v Traipse 'Ornery-Orc' prof.ebral Exp $"
29 29
30 from map_version import MAP_VERSION 30 from map_version import MAP_VERSION
31 from map_msg import * 31 from map_msg import *
32 from min_dialogs import * 32 from min_dialogs import *
33 from map_prop_dialog import * 33 from map_prop_dialog import *
34 34
35 import random 35 import random, os, thread, traceback
36 import os
37 import thread
38 #import gc #Garbage Collecter Needed?
39 import traceback
40 36
41 from miniatures_handler import * 37 from miniatures_handler import *
42 from whiteboard_handler import * 38 from whiteboard_handler import *
43 from background_handler import * 39 from background_handler import *
44 from grid_handler import * 40 from grid_handler import *
158 cacheSize = component.get('settings').get_setting("ImageCacheSize") 154 cacheSize = component.get('settings').get_setting("ImageCacheSize")
159 if len(cacheSize): self.cacheSize = int(cacheSize) 155 if len(cacheSize): self.cacheSize = int(cacheSize)
160 else: pass 156 else: pass
161 if not ImageHandler.Queue.empty(): 157 if not ImageHandler.Queue.empty():
162 (path, image_type, imageId) = ImageHandler.Queue.get() 158 (path, image_type, imageId) = ImageHandler.Queue.get()
163 img = wx.ImageFromMime(path[1], path[2]).ConvertToBitmap() 159 if path == 'failed': img = wx.Image(dir_struct["icon"] + "failed.png", wx.BITMAP_TYPE_PNG)
160 else: img = wx.ImageFromMime(path[1], path[2])
164 try: 161 try:
165 # Now, apply the image to the proper object 162 # Now, apply the image to the proper object
166 if image_type == "miniature": 163 if image_type == "miniature":
167 min = self.layers['miniatures'].get_miniature_by_id(imageId) 164 min = self.layers['miniatures'].get_miniature_by_id(imageId)
168 min.set_bmp(img) 165 if min: min.set_bmp(img)
169 elif image_type == "background" or image_type == "texture": 166 elif image_type == "background" or image_type == "texture":
170 self.layers['bg'].bg_bmp = img 167 self.layers['bg'].bg_bmp = img.ConvertToBitmap()
171 if image_type == "background": self.set_size([img.GetWidth(), img.GetHeight()]) 168 if image_type == "background": self.set_size([img.GetWidth(), img.GetHeight()])
172 except: pass 169 except: pass
173 # Flag that we now need to refresh! 170 # Flag that we now need to refresh!
174 self.requireRefresh += 1 171 self.requireRefresh += 1
175 172
251 scrollsize = self.GetScrollPixelsPerUnit() 248 scrollsize = self.GetScrollPixelsPerUnit()
252 clientsize = self.GetClientSize() 249 clientsize = self.GetClientSize()
253 topleft1 = self.GetViewStart() 250 topleft1 = self.GetViewStart()
254 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]] 251 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]]
255 if (clientsize[0] > 1) and (clientsize[1] > 1): 252 if (clientsize[0] > 1) and (clientsize[1] > 1):
256 dc = wx.MemoryDC() 253 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
257 bmp = wx.EmptyBitmap(clientsize[0]+1, clientsize[1]+1) 254 dc = wx.AutoBufferedPaintDC(self)
258 dc.SelectObject(bmp)
259 dc.SetPen(wx.TRANSPARENT_PEN) 255 dc.SetPen(wx.TRANSPARENT_PEN)
260 dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID)) 256 dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
261 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1) 257 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1)
262 dc.SetDeviceOrigin(-topleft[0], -topleft[1]) 258 dc.SetDeviceOrigin(-topleft[0], -topleft[1])
263 dc.SetUserScale(scale, scale) 259 dc.SetUserScale(scale, scale)
268 [clientsize[0]/scale, clientsize[1]/scale]) 264 [clientsize[0]/scale, clientsize[1]/scale])
269 self.layers['whiteboard'].layerDraw(dc) 265 self.layers['whiteboard'].layerDraw(dc)
270 self.layers['fog'].layerDraw(dc, topleft, clientsize) 266 self.layers['fog'].layerDraw(dc, topleft, clientsize)
271 dc.SetPen(wx.NullPen) 267 dc.SetPen(wx.NullPen)
272 dc.SetBrush(wx.NullBrush) 268 dc.SetBrush(wx.NullBrush)
273 dc.SelectObject(wx.NullBitmap)
274 del dc
275 wdc = self.preppaint()
276 wdc.DrawBitmap(bmp, topleft[0], topleft[1])
277 if settings.get_setting("AlwaysShowMapScale") == "1": 269 if settings.get_setting("AlwaysShowMapScale") == "1":
278 self.showmapscale(wdc) 270 self.showmapscale(dc)
279 try: evt.Skip() 271 try: evt.Skip()
280 except: pass 272 except: pass
281
282 def preppaint(self):
283 dc = wx.PaintDC(self)
284 self.PrepareDC(dc)
285 return (dc)
286 273
287 def showmapscale(self, dc): 274 def showmapscale(self, dc):
288 scalestring = "Scale x" + `self.layers['grid'].mapscale`[:3] 275 scalestring = "Scale x" + `self.layers['grid'].mapscale`[:3]
289 (textWidth, textHeight) = dc.GetTextExtent(scalestring) 276 (textWidth, textHeight) = dc.GetTextExtent(scalestring)
290 dc.SetUserScale(1, 1) 277 dc.SetUserScale(1, 1)
378 dc = wx.ClientDC( self ) 365 dc = wx.ClientDC( self )
379 self.PrepareDC( dc ) 366 self.PrepareDC( dc )
380 dc.SetUserScale(self.layers['grid'].mapscale,self.layers['grid'].mapscale) 367 dc.SetUserScale(self.layers['grid'].mapscale,self.layers['grid'].mapscale)
381 # Grab the current map position 368 # Grab the current map position
382 pos = self.snapMarker( evt.GetLogicalPosition( dc ) ) 369 pos = self.snapMarker( evt.GetLogicalPosition( dc ) )
383 # Enable brush optimizations
384 # dc.SetOptimization( True )
385 # Set up the pen used for drawing our marker 370 # Set up the pen used for drawing our marker
386 dc.SetPen( wx.Pen(wx.RED, 1, wx.LONG_DASH) ) 371 dc.SetPen( wx.Pen(wx.RED, 1, wx.LONG_DASH) )
387 # Now, based on the marker mode, draw the right thing 372 # Now, based on the marker mode, draw the right thing
388 if self.markerMode == MARKER_MODE_MEASURE: 373 if self.markerMode == MARKER_MODE_MEASURE:
389 if self.markerStop.x != -1 and self.markerStop.y != -1: 374 if self.markerStop.x != -1 and self.markerStop.y != -1:
397 # Restore the default DC function 382 # Restore the default DC function
398 dc.SetLogicalFunction(wx.COPY) 383 dc.SetLogicalFunction(wx.COPY)
399 # As long as we are in marker mode, we ned to update the stop point 384 # As long as we are in marker mode, we ned to update the stop point
400 self.markerStop = pos 385 self.markerStop = pos
401 dc.SetPen(wx.NullPen) 386 dc.SetPen(wx.NullPen)
402 # Disable brush optimizations
403 #dc.SetOptimization( False )
404 del dc 387 del dc
405 388
406 def on_tape_down(self, evt): 389 def on_tape_down(self, evt):
407 """Greg's experimental tape measure code. Hopefully, when this is done, it will all be 390 """Greg's experimental tape measure code. Hopefully, when this is done, it will all be
408 modal based on a toolbar.""" 391 modal based on a toolbar."""
414 pos = self.snapMarker( evt.GetLogicalPosition( dc ) ) 397 pos = self.snapMarker( evt.GetLogicalPosition( dc ) )
415 # Maker mode should really be set by a toolbar 398 # Maker mode should really be set by a toolbar
416 self.markerMode = MARKER_MODE_MEASURE 399 self.markerMode = MARKER_MODE_MEASURE
417 # Erase the old line if her have one 400 # Erase the old line if her have one
418 if self.markerStart.x != -1 and self.markerStart.y != -1: 401 if self.markerStart.x != -1 and self.markerStart.y != -1:
419 # Enable brush optimizations
420 #dc.SetOptimization( True )
421 # Set up the pen used for drawing our marker 402 # Set up the pen used for drawing our marker
422 dc.SetPen( wx.Pen(wx.RED, 1, wx.LONG_DASH) ) 403 dc.SetPen( wx.Pen(wx.RED, 1, wx.LONG_DASH) )
423 # Set the DC function that we need 404 # Set the DC function that we need
424 dc.SetLogicalFunction(wx.INVERT) 405 dc.SetLogicalFunction(wx.INVERT)
425 # Draw the marker line 406 # Draw the marker line
427 dc.DrawLine( self.markerStart.x, self.markerStart.y, self.markerStop.x, self.markerStop.y ) 408 dc.DrawLine( self.markerStart.x, self.markerStart.y, self.markerStop.x, self.markerStop.y )
428 dc.EndDrawing() 409 dc.EndDrawing()
429 # Restore the default DC function and pen 410 # Restore the default DC function and pen
430 dc.SetLogicalFunction(wx.COPY) 411 dc.SetLogicalFunction(wx.COPY)
431 dc.SetPen(wx.NullPen) 412 dc.SetPen(wx.NullPen)
432 # Disable brush optimizations
433 #dc.SetOptimization( False )
434 # Save our current start and reset the stop value 413 # Save our current start and reset the stop value
435 self.markerStart = pos 414 self.markerStart = pos
436 self.markerStop = pos 415 self.markerStop = pos
437 del dc 416 del dc
438 417
484 if evt.ShiftDown(): pass 463 if evt.ShiftDown(): pass
485 else: self.frame.on_left_dclick(evt) 464 else: self.frame.on_left_dclick(evt)
486 465
487 def on_left_up(self, evt): 466 def on_left_up(self, evt):
488 if evt.ShiftDown(): self.on_tape_up(evt) 467 if evt.ShiftDown(): self.on_tape_up(evt)
489 elif component.get("tree").dragging: 468 elif component.get('tree_fs').dragging:
490 tree = component.get("tree") 469 tree = component.get('tree_fs')
491 if tree.drag_obj.map_aware(): 470 if tree.drag_obj.map_aware():
492 tree.drag_obj.on_send_to_map(evt) 471 tree.drag_obj.on_send_to_map(evt)
493 tree.dragging = False 472 tree.dragging = False
494 tree.drag_obj = None 473 tree.drag_obj = None
495 else: self.frame.on_left_up(evt) 474 else: self.frame.on_left_up(evt)
496 475
497 def on_motion(self, evt): 476 def on_motion(self, evt):
498 if evt.ShiftDown(): self.on_tape_motion(evt) 477 if evt.ShiftDown(): self.on_tape_motion(evt)
499 elif evt.LeftIsDown() and component.get("tree").dragging: pass 478 elif evt.LeftIsDown() and component.get('tree_fs').dragging: pass
500 else: self.frame.on_motion(evt) 479 else: self.frame.on_motion(evt)
501 480
502 def on_zoom_out(self, evt): 481 def on_zoom_out(self, evt):
503 if self.layers['grid'].mapscale > 0.2: 482 if self.layers['grid'].mapscale > 0.2:
504 # attempt to keep same logical point at center of screen 483 # attempt to keep same logical point at center of screen
715 class map_wnd(wx.Panel): 694 class map_wnd(wx.Panel):
716 def __init__(self, parent, id): 695 def __init__(self, parent, id):
717 wx.Panel.__init__(self, parent, id) 696 wx.Panel.__init__(self, parent, id)
718 self.canvas = MapCanvas(self, -1) 697 self.canvas = MapCanvas(self, -1)
719 self.session = component.get('session') 698 self.session = component.get('session')
720 self.chat = component.get('chat')
721 self.top_frame = component.get('frame') 699 self.top_frame = component.get('frame')
700 self.chat = self.top_frame.chat
722 self.root_dir = os.getcwd() 701 self.root_dir = os.getcwd()
723 self.current_layer = 2 702 self.current_layer = 2
724 self.layer_tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS) 703 self.layer_tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS)
725 self.layer_handlers = [] 704 self.layer_handlers = []
726 self.layer_handlers.append(background_handler(self.layer_tabs,-1,self.canvas)) 705 self.layer_handlers.append(background_handler(self.layer_tabs,-1,self.canvas))
819 evt.Skip() 798 evt.Skip()
820 799
821 def on_left_down(self, evt): 800 def on_left_down(self, evt):
822 self.layer_handlers[self.current_layer].on_left_down(evt) 801 self.layer_handlers[self.current_layer].on_left_down(evt)
823 802
824 #double click handler added by Snowdog 5/03
825 def on_left_dclick(self, evt): 803 def on_left_dclick(self, evt):
826 self.layer_handlers[self.current_layer].on_left_dclick(evt) 804 self.layer_handlers[self.current_layer].on_left_dclick(evt)
827 805
828 def on_right_down(self, evt): 806 def on_right_down(self, evt):
829 self.layer_handlers[self.current_layer].on_right_down(evt) 807 self.layer_handlers[self.current_layer].on_right_down(evt)