Mercurial > traipse_dev
comparison orpg/mapper/map.py @ 139:8e07c1a2c69b alpha
Traipse Alpha 'OpenRPG' {091123-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 (Cleaning up for Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
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
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
Pretty important update that can help remove thousands of dead children from your gametree.
Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check
your gametree and look for dead children!!
New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops return error instead of freezing the
software!
New Syntax added for custom PC sheets
Tip of the Day added, from Core and community
Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from
ruining the fix.
author | sirebral |
---|---|
date | Mon, 23 Nov 2009 03:22:50 -0600 |
parents | 1ed2feab0db9 |
children | a771ba7b7875 |
comparison
equal
deleted
inserted
replaced
138:1ed2feab0db9 | 139:8e07c1a2c69b |
---|---|
33 from map_prop_dialog import * | 33 from map_prop_dialog import * |
34 | 34 |
35 import random | 35 import random |
36 import os | 36 import os |
37 import thread | 37 import thread |
38 #import gc #Garbage Collecter Needed? | |
38 import traceback | 39 import traceback |
39 | 40 |
40 from miniatures_handler import * | 41 from miniatures_handler import * |
41 from whiteboard_handler import * | 42 from whiteboard_handler import * |
42 from background_handler import * | 43 from background_handler import * |
46 | 47 |
47 from orpg.dirpath import dir_struct | 48 from orpg.dirpath import dir_struct |
48 from images import ImageHandler | 49 from images import ImageHandler |
49 from orpg.orpgCore import component | 50 from orpg.orpgCore import component |
50 from orpg.tools.orpg_settings import settings | 51 from orpg.tools.orpg_settings import settings |
51 from xml.etree.ElementTree import ElementTree, Element, tostring, parse | |
52 | 52 |
53 # Various marker modes for player tools on the map | 53 # Various marker modes for player tools on the map |
54 MARKER_MODE_NONE = 0 | 54 MARKER_MODE_NONE = 0 |
55 MARKER_MODE_MEASURE = 1 | 55 MARKER_MODE_MEASURE = 1 |
56 MARKER_MODE_TARGET = 2 | 56 MARKER_MODE_TARGET = 2 |
60 def __init__(self, parent, ID, isEditor=0): | 60 def __init__(self, parent, ID, isEditor=0): |
61 self.parent = parent | 61 self.parent = parent |
62 self.session = component.get("session") | 62 self.session = component.get("session") |
63 wx.ScrolledWindow.__init__(self, parent, ID, | 63 wx.ScrolledWindow.__init__(self, parent, ID, |
64 style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER ) | 64 style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER ) |
65 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) | |
66 self.frame = parent | 65 self.frame = parent |
67 self.MAP_MODE = 1 #Mode 1 = MINI, 2 = DRAW, 3 = TAPE MEASURE | 66 self.MAP_MODE = 1 #Mode 1 = MINI, 2 = DRAW, 3 = TAPE MEASURE |
68 self.layers = {} | 67 self.layers = {} |
69 self.layers['bg'] = layer_back_ground(self) | 68 self.layers['bg'] = layer_back_ground(self) |
70 self.layers['grid'] = grid_layer(self) | 69 self.layers['grid'] = grid_layer(self) |
107 self.cacheSizeSet = False | 106 self.cacheSizeSet = False |
108 self.inside = 0 | 107 self.inside = 0 |
109 # miniatures drag | 108 # miniatures drag |
110 self.drag = None | 109 self.drag = None |
111 | 110 |
112 #self.Bind(wx.EVT_MOUSEWHEEL, self.MouseWheel) | |
113 | |
114 def MouseWheel(self, evt): | |
115 if evt.CmdDown(): | |
116 if evt.GetWheelRotation() > 0: self.on_zoom_in(None) | |
117 elif evt.GetWheelRotation() < 0: self.on_zoom_out(None) | |
118 else: pass | |
119 | |
120 def better_refresh(self, event=None): | 111 def better_refresh(self, event=None): |
121 self.Refresh(True) | 112 self.Refresh(True) |
122 | 113 |
123 def pre_destory_cleanup(self): | 114 def pre_destory_cleanup(self): |
124 self.layers["miniatures"].del_all_miniatures() | 115 self.layers["miniatures"].del_all_miniatures() |
125 | 116 |
126 def processImages(self, evt=None): | 117 def processImages(self, evt=None): |
127 self.session = component.get("session") | 118 self.session = component.get("session") |
128 tabs = ['Background', 'Grid', 'Miniatures', 'Whiteboard', 'Fog', 'General'] | |
129 if self.session.my_role() == self.session.ROLE_LURKER or (str(self.session.group_id) == '0' and str(self.session.status) == '1'): | 119 if self.session.my_role() == self.session.ROLE_LURKER or (str(self.session.group_id) == '0' and str(self.session.status) == '1'): |
130 for tab in tabs: | 120 cidx = self.parent.get_tab_index("Background") |
131 cidx = self.parent.get_tab_index(tab) | 121 self.parent.layer_tabs.EnableTab(cidx, False) |
132 self.parent.tabs.EnableTab(cidx, False) | 122 cidx = self.parent.get_tab_index("Grid") |
133 elif self.session.my_role() == self.session.ROLE_PLAYER: | 123 self.parent.layer_tabs.EnableTab(cidx, False) |
134 for tab in tabs: | 124 cidx = self.parent.get_tab_index("Miniatures") |
135 cidx = self.parent.get_tab_index(tab) | 125 self.parent.layer_tabs.EnableTab(cidx, False) |
136 if tab == "Miniatures" or tab == "Whiteboard": | 126 cidx = self.parent.get_tab_index("Whiteboard") |
137 self.parent.tabs.EnableTab(cidx, True) | 127 self.parent.layer_tabs.EnableTab(cidx, False) |
138 else: self.parent.tabs.EnableTab(cidx, False) | 128 cidx = self.parent.get_tab_index("Fog") |
139 elif self.session.my_role() == self.session.ROLE_GM and str(self.session.group_id) != '0': | 129 self.parent.layer_tabs.EnableTab(cidx, False) |
140 for tab in tabs: | 130 cidx = self.parent.get_tab_index("General") |
141 cidx = self.parent.get_tab_index(tab) | 131 self.parent.layer_tabs.EnableTab(cidx, False) |
142 self.parent.tabs.EnableTab(cidx, True) | 132 else: |
133 cidx = self.parent.get_tab_index("Background") | |
134 if not self.parent.layer_tabs.GetEnabled(cidx): | |
135 cidx = self.parent.get_tab_index("Miniatures") | |
136 self.parent.layer_tabs.EnableTab(cidx, True) | |
137 cidx = self.parent.get_tab_index("Whiteboard") | |
138 self.parent.layer_tabs.EnableTab(cidx, True) | |
139 cidx = self.parent.get_tab_index("Background") | |
140 self.parent.layer_tabs.EnableTab(cidx, False) | |
141 cidx = self.parent.get_tab_index("Grid") | |
142 self.parent.layer_tabs.EnableTab(cidx, False) | |
143 cidx = self.parent.get_tab_index("Fog") | |
144 self.parent.layer_tabs.EnableTab(cidx, False) | |
145 cidx = self.parent.get_tab_index("General") | |
146 self.parent.layer_tabs.EnableTab(cidx, False) | |
147 if self.session.my_role() == self.session.ROLE_GM: | |
148 cidx = self.parent.get_tab_index("Background") | |
149 self.parent.layer_tabs.EnableTab(cidx, True) | |
150 cidx = self.parent.get_tab_index("Grid") | |
151 self.parent.layer_tabs.EnableTab(cidx, True) | |
152 cidx = self.parent.get_tab_index("Fog") | |
153 self.parent.layer_tabs.EnableTab(cidx, True) | |
154 cidx = self.parent.get_tab_index("General") | |
155 self.parent.layer_tabs.EnableTab(cidx, True) | |
143 if not self.cacheSizeSet: | 156 if not self.cacheSizeSet: |
144 self.cacheSizeSet = True | 157 self.cacheSizeSet = True |
145 cacheSize = component.get('settings').get_setting("ImageCacheSize") | 158 cacheSize = component.get('settings').get_setting("ImageCacheSize") |
146 if len(cacheSize): self.cacheSize = int(cacheSize) | 159 if len(cacheSize): self.cacheSize = int(cacheSize) |
147 else: pass | 160 else: pass |
148 if not ImageHandler.Queue.empty(): | 161 if not ImageHandler.Queue.empty(): |
149 (path, image_type, imageId) = ImageHandler.Queue.get() | 162 (path, image_type, imageId) = ImageHandler.Queue.get() |
150 img = wx.ImageFromMime(path[1], path[2]) | 163 img = wx.ImageFromMime(path[1], path[2]) |
151 # Now, apply the image to the proper object | 164 try: |
152 if image_type == "miniature": | 165 # Now, apply the image to the proper object |
153 min = self.layers['miniatures'].get_miniature_by_id(imageId) | 166 if image_type == "miniature": |
154 if min: min.set_bmp(img) | 167 min = self.layers['miniatures'].get_miniature_by_id(imageId) |
155 elif image_type == "background" or image_type == "texture": | 168 if min: min.set_bmp(img) |
156 self.layers['bg'].bg_bmp = img.ConvertToBitmap() | 169 elif image_type == "background" or image_type == "texture": |
157 if image_type == "background": self.set_size([img.GetWidth(), img.GetHeight()]) | 170 self.layers['bg'].bg_bmp = img.ConvertToBitmap() |
171 if image_type == "background": self.set_size([img.GetWidth(), img.GetHeight()]) | |
172 except: pass | |
158 # Flag that we now need to refresh! | 173 # Flag that we now need to refresh! |
159 self.requireRefresh += 1 | 174 self.requireRefresh += 1 |
175 | |
160 """ Randomly purge an item from the cache, while this is lamo, it does | 176 """ Randomly purge an item from the cache, while this is lamo, it does |
161 keep the cache from growing without bounds, which is pretty important!""" | 177 keep the cache from growing without bounds, which is pretty important!""" |
162 if len(ImageHandler.Cache) >= self.cacheSize: | 178 if len(ImageHandler.Cache) >= self.cacheSize: |
163 ImageHandler.cleanCache() | 179 ImageHandler.cleanCache() |
164 else: | 180 else: |
235 scrollsize = self.GetScrollPixelsPerUnit() | 251 scrollsize = self.GetScrollPixelsPerUnit() |
236 clientsize = self.GetClientSize() | 252 clientsize = self.GetClientSize() |
237 topleft1 = self.GetViewStart() | 253 topleft1 = self.GetViewStart() |
238 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]] | 254 topleft = [topleft1[0]*scrollsize[0], topleft1[1]*scrollsize[1]] |
239 if (clientsize[0] > 1) and (clientsize[1] > 1): | 255 if (clientsize[0] > 1) and (clientsize[1] > 1): |
240 #dc = wx.MemoryDC() | |
241 #bmp = wx.EmptyBitmap(clientsize[0]+1, clientsize[1]+1) | |
242 #dc.SelectObject(bmp) | |
243 dc = wx.AutoBufferedPaintDC(self) | 256 dc = wx.AutoBufferedPaintDC(self) |
244 dc.SetPen(wx.TRANSPARENT_PEN) | 257 dc.SetPen(wx.TRANSPARENT_PEN) |
245 dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID)) | 258 dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID)) |
246 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1) | 259 dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1) |
247 dc.SetDeviceOrigin(-topleft[0], -topleft[1]) | 260 dc.SetDeviceOrigin(-topleft[0], -topleft[1]) |
253 [clientsize[0]/scale, clientsize[1]/scale]) | 266 [clientsize[0]/scale, clientsize[1]/scale]) |
254 self.layers['whiteboard'].layerDraw(dc) | 267 self.layers['whiteboard'].layerDraw(dc) |
255 self.layers['fog'].layerDraw(dc, topleft, clientsize) | 268 self.layers['fog'].layerDraw(dc, topleft, clientsize) |
256 dc.SetPen(wx.NullPen) | 269 dc.SetPen(wx.NullPen) |
257 dc.SetBrush(wx.NullBrush) | 270 dc.SetBrush(wx.NullBrush) |
258 #dc.SelectObject(wx.NullBitmap) | |
259 #del dc | |
260 #wdc = self.preppaint() | |
261 #wdc.DrawBitmap(bmp, topleft[0], topleft[1]) | |
262 if settings.get_setting("AlwaysShowMapScale") == "1": | 271 if settings.get_setting("AlwaysShowMapScale") == "1": |
263 self.showmapscale(dc) | 272 self.showmapscale(dc) |
264 try: evt.Skip() | 273 try: evt.Skip() |
265 except: pass | 274 except: pass |
266 | |
267 def preppaint(self): | |
268 dc = wx.PaintDC(self) | |
269 self.PrepareDC(dc) | |
270 return (dc) | |
271 | 275 |
272 def showmapscale(self, dc): | 276 def showmapscale(self, dc): |
273 scalestring = "Scale x" + `self.layers['grid'].mapscale`[:3] | 277 scalestring = "Scale x" + `self.layers['grid'].mapscale`[:3] |
274 (textWidth, textHeight) = dc.GetTextExtent(scalestring) | 278 (textWidth, textHeight) = dc.GetTextExtent(scalestring) |
275 dc.SetUserScale(1, 1) | 279 dc.SetUserScale(1, 1) |
603 else: | 607 else: |
604 if changed: return xml_str + " action='" + action + "'/>" | 608 if changed: return xml_str + " action='" + action + "'/>" |
605 else: return "" | 609 else: return "" |
606 | 610 |
607 def takexml(self, xml): | 611 def takexml(self, xml): |
612 """ | |
613 Added Process Dialog to display during long map parsings | |
614 as well as a try block with an exception traceback to try | |
615 and isolate some of the map related problems users have been | |
616 experiencing --Snowdog 5/15/03 | |
617 | |
618 Apparently Process Dialog causes problems with linux.. commenting it out. sheez. | |
619 --Snowdog 5/27/03 | |
620 """ | |
608 try: | 621 try: |
609 xml_dom = fromstring(xml) | 622 #parse the map DOM |
623 xml_dom = parseXml(xml) | |
610 if xml_dom == None: return | 624 if xml_dom == None: return |
611 node_list = xml_dom.find("map") if xml_dom.tag != 'map' else xml_dom | 625 node_list = xml_dom.getElementsByTagName("map") |
612 # set map version to incoming data so layers can convert | 626 if len(node_list) < 1: pass |
613 self.map_version = node_list.get("version") | 627 else: |
614 action = node_list.get("action") | 628 # set map version to incoming data so layers can convert |
615 if action == "new": | 629 self.map_version = node_list[0].getAttribute("version") |
616 self.layers = {} | 630 action = node_list[0].getAttribute("action") |
617 try: self.layers['bg'] = layer_back_ground(self) | 631 if action == "new": |
618 except: pass | 632 self.layers = {} |
619 try: self.layers['grid'] = grid_layer(self) | 633 try: self.layers['bg'] = layer_back_ground(self) |
620 except: pass | 634 except: pass |
621 try: self.layers['miniatures'] = miniature_layer(self) | 635 try: self.layers['grid'] = grid_layer(self) |
622 except: pass | 636 except: pass |
623 try: self.layers['whiteboard'] = whiteboard_layer(self) | 637 try: self.layers['miniatures'] = miniature_layer(self) |
624 except: pass | 638 except: pass |
625 try: self.layers['fog'] = fog_layer(self) | 639 try: self.layers['whiteboard'] = whiteboard_layer(self) |
626 except: pass | 640 except: pass |
627 sizex = node_list.get("sizex") if node_list.get("sizex") != None else '' | 641 try: self.layers['fog'] = fog_layer(self) |
628 if sizex != "": | 642 except: pass |
629 sizex = int(float(sizex)) | 643 sizex = node_list[0].getAttribute("sizex") |
630 sizey = self.size[1] | 644 if sizex != "": |
631 self.set_size((sizex,sizey)) | 645 sizex = int(float(sizex)) |
632 self.size_changed = 0 | 646 sizey = self.size[1] |
633 sizey = node_list.get("sizey") if node_list.get('sizey') != None else '' | 647 self.set_size((sizex,sizey)) |
634 if sizey != "": | 648 self.size_changed = 0 |
635 sizey = int(float(sizey)) | 649 sizey = node_list[0].getAttribute("sizey") |
636 sizex = self.size[0] | 650 if sizey != "": |
637 self.set_size((sizex,sizey)) | 651 sizey = int(float(sizey)) |
638 self.size_changed = 0 | 652 sizex = self.size[0] |
639 children = node_list.getchildren() | 653 self.set_size((sizex,sizey)) |
640 #fog layer must be computed first, so that no data is inadvertently revealed | 654 self.size_changed = 0 |
641 for c in children: | 655 children = node_list[0]._get_childNodes() |
642 if c.tag == "fog": self.layers[c.tag].layerTakeDOM(c) | 656 #fog layer must be computed first, so that no data is inadvertently revealed |
643 for c in children: | 657 for c in children: |
644 if c.tag != "fog": self.layers[c.tag].layerTakeDOM(c) | 658 name = c._get_nodeName() |
645 # all map data should be converted, set map version to current version | 659 if name == "fog": self.layers[name].layerTakeDOM(c) |
646 self.map_version = MAP_VERSION | 660 for c in children: |
647 self.Refresh(False) | 661 name = c._get_nodeName() |
648 except Exception, e: print 'failed', e; pass | 662 if name != "fog": self.layers[name].layerTakeDOM(c) |
663 # all map data should be converted, set map version to current version | |
664 self.map_version = MAP_VERSION | |
665 self.Refresh(False) | |
666 xml_dom.unlink() # eliminate circular refs | |
667 except: pass | |
649 | 668 |
650 def re_ids_in_xml(self, xml): | 669 def re_ids_in_xml(self, xml): |
651 new_xml = "" | 670 new_xml = "" |
652 tmp_map = map_msg() | 671 tmp_map = map_msg() |
653 xml_dom = fromstring(str(xml)) | 672 xml_dom = parseXml(str(xml)) |
654 node_list = xml_dom.findall("map") | 673 node_list = xml_dom.getElementsByTagName("map") |
655 if len(node_list) < 1: pass | 674 if len(node_list) < 1: pass |
656 else: | 675 else: |
657 tmp_map.init_from_dom(node_list[0]) | 676 tmp_map.init_from_dom(node_list[0]) |
658 if tmp_map.children.has_key("miniatures"): | 677 if tmp_map.children.has_key("miniatures"): |
659 miniatures_layer = tmp_map.children["miniatures"] | 678 miniatures_layer = tmp_map.children["miniatures"] |
672 if whiteboard_layer: | 691 if whiteboard_layer: |
673 lines = whiteboard_layer.get_children().keys() | 692 lines = whiteboard_layer.get_children().keys() |
674 if lines: | 693 if lines: |
675 for line in lines: | 694 for line in lines: |
676 l = whiteboard_layer.children[line] | 695 l = whiteboard_layer.children[line] |
677 if l.tag == 'line': id = 'line-' + self.frame.session.get_next_id() | 696 if l.tagname == 'line': id = 'line-' + self.frame.session.get_next_id() |
678 elif l.tag == 'text': id = 'text-' + self.frame.session.get_next_id() | 697 elif l.tagname == 'text': id = 'text-' + self.frame.session.get_next_id() |
679 elif l.tag == 'circle': id = 'circle-' + self.frame.session.get_next_id() | 698 elif l.tagname == 'circle': id = 'circle-' + self.frame.session.get_next_id() |
680 l.init_prop("id", id) | 699 l.init_prop("id", id) |
681 new_xml = tmp_map.get_all_xml() | 700 new_xml = tmp_map.get_all_xml() |
682 if xml_dom: xml_dom.unlink() | 701 if xml_dom: xml_dom.unlink() |
683 return str(new_xml) | 702 return str(new_xml) |
684 | 703 |
689 self.session = component.get('session') | 708 self.session = component.get('session') |
690 self.chat = component.get('chat') | 709 self.chat = component.get('chat') |
691 self.top_frame = component.get('frame') | 710 self.top_frame = component.get('frame') |
692 self.root_dir = os.getcwd() | 711 self.root_dir = os.getcwd() |
693 self.current_layer = 2 | 712 self.current_layer = 2 |
694 self.tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS) | 713 self.layer_tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS) |
695 self.handlers = {} | 714 self.layer_handlers = [] |
696 self.handlers[0]=(background_handler(self.tabs,-1,self.canvas)) | 715 self.layer_handlers.append(background_handler(self.layer_tabs,-1,self.canvas)) |
697 self.tabs.AddPage(self.handlers[0],"Background") | 716 self.layer_tabs.AddPage(self.layer_handlers[0],"Background") |
698 self.handlers[1]=(grid_handler(self.tabs,-1,self.canvas)) | 717 self.layer_handlers.append(grid_handler(self.layer_tabs,-1,self.canvas)) |
699 self.tabs.AddPage(self.handlers[1],"Grid") | 718 self.layer_tabs.AddPage(self.layer_handlers[1],"Grid") |
700 self.handlers[2]=(miniatures_handler(self.tabs,-1,self.canvas)) | 719 self.layer_handlers.append(miniatures_handler(self.layer_tabs,-1,self.canvas)) |
701 self.tabs.AddPage(self.handlers[2],"Miniatures", True) | 720 self.layer_tabs.AddPage(self.layer_handlers[2],"Miniatures", True) |
702 self.handlers[3]=(whiteboard_handler(self.tabs,-1,self.canvas)) | 721 self.layer_handlers.append(whiteboard_handler(self.layer_tabs,-1,self.canvas)) |
703 self.tabs.AddPage(self.handlers[3],"Whiteboard") | 722 self.layer_tabs.AddPage(self.layer_handlers[3],"Whiteboard") |
704 self.handlers[4]=(fog_handler(self.tabs,-1,self.canvas)) | 723 self.layer_handlers.append(fog_handler(self.layer_tabs,-1,self.canvas)) |
705 self.tabs.AddPage(self.handlers[4],"Fog") | 724 self.layer_tabs.AddPage(self.layer_handlers[4],"Fog") |
706 self.handlers[5]=(map_handler(self.tabs,-1,self.canvas)) | 725 self.layer_handlers.append(map_handler(self.layer_tabs,-1,self.canvas)) |
707 self.tabs.AddPage(self.handlers[5],"General") | 726 self.layer_tabs.AddPage(self.layer_handlers[5],"General") |
708 self.tabs.SetSelection(2) | 727 self.layer_tabs.SetSelection(2) |
709 self.sizer = wx.BoxSizer(wx.VERTICAL) | 728 self.sizer = wx.BoxSizer(wx.VERTICAL) |
710 self.sizer.Add(self.canvas, 1, wx.EXPAND) | 729 self.sizer.Add(self.canvas, 1, wx.EXPAND) |
711 self.sizer.Add(self.tabs, 0, wx.EXPAND) | 730 self.sizer.Add(self.layer_tabs, 0, wx.EXPAND) |
712 self.SetSizer(self.sizer) | 731 self.SetSizer(self.sizer) |
713 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.on_layer_change) | 732 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.on_layer_change) |
714 #self.Bind(wx.EVT_SIZE, self.on_size) | 733 #self.Bind(wx.EVT_SIZE, self.on_size) |
715 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) | 734 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) |
716 self.load_default() | 735 self.load_default() |
717 | |
718 ## Components for making Map Based plugins that create new tabs. | |
719 component.add('map_tabs', self.tabs) | |
720 component.add('map_layers', self.handlers) | |
721 component.add('map_wnd', self) | |
722 | 736 |
723 def OnLeave(self, evt): | 737 def OnLeave(self, evt): |
724 if "__WXGTK__" in wx.PlatformInfo: wx.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) | 738 if "__WXGTK__" in wx.PlatformInfo: wx.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) |
725 | 739 |
726 def load_default(self): | 740 def load_default(self): |
771 self.session.update_role("GM") | 785 self.session.update_role("GM") |
772 d.Destroy() | 786 d.Destroy() |
773 os.chdir(self.root_dir) | 787 os.chdir(self.root_dir) |
774 | 788 |
775 def get_current_layer_handler(self): | 789 def get_current_layer_handler(self): |
776 return self.handlers[self.current_layer] | 790 return self.layer_handlers[self.current_layer] |
777 | 791 |
778 def get_tab_index(self, layer): | 792 def get_tab_index(self, layer): |
779 """Return the index of a chatpanel in the wxNotebook.""" | 793 """Return the index of a chatpanel in the wxNotebook.""" |
780 for i in xrange(self.tabs.GetPageCount()): | 794 for i in xrange(self.layer_tabs.GetPageCount()): |
781 if (self.tabs.GetPageText(i) == layer): | 795 if (self.layer_tabs.GetPageText(i) == layer): |
782 return i | 796 return i |
783 return 0 | 797 return 0 |
784 | 798 |
785 def on_layer_change(self, evt): | 799 def on_layer_change(self, evt): |
786 layer = self.tabs.GetPage(evt.GetSelection()) | 800 layer = self.layer_tabs.GetPage(evt.GetSelection()) |
787 for i in xrange(0, len(self.handlers)): | 801 for i in xrange(0, len(self.layer_handlers)): |
788 if layer == self.handlers[i]: self.current_layer = i | 802 if layer == self.layer_handlers[i]: self.current_layer = i |
789 if self.current_layer == 0: | 803 if self.current_layer == 0: |
790 bg = self.handlers[0] | 804 bg = self.layer_handlers[0] |
791 if (self.session.my_role() != self.session.ROLE_GM): bg.url_path.Show(False) | 805 if (self.session.my_role() != self.session.ROLE_GM): bg.url_path.Show(False) |
792 else: bg.url_path.Show(True) | 806 else: bg.url_path.Show(True) |
793 self.canvas.Refresh(False) | 807 self.canvas.Refresh(False) |
794 evt.Skip() | 808 evt.Skip() |
795 | 809 |
796 def on_left_down(self, evt): | 810 def on_left_down(self, evt): |
797 self.handlers[self.current_layer].on_left_down(evt) | 811 self.layer_handlers[self.current_layer].on_left_down(evt) |
798 | 812 |
799 #double click handler added by Snowdog 5/03 | 813 #double click handler added by Snowdog 5/03 |
800 def on_left_dclick(self, evt): | 814 def on_left_dclick(self, evt): |
801 self.handlers[self.current_layer].on_left_dclick(evt) | 815 self.layer_handlers[self.current_layer].on_left_dclick(evt) |
802 | 816 |
803 def on_right_down(self, evt): | 817 def on_right_down(self, evt): |
804 self.handlers[self.current_layer].on_right_down(evt) | 818 self.layer_handlers[self.current_layer].on_right_down(evt) |
805 | 819 |
806 def on_left_up(self, evt): | 820 def on_left_up(self, evt): |
807 self.handlers[self.current_layer].on_left_up(evt) | 821 self.layer_handlers[self.current_layer].on_left_up(evt) |
808 | 822 |
809 def on_motion(self, evt): | 823 def on_motion(self, evt): |
810 self.handlers[self.current_layer].on_motion(evt) | 824 self.layer_handlers[self.current_layer].on_motion(evt) |
811 | 825 |
812 def MapBar(self, id, data): | 826 def MapBar(self, id, data): |
813 self.canvas.MAP_MODE = data | 827 self.canvas.MAP_MODE = data |
814 if id == 1: self.canvas.MAP_MODE = data | 828 if id == 1: self.canvas.MAP_MODE = data |
815 | 829 |
822 ImageHandler.flushCache() | 836 ImageHandler.flushCache() |
823 self.canvas.pre_destory_cleanup() | 837 self.canvas.pre_destory_cleanup() |
824 except: pass | 838 except: pass |
825 | 839 |
826 def update_tools(self): | 840 def update_tools(self): |
827 for h in self.handlers: | 841 for h in self.layer_handlers: |
828 self.handlers[h].update_info() | 842 h.update_info() |
829 | 843 |
830 def on_hk_map_layer(self, evt): | 844 def on_hk_map_layer(self, evt): |
831 id = self.top_frame.mainmenu.GetHelpString(evt.GetId()) | 845 id = self.top_frame.mainmenu.GetHelpString(evt.GetId()) |
832 if id == "Background Layer": self.current_layer = self.get_tab_index("Background") | 846 if id == "Background Layer": self.current_layer = self.get_tab_index("Background") |
833 if id == "Grid Layer": self.current_layer = self.get_tab_index("Grid") | 847 if id == "Grid Layer": self.current_layer = self.get_tab_index("Grid") |
834 if id == "Miniature Layer": self.current_layer = self.get_tab_index("Miniatures") | 848 if id == "Miniature Layer": self.current_layer = self.get_tab_index("Miniatures") |
835 elif id == "Whiteboard Layer": self.current_layer = self.get_tab_index("Whiteboard") | 849 elif id == "Whiteboard Layer": self.current_layer = self.get_tab_index("Whiteboard") |
836 elif id == "Fog Layer": self.current_layer = self.get_tab_index("Fog") | 850 elif id == "Fog Layer": self.current_layer = self.get_tab_index("Fog") |
837 elif id == "General Properties": self.current_layer = self.get_tab_index("General") | 851 elif id == "General Properties": self.current_layer = self.get_tab_index("General") |
838 self.tabs.SetSelection(self.current_layer) | 852 self.layer_tabs.SetSelection(self.current_layer) |
839 | 853 |
840 def on_flush_cache(self, evt): | 854 def on_flush_cache(self, evt): |
841 ImageHandler.flushCache() | 855 ImageHandler.flushCache() |
842 | 856 |
843 def build_menu(self): | 857 def build_menu(self): |