Mercurial > traipse_dev
diff orpg/main.py @ 135:dcf4fbe09b70 beta
Traipse Beta 'OpenRPG' {091010-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 (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 Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!!
author | sirebral |
---|---|
date | Tue, 10 Nov 2009 14:11:28 -0600 |
parents | 7ed4979cc1cf |
children | e842a5f1b775 |
line wrap: on
line diff
--- a/orpg/main.py Fri Sep 25 20:47:16 2009 -0500 +++ b/orpg/main.py Tue Nov 10 14:11:28 2009 -0600 @@ -35,7 +35,7 @@ from orpg.orpg_windows import * import wx.py -from orpg import minidom + import orpg.player_list import orpg.tools.pluginui as pluginUI import orpg.tools.aliaslib @@ -49,20 +49,23 @@ import orpg.mapper.map import orpg.mapper.images +#Update Manager# Un remark if you have Mercurial installed import upmana.updatemana import upmana.manifest as manifest from orpg.dirpath import dir_struct from orpg.dieroller.utils import DiceManager -from orpg.tools.orpg_settings import settings +from orpg.tools.settings import settings from orpg.tools.validate import validate from orpg.tools.passtool import PassTool -from orpg.tools.orpg_log import logger, crash -from orpg.tools.decorators import debugging +from orpg.tools.orpg_log import logger, crash, debug from orpg.tools.metamenus import MenuBarEx -#from xml.etree.ElementTree import ElementTree, Element -#from xml.etree.ElementTree import fromstring, tostring +from xml.etree.ElementTree import ElementTree, Element, parse +from xml.etree.ElementTree import fromstring, tostring +## Element Tree usage will require users to convert to and from string data quite often until users of older versions update. +## This is a problem that users of older versions will need to cross as it is both Core and Traipse that will make the change. +## Older versions have a problem with correct XML. from orpg.orpg_xml import xml #to be replaced by etree @@ -72,7 +75,7 @@ class orpgFrame(wx.Frame): - @debugging + def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.Point(100, 100), wx.Size(600,420), style=wx.DEFAULT_FRAME_STYLE) self.validate = component.get("validate") @@ -95,7 +98,7 @@ "on_password_signal":self.on_password_signal, "orpgFrame":self} self.settings = component.get('settings') #Arbitrary until settings updated with Core. - self.session = orpg.networking.mplay_client.mplay_client(self.settings.get_setting("player"), call_backs) + self.session = orpg.networking.mplay_client.mplay_client(self.settings.get("player"), call_backs) self.poll_timer = wx.Timer(self, wx.NewId()) self.Bind(wx.EVT_TIMER, self.session.poll, self.poll_timer) self.poll_timer.Start(100) @@ -103,7 +106,7 @@ self.Bind(wx.EVT_TIMER, self.session.update, self.ping_timer) # create roller manager - self.DiceManager = DiceManager(settings.get_setting("dieroller")) + self.DiceManager = DiceManager(settings.get("dieroller")) component.add('DiceManager', self.DiceManager) #create password manager --SD 8/03 @@ -122,7 +125,7 @@ component.add("alias", self.aliaslib) logger.debug("openrpg components all added") - self.tree.load_tree(settings.get_setting("gametree")) + self.tree.load_tree(settings.get("gametree")) logger.debug("Tree Loaded") self.players.size_cols() @@ -137,29 +140,29 @@ logger.debug("update manager reloaded") self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - #Load Update Manager + #Load Debug Console component.add('debugconsole', self.debugger) logger.debug("debugger window") self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - @debugging + def post_show_init(self): """Some Actions need to be done after the main fram is drawn""" self.players.size_cols() - @debugging + def get_activeplugins(self): try: tmp = self.pluginsFrame.get_activeplugins() except: tmp = {} return tmp - @debugging + def get_startplugins(self): try: tmp = self.pluginsFrame.get_startplugins() except: tmp = {} return tmp - @debugging + def on_password_signal(self,signal,type,id,data): try: msg = ["DEBUG: password response= ", @@ -181,7 +184,7 @@ else: pass except: traceback.print_exc() - @debugging + def build_menu(self): menu = \ [[ @@ -234,10 +237,11 @@ ]] self.mainmenu = MenuBarEx(self, menu) - if settings.get_setting('Heartbeat') == '1': + if settings.get('Heartbeat') == '1': self.mainmenu.SetMenuState("GameServerServerHeartbeat", True) - tabtheme = settings.get_setting('TabTheme') #This change is stable. TaS. + self.mainmenu.SetMenuState('ToolsPasswordManager', True if settings.get('PWMannager') == 'On' else False) + tabtheme = settings.get('TabTheme') #This change is stable. TaS. self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua') @@ -246,7 +250,7 @@ self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", tabtheme == 'customslant') self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", tabtheme == 'customflat') - lvl = int(settings.get_setting('LoggingLevel')) + lvl = int(settings.get('LoggingLevel')) if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelDebug", True) if lvl & ORPG_DEBUG: self.mainmenu.SetMenuState("ToolsLoggingLevelNote", True) if lvl & ORPG_INFO: self.mainmenu.SetMenuState("ToolsLoggingLevelInfo", True) @@ -264,6 +268,7 @@ self.traipseSuite = wx.Menu() self.mainmenu.Insert(5, self.traipseSuite, "&Traipse Suite") + #Update Manager mana = wx.MenuItem(self.traipseSuite, wx.ID_ANY, "Update Manager", "Update Manager") self.Bind(wx.EVT_MENU, self.OnMB_UpdateManagerPanel, mana) self.traipseSuite.AppendItem(mana) @@ -275,7 +280,9 @@ def TraipseSuiteWarn(self, menuitem): ### Beta ### Allows for the reuse of the 'Attention' menu. ### component.get('frame').TraipseSuiteWarn('item') ### Portable - self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite!') + self.mainmenu.Remove(8) + self.mainmenu.Insert(8, self.traipseSuite, "&Traipse Suite!") + #self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite!') if menuitem == 'debug': if self.debugger.IsShown() == True: self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') @@ -287,7 +294,9 @@ def TraipseSuiteWarnCleanup(self, menuitem): ### Beta ### Allows for portable cleanup of the 'Attention' menu. ### component.get('frame').TraipseSuiteWarnCleanup('item') ### Portable - self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') + self.mainmenu.Remove(8) + self.mainmenu.Insert(8, self.traipseSuite, "&Traipse Suite") + #self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') if menuitem == 'debug': self.traipseSuite.RemoveItem(self.debugConsole) self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'clear.gif')) @@ -298,10 +307,10 @@ ## All Menu Events ################################# #Tab Styles Menus - @debugging + def SetTabStyles(self, *args, **kwargs): - tabtheme = settings.get_setting('TabTheme') #This change is stable. TaS. + tabtheme = settings.get('TabTheme') #This change is stable. TaS. self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw') self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua') @@ -336,7 +345,7 @@ component.add("tabbedWindows", tabbedwindows) #Run though the new list and set the proper styles - tabbg = settings.get_setting('TabBackgroundGradient') + tabbg = settings.get('TabBackgroundGradient') (red, green, blue) = self.rgb.rgb_tuple(tabbg) for wnd in tabbedwindows: @@ -352,77 +361,77 @@ if textColor != None: wnd.SetNonActiveTabTextColour(textColor) wnd.Refresh() - @debugging + def OnMB_OpenRPGNewMap(self): pass #Not Implemented yet! - @debugging + def OnMB_OpenRPGTabStylesSlantedColorful(self): if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"): - settings.set_setting('TabTheme', 'slanted&colorful') + settings.change('TabTheme', 'slanted&colorful') self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS) else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True) - @debugging + def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self): if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"): - settings.set_setting('TabTheme', 'slanted&bw') + settings.change('TabTheme', 'slanted&bw') self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite", FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True) - @debugging + def OnMB_OpenRPGTabStylesSlantedAqua(self): if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"): - settings.set_setting('TabTheme', 'slanted&aqua') + settings.change('TabTheme', 'slanted&aqua') self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8, graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True) - @debugging + def OnMB_OpenRPGTabStylesSlantedCustom(self): if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"): - settings.set_setting('TabTheme', 'customslant') - gfrom = settings.get_setting('TabGradientFrom') + settings.change('TabTheme', 'customslant') + gfrom = settings.get('TabGradientFrom') (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) - gto = settings.get_setting('TabGradientTo') + gto = settings.get('TabGradientTo') (tored, togreen, toblue) = self.rgb.rgb_tuple(gto) - tabtext = settings.get_setting('TabTextColor') + tabtext = settings.get('TabTextColor') (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext) - tabbg = settings.get_setting('TabBackgroundGradient') + tabbg = settings.get('TabBackgroundGradient') (red, green, blue) = self.rgb.rgb_tuple(tabbg) self.SetTabStyles("OpenRPGTabStylesSlantedCustom", FNB.FNB_VC8, graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), textColor=wx.Color(tred, tgreen, tblue)) else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True) - @debugging + def OnMB_OpenRPGTabStylesFlatBlackandWhite(self): if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"): - settings.set_setting('TabTheme', 'flat&bw') + settings.change('TabTheme', 'flat&bw') self.SetTabStyles("OpenRPGTabStylesFlatBlackandWhite", FNB.FNB_FANCY_TABS, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", True) - @debugging + def OnMB_OpenRPGTabStylesFlatAqua(self): if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"): - settings.set_setting('TabTheme', 'flat&aqua') + settings.change('TabTheme', 'flat&aqua') self.SetTabStyles("OpenRPGTabStylesFlatAqua", FNB.FNB_FANCY_TABS, graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatAqua", True) - @debugging + def OnMB_OpenRPGTabStylesFlatCustom(self): if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"): - settings.set_setting('TabTheme', 'customflat') - gfrom = settings.get_setting('TabGradientFrom') + settings.change('TabTheme', 'customflat') + gfrom = settings.get('TabGradientFrom') (fred, fgreen, fblue) = self.rgb.rgb_tuple(gfrom) - gto = settings.get_setting('TabGradientTo') + gto = settings.get('TabGradientTo') (tored, togreen, toblue) = self.rgb.rgb_tuple(gto) - tabtext = settings.get_setting('TabTextColor') + tabtext = settings.get('TabTextColor') (tred, tgreen, tblue) = self.rgb.rgb_tuple(tabtext) - tabbg = settings.get_setting('TabBackgroundGradient') + tabbg = settings.get('TabBackgroundGradient') (red, green, blue) = self.rgb.rgb_tuple(tabbg) self.SetTabStyles("OpenRPGTabStylesFlatCustom", FNB.FNB_FANCY_TABS, graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), @@ -430,7 +439,7 @@ else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True) #Window Menu - @debugging + def OnMB_WindowsMenu(self, event): menuid = event.GetId() name = self.mainwindows[menuid] @@ -443,7 +452,7 @@ self._mgr.Update() #OpenRPG Menu - @debugging + def OnMB_OpenRPGSettings(self): dlg = orpg.tools.orpg_settings.orpgSettingsWnd(self) dlg.Centre() @@ -453,18 +462,18 @@ self.OnCloseWindow(0) #Game Server Menu - @debugging + def OnMB_GameServerBrowseServers(self): if self._mgr.GetPane("Browse Server Window").IsShown() == True: self._mgr.GetPane("Browse Server Window").Hide() else: self._mgr.GetPane("Browse Server Window").Show() self._mgr.Update() - @debugging + def OnMB_GameServerServerHeartbeat(self): - if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): settings.set_setting('Heartbeat', '1') - else: settings.set_setting('Heartbeat', '0') + if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): settings.change('Heartbeat', '1') + else: settings.change('Heartbeat', '0') - @debugging + def OnMB_GameServerStartServer(self): start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self ) # Spawn the new process and close the stdout handle from it @@ -483,23 +492,23 @@ start_dialog.Destroy() # Tools Menu - @debugging + def OnMB_PluginControlPanel(self, evt): if self.pluginsFrame.IsShown() == True: self.pluginsFrame.Hide() else: self.pluginsFrame.Show() - @debugging + def OnMB_UpdateManagerPanel(self, evt): if self.updateMana.IsShown() == True: self.updateMana.Hide() else: self.updateMana.Show() - @debugging + def OnMB_DebugConsole(self, evt): self.TraipseSuiteWarnCleanup('debug') ### Beta ### if self.debugger.IsShown() == True: self.debugger.Hide() else: self.debugger.Show() - @debugging + def OnMB_ToolsLoggingLevelDebug(self): lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG @@ -507,7 +516,7 @@ logger.log_level = lvl settings.set('LoggingLevel', lvl) - @debugging + def OnMB_ToolsLoggingLevelNote(self): lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG @@ -515,7 +524,7 @@ logger.log_level = lvl settings.set('LoggingLevel', lvl) - @debugging + def OnMB_ToolsLoggingLevelInfo(self): lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO @@ -523,7 +532,7 @@ logger.log_level = lvl settings.set('LoggingLevel', lvl) - @debugging + def OnMB_ToolsLoggingLevelGeneral(self): lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL @@ -531,12 +540,12 @@ logger.log_level = lvl settings.set('LoggingLevel', lvl) - @debugging + def OnMB_ToolsPasswordManager(self): if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable() else: self.password_manager.Disable() - @debugging + def OnMB_ToolsStatusBar(self): if self._mgr.GetPane("Status Window").IsShown() == True: self.mainmenu.SetMenuState("ToolsStatusBar", False) @@ -546,7 +555,7 @@ self._mgr.GetPane("Status Window").Show() self._mgr.Update() - @debugging + def OnMB_ToolsSoundToolbar(self): if self._mgr.GetPane("Sound Control Toolbar").IsShown() == True: self.mainmenu.SetMenuState("ToolsSoundToolbar", False) @@ -556,7 +565,7 @@ self._mgr.GetPane("Sound Control Toolbar").Show() self._mgr.Update() - @debugging + def OnMB_ToolsDiceBar(self): if self._mgr.GetPane("Dice Tool Bar").IsShown() == True: self.mainmenu.SetMenuState("ToolsDiceBar", False) @@ -566,7 +575,7 @@ self._mgr.GetPane("Dice Tool Bar").Show() self._mgr.Update() - @debugging + def OnMB_ToolsMapBar(self): if self._mgr.GetPane("Map Tool Bar").IsShown() == True: self.mainmenu.SetMenuState("ToolsMapBar", False) @@ -577,22 +586,22 @@ self._mgr.Update() #Help Menu #Needs a custom Dialog because it is ugly on Windows - @debugging + def OnMB_HelpAbout(self): if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide() else: self.AboutORPG.Show() - @debugging + def OnMB_HelpOnlineUserGuide(self): wb = webbrowser.get() wb.open("http://www.assembla.com/wiki/show/traipse/User_Manual") - @debugging + def OnMB_HelpChangeLog(self): wb = webbrowser.get() wb.open("http://www.assembla.com/spaces/milestones/index/traipse?spaces_tool_id=Milestones") - @debugging + def OnMB_HelpReportaBug(self): wb = webbrowser.get() wb.open("http://www.assembla.com/spaces/tickets/index/traipse_dev?spaces_tool_id=Tickets") @@ -601,24 +610,14 @@ ################################# ## Build the GUI ################################# - @debugging + def build_gui(self): self.Freeze() self.validate.config_file("layout.xml","default_layout.xml") - filename = dir_struct["user"] + "layout.xml" - temp_file = open(filename) - txt = temp_file.read() - xml_dom = xml.parseXml(txt)._get_documentElement() - temp_file.close() + layout = parse(dir_struct["user"] + "layout.xml") + xml_dom = layout.getroot() - """ Would a component work better? - etree = ElementTree() - with open(dir_struct['user'] + 'layout.xml') as f: - etree.parse(f) - - base = etree.getroot() - """ self.windowsmenu = wx.Menu() self.mainwindows = {} @@ -630,35 +629,35 @@ component.add("plugins", self.get_activeplugins()) component.add("startplugs", self.get_startplugins()) logger.debug("Menu Created") - h = int(xml_dom.getAttribute("height")) - w = int(xml_dom.getAttribute("width")) - posx = int(xml_dom.getAttribute("posx")) - posy = int(xml_dom.getAttribute("posy")) - maximized = int(xml_dom.getAttribute("maximized")) + h = int(xml_dom.get("height")) + w = int(xml_dom.get("width")) + posx = int(xml_dom.get("posx")) + posy = int(xml_dom.get("posy")) + maximized = int(xml_dom.get("maximized")) self.SetDimensions(posx, posy, w, h) logger.debug("Dimensions Set") - # Update Manager + # Update Manager self.manifest = manifest.ManifestChanges() self.updateMana = upmana.updatemana.updaterFrame(self, "OpenRPG Update Manager Beta 0.8", component, self.manifest, True) logger.debug("Menu Created") - h = int(xml_dom.getAttribute("height")) - w = int(xml_dom.getAttribute("width")) - posx = int(xml_dom.getAttribute("posx")) - posy = int(xml_dom.getAttribute("posy")) - maximized = int(xml_dom.getAttribute("maximized")) + h = int(xml_dom.get("height")) + w = int(xml_dom.get("width")) + posx = int(xml_dom.get("posx")) + posy = int(xml_dom.get("posy")) + maximized = int(xml_dom.get("maximized")) self.SetDimensions(posx, posy, w, h) logger.debug("Dimensions Set") # Debug Console self.debugger = orpg.tools.orpg_log.DebugConsole(self) logger.debug("Menu Created") - h = int(xml_dom.getAttribute("height")) - w = int(xml_dom.getAttribute("width")) - posx = int(xml_dom.getAttribute("posx")) - posy = int(xml_dom.getAttribute("posy")) - maximized = int(xml_dom.getAttribute("maximized")) + h = int(xml_dom.get("height")) + w = int(xml_dom.get("width")) + posx = int(xml_dom.get("posx")) + posy = int(xml_dom.get("posy")) + maximized = int(xml_dom.get("maximized")) self.SetDimensions(posx, posy, w, h) logger.debug("Dimensions Set") @@ -675,7 +674,7 @@ wndinfo.ToolbarPane() wndinfo.Hide() self._mgr.AddPane(self.sound_player, wndinfo) - children = xml_dom._get_childNodes() + children = xml_dom.getchildren() for c in children: self.build_window(c, self) # status window @@ -751,12 +750,10 @@ logger.debug("AUI Bindings Done") #Load the layout if one exists - layout = xml_dom.getElementsByTagName("DockLayout") + layout = xml_dom.find("DockLayout") try: - textnode = xml.safe_get_text_node(layout[0]) - self._mgr.LoadPerspective(textnode._get_nodeValue()) + self._mgr.LoadPerspective(layout.text) except: pass - xml_dom.unlink() logger.debug("Perspective Loaded") self._mgr.GetPane("Browse Server Window").Hide() self._mgr.Update() @@ -764,16 +761,16 @@ logger.debug("GUI is all created") self.Thaw() - @debugging + def do_tab_window(self,xml_dom,parent_wnd): #def do_tab_window(self, etreeEl, parent_wnd): # if container window loop through childern and do a recursive call temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_ALLOW_FOREIGN_DND) - children = xml_dom._get_childNodes() + children = xml_dom.getchildren() for c in children: wnd = self.build_window(c,temp_wnd) - name = c.getAttribute("name") + name = c.get("name") temp_wnd.AddPage(wnd, name, False) """ @@ -783,17 +780,17 @@ """ return temp_wnd - @debugging + def build_window(self, xml_dom, parent_wnd): - name = xml_dom._get_nodeName() + name = xml_dom.tag if name == "DockLayout" or name == "dock": return - dirc = xml_dom.getAttribute("direction") #should NOT use dir, it is a built in function. - pos = xml_dom.getAttribute("pos") - height = xml_dom.getAttribute("height") - width = xml_dom.getAttribute("width") - cap = xml_dom.getAttribute("caption") - dockable = xml_dom.getAttribute("dockable") - layer = xml_dom.getAttribute("layer") + dirc = xml_dom.get("direction") #should NOT use dir, it is a built in function. + pos = xml_dom.get("pos") + height = xml_dom.get("height") + width = xml_dom.get("width") + cap = xml_dom.get("caption") + dockable = xml_dom.get("dockable") + layer = xml_dom.get("layer") try: layer = int(layer); dockable = int(dockable) except: layer = 0; dockable = 1 @@ -805,9 +802,9 @@ elif name == "tree": temp_wnd = orpg.gametree.gametree.game_tree(parent_wnd, -1) self.tree = temp_wnd - if settings.get_setting('ColorTree') == '1': - self.tree.SetBackgroundColour(settings.get_setting('bgcolor')) - self.tree.SetForegroundColour(settings.get_setting('textcolor')) + if settings.get('ColorTree') == '1': + self.tree.SetBackgroundColour(settings.get('bgcolor')) + self.tree.SetForegroundColour(settings.get('textcolor')) else: self.tree.SetBackgroundColour('white') self.tree.SetForegroundColour('black') @@ -820,9 +817,9 @@ elif name == "player": temp_wnd = orpg.player_list.player_list(parent_wnd) self.players = temp_wnd - if settings.get_setting('ColorTree') == '1': - self.players.SetBackgroundColour(settings.get_setting('bgcolor')) - self.players.SetForegroundColour(settings.get_setting('textcolor')) + if settings.get('ColorTree') == '1': + self.players.SetBackgroundColour(settings.get('bgcolor')) + self.players.SetForegroundColour(settings.get('textcolor')) else: self.players.SetBackgroundColour('white') self.players.SetForegroundColour('black') @@ -857,7 +854,7 @@ self._mgr.AddPane(temp_wnd, wndinfo) return temp_wnd - @debugging + def onPaneClose(self, evt): pane = evt.GetPane() #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration. @@ -873,55 +870,53 @@ evt.Skip() self._mgr.Update() - @debugging + def saveLayout(self): filename = dir_struct["user"] + "layout.xml" - temp_file = open(filename) - txt = temp_file.read() - xml_dom = xml.parseXml(txt)._get_documentElement() - temp_file.close() + layout = parse(filename) + xml_dom = layout.getroot() (x_size,y_size) = self.GetClientSize() (x_pos,y_pos) = self.GetPositionTuple() if self.IsMaximized(): max = 1 else: max = 0 - xml_dom.setAttribute("height", str(y_size)) - xml_dom.setAttribute("width", str(x_size)) - xml_dom.setAttribute("posx", str(x_pos)) - xml_dom.setAttribute("posy", str(y_pos)) - xml_dom.setAttribute("maximized", str(max)) - layout = xml_dom.getElementsByTagName("DockLayout") + xml_dom.set("height", str(y_size)) + xml_dom.set("width", str(x_size)) + xml_dom.set("posx", str(x_pos)) + xml_dom.set("posy", str(y_pos)) + xml_dom.set("maximized", str(max)) try: - textnode = xml.safe_get_text_node(layout[0]) - textnode._set_nodeValue(str(self._mgr.SavePerspective())) + xml_dom.find("DockLayout").text = str(self._mgr.SavePerspective()) except: - elem = minidom.Element('DockLayout') - elem.setAttribute("DO_NO_EDIT","True") - textnode = xml.safe_get_text_node(elem) - textnode._set_nodeValue(str(self._mgr.SavePerspective())) - xml_dom.appendChild(elem) + elem = Element('DockLayout') + elem.set("DO_NO_EDIT","True") + elem.text = str(self._mgr.SavePerspective()) + xml_dom.append(elem) + + layout.write(filename) + """ temp_file = open(filename, "w") - temp_file.write(xml_dom.toxml(1)) - temp_file.close() + temp_file.write(tostring(xml_dom)) + temp_file.close()""" - @debugging + def build_hotkeys(self): self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys()) self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys()) - @debugging + def start_timer(self): self.poll_timer.Start(100) s = component.get('settings') - if s.get_setting("Heartbeat") == "1": + if s.get("Heartbeat") == "1": self.ping_timer.Start(1000*60) logger.debug("starting heartbeat...", True) - @debugging + def kill_mplay_session(self): self.game_name = "" self.session.start_disconnect() - @debugging + def quit_game(self, evt): dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO) if dlg.ShowModal() == wx.ID_YES: @@ -929,13 +924,13 @@ dlg.Destroy() self.kill_mplay_session() - @debugging + def on_status_event(self, evt): id = evt.get_id() status = evt.get_data() if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status) - @debugging + def on_player_event(self, evt): id = evt.get_id() player = evt.get_data() @@ -951,89 +946,53 @@ self.players.update_player(player) self.players.Refresh() - @debugging + def on_group_event(self, evt): id = evt.get_id() data = evt.get_data() if id == orpg.networking.mplay_client.GROUP_NEW: self.gs.add_room(data) elif id == orpg.networking.mplay_client.GROUP_DEL: - self.password_manager.RemoveGroupData(data) + # self.password_manager.RemoveGroupData(data) #Removed for debugging. self.gs.del_room(data) elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data) - @debugging + def on_receive(self, data, player): # see if we are ignoring this user - (ignore_id,ignore_name) = self.session.get_ignore_list() + (ignore_id, ignore_name) = self.session.get_ignore_list() for m in ignore_id: if m == player[2]: logger.debug("ignoring message from player:" + player[0], True); return # ok we are not ignoring this message #recvSound = "RecvSound" # this will be the default sound. Whisper will change this below + + ### Alpha ### + etreeEl = Element('msg') + try: etreeEl.append(fromstring(data)) + except: etreeEl.text = data + ### Remove after Element Tree is integrated further ### if player: display_name = self.chat.chat_display_name(player) else: display_name = "Server Administrator" - if data[:5] == "<tree": - self.tree.on_receive_data(data,player) - self.chat.InfoPost(display_name + " has sent you a tree node...") - - elif data[:4] == "<map": self.map.new_data(data) + if etreeEl.text: self.chat.Post(etreeEl.text) - elif data[:5] == "<chat": - msg = orpg.chat.chat_msg.chat_msg(data) - self.chat.post_incoming_msg(msg,player) - else: - """ - all this below code is for comptiablity with older clients and can - be removed after a bit - """ - import warnings - warnings.warn("Getting here is bad, find out how and fix it", - DeprecationWarning, 2) - if data[:3] == "/me": - """ - This fixes the emote coloring to comply with what has been - asked for by the user population, not to mention, what I - committed to many moons ago. In doing so, Woody's scheme has - been tossed out. I'm sure Woody won't be happy but I'm - invoking developer priveledge to satisfy user request, not to - mention, this scheme actually makes more sense. In Woody's - scheme, a user could over-ride another users emote color. This - doesn't make sense, rather, people dictate their OWN colors... - which is as it should be in the first place and is as it has - been with normal text. In short, this makes sense and is - consistent. - """ - data = data.replace( "/me", "" ) - """ - Check to see if we find the closing '>' for the font within the - first 22 values - """ - index = data[:22].find( ">" ) - if index == -1: - data = "** " + self.chat.colorize( self.chat.infocolor, display_name + data ) + " **" - - else: - """ - This means that we found a valid font string, so we can - simply plug the name into the string between the start and - stop font delimiter - """ - print "pre data = " + data - data = data[:22] + "** " + display_name + " " + data[22:] + " **" - print "post data = " + data - - elif data[:2] == "/w": - data = data.replace("/w","") - data = "<b>" + display_name + "</b> (whispering): " + data - - else: - # Normal text - if player: data = "<b>" + display_name + "</b>: " + data - else: data = "<b><i><u>" + display_name + "</u>-></i></b> " + data - self.chat.Post(data) - - @debugging + for child in etreeEl.getchildren(): + if child.tag == 'tree': + ### Alpha ### Allows users to decide if they want the node or not. + dlg = wx.MessageDialog(None, display_name + ' is trying to send you a tree node. Accept?', 'Question', + wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) + if dlg.ShowModal() == wx.ID_YES: + dlg.Destroy() + debug(child) + self.tree.on_receive_data(tostring(child)) #Removed player object because it was unused. + self.chat.InfoPost(display_name + " has sent you a tree node...") + elif child.tag == 'map': + #TODO: Fix map to accepts elements + self.map.new_data(tostring(child)) + elif child.tag == 'chat': + msg = orpg.chat.chat_msg.chat_msg(tostring(child)) + self.chat.post_incoming_msg(msg, player) + def on_mplay_event(self, evt): id = evt.get_id() if id == orpg.networking.mplay_client.MPLAY_CONNECTED: @@ -1052,28 +1011,28 @@ ####Begin changes for Custom Exit Message by mDuo13###### elif id == orpg.networking.mplay_client.MPLAY_DISCONNECTING: settings = component.get('settings') - custom_msg = settings.get_setting("dcmsg") + custom_msg = settings.get("dcmsg") custom_msg=custom_msg[:80] if custom_msg[:3]=="/me": self.chat.send_chat_message(custom_msg[3:], 3) else: self.chat.system_message(custom_msg) #####End Changes for Custom Exit Message by mDuo13 - elif id== orpg.networking.mplay_client.MPLAY_GROUP_CHANGE: + elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE: group = evt.get_data() self.chat.InfoPost("Moving to room '"+group[1]+"'..") if self.gs : self.gs.set_cur_room_text(group[1]) self.players.reset() - elif id== orpg.networking.mplay_client.MPLAY_GROUP_CHANGE_F: + elif id == orpg.networking.mplay_client.MPLAY_GROUP_CHANGE_F: self.chat.SystemPost("Room access denied!") - @debugging + def OnCloseWindow(self, event): dlg = wx.MessageDialog(self, "Quit OpenRPG?", "OpenRPG", wx.YES_NO) if dlg.ShowModal() == wx.ID_YES: dlg.Destroy() self.closed_confirmed() - @debugging + def closed_confirmed(self): self.activeplugins = component.get('plugins') self.aliaslib.OnMB_FileSave(None) @@ -1096,9 +1055,9 @@ logger.general("[WARNING] Map error pre_exit_cleanup()", True) try: - save_tree = string.upper(settings.get_setting("SaveGameTreeOnExit")) + save_tree = string.upper(settings.get("SaveGameTreeOnExit")) if (save_tree != "0") and (save_tree != "False") and (save_tree != "NO"): - self.tree.save_tree(settings.get_setting("gametree")) + self.tree.save_tree(settings.get("gametree")) except Exception: logger.general("[WARNING] Error saving gametree", True) @@ -1202,7 +1161,7 @@ ## Application class ######################################## class orpgSplashScreen(wx.SplashScreen): - @debugging + def __init__(self, parent, bitmapfile, duration, callback): wx.SplashScreen.__init__(self, wx.Bitmap(bitmapfile), wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, duration, None, -1) @@ -1211,18 +1170,15 @@ self.Bind(wx.EVT_CLOSE, self.callback) class orpgApp(wx.App): - @debugging + def OnInit(self): - component.add('log', logger) component.add('xml', xml) component.add('settings', settings) component.add('validate', validate) component.add("tabbedWindows", []) - logger._set_log_level = int(settings.get_setting('LoggingLevel')) - logger._set_log_to_console(False) - + #Update Manager self.manifest = manifest.ManifestChanges() self.called = False @@ -1233,13 +1189,13 @@ wx.Yield() return True - @debugging + def OnKeyPress(self, evt): #Event handler if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'): self.ShowShell() else: evt.Skip() - @debugging + def ShowShell(self): #Show the PyCrust window. if not self._crust: @@ -1249,7 +1205,7 @@ self._crust.shell.interp.locals['win'] = win self._crust.Show() - @debugging + def AfterSplash(self,evt): if not self.called: self.splash.Hide() @@ -1264,7 +1220,7 @@ wx.CallAfter(self.splash.Close) return True - @debugging + def OnExit_CleanUp(self): logger.debug("Preforming cleanup\n") try: del os.environ["OPENRPG_BASE"] @@ -1274,7 +1230,7 @@ try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.pyc') except: pass - @debugging + def OnExit(self): self.OnExit_CleanUp() #Exit