annotate orpg/mapper/map.py @ 177:60dde67c4ed6 alpha

Traipse Alpha 'OpenRPG' {100114-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 (Keeping up with Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Alpha!!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image
author sirebral
date Thu, 14 Jan 2010 03:32:20 -0600
parents 033887bb8a86
children ff19dd30064b
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:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
24 # $Id: map.py,v 1.73 2007/12/07 20:39:49 digitalxero Exp $
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 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
28 __version__ = "$Id: map.py,v 1.73 2007/12/07 20:39:49 digitalxero Exp $"
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 # Enable brush optimizations
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
371 # dc.SetOptimization( True )
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
372 # 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
373 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
374 # 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
375 if self.markerMode == MARKER_MODE_MEASURE:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
376 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
377 # 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
378 dc.SetLogicalFunction(wx.INVERT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
379 # 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
380 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
381 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
382 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
383 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
384 # Restore the default DC function
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
385 dc.SetLogicalFunction(wx.COPY)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
386 # 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
387 self.markerStop = pos
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
388 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
389 # Disable brush optimizations
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
390 #dc.SetOptimization( False )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
391 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
392
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
393 def on_tape_down(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
394 """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
395 modal based on a toolbar."""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
396 dc = wx.ClientDC( self )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
397 self.PrepareDC( dc )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
398 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
399 pos = evt.GetLogicalPosition( dc )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
400 # 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
401 pos = self.snapMarker( evt.GetLogicalPosition( dc ) )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
402 # 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
403 self.markerMode = MARKER_MODE_MEASURE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
404 # 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
405 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
406 # Enable brush optimizations
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
407 #dc.SetOptimization( True )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
408 # 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
409 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
410 # 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
411 dc.SetLogicalFunction(wx.INVERT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
412 # Draw the marker line
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
413 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
414 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
415 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
416 # 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
417 dc.SetLogicalFunction(wx.COPY)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
418 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
419 # Disable brush optimizations
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
420 #dc.SetOptimization( False )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
421 # 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
422 self.markerStart = pos
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
423 self.markerStop = pos
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
424 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
425
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
426 def on_tape_up(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
427 """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
428 # 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
429 if self.markerMode == MARKER_MODE_MEASURE:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
430 dc = wx.ClientDC( self )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
431 self.PrepareDC( dc )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
432 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
433 # 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
434 # 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
435 # of the line.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
436 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
437 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
438 midPoint = (self.markerStart + self.markerStop)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
439 midPoint.x /= 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
440 midPoint.y /= 2
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
441 # 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
442 font = dc.GetFont()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
443 # 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
444 dc.SetLogicalFunction(wx.INVERT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
445 # 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
446 dc.SetPen(wx.BLACK_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
447 # 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
448 self.markerMidpoint = midPoint
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
449 self.markerAngle = lineAngle
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
450 dText = "%0.2f Units" % (distance)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
451 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
452 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
453 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
454 # Restore the default font and DC
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
455 dc.SetFont(wx.NullFont)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
456 dc.SetLogicalFunction(wx.COPY)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
457 del font
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
458 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
459 self.markerMode = MARKER_MODE_NONE
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
460
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
461 # 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
462 def on_left_down(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
463 if evt.ShiftDown(): self.on_tape_down (evt)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
464 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
465
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
466 def on_right_down(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
467 if evt.ShiftDown(): pass
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
468 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
469
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
470 def on_left_dclick(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
471 if evt.ShiftDown(): pass
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
472 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
473
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
474 def on_left_up(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
475 if evt.ShiftDown(): self.on_tape_up(evt)
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
476 elif component.get("tree").dragging:
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
477 tree = component.get("tree")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
478 if tree.drag_obj.map_aware():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
479 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
480 tree.dragging = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
481 tree.drag_obj = None
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
482 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
483
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
484 def on_motion(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
485 if evt.ShiftDown(): self.on_tape_motion(evt)
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
486 elif evt.LeftIsDown() and component.get("tree").dragging: pass
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
487 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
488
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
489 def on_zoom_out(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
490 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
491 # 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
492 scale = self.layers['grid'].mapscale
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
493 scrollsize = self.GetScrollPixelsPerUnit()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
494 clientsize = self.GetClientSize()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
495 topleft1 = self.GetViewStart()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
496 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
497 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
498 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
499 self.Scroll(scroll_x, scroll_y)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
500 self.layers['grid'].mapscale -= .1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
501 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
502 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
503 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
504 self.set_size(self.size)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
505 dc = wx.ClientDC(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
506 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
507 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
508 (textWidth,textHeight) = dc.GetTextExtent(scalestring)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
509 dc.SetPen(wx.LIGHT_GREY_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
510 dc.SetBrush(wx.LIGHT_GREY_BRUSH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
511 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
512 dc.SetPen(wx.RED_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
513 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
514 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
515 dc.SetBrush(wx.NullBrush)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
516 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
517 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
518 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
519
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
520 def on_zoom_in(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
521 # 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
522 scale = self.layers['grid'].mapscale
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
523 scrollsize = self.GetScrollPixelsPerUnit()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
524 clientsize = self.GetClientSize()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
525 topleft1 = self.GetViewStart()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
526 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
527 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
528 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
529 self.Scroll(scroll_x, scroll_y)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
530 self.layers['grid'].mapscale += .1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
531 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
532 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
533 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
534 self.set_size(self.size)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
535 dc = wx.ClientDC(self)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
536 dc.BeginDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
537 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
538 (textWidth,textHeight) = dc.GetTextExtent(scalestring)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
539 dc.SetPen(wx.LIGHT_GREY_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
540 dc.SetBrush(wx.LIGHT_GREY_BRUSH)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
541 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
542 dc.SetPen(wx.RED_PEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
543 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
544 dc.SetPen(wx.NullPen)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
545 dc.SetBrush(wx.NullBrush)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
546 dc.EndDrawing()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
547 del dc
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
548 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
549
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
550 def on_prop(self, evt):
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
551 self.session = component.get("session")
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
552 self.chat = component.get("chat")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
553 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
554 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
555 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
556 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
557 if dlg.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
558 self.set_size(dlg.size)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
559 self.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
560 self.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
561 dlg.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
562 os.chdir(self.root_dir)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
563
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
564 def add_miniature(self, min_url, min_label='', min_unique=-1):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
565 if min_unique == -1: min_unique = not self.use_serial
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
566 if min_url == "" or min_url == "http://": return
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
567 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
568 # make label
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
569 wx.BeginBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
570 if self.auto_label:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
571 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
572 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
573 min_label = '%s %d' % ( min_label, self.layers['miniatures'].next_serial() )
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
574 else: min_label = ""
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
575 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
576 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
577 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
578 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
579 except:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
580 self.layers['miniatures'].rollback_serial()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
581 wx.EndBusyCursor()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
582 self.send_map_data()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
583 self.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
584
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
585 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
586 if url == '': return ''
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
587 start = url.rfind("/")+1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
588 label = url[start:len(url)-4]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
589 return label
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
590
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
591 def toxml(self, action="update"):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
592 if action == "new":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
593 self.size_changed = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
594 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
595 changed = self.size_changed
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
596 if self.size_changed:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
597 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
598 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
599 s = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
600 keys = self.layers.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
601 for k in keys:
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
602 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
603 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
604 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
605 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
606 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
607 else: return ""
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
608
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
609 def takexml(self, xml):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
610 """
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
611 Added Process Dialog to display during long map parsings
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
612 as well as a try block with an exception traceback to try
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
613 and isolate some of the map related problems users have been
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
614 experiencing --Snowdog 5/15/03
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
615
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
616 Apparently Process Dialog causes problems with linux.. commenting it out. sheez.
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
617 --Snowdog 5/27/03
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
618 """
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
619 try:
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
620 #parse the map DOM
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
621 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
622 if xml_dom == None: return
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
623 node_list = xml_dom.getElementsByTagName("map")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
624 if len(node_list) < 1: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
625 else:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
626 # set map version to incoming data so layers can convert
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
627 self.map_version = node_list[0].getAttribute("version")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
628 action = node_list[0].getAttribute("action")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
629 if action == "new":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
630 self.layers = {}
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
631 try: self.layers['bg'] = layer_back_ground(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 try: self.layers['grid'] = grid_layer(self)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
634 except: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
635 try: self.layers['miniatures'] = miniature_layer(self)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
636 except: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
637 try: self.layers['whiteboard'] = whiteboard_layer(self)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
638 except: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
639 try: self.layers['fog'] = fog_layer(self)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
640 except: pass
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
641 sizex = node_list[0].getAttribute("sizex")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
642 if sizex != "":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
643 sizex = int(float(sizex))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
644 sizey = self.size[1]
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
645 self.set_size((sizex,sizey))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
646 self.size_changed = 0
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
647 sizey = node_list[0].getAttribute("sizey")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
648 if sizey != "":
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
649 sizey = int(float(sizey))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
650 sizex = self.size[0]
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
651 self.set_size((sizex,sizey))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
652 self.size_changed = 0
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
653 children = node_list[0]._get_childNodes()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
654 #fog layer must be computed first, so that no data is inadvertently revealed
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
655 for c in children:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
656 name = c._get_nodeName()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
657 if name == "fog": self.layers[name].layerTakeDOM(c)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
658 for c in children:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
659 name = c._get_nodeName()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
660 if name != "fog": self.layers[name].layerTakeDOM(c)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
661 # all map data should be converted, set map version to current version
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
662 self.map_version = MAP_VERSION
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
663 self.Refresh(False)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
664 xml_dom.unlink() # eliminate circular refs
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
665 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
666
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
667 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
668 new_xml = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
669 tmp_map = map_msg()
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
670 xml_dom = parseXml(str(xml))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
671 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
672 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
673 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
674 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
675 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
676 miniatures_layer = tmp_map.children["miniatures"]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
677 if miniatures_layer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
678 minis = miniatures_layer.get_children().keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
679 if minis:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
680 for mini in minis:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
681 m = miniatures_layer.children[mini]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
682 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
683 m.init_prop("id", id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
684 # 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
685 # 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
686 # move on and process as always.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
687 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
688 whiteboard_layer = tmp_map.children["whiteboard"]
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
689 if whiteboard_layer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
690 lines = whiteboard_layer.get_children().keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
691 if lines:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
692 for line in lines:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
693 l = whiteboard_layer.children[line]
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
694 if l.tagname == 'line': id = 'line-' + self.frame.session.get_next_id()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
695 elif l.tagname == 'text': id = 'text-' + self.frame.session.get_next_id()
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
696 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
697 l.init_prop("id", id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
698 new_xml = tmp_map.get_all_xml()
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
699 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
700 return str(new_xml)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
701
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
702 class map_wnd(wx.Panel):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
703 def __init__(self, parent, id):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
704 wx.Panel.__init__(self, parent, id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
705 self.canvas = MapCanvas(self, -1)
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
706 self.session = component.get('session')
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
707 self.top_frame = component.get('frame')
159
033887bb8a86 Traipse Alpha 'OpenRPG' {091126-00}
sirebral
parents: 151
diff changeset
708 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
709 self.root_dir = os.getcwd()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
710 self.current_layer = 2
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
711 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
712 self.layer_handlers = []
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
713 self.layer_handlers.append(background_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[0],"Background")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
715 self.layer_handlers.append(grid_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[1],"Grid")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
717 self.layer_handlers.append(miniatures_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
718 self.layer_tabs.AddPage(self.layer_handlers[2],"Miniatures", True)
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
719 self.layer_handlers.append(whiteboard_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
720 self.layer_tabs.AddPage(self.layer_handlers[3],"Whiteboard")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
721 self.layer_handlers.append(fog_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
722 self.layer_tabs.AddPage(self.layer_handlers[4],"Fog")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
723 self.layer_handlers.append(map_handler(self.layer_tabs,-1,self.canvas))
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
724 self.layer_tabs.AddPage(self.layer_handlers[5],"General")
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
725 self.layer_tabs.SetSelection(2)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 0
diff changeset
726 self.sizer = wx.BoxSizer(wx.VERTICAL)
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 0
diff changeset
727 self.sizer.Add(self.canvas, 1, wx.EXPAND)
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
728 self.sizer.Add(self.layer_tabs, 0, wx.EXPAND)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 0
diff changeset
729 self.SetSizer(self.sizer)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
730 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
731 #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
732 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
733 self.load_default()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
734
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
735 def OnLeave(self, evt):
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
736 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
737
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
738 def load_default(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
739 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
740 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
741 return
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
742 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
743 self.new_data(f.read())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
744 f.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
745 self.canvas.send_map_data("new")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
746 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
747 self.session.update_role("GM")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
748
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
749 def new_data(self, data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
750 self.canvas.takexml(data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
751 self.update_tools()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
752
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
753 def on_save(self,evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
754 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
755 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
756 return
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
757 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
758 if d.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
759 f = open(d.GetPath(), "w")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
760 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
761 data += self.canvas.toxml("new")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
762 data += "</nodehandler>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
763 data = data.replace(">",">\n")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
764 f.write(data)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
765 f.close()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
766 d.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
767 os.chdir(self.root_dir)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
768
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
769 def on_open(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
770 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
771 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
772 return
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 20
diff changeset
773 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
774 if d.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
775 f = open(d.GetPath())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
776 map_string = f.read()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
777 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
778 if new_xml:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
779 self.canvas.takexml(new_xml)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
780 self.canvas.send_map_data("new")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
781 self.update_tools()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
782 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
783 self.session.update_role("GM")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
784 d.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
785 os.chdir(self.root_dir)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
786
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
787 def get_current_layer_handler(self):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
788 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
789
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
790 def get_tab_index(self, layer):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
791 """Return the index of a chatpanel in the wxNotebook."""
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
792 for i in xrange(self.layer_tabs.GetPageCount()):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
793 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
794 return i
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
795 return 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
796
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
797 def on_layer_change(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
798 layer = self.layer_tabs.GetPage(evt.GetSelection())
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
799 for i in xrange(0, len(self.layer_handlers)):
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
800 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
801 if self.current_layer == 0:
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
802 bg = self.layer_handlers[0]
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
803 if (self.session.my_role() != self.session.ROLE_GM): bg.url_path.Show(False)
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
804 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
805 self.canvas.Refresh(False)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
806 evt.Skip()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
807
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
808 def on_left_down(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
809 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
810
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
811 def on_left_dclick(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
812 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
813
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
814 def on_right_down(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
815 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
816
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
817 def on_left_up(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
818 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
819
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
820 def on_motion(self, evt):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
821 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
822
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
823 def MapBar(self, id, data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
824 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
825 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
826
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
827 def set_map_focus(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
828 self.canvas.SetFocus()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
829
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
830 def pre_exit_cleanup(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
831 # 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
832 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
833 ImageHandler.flushCache()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
834 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
835 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
836
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
837 def update_tools(self):
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
838 for h in self.layer_handlers:
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
839 h.update_info()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
840
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
841 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
842 id = self.top_frame.mainmenu.GetHelpString(evt.GetId())
20
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
843 if id == "Background Layer": self.current_layer = self.get_tab_index("Background")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
844 if id == "Grid Layer": self.current_layer = self.get_tab_index("Grid")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
845 if id == "Miniature Layer": self.current_layer = self.get_tab_index("Miniatures")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
846 elif id == "Whiteboard Layer": self.current_layer = self.get_tab_index("Whiteboard")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
847 elif id == "Fog Layer": self.current_layer = self.get_tab_index("Fog")
072ffc1d466f 2nd attempt. Still untested.
sirebral
parents: 19
diff changeset
848 elif id == "General Properties": self.current_layer = self.get_tab_index("General")
139
8e07c1a2c69b Traipse Alpha 'OpenRPG' {091123-00}
sirebral
parents: 138
diff changeset
849 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
850
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
851 def on_flush_cache(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
852 ImageHandler.flushCache()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
853
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
854 def build_menu(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
855 # temp menu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
856 menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
857 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
858 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
859 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
860 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
861 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
862 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
863 menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
864 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
865 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
866 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
867 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
868 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
869 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
870 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
871 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
872 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
873 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
874 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
875 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
876 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
877 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
878 menu.AppendItem(item)
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, "General Properties\tCtrl+6", "General 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.on_hk_map_layer, 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 menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
883 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
884 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
885 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
886 menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
887 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
888 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
889 menu.AppendItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
890 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
891
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
892 def get_hot_keys(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
893 self.build_menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
894 return []