Mercurial > traipse
comparison orpg/mapper/miniatures_handler.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 | 51428d30c59e |
children |
comparison
equal
deleted
inserted
replaced
27:51428d30c59e | 28:ff154cf3350c |
---|---|
19 # | 19 # |
20 # File: mapper/whiteboard_hander.py | 20 # File: mapper/whiteboard_hander.py |
21 # Author: OpenRPG Team | 21 # Author: OpenRPG Team |
22 # Maintainer: | 22 # Maintainer: |
23 # Version: | 23 # Version: |
24 # $Id: miniatures_handler.py,v 1.43 2007/12/07 20:39:50 digitalxero Exp $ | 24 # $Id: miniatures_handler.py,v Traipse 'Ornery-Orc' prof.ebral Exp $ |
25 # | 25 # |
26 # Description: Miniature layer handler | 26 # Description: Miniature layer handler |
27 # | 27 # |
28 __version__ = "$Id: miniatures_handler.py,v 1.43 2007/12/07 20:39:50 digitalxero Exp $" | 28 __version__ = "$Id: miniatures_handler.py,v Traipse 'Ornery-Orc' prof.ebral Exp $" |
29 | 29 |
30 from base_handler import * | 30 from base_handler import * |
31 from min_dialogs import * | 31 from min_dialogs import * |
32 import thread | 32 import thread, time, mimetypes, urllib, wx, os |
33 import time | 33 |
34 import mimetypes | |
35 import urllib | |
36 | |
37 import wx | |
38 from grid import GRID_RECTANGLE | 34 from grid import GRID_RECTANGLE |
39 from grid import GRID_HEXAGON | 35 from grid import GRID_HEXAGON |
40 from grid import GRID_ISOMETRIC | 36 from grid import GRID_ISOMETRIC |
41 import os | |
42 | 37 |
43 from orpg.tools.orpg_settings import settings | 38 from orpg.tools.orpg_settings import settings |
44 | 39 from xml.etree.ElementTree import ElementTree, Element |
45 LABEL_TOOL = wx.NewId() | 40 from xml.etree.ElementTree import fromstring, tostring |
41 | |
42 SHOW_LABELS_TOOL = wx.NewId() | |
43 AUTO_LABEL_TOOL = wx.NewId() | |
46 LAYER_TOOL = wx.NewId() | 44 LAYER_TOOL = wx.NewId() |
47 MIN_LIST_TOOL = wx.NewId() | 45 MIN_LIST_TOOL = wx.NewId() |
48 MIN_TOOL = wx.NewId() | 46 MIN_TOOL = wx.NewId() |
49 MIN_URL = wx.NewId() | 47 MIN_URL = wx.NewId() |
50 SERIAL_TOOL = wx.NewId() | 48 SERIAL_TOOL = wx.NewId() |
101 | 99 |
102 def __init__(self, parent, id, canvas): | 100 def __init__(self, parent, id, canvas): |
103 self.sel_min = None | 101 self.sel_min = None |
104 self.auto_label = 1 | 102 self.auto_label = 1 |
105 self.use_serial = 1 | 103 self.use_serial = 1 |
106 self.auto_label_cb = None | |
107 self.canvas = canvas | 104 self.canvas = canvas |
108 self.settings = settings | 105 self.settings = settings |
109 self.mini_rclick_menu_extra_items = {} | 106 self.mini_rclick_menu_extra_items = {} |
110 self.background_rclick_menu_extra_items = {} | 107 self.background_rclick_menu_extra_items = {} |
111 base_layer_handler.__init__(self, parent, id, canvas) | 108 base_layer_handler.__init__(self, parent, id, canvas) |
117 self.tooltip_delay_miliseconds = 500 | 114 self.tooltip_delay_miliseconds = 500 |
118 self.tooltip_timer = wx.CallLater(self.tooltip_delay_miliseconds, self.on_tooltip_timer) | 115 self.tooltip_timer = wx.CallLater(self.tooltip_delay_miliseconds, self.on_tooltip_timer) |
119 self.tooltip_timer.Stop() | 116 self.tooltip_timer.Stop() |
120 dt = myFileDropTarget(self) | 117 dt = myFileDropTarget(self) |
121 self.canvas.SetDropTarget(dt) | 118 self.canvas.SetDropTarget(dt) |
122 #wxInitAllImageHandlers() | 119 self.tooltip = wx.ToolTip('') |
123 | 120 |
124 def build_ctrls(self): | 121 def build_ctrls(self): |
125 base_layer_handler.build_ctrls(self) | 122 base_layer_handler.build_ctrls(self) |
126 # add controls in reverse order! (unless you want them after the default tools) | 123 # add controls in reverse order! (unless you want them after the default tools) |
127 self.auto_label_cb = wx.CheckBox(self, wx.ID_ANY, ' Auto Label ', (-1,-1),(-1,-1)) | |
128 self.auto_label_cb.SetValue(self.auto_label) | |
129 self.min_url = wx.ComboBox(self, wx.ID_ANY, "http://", style=wx.CB_DROPDOWN | wx.CB_SORT) | 124 self.min_url = wx.ComboBox(self, wx.ID_ANY, "http://", style=wx.CB_DROPDOWN | wx.CB_SORT) |
130 self.localBrowse = wx.Button(self, wx.ID_ANY, 'Browse', style=wx.BU_EXACTFIT) | 125 self.localBrowse = wx.Button(self, wx.ID_ANY, 'Browse', style=wx.BU_EXACTFIT) |
131 minilist = createMaskedButton( self, dir_struct["icon"]+'questionhead.gif', 'Edit miniature properties', wx.ID_ANY) | 126 minilist = createMaskedButton( self, dir_struct["icon"]+'questionhead.gif', 'Edit miniature properties', wx.ID_ANY) |
132 miniadd = wx.Button(self, wx.ID_OK, "Add Miniature", style=wx.BU_EXACTFIT) | 127 miniadd = wx.Button(self, wx.ID_OK, "Add Miniature", style=wx.BU_EXACTFIT) |
133 self.sizer.Add(self.auto_label_cb,0,wx.ALIGN_CENTER) | |
134 self.sizer.Add((6, 0)) | |
135 self.sizer.Add(self.min_url, 1, wx.ALIGN_CENTER) | 128 self.sizer.Add(self.min_url, 1, wx.ALIGN_CENTER) |
136 self.sizer.Add((6, 0)) | 129 self.sizer.Add((6, 0)) |
137 self.sizer.Add(miniadd, 0, wx.ALIGN_CENTER) | 130 self.sizer.Add(miniadd, 0, wx.ALIGN_CENTER) |
138 self.sizer.Add((6, 0)) | 131 self.sizer.Add((6, 0)) |
139 self.sizer.Add(self.localBrowse, 0, wx.ALIGN_CENTER) | 132 self.sizer.Add(self.localBrowse, 0, wx.ALIGN_CENTER) |
140 self.sizer.Add((6, 0)) | 133 self.sizer.Add((6, 0)) |
141 self.sizer.Add(minilist, 0, wx.ALIGN_CENTER) | 134 self.sizer.Add(minilist, 0, wx.ALIGN_CENTER) |
142 self.Bind(wx.EVT_BUTTON, self.on_min_list, minilist) | 135 self.Bind(wx.EVT_BUTTON, self.on_min_list, minilist) |
143 self.Bind(wx.EVT_BUTTON, self.on_miniature, miniadd) | 136 self.Bind(wx.EVT_BUTTON, self.on_miniature, miniadd) |
144 self.Bind(wx.EVT_BUTTON, self.on_browse, self.localBrowse) | 137 self.Bind(wx.EVT_BUTTON, self.on_browse, self.localBrowse) |
145 self.Bind(wx.EVT_CHECKBOX, self.on_label, self.auto_label_cb) | |
146 | 138 |
147 def on_browse(self, evt): | 139 def on_browse(self, evt): |
148 if not self.role_is_gm_or_player(): return | 140 if not self.role_is_gm_or_player(): return |
149 dlg = wx.FileDialog(None, "Select a Miniature to load", dir_struct["user"]+'webfiles/', | 141 dlg = wx.FileDialog(None, "Select a Miniature to load", dir_struct["user"]+'webfiles/', |
150 wildcard="Image files (*.bmp, *.gif, *.jpg, *.png)|*.bmp;*.gif;*.jpg;*.png", style=wx.OPEN) | 142 wildcard="Image files (*.bmp, *.gif, *.jpg, *.png)|*.bmp;*.gif;*.jpg;*.png", style=wx.OPEN) |
201 dlg.Destroy() | 193 dlg.Destroy() |
202 self.canvas.layers['miniatures'].rollback_serial() | 194 self.canvas.layers['miniatures'].rollback_serial() |
203 self.canvas.send_map_data() | 195 self.canvas.send_map_data() |
204 self.canvas.Refresh(False) | 196 self.canvas.Refresh(False) |
205 | 197 |
206 | |
207 def build_menu(self,label = "Miniature"): | 198 def build_menu(self,label = "Miniature"): |
208 base_layer_handler.build_menu(self,label) | 199 base_layer_handler.build_menu(self,label) |
209 self.main_menu.AppendSeparator() | 200 self.main_menu.AppendSeparator() |
210 self.main_menu.Append(LABEL_TOOL,"&Auto label","",1) | 201 self.main_menu.Append(SHOW_LABELS_TOOL, "&Show Labels", '', 1) |
211 self.main_menu.Check(LABEL_TOOL,self.auto_label) | 202 self.main_menu.Check(SHOW_LABELS_TOOL, self.canvas.layers['miniatures'].show_labels) |
203 self.main_menu.Append(AUTO_LABEL_TOOL,"&Auto label","",1) | |
204 self.main_menu.Check(AUTO_LABEL_TOOL, self.auto_label) | |
212 self.main_menu.Append(SERIAL_TOOL,"&Number minis","",1) | 205 self.main_menu.Append(SERIAL_TOOL,"&Number minis","",1) |
213 self.main_menu.Check(SERIAL_TOOL, self.use_serial) | 206 self.main_menu.Check(SERIAL_TOOL, self.use_serial) |
214 self.main_menu.Append(MAP_REFRESH_MINI_URLS,"&Refresh miniatures") # Add the menu item | 207 self.main_menu.Append(MAP_REFRESH_MINI_URLS,"&Refresh miniatures") # Add the menu item |
215 self.main_menu.AppendSeparator() | 208 self.main_menu.AppendSeparator() |
216 self.main_menu.Append(MIN_MOVE, "Move") | 209 self.main_menu.Append(MIN_MOVE, "Move") |
217 self.canvas.Bind(wx.EVT_MENU, self.on_map_board_menu_item, id=MAP_REFRESH_MINI_URLS) # Set the handler | 210 self.canvas.Bind(wx.EVT_MENU, self.on_map_board_menu_item, id=MAP_REFRESH_MINI_URLS) # Set the handler |
218 self.canvas.Bind(wx.EVT_MENU, self.on_label, id=LABEL_TOOL) | 211 self.canvas.Bind(wx.EVT_MENU, self.on_show_labels, id=SHOW_LABELS_TOOL) |
212 self.canvas.Bind(wx.EVT_MENU, self.on_auto_label, id=AUTO_LABEL_TOOL) | |
219 self.canvas.Bind(wx.EVT_MENU, self.on_serial, id=SERIAL_TOOL) | 213 self.canvas.Bind(wx.EVT_MENU, self.on_serial, id=SERIAL_TOOL) |
220 # build miniature meenu | 214 # build miniature meenu |
221 self.min_menu = wx.Menu() | 215 self.min_menu = wx.Menu() |
222 # Rectangles and hexagons require slightly different menus because of | 216 # Rectangles and hexagons require slightly different menus because of |
223 # facing and heading possibilities. | 217 # facing and heading possibilities. |
310 if len(self.mini_rclick_menu_extra_items)>0: | 304 if len(self.mini_rclick_menu_extra_items)>0: |
311 self.min_menu.AppendSeparator() | 305 self.min_menu.AppendSeparator() |
312 for item in self.mini_rclick_menu_extra_items.items(): self.min_menu.Append(item[1], item[0]) | 306 for item in self.mini_rclick_menu_extra_items.items(): self.min_menu.Append(item[1], item[0]) |
313 if len(self.background_rclick_menu_extra_items)>0: | 307 if len(self.background_rclick_menu_extra_items)>0: |
314 self.main_menu.AppendSeparator() | 308 self.main_menu.AppendSeparator() |
315 for item in self.background_rclick_menu_extra_items.items(): | 309 for item in self.background_rclick_menu_extra_items.items(): self.main_menu.Append(item[1], item[0]) |
316 self.main_menu.Append(item[1], item[0]) | |
317 | 310 |
318 def do_min_menu(self,pos): | 311 def do_min_menu(self,pos): |
319 self.canvas.PopupMenu(self.min_menu,pos) | 312 self.canvas.PopupMenu(self.min_menu,pos) |
320 | 313 |
321 def do_min_select_menu(self, min_list, pos): | 314 def do_min_select_menu(self, min_list, pos): |
353 self.moveSelectedMini(self.last_rclick_pos) | 346 self.moveSelectedMini(self.last_rclick_pos) |
354 self.deselectAndRefresh() | 347 self.deselectAndRefresh() |
355 return | 348 return |
356 elif id == MIN_REMOVE: self.canvas.layers['miniatures'].del_miniature(self.sel_rmin) | 349 elif id == MIN_REMOVE: self.canvas.layers['miniatures'].del_miniature(self.sel_rmin) |
357 elif id == MIN_TO_GAMETREE: | 350 elif id == MIN_TO_GAMETREE: |
358 min_xml = self.sel_rmin.toxml(action="new") | 351 ### Alpha ### implements ElementTree |
359 node_begin = "<nodehandler module='map_miniature_nodehandler' class='map_miniature_handler' name='" | 352 mini = self.sel_rmin.toxml(action="new") |
360 if self.sel_rmin.label: node_begin += self.sel_rmin.label + "'" | 353 node = Element('nodehandler') |
361 else: node_begin += "Unnamed Miniature'" | 354 node.set('module', 'map_miniature_nodehandler') |
362 node_begin += ">" | 355 node.set('class', 'map_miniature_handler') |
363 gametree = component.get('tree') | 356 name = self.sel_rmin.label if self.sel_rmin.label else 'Unnamed Miniature' |
364 node_xml = node_begin + min_xml + '</nodehandler>' | 357 node.set('name', name) |
365 #print "Sending this XML to insert_xml:" + node_xml | 358 node.append(fromstring(mini)) |
366 gametree.insert_xml(str(node_xml)) | 359 gametree = component.get('tree_fs') |
360 gametree.insert_xml(tostring(node)) | |
361 ### ElementTree is a nice decision from Core, kudos!! ### | |
367 elif id == MIN_SHOW_HIDE: | 362 elif id == MIN_SHOW_HIDE: |
368 if self.sel_rmin.hide: self.sel_rmin.hide = 0 | 363 if self.sel_rmin.hide: self.sel_rmin.hide = 0 |
369 else: self.sel_rmin.hide = 1 | 364 else: self.sel_rmin.hide = 1 |
370 elif id == MIN_LOCK_UNLOCK: | 365 elif id == MIN_LOCK_UNLOCK: |
371 if self.sel_rmin.locked: self.sel_rmin.locked = False | 366 if self.sel_rmin.locked: self.sel_rmin.locked = False |
414 # before getting the oldz to test | 409 # before getting the oldz to test |
415 # Save the selected minis current z-order | 410 # Save the selected minis current z-order |
416 oldz = self.sel_rmin.zorder | 411 oldz = self.sel_rmin.zorder |
417 # Make sure the mini isn't sticky front or back | 412 # Make sure the mini isn't sticky front or back |
418 if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT): | 413 if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT): |
419 ## print "old z-order = " + str(oldz) | |
420 self.sel_rmin.zorder -= 1 | 414 self.sel_rmin.zorder -= 1 |
421 # Re-collapse to normalize | 415 # Re-collapse to normalize |
422 # Note: only one update (with the final values) will be sent | 416 # Note: only one update (with the final values) will be sent |
423 self.canvas.layers['miniatures'].collapse_zorder() | 417 self.canvas.layers['miniatures'].collapse_zorder() |
424 | 418 |
428 # minis - 1. If this isn't the case, then execute | 422 # minis - 1. If this isn't the case, then execute |
429 # a self.canvas.layers['miniatures'].collapse_zorder() | 423 # a self.canvas.layers['miniatures'].collapse_zorder() |
430 # before getting the oldz to test | 424 # before getting the oldz to test |
431 # Save the selected minis current z-order | 425 # Save the selected minis current z-order |
432 oldz = self.sel_rmin.zorder | 426 oldz = self.sel_rmin.zorder |
433 ## print "old z-order = " + str(oldz) | |
434 self.sel_rmin.zorder += 1 | 427 self.sel_rmin.zorder += 1 |
435 | 428 |
436 # Re-collapse to normalize | 429 # Re-collapse to normalize |
437 # Note: only one update (with the final values) will be sent | 430 # Note: only one update (with the final values) will be sent |
438 self.canvas.layers['miniatures'].collapse_zorder() | 431 self.canvas.layers['miniatures'].collapse_zorder() |
446 # Save the selected minis current z-order | 439 # Save the selected minis current z-order |
447 oldz = self.sel_rmin.zorder | 440 oldz = self.sel_rmin.zorder |
448 | 441 |
449 # Make sure the mini isn't sticky front or back | 442 # Make sure the mini isn't sticky front or back |
450 if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT): | 443 if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT): |
451 ## print "old z-order = " + str(oldz) | |
452 # The new z-order will be one more than the last index | 444 # The new z-order will be one more than the last index |
453 newz = len(self.canvas.layers['miniatures'].miniatures) | 445 newz = len(self.canvas.layers['miniatures'].miniatures) |
454 ## print "new z-order = " + str(newz) | |
455 self.sel_rmin.zorder = newz | 446 self.sel_rmin.zorder = newz |
456 # Re-collapse to normalize | 447 # Re-collapse to normalize |
457 # Note: only one update (with the final values) will be sent | 448 # Note: only one update (with the final values) will be sent |
458 self.canvas.layers['miniatures'].collapse_zorder() | 449 self.canvas.layers['miniatures'].collapse_zorder() |
459 | 450 |
465 # before getting the oldz to test | 456 # before getting the oldz to test |
466 # Save the selected minis current z-order | 457 # Save the selected minis current z-order |
467 oldz = self.sel_rmin.zorder | 458 oldz = self.sel_rmin.zorder |
468 # Make sure the mini isn't sticky front or back | 459 # Make sure the mini isn't sticky front or back |
469 if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT): | 460 if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT): |
470 ## print "old z-order = " + str(oldz) | |
471 | 461 |
472 # Since 0 is the lowest in a normalized order, be one less | 462 # Since 0 is the lowest in a normalized order, be one less |
473 newz = -1 | 463 newz = -1 |
474 ## print "new z-order = " + str(newz) | |
475 self.sel_rmin.zorder = newz | 464 self.sel_rmin.zorder = newz |
476 # Re-collapse to normalize | 465 # Re-collapse to normalize |
477 # Note: only one update (with the final values) will be sent | 466 # Note: only one update (with the final values) will be sent |
478 self.canvas.layers['miniatures'].collapse_zorder() | 467 self.canvas.layers['miniatures'].collapse_zorder() |
479 | 468 |
480 elif id == MIN_FRONTBACK_UNLOCK: | 469 elif id == MIN_FRONTBACK_UNLOCK: |
481 #print "Unlocked/ unstickified..." | |
482 if self.sel_rmin.zorder == MIN_STICKY_BACK: self.sel_rmin.zorder = MIN_STICKY_BACK + 1 | 470 if self.sel_rmin.zorder == MIN_STICKY_BACK: self.sel_rmin.zorder = MIN_STICKY_BACK + 1 |
483 elif self.sel_rmin.zorder == MIN_STICKY_FRONT: self.sel_rmin.zorder = MIN_STICKY_FRONT - 1 | 471 elif self.sel_rmin.zorder == MIN_STICKY_FRONT: self.sel_rmin.zorder = MIN_STICKY_FRONT - 1 |
484 elif id == MIN_LOCK_BACK: self.sel_rmin.zorder = MIN_STICKY_BACK | 472 elif id == MIN_LOCK_BACK: self.sel_rmin.zorder = MIN_STICKY_BACK |
485 elif id == MIN_LOCK_FRONT: self.sel_rmin.zorder = MIN_STICKY_FRONT | 473 elif id == MIN_LOCK_FRONT: self.sel_rmin.zorder = MIN_STICKY_FRONT |
486 # Pretty much, we always want to refresh when we go through here | 474 # Pretty much, we always want to refresh when we go through here |
517 y = dc.DeviceToLogicalY(0) | 505 y = dc.DeviceToLogicalY(0) |
518 self.canvas.layers['miniatures'].add_miniature(id, min_url, pos=cmpPoint(x,y), label=min_label) | 506 self.canvas.layers['miniatures'].add_miniature(id, min_url, pos=cmpPoint(x,y), label=min_label) |
519 except: | 507 except: |
520 # When there is an exception here, we should be decrementing the serial_number for reuse!! | 508 # When there is an exception here, we should be decrementing the serial_number for reuse!! |
521 unablemsg= "Unable to load/resolve URL: " + min_url + " on resource \"" + min_label + "\"!!!\n\n" | 509 unablemsg= "Unable to load/resolve URL: " + min_url + " on resource \"" + min_label + "\"!!!\n\n" |
522 #print unablemsg | |
523 dlg = wx.MessageDialog(self,unablemsg, 'Url not found',wx.ICON_EXCLAMATION) | 510 dlg = wx.MessageDialog(self,unablemsg, 'Url not found',wx.ICON_EXCLAMATION) |
524 dlg.ShowModal() | 511 dlg.ShowModal() |
525 dlg.Destroy() | 512 dlg.Destroy() |
526 self.canvas.layers['miniatures'].rollback_serial() | 513 self.canvas.layers['miniatures'].rollback_serial() |
527 self.canvas.send_map_data() | 514 self.canvas.send_map_data() |
528 self.canvas.Refresh(False) | 515 self.canvas.Refresh(False) |
529 #except Exception, e: | 516 #except Exception, e: |
530 #wx.MessageBox(str(e),"Miniature Error") | 517 #wx.MessageBox(str(e),"Miniature Error") |
531 | 518 |
532 def on_label(self,evt): | 519 def on_show_labels(self, evt): |
520 show_labels = not self.canvas.layers['miniatures'].show_labels | |
521 self.canvas.layers['miniatures'].show_labels = show_labels | |
522 self.canvas.Refresh() | |
523 | |
524 def on_auto_label(self,evt): | |
533 self.auto_label = not self.auto_label | 525 self.auto_label = not self.auto_label |
534 self.auto_label_cb.SetValue(self.auto_label) | 526 #self.auto_label_cb.SetValue(self.auto_label) |
535 #self.send_map_data() | 527 #self.send_map_data() |
536 #self.Refresh() | 528 #self.Refresh() |
537 | 529 |
538 def on_min_list(self,evt): | 530 def on_min_list(self,evt): |
539 session = self.canvas.frame.session | 531 session = self.canvas.frame.session |
540 if (session.my_role() != session.ROLE_GM): | 532 if (session.my_role() != session.ROLE_GM): |
541 self.infoPost("You must be a GM to use this feature") | 533 self.infoPost("You must be a GM to use this feature") |
542 return | 534 return |
543 #d = min_list_panel(self.frame.GetParent(),self.canvas.layers,"Miniature list") | 535 #d = min_list_panel(self.frame.GetParent(),self.canvas.layers,"Miniature list") |
544 d = min_list_panel(self.canvas.frame,self.canvas.layers,"Miniature list") | 536 d = min_list_panel(self.canvas.frame, self.canvas.layers, "Miniature list") |
545 if d.ShowModal() == wx.ID_OK: d.Destroy() | 537 if d.ShowModal() == wx.ID_OK: d.Destroy() |
546 self.canvas.Refresh(False) | 538 self.canvas.Refresh(False) |
547 | 539 |
548 def on_serial(self, evt): | 540 def on_serial(self, evt): |
549 self.use_serial = not self.use_serial | 541 self.use_serial = not self.use_serial |
617 y = dc.DeviceToLogicalY(y) | 609 y = dc.DeviceToLogicalY(y) |
618 (imgtype,j) = mimetypes.guess_type(filename) | 610 (imgtype,j) = mimetypes.guess_type(filename) |
619 postdata = urllib.urlencode({'filename':filename, 'imgdata':imgdata, 'imgtype':imgtype}) | 611 postdata = urllib.urlencode({'filename':filename, 'imgdata':imgdata, 'imgtype':imgtype}) |
620 if self.settings.get_setting('LocalorRemote') == 'Remote': | 612 if self.settings.get_setting('LocalorRemote') == 'Remote': |
621 thread.start_new_thread(self.canvas.layers['miniatures'].upload, (postdata, filepath), {'pos':cmpPoint(x,y)}) | 613 thread.start_new_thread(self.canvas.layers['miniatures'].upload, (postdata, filepath), {'pos':cmpPoint(x,y)}) |
622 else: | 614 else: self.CherryPit(filepath, '') |
623 self.CherryPit(filepath, '') | |
624 | 615 |
625 def on_tooltip_timer(self, *args): | 616 def on_tooltip_timer(self, *args): |
626 pos = args[0] | 617 pos = args[0] |
627 dc = wx.ClientDC(self.canvas) | 618 dc = wx.ClientDC(self.canvas) |
628 self.canvas.PrepareDC(dc) | 619 self.canvas.PrepareDC(dc) |
629 dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale) | 620 dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale) |
630 pos = wx.Point(dc.DeviceToLogicalX(pos.x), dc.DeviceToLogicalY(pos.y)) | 621 pos = wx.Point(dc.DeviceToLogicalX(pos.x), dc.DeviceToLogicalY(pos.y)) |
631 mini_list = self.getMiniListOrSelectedMini(pos) | 622 mini_list = self.getMiniListOrSelectedMini(pos) |
632 if len(mini_list) > 0: | 623 if len(mini_list) > 0: |
633 tooltip = self.get_mini_tooltip(mini_list) | 624 tooltip = mini_list[0].label |
634 self.canvas.SetToolTipString(tooltip) | 625 #self.canvas.SetToolTipString(mini_list[0].label) |
635 else: self.canvas.SetToolTipString("") | 626 #Once set, it never unsets, so it sucks. |
627 else: self.canvas.SetToolTipString('') | |
636 | 628 |
637 def on_motion(self,evt): | 629 def on_motion(self,evt): |
638 if evt.Dragging() and evt.LeftIsDown(): | 630 if evt.Dragging() and evt.LeftIsDown(): |
639 if self.canvas.drag is None and self.drag_mini is not None: | 631 if self.canvas.drag is None and self.drag_mini is not None: |
640 drag_bmp = self.drag_mini.bmp | 632 drag_bmp = self.drag_mini.bmp |
641 if self.drag_mini.width and self.drag_mini.height: | 633 if self.drag_mini.width and self.drag_mini.height: |
642 tmp_image = drag_bmp.ConvertToImage() | 634 tmp_image = drag_bmp.ConvertToImage() |
643 tmp_image.Rescale(int(self.drag_mini.width * self.canvas.layers['grid'].mapscale), | |
644 int(self.drag_mini.height * self.canvas.layers['grid'].mapscale)) | |
645 tmp_image.ConvertAlphaToMask() | 635 tmp_image.ConvertAlphaToMask() |
646 drag_bmp = tmp_image.ConvertToBitmap() | 636 drag_bmp = tmp_image.ConvertToBitmap() |
647 mask = wx.Mask(drag_bmp, wx.Colour(tmp_image.GetMaskRed(), | 637 mask = wx.Mask(drag_bmp, wx.Colour(tmp_image.GetMaskRed(), |
648 tmp_image.GetMaskGreen(), tmp_image.GetMaskBlue())) | 638 tmp_image.GetMaskGreen(), tmp_image.GetMaskBlue())) |
649 drag_bmp.SetMask(mask) | 639 drag_bmp.SetMask(mask) |
660 int(self.drag_offset.y * self.canvas.layers['grid'].mapscale)), self.canvas, False) | 650 int(self.drag_offset.y * self.canvas.layers['grid'].mapscale)), self.canvas, False) |
661 elif self.canvas.drag is not None: | 651 elif self.canvas.drag is not None: |
662 self.canvas.drag.Move(evt.GetPosition()) | 652 self.canvas.drag.Move(evt.GetPosition()) |
663 self.canvas.drag.Show() | 653 self.canvas.drag.Show() |
664 # reset tool tip timer | 654 # reset tool tip timer |
665 self.canvas.SetToolTipString("") | 655 self.canvas.SetToolTipString('') |
666 self.tooltip_timer.Restart(self.tooltip_delay_miliseconds, evt.GetPosition()) | 656 self.tooltip_timer.Restart(self.tooltip_delay_miliseconds, evt.GetPosition()) |
667 | 657 |
668 def on_left_up(self,evt): | 658 def on_left_up(self,evt): |
669 if self.canvas.drag: | 659 if self.canvas.drag: |
670 self.canvas.drag.Hide() | 660 self.canvas.drag.Hide() |
756 def infoPost(self, message): | 746 def infoPost(self, message): |
757 component.get("chat").InfoPost(message) | 747 component.get("chat").InfoPost(message) |
758 | 748 |
759 def role_is_gm_or_player(self): | 749 def role_is_gm_or_player(self): |
760 session = self.canvas.frame.session | 750 session = self.canvas.frame.session |
761 if (session.my_role() <> session.ROLE_GM) and (session.my_role() <> session.ROLE_PLAYER) and (session.use_roles()): | 751 if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER) and (session.use_roles()): |
762 self.infoPost("You must be either a player or GM to use the miniature Layer") | 752 self.infoPost("You must be either a player or GM to use the miniature Layer") |
763 return False | 753 return False |
764 return True | 754 return True |
765 | 755 |
766 def role_is_gm(self): | 756 def role_is_gm(self): |
767 session = self.canvas.frame.session | 757 session = self.canvas.frame.session |
768 if (session.my_role() <> session.ROLE_GM) and (session.use_roles()): return False | 758 if (session.my_role() != session.ROLE_GM) and (session.use_roles()): return False |
769 return True | 759 return True |
770 | 760 |
771 def alreadyDealingWithMenu(self): | 761 def alreadyDealingWithMenu(self): |
772 return self.lastMenuChoice is not None | 762 return self.lastMenuChoice is not None |
773 | 763 |