comparison orpg/main.py @ 74:fdcca00696ea ornery-dev

Continuing the code refinement.
author sirebral
date Fri, 21 Aug 2009 21:40:22 -0500
parents 8bc955faf819
children dd4be4817377
comparison
equal deleted inserted replaced
73:7b752c9d0c28 74:fdcca00696ea
32 from orpg.orpg_wx import * 32 from orpg.orpg_wx import *
33 from orpg.orpgCore import * 33 from orpg.orpgCore import *
34 from orpg_version import * 34 from orpg_version import *
35 from orpg.orpg_windows import * 35 from orpg.orpg_windows import *
36 36
37 from orpg.dirpath import dir_struct 37 import wx.py
38
39 from orpg import minidom 38 from orpg import minidom
40
41 import orpg.player_list 39 import orpg.player_list
42
43 import orpg.tools.pluginui as pluginUI 40 import orpg.tools.pluginui as pluginUI
44 import orpg.tools.aliaslib 41 import orpg.tools.aliaslib
45 import orpg.tools.toolBars 42 import orpg.tools.toolBars
46 import orpg.tools.orpg_sound 43 import orpg.tools.orpg_sound
47 import orpg.tools.rgbhex 44 import orpg.tools.rgbhex
48
49 import orpg.gametree.gametree 45 import orpg.gametree.gametree
50 import orpg.chat.chatwnd 46 import orpg.chat.chatwnd
51
52 import orpg.networking.gsclient 47 import orpg.networking.gsclient
53 import orpg.networking.mplay_client 48 import orpg.networking.mplay_client
54
55 import orpg.mapper.map 49 import orpg.mapper.map
56 import orpg.mapper.images 50 import orpg.mapper.images
57 51
58 import upmana.updatemana 52 import upmana.updatemana
59 import upmana.manifest as manifest 53 import upmana.manifest as manifest
60 import wx.py 54
61 55 from orpg.dirpath import dir_struct
62 from orpg.dieroller.utils import DiceManager 56 from orpg.dieroller.utils import DiceManager
63 from orpg.tools.orpg_settings import settings #imported, not used yet 57 from orpg.tools.orpg_settings import settings
64 from orpg.tools.validate import validate 58 from orpg.tools.validate import validate
65 from orpg.tools.passtool import PassTool 59 from orpg.tools.passtool import PassTool
66 from orpg.tools.orpg_log import logger 60 from orpg.tools.orpg_log import logger
67 from orpg.tools.decorators import debugging 61 from orpg.tools.decorators import debugging
68 from orpg.tools.metamenus import MenuBarEx 62 from orpg.tools.metamenus import MenuBarEx
70 #from xml.etree.ElementTree import ElementTree, Element 64 #from xml.etree.ElementTree import ElementTree, Element
71 #from xml.etree.ElementTree import fromstring, tostring 65 #from xml.etree.ElementTree import fromstring, tostring
72 from orpg.orpg_xml import xml #to be replaced by etree 66 from orpg.orpg_xml import xml #to be replaced by etree
73 67
74 68
75
76 #################################### 69 ####################################
77 ## Main Frame 70 ## Main Frame
78 #################################### 71 ####################################
79 72
80 73
81 class orpgFrame(wx.Frame): 74 class orpgFrame(wx.Frame):
82 @debugging 75 @debugging
83 def __init__(self, parent, id, title): 76 def __init__(self, parent, id, title):
84 wx.Frame.__init__(self, parent, id, title, wx.Point(100, 100), wx.Size(600,420), style=wx.DEFAULT_FRAME_STYLE) 77 wx.Frame.__init__(self, parent, id, title, wx.Point(100, 100), wx.Size(600,420), style=wx.DEFAULT_FRAME_STYLE)
85 self.orpgLog = component.get('log')
86 self.xml = component.get("xml")
87 self.validate = component.get("validate") 78 self.validate = component.get("validate")
88 self.orpgLog.log("Enter orpgFrame", ORPG_DEBUG) 79 logger.debug("Enter orpgFrame")
89 self.rgbcovert = orpg.tools.rgbhex.RGBHex() 80 self.rgb = orpg.tools.rgbhex.RGBHex()
90 self._mgr = AUI.AuiManager(self) 81 self._mgr = AUI.AuiManager(self)
91 82
92 # Determine which icon format to use 83 # Determine which icon format to use
93 icon = None 84 icon = None
94 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) 85 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
128 logger.debug("GUI Built") 119 logger.debug("GUI Built")
129 component.add("chat",self.chat) 120 component.add("chat",self.chat)
130 component.add("map",self.map) 121 component.add("map",self.map)
131 component.add("alias", self.aliaslib) 122 component.add("alias", self.aliaslib)
132 123
133 self.orpgLog.log("openrpg components all added", ORPG_DEBUG) 124 logger.debug("openrpg components all added")
134 self.tree.load_tree(settings.get_setting("gametree")) 125 self.tree.load_tree(settings.get_setting("gametree"))
135 logger.debug("Tree Loaded") 126 logger.debug("Tree Loaded")
136 self.players.size_cols() 127 self.players.size_cols()
137 128
138 #Load the Plugins This has to be after the chat component has been added 129 #Load the Plugins This has to be after the chat component has been added
289 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", tabtheme == 'customflat') 280 self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", tabtheme == 'customflat')
290 281
291 if kwargs.has_key('style'): newstyle = kwargs['style'] 282 if kwargs.has_key('style'): newstyle = kwargs['style']
292 else: 283 else:
293 try: newstyle = args[1] 284 try: newstyle = args[1]
294 except: self.orpgLog.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL); return 285 except: logger.general('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)'); return
295 if kwargs.has_key('menu'): menu = kwargs['menu'] 286 if kwargs.has_key('menu'): menu = kwargs['menu']
296 else: 287 else:
297 try: menu = args[0] 288 try: menu = args[0]
298 except: self.orpgLog.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL); return 289 except: logger.general('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)'); return
299 290
300 if kwargs.has_key('graidentTo'): graidentTo = kwargs['graidentTo'] 291 if kwargs.has_key('graidentTo'): graidentTo = kwargs['graidentTo']
301 else: graidentTo = None 292 else: graidentTo = None
302 if kwargs.has_key('graidentFrom'): graidentFrom = kwargs['graidentFrom'] 293 if kwargs.has_key('graidentFrom'): graidentFrom = kwargs['graidentFrom']
303 else: graidentFrom = None 294 else: graidentFrom = None
304 if kwargs.has_key('textColor'): textColor = kwargs['textColor'] 295 if kwargs.has_key('textColor'): textColor = kwargs['textColor']
305 else: textColor = None 296 else: textColor = None
306 297
307 #Run though the current tabbed window list and remove those that have been closed 298 #Run though the current tabbed window list and remove those that have been closed
308 tabbedwindows = component.get("tabbedWindows") 299 tabbedwindows = component.get("tabbedWindows")
309 rgbc = orpg.tools.rgbhex.RGBHex()
310 new = [] 300 new = []
311 for wnd in tabbedwindows: 301 for wnd in tabbedwindows:
312 try: style = wnd.GetWindowStyleFlag(); new.append(wnd) 302 try: style = wnd.GetWindowStyleFlag(); new.append(wnd)
313 except: pass 303 except: pass
314 tabbedwindows = new 304 tabbedwindows = new
315 component.add("tabbedWindows", tabbedwindows) 305 component.add("tabbedWindows", tabbedwindows)
316 306
317 #Run though the new list and set the proper styles 307 #Run though the new list and set the proper styles
318 tabbg = settings.get_setting('TabBackgroundGradient') 308 tabbg = settings.get_setting('TabBackgroundGradient')
319 rgbc = orpg.tools.rgbhex.RGBHex() 309 (red, green, blue) = self.rgb.rgb_tuple(tabbg)
320 (red, green, blue) = rgbc.rgb_tuple(tabbg)
321 310
322 for wnd in tabbedwindows: 311 for wnd in tabbedwindows:
323 style = wnd.GetWindowStyleFlag() 312 style = wnd.GetWindowStyleFlag()
324 # remove old tabs style 313 # remove old tabs style
325 mirror = ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS | FNB.FNB_COLORFUL_TABS) 314 mirror = ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS | FNB.FNB_COLORFUL_TABS)
361 350
362 @debugging 351 @debugging
363 def OnMB_OpenRPGTabStylesSlantedCustom(self): 352 def OnMB_OpenRPGTabStylesSlantedCustom(self):
364 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"): 353 if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"):
365 settings.set_setting('TabTheme', 'customslant') 354 settings.set_setting('TabTheme', 'customslant')
366 rgbc = orpg.tools.rgbhex.RGBHex()
367 gfrom = settings.get_setting('TabGradientFrom') 355 gfrom = settings.get_setting('TabGradientFrom')
368 (fred, fgreen, fblue) = rgbc.rgb_tuple(gfrom) 356 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom)
369 gto = settings.get_setting('TabGradientTo') 357 gto = settings.get_setting('TabGradientTo')
370 (tored, togreen, toblue) = rgbc.rgb_tuple(gto) 358 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto)
371 tabtext = settings.get_setting('TabTextColor') 359 tabtext = settings.get_setting('TabTextColor')
372 (tred, tgreen, tblue) = rgbc.rgb_tuple(tabtext) 360 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext)
373 tabbg = settings.get_setting('TabBackgroundGradient') 361 tabbg = settings.get_setting('TabBackgroundGradient')
374 (red, green, blue) = rgbc.rgb_tuple(tabbg) 362 (red, green, blue) = self.rgb.rgb_tuple(tabbg)
375 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8, 363 self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8,
376 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), 364 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue),
377 textColor=wx.Color(tred, tgreen, tblue)) 365 textColor=wx.Color(tred, tgreen, tblue))
378 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True) 366 else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True)
379 367
395 383
396 @debugging 384 @debugging
397 def OnMB_OpenRPGTabStylesFlatCustom(self): 385 def OnMB_OpenRPGTabStylesFlatCustom(self):
398 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"): 386 if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"):
399 settings.set_setting('TabTheme', 'customflat') 387 settings.set_setting('TabTheme', 'customflat')
400 rgbc = orpg.tools.rgbhex.RGBHex()
401 gfrom = settings.get_setting('TabGradientFrom') 388 gfrom = settings.get_setting('TabGradientFrom')
402 (fred, fgreen, fblue) = rgbc.rgb_tuple(gfrom) 389 (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom)
403 gto = settings.get_setting('TabGradientTo') 390 gto = settings.get_setting('TabGradientTo')
404 (tored, togreen, toblue) = rgbc.rgb_tuple(gto) 391 (tored, togreen, toblue) = self.rgb.rgb_tuple(gto)
405 tabtext = settings.get_setting('TabTextColor') 392 tabtext = settings.get_setting('TabTextColor')
406 (tred, tgreen, tblue) = rgbc.rgb_tuple(tabtext) 393 (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext)
407 tabbg = settings.get_setting('TabBackgroundGradient') 394 tabbg = settings.get_setting('TabBackgroundGradient')
408 (red, green, blue) = rgbc.rgb_tuple(tabbg) 395 (red, green, blue) = self.rgb.rgb_tuple(tabbg)
409 self.SetTabStyles("OpenRPGTabStylesFlatCustom", FNB.FNB_FANCY_TABS, 396 self.SetTabStyles("OpenRPGTabStylesFlatCustom", FNB.FNB_FANCY_TABS,
410 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), 397 graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue),
411 textColor=wx.Color(tred, tgreen, tblue)) 398 textColor=wx.Color(tred, tgreen, tblue))
412 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True) 399 else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True)
413 400
606 ################################# 593 #################################
607 ## Build the GUI 594 ## Build the GUI
608 ################################# 595 #################################
609 @debugging 596 @debugging
610 def build_gui(self): 597 def build_gui(self):
611 self.orpgLog.log("Enter orpgFrame->build_gui()", ORPG_DEBUG)
612 self.Freeze() 598 self.Freeze()
613 self.validate.config_file("layout.xml","default_layout.xml") 599 self.validate.config_file("layout.xml","default_layout.xml")
614 600
615 filename = dir_struct["user"] + "layout.xml" 601 filename = dir_struct["user"] + "layout.xml"
616 temp_file = open(filename) 602 temp_file = open(filename)
623 with open(dir_struct['user'] + 'layout.xml') as f: 609 with open(dir_struct['user'] + 'layout.xml') as f:
624 etree.parse(f) 610 etree.parse(f)
625 611
626 base = etree.getroot() 612 base = etree.getroot()
627 """ 613 """
628
629 self.windowsmenu = wx.Menu() 614 self.windowsmenu = wx.Menu()
630 self.mainwindows = {} 615 self.mainwindows = {}
631 616
632 #Plugins Window 617 #Plugins Window
633 self.pluginsFrame = pluginUI.PluginFrame(self) 618 self.pluginsFrame = pluginUI.PluginFrame(self)
634 component.add("plugins", self.get_activeplugins()) 619 component.add("plugins", self.get_activeplugins())
635 component.add("startplugs", self.get_startplugins()) 620 component.add("startplugs", self.get_startplugins())
636 self.orpgLog.log("Menu Created", ORPG_DEBUG) 621 logger.debug("Menu Created")
637 h = int(xml_dom.getAttribute("height")) 622 h = int(xml_dom.getAttribute("height"))
638 w = int(xml_dom.getAttribute("width")) 623 w = int(xml_dom.getAttribute("width"))
639 posx = int(xml_dom.getAttribute("posx")) 624 posx = int(xml_dom.getAttribute("posx"))
640 posy = int(xml_dom.getAttribute("posy")) 625 posy = int(xml_dom.getAttribute("posy"))
641 maximized = int(xml_dom.getAttribute("maximized")) 626 maximized = int(xml_dom.getAttribute("maximized"))
644 629
645 #Update Manager 630 #Update Manager
646 self.manifest = manifest.ManifestChanges() 631 self.manifest = manifest.ManifestChanges()
647 self.updateMana = upmana.updatemana.updaterFrame(self, 632 self.updateMana = upmana.updatemana.updaterFrame(self,
648 "OpenRPG Update Manager Beta 0.7.2", component, self.manifest, True) 633 "OpenRPG Update Manager Beta 0.7.2", component, self.manifest, True)
649 self.orpgLog.log("Menu Created", ORPG_DEBUG) 634 logger.debug("Menu Created")
650 h = int(xml_dom.getAttribute("height")) 635 h = int(xml_dom.getAttribute("height"))
651 w = int(xml_dom.getAttribute("width")) 636 w = int(xml_dom.getAttribute("width"))
652 posx = int(xml_dom.getAttribute("posx")) 637 posx = int(xml_dom.getAttribute("posx"))
653 posy = int(xml_dom.getAttribute("posy")) 638 posy = int(xml_dom.getAttribute("posy"))
654 maximized = int(xml_dom.getAttribute("maximized")) 639 maximized = int(xml_dom.getAttribute("maximized"))
711 wndinfo.ToolbarPane() 696 wndinfo.ToolbarPane()
712 wndinfo.Hide() 697 wndinfo.Hide()
713 self._mgr.AddPane(self.mapToolBar, wndinfo) 698 self._mgr.AddPane(self.mapToolBar, wndinfo)
714 logger.debug("Map Tool Bar Created") 699 logger.debug("Map Tool Bar Created")
715 700
716 #Create the Browse Server Window 701 #Create the Browse Server Window #Turn into frame, as with others.
717 self.gs = orpg.networking.gsclient.game_server_panel(self) 702 self.gs = orpg.networking.gsclient.game_server_panel(self)
718 wndinfo = AUI.AuiPaneInfo() 703 wndinfo = AUI.AuiPaneInfo()
719 wndinfo.DestroyOnClose(False) 704 wndinfo.DestroyOnClose(False)
720 wndinfo.Name("Browse Server Window") 705 wndinfo.Name("Browse Server Window")
721 wndinfo.Caption("Game Server") 706 wndinfo.Caption("Game Server")
747 try: 732 try:
748 textnode = xml.safe_get_text_node(layout[0]) 733 textnode = xml.safe_get_text_node(layout[0])
749 self._mgr.LoadPerspective(textnode._get_nodeValue()) 734 self._mgr.LoadPerspective(textnode._get_nodeValue())
750 except: pass 735 except: pass
751 xml_dom.unlink() 736 xml_dom.unlink()
752 self.orpgLog.log("Perspective Loaded", ORPG_DEBUG) 737 logger.debug("Perspective Loaded")
753 self._mgr.GetPane("Browse Server Window").Hide() 738 self._mgr.GetPane("Browse Server Window").Hide()
754 self._mgr.Update() 739 self._mgr.Update()
755 self.Maximize(maximized) 740 self.Maximize(maximized)
756 self.orpgLog.log("GUI is all created", ORPG_DEBUG) 741 logger.debug("GUI is all created")
757 self.Thaw() 742 self.Thaw()
758 743
759 @debugging 744 @debugging
760 def do_tab_window(self,xml_dom,parent_wnd): 745 def do_tab_window(self,xml_dom,parent_wnd):
761 #def do_tab_window(self, etreeEl, parent_wnd): 746 #def do_tab_window(self, etreeEl, parent_wnd):
777 762
778 @debugging 763 @debugging
779 def build_window(self, xml_dom, parent_wnd): 764 def build_window(self, xml_dom, parent_wnd):
780 name = xml_dom._get_nodeName() 765 name = xml_dom._get_nodeName()
781 if name == "DockLayout" or name == "dock": return 766 if name == "DockLayout" or name == "dock": return
782 dir = xml_dom.getAttribute("direction") 767 dirc = xml_dom.getAttribute("direction") #should NOT use dir, it is a built in function.
783 pos = xml_dom.getAttribute("pos") 768 pos = xml_dom.getAttribute("pos")
784 height = xml_dom.getAttribute("height") 769 height = xml_dom.getAttribute("height")
785 width = xml_dom.getAttribute("width") 770 width = xml_dom.getAttribute("width")
786 cap = xml_dom.getAttribute("caption") 771 cap = xml_dom.getAttribute("caption")
787 dockable = xml_dom.getAttribute("dockable") 772 dockable = xml_dom.getAttribute("dockable")
832 wndinfo.BestSize(wx.Size(int(width), int(height))) 817 wndinfo.BestSize(wx.Size(int(width), int(height)))
833 wndinfo.Layer(int(layer)) 818 wndinfo.Layer(int(layer))
834 wndinfo.Caption(cap) 819 wndinfo.Caption(cap)
835 820
836 # Lambda here should work! (future dev) 821 # Lambda here should work! (future dev)
837 if dir.lower() == 'top': wndinfo.Top() 822 if dirc.lower() == 'top': wndinfo.Top()
838 elif dir.lower() == 'bottom': wndinfo.Bottom() 823 elif dirc.lower() == 'bottom': wndinfo.Bottom()
839 elif dir.lower() == 'left': wndinfo.Left() 824 elif dirc.lower() == 'left': wndinfo.Left()
840 elif dir.lower() == 'right': wndinfo.Right() 825 elif dirc.lower() == 'right': wndinfo.Right()
841 elif dir.lower() == 'center': wndinfo.Center(); wndinfo.CaptionVisible(False) 826 elif dirc.lower() == 'center': wndinfo.Center(); wndinfo.CaptionVisible(False)
842 827
843 if dockable != 1: 828 if dockable != 1:
844 wndinfo.Dockable(False) 829 wndinfo.Dockable(False)
845 wndinfo.Floatable(False) 830 wndinfo.Floatable(False)
846 if pos != '' or pos != '0' or pos != None: 831 if pos != '' or pos != '0' or pos != None:
847 wndinfo.Position(int(pos)) 832 wndinfo.Position(int(pos))
848 wndinfo.Show() 833 wndinfo.Show()
849 self._mgr.AddPane(temp_wnd, wndinfo) 834 self._mgr.AddPane(temp_wnd, wndinfo)
850 self.orpgLog.log("Exit orpgFrame->build_window(" + name + ")", ORPG_DEBUG)
851 return temp_wnd 835 return temp_wnd
852 836
853 @debugging 837 @debugging
854 def onPaneClose(self, evt): 838 def onPaneClose(self, evt):
855 self.orpgLog.log("Enter orpgFrame->onPaneClose()", ORPG_DEBUG)
856 pane = evt.GetPane() 839 pane = evt.GetPane()
857 #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration. 840 #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration.
858 #Adding ID also fixed docking. Go figure. 841 #Adding ID also fixed docking. Go figure.
859 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False) 842 if pane.name == 'Sound Control Toolbar': self.mainmenu.SetMenuState('ToolsSoundToolbar', False)
860 elif pane.name == 'Status Window': self.mainmenu.SetMenuState('ToolsStatusBar', False) 843 elif pane.name == 'Status Window': self.mainmenu.SetMenuState('ToolsStatusBar', False)
864 for wndid, wname in self.mainwindows.iteritems(): 847 for wndid, wname in self.mainwindows.iteritems():
865 #print pane.name, wname, wndid 848 #print pane.name, wname, wndid
866 if pane.name == wname: self.windowsmenu.Check(wndid, False); break 849 if pane.name == wname: self.windowsmenu.Check(wndid, False); break
867 evt.Skip() 850 evt.Skip()
868 self._mgr.Update() 851 self._mgr.Update()
869 self.orpgLog.log("Exit orpgFrame->onPaneClose()", ORPG_DEBUG)
870 852
871 @debugging 853 @debugging
872 def saveLayout(self): 854 def saveLayout(self):
873 self.orpgLog.log("Enter orpgFrame->saveLayout()", ORPG_DEBUG)
874 filename = dir_struct["user"] + "layout.xml" 855 filename = dir_struct["user"] + "layout.xml"
875 temp_file = open(filename) 856 temp_file = open(filename)
876 txt = temp_file.read() 857 txt = temp_file.read()
877 xml_dom = xml.parseXml(txt)._get_documentElement() 858 xml_dom = xml.parseXml(txt)._get_documentElement()
878 temp_file.close() 859 temp_file.close()
896 textnode._set_nodeValue(str(self._mgr.SavePerspective())) 877 textnode._set_nodeValue(str(self._mgr.SavePerspective()))
897 xml_dom.appendChild(elem) 878 xml_dom.appendChild(elem)
898 temp_file = open(filename, "w") 879 temp_file = open(filename, "w")
899 temp_file.write(xml_dom.toxml(1)) 880 temp_file.write(xml_dom.toxml(1))
900 temp_file.close() 881 temp_file.close()
901 self.orpgLog.log("Exit saveLayout()", ORPG_DEBUG)
902 882
903 @debugging 883 @debugging
904 def build_hotkeys(self): 884 def build_hotkeys(self):
905 self.orpgLog.log("Enter orpgFrame->build_hotkeys(self)", ORPG_DEBUG)
906 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys()) 885 self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys())
907 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys()) 886 self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys())
908 self.orpgLog.log("Exit orpgFrame->build_hotkeys(self)", ORPG_DEBUG)
909 887
910 @debugging 888 @debugging
911 def start_timer(self): 889 def start_timer(self):
912 self.orpgLog.log("Enter orpgFrame->start_timer(self)", ORPG_DEBUG)
913 self.poll_timer.Start(100) 890 self.poll_timer.Start(100)
914 s = component.get('settings') 891 s = component.get('settings')
915 if s.get_setting("Heartbeat") == "1": 892 if s.get_setting("Heartbeat") == "1":
916 self.ping_timer.Start(1000*60) 893 self.ping_timer.Start(1000*60)
917 self.orpgLog.log("starting heartbeat...", ORPG_DEBUG, True) 894 logger.debug("starting heartbeat...", True)
918 self.orpgLog.log("Exit orpgFrame->start_timer(self)", ORPG_DEBUG)
919 895
920 @debugging 896 @debugging
921 def kill_mplay_session(self): 897 def kill_mplay_session(self):
922 self.orpgLog.log("Enter orpgFrame->kill_mplay_session(self)", ORPG_DEBUG)
923 self.game_name = "" 898 self.game_name = ""
924 self.session.start_disconnect() 899 self.session.start_disconnect()
925 self.orpgLog.log("Exit orpgFrame->kill_mplay_session(self)", ORPG_DEBUG)
926 900
927 @debugging 901 @debugging
928 def quit_game(self, evt): 902 def quit_game(self, evt):
929 self.orpgLog.log("Enter orpgFrame->quit_game(self, evt)", ORPG_DEBUG)
930 dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO) 903 dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO)
931 if dlg.ShowModal() == wx.ID_YES: 904 if dlg.ShowModal() == wx.ID_YES:
932 self.session.exitCondition.notifyAll() 905 self.session.exitCondition.notifyAll()
933 dlg.Destroy() 906 dlg.Destroy()
934 self.kill_mplay_session() 907 self.kill_mplay_session()
935 self.orpgLog.log("Exit orpgFrame->quit_game(self, evt)", ORPG_DEBUG)
936 908
937 @debugging 909 @debugging
938 def on_status_event(self, evt): 910 def on_status_event(self, evt):
939 self.orpgLog.log("Enter orpgFrame->on_status_event(self, evt)", ORPG_DEBUG)
940 id = evt.get_id() 911 id = evt.get_id()
941 status = evt.get_data() 912 status = evt.get_data()
942 if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status) 913 if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status)
943 self.orpgLog.log("Exit orpgFrame->on_status_event(self, evt)", ORPG_DEBUG)
944 914
945 @debugging 915 @debugging
946 def on_player_event(self, evt): 916 def on_player_event(self, evt):
947 self.orpgLog.log("Enter orpgFrame->on_player_event(self, evt)", ORPG_DEBUG)
948 id = evt.get_id() 917 id = evt.get_id()
949 player = evt.get_data() 918 player = evt.get_data()
950 display_name = self.chat.chat_display_name(player) 919 display_name = self.chat.chat_display_name(player)
951 time_str = time.strftime("%H:%M", time.localtime()) 920 time_str = time.strftime("%H:%M", time.localtime())
952 if id == orpg.networking.mplay_client.PLAYER_NEW: 921 if id == orpg.networking.mplay_client.PLAYER_NEW:
956 self.players.del_player(player) 925 self.players.del_player(player)
957 self.chat.InfoPost(display_name + " (exit): " + time_str) 926 self.chat.InfoPost(display_name + " (exit): " + time_str)
958 elif id == orpg.networking.mplay_client.PLAYER_UPDATE: 927 elif id == orpg.networking.mplay_client.PLAYER_UPDATE:
959 self.players.update_player(player) 928 self.players.update_player(player)
960 self.players.Refresh() 929 self.players.Refresh()
961 self.orpgLog.log("Exit orpgFrame->on_player_event(self, evt)", ORPG_DEBUG)
962 930
963 @debugging 931 @debugging
964 def on_group_event(self, evt): 932 def on_group_event(self, evt):
965 self.orpgLog.log("Enter orpgFrame->on_group_event(self, evt)", ORPG_DEBUG)
966 id = evt.get_id() 933 id = evt.get_id()
967 data = evt.get_data() 934 data = evt.get_data()
968
969 if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data) 935 if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data)
970 elif id == orpg.networking.mplay_client.GROUP_DEL: 936 elif id == orpg.networking.mplay_client.GROUP_DEL:
971 self.password_manager.RemoveGroupData(data) 937 self.password_manager.RemoveGroupData(data)
972 self.gs.del_room(data) 938 self.gs.del_room(data)
973 elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data) 939 elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data)
974 self.orpgLog.log("Exit orpgFrame->on_group_event(self, evt)", ORPG_DEBUG)
975 940
976 @debugging 941 @debugging
977 def on_receive(self, data, player): 942 def on_receive(self, data, player):
978 self.orpgLog.log("Enter orpgFrame->on_receive(self, data, player)", ORPG_DEBUG)
979
980 # see if we are ignoring this user 943 # see if we are ignoring this user
981 (ignore_id,ignore_name) = self.session.get_ignore_list() 944 (ignore_id,ignore_name) = self.session.get_ignore_list()
982 for m in ignore_id: 945 for m in ignore_id:
983 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return 946 if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return
984 947
985 # ok we are not ignoring this message 948 # ok we are not ignoring this message
986 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below 949 #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below
987 if player: display_name = self.chat.chat_display_name(player) 950 if player: display_name = self.chat.chat_display_name(player)
988 else: display_name = "Server Administrator" 951 else: display_name = "Server Administrator"
989 952
990 if data[:5] == "<tree": 953 if data[:5] == "<tree":
991 self.tree.on_receive_data(data,player) 954 self.tree.on_receive_data(data,player)
1180 component.add('xml', xml) 1143 component.add('xml', xml)
1181 component.add('settings', settings) 1144 component.add('settings', settings)
1182 component.add('validate', validate) 1145 component.add('validate', validate)
1183 component.add("tabbedWindows", []) 1146 component.add("tabbedWindows", [])
1184 1147
1148 logger._set_log_level = int(settings.get_setting('LoggingLevel'))
1149 logger._set_log_to_console(False)
1150
1185 self.manifest = manifest.ManifestChanges() 1151 self.manifest = manifest.ManifestChanges()
1186 1152
1187 self.orpgLog = component.get('log')
1188 self.validate = component.get('validate')
1189 logger.log_level = int(settings.get_setting('LoggingLevel'))
1190 self.called = False 1153 self.called = False
1191 wx.InitAllImageHandlers() 1154 wx.InitAllImageHandlers()
1192 self.splash = orpgSplashScreen(None, dir_struct["icon"] + 'splash13.jpg', 3000, self.AfterSplash) 1155 self.splash = orpgSplashScreen(None, dir_struct["icon"] + 'splash13.jpg', 3000, self.AfterSplash)
1193 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) 1156 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress)
1194 self._crust = None 1157 self._crust = None
1226 wx.CallAfter(self.splash.Close) 1189 wx.CallAfter(self.splash.Close)
1227 return True 1190 return True
1228 1191
1229 @debugging 1192 @debugging
1230 def OnExit_CleanUp(self): 1193 def OnExit_CleanUp(self):
1231 self.orpgLog.log("Preforming cleanup\n", ORPG_DEBUG) 1194 logger.debug("Preforming cleanup\n")
1232 try: del os.environ["OPENRPG_BASE"] 1195 try: del os.environ["OPENRPG_BASE"]
1233 except: pass 1196 except: pass
1234 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py') 1197 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py')
1235 except: pass 1198 except: pass
1236 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc') 1199 try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc')
1238 1201
1239 @debugging 1202 @debugging
1240 def OnExit(self): 1203 def OnExit(self):
1241 self.OnExit_CleanUp() 1204 self.OnExit_CleanUp()
1242 #Exit 1205 #Exit
1243 self.orpgLog.log("Main Application Exit\n\n", ORPG_DEBUG) 1206 logger.debug("Main Application Exit\n\n")