diff orpg/mapper/map.py @ 18:97265586402b ornery-orc

Traipse 'OpenRPG' {090827-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: Update Manager is now in version 0.8. While not every button works, users can now browse the different revisions and their different changesets. The code has been refined some with feature from Core added to it. A Crash report is now created if the users software crashes. Update Manager has been moved to the Traipse Suite menu item, and a Debug Console as been added as well.
author sirebral
date Thu, 27 Aug 2009 01:04:43 -0500
parents 211ac836b6a0
children ff154cf3350c
line wrap: on
line diff
--- a/orpg/mapper/map.py	Thu Aug 13 13:14:10 2009 -0500
+++ b/orpg/mapper/map.py	Thu Aug 27 01:04:43 2009 -0500
@@ -31,20 +31,24 @@
 from map_msg import *
 from min_dialogs import *
 from map_prop_dialog import *
-import orpg.dirpath
+
 import random
 import os
 import thread
-import gc
+#import gc #Garbage Collecter Needed?
 import traceback
+
 from miniatures_handler import *
 from whiteboard_handler import *
 from background_handler import *
-from fog_handler import *
-from images import ImageHandler
 from grid_handler import *
 from map_handler import *
-from orpg.orpgCore import open_rpg
+from fog_handler import *
+
+from orpg.dirpath import dir_struct
+from images import ImageHandler
+from orpg.orpgCore import component
+from orpg.tools.orpg_settings import settings
 
 # Various marker modes for player tools on the map
 MARKER_MODE_NONE = 0
@@ -55,10 +59,7 @@
 class MapCanvas(wx.ScrolledWindow):
     def __init__(self, parent, ID, isEditor=0):
         self.parent = parent
-        self.log = open_rpg.get_component("log")
-        self.log.log("Enter MapCanvas", ORPG_DEBUG)
-        self.settings = open_rpg.get_component("settings")
-        self.session = open_rpg.get_component("session")
+        self.session = component.get("session")
         wx.ScrolledWindow.__init__(self, parent, ID, 
             style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER )
         self.frame = parent
@@ -106,21 +107,15 @@
         self.inside = 0
         # miniatures drag
         self.drag = None
-        self.log.log("Exit MapCanvas", ORPG_DEBUG)
 
     def better_refresh(self, event=None):
-        self.log.log("Enter MapCanvas->better_refresh(self)", ORPG_DEBUG)
         self.Refresh(True)
-        self.log.log("Eexit MapCanvas->better_refresh(self)", ORPG_DEBUG)
 
     def pre_destory_cleanup(self):
-        self.log.log("Enter MapCanvas->pre_destory_cleanup(self)", ORPG_DEBUG)
         self.layers["miniatures"].del_all_miniatures()
-        self.log.log("Exit MapCanvas->pre_destory_cleanup(self)", ORPG_DEBUG)
 
     def processImages(self, evt=None):
-        self.log.log("Enter MapCanvas->processImages(self)", ORPG_DEBUG)
-        self.session = open_rpg.get_component("session")
+        self.session = component.get("session")
         if self.session.my_role() == self.session.ROLE_LURKER or (str(self.session.group_id) == '0' and str(self.session.status) == '1'):
             cidx = self.parent.get_tab_index("Background")
             self.parent.layer_tabs.EnableTab(cidx, False)
@@ -160,11 +155,9 @@
                     self.parent.layer_tabs.EnableTab(cidx, True)
         if not self.cacheSizeSet:
             self.cacheSizeSet = True
-            cacheSize = self.settings.get_setting("ImageCacheSize")
+            cacheSize = component.get('settings').get_setting("ImageCacheSize")
             if len(cacheSize): self.cacheSize = int(cacheSize)
-            else: self.log.log("Default cache size being used.", ORPG_GENERAL)
-            self.log.log("Current image cache size is set at " + str(self.cacheSize) + " images, using random purge.", 
-                ORPG_GENERAL)
+            else: pass
         if not ImageHandler.Queue.empty():
             (path, image_type, imageId) = ImageHandler.Queue.get()
             img = wx.ImageFromMime(path[1], path[2]).ConvertToBitmap()
@@ -180,15 +173,15 @@
             # Flag that we now need to refresh!
             self.requireRefresh += 1
 
-            # Randomly purge an item from the cache, while this is lamo, it does
-            # keep the cache from growing without bounds, which is pretty important!
+            """ Randomly purge an item from the cache, while this is lamo, it does
+                keep the cache from growing without bounds, which is pretty important!"""
             if len(ImageHandler.Cache) >= self.cacheSize:
                 ImageHandler.cleanCache()
         else:
-            # Now, make sure not only that we require a refresh, but that enough time has
-            # gone by since our last refresh.  This keeps back to back refreshing occuring during
-            # large map loads.  Of course, we are now trying to pack as many image refreshes as
-            # we can into a single cycle.
+            """ Now, make sure not only that we require a refresh, but that enough time has
+                gone by since our last refresh.  This keeps back to back refreshing occuring during
+                large map loads.  Of course, we are now trying to pack as many image refreshes as
+                we can into a single cycle."""
             if self.requireRefresh and (self.requireRefresh == self.lastRefreshValue):
                 if (self.lastRefreshTime) < time.time():
                     self.requireRefresh = 0
@@ -196,86 +189,64 @@
                     self.lastRefreshTime = time.time()
                     self.Refresh(True)
             else: self.lastRefreshValue = self.requireRefresh
-        self.log.log("Exit MapCanvas->processImages(self)", ORPG_DEBUG)
 
     def on_scroll(self, evt):
-        self.log.log("Enter MapCanvas->on_scroll(self, evt)", ORPG_DEBUG)
         if self.drag: self.drag.Hide()
-        if self.settings.get_setting("AlwaysShowMapScale") == "1": self.printscale()
+        if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale()
         evt.Skip()
-        self.log.log("Exit MapCanvas->on_scroll(self, evt)", ORPG_DEBUG)
 
     def on_char(self, evt):
-        self.log.log("Enter MapCanvas->on_char(self, evt)", ORPG_DEBUG)
-        if self.settings.get_setting("AlwaysShowMapScale") == "1": self.printscale()
+        if component.get('settings').get_setting("AlwaysShowMapScale") == "1": self.printscale()
         evt.Skip()
-        self.log.log("Exit MapCanvas->on_char(self, evt)", ORPG_DEBUG)
 
     def printscale(self):
-        self.log.log("Enter MapCanvas->printscale(self)", ORPG_DEBUG)
         wx.BeginBusyCursor()
         dc = wx.ClientDC(self)
         self.PrepareDC(dc)
         self.showmapscale(dc)
         self.Refresh(True)
         wx.EndBusyCursor()
-        self.log.log("Exit MapCanvas->printscale(self)", ORPG_DEBUG)
 
     def send_map_data(self, action="update"):
-        self.log.log("Enter MapCanvas->send_map_data(self, " + action +")", ORPG_DEBUG)
         wx.BeginBusyCursor()
         send_text = self.toxml(action)
         if send_text:
             if not self.isEditor: self.frame.session.send(send_text)
         wx.EndBusyCursor()
-        self.log.log("Exit MapCanvas->send_map_data(self, " + action +")", ORPG_DEBUG)
 
     def get_size(self):
-        self.log.log("Enter MapCanvas->get_size(self)", ORPG_DEBUG)
-        self.log.log("Exit MapCanvas->get_size(self) return " + str(self.size), ORPG_DEBUG)
         return self.size
 
     def set_size(self, size):
-        self.log.log("Enter MapCanvas->set_size(self, size)", ORPG_DEBUG)
         if size[0] < 300: size = (300, size[1])
         if size[1] < 300: size = (size[0], 300)
         self.size_changed = 1
         self.size = size
         self.fix_scroll()
         self.layers['fog'].resize(size)
-        self.log.log("Exit MapCanvas->set_size(self, size)", ORPG_DEBUG)
 
     def fix_scroll(self):
-        self.log.log("Enter MapCanvas->fix_scroll(self)", ORPG_DEBUG)
         scale = self.layers['grid'].mapscale
         pos = self.GetViewStart()
         unit = self.GetScrollPixelsPerUnit()
         pos = [pos[0]*unit[0],pos[1]*unit[1]]
         size = self.GetClientSize()
         unit = [10*scale,10*scale]
-        if (unit[0] == 0 or unit[1] == 0):
-            self.log.log("Exit MapCanvas->fix_scroll(self)", ORPG_DEBUG)
-            return
+        if (unit[0] == 0 or unit[1] == 0): return
         pos[0] /= unit[0]
         pos[1] /= unit[1]
         mx = [int(self.size[0]*scale/unit[0])+1, int(self.size[1]*scale/unit[1]+1)]
         self.SetScrollbars(unit[0], unit[1], mx[0], mx[1], pos[0], pos[1])
-        self.log.log("Exit MapCanvas->fix_scroll(self)", ORPG_DEBUG)
 
     def on_resize(self, evt):
-        self.log.log("Enter MapCanvas->on_resize(self, evt)", ORPG_DEBUG)
         self.fix_scroll()
         wx.CallAfter(self.Refresh, True)
         evt.Skip()
-        self.log.log("Exit MapCanvas->on_resize(self, evt)", ORPG_DEBUG)
 
     def on_erase_background(self, evt):
-        self.log.log("Enter MapCanvas->on_erase_background(self, evt)", ORPG_DEBUG)
         evt.Skip()
-        self.log.log("Exit MapCanvas->on_erase_background(self, evt)", ORPG_DEBUG)
 
     def on_paint(self, evt):
-        self.log.log("Enter MapCanvas->on_paint(self, evt)", ORPG_DEBUG)
         scale = self.layers['grid'].mapscale
         scrollsize = self.GetScrollPixelsPerUnit()
         clientsize = self.GetClientSize()
@@ -303,21 +274,17 @@
             del dc
             wdc = self.preppaint()
             wdc.DrawBitmap(bmp, topleft[0], topleft[1])
-            if self.frame.settings.get_setting("AlwaysShowMapScale") == "1":
+            if settings.get_setting("AlwaysShowMapScale") == "1":
                 self.showmapscale(wdc)
         try: evt.Skip()
         except: pass
-        self.log.log("Exit MapCanvas->on_paint(self, evt)", ORPG_DEBUG)
 
     def preppaint(self):
-        self.log.log("Enter MapCanvas->preppaint(self)", ORPG_DEBUG)
         dc = wx.PaintDC(self)
         self.PrepareDC(dc)
-        self.log.log("Exit MapCanvas->preppaint(self)", ORPG_DEBUG)
         return (dc)
 
     def showmapscale(self, dc):
-        self.log.log("Enter MapCanvas->showmapscale(self, dc)", ORPG_DEBUG)
         scalestring = "Scale x" + `self.layers['grid'].mapscale`[:3]
         (textWidth, textHeight) = dc.GetTextExtent(scalestring)
         dc.SetUserScale(1, 1)
@@ -330,13 +297,11 @@
         dc.DrawText(scalestring, x+1, y+1)
         dc.SetPen(wx.NullPen)
         dc.SetBrush(wx.NullBrush)
-        self.log.log("Exit MapCanvas->showmapscale(self, dc)", ORPG_DEBUG)
 
     def snapMarker(self, snapPoint):
         """Based on the position and unit size, figure out where we need to snap to.  As is, on
         a square grid, there are four possible places to snap.  On a hex gid, there are 6 or 12 snap
         points."""
-        self.log.log("Enter MapCanvas->snapMarker(self, snapPoint)", ORPG_DEBUG)
 
         # If snap to grid is disabled, simply return snapPoint unmodified
         if self.layers['grid'].snap:
@@ -362,48 +327,38 @@
                 else: quadYPos = offsetY + size
                 # Create our snap snapPoint and return it
                 snapPoint = wx.Point( quadXPos, quadYPos )
-        self.log.log("Exit MapCanvas->snapMarker(self, snapPoint)", ORPG_DEBUG)
         return snapPoint
 
     # Bunch of math stuff for marking and measuring
     def calcSlope(self, start, stop):
         """Calculates the slop of a line and returns it."""
-        self.log.log("Enter MapCanvas->calcSlope(self, start, stop)", ORPG_DEBUG)
         if start.x == stop.x: s = 0.0001
         else: s = float((stop.y - start.y)) / float((stop.x - start.x))
-        self.log.log("Exit MapCanvas->calcSlope(self, start, stop)", ORPG_DEBUG)
         return s
 
     def calcSlopeToAngle(self, slope):
         """Based on the input slope, the angle (in degrees) will be returned."""
-        self.log.log("Enter MapCanvas->calcSlopeToAngle(self, slope)", ORPG_DEBUG)
         # See if the slope is neg or positive
         if slope == abs(slope):
             # Slope is positive, so make sure it's not zero
             if slope == 0: a = 0
             else: a = 360 - atan(slope) * (180.0/pi)
         else: a = atan(abs(slope)) * (180.0/pi)
-        self.log.log("Exit MapCanvas->calcSlopeToAngle(self, slope)", ORPG_DEBUG)
         return a
 
     def calcLineAngle(self, start, stop):
         """Based on two points that are on a line, return the angle of that line."""
-        self.log.log("Enter MapCanvas->calcLineAngle(self, start, stop)", ORPG_DEBUG)
         a = self.calcSlopeToAngle( self.calcSlope( start, stop ) )
-        self.log.log("Exit MapCanvas->calcLineAngle(self, start, stop)", ORPG_DEBUG)
         return a
 
     def calcPixelDistance(self, start, stop):
         """Calculate the distance between two pixels and returns it.  The calculated
         distance is the Euclidean Distance, which is:
         d = sqrt( (x2 - x1)**2 + (y2 - y1)**2 )"""
-        self.log.log("Enter MapCanvas->calcPixelDistance(self, start, stop)", ORPG_DEBUG)
         d = sqrt( abs((stop.x - start.x)**2 - (stop.y - start.y)**2) )
-        self.log.log("Exit MapCanvas->calcPixelDistance(self, start, stop)", ORPG_DEBUG)
         return d
 
     def calcUnitDistance(self, start, stop, lineAngle):
-        self.log.log("Enter MapCanvas->calcUnitDistance(self, start, stop, lineAngle)", ORPG_DEBUG)
         distance = self.calcPixelDistance( start, stop )
         ln = "%0.2f" % lineAngle
         if self.layers['grid'].mode == GRID_HEXAGON:
@@ -413,12 +368,10 @@
             if ln == "0.00" or ln == "359.99": ud = distance / self.layers['grid'].unit_size
             else: ud = (sqrt(abs((stop.x - start.x)**2 + (stop.y - start.y)**2))) / self.layers['grid'].unit_size
             #ud = sqrt( abs((stop.x - start.x)**2 - (stop.y - start.y)**2) )
-        self.log.log("Exit MapCanvas->calcUnitDistance(self, start, stop, lineAngle)", ORPG_DEBUG)
         return ud
 
     def on_tape_motion(self, evt):
         """Track mouse motion so we can update the marker visual every time it's moved"""
-        self.log.log("Enter MapCanvas->on_tape_motion(self, evt)", ORPG_DEBUG)
         # Make sure we have a mode to do anything, otherwise, we ignore this
         if self.markerMode:
             # Grap the current DC for all of the marker modes
@@ -428,7 +381,7 @@
             # Grab the current map position
             pos = self.snapMarker( evt.GetLogicalPosition( dc ) )
             # Enable brush optimizations
-            #dc.SetOptimization( True )
+            # dc.SetOptimization( True )
             # Set up the pen used for drawing our marker
             dc.SetPen( wx.Pen(wx.RED, 1, wx.LONG_DASH) )
             # Now, based on the marker mode, draw the right thing
@@ -449,12 +402,10 @@
             # Disable brush optimizations
             #dc.SetOptimization( False )
             del dc
-        self.log.log("Exit MapCanvas->on_tape_motion(self, evt)", ORPG_DEBUG)
 
     def on_tape_down(self, evt):
         """Greg's experimental tape measure code.  Hopefully, when this is done, it will all be
         modal based on a toolbar."""
-        self.log.log("Enter MapCanvas->on_tape_down(self, evt)", ORPG_DEBUG)
         dc = wx.ClientDC( self )
         self.PrepareDC( dc )
         dc.SetUserScale(self.layers['grid'].mapscale,self.layers['grid'].mapscale)
@@ -484,11 +435,9 @@
         self.markerStart = pos
         self.markerStop = pos
         del dc
-        self.log.log("Exit MapCanvas->on_tape_down(self, evt)", ORPG_DEBUG)
 
     def on_tape_up(self, evt):
         """When we release the middle button, disable any marking updates that we have been doing."""
-        self.log.log("Enter MapCanvas->on_tape_up(self, evt)", ORPG_DEBUG)
         # If we are in measure mode, draw the actual UNIT distance
         if self.markerMode == MARKER_MODE_MEASURE:
             dc = wx.ClientDC( self )
@@ -521,48 +470,36 @@
             del font
             del dc
         self.markerMode = MARKER_MODE_NONE
-        self.log.log("Exit MapCanvas->on_tape_up(self, evt)", ORPG_DEBUG)
 
     # MODE 1 = MOVE, MODE 2 = whiteboard, MODE 3 = Tape measure
     def on_left_down(self, evt):
-        self.log.log("Enter MapCanvas->on_left_down(self, evt)", ORPG_DEBUG)
         if evt.ShiftDown(): self.on_tape_down (evt)
         else: self.frame.on_left_down(evt)
-        self.log.log("Exit MapCanvas->on_left_down(self, evt)", ORPG_DEBUG)
 
     def on_right_down(self, evt):
-        self.log.log("Enter MapCanvas->on_right_down(self, evt)", ORPG_DEBUG)
         if evt.ShiftDown(): pass
         else: self.frame.on_right_down(evt)
-        self.log.log("Exit MapCanvas->on_right_down(self, evt)", ORPG_DEBUG)
 
     def on_left_dclick(self, evt):
-        self.log.log("Enter MapCanvas->on_left_dclick(self, evt)", ORPG_DEBUG)
         if evt.ShiftDown(): pass
         else: self.frame.on_left_dclick(evt)
-        self.log.log("Exit MapCanvas->on_left_dclick(self, evt)", ORPG_DEBUG)
 
     def on_left_up(self, evt):
-        self.log.log("Enter MapCanvas->on_left_up(self, evt)", ORPG_DEBUG)
         if evt.ShiftDown(): self.on_tape_up(evt)
-        elif open_rpg.get_component("tree").dragging:
-            tree = open_rpg.get_component("tree")
+        elif component.get("tree").dragging:
+            tree = component.get("tree")
             if tree.drag_obj.map_aware():
                 tree.drag_obj.on_send_to_map(evt)
                 tree.dragging = False
                 tree.drag_obj = None
         else: self.frame.on_left_up(evt)
-        self.log.log("Exit MapCanvas->on_left_up(self, evt)", ORPG_DEBUG)
 
     def on_motion(self, evt):
-        self.log.log("Enter MapCanvas->on_motion(self, evt)", ORPG_DEBUG)
         if evt.ShiftDown(): self.on_tape_motion(evt)
-        elif evt.LeftIsDown() and open_rpg.get_component("tree").dragging: pass
+        elif evt.LeftIsDown() and component.get("tree").dragging: pass
         else: self.frame.on_motion(evt)
-        self.log.log("Exit MapCanvas->on_motion(self, evt)", ORPG_DEBUG)
 
     def on_zoom_out(self, evt):
-        self.log.log("Enter MapCanvas->on_zoom_out(self, evt)", ORPG_DEBUG)
         if self.layers['grid'].mapscale > 0.2:
             # attempt to keep same logical point at center of screen
             scale = self.layers['grid'].mapscale
@@ -592,10 +529,8 @@
             dc.EndDrawing()
             del dc
             self.zoom_display_timer.Start(500,1)
-        self.log.log("Exit MapCanvas->on_zoom_out(self, evt)", ORPG_DEBUG)
 
     def on_zoom_in(self, evt):
-        self.log.log("Enter MapCanvas->on_zoom_in(self, evt)", ORPG_DEBUG)
         # attempt to keep same logical point at center of screen
         scale = self.layers['grid'].mapscale
         scrollsize = self.GetScrollPixelsPerUnit()
@@ -624,15 +559,12 @@
         dc.EndDrawing()
         del dc
         self.zoom_display_timer.Start(500, 1)
-        self.log.log("Exit MapCanvas->on_zoom_in(self, evt)", ORPG_DEBUG)
 
     def on_prop(self, evt):
-        self.log.log("Enter MapCanvas->on_prop(self, evt)", ORPG_DEBUG)
-        self.session = open_rpg.get_component("session")
-        self.chat = open_rpg.get_component("chat")
+        self.session = component.get("session")
+        self.chat = component.get("chat")
         if (self.session.my_role() != self.session.ROLE_GM):
             self.chat.InfoPost("You must be a GM to use this feature")
-            self.log.log("Exit MapCanvas->on_prop(self, evt)", ORPG_DEBUG)
             return
         dlg = general_map_prop_dialog(self.frame.GetParent(),self.size,self.layers['bg'],self.layers['grid'])
         if dlg.ShowModal() == wx.ID_OK:
@@ -641,10 +573,8 @@
             self.Refresh(False)
         dlg.Destroy()
         os.chdir(self.root_dir)
-        self.log.log("Exit MapCanvas->on_prop(self, evt)", ORPG_DEBUG)
 
     def add_miniature(self, min_url, min_label='', min_unique=-1):
-        self.log.log("Enter MapCanvas->add_miniature(self, min_url, min_label, min_unique)", ORPG_DEBUG)
         if min_unique == -1: min_unique = not self.use_serial
         if min_url == "" or min_url == "http://": return
         if min_url[:7] != "http://" : min_url = "http://" + min_url
@@ -659,27 +589,19 @@
         try:
             id = 'mini-' + self.frame.session.get_next_id()
             self.layers['miniatures'].add_miniature(id, min_url, label=min_label)
-        except Exception, e:
-            self.log.log(traceback.format_exc(), ORPG_GENERAL)
-            self.log.log("Unable to load/resolve URL: " + min_url + " on resource ' + min_label + ' !!!", ORPG_GENERAL)
+        except:
             self.layers['miniatures'].rollback_serial()
         wx.EndBusyCursor()
         self.send_map_data()
         self.Refresh(False)
-        self.log.log("Exit MapCanvas->add_miniature(self, min_url, min_label, min_unique)", ORPG_DEBUG)
 
     def get_label_from_url(self, url=''):
-        self.log.log("Enter MapCanvas->get_label_from_url(self, url)", ORPG_DEBUG)
-        if url == '':
-            self.log.log("Exit MapCanvas->get_label_from_url(self, url)", ORPG_DEBUG)
-            return ''
+        if url == '': return ''
         start = url.rfind("/")+1
         label = url[start:len(url)-4]
-        self.log.log("Exit MapCanvas->get_label_from_url(self, url)", ORPG_DEBUG)
         return label
 
     def toxml(self, action="update"):
-        self.log.log("Enter MapCanvas->toxml(self, " + action + ")", ORPG_DEBUG)
         if action == "new":
             self.size_changed = 1
         xml_str = "<map version='" + self.map_version + "'"
@@ -692,36 +614,27 @@
         for k in keys:
             if (k != "fog" or action != "update"): s += self.layers[k].layerToXML(action)
         self.size_changed = 0
-        if s:
-            self.log.log("Exit MapCanvas->toxml(self, " + action + ")", ORPG_DEBUG)
-            return xml_str + " action='" + action + "'>" + s + "</map>"
+        if s: return xml_str + " action='" + action + "'>" + s + "</map>"
         else:
-            if changed:
-                self.log.log("Exit MapCanvas->toxml(self, " + action + ")", ORPG_DEBUG)
-                return xml_str + " action='" + action + "'/>"
-            else:
-                self.log.log("Exit MapCanvas->toxml(self, " + action + ")", ORPG_DEBUG)
-                return ""
+            if changed: return xml_str + " action='" + action + "'/>"
+            else: return ""
 
     def takexml(self, xml):
-        #
-        # Added Process Dialog to display during long map parsings
-        # as well as a try block with an exception traceback to try
-        # and isolate some of the map related problems users have been
-        # experiencing --Snowdog 5/15/03
-        #
-        # Apparently Process Dialog causes problems with linux.. commenting it out. sheez.
-        #  --Snowdog 5/27/03
-        self.log.log("Enter MapCanvas->takexml(self, xml)", ORPG_DEBUG)
+        """
+          Added Process Dialog to display during long map parsings
+          as well as a try block with an exception traceback to try
+          and isolate some of the map related problems users have been
+          experiencing --Snowdog 5/15/03
+         
+          Apparently Process Dialog causes problems with linux.. commenting it out. sheez.
+           --Snowdog 5/27/03
+        """
         try:
             #parse the map DOM
             xml_dom = parseXml(xml)
-            if xml_dom == None:
-                self.log.log("xml_dom == None\n" + xml, ORPG_INFO)
-                self.log.log("Exit MapCanvas->takexml(self, xml)", ORPG_DEBUG)
-                return
+            if xml_dom == None: return
             node_list = xml_dom.getElementsByTagName("map")
-            if len(node_list) < 1: self.log.log("Invalid XML format for mapper", ORPG_INFO)
+            if len(node_list) < 1: pass
             else:
                 # set map version to incoming data so layers can convert
                 self.map_version = node_list[0].getAttribute("version")
@@ -762,18 +675,14 @@
                 self.map_version = MAP_VERSION
                 self.Refresh(False)
             xml_dom.unlink()  # eliminate circular refs
-        except:
-            self.log.log(traceback.format_exc(), ORPG_GENERAL)
-            self.log.log("EXCEPTION: Critical Error Loading Map!!!", ORPG_GENERAL)
-        self.log.log("Exit MapCanvas->takexml(self, xml)", ORPG_DEBUG)
+        except: pass
 
     def re_ids_in_xml(self, xml):
-        self.log.log("Enter MapCanvas->re_ids_in_xml(self, xml)", ORPG_DEBUG)
         new_xml = ""
         tmp_map = map_msg()
         xml_dom = parseXml(str(xml))
         node_list = xml_dom.getElementsByTagName("map")
-        if len(node_list) < 1: self.log.log("Invalid XML format for mapper", ORPG_INFO)
+        if len(node_list) < 1: pass
         else:
             tmp_map.init_from_dom(node_list[0])
             if tmp_map.children.has_key("miniatures"):
@@ -801,19 +710,15 @@
                             l.init_prop("id", id)
             new_xml = tmp_map.get_all_xml()
         if xml_dom: xml_dom.unlink()
-        self.log.log("Exit MapCanvas->re_ids_in_xml(self, xml)", ORPG_DEBUG)
         return str(new_xml)
 
 class map_wnd(wx.Panel):
     def __init__(self, parent, id):
-        self.log = open_rpg.get_component('log')
-        self.log.log("Enter map_wnd", ORPG_DEBUG)
         wx.Panel.__init__(self, parent, id)
         self.canvas = MapCanvas(self, -1)
-        self.session = open_rpg.get_component('session')
-        self.settings = open_rpg.get_component('settings')
-        self.chat = open_rpg.get_component('chat')
-        self.top_frame = open_rpg.get_component('frame')
+        self.session = component.get('session')
+        self.chat = component.get('chat')
+        self.top_frame = component.get('frame')
         self.root_dir = os.getcwd()
         self.current_layer = 2
         self.layer_tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS)
@@ -839,38 +744,30 @@
         #self.Bind(wx.EVT_SIZE, self.on_size)
         self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
         self.load_default()
-        self.log.log("Exit map_wnd", ORPG_DEBUG)
 
     def OnLeave(self, evt):
         if "__WXGTK__" in wx.PlatformInfo: wx.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
 
     def load_default(self):
-        self.log.log("Enter map_wnd->load_default(self)", ORPG_DEBUG)
         if self.session.is_connected() and (self.session.my_role() != self.session.ROLE_GM) and (self.session.use_roles()):
             self.chat.InfoPost("You must be a GM to use this feature")
-            self.log.log("Exit map_wnd->load_default(self)", ORPG_DEBUG)
             return
-        f = open(orpg.dirpath.dir_struct["template"] + "default_map.xml")
+        f = open(dir_struct["template"] + "default_map.xml")
         self.new_data(f.read())
         f.close()
         self.canvas.send_map_data("new")
         if not self.session.is_connected() and (self.session.my_role() != self.session.ROLE_GM):
             self.session.update_role("GM")
-        self.log.log("Exit map_wnd->load_default(self)", ORPG_DEBUG)
 
     def new_data(self, data):
-        self.log.log("Enter map_wnd->new_data(self, data)", ORPG_DEBUG)
         self.canvas.takexml(data)
         self.update_tools()
-        self.log.log("Exit map_wnd->new_data(self, data)", ORPG_DEBUG)
 
     def on_save(self,evt):
-        self.log.log("Enter map_wnd->new_data(self, data)", ORPG_DEBUG)
         if (self.session.my_role() != self.session.ROLE_GM):
             self.chat.InfoPost("You must be a GM to use this feature")
-            self.log.log("Exit map_wnd->new_data(self, data)", ORPG_DEBUG)
             return
-        d = wx.FileDialog(self.GetParent(), "Save map data", orpg.dirpath.dir_struct["user"], "", "*.xml", wx.SAVE)
+        d = wx.FileDialog(self.GetParent(), "Save map data", dir_struct["user"], "", "*.xml", wx.SAVE)
         if d.ShowModal() == wx.ID_OK:
             f = open(d.GetPath(), "w")
             data = '<nodehandler class="min_map" icon="compass" module="core" name="miniature Map">'
@@ -881,15 +778,12 @@
             f.close()
         d.Destroy()
         os.chdir(self.root_dir)
-        self.log.log("Exit map_wnd->new_data(self, data)", ORPG_DEBUG)
 
     def on_open(self, evt):
-        self.log.log("Enter map_wnd->on_open(self, evt)", ORPG_DEBUG)
         if self.session.is_connected() and (self.session.my_role() != self.session.ROLE_GM) and (self.session.use_roles()):
             self.chat.InfoPost("You must be a GM to use this feature")
-            self.log.log("Exit map_wnd->on_open(self, evt)", ORPG_DEBUG)
             return
-        d = wx.FileDialog(self.GetParent(), "Select a file", orpg.dirpath.dir_struct["user"], "", "*.xml", wx.OPEN)
+        d = wx.FileDialog(self.GetParent(), "Select a file", dir_struct["user"], "", "*.xml", wx.OPEN)
         if d.ShowModal() == wx.ID_OK:
             f = open(d.GetPath())
             map_string = f.read()
@@ -902,25 +796,18 @@
                     self.session.update_role("GM")
         d.Destroy()
         os.chdir(self.root_dir)
-        self.log.log("Exit map_wnd->on_open(self, evt)", ORPG_DEBUG)
 
     def get_current_layer_handler(self):
-        self.log.log("Enter map_wnd->get_current_layer_handler(self)", ORPG_DEBUG)
-        self.log.log("Exit map_wnd->get_current_layer_handler(self)", ORPG_DEBUG)
         return self.layer_handlers[self.current_layer]
 
     def get_tab_index(self, layer):
         """Return the index of a chatpanel in the wxNotebook."""
-        self.log.log("Enter map_wnd->get_tab_index(self, layer)", ORPG_DEBUG)
         for i in xrange(self.layer_tabs.GetPageCount()):
             if (self.layer_tabs.GetPageText(i) == layer):
-                self.log.log("Exit map_wnd->get_tab_index(self, layer) return " + str(i), ORPG_DEBUG)
                 return i
-        self.log.log("Exit map_wnd->get_tab_index(self, layer) return 0", ORPG_DEBUG)
         return 0
 
     def on_layer_change(self, evt):
-        self.log.log("Enter map_wnd->on_layer_change(self, evt)", ORPG_DEBUG)
         layer = self.layer_tabs.GetPage(evt.GetSelection())
         for i in xrange(0, len(self.layer_handlers)):
             if layer == self.layer_handlers[i]: self.current_layer = i
@@ -930,67 +817,43 @@
             else: bg.url_path.Show(True)
         self.canvas.Refresh(False)
         evt.Skip()
-        self.log.log("Exit map_wnd->on_layer_change(self, evt)", ORPG_DEBUG)
 
     def on_left_down(self, evt):
-        self.log.log("Enter map_wnd->on_left_down(self, evt)", ORPG_DEBUG)
-        self.log.log("Exit map_wnd->on_left_down(self, evt)", ORPG_DEBUG)
         self.layer_handlers[self.current_layer].on_left_down(evt)
 
     #double click handler added by Snowdog 5/03
     def on_left_dclick(self, evt):
-        self.log.log("Enter map_wnd->on_left_dclick(self, evt)", ORPG_DEBUG)
-        self.log.log("Exit map_wnd->on_left_dclick(self, evt)", ORPG_DEBUG)
         self.layer_handlers[self.current_layer].on_left_dclick(evt)
 
     def on_right_down(self, evt):
-        self.log.log("Enter map_wnd->on_right_down(self, evt)", ORPG_DEBUG)
-        self.log.log("Exit map_wnd->on_right_down(self, evt)", ORPG_DEBUG)
         self.layer_handlers[self.current_layer].on_right_down(evt)
 
     def on_left_up(self, evt):
-        self.log.log("Enter map_wnd->on_left_up(self, evt)", ORPG_DEBUG)
-        self.log.log("Exit map_wnd->on_left_up(self, evt)", ORPG_DEBUG)
         self.layer_handlers[self.current_layer].on_left_up(evt)
 
     def on_motion(self, evt):
-        self.log.log("Enter map_wnd->on_motion(self, evt)", ORPG_DEBUG)
-        self.log.log("Exit map_wnd->on_motion(self, evt)", ORPG_DEBUG)
         self.layer_handlers[self.current_layer].on_motion(evt)
 
     def MapBar(self, id, data):
-        self.log.log("Enter map_wnd->MapBar(self, id, data)", ORPG_DEBUG)
         self.canvas.MAP_MODE = data
-        if id == 1:
-            self.canvas.MAP_MODE = data
-        self.log.log("Exit map_wnd->MapBar(self, id, data)", ORPG_DEBUG)
+        if id == 1: self.canvas.MAP_MODE = data
 
     def set_map_focus(self, evt):
-        self.log.log("Enter map_wnd->set_map_focus(self, evt)", ORPG_DEBUG)
         self.canvas.SetFocus()
-        self.log.log("Exit map_wnd->set_map_focus(self, evt)", ORPG_DEBUG)
 
     def pre_exit_cleanup(self):
-        self.log.log("Enter map_wnd->pre_exit_cleanup(self)", ORPG_DEBUG)
         # do some pre exit clean up for bitmaps or other objects
         try:
             ImageHandler.flushCache()
             self.canvas.pre_destory_cleanup()
-        except Exception, e:
-            self.log.log(traceback.format_exc(), ORPG_CRITICAL)
-            self.log.log("EXCEPTION: " + str(e), ORPG_CRITICAL)
-        self.log.log("Exit map_wnd->pre_exit_cleanup(self)", ORPG_DEBUG)
+        except: pass
 
     def update_tools(self):
-        self.log.log("Enter map_wnd->update_tools(self)", ORPG_DEBUG)
         for h in self.layer_handlers:
             h.update_info()
-        self.log.log("Exit map_wnd->update_tools(self)", ORPG_DEBUG)
 
     def on_hk_map_layer(self, evt):
-        self.log.log("Enter map_wnd->on_hk_map_layer(self, evt)", ORPG_DEBUG)
         id = self.top_frame.mainmenu.GetHelpString(evt.GetId())
-        #print evt.GetMenu().GetTitle()
         if id == "Background Layer": self.current_layer = self.get_tab_index("Background")
         if id == "Grid Layer": self.current_layer = self.get_tab_index("Grid")
         if id == "Miniature Layer": self.current_layer = self.get_tab_index("Miniatures")
@@ -998,15 +861,11 @@
         elif id == "Fog Layer": self.current_layer = self.get_tab_index("Fog")
         elif id == "General Properties": self.current_layer = self.get_tab_index("General")
         self.layer_tabs.SetSelection(self.current_layer)
-        self.log.log("Exit map_wnd->on_hk_map_layer(self, evt)", ORPG_DEBUG)
 
     def on_flush_cache(self, evt):
-        self.log.log("Enter map_wnd->on_flush_cache(self, evt)", ORPG_DEBUG)
         ImageHandler.flushCache()
-        self.log.log("Exit map_wnd->on_flush_cache(self, evt)", ORPG_DEBUG)
 
     def build_menu(self):
-        self.log.log("Enter map_wnd->build_menu(self)", ORPG_DEBUG)
         # temp menu
         menu = wx.Menu()
         item = wx.MenuItem(menu, wx.ID_ANY, "&Load Map", "Load Map")
@@ -1043,10 +902,7 @@
         self.top_frame.Bind(wx.EVT_MENU, self.canvas.on_prop, item)
         menu.AppendItem(item)
         self.top_frame.mainmenu.Insert(2, menu, '&Map')
-        self.log.log("Exit map_wnd->build_menu(self)", ORPG_DEBUG)
 
     def get_hot_keys(self):
-        self.log.log("Enter map_wnd->get_hot_keys(self)", ORPG_DEBUG)
         self.build_menu()
-        self.log.log("Exit map_wnd->get_hot_keys(self)", ORPG_DEBUG)
         return []