annotate orpg/mapper/map.py @ 195:b633f4c64aae alpha

Traipse Alpha 'OpenRPG' {100219-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Patch-2) New Features: New Namespace method with two new syntaxes 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
author sirebral
date Sat, 24 Apr 2010 08:37:20 -0500
parents ff19dd30064b
children 0ccfb8836b81
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/map.py
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
21 # Author: OpenRPG
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:
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 178
diff changeset
24 # $Id: map.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:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27 #
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents: 178
diff changeset
28 __version__ = "$Id: map.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 map_version import MAP_VERSION
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
31 from map_msg import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
32 from min_dialogs import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
33 from map_prop_dialog import *
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
34
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 147
diff changeset
35 import random, os, thread, traceback
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
36
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
37 from miniatures_handler import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
38 from whiteboard_handler import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
39 from background_handler import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
40 from grid_handler import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
41 from map_handler import *
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
42 from fog_handler import *
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
43
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
44 from orpg.dirpath import dir_struct
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
45 from images import ImageHandler
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
46 from orpg.orpgCore import component
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
47 from orpg.tools.orpg_settings import settings
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
48
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
49 # Various marker modes for player tools on the map
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
50 MARKER_MODE_NONE = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
51 MARKER_MODE_MEASURE = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
52 MARKER_MODE_TARGET = 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
53 MARKER_MODE_AREA_TARGET = 3
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
54
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
55 class MapCanvas(wx.ScrolledWindow):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
56 def __init__(self, parent, ID, isEditor=0):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 self.parent = parent
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
58 self.session = component.get("session")
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
59 wx.ScrolledWindow.__init__(self, parent, ID,
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
60 style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
61 self.frame = parent
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
62 self.MAP_MODE = 1 #Mode 1 = MINI, 2 = DRAW, 3 = TAPE MEASURE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
63 self.layers = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
64 self.layers['bg'] = layer_back_ground(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
65 self.layers['grid'] = grid_layer(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
66 self.layers['whiteboard'] = whiteboard_layer(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
67 self.layers['miniatures'] = miniature_layer(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
68 self.layers['fog'] = fog_layer(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
69 self.Bind(wx.EVT_ERASE_BACKGROUND, self.on_erase_background)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
70 self.Bind(wx.EVT_PAINT, self.on_paint)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
71 self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
72 self.Bind(wx.EVT_LEFT_DCLICK, self.on_left_dclick)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
73 self.Bind(wx.EVT_LEFT_UP, self.on_left_up)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
74 self.Bind(wx.EVT_RIGHT_DOWN, self.on_right_down)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
75 self.Bind(wx.EVT_MOTION, self.on_motion)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
76 self.Bind(wx.EVT_SCROLLWIN, self.on_scroll)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
77 self.Bind(wx.EVT_CHAR, self.on_char)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
78 self.Bind(wx.EVT_SIZE, self.on_resize)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
79 self.set_size((1000,1000))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80 self.root_dir = os.getcwd()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
81 self.size_change = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
82 self.isEditor = isEditor
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
83 self.map_version = MAP_VERSION
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
84 self.cacheSize = 32
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
85 # Create the marker mode attributes for the map
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
86 self.markerMode = MARKER_MODE_NONE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
87 self.markerStart = wx.Point( -1, -1 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
88 self.markerStop = wx.Point( -1, -1 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
89 self.markerMidpoint = wx.Point( -1, -1 )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
90 self.markerAngle = 0.0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
91 # Optimization of map refreshing during busy map load
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
92 self.lastRefreshValue = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
93 self.requireRefresh = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
94 self.lastRefreshTime = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
95 self.zoom_display_timer = wx.Timer(self, wx.NewId())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
96 self.Bind(wx.EVT_TIMER, self.better_refresh, self.zoom_display_timer)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
97 random.seed( time.time() )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
98 self.image_timer = wx.Timer(self, wx.NewId())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
99 self.Bind(wx.EVT_TIMER, self.processImages, self.image_timer)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
100 self.image_timer.Start(100)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
101 # Used to check if we've used the user cache size value
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
102 self.cacheSizeSet = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103 self.inside = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104 # miniatures drag
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
105 self.drag = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
106
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
107 def better_refresh(self, event=None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
108 self.Refresh(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
109
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
110 def pre_destory_cleanup(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
111 self.layers["miniatures"].del_all_miniatures()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
112
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
113 def processImages(self, evt=None):
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
114 self.session = component.get("session")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
115 if self.session.my_role() == self.session.ROLE_LURKER or (str(self.session.group_id) == '0' and str(self.session.status) == '1'):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
116 cidx = self.parent.get_tab_index("Background")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
117 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
118 cidx = self.parent.get_tab_index("Grid")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
119 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
120 cidx = self.parent.get_tab_index("Miniatures")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
121 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
122 cidx = self.parent.get_tab_index("Whiteboard")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
123 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
124 cidx = self.parent.get_tab_index("Fog")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
125 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
126 cidx = self.parent.get_tab_index("General")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
127 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
128 else:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
129 cidx = self.parent.get_tab_index("Background")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
130 if not self.parent.layer_tabs.GetEnabled(cidx):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
131 cidx = self.parent.get_tab_index("Miniatures")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
132 self.parent.layer_tabs.EnableTab(cidx, True)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
133 cidx = self.parent.get_tab_index("Whiteboard")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
134 self.parent.layer_tabs.EnableTab(cidx, True)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
135 cidx = self.parent.get_tab_index("Background")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
136 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
137 cidx = self.parent.get_tab_index("Grid")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
138 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
139 cidx = self.parent.get_tab_index("Fog")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
140 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
141 cidx = self.parent.get_tab_index("General")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
142 self.parent.layer_tabs.EnableTab(cidx, False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
143 if self.session.my_role() == self.session.ROLE_GM:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
144 cidx = self.parent.get_tab_index("Background")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
145 self.parent.layer_tabs.EnableTab(cidx, True)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
146 cidx = self.parent.get_tab_index("Grid")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
147 self.parent.layer_tabs.EnableTab(cidx, True)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
148 cidx = self.parent.get_tab_index("Fog")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
149 self.parent.layer_tabs.EnableTab(cidx, True)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
150 cidx = self.parent.get_tab_index("General")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
151 self.parent.layer_tabs.EnableTab(cidx, True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
152 if not self.cacheSizeSet:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
153 self.cacheSizeSet = True
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
154 cacheSize = component.get('settings').get_setting("ImageCacheSize")
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
155 if len(cacheSize): self.cacheSize = int(cacheSize)
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
156 else: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
157 if not ImageHandler.Queue.empty():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
158 (path, image_type, imageId) = ImageHandler.Queue.get()
177
60dde67c4ed6 Traipse Alpha 'OpenRPG' {100114-00}
sirebral
parents: 159
diff changeset
159 if path == 'failed': img = wx.Image(dir_struct["icon"] + "failed.png", wx.BITMAP_TYPE_PNG)
60dde67c4ed6 Traipse Alpha 'OpenRPG' {100114-00}
sirebral
parents: 159
diff changeset
160 else: img = wx.ImageFromMime(path[1], path[2])
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
161 try:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
162 # Now, apply the image to the proper object
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
163 if image_type == "miniature":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
164 min = self.layers['miniatures'].get_miniature_by_id(imageId)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
165 if min: min.set_bmp(img)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
166 elif image_type == "background" or image_type == "texture":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
167 self.layers['bg'].bg_bmp = img.ConvertToBitmap()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
168 if image_type == "background": self.set_size([img.GetWidth(), img.GetHeight()])
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
169 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
170 # Flag that we now need to refresh!
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
171 self.requireRefresh += 1
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
172
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
173 """ Randomly purge an item from the cache, while this is lamo, it does
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
174 keep the cache from growing without bounds, which is pretty important!"""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
175 if len(ImageHandler.Cache) >= self.cacheSize:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
176 ImageHandler.cleanCache()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
177 else:
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
178 """ Now, make sure not only that we require a refresh, but that enough time has
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
179 gone by since our last refresh. This keeps back to back refreshing occuring during
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
180 large map loads. Of course, we are now trying to pack as many image refreshes as
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
181 we can into a single cycle."""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
182 if self.requireRefresh and (self.requireRefresh == self.lastRefreshValue):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
183 if (self.lastRefreshTime) < time.time():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
184 self.requireRefresh = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
185 self.lastRefreshValue = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
186 self.lastRefreshTime = time.time()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
187 self.Refresh(True)
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
188 else: self.lastRefreshValue = self.requireRefresh
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
189
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
190 def on_scroll(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
191 if self.drag: self.drag.Hide()
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
192 if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
193 evt.Skip()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
194
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
195 def on_char(self, evt):
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
196 if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
197 evt.Skip()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
198
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
199 def printscale(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
200 wx.BeginBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
201 dc = wx.ClientDC(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
202 self.PrepareDC(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
203 self.showmapscale(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
204 self.Refresh(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
205 wx.EndBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
206
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
207 def send_map_data(self, action="update"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
208 wx.BeginBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
209 send_text = self.toxml(action)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
210 if send_text:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
211 if not self.isEditor: self.frame.session.send(send_text)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
212 wx.EndBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
213
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
214 def get_size(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
215 return self.size
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
216
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
217 def set_size(self, size):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
218 if size[0] < 300: size = (300, size[1])
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
219 if size[1] < 300: size = (size[0], 300)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
220 self.size_changed = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
221 self.size = size
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
222 self.fix_scroll()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
223 self.layers['fog'].resize(size)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
224
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
225 def fix_scroll(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
226 scale = self.layers['grid'].mapscale
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
227 pos = self.GetViewStart()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
228 unit = self.GetScrollPixelsPerUnit()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
229 pos = [pos[0]*unit[0],pos[1]*unit[1]]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
230 size = self.GetClientSize()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
231 unit = [10*scale,10*scale]
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
232 if (unit[0] == 0 or unit[1] == 0): return
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
233 pos[0] /= unit[0]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
234 pos[1] /= unit[1]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
235 mx = [int(self.size[0]*scale/unit[0])+1, int(self.size[1]*scale/unit[1]+1)]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
236 self.SetScrollbars(unit[0], unit[1], mx[0], mx[1], pos[0], pos[1])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
237
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
238 def on_resize(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
239 self.fix_scroll()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
240 wx.CallAfter(self.Refresh, True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
241 evt.Skip()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
242
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
243 def on_erase_background(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
244 evt.Skip()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
245
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
246 def on_paint(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
247 scale = self.layers['grid'].mapscale
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
248 scrollsize = self.GetScrollPixelsPerUnit()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
249 clientsize = self.GetClientSize()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
250 topleft1 = self.GetViewStart()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
251 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
252 if (clientsize[0] > 1) and (clientsize[1] > 1):
147
a771ba7b7875 Traipse Alpha 'OpenRPG' {091123-04}
sirebral
parents: 139
diff changeset
253 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 105
diff changeset
254 dc = wx.AutoBufferedPaintDC(self)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
255 dc.SetPen(wx.TRANSPARENT_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
256 dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
257 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
258 dc.SetDeviceOrigin(-topleft[0], -topleft[1])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
259 dc.SetUserScale(scale, scale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
260 self.layers['bg'].layerDraw(dc, scale, topleft, clientsize)
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
261 self.layers['grid'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
262 [clientsize[0]/scale, clientsize[1]/scale])
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
263 self.layers['miniatures'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 14
diff changeset
264 [clientsize[0]/scale, clientsize[1]/scale])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
265 self.layers['whiteboard'].layerDraw(dc)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
266 self.layers['fog'].layerDraw(dc, topleft, clientsize)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
267 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
268 dc.SetBrush(wx.NullBrush)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
269 if settings.get_setting("AlwaysShowMapScale") == "1":
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 105
diff changeset
270 self.showmapscale(dc)
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
271 try: evt.Skip()
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
272 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
273
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
274 def showmapscale(self, dc):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
275 scalestring = "Scale x" + `self.layers['grid'].mapscale`[:3]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
276 (textWidth, textHeight) = dc.GetTextExtent(scalestring)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
277 dc.SetUserScale(1, 1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
278 dc.SetPen(wx.LIGHT_GREY_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
279 dc.SetBrush(wx.LIGHT_GREY_BRUSH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
280 x = dc.DeviceToLogicalX(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
281 y = dc.DeviceToLogicalY(0)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
282 dc.DrawRectangle(x, y, textWidth+2, textHeight+2)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
283 dc.SetPen(wx.RED_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
284 dc.DrawText(scalestring, x+1, y+1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
285 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
286 dc.SetBrush(wx.NullBrush)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
287
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
288 def snapMarker(self, snapPoint):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
289 """Based on the position and unit size, figure out where we need to snap to. As is, on
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
290 a square grid, there are four possible places to snap. On a hex gid, there are 6 or 12 snap
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
291 points."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
292
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
293 # If snap to grid is disabled, simply return snapPoint unmodified
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
294 if self.layers['grid'].snap:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
295 # This means we need to determine where to snap our line. We will support
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
296 # snapping to four different snapPoints per square for now.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
297 # TODO!!!
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
298 if self.layers['grid'].mode == GRID_HEXAGON: size = self.layers['grid'].unit_size_y
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
299 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
300 size = int(self.layers['grid'].unit_size)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
301 # Find the uppper left hand corner of the grid we are to snap to
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
302 offsetX = (snapPoint.x / size) * size
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
303 offsetY = (snapPoint.y / size) * size
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
304 # Calculate the delta value between where we clicked and the square it is near
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
305 deltaX = snapPoint.x - offsetX
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
306 deltaY = snapPoint.y - offsetY
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
307 # Now, figure our what quadrant (x, y) we need to snap to
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
308 snapSize = size / 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
309 # Figure out the X snap placement
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
310 if deltaX <= snapSize: quadXPos = offsetX
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
311 else: quadXPos = offsetX + size
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
312 # Now, figure out the Y snap placement
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
313 if deltaY <= snapSize: quadYPos = offsetY
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
314 else: quadYPos = offsetY + size
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
315 # Create our snap snapPoint and return it
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
316 snapPoint = wx.Point( quadXPos, quadYPos )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
317 return snapPoint
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
318
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
319 # Bunch of math stuff for marking and measuring
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
320 def calcSlope(self, start, stop):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
321 """Calculates the slop of a line and returns it."""
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
322 if start.x == stop.x: s = 0.0001
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
323 else: s = float((stop.y - start.y)) / float((stop.x - start.x))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
324 return s
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
325
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
326 def calcSlopeToAngle(self, slope):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
327 """Based on the input slope, the angle (in degrees) will be returned."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
328 # See if the slope is neg or positive
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
329 if slope == abs(slope):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
330 # Slope is positive, so make sure it's not zero
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
331 if slope == 0: a = 0
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
332 else: a = 360 - atan(slope) * (180.0/pi)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
333 else: a = atan(abs(slope)) * (180.0/pi)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
334 return a
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
335
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
336 def calcLineAngle(self, start, stop):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
337 """Based on two points that are on a line, return the angle of that line."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
338 a = self.calcSlopeToAngle( self.calcSlope( start, stop ) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
339 return a
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
340
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
341 def calcPixelDistance(self, start, stop):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
342 """Calculate the distance between two pixels and returns it. The calculated
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
343 distance is the Euclidean Distance, which is:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
344 d = sqrt( (x2 - x1)**2 + (y2 - y1)**2 )"""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
345 d = sqrt( abs((stop.x - start.x)**2 - (stop.y - start.y)**2) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
346 return d
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
347
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
348 def calcUnitDistance(self, start, stop, lineAngle):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
349 distance = self.calcPixelDistance( start, stop )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
350 ln = "%0.2f" % lineAngle
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
351 if self.layers['grid'].mode == GRID_HEXAGON:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
352 if ln == "0.00" or ln == "359.99": ud = distance / self.layers['grid'].unit_size_y
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
353 else: ud = (sqrt(abs((stop.x - start.x)**2 + (stop.y - start.y)**2))) / self.layers['grid'].unit_size_y
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
354 else:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
355 if ln == "0.00" or ln == "359.99": ud = distance / self.layers['grid'].unit_size
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
356 else: ud = (sqrt(abs((stop.x - start.x)**2 + (stop.y - start.y)**2))) / self.layers['grid'].unit_size
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
357 #ud = sqrt( abs((stop.x - start.x)**2 - (stop.y - start.y)**2) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
358 return ud
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
359
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
360 def on_tape_motion(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
361 """Track mouse motion so we can update the marker visual every time it's moved"""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
362 # Make sure we have a mode to do anything, otherwise, we ignore this
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
363 if self.markerMode:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
364 # Grap the current DC for all of the marker modes
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
365 dc = wx.ClientDC( self )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
366 self.PrepareDC( dc )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
367 dc.SetUserScale(self.layers['grid'].mapscale,self.layers['grid'].mapscale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
368 # Grab the current map position
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
369 pos = self.snapMarker( evt.GetLogicalPosition( dc ) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
370 # Set up the pen used for drawing our marker
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
371 dc.SetPen( wx.Pen(wx.RED, 1, wx.LONG_DASH) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
372 # Now, based on the marker mode, draw the right thing
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
373 if self.markerMode == MARKER_MODE_MEASURE:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
374 if self.markerStop.x != -1 and self.markerStop.y != -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
375 # Set the DC function that we need
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
376 dc.SetLogicalFunction(wx.INVERT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
377 # Erase old and Draw new marker line
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
378 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
379 dc.DrawLine( self.markerStart.x, self.markerStart.y, self.markerStop.x, self.markerStop.y )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
380 dc.DrawLine( self.markerStart.x, self.markerStart.y, pos.x, pos.y )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
381 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
382 # Restore the default DC function
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
383 dc.SetLogicalFunction(wx.COPY)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
384 # As long as we are in marker mode, we ned to update the stop point
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
385 self.markerStop = pos
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
386 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
387 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
388
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
389 def on_tape_down(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
390 """Greg's experimental tape measure code. Hopefully, when this is done, it will all be
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
391 modal based on a toolbar."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
392 dc = wx.ClientDC( self )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
393 self.PrepareDC( dc )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
394 dc.SetUserScale(self.layers['grid'].mapscale,self.layers['grid'].mapscale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
395 pos = evt.GetLogicalPosition( dc )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
396 # If grid snap is enabled, then snap the tool to a proper position
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
397 pos = self.snapMarker( evt.GetLogicalPosition( dc ) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
398 # Maker mode should really be set by a toolbar
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
399 self.markerMode = MARKER_MODE_MEASURE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
400 # Erase the old line if her have one
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
401 if self.markerStart.x != -1 and self.markerStart.y != -1:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
402 # Set up the pen used for drawing our marker
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
403 dc.SetPen( wx.Pen(wx.RED, 1, wx.LONG_DASH) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
404 # Set the DC function that we need
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
405 dc.SetLogicalFunction(wx.INVERT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
406 # Draw the marker line
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
407 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
408 dc.DrawLine( self.markerStart.x, self.markerStart.y, self.markerStop.x, self.markerStop.y )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
409 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
410 # Restore the default DC function and pen
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
411 dc.SetLogicalFunction(wx.COPY)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
412 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
413 # Save our current start and reset the stop value
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
414 self.markerStart = pos
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
415 self.markerStop = pos
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
416 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
417
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
418 def on_tape_up(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
419 """When we release the middle button, disable any marking updates that we have been doing."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
420 # If we are in measure mode, draw the actual UNIT distance
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
421 if self.markerMode == MARKER_MODE_MEASURE:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
422 dc = wx.ClientDC( self )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
423 self.PrepareDC( dc )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
424 dc.SetUserScale(self.layers['grid'].mapscale,self.layers['grid'].mapscale)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
425 # Draw the measured distance on the DC. Since we want
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
426 # the text to match the line angle, calculate the angle
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
427 # of the line.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
428 lineAngle = self.calcLineAngle( self.markerStart, self.markerStop )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
429 distance = self.calcUnitDistance( self.markerStart, self.markerStop, lineAngle )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
430 midPoint = (self.markerStart + self.markerStop)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
431 midPoint.x /= 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
432 midPoint.y /= 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
433 # Adjust out font to be bigger & scaled
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
434 font = dc.GetFont()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
435 # Set the DC function that we need
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
436 dc.SetLogicalFunction(wx.INVERT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
437 # Set the pen we want to use
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
438 dc.SetPen(wx.BLACK_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
439 # Now, draw the text at the proper angle on the canvas
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
440 self.markerMidpoint = midPoint
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
441 self.markerAngle = lineAngle
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
442 dText = "%0.2f Units" % (distance)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
443 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
444 dc.DrawRotatedText( dText, midPoint.x, midPoint.y, lineAngle )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
445 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
446 # Restore the default font and DC
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
447 dc.SetFont(wx.NullFont)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
448 dc.SetLogicalFunction(wx.COPY)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
449 del font
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
450 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
451 self.markerMode = MARKER_MODE_NONE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
452
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
453 # MODE 1 = MOVE, MODE 2 = whiteboard, MODE 3 = Tape measure
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
454 def on_left_down(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
455 if evt.ShiftDown(): self.on_tape_down (evt)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
456 else: self.frame.on_left_down(evt)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
457
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
458 def on_right_down(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
459 if evt.ShiftDown(): pass
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
460 else: self.frame.on_right_down(evt)
0
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 def on_left_dclick(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
463 if evt.ShiftDown(): pass
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
464 else: self.frame.on_left_dclick(evt)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
465
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
466 def on_left_up(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
467 if evt.ShiftDown(): self.on_tape_up(evt)
178
ff19dd30064b Traipse Alpha 'OpenRPG' {100114-02}
sirebral
parents: 177
diff changeset
468 elif component.get('tree_fs').dragging:
ff19dd30064b Traipse Alpha 'OpenRPG' {100114-02}
sirebral
parents: 177
diff changeset
469 tree = component.get('tree_fs')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
470 if tree.drag_obj.map_aware():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
471 tree.drag_obj.on_send_to_map(evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
472 tree.dragging = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
473 tree.drag_obj = None
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
474 else: self.frame.on_left_up(evt)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
475
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
476 def on_motion(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
477 if evt.ShiftDown(): self.on_tape_motion(evt)
178
ff19dd30064b Traipse Alpha 'OpenRPG' {100114-02}
sirebral
parents: 177
diff changeset
478 elif evt.LeftIsDown() and component.get('tree_fs').dragging: pass
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
479 else: self.frame.on_motion(evt)
0
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_zoom_out(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
482 if self.layers['grid'].mapscale > 0.2:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
483 # attempt to keep same logical point at center of screen
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
484 scale = self.layers['grid'].mapscale
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
485 scrollsize = self.GetScrollPixelsPerUnit()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
486 clientsize = self.GetClientSize()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
487 topleft1 = self.GetViewStart()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
488 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
489 scroll_x = (((topleft[0]+clientsize[0]/2)*(scale-.1)/scale)-clientsize[0]/2)/scrollsize[0]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
490 scroll_y = (((topleft[1]+clientsize[1]/2)*(scale-.1)/scale)-clientsize[1]/2)/scrollsize[1]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
491 self.Scroll(scroll_x, scroll_y)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
492 self.layers['grid'].mapscale -= .1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
493 scalestring = "x" + `self.layers['grid'].mapscale`[:3]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
494 self.frame.get_current_layer_handler().zoom_out_button.SetToolTip(wx.ToolTip("Zoom out from " + scalestring) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
495 self.frame.get_current_layer_handler().zoom_in_button.SetToolTip(wx.ToolTip("Zoom in from " + scalestring) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
496 self.set_size(self.size)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
497 dc = wx.ClientDC(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
498 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
499 scalestring = "Scale x" + `self.layers['grid'].mapscale`[:3]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
500 (textWidth,textHeight) = dc.GetTextExtent(scalestring)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
501 dc.SetPen(wx.LIGHT_GREY_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
502 dc.SetBrush(wx.LIGHT_GREY_BRUSH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
503 dc.DrawRectangle(dc.DeviceToLogicalX(0),dc.DeviceToLogicalY(0),textWidth,textHeight)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
504 dc.SetPen(wx.RED_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
505 dc.DrawText(scalestring,dc.DeviceToLogicalX(0),dc.DeviceToLogicalY(0))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
506 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
507 dc.SetBrush(wx.NullBrush)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
508 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
509 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
510 self.zoom_display_timer.Start(500,1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
511
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
512 def on_zoom_in(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
513 # attempt to keep same logical point at center of screen
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
514 scale = self.layers['grid'].mapscale
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
515 scrollsize = self.GetScrollPixelsPerUnit()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
516 clientsize = self.GetClientSize()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
517 topleft1 = self.GetViewStart()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
518 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
519 scroll_x = (((topleft[0]+clientsize[0]/2)*(scale+.1)/scale)-clientsize[0]/2)/scrollsize[0]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
520 scroll_y = (((topleft[1]+clientsize[1]/2)*(scale+.1)/scale)-clientsize[1]/2)/scrollsize[1]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
521 self.Scroll(scroll_x, scroll_y)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
522 self.layers['grid'].mapscale += .1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
523 scalestring = "x" + `self.layers['grid'].mapscale`[:3]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
524 self.frame.get_current_layer_handler().zoom_out_button.SetToolTip(wx.ToolTip("Zoom out from " + scalestring) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
525 self.frame.get_current_layer_handler().zoom_in_button.SetToolTip(wx.ToolTip("Zoom in from " + scalestring) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
526 self.set_size(self.size)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
527 dc = wx.ClientDC(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
528 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
529 scalestring = "Scale x" + `self.layers['grid'].mapscale`[:3]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
530 (textWidth,textHeight) = dc.GetTextExtent(scalestring)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
531 dc.SetPen(wx.LIGHT_GREY_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
532 dc.SetBrush(wx.LIGHT_GREY_BRUSH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
533 dc.DrawRectangle(dc.DeviceToLogicalX(0), dc.DeviceToLogicalY(0), textWidth,textHeight)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
534 dc.SetPen(wx.RED_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
535 dc.DrawText(scalestring, dc.DeviceToLogicalX(0), dc.DeviceToLogicalY(0))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
536 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
537 dc.SetBrush(wx.NullBrush)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
538 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
539 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
540 self.zoom_display_timer.Start(500, 1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
541
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
542 def on_prop(self, evt):
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
543 self.session = component.get("session")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
544 self.chat = component.get("chat")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
545 if (self.session.my_role() != self.session.ROLE_GM):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
546 self.chat.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
547 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
548 dlg = general_map_prop_dialog(self.frame.GetParent(),self.size,self.layers['bg'],self.layers['grid'])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
549 if dlg.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
550 self.set_size(dlg.size)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
551 self.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
552 self.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
553 dlg.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
554 os.chdir(self.root_dir)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
555
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
556 def add_miniature(self, min_url, min_label='', min_unique=-1):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
557 if min_unique == -1: min_unique = not self.use_serial
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
558 if min_url == "" or min_url == "http://": return
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
559 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
560 # make label
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
561 wx.BeginBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
562 if self.auto_label:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
563 if min_label == '': min_label = self.get_label_from_url( min_url )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
564 if not min_unique and self.use_serial:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
565 min_label = '%s %d' % ( min_label, self.layers['miniatures'].next_serial() )
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
566 else: min_label = ""
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
567 if self.frame.min_url.FindString(min_url) == -1: self.frame.min_url.Append(min_url)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
568 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
569 id = 'mini-' + self.frame.session.get_next_id()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
570 self.layers['miniatures'].add_miniature(id, min_url, label=min_label)
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
571 except:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
572 self.layers['miniatures'].rollback_serial()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
573 wx.EndBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
574 self.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
575 self.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
576
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
577 def get_label_from_url(self, url=''):
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
578 if url == '': return ''
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
579 start = url.rfind("/")+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
580 label = url[start:len(url)-4]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
581 return label
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
582
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
583 def toxml(self, action="update"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
584 if action == "new":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
585 self.size_changed = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
586 xml_str = "<map version='" + self.map_version + "'"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
587 changed = self.size_changed
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
588 if self.size_changed:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
589 xml_str += " sizex='" + str(self.size[0]) + "'"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
590 xml_str += " sizey='" + str(self.size[1]) + "'"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
591 s = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
592 keys = self.layers.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
593 for k in keys:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
594 if (k != "fog" or action != "update"): s += self.layers[k].layerToXML(action)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
595 self.size_changed = 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
596 if s: return xml_str + " action='" + action + "'>" + s + "</map>"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
597 else:
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
598 if changed: return xml_str + " action='" + action + "'/>"
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
599 else: return ""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
600
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
601 def takexml(self, xml):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
602 """
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
603 Added Process Dialog to display during long map parsings
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
604 as well as a try block with an exception traceback to try
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
605 and isolate some of the map related problems users have been
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
606 experiencing --Snowdog 5/15/03
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
607
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
608 Apparently Process Dialog causes problems with linux.. commenting it out. sheez.
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
609 --Snowdog 5/27/03
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
610 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
611 try:
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
612 #parse the map DOM
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
613 xml_dom = parseXml(xml)
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
614 if xml_dom == None: return
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
615 node_list = xml_dom.getElementsByTagName("map")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
616 if len(node_list) < 1: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
617 else:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
618 # set map version to incoming data so layers can convert
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
619 self.map_version = node_list[0].getAttribute("version")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
620 action = node_list[0].getAttribute("action")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
621 if action == "new":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
622 self.layers = {}
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
623 try: self.layers['bg'] = layer_back_ground(self)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
624 except: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
625 try: self.layers['grid'] = grid_layer(self)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
626 except: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
627 try: self.layers['miniatures'] = miniature_layer(self)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
628 except: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
629 try: self.layers['whiteboard'] = whiteboard_layer(self)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
630 except: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
631 try: self.layers['fog'] = fog_layer(self)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
632 except: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
633 sizex = node_list[0].getAttribute("sizex")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
634 if sizex != "":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
635 sizex = int(float(sizex))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
636 sizey = self.size[1]
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
637 self.set_size((sizex,sizey))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
638 self.size_changed = 0
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
639 sizey = node_list[0].getAttribute("sizey")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
640 if sizey != "":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
641 sizey = int(float(sizey))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
642 sizex = self.size[0]
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
643 self.set_size((sizex,sizey))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
644 self.size_changed = 0
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
645 children = node_list[0]._get_childNodes()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
646 #fog layer must be computed first, so that no data is inadvertently revealed
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
647 for c in children:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
648 name = c._get_nodeName()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
649 if name == "fog": self.layers[name].layerTakeDOM(c)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
650 for c in children:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
651 name = c._get_nodeName()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
652 if name != "fog": self.layers[name].layerTakeDOM(c)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
653 # all map data should be converted, set map version to current version
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
654 self.map_version = MAP_VERSION
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
655 self.Refresh(False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
656 xml_dom.unlink() # eliminate circular refs
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
657 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
658
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
659 def re_ids_in_xml(self, xml):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
660 new_xml = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
661 tmp_map = map_msg()
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
662 xml_dom = parseXml(str(xml))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
663 node_list = xml_dom.getElementsByTagName("map")
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
664 if len(node_list) < 1: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
665 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
666 tmp_map.init_from_dom(node_list[0])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
667 if tmp_map.children.has_key("miniatures"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
668 miniatures_layer = tmp_map.children["miniatures"]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
669 if miniatures_layer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
670 minis = miniatures_layer.get_children().keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
671 if minis:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
672 for mini in minis:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
673 m = miniatures_layer.children[mini]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
674 id = 'mini-' + self.frame.session.get_next_id()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
675 m.init_prop("id", id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
676 # This allows for backward compatibility with older maps which do not
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
677 # have a whiteboard node. As such, if it's not there, we'll just happily
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
678 # move on and process as always.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
679 if tmp_map.children.has_key("whiteboard"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
680 whiteboard_layer = tmp_map.children["whiteboard"]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
681 if whiteboard_layer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
682 lines = whiteboard_layer.get_children().keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
683 if lines:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
684 for line in lines:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
685 l = whiteboard_layer.children[line]
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
686 if l.tagname == 'line': id = 'line-' + self.frame.session.get_next_id()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
687 elif l.tagname == 'text': id = 'text-' + self.frame.session.get_next_id()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
688 elif l.tagname == 'circle': id = 'circle-' + self.frame.session.get_next_id()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
689 l.init_prop("id", id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
690 new_xml = tmp_map.get_all_xml()
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
691 if xml_dom: xml_dom.unlink()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
692 return str(new_xml)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
693
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
694 class map_wnd(wx.Panel):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
695 def __init__(self, parent, id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
696 wx.Panel.__init__(self, parent, id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
697 self.canvas = MapCanvas(self, -1)
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
698 self.session = component.get('session')
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
699 self.top_frame = component.get('frame')
159
033887bb8a86 Traipse Alpha 'OpenRPG' {091126-00}
sirebral
parents: 151
diff changeset
700 self.chat = self.top_frame.chat
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
701 self.root_dir = os.getcwd()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
702 self.current_layer = 2
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
703 self.layer_tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
704 self.layer_handlers = []
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
705 self.layer_handlers.append(background_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
706 self.layer_tabs.AddPage(self.layer_handlers[0],"Background")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
707 self.layer_handlers.append(grid_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
708 self.layer_tabs.AddPage(self.layer_handlers[1],"Grid")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
709 self.layer_handlers.append(miniatures_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
710 self.layer_tabs.AddPage(self.layer_handlers[2],"Miniatures", True)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
711 self.layer_handlers.append(whiteboard_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
712 self.layer_tabs.AddPage(self.layer_handlers[3],"Whiteboard")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
713 self.layer_handlers.append(fog_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
714 self.layer_tabs.AddPage(self.layer_handlers[4],"Fog")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
715 self.layer_handlers.append(map_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
716 self.layer_tabs.AddPage(self.layer_handlers[5],"General")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
717 self.layer_tabs.SetSelection(2)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 0
diff changeset
718 self.sizer = wx.BoxSizer(wx.VERTICAL)
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 0
diff changeset
719 self.sizer.Add(self.canvas, 1, wx.EXPAND)
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
720 self.sizer.Add(self.layer_tabs, 0, wx.EXPAND)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 0
diff changeset
721 self.SetSizer(self.sizer)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
722 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.on_layer_change)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 0
diff changeset
723 #self.Bind(wx.EVT_SIZE, self.on_size)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
724 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
725 self.load_default()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
726
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
727 def OnLeave(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
728 if "__WXGTK__" in wx.PlatformInfo: wx.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
729
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
730 def load_default(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
731 if self.session.is_connected() and (self.session.my_role() != self.session.ROLE_GM) and (self.session.use_roles()):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
732 self.chat.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
733 return
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
734 f = open(dir_struct["template"] + "default_map.xml")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
735 self.new_data(f.read())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
736 f.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
737 self.canvas.send_map_data("new")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
738 if not self.session.is_connected() and (self.session.my_role() != self.session.ROLE_GM):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
739 self.session.update_role("GM")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
740
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
741 def new_data(self, data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
742 self.canvas.takexml(data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
743 self.update_tools()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
744
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
745 def on_save(self,evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
746 if (self.session.my_role() != self.session.ROLE_GM):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
747 self.chat.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
748 return
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
749 d = wx.FileDialog(self.GetParent(), "Save map data", dir_struct["user"], "", "*.xml", wx.SAVE)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
750 if d.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
751 f = open(d.GetPath(), "w")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
752 data = '<nodehandler class="min_map" icon="compass" module="core" name="miniature Map">'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
753 data += self.canvas.toxml("new")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
754 data += "</nodehandler>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
755 data = data.replace(">",">\n")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
756 f.write(data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
757 f.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
758 d.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
759 os.chdir(self.root_dir)
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 on_open(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
762 if self.session.is_connected() and (self.session.my_role() != self.session.ROLE_GM) and (self.session.use_roles()):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
763 self.chat.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
764 return
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
765 d = wx.FileDialog(self.GetParent(), "Select a file", dir_struct["user"], "", "*.xml", wx.OPEN)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
766 if d.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
767 f = open(d.GetPath())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
768 map_string = f.read()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
769 new_xml = self.canvas.re_ids_in_xml(map_string)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
770 if new_xml:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
771 self.canvas.takexml(new_xml)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
772 self.canvas.send_map_data("new")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
773 self.update_tools()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
774 if not self.session.is_connected() and (self.session.my_role() != self.session.ROLE_GM):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
775 self.session.update_role("GM")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
776 d.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
777 os.chdir(self.root_dir)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
778
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
779 def get_current_layer_handler(self):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
780 return self.layer_handlers[self.current_layer]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
781
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
782 def get_tab_index(self, layer):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
783 """Return the index of a chatpanel in the wxNotebook."""
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
784 for i in xrange(self.layer_tabs.GetPageCount()):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
785 if (self.layer_tabs.GetPageText(i) == layer):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
786 return i
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
787 return 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
788
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
789 def on_layer_change(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
790 layer = self.layer_tabs.GetPage(evt.GetSelection())
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
791 for i in xrange(0, len(self.layer_handlers)):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
792 if layer == self.layer_handlers[i]: self.current_layer = i
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
793 if self.current_layer == 0:
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
794 bg = self.layer_handlers[0]
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
795 if (self.session.my_role() != self.session.ROLE_GM): bg.url_path.Show(False)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
796 else: bg.url_path.Show(True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
797 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
798 evt.Skip()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
799
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
800 def on_left_down(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
801 self.layer_handlers[self.current_layer].on_left_down(evt)
0
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 on_left_dclick(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
804 self.layer_handlers[self.current_layer].on_left_dclick(evt)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
805
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
806 def on_right_down(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
807 self.layer_handlers[self.current_layer].on_right_down(evt)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
808
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
809 def on_left_up(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
810 self.layer_handlers[self.current_layer].on_left_up(evt)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
811
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
812 def on_motion(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
813 self.layer_handlers[self.current_layer].on_motion(evt)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
814
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
815 def MapBar(self, id, data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
816 self.canvas.MAP_MODE = data
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
817 if id == 1: self.canvas.MAP_MODE = data
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
818
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
819 def set_map_focus(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
820 self.canvas.SetFocus()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
821
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
822 def pre_exit_cleanup(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
823 # do some pre exit clean up for bitmaps or other objects
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
824 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
825 ImageHandler.flushCache()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
826 self.canvas.pre_destory_cleanup()
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
827 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
828
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
829 def update_tools(self):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
830 for h in self.layer_handlers:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
831 h.update_info()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
832
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
833 def on_hk_map_layer(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
834 id = self.top_frame.mainmenu.GetHelpString(evt.GetId())
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
835 if id == "Background Layer": self.current_layer = self.get_tab_index("Background")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
836 if id == "Grid Layer": self.current_layer = self.get_tab_index("Grid")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
837 if id == "Miniature Layer": self.current_layer = self.get_tab_index("Miniatures")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
838 elif id == "Whiteboard Layer": self.current_layer = self.get_tab_index("Whiteboard")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
839 elif id == "Fog Layer": self.current_layer = self.get_tab_index("Fog")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
840 elif id == "General Properties": self.current_layer = self.get_tab_index("General")
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
841 self.layer_tabs.SetSelection(self.current_layer)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
842
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
843 def on_flush_cache(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
844 ImageHandler.flushCache()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
845
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
846 def build_menu(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
847 # temp menu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
848 menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
849 item = wx.MenuItem(menu, wx.ID_ANY, "&Load Map", "Load Map")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
850 self.top_frame.Bind(wx.EVT_MENU, self.on_open, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
851 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
852 item = wx.MenuItem(menu, wx.ID_ANY, "&Save Map", "Save Map")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
853 self.top_frame.Bind(wx.EVT_MENU, self.on_save, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
854 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
855 menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
856 item = wx.MenuItem(menu, wx.ID_ANY, "Background Layer\tCtrl+1", "Background Layer")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
857 self.top_frame.Bind(wx.EVT_MENU, self.on_hk_map_layer, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
858 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
859 item = wx.MenuItem(menu, wx.ID_ANY, "Grid Layer\tCtrl+2", "Grid Layer")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
860 self.top_frame.Bind(wx.EVT_MENU, self.on_hk_map_layer, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
861 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
862 item = wx.MenuItem(menu, wx.ID_ANY, "Miniature Layer\tCtrl+3", "Miniature Layer")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
863 self.top_frame.Bind(wx.EVT_MENU, self.on_hk_map_layer, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
864 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
865 item = wx.MenuItem(menu, wx.ID_ANY, "Whiteboard Layer\tCtrl+4", "Whiteboard Layer")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
866 self.top_frame.Bind(wx.EVT_MENU, self.on_hk_map_layer, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
867 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
868 item = wx.MenuItem(menu, wx.ID_ANY, "Fog Layer\tCtrl+5", "Fog Layer")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
869 self.top_frame.Bind(wx.EVT_MENU, self.on_hk_map_layer, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
870 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
871 item = wx.MenuItem(menu, wx.ID_ANY, "General Properties\tCtrl+6", "General Properties")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
872 self.top_frame.Bind(wx.EVT_MENU, self.on_hk_map_layer, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
873 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
874 menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
875 item = wx.MenuItem(menu, wx.ID_ANY, "&Flush Image Cache\tCtrl+F", "Flush Image Cache")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
876 self.top_frame.Bind(wx.EVT_MENU, self.on_flush_cache, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
877 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
878 menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
879 item = wx.MenuItem(menu, wx.ID_ANY, "&Properties", "Properties")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
880 self.top_frame.Bind(wx.EVT_MENU, self.canvas.on_prop, item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
881 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
882 self.top_frame.mainmenu.Insert(2, menu, '&Map')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
883
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
884 def get_hot_keys(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
885 self.build_menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
886 return []