annotate orpg/mapper/miniatures_handler.py @ 217:c719a07cd28d beta

Traipse Beta 'OpenRPG' {100430-01} 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 (Patch-2) New Features: New Namespace method with two new syntaxes New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New Namespace FutureCheck helps ensure you don't receive an incorrect node New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode New to Update Manager, checks Repo for updates on software start New to Mini Lin node, change title in design mode Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues Fix to URL2Link plugin, modified regex compilation should remove memory leak Fix to mapy.py, a roll back due to zoomed grid issues Fix to whiteboard_handler, Circles work by you clicking the center of the circle Fix to Servers parse_incoming_dom which was outdated and did not respect XML Fix to a broken link in the server welcome message Fix to InterParse and logger requiring traceback Fix to Update Manager Status Bar Fix to failed image and erroneous pop up Fix to Mini Lib node that was preventing use Fix to plugins that parce dice but did not call InterParse Fix to nodes for name changing by double click Fix to Game Tree, node ordering on drag and drop corrected Daily-01: Again forgot the version number Files affect in last update: Currently selected branch: beta Author: sirebral Files Modified (in update): orpg/chat/commands.py orpg/gametree/gametree.py orpg/gametree/nodehandlers/containers.py orpg/gametree/nodehandlers/minilib.py orpg/pluginhandler.py plugins/xxhiddendice.py plugins/xxsimpleinit.py
author sirebral
date Fri, 30 Apr 2010 05:44:05 -0500
parents dcae32e219f1
children
rev   line source
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
3 # openrpg-dev@lists.sourceforge.net
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
4 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
6 # it under the terms of the GNU General Public License as published by
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
8 # (at your option) any later version.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
9 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
13 # GNU General Public License for more details.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
14 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
16 # along with this program; if not, write to the Free Software
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
18 # --
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
19 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
20 # File: mapper/whiteboard_hander.py
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
21 # Author: OpenRPG Team
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
22 # Maintainer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
23 # Version:
184
dcae32e219f1 Traipse Beta 'OpenRPG' {100117-00}
sirebral
parents: 183
diff changeset
24 # $Id: miniatures_handler.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
25 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
26 # Description: Miniature layer handler
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27 #
184
dcae32e219f1 Traipse Beta 'OpenRPG' {100117-00}
sirebral
parents: 183
diff changeset
28 __version__ = "$Id: miniatures_handler.py,v Traipse 'Ornery-Orc' prof.ebral Exp $"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
29
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
30 from base_handler import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
31 from min_dialogs import *
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
32 import thread, time, mimetypes, urllib, wx, os
92
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
33
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
34 from grid import GRID_RECTANGLE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
35 from grid import GRID_HEXAGON
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
36 from grid import GRID_ISOMETRIC
10
73d9286c22cf Adds some superb CherryPy features! Components can be deleted now too!
sirebral
parents: 7
diff changeset
37
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
38 from orpg.tools.orpg_settings import settings
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
39 from xml.etree.ElementTree import ElementTree, Element
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
40 from xml.etree.ElementTree import fromstring, tostring
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
41
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
42 SHOW_LABELS_TOOL = wx.NewId()
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
43 AUTO_LABEL_TOOL = wx.NewId()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
44 LAYER_TOOL = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
45 MIN_LIST_TOOL = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
46 MIN_TOOL = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
47 MIN_URL = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
48 SERIAL_TOOL = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
49 MIN_MOVE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
50 MIN_REMOVE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
51 MIN_PROP_DLG = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
52 MIN_FACING_NONE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
53 MIN_FACING_MATCH = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
54 MIN_FACING_EAST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
55 MIN_FACING_WEST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
56 MIN_FACING_NORTH = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 MIN_FACING_SOUTH = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
58 MIN_FACING_NORTHEAST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
59 MIN_FACING_SOUTHEAST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
60 MIN_FACING_SOUTHWEST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
61 MIN_FACING_NORTHWEST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
62 MIN_HEADING_NONE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
63 MIN_HEADING_MATCH = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
64 MIN_HEADING_EAST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
65 MIN_HEADING_WEST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
66 MIN_HEADING_NORTH = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
67 MIN_HEADING_SOUTH = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
68 MIN_HEADING_NORTHEAST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
69 MIN_HEADING_SOUTHEAST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
70 MIN_HEADING_SOUTHWEST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
71 MIN_HEADING_NORTHWEST = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
72 MIN_HEADING_SUBMENU = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
73 MIN_FACING_SUBMENU = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
74 MIN_ALIGN_SUBMENU = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
75 MIN_ALIGN_GRID_CENTER = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
76 MIN_ALIGN_GRID_TL = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
77 MIN_TITLE_HACK = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
78 MIN_TO_GAMETREE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
79 MIN_BACK_ONE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80 MIN_FORWARD_ONE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
81 MIN_TO_BACK = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
82 MIN_TO_FRONT = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
83 MIN_LOCK_BACK = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
84 MIN_LOCK_FRONT = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
85 MIN_FRONTBACK_UNLOCK = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
86 MIN_ZORDER_SUBMENU = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
87 MIN_SHOW_HIDE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
88 MIN_LOCK_UNLOCK = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
89 MAP_REFRESH_MINI_URLS = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
90
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
91 class myFileDropTarget(wx.FileDropTarget):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
92 def __init__(self, handler):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
93 wx.FileDropTarget.__init__(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
94 self.m_handler = handler
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
95 def OnDropFiles(self, x, y, filenames):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
96 self.m_handler.on_drop_files(x, y, filenames)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
97
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
98 class miniatures_handler(base_layer_handler):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
99
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
100 def __init__(self, parent, id, canvas):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
101 self.sel_min = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
102 self.auto_label = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103 self.use_serial = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104 self.canvas = canvas
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
105 self.settings = settings
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
106 self.mini_rclick_menu_extra_items = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
107 self.background_rclick_menu_extra_items = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
108 base_layer_handler.__init__(self, parent, id, canvas)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
109 # id is the index of the last good menu choice or 'None'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
110 # if the last menu was left without making a choice
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
111 # should be -1 at other times to prevent events overlapping
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
112 self.lastMenuChoice = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
113 self.drag_mini = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
114 self.tooltip_delay_miliseconds = 500
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
115 self.tooltip_timer = wx.CallLater(self.tooltip_delay_miliseconds, self.on_tooltip_timer)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
116 self.tooltip_timer.Stop()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
117 dt = myFileDropTarget(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
118 self.canvas.SetDropTarget(dt)
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
119 self.tooltip = wx.ToolTip('')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
120
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
121 def build_ctrls(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
122 base_layer_handler.build_ctrls(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
123 # add controls in reverse order! (unless you want them after the default tools)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
124 self.min_url = wx.ComboBox(self, wx.ID_ANY, "http://", style=wx.CB_DROPDOWN | wx.CB_SORT)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
125 self.localBrowse = wx.Button(self, wx.ID_ANY, 'Browse', style=wx.BU_EXACTFIT)
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
126 minilist = createMaskedButton( self, dir_struct["icon"]+'questionhead.gif', 'Edit miniature properties', wx.ID_ANY)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
127 miniadd = wx.Button(self, wx.ID_OK, "Add Miniature", style=wx.BU_EXACTFIT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
128 self.sizer.Add(self.min_url, 1, wx.ALIGN_CENTER)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
129 self.sizer.Add((6, 0))
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
130 self.sizer.Add(miniadd, 0, wx.ALIGN_CENTER)
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
131 self.sizer.Add((6, 0))
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
132 self.sizer.Add(self.localBrowse, 0, wx.ALIGN_CENTER)
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
133 self.sizer.Add((6, 0))
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
134 self.sizer.Add(minilist, 0, wx.ALIGN_CENTER)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
135 self.Bind(wx.EVT_BUTTON, self.on_min_list, minilist)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
136 self.Bind(wx.EVT_BUTTON, self.on_miniature, miniadd)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
137 self.Bind(wx.EVT_BUTTON, self.on_browse, self.localBrowse)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
138
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
139 def on_browse(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
140 if not self.role_is_gm_or_player(): return
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
141 dlg = wx.FileDialog(None, "Select a Miniature to load", dir_struct["user"]+'webfiles/',
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
142 wildcard="Image files (*.bmp, *.gif, *.jpg, *.png)|*.bmp;*.gif;*.jpg;*.png", style=wx.OPEN)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
143 if not dlg.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
144 dlg.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
145 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
146 file = open(dlg.GetPath(), "rb")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
147 imgdata = file.read()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
148 file.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
149 filename = dlg.GetFilename()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
150 (imgtype,j) = mimetypes.guess_type(filename)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
151 postdata = urllib.urlencode({'filename':filename, 'imgdata':imgdata, 'imgtype':imgtype})
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
152 if self.settings.get_setting('LocalorRemote') == 'Remote':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
153 # make the new mini appear in top left of current viewable map
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
154 dc = wx.ClientDC(self.canvas)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
155 self.canvas.PrepareDC(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
156 dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
157 x = dc.DeviceToLogicalX(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
158 y = dc.DeviceToLogicalY(0)
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
159 thread.start_new_thread(self.canvas.layers['miniatures'].upload,
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
160 (postdata, dlg.GetPath()), {'pos':cmpPoint(x,y)})
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
161 else:
94
118fbe111922 Traipse Beta 'OpenRPG' {090919-02}
sirebral
parents: 92
diff changeset
162 self.CherryPit(dlg.GetDirectory(), filename)
92
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
163
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
164 def CherryPit(self, path, filename):
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
165 try: min_url = component.get("cherrypy") + filename
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
166 except: return #chat.InfoPost('CherryPy is not started!')
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
167 min_url = path.replace(orpg.dirpath.dir_struct["user"]+'webfiles',
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
168 component.get("cherrypy")).replace(os.sep, '/') + '/' + filename
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
169 # build url
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
170 if min_url == "" or min_url == "http://": return
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
171 if min_url[:7] != "http://": min_url = "http://" + min_url
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
172 # make label
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
173 if self.auto_label and min_url[-4:-3] == '.':
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
174 start = min_url.rfind("/") + 1
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
175 min_label = min_url[start:len(min_url)-4]
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
176 if self.use_serial: min_label = '%s %d' % ( min_label, self.canvas.layers['miniatures'].next_serial() )
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
177 else: min_label = ""
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
178 if self.min_url.FindString(min_url) == -1: self.min_url.Append(min_url)
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
179 try:
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
180 id = 'mini-' + self.canvas.frame.session.get_next_id()
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
181 # make the new mini appear in top left of current viewable map
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
182 dc = wx.ClientDC(self.canvas)
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
183 self.canvas.PrepareDC(dc)
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
184 dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale)
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
185 x = dc.DeviceToLogicalX(0)
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
186 y = dc.DeviceToLogicalY(0)
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
187 self.canvas.layers['miniatures'].add_miniature(id, min_url, pos=cmpPoint(x,y), label=min_label)
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
188 except:
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
189 # When there is an exception here, we should be decrementing the serial_number for reuse!!
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
190 unablemsg= "Unable to load/resolve URL: " + min_url + " on resource \"" + min_label + "\"!!!\n\n"
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
191 dlg = wx.MessageDialog(self,unablemsg, 'Url not found',wx.ICON_EXCLAMATION)
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
192 dlg.ShowModal()
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
193 dlg.Destroy()
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
194 self.canvas.layers['miniatures'].rollback_serial()
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
195 self.canvas.send_map_data()
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
196 self.canvas.Refresh(False)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
197
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
198 def build_menu(self,label = "Miniature"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
199 base_layer_handler.build_menu(self,label)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
200 self.main_menu.AppendSeparator()
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
201 self.main_menu.Append(SHOW_LABELS_TOOL, "&Show Labels", '', 1)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
202 self.main_menu.Check(SHOW_LABELS_TOOL, self.canvas.layers['miniatures'].show_labels)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
203 self.main_menu.Append(AUTO_LABEL_TOOL,"&Auto label","",1)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
204 self.main_menu.Check(AUTO_LABEL_TOOL, self.auto_label)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
205 self.main_menu.Append(SERIAL_TOOL,"&Number minis","",1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
206 self.main_menu.Check(SERIAL_TOOL, self.use_serial)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
207 self.main_menu.Append(MAP_REFRESH_MINI_URLS,"&Refresh miniatures") # Add the menu item
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
208 self.main_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
209 self.main_menu.Append(MIN_MOVE, "Move")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
210 self.canvas.Bind(wx.EVT_MENU, self.on_map_board_menu_item, id=MAP_REFRESH_MINI_URLS) # Set the handler
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
211 self.canvas.Bind(wx.EVT_MENU, self.on_show_labels, id=SHOW_LABELS_TOOL)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
212 self.canvas.Bind(wx.EVT_MENU, self.on_auto_label, id=AUTO_LABEL_TOOL)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
213 self.canvas.Bind(wx.EVT_MENU, self.on_serial, id=SERIAL_TOOL)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
214 # build miniature meenu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
215 self.min_menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
216 # Rectangles and hexagons require slightly different menus because of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
217 # facing and heading possibilities.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
218 heading_menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
219 face_menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
220 face_menu.Append(MIN_FACING_NONE,"&None")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
221 face_menu.Append(MIN_FACING_NORTH,"&North")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
222 face_menu.Append(MIN_FACING_NORTHEAST,"Northeast")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
223 face_menu.Append(MIN_FACING_EAST,"East")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
224 face_menu.Append(MIN_FACING_SOUTHEAST,"Southeast")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
225 face_menu.Append(MIN_FACING_SOUTH,"&South")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
226 face_menu.Append(MIN_FACING_SOUTHWEST,"Southwest")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
227 face_menu.Append(MIN_FACING_WEST,"West")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
228 face_menu.Append(MIN_FACING_NORTHWEST,"Northwest")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
229 heading_menu.Append(MIN_HEADING_NONE,"&None")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
230 heading_menu.Append(MIN_HEADING_NORTH,"&North")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
231 heading_menu.Append(MIN_HEADING_NORTHEAST,"Northeast")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
232 heading_menu.Append(MIN_HEADING_EAST,"East")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
233 heading_menu.Append(MIN_HEADING_SOUTHEAST,"Southeast")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
234 heading_menu.Append(MIN_HEADING_SOUTH,"&South")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
235 heading_menu.Append(MIN_HEADING_SOUTHWEST,"Southwest")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
236 heading_menu.Append(MIN_HEADING_WEST,"West")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
237 heading_menu.Append(MIN_HEADING_NORTHWEST,"Northwest")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
238 align_menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
239 align_menu.Append(MIN_ALIGN_GRID_CENTER,"&Center")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
240 align_menu.Append(MIN_ALIGN_GRID_TL,"&Top-Left")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
241 # This is a hack to simulate a menu title, due to problem in Linux
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
242 if wx.Platform == '__WXMSW__': self.min_menu.SetTitle(label)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
243 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
244 self.min_menu.Append(MIN_TITLE_HACK,label)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
245 self.min_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
246 self.min_menu.Append(MIN_SHOW_HIDE,"Show / Hide")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
247 self.min_menu.Append(MIN_LOCK_UNLOCK, "Lock / Unlock")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
248 self.min_menu.Append(MIN_REMOVE,"&Remove")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
249 self.min_menu.Append(MIN_TO_GAMETREE,"To &Gametree")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
250 self.min_menu.AppendMenu(MIN_HEADING_SUBMENU,"Set &Heading",heading_menu)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
251 self.min_menu.AppendMenu(MIN_FACING_SUBMENU,"Set &Facing",face_menu)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
252 self.min_menu.AppendMenu(MIN_ALIGN_SUBMENU,"Snap-to &Alignment",align_menu)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
253 self.min_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
254 zorder_menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
255 zorder_menu.Append(MIN_BACK_ONE,"Back one")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
256 zorder_menu.Append(MIN_FORWARD_ONE,"Forward one")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
257 zorder_menu.Append(MIN_TO_BACK,"To back")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
258 zorder_menu.Append(MIN_TO_FRONT,"To front")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
259 zorder_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
260 zorder_menu.Append(MIN_LOCK_BACK,"Lock to back")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
261 zorder_menu.Append(MIN_LOCK_FRONT,"Lock to front")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
262 zorder_menu.Append(MIN_FRONTBACK_UNLOCK,"Unlock Front/Back")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
263 self.min_menu.AppendMenu(MIN_ZORDER_SUBMENU, "Miniature Z-Order",zorder_menu)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
264 #self.min_menu.Append(MIN_LOCK,"&Lock")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
265 self.min_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
266 self.min_menu.Append(MIN_PROP_DLG,"&Properties")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
267 self.min_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
268 self.min_menu.Append(MIN_MOVE, "Move")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
269 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_MOVE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
270 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_SHOW_HIDE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
271 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_LOCK_UNLOCK)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
272 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_REMOVE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
273 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_TO_GAMETREE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
274 #self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_LOCK)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
275 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_PROP_DLG)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
276 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FACING_NONE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
277 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FACING_EAST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
278 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FACING_WEST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
279 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FACING_NORTH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
280 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FACING_SOUTH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
281 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FACING_NORTHEAST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
282 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FACING_SOUTHEAST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
283 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FACING_SOUTHWEST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
284 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FACING_NORTHWEST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
285 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_HEADING_NONE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
286 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_HEADING_EAST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
287 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_HEADING_WEST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
288 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_HEADING_NORTH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
289 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_HEADING_SOUTH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
290 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_HEADING_NORTHEAST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
291 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_HEADING_SOUTHEAST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
292 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_HEADING_SOUTHWEST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
293 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_HEADING_NORTHWEST)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
294 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_ALIGN_GRID_CENTER)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
295 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_ALIGN_GRID_TL)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
296 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_BACK_ONE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
297 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FORWARD_ONE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
298 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_TO_BACK)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
299 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_TO_FRONT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
300 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_LOCK_BACK)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
301 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_LOCK_FRONT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
302 self.canvas.Bind(wx.EVT_MENU, self.on_min_menu_item, id=MIN_FRONTBACK_UNLOCK)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
303 ######### add plugin added menu items #########
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
304 if len(self.mini_rclick_menu_extra_items)>0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
305 self.min_menu.AppendSeparator()
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
306 for item in self.mini_rclick_menu_extra_items.items(): self.min_menu.Append(item[1], item[0])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
307 if len(self.background_rclick_menu_extra_items)>0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
308 self.main_menu.AppendSeparator()
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
309 for item in self.background_rclick_menu_extra_items.items(): self.main_menu.Append(item[1], item[0])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
310
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
311 def do_min_menu(self,pos):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
312 self.canvas.PopupMenu(self.min_menu,pos)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
313
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
314 def do_min_select_menu(self, min_list, pos):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
315 # to prevent another event being processed
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
316 self.lastMenuChoice = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
317 self.min_select_menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
318 self.min_select_menu.SetTitle("Select Miniature")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
319 loop_count = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
320 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
321 for m in min_list:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
322 # Either use the miniatures label for the selection list
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
323 if m.label: self.min_select_menu.Append(loop_count, m.label)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
324 # Or use part of the images filename as an identifier
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
325 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
326 string_split = string.split(m.path,"/",)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
327 last_string = string_split[len(string_split)-1]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
328 self.min_select_menu.Append(loop_count, 'Unlabeled - ' + last_string[:len(last_string)-4])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
329 self.canvas.Bind(wx.EVT_MENU, self.min_selected, id=loop_count)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
330 loop_count += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
331 self.canvas.PopupMenu(self.min_select_menu,pos)
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
332 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
333
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
334 def min_selected(self,evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
335 # this is the callback function for the menu that is used to choose
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
336 # between minis when you right click, left click or left double click
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
337 # on a stack of two or more
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
338 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
339 self.canvas.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
340 self.lastMenuChoice = evt.GetId()-1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
341
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
342 def on_min_menu_item(self,evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
343 id = evt.GetId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
344 if id == MIN_MOVE:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
345 if self.sel_min:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
346 self.moveSelectedMini(self.last_rclick_pos)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
347 self.deselectAndRefresh()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
348 return
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
349 elif id == MIN_REMOVE: self.canvas.layers['miniatures'].del_miniature(self.sel_rmin)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
350 elif id == MIN_TO_GAMETREE:
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
351 ### Alpha ### implements ElementTree
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
352 mini = self.sel_rmin.toxml(action="new")
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
353 node = Element('nodehandler')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
354 node.set('module', 'map_miniature_nodehandler')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
355 node.set('class', 'map_miniature_handler')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
356 name = self.sel_rmin.label if self.sel_rmin.label else 'Unnamed Miniature'
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
357 node.set('name', name)
183
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 152
diff changeset
358 node.append(fromstring(mini))
0d9b746b5751 Traipse Beta 'OpenRPG' {100115-00}
sirebral
parents: 152
diff changeset
359 gametree = component.get('tree_fs')
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
360 gametree.insert_xml(tostring(node))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
361 ### ElementTree is a nice decision from Core, kudos!! ###
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
362 elif id == MIN_SHOW_HIDE:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
363 if self.sel_rmin.hide: self.sel_rmin.hide = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
364 else: self.sel_rmin.hide = 1
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
365 elif id == MIN_LOCK_UNLOCK:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
366 if self.sel_rmin.locked: self.sel_rmin.locked = False
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
367 else: self.sel_rmin.locked = True
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
368 if self.sel_rmin == self.sel_min:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
369 # when we lock / unlock the selected mini make sure it isn't still selected
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
370 # or it might easily get moved by accident and be hard to move back
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
371 self.sel_min.selected = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
372 self.sel_min.isUpdated = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
373 self.sel_min = None
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
374 recycle_bin = {MIN_HEADING_NONE: FACE_NONE, MIN_HEADING_NORTH: FACE_NORTH,
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
375 MIN_HEADING_NORTHWEST: FACE_NORTHWEST, MIN_HEADING_NORTHEAST: FACE_NORTHEAST,
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
376 MIN_HEADING_EAST: FACE_EAST, MIN_HEADING_SOUTHEAST: FACE_SOUTHEAST, MIN_HEADING_SOUTHWEST: FACE_SOUTHWEST,
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
377 MIN_HEADING_SOUTH: FACE_SOUTH, MIN_HEADING_WEST: FACE_WEST}
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
378 if recycle_bin.has_key(id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
379 self.sel_rmin.heading = recycle_bin[id]
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
380 del recycle_bin
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
381 recycle_bin = {MIN_FACING_NONE: FACE_NONE, MIN_FACING_NORTH: FACE_NORTH,
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
382 MIN_FACING_NORTHWEST: FACE_NORTHWEST, MIN_FACING_NORTHEAST: FACE_NORTHEAST,
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
383 MIN_FACING_EAST: FACE_EAST, MIN_FACING_SOUTHEAST: FACE_SOUTHEAST, MIN_FACING_SOUTHWEST: FACE_SOUTHWEST,
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
384 MIN_FACING_SOUTH: FACE_SOUTH, MIN_FACING_WEST: FACE_WEST}
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
385 if recycle_bin.has_key(id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
386 self.sel_rmin.face = recycle_bin[id]
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
387 del recycle_bin
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
388 elif id == MIN_ALIGN_GRID_CENTER: self.sel_rmin.snap_to_align = SNAPTO_ALIGN_CENTER
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
389 elif id == MIN_ALIGN_GRID_TL: self.sel_rmin.snap_to_align = SNAPTO_ALIGN_TL
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
390 elif id == MIN_PROP_DLG:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
391 old_lock_value = self.sel_rmin.locked
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
392 dlg = min_edit_dialog(self.canvas.frame.GetParent(),self.sel_rmin)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
393 if dlg.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
394 if self.sel_rmin == self.sel_min and self.sel_rmin.locked != old_lock_value:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
395 # when we lock / unlock the selected mini make sure it isn't still selected
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
396 # or it might easily get moved by accident and be hard to move back
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
397 self.sel_min.selected = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
398 self.sel_min.isUpdated = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
399 self.sel_min = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
400 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
401 self.canvas.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
402 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
403
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
404 elif id == MIN_BACK_ONE:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
405 # This assumes that we always start out with a z-order
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
406 # that starts at 0 and goes up to the number of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
407 # minis - 1. If this isn't the case, then execute
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
408 # a self.canvas.layers['miniatures'].collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
409 # before getting the oldz to test
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
410 # Save the selected minis current z-order
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
411 oldz = self.sel_rmin.zorder
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
412 # Make sure the mini isn't sticky front or back
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
413 if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
414 self.sel_rmin.zorder -= 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
415 # Re-collapse to normalize
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
416 # Note: only one update (with the final values) will be sent
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
417 self.canvas.layers['miniatures'].collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
418
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
419 elif id == MIN_FORWARD_ONE:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
420 # This assumes that we always start out with a z-order
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
421 # that starts at 0 and goes up to the number of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
422 # minis - 1. If this isn't the case, then execute
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
423 # a self.canvas.layers['miniatures'].collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
424 # before getting the oldz to test
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
425 # Save the selected minis current z-order
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
426 oldz = self.sel_rmin.zorder
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
427 self.sel_rmin.zorder += 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
428
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
429 # Re-collapse to normalize
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
430 # Note: only one update (with the final values) will be sent
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
431 self.canvas.layers['miniatures'].collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
432
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
433 elif id == MIN_TO_FRONT:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
434 # This assumes that we always start out with a z-order
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
435 # that starts at 0 and goes up to the number of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
436 # minis - 1. If this isn't the case, then execute
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
437 # a self.canvas.layers['miniatures'].collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
438 # before getting the oldz to test
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
439 # Save the selected minis current z-order
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
440 oldz = self.sel_rmin.zorder
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
441
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
442 # Make sure the mini isn't sticky front or back
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
443 if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
444 # The new z-order will be one more than the last index
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
445 newz = len(self.canvas.layers['miniatures'].miniatures)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
446 self.sel_rmin.zorder = newz
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
447 # Re-collapse to normalize
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
448 # Note: only one update (with the final values) will be sent
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
449 self.canvas.layers['miniatures'].collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
450
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
451 elif id == MIN_TO_BACK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
452 # This assumes that we always start out with a z-order
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
453 # that starts at 0 and goes up to the number of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
454 # minis - 1. If this isn't the case, then execute
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
455 # a self.canvas.layers['miniatures'].collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
456 # before getting the oldz to test
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
457 # Save the selected minis current z-order
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
458 oldz = self.sel_rmin.zorder
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
459 # Make sure the mini isn't sticky front or back
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
460 if (oldz != MIN_STICKY_BACK) and (oldz != MIN_STICKY_FRONT):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
461
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
462 # Since 0 is the lowest in a normalized order, be one less
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
463 newz = -1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
464 self.sel_rmin.zorder = newz
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
465 # Re-collapse to normalize
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
466 # Note: only one update (with the final values) will be sent
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
467 self.canvas.layers['miniatures'].collapse_zorder()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
468
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
469 elif id == MIN_FRONTBACK_UNLOCK:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
470 if self.sel_rmin.zorder == MIN_STICKY_BACK: self.sel_rmin.zorder = MIN_STICKY_BACK + 1
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
471 elif self.sel_rmin.zorder == MIN_STICKY_FRONT: self.sel_rmin.zorder = MIN_STICKY_FRONT - 1
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
472 elif id == MIN_LOCK_BACK: self.sel_rmin.zorder = MIN_STICKY_BACK
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
473 elif id == MIN_LOCK_FRONT: self.sel_rmin.zorder = MIN_STICKY_FRONT
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
474 # Pretty much, we always want to refresh when we go through here
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
475 # This helps us remove the redundant self.Refresh() on EVERY menu event
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
476 # that we process above.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
477 self.sel_rmin.isUpdated = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
478 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
479 self.canvas.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
480
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
481 def on_miniature(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
482 session = self.canvas.frame.session
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
483 if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER) and (session.use_roles()):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
484 self.infoPost("You must be either a player or GM to use the miniature Layer")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
485 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
486 min_url = self.min_url.GetValue()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
487 # build url
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
488 if min_url == "" or min_url == "http://": return
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
489 if min_url[:7] != "http://" : min_url = "http://" + min_url
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
490 # make label
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
491 if self.auto_label and min_url[-4:-3] == '.':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
492 start = min_url.rfind("/") + 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
493 min_label = min_url[start:len(min_url)-4]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
494 if self.use_serial:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
495 min_label = '%s %d' % ( min_label, self.canvas.layers['miniatures'].next_serial() )
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
496 else: min_label = ""
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
497 if self.min_url.FindString(min_url) == -1: self.min_url.Append(min_url)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
498 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
499 id = 'mini-' + self.canvas.frame.session.get_next_id()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
500 # make the new mini appear in top left of current viewable map
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
501 dc = wx.ClientDC(self.canvas)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
502 self.canvas.PrepareDC(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
503 dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
504 x = dc.DeviceToLogicalX(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
505 y = dc.DeviceToLogicalY(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
506 self.canvas.layers['miniatures'].add_miniature(id, min_url, pos=cmpPoint(x,y), label=min_label)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
507 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
508 # When there is an exception here, we should be decrementing the serial_number for reuse!!
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
509 unablemsg= "Unable to load/resolve URL: " + min_url + " on resource \"" + min_label + "\"!!!\n\n"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
510 dlg = wx.MessageDialog(self,unablemsg, 'Url not found',wx.ICON_EXCLAMATION)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
511 dlg.ShowModal()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
512 dlg.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
513 self.canvas.layers['miniatures'].rollback_serial()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
514 self.canvas.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
515 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
516 #except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
517 #wx.MessageBox(str(e),"Miniature Error")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
518
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
519 def on_show_labels(self, evt):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
520 show_labels = not self.canvas.layers['miniatures'].show_labels
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
521 self.canvas.layers['miniatures'].show_labels = show_labels
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
522 self.canvas.Refresh()
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
523
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
524 def on_auto_label(self,evt):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
525 self.auto_label = not self.auto_label
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
526 #self.auto_label_cb.SetValue(self.auto_label)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
527 #self.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
528 #self.Refresh()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
529
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
530 def on_min_list(self,evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
531 session = self.canvas.frame.session
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
532 if (session.my_role() != session.ROLE_GM):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
533 self.infoPost("You must be a GM to use this feature")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
534 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
535 #d = min_list_panel(self.frame.GetParent(),self.canvas.layers,"Miniature list")
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
536 d = min_list_panel(self.canvas.frame, self.canvas.layers, "Miniature list")
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
537 if d.ShowModal() == wx.ID_OK: d.Destroy()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
538 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
539
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
540 def on_serial(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
541 self.use_serial = not self.use_serial
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
542
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
543 def on_map_board_menu_item(self,evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
544 id = evt.GetId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
545 if id == MAP_REFRESH_MINI_URLS: # Note: this doesn't change the mini, so no need to update the map
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
546 for mini in self.canvas.layers['miniatures'].miniatures: # For all minis
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
547 mini.set_bmp(ImageHandler.load(mini.path, 'miniature', mini.id)) # Reload their bmp member
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
548 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
549
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
550 ####################################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
551 ## old functions, changed an awful lot
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
552
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
553 def on_left_down(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
554 if not self.role_is_gm_or_player() or self.alreadyDealingWithMenu(): return
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
555 mini = self.find_mini(evt, evt.CmdDown() and self.role_is_gm())
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
556 if mini:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
557 deselecting_selected_mini = (mini == self.sel_min) #clicked on the selected mini
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
558 self.deselectAndRefresh()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
559 self.drag_mini = mini
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
560 if deselecting_selected_mini: return
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
561 self.sel_min = mini
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
562 self.sel_min.selected = True
7
2b9e766f9dee Tests fixes issues with Linux GUI effecting miniatures
sirebral
parents: 0
diff changeset
563 self.canvas.Refresh()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
564 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
565 self.drag_mini = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
566 pos = self.getLogicalPosition(evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
567 self.moveSelectedMini(pos)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
568 self.deselectAndRefresh()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
569
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
570 def on_right_down(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
571 if not self.role_is_gm_or_player() or self.alreadyDealingWithMenu(): return
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
572 self.last_rclick_pos = self.getLogicalPosition(evt)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
573 mini = self.find_mini(evt, evt.CmdDown() and self.role_is_gm())
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
574 if mini:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
575 self.sel_rmin = mini
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
576 if self.sel_min: self.min_menu.Enable(MIN_MOVE, True)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
577 else: self.min_menu.Enable(MIN_MOVE, False)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
578 self.prepare_mini_rclick_menu(evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
579 self.do_min_menu(evt.GetPosition())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
580 else:# pass it on
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
581 if self.sel_min: self.main_menu.Enable(MIN_MOVE, True)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
582 else: self.main_menu.Enable(MIN_MOVE, False)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
583 self.prepare_background_rclick_menu(evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
584 base_layer_handler.on_right_down(self, evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
585
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
586 ####################################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
587 ## new functions
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
588
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
589 def on_drop_files(self, x, y, filepaths):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
590 # currently we ignore multiple files
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
591 filepath = filepaths[0]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
592 start1 = filepath.rfind("\\") + 1 # check for both slashes in path to be on the safe side
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
593 start2 = filepath.rfind("/") + 1
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
594 if start1 < start2: start1 = start2
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
595 filename = filepath[start1:]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
596 pos = filename.rfind('.')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
597 ext = filename[pos:].lower()
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
598 #ext = filename[-4:].lower()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
599 if(ext != ".bmp" and ext != ".gif" and ext != ".jpg" and ext != ".jpeg" and ext != ".png"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
600 self.infoPost("Supported file extensions are: *.bmp, *.gif, *.jpg, *.jpeg, *.png")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
601 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
602 file = open(filepath, "rb")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
603 imgdata = file.read()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
604 file.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
605 dc = wx.ClientDC(self.canvas)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
606 self.canvas.PrepareDC(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
607 dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
608 x = dc.DeviceToLogicalX(x)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
609 y = dc.DeviceToLogicalY(y)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
610 (imgtype,j) = mimetypes.guess_type(filename)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
611 postdata = urllib.urlencode({'filename':filename, 'imgdata':imgdata, 'imgtype':imgtype})
92
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
612 if self.settings.get_setting('LocalorRemote') == 'Remote':
68c7bd272f27 Traipse Beta 'OpenRPG' {090919-00}
sirebral
parents: 76
diff changeset
613 thread.start_new_thread(self.canvas.layers['miniatures'].upload, (postdata, filepath), {'pos':cmpPoint(x,y)})
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
614 else: self.CherryPit(filepath, '')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
615
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
616 def on_tooltip_timer(self, *args):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
617 pos = args[0]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
618 dc = wx.ClientDC(self.canvas)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
619 self.canvas.PrepareDC(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
620 dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
621 pos = wx.Point(dc.DeviceToLogicalX(pos.x), dc.DeviceToLogicalY(pos.y))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
622 mini_list = self.getMiniListOrSelectedMini(pos)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
623 if len(mini_list) > 0:
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
624 tooltip = mini_list[0].label
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
625 #self.canvas.SetToolTipString(mini_list[0].label)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
626 #Once set, it never unsets, so it sucks.
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 140
diff changeset
627 else: self.canvas.SetToolTipString('')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
628
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
629 def on_motion(self,evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
630 if evt.Dragging() and evt.LeftIsDown():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
631 if self.canvas.drag is None and self.drag_mini is not None:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
632 drag_bmp = self.drag_mini.bmp
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
633 if self.drag_mini.width and self.drag_mini.height:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
634 tmp_image = drag_bmp.ConvertToImage()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
635 tmp_image.ConvertAlphaToMask()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
636 drag_bmp = tmp_image.ConvertToBitmap()
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
637 mask = wx.Mask(drag_bmp, wx.Colour(tmp_image.GetMaskRed(),
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
638 tmp_image.GetMaskGreen(), tmp_image.GetMaskBlue()))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
639 drag_bmp.SetMask(mask)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
640 tmp_image = tmp_image.ConvertToGreyscale()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
641 self.drag_mini.gray = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
642 self.drag_mini.isUpdated = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
643 def refresh():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
644 self.canvas.drag.Hide()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
645 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
646 wx.CallAfter(refresh)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
647 self.canvas.drag = wx.DragImage(drag_bmp)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
648 self.drag_offset = self.getLogicalPosition(evt)- self.drag_mini.pos
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
649 self.canvas.drag.BeginDrag((int(self.drag_offset.x * self.canvas.layers['grid'].mapscale),
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
650 int(self.drag_offset.y * self.canvas.layers['grid'].mapscale)), self.canvas, False)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
651 elif self.canvas.drag is not None:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
652 self.canvas.drag.Move(evt.GetPosition())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
653 self.canvas.drag.Show()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
654 # reset tool tip timer
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
655 self.canvas.SetToolTipString('')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
656 self.tooltip_timer.Restart(self.tooltip_delay_miliseconds, evt.GetPosition())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
657
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
658 def on_left_up(self,evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
659 if self.canvas.drag:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
660 self.canvas.drag.Hide()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
661 self.canvas.drag.EndDrag()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
662 self.canvas.drag = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
663 pos = self.getLogicalPosition(evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
664 pos = pos - self.drag_offset
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
665 if self.canvas.layers['grid'].snap:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
666 nudge = int(self.canvas.layers['grid'].unit_size/2)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
667 if self.canvas.layers['grid'].mode != GRID_ISOMETRIC:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
668 if self.drag_mini.snap_to_align == SNAPTO_ALIGN_CENTER:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
669 pos = pos + (int(self.drag_mini.bmp.GetWidth()/2),int(self.drag_mini.bmp.GetHeight()/2))
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
670 else: pos = pos + (nudge, nudge)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
671 else:# GRID_ISOMETRIC
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
672 if self.drag_mini.snap_to_align == SNAPTO_ALIGN_CENTER:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
673 pos = pos + (int(self.drag_mini.bmp.GetWidth()/2), self.drag_mini.bmp.GetHeight())
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
674 else: pass # no nudge for the isomorphic / top-left
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
675 self.sel_min = self.drag_mini
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
676 # check to see if the mouse is inside the window still
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
677 w = self.canvas.GetClientSizeTuple() # this is the window size, minus any scrollbars
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
678 p = evt.GetPosition() # compare the window size, w with the non-logical position
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
679 c = self.canvas.size # this is the grid size, compare with the logical position, pos
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
680 # both are [width, height]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
681 if p.x>=0 and pos.x<c[0] and p.x<w[0] and p.y>=0 and pos.y<c[1] and p.y<w[1]:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
682 self.moveSelectedMini(pos)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
683 self.sel_min.gray = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
684 self.sel_min.selected = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
685 self.sel_min.isUpdated = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
686 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
687 self.canvas.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
688 self.sel_min = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
689 self.drag_mini = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
690
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
691 def on_left_dclick(self,evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
692 if not self.role_is_gm_or_player() or self.alreadyDealingWithMenu(): return
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 12
diff changeset
693 mini = self.find_mini(evt, evt.CmdDown() and self.role_is_gm())
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
694 if mini: self.on_mini_dclick(evt, mini)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
695 else: base_layer_handler.on_left_dclick(self, evt)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
696
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
697
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
698 ####################################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
699 ## hook functions (although with python you can override any of the functions)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
700
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
701 def prepare_mini_rclick_menu(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
702 # override the entire right-click on a mini menu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
703 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
704
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
705 def prepare_background_rclick_menu(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
706 # override the entire right-click on the map menu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
707 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
708
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
709 def get_mini_tooltip(self, mini_list):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
710 # override to create a tooltip
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
711 return ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
712
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
713 def on_mini_dclick(self, evt, mini):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
714 # do something after the mini was left double clicked
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
715 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
716
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
717 ####################################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
718 ## easy way to add a single menu item
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
719
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
720 def set_mini_rclick_menu_item(self, label, callback_function):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
721 # remember you might want to call these at the end of your callback function:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
722 # mini_handler.sel_rmin.isUpdated = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
723 # canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
724 # canvas.send_map_data()
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
725 if callback_function == None: del self.mini_rclick_menu_extra_items[label]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
726 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
727 if not self.mini_rclick_menu_extra_items.has_key(label):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
728 self.mini_rclick_menu_extra_items[label]=wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
729 menu_id = self.mini_rclick_menu_extra_items[label]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
730 self.canvas.Bind(wx.EVT_MENU, callback_function, id=menu_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
731 self.build_menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
732
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
733 def set_background_rclick_menu_item(self, label, callback_function):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
734 if callback_function == None: del self.background_rclick_menu_extra_items[label]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
735 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
736 if not self.background_rclick_menu_extra_items.has_key(label):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
737 self.background_rclick_menu_extra_items[label]=wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
738 menu_id = self.background_rclick_menu_extra_items[label]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
739 self.canvas.Bind(wx.EVT_MENU, callback_function, id=menu_id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
740 self.build_menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
741
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
742
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
743 ####################################################################
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
744 ## helper functions
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
745
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
746 def infoPost(self, message):
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 59
diff changeset
747 component.get("chat").InfoPost(message)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
748
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
749 def role_is_gm_or_player(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
750 session = self.canvas.frame.session
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
751 if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER) and (session.use_roles()):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
752 self.infoPost("You must be either a player or GM to use the miniature Layer")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
753 return False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
754 return True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
755
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
756 def role_is_gm(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
757 session = self.canvas.frame.session
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 94
diff changeset
758 if (session.my_role() != session.ROLE_GM) and (session.use_roles()): return False
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
759 return True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
760
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
761 def alreadyDealingWithMenu(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
762 return self.lastMenuChoice is not None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
763
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
764 def getLastMenuChoice(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
765 choice = self.lastMenuChoice
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
766 self.lastMenuChoice = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
767 return choice
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
768
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
769 def getLogicalPosition(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
770 dc = wx.ClientDC(self.canvas)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
771 self.canvas.PrepareDC(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
772 dc.SetUserScale(self.canvas.layers['grid'].mapscale,self.canvas.layers['grid'].mapscale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
773 pos = evt.GetLogicalPosition(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
774 return pos
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
775
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
776 def getMiniListOrSelectedMini(self, pos, include_locked=False):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
777 if self.sel_min and self.sel_min.hit_test(pos):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
778 # clicked on the selected mini - assume that is the intended target
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
779 # and don't give a choice of it and any other minis stacked with it
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
780 mini_list = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
781 mini_list.append(self.sel_min)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
782 return mini_list
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
783 mini_list = self.canvas.layers['miniatures'].find_miniature(pos, (not include_locked))
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
784 if mini_list: return mini_list
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
785 mini_list = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
786 return mini_list
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
787
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
788 def deselectAndRefresh(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
789 if self.sel_min:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
790 self.sel_min.selected = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
791 self.sel_min.isUpdated = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
792 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
793 self.canvas.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
794 self.sel_min = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
795
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
796 def moveSelectedMini(self, pos):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
797 if self.sel_min: self.moveMini(pos, self.sel_min)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
798
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
799 def moveMini(self, pos, mini):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
800 grid = self.canvas.layers['grid']
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
801 mini.pos = grid.get_snapped_to_pos(pos, mini.snap_to_align, mini.bmp.GetWidth(), mini.bmp.GetHeight())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
802
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
803 def find_mini(self, evt, include_locked):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
804 if not self.role_is_gm_or_player() or self.alreadyDealingWithMenu(): return
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
805 pos = self.getLogicalPosition(evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
806 mini_list = self.getMiniListOrSelectedMini(pos, include_locked)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
807 mini = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
808 if len(mini_list) > 1:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
809 try: self.do_min_select_menu(mini_list, evt.GetPosition())
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
810 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
811 choice = self.getLastMenuChoice()
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
812 if choice == None: return None # left menu without making a choice, eg by clicking outside menu
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
813 mini = mini_list[choice]
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
814 elif len(mini_list) == 1: mini = mini_list[0]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
815 return mini
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
816