diff orpg/main.py @ 227:81d0bfd5e800 alpha

Traipse Alpha 'OpenRPG' {100612-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 (Preparing to close updates) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created
author sirebral
date Sat, 12 Jun 2010 03:50:37 -0500
parents 4b2884f29a72
children
line wrap: on
line diff
--- a/orpg/main.py	Fri Jan 15 22:45:51 2010 -0600
+++ b/orpg/main.py	Sat Jun 12 03:50:37 2010 -0500
@@ -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 *
@@ -50,25 +50,20 @@
 import orpg.mapper.images
 
 import orpg.dieroller.utils
-
-#Update Manager# Un remark if you have Mercurial installed
 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.settings import settings
 from orpg.tools.validate import validate
 from orpg.tools.passtool import PassTool
 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, 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
+#from orpg.orpg_xml import xml #to be replaced by etree
 
 
 ####################################
@@ -77,7 +72,7 @@
 
 
 class orpgFrame(wx.Frame):
-    
+
     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")
@@ -167,6 +162,11 @@
             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')
+        if setting == 'Meta Servers':
+            settings.add('Networking', 'MetaServers', 'metaservers.xml', '.xml file', 'Contains a list of Meta Servers')
+            logger.info('New Settings added', True)
+            self.validate.config_file("metaservers.xml","default_metaservers.xml")
+            self.TraipseSuiteWarn('debug')
 
     def get_activeplugins(self):
         try: tmp = self.pluginsFrame.get_activeplugins()
@@ -207,7 +207,7 @@
                     ['  -'],
                     ['  Tab Styles'],
                     ['    Slanted'],
-                    ['      Colorful', "check"],
+                    #['      Colorful', "check"],
                     ['      Black and White', "check"],
                     ['      Aqua', "check"],
                     ['      Custom', "check"],
@@ -257,7 +257,8 @@
 
         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')
+        if tabtheme == 'slanted&colorful': tabtheme = 'customflat'; settings.change('TabTheme', 'customflat')
+        #self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
         self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw')
         self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua')
         self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw')
@@ -299,7 +300,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)
@@ -322,9 +324,8 @@
     #Tab Styles Menus
     
     def SetTabStyles(self, *args, **kwargs):
-
         tabtheme = settings.get('TabTheme')  #This change is stable. TaS.
-        self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
+        #self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
         self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw')
         self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua')
         self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw')
@@ -340,7 +341,6 @@
         else:
             try: menu = args[0]
             except: logger.general('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)'); return
-
         if kwargs.has_key('graidentTo'): graidentTo = kwargs['graidentTo']
         else: graidentTo = None
         if kwargs.has_key('graidentFrom'): graidentFrom = kwargs['graidentFrom']
@@ -364,7 +364,7 @@
         for wnd in tabbedwindows:
             style = wnd.GetWindowStyleFlag()
             # remove old tabs style
-            mirror = ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS | FNB.FNB_COLORFUL_TABS)
+            mirror = ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS )
             style &= mirror
             style |= newstyle
             wnd.SetWindowStyleFlag(style)
@@ -374,18 +374,15 @@
             if textColor != None: wnd.SetNonActiveTabTextColour(textColor)
             wnd.Refresh()
 
-    
     def OnMB_OpenRPGNewMap(self):
         pass #Not Implemented yet!
 
-    
     def OnMB_OpenRPGTabStylesSlantedColorful(self):
         if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"):
             settings.change('TabTheme', 'slanted&colorful')
             self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS)
         else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True)
 
-    
     def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self):
         if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"):
             settings.change('TabTheme', 'slanted&bw')
@@ -393,7 +390,6 @@
                 FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK)
         else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True)
 
-    
     def OnMB_OpenRPGTabStylesSlantedAqua(self):
         if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"):
             settings.change('TabTheme', 'slanted&aqua')
@@ -505,7 +501,7 @@
         else: self.updateMana.Show()
 
     def OnMB_DebugConsole(self, evt):
-        self.TraipseSuiteWarnCleanup('debug') ### Beta ###
+        self.TraipseSuiteWarnCleanup('debug')
         if self.debugger.IsShown() == True: self.debugger.Hide()
         else: self.debugger.Show()
 
@@ -514,28 +510,28 @@
         if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG
         else: lvl &= ~ORPG_DEBUG
         logger.log_level = lvl
-        settings.set('LoggingLevel', lvl)
+        settings.change('LoggingLevel', lvl)
 
     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)
 
     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)
 
     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)
 
     def OnMB_ToolsPasswordManager(self):
         if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable()
@@ -630,10 +626,8 @@
         # Update Manager 
         #self.manifest = manifest.ManifestChanges()
         self.updateMana = upmana.updatemana.updaterFrame(self, 
-            "OpenRPG Update Manager 1.0", component, manifest, True)
-        print component.get('upmana-win')
+            "OpenRPG Update Manager 1.2", component, manifest, True)
         component.add('upmana-win', self.updateMana)
-        print component.get('upmana-win')
         logger.debug("Menu Created")
         h = int(xml_dom.get("height"))
         w = int(xml_dom.get("width"))
@@ -685,7 +679,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"
@@ -757,11 +751,11 @@
 
     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)
+        temp_wnd = orpgTabberWnd(parent_wnd)
 
         children = xml_dom.getchildren()
         for c in children:
-            wnd = self.build_window(c,temp_wnd)
+            wnd = self.build_window(c, temp_wnd)
             name = c.get("name")
             temp_wnd.AddPage(wnd, name, False)
         return temp_wnd
@@ -800,7 +794,7 @@
             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)
+            component.add("chat", self.chat)
 
         elif name == "player":
             temp_wnd = orpg.player_list.player_list(parent_wnd)
@@ -939,10 +933,9 @@
         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 etreeEl.text: self.chat.Post(etreeEl.text)
+        display_name = self.chat.chat_display_name(player)
+        if etreeEl.text:self.chat.Post(display_name+etreeEl.text)
 
         for child in etreeEl.getchildren():
             if child.tag == 'tree':
@@ -950,7 +943,6 @@
                     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))
                   self.chat.InfoPost(display_name + " has sent you a tree node...")
             elif child.tag == 'map':
@@ -1112,7 +1104,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')
 
@@ -1135,7 +1128,7 @@
     
     def OnInit(self):
         component.add('log', logger)
-        component.add('xml', xml)
+        #component.add('xml', xml)
         component.add('settings', settings)
         component.add('validate', validate)
         component.add("tabbedWindows", [])