Mercurial > traipse
diff orpg/main.py @ 28:ff154cf3350c ornery-orc
Traipse 'OpenRPG' {100203-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 (Stable)
New Features:
New Bookmarks Feature
New 'boot' command to remote admin
New confirmation window for sent nodes
Miniatures Layer pop up box allows users to turn off Mini labels, from
FlexiRPG
New Zoom Mouse plugin added
New Images added to Plugin UI
Switching to Element Tree
New Map efficiency, from FlexiRPG
New Status Bar to Update Manager
New TrueDebug Class in orpg_log (See documentation for usage)
New Portable Mercurial
New Tip of the Day, from Core and community
New Reference Syntax added for custom PC sheets
New Child Reference for gametree
New Parent Reference for gametree
New Gametree Recursion method, mapping, context sensitivity, and
effeciency..
New Features node with bonus nodes and Node Referencing help added
New Dieroller structure from Core
New DieRoller portability for odd Dice
New 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)]
New 'Mythos' System die roller added
New vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for
Mythos roller also
New Warhammer FRPG Die Roller (Special thanks to Puu-san for the
support)
New EZ_Tree Reference system. Push a button, Traipse the tree, get a
reference (Beta!)
New Grids act more like Spreadsheets in Use mode, with Auto Calc
Fixes:
Fix to allow for portability to an OpenSUSE linux OS
Fix to mplay_client for Fedora and OpenSUSE
Fix to Text based Server
Fix to Remote Admin Commands
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Fix to Map from gametree not showing to all clients
Fix to gametree about menus
Fix to Password Manager check on startup
Fix to PC Sheets from tool nodes. They now use the tabber_panel
Fix to Whiteboard ID to prevent random line or text deleting.
Fixes to Server, Remote Server, and Server GUI
Fix to Update Manager; cleaner clode for saved repositories
Fixes made to Settings Panel and now reactive settings when Ok is
pressed
Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of
a Splice
Fix to Use panel of Forms and Tabbers. Now longer enters design mode
Fix made Image Fetching. New fetching image and new failed image
Fix to whiteboard ID's to prevent non updated clients from ruining the
fix.
default_manifest.xml renamed to default_upmana.xml
author | sirebral |
---|---|
date | Wed, 03 Feb 2010 22:16:49 -0600 |
parents | 51428d30c59e |
children | fc48380f0c9f |
line wrap: on
line diff
--- a/orpg/main.py Sat Oct 03 18:49:37 2009 -0500 +++ b/orpg/main.py Wed Feb 03 22:16:49 2010 -0600 @@ -21,13 +21,13 @@ # File: main.py # Author: Chris Davis # Maintainer: -# Version: -# $Id: main.py,v 1.153 2008/01/24 03:52:03 digitalxero Exp $ +# Version: Traipse 'Ornery-Orc' +# $Id: main.py,v Traipse 'Ornery-Orc' prof.ebral Exp $ # # Description: This is the main entry point of the oprg application # -__version__ = "$Id: main.py,v 1.154 2009/07/19 03:52:03 madmathlabs Exp $" +__version__ = "$Id: main.py,v Traipse 'Ornery-Orc' prof.ebral Exp $" from orpg.orpg_wx import * from orpg.orpgCore import * @@ -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,20 @@ import orpg.mapper.map import orpg.mapper.images +import orpg.dieroller.utils import upmana.updatemana -import upmana.manifest as manifest +from upmana.manifest import 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 orpg.tools.InterParse import Parse -#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 from orpg.orpg_xml import xml #to be replaced by etree @@ -72,7 +72,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") @@ -94,8 +94,8 @@ "on_status_event":self.on_status_event, "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(settings.get("player"), call_backs) + component.add("session", self.session) 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,26 +103,21 @@ self.Bind(wx.EVT_TIMER, self.session.update, self.ping_timer) # create roller manager - self.DiceManager = DiceManager(settings.get_setting("dieroller")) + self.DiceManager = orpg.dieroller.utils.roller_manager() + self.DiceManager.setRoller(settings.get("dieroller")) component.add('DiceManager', self.DiceManager) #create password manager --SD 8/03 self.password_manager = component.get('password_manager') - component.add("session", self.session) - component.add('frame', self) # build frame windows + component.add('frame', self) self.build_menu() self.build_gui() self.build_hotkeys() - logger.debug("GUI Built") - component.add("chat",self.chat) - component.add("map",self.map) - 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() @@ -132,34 +127,52 @@ logger.debug("plugins reloaded and startup plugins launched") self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + tipotday_start = settings.get('tipotday_start') + try: tipotday_start = int(tipotday_start) + except TypeError: tipotday_start = 0 + + self.TipOfTheDay = wx.CreateFileTipProvider(dir_struct['data']+'tips.txt', tipotday_start) #Load Update Manager component.add('updatemana', self.updateMana) 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 ShowTipOfTheDay(self): + if wx.ShowTip(self, self.TipOfTheDay, settings.get('tipotday_enabled') != '0'): + settings.change('tipotday_enabled', '1') + else: settings.change('tipotday_enabled', '0') + settings.change('tipotday_start', str(self.TipOfTheDay.CurrentTip)) + def post_show_init(self): - """Some Actions need to be done after the main fram is drawn""" + """Some Actions need to be done after the main frame is drawn""" self.players.size_cols() + try: + if settings.get('tipotday_enabled').lower() != '0': self.ShowTipOfTheDay() + except: self.add_setting('Tip of the Day') - @debugging + def add_setting(self, setting): + if setting == 'Tip of the Day': + settings.add_tab('General', 'Tip of the Day', 'grid') + settings.add('Tip of the Day', 'tipotday_start', '0', 'int', 'Current Tip of the Day') + settings.add('Tip of the Day', 'tipotday_enabled', '1', '0|1', 'Show Tip of the Day on startup') + logger.info('New Settings added', True) + self.TraipseSuiteWarn('debug') + 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 +194,6 @@ else: pass except: traceback.print_exc() - @debugging def build_menu(self): menu = \ [[ @@ -230,14 +242,16 @@ [' &About'], [' Online User Guide'], [' Change Log'], - [' Report a Bug'] + [' Report a Bug'], + [' Tip of the Day'] ]] 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 +260,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 +278,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) @@ -273,21 +288,24 @@ self.traipseSuite.AppendItem(self.debugConsole) def TraipseSuiteWarn(self, menuitem): - ### Beta ### Allows for the reuse of the 'Attention' menu. + ### 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!") if menuitem == 'debug': if self.debugger.IsShown() == True: - self.mainmenu.Replace(8, self.traipseSuite, '&Traipse Suite') + self.mainmenu.Remove(8) + self.mainmenu.Insert(8, self.traipseSuite, "&Traipse Suite") else: self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'spotlight.png')) self.traipseSuite.RemoveItem(self.debugConsole) self.traipseSuite.AppendItem(self.debugConsole) def TraipseSuiteWarnCleanup(self, menuitem): - ### Beta ### Allows for portable cleanup of the 'Attention' menu. + ### 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") if menuitem == 'debug': self.traipseSuite.RemoveItem(self.debugConsole) self.debugConsole.SetBitmap(wx.Bitmap(dir_struct["icon"] + 'clear.gif')) @@ -298,10 +316,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 +354,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 +370,69 @@ 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 +440,6 @@ else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True) #Window Menu - @debugging def OnMB_WindowsMenu(self, event): menuid = event.GetId() name = self.mainwindows[menuid] @@ -443,7 +452,6 @@ self._mgr.Update() #OpenRPG Menu - @debugging def OnMB_OpenRPGSettings(self): dlg = orpg.tools.orpg_settings.orpgSettingsWnd(self) dlg.Centre() @@ -453,18 +461,15 @@ 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,60 +488,51 @@ 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 ### + self.TraipseSuiteWarnCleanup('debug') 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 else: lvl &= ~ORPG_DEBUG logger.log_level = lvl - settings.set('LoggingLevel', lvl) + settings.change('LoggingLevel', lvl) - @debugging def OnMB_ToolsLoggingLevelNote(self): lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG else: lvl &= ~ORPG_DEBUG logger.log_level = lvl - settings.set('LoggingLevel', lvl) + settings.change('LoggingLevel', lvl) - @debugging def OnMB_ToolsLoggingLevelInfo(self): lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO else: lvl &= ~ORPG_INFO logger.log_level = lvl - settings.set('LoggingLevel', lvl) + settings.change('LoggingLevel', lvl) - @debugging def OnMB_ToolsLoggingLevelGeneral(self): lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL else: lvl &= ~ORPG_GENERAL logger.log_level = lvl - settings.set('LoggingLevel', lvl) + settings.change('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 +542,6 @@ 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 +551,6 @@ 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 +560,6 @@ 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) @@ -576,49 +569,37 @@ self._mgr.GetPane("Map Tool Bar").Show() 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") + def OnMB_HelpTipoftheDay(self): + self.ShowTipOfTheDay() + ################################# ## 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 +611,36 @@ 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 - self.manifest = manifest.ManifestChanges() + # Update Manager + #self.manifest = manifest.ManifestChanges() self.updateMana = upmana.updatemana.updaterFrame(self, - "OpenRPG Update Manager Beta 0.8", component, self.manifest, True) + "OpenRPG Update Manager 1.0", component, manifest, True) + component.add('upmana-win', self.updateMana) 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 +657,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 @@ -693,7 +675,7 @@ logger.debug("Status Window Created") # Create and show the floating dice toolbar - self.dieToolBar = orpg.tools.toolBars.DiceToolBar(self, callBack = self.chat.ParsePost) + self.dieToolBar = orpg.tools.toolBars.DiceToolBar(self, callBack = Parse.Post) wndinfo = AUI.AuiPaneInfo() menuid = wx.NewId() self.mainwindows[menuid] = "Dice Tool Bar" @@ -736,6 +718,7 @@ #Create the Alias Lib Window self.aliaslib = orpg.tools.aliaslib.AliasLib() + component.add("alias", self.aliaslib) self.aliaslib.Hide() logger.debug("Alias Window Created") menuid = wx.NewId() @@ -751,49 +734,38 @@ logger.debug("AUI Bindings Done") #Load the layout if one exists - layout = xml_dom.getElementsByTagName("DockLayout") try: - textnode = xml.safe_get_text_node(layout[0]) - self._mgr.LoadPerspective(textnode._get_nodeValue()) + layout = xml_dom.find("DockLayout") + self._mgr.LoadPerspective(layout.text) + logger.debug("Perspective Loaded") except: pass - xml_dom.unlink() - logger.debug("Perspective Loaded") self._mgr.GetPane("Browse Server Window").Hide() self._mgr.Update() self.Maximize(maximized) 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): + def do_tab_window(self, xml_dom, 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) - - """ - for c in etreeEl.getchildren(): - wnd = self.build_window(c, temp_wnd) - temp_wnd.AddPage(wnd, c.get('name'), False) - """ 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 @@ -802,12 +774,14 @@ elif name == "map": temp_wnd = orpg.mapper.map.map_wnd(parent_wnd, -1) self.map = temp_wnd + component.add("map",self.map) + 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') @@ -816,13 +790,14 @@ temp_wnd = orpg.chat.chatwnd.chat_notebook(parent_wnd, wx.DefaultSize) self.chattabs = temp_wnd self.chat = temp_wnd.MainChatPanel + component.add("chat",self.chat) 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 +832,6 @@ 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. @@ -868,60 +842,45 @@ elif pane.name == 'Map Tool Bar': self.mainmenu.SetMenuState('ToolsMapBar', False) else: for wndid, wname in self.mainwindows.iteritems(): - #print pane.name, wname, wndid if pane.name == wname: self.windowsmenu.Check(wndid, False); break 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") - try: - textnode = xml.safe_get_text_node(layout[0]) - textnode._set_nodeValue(str(self._mgr.SavePerspective())) + 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: 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) - temp_file = open(filename, "w") - temp_file.write(xml_dom.toxml(1)) - temp_file.close() + elem = Element('DockLayout') + elem.set("DO_NO_EDIT","True") + elem.text = str(self._mgr.SavePerspective()) + xml_dom.append(elem) + layout.write(filename) - @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 settings.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 +888,11 @@ 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 +908,47 @@ 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 + + etreeEl = Element('msg') + try: etreeEl.append(fromstring(data)) + except: etreeEl.text = data 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': + dlg = wx.MessageDialog(None, component.strip_html(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() + self.tree.on_receive_data(tostring(child)) + 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: @@ -1051,29 +966,26 @@ ####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) @@ -1090,15 +1002,13 @@ try: settings.save() except Exception: logger.general("[WARNING] Error saving 'settings' component", True) - try: self.map.pre_exit_cleanup() except Exception: 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) @@ -1149,7 +1059,7 @@ ## About Dialog class ######################################## class AboutORPG(wx.Frame): - def __init__(self, parent): + def __init__(self, parent, description=''): super(AboutORPG, self).__init__(parent, -1, "About 'Traipse' OpenRPG") icon = None icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) @@ -1170,7 +1080,7 @@ self.Bind(wx.EVT_CLOSE, self.Min) self.Min(None) - description = "OpenRPG is a Virtual Game Table that allows users to connect via a network and play table " + description += "OpenRPG is a Virtual Game Table that allows users to connect via a network and play table " description += "top games with friends. 'Traipse' is an OpenRPG distro that is easy to setup and provides superb " description += "functionality. OpenRPG is originally designed by Chris Davis." @@ -1191,7 +1101,8 @@ 'Bernhard Bergbauer', 'Chris Blocher', 'David Byron', 'Ben Collins-Sussman', 'Robin Cook', 'Greg Copeland', 'Chris Davis', 'Michael Edwards', 'Andrew Ettinger', 'Todd Faris', 'Dj Gilcrease', 'Christopher Hickman', 'Paul Hosking', 'Brian Manning', 'Scott Mackay', 'Jesse McConnell', - 'Brian Osman', 'Rome Reginelli', 'Christopher Rouse', 'Dave Sanders', 'Tyler Starke', 'Mark Tarrabain'] + 'Brian Osman', 'Rome Reginelli', 'Christopher Rouse', 'Dave Sanders', 'Tyler Starke', 'Mark Tarrabain', + 'David Vrabel'] for dev in orpg_devs: self.About.AppendText(dev+'\n') @@ -1202,7 +1113,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,20 +1122,14 @@ 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) - - self.manifest = manifest.ManifestChanges() - self.called = False wx.InitAllImageHandlers() self.splash = orpgSplashScreen(None, dir_struct["icon"] + 'splash13.jpg', 3000, self.AfterSplash) @@ -1233,13 +1138,11 @@ 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 +1152,6 @@ self._crust.shell.interp.locals['win'] = win self._crust.Show() - @debugging def AfterSplash(self,evt): if not self.called: self.splash.Hide() @@ -1264,7 +1166,6 @@ 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 +1175,6 @@ 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