# HG changeset patch # User sirebral # Date 1250595217 18000 # Node ID c54768cffbd4e3bc98b1d6bf4d6e127a949b88f6 # Parent 4840657c23c50e9da8e9901a6b2bd62e48256217 Traipse Dev 'OpenRPG' {090818-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: *Unstable* This is the first wave of Code Refinement updates. Includes new material from Core Beta; new debugger material (partially implemented), beginnings of switch to etree, TerminalWriter, and a little more. open_rpg has been renamed to component; functioning now as component.get(), component.add(), component.delete(). This version has known bugs, specifically with the gametree and nodes. I think the XML files where not removed during testing of Core and switching back. diff -r 4840657c23c5 -r c54768cffbd4 data/SWd20/SWd20classes.xml diff -r 4840657c23c5 -r c54768cffbd4 data/SWd20/d20armor.xml diff -r 4840657c23c5 -r c54768cffbd4 data/SWd20/d20feats.xml diff -r 4840657c23c5 -r c54768cffbd4 data/SWd20/d20weapons.xml diff -r 4840657c23c5 -r c54768cffbd4 data/d20/d20armor.xml diff -r 4840657c23c5 -r c54768cffbd4 data/d20/d20classes.xml diff -r 4840657c23c5 -r c54768cffbd4 data/d20/d20divine.xml diff -r 4840657c23c5 -r c54768cffbd4 data/d20/d20feats.xml diff -r 4840657c23c5 -r c54768cffbd4 data/d20/d20powers.xml diff -r 4840657c23c5 -r c54768cffbd4 data/d20/d20spells.xml diff -r 4840657c23c5 -r c54768cffbd4 data/d20/d20weapons.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd35/books.txt diff -r 4840657c23c5 -r c54768cffbd4 data/dnd35/classes.txt diff -r 4840657c23c5 -r c54768cffbd4 data/dnd35/dnd35armor.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd35/dnd35character.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd35/dnd35classes.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd35/dnd35feats.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd35/dnd35weapons.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd35/feats.txt diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/dnd3earmor.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/dnd3echaracter.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/dnd3eclasses.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/dnd3edivine.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/dnd3efeats.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/dnd3epowers.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/dnd3espells.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/dnd3eweapons.xml diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/feats.txt diff -r 4840657c23c5 -r c54768cffbd4 data/dnd3e/skills.txt diff -r 4840657c23c5 -r c54768cffbd4 orpg/chat/__init__.py --- a/orpg/chat/__init__.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/chat/__init__.py Tue Aug 18 06:33:37 2009 -0500 @@ -0,0 +1,1 @@ + diff -r 4840657c23c5 -r c54768cffbd4 orpg/chat/chat_msg.py --- a/orpg/chat/chat_msg.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/chat/chat_msg.py Tue Aug 18 06:33:37 2009 -0500 @@ -29,7 +29,8 @@ __version__ = "$Id: chat_msg.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $" -import orpg.orpg_xml +#import orpg.orpg_xml +from orpg.orpgCore import * from chat_version import CHAT_VERSION CHAT_MESSAGE = 1 @@ -40,19 +41,21 @@ WHISPER_EMOTE_MESSAGE = 6 class chat_msg: - def __init__(self,xml_text=""): + def __init__(self,xml_text=""): + self.xml = component.get('xml') self.chat_dom = None - self.takexml(xml_text) + self.takexml(xml_text) def __del__(self): if self.chat_dom: self.chat_dom.unlink() def toxml(self): - return orpg.orpg_xml.toxml(self.chat_dom) + return self.xml.toxml(self.chat_dom) - def takexml(self,xml_text): - xml_dom = orpg.orpg_xml.parseXml(xml_text) + def takexml(self,xml_text): + #self.xml = component.get('xml') + xml_dom = self.xml.parseXml(xml_text) node_list = xml_dom.getElementsByTagName("chat") if len(node_list) < 1: print "Warning: no elements found in DOM." @@ -66,10 +69,10 @@ self.text_node = None self.chat_dom.unlink() self.chat_dom = xml_dom - self.text_node = orpg.orpg_xml.safe_get_text_node(self.chat_dom) + self.text_node = self.xml.safe_get_text_node(self.chat_dom) def set_text(self,text): - text = orpg.orpg_xml.strip_text(text) + text = self.xml.strip_text(text) self.text_node._set_nodeValue(text) def set_type(self,type): diff -r 4840657c23c5 -r c54768cffbd4 orpg/chat/chatwnd.py --- a/orpg/chat/chatwnd.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/chat/chatwnd.py Tue Aug 18 06:33:37 2009 -0500 @@ -45,11 +45,11 @@ ## from orpg.orpg_windows import * from orpg.player_list import WG_LIST -import orpg.dirpath +from orpg.dirpath import dir_struct import orpg.tools.rgbhex import orpg.tools.inputValidator -from orpg.tools.metamenus import MenuEx -from orpg.orpgCore import open_rpg +#from orpg.tools.metamenus import MenuEx #Needed? +from orpg.orpgCore import component import webbrowser from string import * from orpg.orpg_version import VERSION @@ -65,7 +65,8 @@ import cStringIO # for reading inline imagedata as a stream from HTMLParser import HTMLParser import chat_util -import traceback +import traceback +from orpg.tools.decorators import debugging NEWCHAT = False try: import wx.webview @@ -111,11 +112,11 @@ header = '[%s] : ' % ( timestamp ); if settings.get_setting('TimeStampGameLog') != '1': header = '' try: - f = open( orpg.dirpath.dir_struct["user"] + filename, 'a' ) + f = open( dir_struct["user"] + filename, 'a' ) f.write( '
%s%s
\n' % ( header, text ) ) f.close() except: - print "could not open " + orpg.dirpath.dir_struct["user"] + filename + ", ignoring..." + print "could not open " + dir_struct["user"] + filename + ", ignoring..." pass # This class displayes the chat information in html? @@ -306,19 +307,19 @@ # OnPageChanged(self, event) # set_default_font(self, font, fontsize) -class chat_notebook(orpgTabberWnd): +class chat_notebook(orpgTabberWnd): + @debugging def __init__(self, parent, size): - self.log = open_rpg.get_component("log") - self.log.log("Enter chat_notebook", ORPG_DEBUG) - orpgTabberWnd.__init__(self, parent, True, size=size, style=FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_NO_NAV_BUTTONS|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS) - self.settings = open_rpg.get_component("settings") + orpgTabberWnd.__init__(self, parent, True, size=size, + style=FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_NO_NAV_BUTTONS|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS) + self.settings = component.get("settings") self.whisper_tabs = [] self.group_tabs = [] self.null_tabs = [] self.il = wx.ImageList(16, 16) - bmp = wx.Bitmap(orpg.dirpath.dir_struct["icon"]+'player.gif') + bmp = wx.Bitmap(dir_struct["icon"]+'player.gif') self.il.Add(bmp) - bmp = wx.Bitmap(orpg.dirpath.dir_struct["icon"]+'clear.gif') + bmp = wx.Bitmap(dir_struct["icon"]+'clear.gif') self.il.Add(bmp) self.SetImageList(self.il) # Create "main" chatpanel tab, undeletable, connected to 'public' room. @@ -333,73 +334,68 @@ self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.onPageChanging) self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.onCloseTab) # html font/fontsize is global to all the notebook tabs. - self.font, self.fontsize = self.MainChatPanel.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'), self.settings.get_setting('defaultfontsize')) + self.font, self.fontsize = self.MainChatPanel.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'), + self.settings.get_setting('defaultfontsize')) self.GMChatPanel = None if self.settings.get_setting("GMWhisperTab") == '1': self.create_gm_tab() self.SetSelection(0) - self.log.log("Exit chat_notebook", ORPG_DEBUG) - + + @debugging def get_tab_index(self, chatpanel): "Return the index of a chatpanel in the wxNotebook." - self.log.log("Enter chat_notebook->get_tab_index(self, chatpanel)", ORPG_DEBUG) for i in xrange(self.GetPageCount()): if (self.GetPage(i) == chatpanel): - self.log.log("Exit chat_notebook->get_tab_index(self, chatpanel)", ORPG_DEBUG) return i - + + @debugging def create_gm_tab(self): - self.log.log("Enter chat_notebook->create_gm_tab(self)", ORPG_DEBUG) if self.GMChatPanel == None: self.GMChatPanel = chat_panel(self, -1, MAIN_TAB, 'gm') self.AddPage(self.GMChatPanel, "GM", False) self.SetPageImage(self.GetPageCount()-1, 1) self.GMChatPanel.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) - self.log.log("Exit chat_notebook->create_gm_tab(self)", ORPG_DEBUG) - + + @debugging def create_whisper_tab(self, playerid): "Add a new chatpanel directly connected to integer 'playerid' via whispering." - self.log.log("Enter chat_notebook->create_whisper_tab(self," + str(playerid) +")", ORPG_DEBUG) private_tab = chat_panel(self, -1, WHISPER_TAB, playerid) playername = strip_html(self.MainChatPanel.session.get_player_by_player_id(playerid)[0]) self.AddPage(private_tab, playername, False) private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) self.whisper_tabs.append(private_tab) self.newMsg(self.GetPageCount()-1) - self.AliasLib = open_rpg.get_component('alias') + self.AliasLib = component.get('alias') wx.CallAfter(self.AliasLib.RefreshAliases) - self.log.log("Exit chat_notebook->create_whisper_tab(self, playerid)", ORPG_DEBUG) return private_tab - + + @debugging def create_group_tab(self, group_name): "Add a new chatpanel directly connected to integer 'playerid' via whispering." - self.log.log("Enter chat_notebook->create_group_tab(self, group_name)", ORPG_DEBUG) private_tab = chat_panel(self, -1, GROUP_TAB, group_name) self.AddPage(private_tab, group_name, False) private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) self.group_tabs.append(private_tab) self.newMsg(self.GetPageCount()-1) - self.AliasLib = open_rpg.get_component('alias') + self.AliasLib = component.get('alias') wx.CallAfter(self.AliasLib.RefreshAliases) - self.log.log("Exit chat_notebook->create_group_tab(self, group_name)", ORPG_DEBUG) return private_tab - + + @debugging def create_null_tab(self, tab_name): "Add a new chatpanel directly connected to integer 'playerid' via whispering." - self.log.log("Enter chat_notebook->create_null_tab(self, tab_name)", ORPG_DEBUG) private_tab = chat_panel(self, -1, NULL_TAB, tab_name) self.AddPage(private_tab, tab_name, False) private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) self.null_tabs.append(private_tab) self.newMsg(self.GetPageCount()-1) - self.AliasLib = open_rpg.get_component('alias') + self.AliasLib = component.get('alias') wx.CallAfter(self.AliasLib.RefreshAliases) - self.log.log("Exit chat_notebook->create_null_tab(self, tab_name)", ORPG_DEBUG) return private_tab - + + @debugging def onCloseTab(self, evt): - self.log.log("Enter chat_notebook->onCloseTab(self, evt)", ORPG_DEBUG) try: tabid = evt.GetSelection() except: tabid = self.GetSelection() @@ -426,28 +422,24 @@ if panel in self.whisper_tabs: self.whisper_tabs.remove(panel) elif panel in self.group_tabs: self.group_tabs.remove(panel) elif panel in self.null_tabs: self.null_tabs.remove(panel) - self.log.log("Exit chat_notebook->onCloseTab(self, evt)", ORPG_DEBUG) - + + @debugging def newMsg(self, tabid): - self.log.log("Enter chat_notebook->newMsg(self, tabid)", ORPG_DEBUG) if tabid != self.GetSelection(): self.SetPageImage(tabid, 0) - self.log.log("Exit chat_notebook->newMsg(self, tabid)", ORPG_DEBUG) - + + @debugging def onPageChanging(self, event): """When private chattabs are selected, set the bitmap back to 'normal'.""" - self.log.log("Enter chat_notebook->onPageChanging(self, event)", ORPG_DEBUG) event.Skip() - self.log.log("Exit chat_notebook->onPageChanging(self, event)", ORPG_DEBUG) - + + @debugging def onPageChanged(self, event): """When private chattabs are selected, set the bitmap back to 'normal'.""" - self.log.log("Enter chat_notebook->onPageChanged(self, event)", ORPG_DEBUG) selected_idx = event.GetSelection() self.SetPageImage(selected_idx, 1) page = self.GetPage(selected_idx) #wx.CallAfter(page.set_chat_text_focus, 0) event.Skip() - self.log.log("Exit chat_notebook->onPageChanged(self, event)", ORPG_DEBUG) """ This class defines and builds the Chat Frame for OpenRPG @@ -489,21 +481,20 @@ !openrpg : !sendtarget: who gets outbound messages: either 'all' or a playerid """ - + + @debugging def __init__(self, parent, id, tab_type, sendtarget): - self.log = open_rpg.get_component("log") - self.log.log("Enter chat_panel", ORPG_DEBUG) wx.Panel.__init__(self, parent, id) - self.session = open_rpg.get_component('session') - self.settings = open_rpg.get_component('settings') - self.activeplugins = open_rpg.get_component('plugins') + self.session = component.get('session') + self.settings = component.get('settings') + self.activeplugins = component.get('plugins') self.parent = parent # who receives outbound messages, either "all" or "playerid" string self.sendtarget = sendtarget self.type = tab_type - self.sound_player = open_rpg.get_component('sound') + self.sound_player = component.get('sound') # create die roller manager - self.DiceManager = open_rpg.get_component('DiceManager') + self.DiceManager = component.get('DiceManager') # create rpghex tool self.r_h = orpg.tools.rgbhex.RGBHex() self.h = 0 @@ -528,7 +519,7 @@ self.Bind(wx.EVT_SIZE, self.OnSize) self.build_ctrls() #openrpg dir - self.root_dir = orpg.dirpath.dir_struct["home"] + self.root_dir = dir_struct["home"] # html font/fontsize is global to all the notebook tabs. StartupFont = self.settings.get_setting("defaultfont") StartupFontSize = self.settings.get_setting("defaultfontsize") @@ -538,11 +529,10 @@ self.font = self.chatwnd.GetFont().GetFaceName() self.fontsize = self.chatwnd.GetFont().GetPointSize() self.scroll_down() - self.log.log("Exit chat_panel", ORPG_DEBUG) - + + @debugging def set_default_font(self, fontname=None, fontsize=None): """Set all chatpanels to new default fontname/fontsize. Returns current font settings in a (fontname, fontsize) tuple.""" - self.log.log("Enter chat_panel->set_default_font(self, fontname=None, fontsize=None)", ORPG_DEBUG) if (fontname is not None): newfont = fontname else: newfont = self.font if (fontsize is not None): newfontsize = int(fontsize) @@ -551,12 +541,11 @@ self.InfoPost("Font is now " + newfont + " point size " + `newfontsize`) self.font = newfont self.fontsize = newfontsize - self.log.log("Exit chat_panel->set_default_font(self, fontname=None, fontsize=None)", ORPG_DEBUG) return (self.font, self.fontsize) - + + @debugging def build_menu(self): - self.log.log("Enter chat_panel->build_menu(self)", ORPG_DEBUG) - top_frame = open_rpg.get_component('frame') + top_frame = component.get('frame') menu = wx.Menu() item = wx.MenuItem(menu, wx.ID_ANY, "&Background color", "Background color") top_frame.Bind(wx.EVT_MENU, self.OnMB_BackgroundColor, item) @@ -591,7 +580,8 @@ tabmenu = wx.Menu() toolmenu = wx.Menu() item = wx.MenuItem(wndmenu, wx.ID_ANY, "Show Images", "Show Images", wx.ITEM_CHECK) - top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowImages, item) + top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowImages, item) + wndmenu.AppendItem(item) if self.settings.get_setting("Show_Images_In_Chat") == '1': item.Check(True) item = wx.MenuItem(wndmenu, wx.ID_ANY, "Strip HTML", "Strip HTML", wx.ITEM_CHECK) @@ -641,70 +631,59 @@ toolmenu.AppendItem(item) if self.settings.get_setting("AliasTool_On") == '1': item.Check(True) settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tool Bars', toolmenu) - menu.AppendMenu(wx.ID_ANY, 'Chat Settings', settingmenu) + menu.AppendMenu(wx.ID_ANY, 'Chat Settings', settingmenu) top_frame.mainmenu.Insert(2, menu, '&Chat') - self.log.log("Exit chat_panel->build_menu(self)", ORPG_DEBUG) - ## Settings Menu Events + ## Settings Menu Events + @debugging def OnMB_ShowImages(self, event): - self.log.log("Enter chat_panel->OnMB_ShowImages(self, event)", ORPG_DEBUG) if event.IsChecked(): self.settings.set_setting("Show_Images_In_Chat", '1') else: self.settings.set_setting("Show_Images_In_Chat", '0') - self.log.log("Exit chat_panel->OnMB_ShowImages(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_StripHTML(self, event): - self.log.log("Enter chat_panel->OnMB_StripHTML(self, event)", ORPG_DEBUG) if event.IsChecked(): self.settings.set_setting("Sstriphtml", '1') else: self.settings.set_setting("striphtml", '0') - self.log.log("Exit chat_panel->OnMB_StripHTML(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_ChatTimeIndex(self, event): - self.log.log("Enter chat_panel->OnMB_ChatTimeIndex(self, event)", ORPG_DEBUG) if event.IsChecked(): self.settings.set_setting("Chat_Time_Indexing", '1') else: self.settings.set_setting("Chat_Time_Indexing", '0') - self.log.log("Exit chat_panel->OnMB_ChatTimeIndex(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_ChatAutoComplete(self, event): - self.log.log("Enter chat_panel->OnMB_ChatAutoComplete(self, event)", ORPG_DEBUG) if event.IsChecked(): self.settings.set_setting("SuppressChatAutoComplete", '0') else: self.settings.set_setting("SuppressChatAutoComplete", '1') - self.log.log("Exit chat_panel->OnMB_ChatAutoComplete(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_ShowIDinChat(self, event): - self.log.log("Enter chat_panel->OnMB_ShowIDinChat(self, event)", ORPG_DEBUG) if event.IsChecked(): self.settings.set_setting("ShowIDInChat", '1') else: self.settings.set_setting("ShowIDInChat", '0') - self.log.log("Exit chat_panel->OnMB_ShowIDinChat(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_LogTimeIndex(self, event): - self.log.log("Enter chat_panel->OnMB_LogTimeIndex(self, event)", ORPG_DEBUG) if event.IsChecked(): self.settings.set_setting("TimeStampGameLog", '1') else: self.settings.set_setting("TimeStampGameLog", '0') - self.log.log("Exit chat_panel->OnMB_LogTimeIndex(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_TabbedWhispers(self, event): - self.log.log("Enter chat_panel->OnMB_TabbedWhispers(self, event)", ORPG_DEBUG) if event.IsChecked(): self.settings.set_setting("tabbedwhispers", '1') else: self.settings.set_setting("tabbedwhispers", '0') - self.log.log("Exit chat_panel->OnMB_TabbedWhispers(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_GMTab(self, event): - self.log.log("Enter chat_panel->OnMB_GMTab(self, event)", ORPG_DEBUG) if event.IsChecked(): self.settings.set_setting("GMWhisperTab", '1') self.parent.create_gm_tab() else: self.settings.set_setting("GMWhisperTab", '0') - self.log.log("Exit chat_panel->OnMB_GMTab(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_GroupWhisperTabs(self, event): - self.log.log("Enter chat_panel->OnMB_GroupWhisperTabs(self, event)", ORPG_DEBUG) if event.IsChecked(): self.settings.set_setting("GroupWhisperTab", '1') else: self.settings.set_setting("GroupWhisperTab", '0') - self.log.log("Exit chat_panel->OnMB_GroupWhisperTabs(self, event)", ORPG_DEBUG) - - + + @debugging def OnMB_DiceBar(self, event): - self.log.log("Enter chat_panel->OnMB_DiceBar(self, event)", ORPG_DEBUG) act = '0' if event.IsChecked(): self.settings.set_setting("DiceButtons_On", '1') @@ -716,10 +695,9 @@ for panel in self.parent.whisper_tabs: panel.toggle_dice(act) for panel in self.parent.group_tabs: panel.toggle_dice(act) for panel in self.parent.null_tabs: panel.toggle_dice(act) - self.log.log("Exit chat_panel->OnMB_DiceBar(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_FormatButtons(self, event): - self.log.log("Enter chat_panel->OnMB_FormatButtons(self, event)", ORPG_DEBUG) act = '0' if event.IsChecked(): self.settings.set_setting("FormattingButtons_On", '1') @@ -732,10 +710,9 @@ for panel in self.parent.whisper_tabs: panel.toggle_formating(act) for panel in self.parent.group_tabs: panel.toggle_formating(act) for panel in self.parent.null_tabs: panel.toggle_formating(act) - self.log.log("Exit chat_panel->OnMB_FormatButtons(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_AliasTool(self, event): - self.log.log("Enter chat_panel->OnMB_AliasTool(self, event)", ORPG_DEBUG) act = '0' if event.IsChecked(): self.settings.set_setting("AliasTool_On", '1') @@ -747,11 +724,10 @@ for panel in self.parent.whisper_tabs: panel.toggle_alias(act) for panel in self.parent.group_tabs: panel.toggle_alias(act) for panel in self.parent.null_tabs:panel.toggle_alias(act) - self.log.log("Exit chat_panel->OnMB_AliasTool(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_BackgroundColor(self, event): - self.log.log("Enter chat_panel->OnMB_BackgroundColor(self, event)", ORPG_DEBUG) - top_frame = open_rpg.get_component('frame') + top_frame = component.get('frame') hexcolor = self.get_color() if hexcolor != None: self.bgcolor = hexcolor @@ -770,11 +746,10 @@ top_frame.players.SetForegroundColour('black') top_frame.players.Refresh() self.chatwnd.scroll_down() - self.log.log("Exit chat_panel->OnMB_BackgroundColor(self, event)", ORPG_DEBUG) - + + @debugging def OnMB_TextColor(self, event): - self.log.log("Enter chat_panel->OnMB_TextColor(self, event)", ORPG_DEBUG) - top_frame = open_rpg.get_component('frame') + top_frame = component.get('frame') hexcolor = self.get_color() if hexcolor != None: self.textcolor = hexcolor @@ -793,41 +768,38 @@ top_frame.players.SetForegroundColour('black') top_frame.players.Refresh() self.chatwnd.scroll_down() - self.log.log("Exit chat_panel->OnMB_TextColor(self, event)", ORPG_DEBUG) - - + + @debugging def get_hot_keys(self): - self.log.log("Enter chat_panel->get_hot_keys(self)", ORPG_DEBUG) # dummy menus for hotkeys self.build_menu() entries = [] entries.append((wx.ACCEL_CTRL, ord('H'), self.setChatFocusMenu.GetId())) #entries.append((wx.ACCEL_CTRL, wx.WXK_TAB, SWAP_TABS)) - self.log.log("Enter chat_panel->get_hot_keys(self)", ORPG_DEBUG) return entries - + + @debugging def forward_tabs(self, evt): - self.log.log("Enter chat_panel->swap_tabs(self, evt)", ORPG_DEBUG) self.parent.AdvanceSelection() - self.log.log("Exit chat_panel->swap_tabs(self, evt)", ORPG_DEBUG) def back_tabs(self, evt): - self.log.log("Enter chat_panel->swap_tabs(self, evt)", ORPG_DEBUG) self.parent.AdvanceSelection(False) - self.log.log("Exit chat_panel->swap_tabs(self, evt)", ORPG_DEBUG) # This subroutine builds the controls for the chat frame # - # !self : instance of self + # !self : instance of self + @debugging def build_ctrls(self): - self.log.log("Enter chat_panel->build_ctrls(self)", ORPG_DEBUG) self.chatwnd = chat_html_window(self,-1) self.set_colors() wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header()) if (self.sendtarget == "all"): - wx.CallAfter(self.Post, self.colorize(self.syscolor, "Welcome to OpenRPG version " + self.version + "... ")) + wx.CallAfter(self.Post, self.colorize(self.syscolor, + "Welcome to OpenRPG version " + self.version + "... ")) #self.chat_cmds.on_help() - self.chattxt = orpg.tools.predTextCtrl.predTextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER |wx.TE_PROCESS_TAB|wx.TE_LINEWRAP, keyHook = self.myKeyHook, validator=None ) + self.chattxt = orpg.tools.predTextCtrl.predTextCtrl(self, -1, "", + style=wx.TE_PROCESS_ENTER |wx.TE_PROCESS_TAB|wx.TE_LINEWRAP, + keyHook = self.myKeyHook, validator=None ) self.build_bar() self.basesizer = wx.BoxSizer(wx.VERTICAL) self.basesizer.Add( self.chatwnd, 1, wx.EXPAND ) @@ -862,15 +834,15 @@ self.chattxt.Bind(wx.EVT_MOUSEWHEEL, self.chatwnd.mouse_wheel) self.chattxt.Bind(wx.EVT_CHAR, self.chattxt.OnChar) self.chattxt.Bind(wx.EVT_TEXT_COPY, self.textCopy) - self.log.log("Exit chat_panel->build_ctrls(self)", ORPG_DEBUG) # def build_ctrls - end - + + @debugging def textCopy(self, event): if self.chattxt.GetStringSelection() == '': self.chatwnd.OnM_EditCopy(None) else: self.chatwnd.Copy() - + + @debugging def build_bar(self): - self.log.log("Enter chat_panel->build_bar(self)", ORPG_DEBUG) self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL) self.scroll_lock = None self.numDieText = None @@ -884,20 +856,20 @@ self.toolbar_sizer.Add(self.scroll_lock,0,wx.EXPAND) self.build_formating() self.build_colorbutton() - self.log.log("Exit chat_panel->build_bar(self)", ORPG_DEBUG) - + + @debugging def build_scroll(self): - self.log.log("Enter chat_panel->build_scroll(self)", ORPG_DEBUG) self.scroll_lock = wx.Button( self, wx.ID_ANY, "Scroll ON",size= wx.Size(80,25)) - self.log.log("Exit chat_panel->build_scroll(self)", ORPG_DEBUG) - + + @debugging def build_alias(self): - self.log.log("Enter chat_panel->build_alias(self)", ORPG_DEBUG) self.aliasList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultAliasName]) - self.aliasButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"] + 'player.gif', 'Refresh list of aliases from Game Tree', wx.ID_ANY, '#bdbdbd' ) + self.aliasButton = createMaskedButton( self, dir_struct["icon"] + 'player.gif', + 'Refresh list of aliases from Game Tree', wx.ID_ANY, '#bdbdbd' ) self.aliasList.SetSelection(0) self.filterList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultFilterName]) - self.filterButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"] + 'add_filter.gif', 'Refresh list of filters from Game Tree', wx.ID_ANY, '#bdbdbd' ) + self.filterButton = createMaskedButton( self, dir_struct["icon"] + 'add_filter.gif', + 'Refresh list of filters from Game Tree', wx.ID_ANY, '#bdbdbd' ) self.filterList.SetSelection(0) self.toolbar_sizer.Add( self.aliasButton, 0, wx.EXPAND ) self.toolbar_sizer.Add( self.aliasList,0,wx.EXPAND) @@ -905,10 +877,9 @@ self.toolbar_sizer.Add( self.filterList,0,wx.EXPAND) if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0') else: self.toggle_alias('1') - self.log.log("Exit chat_panel->build_alias(self)", ORPG_DEBUG) - + + @debugging def toggle_alias(self, act): - self.log.log("Enter chat_panel->toggle_alias(self, " + str(act) + ")", ORPG_DEBUG) if act == '0': self.toolbar_sizer.Show(self.aliasList, False) self.toolbar_sizer.Show(self.filterList, False) @@ -921,24 +892,22 @@ self.toolbar_sizer.Show(self.aliasButton, True) self.toolbar_sizer.Show(self.filterButton, True) self.toolbar_sizer.Layout() - self.log.log("Exit chat_panel->toggle_alias(self, act)", ORPG_DEBUG) - + + @debugging def build_text(self): - self.log.log("Enter chat_panel->build_text(self)", ORPG_DEBUG) - self.textpop_lock = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd') - self.log.log("Exit chat_panel->build_text(self)", ORPG_DEBUG) - + self.textpop_lock = createMaskedButton(self, dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd') + + @debugging def build_dice(self): - self.log.log("Enter chat_panel->build_dice(self)", ORPG_DEBUG) self.numDieText = wx.TextCtrl( self, wx.ID_ANY, "1", size= wx.Size(25, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) self.dieModText = wx.TextCtrl( self, wx.ID_ANY, "", size= wx.Size(50, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) - self.d4Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d4.gif', 'Roll d4', wx.ID_ANY) - self.d6Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d6.gif', 'Roll d6', wx.ID_ANY) - self.d8Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d8.gif', 'Roll d8', wx.ID_ANY) - self.d10Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d10.gif', 'Roll d10', wx.ID_ANY) - self.d12Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d12.gif', 'Roll d12', wx.ID_ANY) - self.d20Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d20.gif', 'Roll d20', wx.ID_ANY) - self.d100Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d100.gif', 'Roll d100', wx.ID_ANY) + self.d4Button = createMaskedButton(self, dir_struct["icon"]+'b_d4.gif', 'Roll d4', wx.ID_ANY) + self.d6Button = createMaskedButton(self, dir_struct["icon"]+'b_d6.gif', 'Roll d6', wx.ID_ANY) + self.d8Button = createMaskedButton(self, dir_struct["icon"]+'b_d8.gif', 'Roll d8', wx.ID_ANY) + self.d10Button = createMaskedButton(self, dir_struct["icon"]+'b_d10.gif', 'Roll d10', wx.ID_ANY) + self.d12Button = createMaskedButton(self, dir_struct["icon"]+'b_d12.gif', 'Roll d12', wx.ID_ANY) + self.d20Button = createMaskedButton(self, dir_struct["icon"]+'b_d20.gif', 'Roll d20', wx.ID_ANY) + self.d100Button = createMaskedButton(self, dir_struct["icon"]+'b_d100.gif', 'Roll d100', wx.ID_ANY) self.toolbar_sizer.Add( self.numDieText, 0, wx.ALIGN_CENTER | wx.EXPAND) self.toolbar_sizer.Add( self.d4Button, 0 ,wx.EXPAND) self.toolbar_sizer.Add( self.d6Button, 0 ,wx.EXPAND) @@ -950,10 +919,9 @@ self.toolbar_sizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 ) if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0') else: self.toggle_dice('1') - self.log.log("Exit chat_panel->build_dice(self)", ORPG_DEBUG) - + + @debugging def toggle_dice(self, act): - self.log.log("Enter chat_panel->toggle_dice(self, "+ str(act) + ")", ORPG_DEBUG) if act == '0': self.toolbar_sizer.Show(self.numDieText, False) self.toolbar_sizer.Show(self.d4Button, False) @@ -976,22 +944,23 @@ self.toolbar_sizer.Show(self.d100Button, True) self.toolbar_sizer.Show(self.dieModText, True) self.toolbar_sizer.Layout() - self.log.log("Exit chat_panel->toggle_dice(self, "+ str(act) + ")", ORPG_DEBUG) - + + @debugging def build_formating(self): - self.log.log("Enter chat_panel->build_formating(self)", ORPG_DEBUG) - self.boldButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'bold.gif', 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd') - self.italicButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'italic.gif', 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' ) - self.underlineButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'underlined.gif', 'Underline the selected text', wx.ID_ANY, '#bdbdbd' ) + self.boldButton = createMaskedButton( self, dir_struct["icon"]+'bold.gif', + 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd') + self.italicButton = createMaskedButton( self, dir_struct["icon"]+'italic.gif', + 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' ) + self.underlineButton = createMaskedButton( self, dir_struct["icon"]+'underlined.gif', + 'Underline the selected text', wx.ID_ANY, '#bdbdbd' ) self.toolbar_sizer.Add( self.boldButton, 0, wx.EXPAND ) self.toolbar_sizer.Add( self.italicButton, 0, wx.EXPAND ) self.toolbar_sizer.Add( self.underlineButton, 0, wx.EXPAND ) if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0') else: self.toggle_formating('1') - self.log.log("Exit chat_panel->build_formating(self)", ORPG_DEBUG) - + + @debugging def toggle_formating(self, act): - self.log.log("Enter chat_panel->toggle_formating(self, " + str(act) + ")", ORPG_DEBUG) if act == '0': self.toolbar_sizer.Show(self.boldButton, False) self.toolbar_sizer.Show(self.italicButton, False) @@ -1002,25 +971,23 @@ self.toolbar_sizer.Show(self.italicButton, True) self.toolbar_sizer.Show(self.underlineButton, True) self.toolbar_sizer.Layout() - self.log.log("Exit chat_panel->toggle_formating(self, " + str(act) + ")", ORPG_DEBUG) - # Heroman - Ideally, we would use static labels... + # Heroman - Ideally, we would use static labels... + @debugging def build_colorbutton(self): - self.log.log("Enter chat_panel->build_colorbutton(self)", ORPG_DEBUG) - self.color_button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'textcolor.gif', + self.color_button = createMaskedButton(self, dir_struct["icon"]+'textcolor.gif', 'Text Color', wx.ID_ANY, '#bdbdbd', wx.BITMAP_TYPE_GIF) - self.saveButton = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'save.bmp', + self.saveButton = createMaskedButton(self, dir_struct["icon"]+'save.bmp', 'Save the chatbuffer', wx.ID_ANY, '#c0c0c0', wx.BITMAP_TYPE_BMP ) self.color_button.SetBackgroundColour(self.settings.get_setting('mytextcolor')) self.toolbar_sizer.Add(self.color_button, 0, wx.EXPAND) self.toolbar_sizer.Add(self.saveButton, 0, wx.EXPAND) - self.log.log("Exit chat_panel->build_colorbutton(self)", ORPG_DEBUG) - + + @debugging def OnMotion(self, evt): - self.log.log("Enter chat_panel->OnMotion(self, evt)", ORPG_DEBUG) contain = self.chatwnd.GetInternalRepresentation() if contain: sx = sy = 0 @@ -1036,18 +1003,17 @@ link = lnk.GetHref() self.session.set_status_url(link) except: pass - else: self.log.log("Error, self.chatwnd.GetInternalRepresentation() return None", ORPG_GENERAL) + else: logger.general("Error, self.chatwnd.GetInternalRepresentation() return None") evt.Skip() - self.log.log("Exit chat_panel->OnMotion(self, evt)", ORPG_DEBUG) # This subroutine is registered with predTextCtrl to be run for every OnChar event # It checks if we need to send a typing message # # self: duh - # event: raw KeyEvent from OnChar() + # event: raw KeyEvent from OnChar() + @debugging def myKeyHook(self, event): - self.log.log("Enter chat_panel->myKeyHook(self, event)", ORPG_DEBUG) if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected thisPress = time.time() # thisPress is local temp variable if (thisPress - self.lastSend) > 4: # Check to see if it's been 5 seconds since our last notice @@ -1056,16 +1022,17 @@ self.lastPress = thisPress # either way, record the time of this keystroke for use in # self.typingTimerFunc() if self.settings.get_setting('SuppressChatAutoComplete') == '1': - self.log.log("Exit chat_panel->myKeyHook(self, event) return 1", ORPG_DEBUG) + logger.debug("Exit chat_panel->myKeyHook(self, event) return 1") return 1 else: - self.log.log("Exit chat_panel->myKeyHook(self, event) return 0", ORPG_DEBUG) + loger.debug("Exit chat_panel->myKeyHook(self, event) return 0") return 0 # This subroutine gets called once a second by the typing Timer # It checks if we need to send a not_typing message # - # self: duh + # self: duh + @debugging def typingTimerFunc(self, event): #following added by mDuo13 ##############refresh_counter()############## @@ -1074,8 +1041,8 @@ try: plugin.refresh_counter() except Exception, e: if str(e) != "'module' object has no attribute 'refresh_counter'": - self.log.log(traceback.format_exc(), ORPG_GENERAL) - self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) + logger.general(traceback.format_exc()) + logger.general("EXCEPTION: " + str(e)) #end mDuo13 added code if self.lastSend: # This will be zero when not typing, so equiv to if is_typing thisTime = time.time() # thisTime is a local temp variable @@ -1086,9 +1053,10 @@ # This subroutine actually takes care of sending the messages for typing/not_typing events # # self: duh - # typing: boolean + # typing: boolean + + @debugging def sendTyping(self, typing): - self.log.log("Enter chat_panel->sendTyping(self, typing)", ORPG_DEBUG) if typing: self.lastSend = time.time() # remember our send time for use in myKeyHook() #I think this is cleaner @@ -1101,14 +1069,13 @@ status_text = self.settings.get_setting('IdleStatusAlias') if status_text == "" or status_text == None: status_text = "Idle" self.session.set_text_status(status_text) - self.log.log("Exit chat_panel->sendTyping(self, typing)", ORPG_DEBUG) # This subroutine sets the colors of the chat based on the settings in the # self instance. # - # !self : instance of self + # !self : instance of self + @debugging def set_colors(self): - self.log.log("Enter chat_panel->set_colors(self)", ORPG_DEBUG) # chat window backround color self.bgcolor = self.settings.get_setting('bgcolor') # chat window normal text color @@ -1123,31 +1090,27 @@ self.emotecolor = self.settings.get_setting('emotecolor') # color of whispers self.whispercolor = self.settings.get_setting('whispercolor') - self.log.log("Exit chat_panel->set_colors(self)", ORPG_DEBUG) # def set_colors - end # This subroutine will insert text into the chat window # # !self : instance of self - # !txt : text to be inserted into the chat window + # !txt : text to be inserted into the chat window + @debugging def set_chat_text(self, txt): - self.log.log("Enter chat_panel->set_chat_text(self, txt)", ORPG_DEBUG) self.chattxt.SetValue(txt) self.chattxt.SetFocus() self.chattxt.SetInsertionPointEnd() - self.log.log("Exit chat_panel->set_chat_text(self, txt)", ORPG_DEBUG) # def set_chat_text - end - + + @debugging def get_chat_text(self): - self.log.log("Enter chat_panel->get_chat_text(self)", ORPG_DEBUG) - self.log.log("Enter chat_panel->get_chat_text(self)", ORPG_DEBUG) return self.chattxt.GetValue() - # This subroutine sets the focus to the chat window + # This subroutine sets the focus to the chat window + @debugging def set_chat_text_focus(self, event): - self.log.log("Enter chat_panel->set_chat_text_focus(self, event)", ORPG_DEBUG) wx.CallAfter(self.chattxt.SetFocus) - self.log.log("Exit chat_panel->set_chat_text_focus(self, event)", ORPG_DEBUG) # def set_chat_text_focus - end # This subrtouine grabs the user input and make the special keys and @@ -1157,27 +1120,30 @@ # !event : # # Note: self.chattxt now handles it's own Key events. It does, however still - # call it's parent's (self) OnChar to handle "default" behavior. + # call it's parent's (self) OnChar to handle "default" behavior. + @debugging def OnChar(self, event): - self.log.log("Enter chat_panel->OnChar(self, event)", ORPG_DEBUG) s = self.chattxt.GetValue() #self.histlen = len(self.history) - 1 ## RETURN KEY (no matter if there is text in chattxt) # This section is run even if there is nothing in the chattxt (as opposed to the next wx.WXK_RETURN handler if event.GetKeyCode() == wx.WXK_RETURN: - self.log.log("event.GetKeyCode() == wx.WXK_RETURN", ORPG_DEBUG) + logger.debug("event.GetKeyCode() == wx.WXK_RETURN") self.set_colors() if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected self.sendTyping(0) # Send a "not_typing" event on enter key press macroText="" + recycle_bin = {wx.WXK_F1: 'event.GetKeyCode() == wx.WXK_F1', wx.WXK_F2: 'event.GetKeyCode() == wx.WXK_F2', + wx.WXK_F3: 'event.GetKeyCode() == wx.WXK_F3', wx.WXK_F4: 'event.GetKeyCode() == wx.WXK_F4', + wx.WXK_F5: 'event.GetKeyCode() == wx.WXK_F5', wx.WXK_F6: 'event.GetKeyCode() == wx.WXK_F6', + wx.WXK_F7: 'event.GetKeyCode() == wx.WXK_F7', wx.WXK_F8: 'event.GetKeyCode() == wx.WXK_F8', + wx.WXK_F9: 'event.GetKeyCode() == wx.WXK_F9', wx.WXK_F10: 'event.GetKeyCode() == wx.WXK_F10', + wx.WXK_F11: 'event.GetKeyCode() == wx.WXK_F11', wx.WXK_F12: 'event.GetKeyCode() == wx.WXK_F12'} - - recycle_bin = {wx.WXK_F1: 'event.GetKeyCode() == wx.WXK_F1', wx.WXK_F2: 'event.GetKeyCode() == wx.WXK_F2', wx.WXK_F3: 'event.GetKeyCode() == wx.WXK_F3', wx.WXK_F4: 'event.GetKeyCode() == wx.WXK_F4', wx.WXK_F5: 'event.GetKeyCode() == wx.WXK_F5', wx.WXK_F6: 'event.GetKeyCode() == wx.WXK_F6', wx.WXK_F7: 'event.GetKeyCode() == wx.WXK_F7', wx.WXK_F8: 'event.GetKeyCode() == wx.WXK_F8', wx.WXK_F9: 'event.GetKeyCode() == wx.WXK_F9', wx.WXK_F10: 'event.GetKeyCode() == wx.WXK_F10', wx.WXK_F11: 'event.GetKeyCode() == wx.WXK_F11', wx.WXK_F12: 'event.GetKeyCode() == wx.WXK_F12'} -# Recycle Bin and Lambda should reduce this whole IF ELIF statement block. bin_event = event.GetKeyCode() if recycle_bin.has_key(bin_event): - self.log.log(lambda bin_event: recycle_bin[bin_event], ORPG_DEBUG) + logger.debug(lambda bin_event: recycle_bin[bin_event]) macroText = self.settings.get_setting(recycle_bin[bin_event][29:]) recycle_bin = {}; del bin_event @@ -1188,7 +1154,7 @@ ## RETURN KEY (and not text in control) if (event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText): - self.log.log("(event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText)", ORPG_DEBUG) + logger.debug("(event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText)") self.histidx = -1 self.temptext = "" self.history = [s] + self.history#prepended instead of appended now, so higher index = greater age @@ -1202,7 +1168,7 @@ ## UP KEY elif event.GetKeyCode() == wx.WXK_UP: - self.log.log("event.GetKeyCode() == wx.WXK_UP", ORPG_DEBUG) + logger.debug("event.GetKeyCode() == wx.WXK_UP") if self.histidx < len(self.history)-1: #text that's not in history but also hasn't been sent to chat gets stored in self.temptext #this way if someone presses the up key, they don't lose their current message permanently @@ -1218,7 +1184,7 @@ ## DOWN KEY elif event.GetKeyCode() == wx.WXK_DOWN: - self.log.log("event.GetKeyCode() == wx.WXK_DOWN", ORPG_DEBUG) + logger.debug("event.GetKeyCode() == wx.WXK_DOWN") #histidx of -1 indicates currently viewing text that's not in self.history if self.histidx > -1: self.histidx -= 1 @@ -1232,7 +1198,7 @@ ## TAB KEY elif event.GetKeyCode() == wx.WXK_TAB: - self.log.log("event.GetKeyCode() == wx.WXK_TAB", ORPG_DEBUG) + logger.debug("event.GetKeyCode() == wx.WXK_TAB") if s !="": found = 0 nicks = [] @@ -1271,13 +1237,13 @@ ## PAGE UP elif event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP): - self.log.log("event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP)", ORPG_DEBUG) + logger.debug("event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP)") self.chatwnd.ScrollPages(-1) if not self.lockscroll: self.lock_scroll(0) ## PAGE DOWN elif event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN): - self.log.log("event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN)", ORPG_DEBUG) + logger.debug("event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN)") if not self.lockscroll: self.lock_scroll(0) if ((self.chatwnd.GetScrollRange(1)-self.chatwnd.GetScrollPos(1)-self.chatwnd.GetScrollThumb(1) < 30) and self.lockscroll): self.lock_scroll(0) @@ -1285,7 +1251,7 @@ ## END elif event.GetKeyCode() == wx.WXK_END: - self.log.log("event.GetKeyCode() == wx.WXK_END", ORPG_DEBUG) + logger.debug("event.GetKeyCode() == wx.WXK_END", ORPG_DEBUG) if self.lockscroll: self.lock_scroll(0) self.Post() @@ -1293,12 +1259,12 @@ ## NOTHING else: event.Skip() - self.log.log("Exit chat_panel->OnChar(self, event)", ORPG_DEBUG) + logger.debug("Exit chat_panel->OnChar(self, event)", ORPG_DEBUG) # def OnChar - end - + + @debugging def onDieRoll(self, evt): """Roll the dice based on the button pressed and the die modifiers entered, if any.""" - self.log.log("Enter chat_panel->onDieRoll(self, evt)", ORPG_DEBUG) # Get any die modifiers if they have been entered numDie = self.numDieText.GetValue() dieMod = self.dieModText.GetValue() @@ -1311,15 +1277,14 @@ dieText = "[" + dieText + "]" self.ParsePost(dieText, 1, 1) self.chattxt.SetFocus() - self.log.log("Exit chat_panel->onDieRoll(self, evt)", ORPG_DEBUG) # This subroutine saves a chat buffer as html to a file chosen via a # FileDialog. # # !self : instance of self - # !evt : + # !evt : + @debugging def on_chat_save(self, evt): - self.log.log("Enter chat_panel->on_chat_save(self, evt)", ORPG_DEBUG) f = wx.FileDialog(self,"Save Chat Buffer",".","","HTM* (*.htm*)|*.htm*|HTML (*.html)|*.html|HTM (*.htm)|*.htm",wx.SAVE) if f.ShowModal() == wx.ID_OK: file = open(f.GetPath(), "w") @@ -1327,19 +1292,22 @@ file.close() f.Destroy() os.chdir(self.root_dir) - self.log.log("Exit chat_panel->on_chat_save(self, evt)", ORPG_DEBUG) # def on_chat_save - end - + + @debugging def ResetPage(self): self.set_colors() buffertext = self.chatwnd.Header() + "\n" - buffertext += chat_util.strip_body_tags(self.chatwnd.StripHeader()).replace("
", "
").replace('', '').replace("
", "
\n").replace("\n\n", '') + buffertext += chat_util.strip_body_tags(self.chatwnd.StripHeader()).replace("
", + "
").replace('', + '').replace("
", + "
\n").replace("\n\n", '') return buffertext # This subroutine sets the color of selected text, or base text color if - # nothing is selected + # nothing is selected + @debugging def on_text_color(self, event): - self.log.log("Enter chat_panel->on_text_color(self, event)", ORPG_DEBUG) hexcolor = self.r_h.do_hex_color_dlg(self) if hexcolor != None: (beg,end) = self.chattxt.GetSelection() @@ -1355,18 +1323,16 @@ self.settings.set_setting('mytextcolor',hexcolor) self.set_colors() self.Post() - self.log.log("Exit chat_panel->on_text_color(self, event)", ORPG_DEBUG) # def on_text_color - end # This subroutine take a color and a text string and formats it into html. # # !self : instance of self # !color : color for the text to be set - # !text : text string to be included in the html. + # !text : text string to be included in the html. + @debugging def colorize(self, color, text): """Puts font tags of 'color' around 'text' value, and returns the string""" - self.log.log("Enter chat_panel->colorize(self, color, text)", ORPG_DEBUG) - self.log.log("Exit chat_panel->colorize(self, color, text)", ORPG_DEBUG) return "" + text + "" # def colorize - end @@ -1374,9 +1340,9 @@ # tags included. # # !self : instance of self - # !event : + # !event : + @debugging def on_text_format(self, event): - self.log.log("Enter chat_panel->on_text_format(self, event)", ORPG_DEBUG) id = event.GetId() txt = self.chattxt.GetValue() (beg,end) = self.chattxt.GetSelection() @@ -1390,11 +1356,10 @@ self.chattxt.SetValue(txt) self.chattxt.SetInsertionPointEnd() self.chattxt.SetFocus() - self.log.log("Exit chat_panel->on_text_format(self, event)", ORPG_DEBUG) # def on_text_format - end - + + @debugging def lock_scroll(self, event): - self.log.log("Enter chat_panel->lock_scroll(self, event)", ORPG_DEBUG) if self.lockscroll: self.lockscroll = False self.scroll_lock.SetLabel("Scroll ON") @@ -1405,78 +1370,73 @@ else: self.lockscroll = True self.scroll_lock.SetLabel("Scroll OFF") - self.log.log("Exit chat_panel->lock_scroll(self, event)", ORPG_DEBUG) # This subroutine will popup a text window with the chatbuffer contents # # !self : instance of self - # !event : + # !event : + @debugging def pop_textpop(self, event): """searchable popup text view of chatbuffer""" - self.log.log("Enter chat_panel->pop_textpop(self, event)", ORPG_DEBUG) h_buffertext = self.ResetPage() h_dlg = orpgScrolledMessageFrameEditor(self, h_buffertext, "Text View of Chat Window", None, (500,300)) h_dlg.Show(True) - self.log.log("Exit chat_panel->pop_textpop(self, event)", ORPG_DEBUG) # This subroutine will change the dimension of the window # # !self : instance of self - # !event : + # !event : + @debugging def OnSize(self, event=None): - self.log.log("Enter chat_panel->OnSize(self, event=None)", ORPG_DEBUG) event.Skip() wx.CallAfter(self.scroll_down) - self.log.log("Exit chat_panel->OnSize(self, event=None)", ORPG_DEBUG) # def OnSize - end - + + @debugging def scroll_down(self): self.Freeze() self.chatwnd.scroll_down() self.Thaw() - ###### message helpers ###### + ###### message helpers ###### + @debugging def PurgeChat(self): self.set_colors() self.chatwnd.SetPage(self.chatwnd.Header()) - + + @debugging def system_message(self, text): - self.log.log("Enter chat_panel->system_message(self, text)", ORPG_DEBUG) self.send_chat_message(text,chat_msg.SYSTEM_MESSAGE) self.SystemPost(text) - self.log.log("Exit chat_panel->system_message(self, text)", ORPG_DEBUG) - + + @debugging def info_message(self, text): - self.log.log("Enter chat_panel->info_message(self, text)", ORPG_DEBUG) self.send_chat_message(text,chat_msg.INFO_MESSAGE) self.InfoPost(text) - self.log.log("Exit chat_panel->info_message(self, text)", ORPG_DEBUG) - + + @debugging def get_gms(self): - self.log.log("Enter chat_panel->get_gms(self)", ORPG_DEBUG) the_gms = [] for playerid in self.session.players: if len(self.session.players[playerid])>7: if self.session.players[playerid][7]=="GM" and self.session.group_id != '0': the_gms += [playerid] - self.log.log("Exit chat_panel->get_gms(self)", ORPG_DEBUG) return the_gms - + + @debugging def GetName(self): - self.log.log("Enter chat_panel->GetName(self)", ORPG_DEBUG) - self.AliasLib = open_rpg.get_component('alias') + self.AliasLib = component.get('alias') player = self.session.get_my_info() if self.AliasLib != None: self.AliasLib.alias = self.aliasList.GetStringSelection(); if self.AliasLib.alias[0] != self.defaultAliasName: - self.log.log("Exit chat_panel->GetName(self)", ORPG_DEBUG) + logger.debug("Exit chat_panel->GetName(self)") return [self.chat_display_name([self.AliasLib.alias[0], player[1], player[2]]), self.AliasLib.alias[1]] - self.log.log("Exit chat_panel->GetName(self)", ORPG_DEBUG) return [self.chat_display_name(player), "Default"] - + + @debugging def GetFilteredText(self, text): - self.log.log("Enter chat_panel->GetFilteredText(self, text)", ORPG_DEBUG) advregex = re.compile('\"(.*?)\"', re.I) - self.AliasLib = open_rpg.get_component('alias') + self.AliasLib = component.get('alias') if self.AliasLib != None: self.AliasLib.filter = self.filterList.GetSelection()-1; for rule in self.AliasLib.filterRegEx: @@ -1486,11 +1446,10 @@ match = m.group(0) newmatch = re.sub(rule[0], rule[1], match) text = text.replace(match, newmatch) - self.log.log("Exit chat_panel->GetFilteredText(self, text)", ORPG_DEBUG) return text - + + @debugging def emote_message(self, text): - self.log.log("Enter chat_panel->emote_message(self, text)", ORPG_DEBUG) text = self.NormalizeParse(text) text = self.colorize(self.emotecolor, text) @@ -1507,10 +1466,9 @@ name = self.GetName()[0] text = "** " + name + " " + text + " **" self.EmotePost(text) - self.log.log("Exit chat_panel->emote_message(self, text)", ORPG_DEBUG) - + + @debugging def whisper_to_players(self, text, player_ids): - self.log.log("Enter chat_panel->whisper_to_players(self, text, player_ids)", ORPG_DEBUG) tabbed_whispers_p = self.settings.get_setting("tabbedwhispers") # Heroman - apply any filtering selected text = self.NormalizeParse(text) @@ -1535,10 +1493,9 @@ id = id.strip() if self.session.is_valid_id(id): self.send_chat_message(text,chat_msg.WHISPER_MESSAGE,id) else: self.InfoPost(id + " Unknown!") - self.log.log("Exit chat_panel->whisper_to_players(self, text, player_ids)", ORPG_DEBUG) - + + @debugging def send_chat_message(self, text, type=chat_msg.CHAT_MESSAGE, player_id="all"): - self.log.log("Enter chat_panel->send_chat_message(self, text, type, player_id)", ORPG_DEBUG) #########send_msg()############# send = 1 for plugin_fname in self.activeplugins.keys(): @@ -1546,8 +1503,8 @@ try: text, send = plugin.send_msg(text, send) except Exception, e: if str(e) != "'module' object has no attribute 'send_msg'": - self.log.log(traceback.format_exc(), ORPG_GENERAL) - self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) + logger.general(traceback.format_exc()) + logger.general("EXCEPTION: " + str(e)) msg = chat_msg.chat_msg() msg.set_text(text) msg.set_type(type) @@ -1561,11 +1518,10 @@ msg.set_alias(playername) if send: self.session.send(msg.toxml(),player_id) del msg - self.log.log("Exit chat_panel->send_chat_message(self, text, type, player_id)", ORPG_DEBUG) - #### incoming chat message handler ##### + #### incoming chat message handler ##### + @debugging def post_incoming_msg(self, msg, player): - self.log.log("Enter chat_panel->post_incoming_msg(self, msg, player)", ORPG_DEBUG) # pull data type = msg.get_type() @@ -1582,8 +1538,8 @@ try: text, type, name = plugin.plugin_incoming_msg(text, type, display_name, player) except Exception, e: if str(e) != "'module' object has no attribute 'receive_msg'": - self.log.log(traceback.format_exc(), ORPG_GENERAL) - self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) + logger.general(traceback.format_exc()) + logger.general("EXCEPTION: " + str(e)) #end mDuo13 added code #image stripping for players' names strip_img = self.settings.get_setting("Show_Images_In_Chat") @@ -1668,8 +1624,8 @@ else: self.parent.MainChatPanel.EmotePost("**" + msg + "**") self.parent.newMsg(0) except Exception, e: - self.log.log(traceback.format_exc(), ORPG_GENERAL) - self.log.log("EXCEPTION: 'Error in posting whisper message': " + str(e), ORPG_GENERAL) + logger.general(traceback.format_exc()) + logger.general("EXCEPTION: 'Error in posting whisper message': " + str(e)) elif (type == chat_msg.EMOTE_MESSAGE): text = "** " + display_name + " " + text + " **" self.EmotePost(text) @@ -1686,27 +1642,23 @@ sound_file = self.settings.get_setting(recvSound) if sound_file != '': self.sound_player.play(sound_file) - self.log.log("Exit chat_panel->post_incoming_msg(self, msg, player)", ORPG_DEBUG) #### Posting helpers ##### - + + @debugging def InfoPost(self, s): - self.log.log("Enter chat_panel->InfoPost(self, s)", ORPG_DEBUG) self.Post(self.colorize(self.infocolor, s), c='info') - self.log.log("Exit chat_panel->InfoPost(self, s)", ORPG_DEBUG) - + + @debugging def SystemPost(self, s): - self.log.log("Enter chat_panel->SystemPost(self, s)", ORPG_DEBUG) self.Post(self.colorize(self.syscolor, s), c='system') - self.log.log("Exit chat_panel->SystemPost(self, s)", ORPG_DEBUG) - + + @debugging def EmotePost(self, s): - self.log.log("Enter chat_panel->EmotePost(self, s)", ORPG_DEBUG) self.Post(self.colorize(self.emotecolor, s), c='emote') - self.log.log("Exit chat_panel->EmotePost(self, s)", ORPG_DEBUG) - #### Standard Post method ##### + #### Standard Post method ##### + @debugging def Post(self, s="", send=False, myself=False, c='post'): - self.log.log("Enter chat_panel->Post(self, s, send, myself)", ORPG_DEBUG) strip_p = self.settings.get_setting("striphtml") strip_img = self.settings.get_setting("Show_Images_In_Chat")#moved back 7-11-05. --mDuo13 if (strip_p == "1"): s = strip_html(s) @@ -1731,8 +1683,8 @@ try: s = plugin.post_msg(s, myself) except Exception, e: if str(e) != "'module' object has no attribute 'post_msg'": - self.log.log(traceback.format_exc(), ORPG_GENERAL) - self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) + logger.general(traceback.format_exc()) + logger.general("EXCEPTION: " + str(e)) #end mDuo13 added code if myself: name = "" + display_name + ": " @@ -1762,8 +1714,8 @@ s2 = plugin.post_msg(s2, myself) except Exception, e: if str(e) != "'module' object has no attribute 'post_msg'": - self.log.log(traceback.format_exc(), ORPG_GENERAL) - self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) + logger.general(traceback.format_exc()) + logger.general("EXCEPTION: " + str(e)) if s2 != "": #Italici the messages from tabbed whispers if self.type == WHISPER_TAB or self.type == GROUP_TAB or self.sendtarget == 'gm': @@ -1796,61 +1748,56 @@ elif self.type == NULL_TAB: pass else: self.InfoPost("Failed to send message, unknown send type for this tab") self.parsed=0 - self.log.log("Exit chat_panel->Post(self, s, send, myself)", ORPG_DEBUG) # # TimeIndexString() # # time indexing for chat display only (don't log time indexing) - # added by Snowdog 4/04 + # added by Snowdog 4/04 + @debugging def TimeIndexString(self): - self.log.log("Enter chat_panel->TimeIndexString(self)", ORPG_DEBUG) try: mtime = "" if self.settings.get_setting('Chat_Time_Indexing') == "0": pass elif self.settings.get_setting('Chat_Time_Indexing') == "1": mtime = time.strftime("[%I:%M:%S] ", time.localtime()) - self.log.log("Exit chat_panel->TimeIndexString(self)", ORPG_DEBUG) return mtime except Exception, e: - self.log.log(traceback.format_exc(), ORPG_GENERAL) - self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) + logger.general(traceback.format_exc()) + logger.general("EXCEPTION: " + str(e)) return "[ERROR]" - #### Post with parsing dice #### + #### Post with parsing dice #### + @debugging def ParsePost(self, s, send=False, myself=False): - self.log.log("Enter chat_panel->ParsePost(self, s, send, myself)", ORPG_DEBUG) s = self.NormalizeParse(s) self.set_colors() self.Post(s,send,myself) - self.log.log("Exit chat_panel->ParsePost(self, s, send, myself)", ORPG_DEBUG) - - def NormalizeParse(self, s): - self.log.log("Enter chat_panel->NormalizeParse(self, s)", ORPG_DEBUG) + + @debugging + def NormalizeParse(self, s): for plugin_fname in self.activeplugins.keys(): plugin = self.activeplugins[plugin_fname] try: s = plugin.pre_parse(s) except Exception, e: if str(e) != "'module' object has no attribute 'post_msg'": - self.log.log(traceback.format_exc(), ORPG_GENERAL) - self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) + logger.general(traceback.format_exc()) + logger.general("EXCEPTION: " + str(e)) if self.parsed == 0: s = self.ParseNode(s) s = self.ParseDice(s) s = self.ParseFilter(s) self.parsed = 1 - self.log.log("Exit chat_panel->NormalizeParse(self, s)", ORPG_DEBUG) return s - - def ParseFilter(self, s): - self.log.log("Enter chat_panel->ParseFilter(self, s)", ORPG_DEBUG) + + @debugging + def ParseFilter(self, s): s = self.GetFilteredText(s) - self.log.log("Exit chat_panel->ParseFilter(self, s)", ORPG_DEBUG) return s - - def ParseNode(self, s): + + @debugging + def ParseNode(self, s): """Parses player input for embedded nodes rolls""" - self.log.log("Enter chat_panel->ParseNode(self, s)", ORPG_DEBUG) cur_loc = 0 #[a-zA-Z0-9 _\-\.] reg = re.compile("(!@([a-zA-Z0-9 _\-\./]+(::[a-zA-Z0-9 _\-\./]+)*)@!)") @@ -1858,12 +1805,11 @@ for i in xrange(0,len(matches)): newstr = self.ParseNode(self.resolve_nodes(matches[i][1])) s = s.replace(matches[i][0], newstr, 1) - self.log.log("Exit chat_panel->ParseNode(self, s)", ORPG_DEBUG) return s - - def ParseDice(self, s): + + @debugging + def ParseDice(self, s): """Parses player input for embedded dice rolls""" - self.log.log("Enter chat_panel->ParseDice(self, s)", ORPG_DEBUG) reg = re.compile("\[([^]]*?)\]") matches = reg.findall(s) for i in xrange(0,len(matches)): @@ -1878,12 +1824,11 @@ if qmode == 1: s = s.replace("[" + matches[i] + "]", "" + newstr, 1) else: s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "] => " + newstr, 1) - self.log.log("Exit chat_panel->ParseDice(self, s)", ORPG_DEBUG) return s - + + @debugging def PraseUnknowns(self, s): # Uses a tuple. Usage: ?Label}dY. If no Label is assigned then use ?}DY - self.log.log("Enter chat_panel->PraseUnknowns(self, s)", ORPG_DEBUG) newstr = "0" reg = re.compile("(\?\{*)([a-zA-Z ]*)(\}*)") matches = reg.findall(s) @@ -1899,24 +1844,22 @@ if newstr == '': newstr = '0' s = s.replace(matches[i][0], newstr, 1).replace(matches[i][1], '', 1).replace(matches[i][2], '', 1) dlg.Destroy() - self.log.log("Exit chat_panel->PraseUnknowns(self, s)", ORPG_DEBUG) return s # This subroutine builds a chat display name. - # - def chat_display_name(self, player): - self.log.log("Enter chat_panel->chat_display_name(self, player)", ORPG_DEBUG) + # + @debugging + def chat_display_name(self, player): if self.settings.get_setting("ShowIDInChat") == "0": display_name = player[0] else: display_name = "("+player[2]+") " + player[0] - self.log.log("Exit chat_panel->chat_display_name(self, player)", ORPG_DEBUG) return display_name # This subroutine will get a hex color and return it, or return nothing - # - def get_color(self): - self.log.log("Enter chat_panel->get_color(self)", ORPG_DEBUG) + # + @debugging + def get_color(self): data = wx.ColourData() data.SetChooseFull(True) dlg = wx.ColourDialog(self, data) @@ -1925,16 +1868,14 @@ (red,green,blue) = data.GetColour().Get() hexcolor = self.r_h.hexstring(red, green, blue) dlg.Destroy() - self.log.log("Exit chat_panel->get_color(self) return hexcolor", ORPG_DEBUG) return hexcolor else: dlg.Destroy() - self.log.log("Exit chat_panel->get_color(self) return None", ORPG_DEBUG) return None # def get_color - end - + + @debugging def replace_quotes(self, s): - self.log.log("Enter chat_panel->replace_quotes(self, s)", ORPG_DEBUG) in_tag = 0 i = 0 rs = s[:] @@ -1948,11 +1889,10 @@ if in_tag: rs = rs[:i] + "'" + rs[i+1:] i += 1 - self.log.log("Exit chat_panel->replace_quotes(self, s)", ORPG_DEBUG) - return rs + return rs - def resolve_loop(self, dom, nodeName, doLoop = False): - self.log.log("Enter chat_panel->resolve_loop(self, dom, nodeName)", ORPG_DEBUG) + @debugging + def resolve_loop(self, dom, nodeName, doLoop = False): for node in dom: if node._get_tagName() != 'nodehandler': continue @@ -1963,16 +1903,14 @@ if node.getAttribute('name') != nodeName: continue foundNode = node - self.log.log("Exit chat_panel->resolve_loop(self, dom, path) return (True, value)", ORPG_DEBUG) return (True, foundNode) - self.log.log("Exit chat_panel->resolve_loop(self, dom, path) return (False, '')", ORPG_DEBUG) - return (False, '') + return (False, '') - def resolve_nodes(self, s): - self.log.log("Enter chat_panel->resolve_nodes(self, s)", ORPG_DEBUG) + @debugging + def resolve_nodes(self, s): value = "" node_path_list = s.split("::") - gametree = open_rpg.get_component('tree') + gametree = component.get('tree') dom = gametree.master_dom.getChildren() for nodeName in node_path_list: (found, node) = self.resolve_loop(dom, nodeName) @@ -1996,5 +1934,4 @@ value = node._get_nodeValue() else: value = s - self.log.log("Exit chat_panel->resolve_nodes(self, s)", ORPG_DEBUG) return value diff -r 4840657c23c5 -r c54768cffbd4 orpg/dieroller/die.py diff -r 4840657c23c5 -r c54768cffbd4 orpg/dieroller/utils.py --- a/orpg/dieroller/utils.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/dieroller/utils.py Tue Aug 18 06:33:37 2009 -0500 @@ -41,7 +41,8 @@ from gurps import * from runequest import * from savage import * -from trinity import * +from trinity import * +from orpg.orpgCore import component import re @@ -49,17 +50,14 @@ class roller_manager: def __init__(self,roller_class="d20"): - try: - self.setRoller(roller_class) - except: - self.roller_class = "std" + try: self.setRoller(roller_class) + except: self.roller_class = "std" def setRoller(self,roller_class): try: rollers.index(roller_class) self.roller_class = roller_class - except: - raise Exception, "Invalid die roller!" + except: raise Exception, "Invalid die roller!" def getRoller(self): return self.roller_class @@ -71,15 +69,11 @@ s = match.group(0) (num,sides) = s.split('d') - if sides.strip().upper() == 'F': - sides = "'f'" - + if sides.strip().upper() == 'F': sides = "'f'" try: if int(num) > 100 or int(sides) > 10000: return None - except: - pass - + except: pass return "(" + num.strip() + "**" + self.roller_class + "(" + sides.strip() + "))" # Use this to convert ndm-style (3d6) dice to d_base format @@ -91,10 +85,9 @@ s2 = self.roller_class + "(0)." + s test = eval(s2) return s2 - except: - pass + except: pass return result - def proccessRoll(self,s): return str(eval(self.convertTheDieString(s))) +#component.add('dieroller', roller_manager()) diff -r 4840657c23c5 -r c54768cffbd4 orpg/external/__init__.py diff -r 4840657c23c5 -r c54768cffbd4 orpg/external/std.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/orpg/external/std.py Tue Aug 18 06:33:37 2009 -0500 @@ -0,0 +1,20 @@ + +import sys + +class Std(object): + """ + makes all standard python modules available as a lazily + computed attribute. + """ + + def __init__(self): + self.__dict__ = sys.modules + + def __getattr__(self, name): + try: + m = __import__(name) + except ImportError: + raise AttributeError("py.std: could not import %s" % name) + return m + +std = Std() diff -r 4840657c23c5 -r c54768cffbd4 orpg/external/terminalwriter.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/orpg/external/terminalwriter.py Tue Aug 18 06:33:37 2009 -0500 @@ -0,0 +1,284 @@ +""" + +Helper functions for writing to terminals and files. + +""" + + +import sys, os +from orpg.external.std import std + +def _getdimensions(): + import termios,fcntl,struct + call = fcntl.ioctl(0,termios.TIOCGWINSZ,"\000"*8) + height,width = struct.unpack( "hhhh", call ) [:2] + return height, width + +if sys.platform == 'win32': + # ctypes access to the Windows console + + STD_OUTPUT_HANDLE = -11 + STD_ERROR_HANDLE = -12 + FOREGROUND_BLUE = 0x0001 # text color contains blue. + FOREGROUND_GREEN = 0x0002 # text color contains green. + FOREGROUND_RED = 0x0004 # text color contains red. + FOREGROUND_WHITE = 0x0007 + FOREGROUND_INTENSITY = 0x0008 # text color is intensified. + BACKGROUND_BLUE = 0x0010 # background color contains blue. + BACKGROUND_GREEN = 0x0020 # background color contains green. + BACKGROUND_RED = 0x0040 # background color contains red. + BACKGROUND_WHITE = 0x0070 + BACKGROUND_INTENSITY = 0x0080 # background color is intensified. + + def GetStdHandle(kind): + import ctypes + return ctypes.windll.kernel32.GetStdHandle(kind) + + def SetConsoleTextAttribute(handle, attr): + import ctypes + ctypes.windll.kernel32.SetConsoleTextAttribute( + handle, attr) + + def _getdimensions(): + import ctypes + from ctypes import wintypes + + SHORT = ctypes.c_short + class COORD(ctypes.Structure): + _fields_ = [('X', SHORT), + ('Y', SHORT)] + class SMALL_RECT(ctypes.Structure): + _fields_ = [('Left', SHORT), + ('Top', SHORT), + ('Right', SHORT), + ('Bottom', SHORT)] + class CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): + _fields_ = [('dwSize', COORD), + ('dwCursorPosition', COORD), + ('wAttributes', wintypes.WORD), + ('srWindow', SMALL_RECT), + ('dwMaximumWindowSize', COORD)] + STD_OUTPUT_HANDLE = -11 + handle = GetStdHandle(STD_OUTPUT_HANDLE) + info = CONSOLE_SCREEN_BUFFER_INFO() + ctypes.windll.kernel32.GetConsoleScreenBufferInfo( + handle, ctypes.byref(info)) + # Substract one from the width, otherwise the cursor wraps + # and the ending \n causes an empty line to display. + return info.dwSize.Y, info.dwSize.X - 1 + +def get_terminal_width(): + try: + height, width = _getdimensions() + except (SystemExit, KeyboardInterrupt), e: + raise + except: + # FALLBACK + width = int(os.environ.get('COLUMNS', 80))-1 + # XXX the windows getdimensions may be bogus, let's sanify a bit + width = max(width, 40) # we alaways need 40 chars + return width + +terminal_width = get_terminal_width() + +# XXX unify with _escaped func below +def ansi_print(text, esc, file=None, newline=True, flush=False): + if file is None: + file = sys.stderr + text = text.rstrip() + if esc and not isinstance(esc, tuple): + esc = (esc,) + if esc and sys.platform != "win32" and file.isatty(): + text = (''.join(['\x1b[%sm' % cod for cod in esc]) + + text + + '\x1b[0m') # ANSI color code "reset" + if newline: + text += '\n' + + if esc and sys.platform == "win32" and file.isatty(): + if 1 in esc: + bold = True + esc = tuple([x for x in esc if x != 1]) + else: + bold = False + esctable = {() : FOREGROUND_WHITE, # normal + (31,): FOREGROUND_RED, # red + (32,): FOREGROUND_GREEN, # green + (33,): FOREGROUND_GREEN|FOREGROUND_RED, # yellow + (34,): FOREGROUND_BLUE, # blue + (35,): FOREGROUND_BLUE|FOREGROUND_RED, # purple + (36,): FOREGROUND_BLUE|FOREGROUND_GREEN, # cyan + (37,): FOREGROUND_WHITE, # white + (39,): FOREGROUND_WHITE, # reset + } + attr = esctable.get(esc, FOREGROUND_WHITE) + if bold: + attr |= FOREGROUND_INTENSITY + STD_OUTPUT_HANDLE = -11 + STD_ERROR_HANDLE = -12 + if file is sys.stderr: + handle = GetStdHandle(STD_ERROR_HANDLE) + else: + handle = GetStdHandle(STD_OUTPUT_HANDLE) + SetConsoleTextAttribute(handle, attr) + file.write(text) + SetConsoleTextAttribute(handle, FOREGROUND_WHITE) + else: + file.write(text) + + if flush: + file.flush() + +def should_do_markup(file): + return hasattr(file, 'isatty') and file.isatty() \ + and os.environ.get('TERM') != 'dumb' + +class TerminalWriter(object): + _esctable = dict(black=30, red=31, green=32, yellow=33, + blue=34, purple=35, cyan=36, white=37, + Black=40, Red=41, Green=42, Yellow=43, + Blue=44, Purple=45, Cyan=46, White=47, + bold=1, light=2, blink=5, invert=7) + + def __init__(self, file=None, stringio=False): + if file is None: + if stringio: + self.stringio = file = std.cStringIO.StringIO() + else: + file = std.sys.stdout + elif callable(file): + file = WriteFile(file) + self._file = file + self.fullwidth = get_terminal_width() + self.hasmarkup = should_do_markup(file) + + def _escaped(self, text, esc): + if esc and self.hasmarkup: + text = (''.join(['\x1b[%sm' % cod for cod in esc]) + + text +'\x1b[0m') + return text + + def markup(self, text, **kw): + esc = [] + for name in kw: + if name not in self._esctable: + raise ValueError("unknown markup: %r" %(name,)) + if kw[name]: + esc.append(self._esctable[name]) + return self._escaped(text, tuple(esc)) + + def sep(self, sepchar, title=None, fullwidth=None, **kw): + if fullwidth is None: + fullwidth = self.fullwidth + # the goal is to have the line be as long as possible + # under the condition that len(line) <= fullwidth + if title is not None: + # we want 2 + 2*len(fill) + len(title) <= fullwidth + # i.e. 2 + 2*len(sepchar)*N + len(title) <= fullwidth + # 2*len(sepchar)*N <= fullwidth - len(title) - 2 + # N <= (fullwidth - len(title) - 2) // (2*len(sepchar)) + N = (fullwidth - len(title) - 2) // (2*len(sepchar)) + fill = sepchar * N + line = "%s %s %s" % (fill, title, fill) + else: + # we want len(sepchar)*N <= fullwidth + # i.e. N <= fullwidth // len(sepchar) + line = sepchar * (fullwidth // len(sepchar)) + # in some situations there is room for an extra sepchar at the right, + # in particular if we consider that with a sepchar like "_ " the + # trailing space is not important at the end of the line + if len(line) + len(sepchar.rstrip()) <= fullwidth: + line += sepchar.rstrip() + + self.line(line, **kw) + + def write(self, s, **kw): + if s: + s = str(s) + if self.hasmarkup and kw: + s = self.markup(s, **kw) + self._file.write(s) + self._file.flush() + + def line(self, s='', **kw): + self.write(s, **kw) + self.write('\n') + +class Win32ConsoleWriter(object): + + def __init__(self, file=None, stringio=False): + if file is None: + if stringio: + self.stringio = file = std.cStringIO.StringIO() + else: + file = std.sys.stdout + elif callable(file): + file = WriteFile(file) + self._file = file + self.fullwidth = get_terminal_width() + self.hasmarkup = should_do_markup(file) + + def sep(self, sepchar, title=None, fullwidth=None, **kw): + if fullwidth is None: + fullwidth = self.fullwidth + # the goal is to have the line be as long as possible + # under the condition that len(line) <= fullwidth + if title is not None: + # we want 2 + 2*len(fill) + len(title) <= fullwidth + # i.e. 2 + 2*len(sepchar)*N + len(title) <= fullwidth + # 2*len(sepchar)*N <= fullwidth - len(title) - 2 + # N <= (fullwidth - len(title) - 2) // (2*len(sepchar)) + N = (fullwidth - len(title) - 2) // (2*len(sepchar)) + fill = sepchar * N + line = "%s %s %s" % (fill, title, fill) + else: + # we want len(sepchar)*N <= fullwidth + # i.e. N <= fullwidth // len(sepchar) + line = sepchar * (fullwidth // len(sepchar)) + # in some situations there is room for an extra sepchar at the right, + # in particular if we consider that with a sepchar like "_ " the + # trailing space is not important at the end of the line + if len(line) + len(sepchar.rstrip()) <= fullwidth: + line += sepchar.rstrip() + + self.line(line, **kw) + + def write(self, s, **kw): + if s: + s = str(s) + if self.hasmarkup: + handle = GetStdHandle(STD_OUTPUT_HANDLE) + + if self.hasmarkup and kw: + attr = 0 + if kw.pop('bold', False): + attr |= FOREGROUND_INTENSITY + + if kw.pop('red', False): + attr |= FOREGROUND_RED + elif kw.pop('blue', False): + attr |= FOREGROUND_BLUE + elif kw.pop('green', False): + attr |= FOREGROUND_GREEN + else: + attr |= FOREGROUND_WHITE + + SetConsoleTextAttribute(handle, attr) + self._file.write(s) + self._file.flush() + if self.hasmarkup: + SetConsoleTextAttribute(handle, FOREGROUND_WHITE) + + def line(self, s='', **kw): + self.write(s + '\n', **kw) + +if sys.platform == 'win32': + TerminalWriter = Win32ConsoleWriter + +class WriteFile(object): + def __init__(self, writemethod): + self.write = writemethod + def flush(self): + return + + diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/gametree.py --- a/orpg/gametree/gametree.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/gametree.py Tue Aug 18 06:33:37 2009 -0500 @@ -30,8 +30,8 @@ from orpg.orpg_wx import * from orpg.orpg_windows import * -from orpg.orpgCore import open_rpg -import orpg.dirpath +from orpg.orpgCore import component +from orpg.dirpath import dir_struct from nodehandlers import core import orpg.gametree.nodehandlers.containers import orpg.gametree.nodehandlers.forms @@ -80,15 +80,16 @@ class game_tree(wx.TreeCtrl): def __init__(self, parent, id): - wx.TreeCtrl.__init__(self,parent,id, wx.DefaultPosition, wx.DefaultSize,style=wx.TR_EDIT_LABELS | wx.TR_HAS_BUTTONS) - self.log = open_rpg.get_component('log') - self.log.log("Enter game_tree", ORPG_DEBUG) - self.validate = open_rpg.get_component('validate') - self.xml = open_rpg.get_component('xml') - self.settings = open_rpg.get_component('settings') - self.session = open_rpg.get_component('session') - self.chat = open_rpg.get_component('chat') - self.mainframe = open_rpg.get_component('frame') + wx.TreeCtrl.__init__(self,parent,id, wx.DefaultPosition, + wx.DefaultSize,style=wx.TR_EDIT_LABELS | wx.TR_HAS_BUTTONS) + self.orpgLog = component.get('log') + self.orpgLog.log("Enter game_tree", ORPG_DEBUG) + self.validate = component.get('validate') + self.xml = component.get('xml') + self.settings = component.get('settings') + self.session = component.get('session') + self.chat = component.get('chat') + self.mainframe = component.get('frame') self.build_img_list() self.build_std_menu() self.nodehandlers = {} @@ -105,37 +106,37 @@ self.Bind(wx.EVT_KEY_UP, self.on_key_up) self.id = 1 self.dragging = False - self.root_dir = orpg.dirpath.dir_struct["home"] - self.last_save_dir = orpg.dirpath.dir_struct["user"] + self.root_dir = dir_struct["home"] + self.last_save_dir = dir_struct["user"] #Create tree from default if it does not exist self.validate.config_file("tree.xml","default_tree.xml") - open_rpg.add_component("tree", self) + component.add("tree", self) #build tree self.root = self.AddRoot("Game Tree",self.icons['gear']) self.was_labeling = 0 self.rename_flag = 0 self.image_cache = {} - self.log.log("Exit game_tree", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree", ORPG_DEBUG) def add_nodehandler(self, nodehandler, nodeclass): - self.log.log("Enter game_tree->add_nodehandler(self, nodehandler, nodeclass)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->add_nodehandler(self, nodehandler, nodeclass)", ORPG_DEBUG) if not self.nodehandlers.has_key(nodehandler): self.nodehandlers[nodehandler] = nodeclass else: - self.log.log("Nodehandler for " + nodehandler + " already exists!", ORPG_DEBUG, True) - self.log.log("Exit game_tree->add_nodehandler(self, nodehandler, nodeclass)", ORPG_DEBUG) + self.orpgLog.log("Nodehandler for " + nodehandler + " already exists!", ORPG_DEBUG, True) + self.orpgLog.log("Exit game_tree->add_nodehandler(self, nodehandler, nodeclass)", ORPG_DEBUG) def remove_nodehandler(self, nodehandler): - self.log.log("Enter game_tree->remove_nodehandler(self, nodehandler)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->remove_nodehandler(self, nodehandler)", ORPG_DEBUG) if self.nodehandlers.has_key(nodehandler): del self.nodehandlers[nodehandler] else: - self.log.log("No nodehandler for " + nodehandler + " exists!", ORPG_DEBUG, True) - self.log.log("Exit game_tree->remove_nodehandler(self, nodehandler)", ORPG_DEBUG) + self.orpgLog.log("No nodehandler for " + nodehandler + " exists!", ORPG_DEBUG, True) + self.orpgLog.log("Exit game_tree->remove_nodehandler(self, nodehandler)", ORPG_DEBUG) def init_nodehandlers(self): - self.log.log("Enter game_tree->init_nodehandlers(self)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->init_nodehandlers(self)", ORPG_DEBUG) self.add_nodehandler('group_handler', orpg.gametree.nodehandlers.containers.group_handler) self.add_nodehandler('tabber_handler', orpg.gametree.nodehandlers.containers.tabber_handler) self.add_nodehandler('splitter_handler', orpg.gametree.nodehandlers.containers.splitter_handler) @@ -158,12 +159,12 @@ self.add_nodehandler('node_loader', core.node_loader) self.add_nodehandler('url_loader', core.url_loader) self.add_nodehandler('min_map', core.min_map) - self.log.log("Exit game_tree->init_nodehandlers(self)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->init_nodehandlers(self)", ORPG_DEBUG) # event = wxKeyEvent # set to be called by wxWindows by EVT_CHAR macro in __init__ def on_key_up(self, evt): - self.log.log("Enter game_tree->on_key_up(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_key_up(self, evt)", ORPG_DEBUG) key_code = evt.GetKeyCode() if self.dragging and (key_code == wx.WXK_SHIFT): curSelection = self.GetSelection() @@ -176,10 +177,10 @@ obj.on_drop(evt) self.drag_obj = None evt.Skip() - self.log.log("Exit game_tree->on_key_up(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_key_up(self, evt)", ORPG_DEBUG) def on_char(self, evt): - self.log.log("Enter game_tree->on_char(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_char(self, evt)", ORPG_DEBUG) key_code = evt.GetKeyCode() curSelection = self.GetSelection() # Get the current selection if evt.ShiftDown() and ((key_code == wx.WXK_UP) or (key_code == wx.WXK_DOWN)) and not self.dragging: @@ -207,13 +208,13 @@ self.rename_flag = 1 self.EditLabel(curSelection) evt.Skip() - self.log.log("Exit game_tree->on_char(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_char(self, evt)", ORPG_DEBUG) ## locate_valid_tree ## GUI based dialogs to locate/fix missing treefile issues --Snowdog 3/05 def locate_valid_tree(self, error, msg, dir, filename): """prompts the user to locate a new tree file or create a new one""" - self.log.log("Enter game_tree->locate_valid_tree(self, error, msg, dir, filename)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->locate_valid_tree(self, error, msg, dir, filename)", ORPG_DEBUG) response = wx.MessageDialog(self, msg, error, wx.YES|wx.NO|wx.ICON_ERROR) if response == wx.YES: file = None @@ -223,22 +224,22 @@ dlg.Destroy() if not file: self.load_tree(error=1) else: self.load_tree(file) - self.log.log("Exit game_tree->locate_valid_tree(self, error, msg, dir, filename)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->locate_valid_tree(self, error, msg, dir, filename)", ORPG_DEBUG) return else: self.validate.config_file("tree.xml","default_tree.xml") self.load_tree(error=1) - self.log.log("Exit game_tree->locate_valid_tree(self, error, msg, dir, filename)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->locate_valid_tree(self, error, msg, dir, filename)", ORPG_DEBUG) return - def load_tree(self, filename=orpg.dirpath.dir_struct["user"]+'tree.xml', error=0): - self.log.log("Enter game_tree->load_tree(self, filename, error)", ORPG_DEBUG) + def load_tree(self, filename=dir_struct["user"]+'tree.xml', error=0): + self.orpgLog.log("Enter game_tree->load_tree(self, filename, error)", ORPG_DEBUG) self.settings.set_setting("gametree", filename) tmp = None xml_dom = None xml_doc = None try: - self.log.log("Reading Gametree file: " + filename + "...", ORPG_INFO, True) + self.orpgLog.log("Reading Gametree file: " + filename + "...", ORPG_INFO, True) tmp = open(filename,"r") xml_doc = self.xml.parseXml(tmp.read()) tmp.close() @@ -246,16 +247,16 @@ pass else: xml_dom = xml_doc._get_documentElement() - self.log.log("done.", ORPG_INFO, True) + self.orpgLog.log("done.", ORPG_INFO, True) except IOError: emsg = "Gametree Missing!\n"+filename+" cannot be found.\n\n"\ "Would you like to locate it?\n"\ "(Selecting 'No' will cause a new default gametree to be generated)" fn = filename[ ((filename.rfind(os.sep))+len(os.sep)):] - self.locate_valid_tree("Gametree Error", emsg, orpg.dirpath.dir_struct["user"], fn) - self.log.log(emsg, ORPG_GENERAL) - self.log.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG) + self.locate_valid_tree("Gametree Error", emsg, dir_struct["user"], fn) + self.orpgLog.log(emsg, ORPG_GENERAL) + self.orpgLog.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG) return if not xml_dom: @@ -269,9 +270,9 @@ "lastgood.xml WILL BE OVERWRITTEN NEXT TIME YOU RUN OPENRPG.\n\n"\ "Would you like to select a different gametree file to use?\n"\ "(Selecting 'No' will cause a new default gametree to be generated)" - self.locate_valid_tree("Corrupt Gametree!", emsg, orpg.dirpath.dir_struct["user"], fn) - self.log.log(emsg, ORPG_GENERAL) - self.log.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG) + self.locate_valid_tree("Corrupt Gametree!", emsg, dir_struct["user"], fn) + self.orpgLog.log(emsg, ORPG_GENERAL) + self.orpgLog.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG) return if xml_dom._get_tagName() != "gametree": @@ -279,53 +280,53 @@ emsg = fn+" does not appear to be a valid gametree file.\n\n"\ "Would you like to select a different gametree file to use?\n"\ "(Selecting 'No' will cause a new default gametree to be generated)" - self.locate_valid_tree("Invalid Gametree!", emsg, orpg.dirpath.dir_struct["user"], fn) - self.log.log(emsg, ORPG_DEBUG) - self.log.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG) + self.locate_valid_tree("Invalid Gametree!", emsg, dir_struct["user"], fn) + self.orpgLog.log(emsg, ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG) return # get gametree version - we could write conversion code here! self.master_dom = xml_dom - self.log.log("Master Dom Set", ORPG_DEBUG) + self.orpgLog.log("Master Dom Set", ORPG_DEBUG) try: version = self.master_dom.getAttribute("version") # see if we should load the gametree loadfeatures = int(self.settings.get_setting("LoadGameTreeFeatures")) if loadfeatures: - xml_dom = self.xml.parseXml(open(orpg.dirpath.dir_struct["template"]+"feature.xml","r").read()) + xml_dom = self.xml.parseXml(open(dir_struct["template"]+"feature.xml","r").read()) xml_dom = xml_dom._get_documentElement() xml_dom = self.master_dom.appendChild(xml_dom) self.settings.set_setting("LoadGameTreeFeatures","0") ## load tree - self.log.log("Features loaded (if required)", ORPG_DEBUG) + self.orpgLog.log("Features loaded (if required)", ORPG_DEBUG) self.CollapseAndReset(self.root) children = self.master_dom._get_childNodes() - self.log.log("Parsing Gametree Nodes ", ORPG_INFO, True) + self.orpgLog.log("Parsing Gametree Nodes ", ORPG_INFO, True) for c in children: print '.', self.load_xml(c,self.root) - self.log.log("done", ORPG_INFO, True) + self.orpgLog.log("done", ORPG_INFO, True) self.Expand(self.root) self.SetPyData(self.root,self.master_dom) if error != 1: infile = open(filename, "rb") - outfile = open(orpg.dirpath.dir_struct["user"]+"lastgood.xml", "wb") + outfile = open(dir_struct["user"]+"lastgood.xml", "wb") outfile.write(infile.read()) else: - self.log.log("Not overwriting lastgood.xml file.", ORPG_INFO, True) + self.orpgLog.log("Not overwriting lastgood.xml file.", ORPG_INFO, True) except Exception, e: - self.log.log(traceback.format_exc(), ORPG_GENERAL) + self.orpgLog.log(traceback.format_exc(), ORPG_GENERAL) wx.MessageBox("Corrupt Tree!\nYour game tree is being regenerated. To\nsalvage a recent version of your gametree\nexit OpenRPG and copy the lastgood.xml\nfile in your myfiles directory\nto "+filename+ "\nin your myfiles directory.\nlastgood.xml WILL BE OVERWRITTEN NEXT TIME YOU RUN OPENRPG.") os.rename(filename,filename+".corrupt") self.validate.config_file("tree.xml","default_tree.xml") self.load_tree(error=1) - self.log.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG) def build_std_menu(self, obj=None): - self.log.log("Enter game_tree->build_std_menu(self, obj)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->build_std_menu(self, obj)", ORPG_DEBUG) # build useful menu useful_menu = wx.Menu() @@ -385,20 +386,20 @@ self.Bind(wx.EVT_MENU, self.on_load_new_tree, id=TOP_NEW_TREE) self.Bind(wx.EVT_MENU, self.on_tree_prop, id=TOP_TREE_PROP) self.Bind(wx.EVT_MENU, self.on_insert_features, id=TOP_FEATURES) - self.log.log("Exit game_tree->build_std_menu(self, obj)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->build_std_menu(self, obj)", ORPG_DEBUG) def do_std_menu(self, evt, obj): - self.log.log("Enter game_tree->do_std_menu(self, evt, obj)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->do_std_menu(self, evt, obj)", ORPG_DEBUG) try: self.std_menu.Enable(STD_MENU_MAP, obj.checkToMapMenu()) except: self.std_menu.Enable(STD_MENU_MAP, obj.map_aware()) self.std_menu.Enable(STD_MENU_CLONE, obj.can_clone()) self.PopupMenu(self.std_menu) - self.log.log("Exit game_tree->do_std_menu(self, evt, obj)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->do_std_menu(self, evt, obj)", ORPG_DEBUG) def strip_html(self, player): - self.log.log("Enter game_tree->strip_html(self, player)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->strip_html(self, player)", ORPG_DEBUG) ret_string = "" x = 0 in_tag = 0 @@ -412,27 +413,27 @@ pass else : ret_string = ret_string + player[0][x] - self.log.log(ret_string, ORPG_DEBUG) - self.log.log("Exit game_tree->strip_html(self, player)", ORPG_DEBUG) + self.orpgLog.log(ret_string, ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->strip_html(self, player)", ORPG_DEBUG) return ret_string def on_receive_data(self, data, player): - self.log.log("Enter game_tree->on_receive_data(self, data, player)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_receive_data(self, data, player)", ORPG_DEBUG) beg = string.find(data,"") end = string.rfind(data,"") data = data[6:end] self.insert_xml(data) - self.log.log("Exit game_tree->on_receive_data(self, data, player)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_receive_data(self, data, player)", ORPG_DEBUG) def on_send_to_chat(self, evt): - self.log.log("Enter game_tree->on_send_to_chat(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_send_to_chat(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) obj.on_send_to_chat(evt) - self.log.log("Exit game_tree->on_send_to_chat(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_send_to_chat(self, evt)", ORPG_DEBUG) def on_whisper_to(self, evt): - self.log.log("Enter game_tree->on_whisper_to(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_whisper_to(self, evt)", ORPG_DEBUG) players = self.session.get_players() opts = [] myid = self.session.get_id() @@ -457,10 +458,10 @@ for s in selections: player_ids.append(players[s][2]) self.chat.whisper_to_players(obj.tohtml(),player_ids) - self.log.log("Exit game_tree->on_whisper_to(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_whisper_to(self, evt)", ORPG_DEBUG) def on_export_html(self, evt): - self.log.log("Enter game_tree->on_export_html(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_export_html(self, evt)", ORPG_DEBUG) f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","HTML (*.html)|*.html",wx.SAVE) if f.ShowModal() == wx.ID_OK: item = self.GetSelection() @@ -476,34 +477,34 @@ self.last_save_dir, throwaway = os.path.split( f.GetPath() ) f.Destroy() os.chdir(self.root_dir) - self.log.log("Exit game_tree->on_export_html(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_export_html(self, evt)", ORPG_DEBUG) def indifferent(self, evt): - self.log.log("Enter game_tree->indifferent(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->indifferent(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) obj.usefulness("indifferent") - self.log.log("Exit game_tree->indifferent(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->indifferent(self, evt)", ORPG_DEBUG) def useful(self, evt): - self.log.log("Enter game_tree->useful(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->useful(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) obj.usefulness("useful") - self.log.log("Exit game_tree->useful(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->useful(self, evt)", ORPG_DEBUG) def useless(self, evt): - self.log.log("Enter game_tree->useless(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->useless(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) obj.usefulness("useless") - self.log.log("Exit game_tree->useless(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->useless(self, evt)", ORPG_DEBUG) def on_email(self,evt): pass def on_send_to(self, evt): - self.log.log("Enter game_tree->on_send_to(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_send_to(self, evt)", ORPG_DEBUG) players = self.session.get_players() opts = [] myid = self.session.get_id() @@ -527,10 +528,10 @@ for s in selections: self.session.send(xmldata,players[s][2]) dlg.Destroy() - self.log.log("Exit game_tree->on_send_to(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_send_to(self, evt)", ORPG_DEBUG) def on_icon(self, evt): - self.log.log("Enter game_tree->on_icon(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_icon(self, evt)", ORPG_DEBUG) icons = self.icons.keys() icons.sort() dlg = wx.SingleChoiceDialog(self,"Choose Icon?","Change Icon",icons) @@ -540,10 +541,10 @@ obj = self.GetPyData(item) obj.change_icon(key) dlg.Destroy() - self.log.log("Exit game_tree->on_icon(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_icon(self, evt)", ORPG_DEBUG) def on_wizard(self, evt): - self.log.log("Enter game_tree->on_wizard(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_wizard(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) name = "New " + obj.master_dom.getAttribute("name") @@ -552,11 +553,11 @@ xml_data += self.xml.toxml(obj) xml_data += "" self.insert_xml(xml_data) - self.log.log(xml_data, ORPG_DEBUG) - self.log.log("Exit game_tree->on_wizard(self, evt)", ORPG_DEBUG) + self.orpgLog.log(xml_data, ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_wizard(self, evt)", ORPG_DEBUG) def on_clone(self, evt): - self.log.log("Enter game_tree->on_clone(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_clone(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) if obj.can_clone(): @@ -569,118 +570,118 @@ parent = obj.master_dom._get_parentNode() xml_dom = parent.insertBefore(xml_dom, obj.master_dom) self.load_xml(xml_dom, parent_node, prev_sib) - self.log.log("Exit game_tree->on_clone(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_clone(self, evt)", ORPG_DEBUG) def on_save(self, evt): """save node to a xml file""" - self.log.log("Enter game_tree->on_save(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_save(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) obj.on_save(evt) os.chdir(self.root_dir) - self.log.log("Exit game_tree->on_save(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_save(self, evt)", ORPG_DEBUG) def on_save_tree_as(self, evt): - self.log.log("Enter game_tree->on_save_tree_as(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_save_tree_as(self, evt)", ORPG_DEBUG) f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.SAVE) if f.ShowModal() == wx.ID_OK: self.save_tree(f.GetPath()) self.last_save_dir, throwaway = os.path.split( f.GetPath() ) f.Destroy() os.chdir(self.root_dir) - self.log.log("Exit game_tree->on_save_tree_as(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_save_tree_as(self, evt)", ORPG_DEBUG) def on_save_tree(self, evt=None): - self.log.log("Enter game_tree->on_save_tree(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_save_tree(self, evt)", ORPG_DEBUG) filename = self.settings.get_setting("gametree") self.save_tree(filename) - self.log.log("Exit game_tree->on_save_tree(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_save_tree(self, evt)", ORPG_DEBUG) - def save_tree(self, filename=orpg.dirpath.dir_struct["user"]+'tree.xml'): - self.log.log("Enter game_tree->save_tree(self, filename)", ORPG_DEBUG) + def save_tree(self, filename=dir_struct["user"]+'tree.xml'): + self.orpgLog.log("Enter game_tree->save_tree(self, filename)", ORPG_DEBUG) self.master_dom.setAttribute("version",GAMETREE_VERSION) self.settings.set_setting("gametree",filename) file = open(filename,"w") file.write(self.xml.toxml(self.master_dom,1)) file.close() - self.log.log("Exit game_tree->save_tree(self, filename)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->save_tree(self, filename)", ORPG_DEBUG) def on_load_new_tree(self, evt): - self.log.log("Enter game_tree->on_load_new_tree(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_load_new_tree(self, evt)", ORPG_DEBUG) f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.OPEN) if f.ShowModal() == wx.ID_OK: self.load_tree(f.GetPath()) self.last_save_dir, throwaway = os.path.split( f.GetPath() ) f.Destroy() os.chdir(self.root_dir) - self.log.log("Exit game_tree->on_load_new_tree(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_load_new_tree(self, evt)", ORPG_DEBUG) def on_insert_file(self, evt): """loads xml file into the tree""" - self.log.log("Enter game_tree->on_insert_file(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_insert_file(self, evt)", ORPG_DEBUG) if self.last_save_dir == ".": - self.last_save_dir = orpg.dirpath.dir_struct["user"] + self.last_save_dir = dir_struct["user"] f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.OPEN) if f.ShowModal() == wx.ID_OK: self.insert_xml(open(f.GetPath(),"r").read()) self.last_save_dir, throwaway = os.path.split( f.GetPath() ) f.Destroy() os.chdir(self.root_dir) - self.log.log("Exit game_tree->on_insert_file(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_insert_file(self, evt)", ORPG_DEBUG) def on_insert_url(self, evt): """loads xml url into the tree""" - self.log.log("Enter game_tree->on_insert_url(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_insert_url(self, evt)", ORPG_DEBUG) dlg = wx.TextEntryDialog(self,"URL?","Insert URL", "http://") if dlg.ShowModal() == wx.ID_OK: path = dlg.GetValue() file = urllib.urlopen(path) self.insert_xml(file.read()) dlg.Destroy() - self.log.log("Exit game_tree->on_insert_url(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_insert_url(self, evt)", ORPG_DEBUG) def on_insert_features(self, evt): - self.log.log("Enter game_tree->on_insert_features(self, evt)", ORPG_DEBUG) - self.insert_xml(open(orpg.dirpath.dir_struct["template"]+"feature.xml","r").read()) - self.log.log("Exit game_tree->on_insert_features(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_insert_features(self, evt)", ORPG_DEBUG) + self.insert_xml(open(dir_struct["template"]+"feature.xml","r").read()) + self.orpgLog.log("Exit game_tree->on_insert_features(self, evt)", ORPG_DEBUG) def on_tree_prop(self, evt): - self.log.log("Enter game_tree->on_tree_prop(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_tree_prop(self, evt)", ORPG_DEBUG) dlg = gametree_prop_dlg(self, self.settings) if dlg.ShowModal() == wx.ID_OK: pass dlg.Destroy() - self.log.log("Exit game_tree->on_tree_prop(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_tree_prop(self, evt)", ORPG_DEBUG) def on_node_design(self, evt): - self.log.log("Enter game_tree->on_node_design(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_node_design(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) obj.on_design(evt) - self.log.log("Exit game_tree->on_node_design(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_node_design(self, evt)", ORPG_DEBUG) def on_node_use(self, evt): - self.log.log("Enter game_tree->on_node_use(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_node_use(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) obj.on_use(evt) - self.log.log("Exit game_tree->on_node_use(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_node_use(self, evt)", ORPG_DEBUG) def on_node_pp(self, evt): - self.log.log("Enter game_tree->on_node_pp(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_node_pp(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) obj.on_html_view(evt) - self.log.log("Exit game_tree->on_node_pp(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_node_pp(self, evt)", ORPG_DEBUG) def on_del(self, evt): - self.log.log("Enter game_tree->on_del(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_del(self, evt)", ORPG_DEBUG) status_value = "none" try: item = self.GetSelection() @@ -721,10 +722,10 @@ msg.ShowModal() msg.Destroy() - self.log.log("Exit game_tree->on_del(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_del(self, evt)", ORPG_DEBUG) def on_about(self, evt): - self.log.log("Enter game_tree->on_about(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_about(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) @@ -732,77 +733,77 @@ about.ShowModal() about.Destroy() - self.log.log("Exit game_tree->on_about(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_about(self, evt)", ORPG_DEBUG) def on_send_to_map(self, evt): - self.log.log("Enter game_tree->on_send_to_map(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_send_to_map(self, evt)", ORPG_DEBUG) item = self.GetSelection() obj = self.GetPyData(item) if hasattr(obj,"on_send_to_map"): obj.on_send_to_map(evt) - self.log.log("Exit game_tree->on_send_to_map(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_send_to_map(self, evt)", ORPG_DEBUG) def insert_xml(self, txt): - self.log.log("Enter game_tree->insert_xml(self, txt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->insert_xml(self, txt)", ORPG_DEBUG) #Updated to allow safe merging of gametree files #without leaving an unusable and undeletable node. # -- Snowdog 8/03 xml_dom = self.xml.parseXml(txt) if xml_dom == None: wx.MessageBox("Import Failed: Invalid or missing node data") - self.log.log("Import Failed: Invalid or missing node data", ORPG_DEBUG) - self.log.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) + self.orpgLog.log("Import Failed: Invalid or missing node data", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) return xml_temp = xml_dom._get_documentElement() if not xml_temp: wx.MessageBox("Error Importing Node or Tree") - self.log.log("Error Importing Node or Tree", ORPG_DEBUG) - self.log.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) + self.orpgLog.log("Error Importing Node or Tree", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) return if xml_temp._get_tagName() == "gametree": children = xml_temp._get_childNodes() for c in children: self.load_xml(c, self.root) - self.log.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) return if not xml_dom: wx.MessageBox("XML Error") - self.log.log("XML Error", ORPG_DEBUG) - self.log.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) + self.orpgLog.log("XML Error", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) return xml_dom = xml_dom._get_firstChild() child = self.master_dom._get_firstChild() xml_dom = self.master_dom.insertBefore(xml_dom,child) self.load_xml(xml_dom,self.root,self.root) - self.log.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG) def build_img_list(self): """make image list""" - self.log.log("Enter game_tree->build_img_list(self)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->build_img_list(self)", ORPG_DEBUG) helper = img_helper() self.icons = { } self._imageList= wx.ImageList(16,16,False) - man = open(orpg.dirpath.dir_struct["icon"]+"icons.xml","r") + man = open(dir_struct["icon"]+"icons.xml","r") xml_dom = self.xml.parseXml(man.read()) man.close() xml_dom = xml_dom._get_documentElement() node_list = xml_dom._get_childNodes() for n in node_list: key = n.getAttribute("name") - path = orpg.dirpath.dir_struct["icon"] + n.getAttribute("file") + path = dir_struct["icon"] + n.getAttribute("file") img = helper.load_file(path) self.icons[key] = self._imageList.Add(img) self.SetImageList(self._imageList) - self.log.log("Exit game_tree->build_img_list(self)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->build_img_list(self)", ORPG_DEBUG) def load_xml(self, xml_dom, parent_node, prev_node=None): - self.log.log("Enter game_tree->load_xml(self, xml_dom, parent_node, prev_node)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->load_xml(self, xml_dom, parent_node, prev_node)", ORPG_DEBUG) #add the first tree node i = 0 text = xml_dom.getAttribute("name") @@ -810,7 +811,7 @@ if self.icons.has_key(icon): i = self.icons[icon] name = xml_dom._get_nodeName() - self.log.log("Text, icon and name set\n" + text + "\n" + icon + "\n" + name, ORPG_DEBUG) + self.orpgLog.log("Text, icon and name set\n" + text + "\n" + icon + "\n" + name, ORPG_DEBUG) if prev_node: if prev_node == parent_node: new_tree_node = self.PrependItem(parent_node, text, i, i) @@ -819,37 +820,37 @@ else: new_tree_node = self.AppendItem(parent_node, text, i, i) - self.log.log("Node Added to tree", ORPG_DEBUG) + self.orpgLog.log("Node Added to tree", ORPG_DEBUG) #create a nodehandler or continue loading xml into tree if name == "nodehandler": #wx.BeginBusyCursor() - self.log.log("We have a Nodehandler", ORPG_DEBUG) + self.orpgLog.log("We have a Nodehandler", ORPG_DEBUG) try: py_class = xml_dom.getAttribute("class") - self.log.log("nodehandler class: " + py_class, ORPG_DEBUG) + self.orpgLog.log("nodehandler class: " + py_class, ORPG_DEBUG) if not self.nodehandlers.has_key(py_class): raise Exception, "Unknown Nodehandler for " + py_class self.nodes[self.id] = self.nodehandlers[py_class](xml_dom, new_tree_node) self.SetPyData(new_tree_node, self.nodes[self.id]) - self.log.log("Node Data set", ORPG_DEBUG) + self.orpgLog.log("Node Data set", ORPG_DEBUG) bmp = self.nodes[self.id].get_scaled_bitmap(16,16) if bmp: self.cached_load_of_image(bmp,new_tree_node,) - self.log.log("Node Icon loaded", ORPG_DEBUG) + self.orpgLog.log("Node Icon loaded", ORPG_DEBUG) self.id = self.id + 1 except Exception, er: - self.log.log(traceback.format_exc(), ORPG_GENERAL) - #self.log.log("Error Info: " + xml_dom.getAttribute("class") + "\n" + str(er), "Tree Node Load Error", ORPG_GENERAL, True) # Arbitrary fix! TaS. (gametree should thread in the future.) - self.log.log("Error Info: " + xml_dom.getAttribute("class") + "\n" + str(er), ORPG_GENERAL, True) + self.orpgLog.log(traceback.format_exc(), ORPG_GENERAL) + #self.orpgLog.log("Error Info: " + xml_dom.getAttribute("class") + "\n" + str(er), "Tree Node Load Error", ORPG_GENERAL, True) # Arbitrary fix! TaS. (gametree should thread in the future.) + self.orpgLog.log("Error Info: " + xml_dom.getAttribute("class") + "\n" + str(er), ORPG_GENERAL, True) self.Delete(new_tree_node) parent = xml_dom._get_parentNode() parent.removeChild(xml_dom) #wx.EndBusyCursor() - self.log.log("Exit game_tree->load_xml(self, xml_dom, parent_node, prev_node)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->load_xml(self, xml_dom, parent_node, prev_node)", ORPG_DEBUG) return new_tree_node def cached_load_of_image(self, bmp_in, new_tree_node): - self.log.log("Enter game_tree->cached_load_of_image(self, bmp_in, new_tree_node)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->cached_load_of_image(self, bmp_in, new_tree_node)", ORPG_DEBUG) image_list = self.GetImageList() img = wx.ImageFromBitmap(bmp_in) img_data = img.GetData() @@ -864,12 +865,12 @@ self.image_cache[image_index] = img_data self.SetItemImage(new_tree_node,image_index) self.SetItemImage(new_tree_node,image_index, wx.TreeItemIcon_Selected) - self.log.log("Exit game_tree->cached_load_of_image(self, bmp_in, new_tree_node)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->cached_load_of_image(self, bmp_in, new_tree_node)", ORPG_DEBUG) return image_index def on_rclick(self, evt): - self.log.log("Enter game_tree->on_rclick(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_rclick(self, evt)", ORPG_DEBUG) pt = evt.GetPosition() (item, flag) = self.HitTest(pt) if item.IsOk(): @@ -881,10 +882,10 @@ self.PopupMenu(self.top_menu) else: self.PopupMenu(self.top_menu,pt) - self.log.log("Exit game_tree->on_rclick(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_rclick(self, evt)", ORPG_DEBUG) def on_ldclick(self, evt): - self.log.log("Enter game_tree->on_ldclick(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_ldclick(self, evt)", ORPG_DEBUG) self.rename_flag = 0 pt = evt.GetPosition() (item, flag) = self.HitTest(pt) @@ -902,10 +903,10 @@ obj.on_html_view(evt) elif action == "chat": self.on_send_to_chat(evt) - self.log.log("Exit game_tree->on_ldclick(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_ldclick(self, evt)", ORPG_DEBUG) def on_left_down(self, evt): - self.log.log("Enter game_tree->on_left_down(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_left_down(self, evt)", ORPG_DEBUG) pt = evt.GetPosition() (item, flag) = self.HitTest(pt) if item.IsOk() and self.was_labeling: @@ -918,10 +919,10 @@ else: self.SelectItem(item) evt.Skip() - self.log.log("Exit game_tree->on_left_down(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_left_down(self, evt)", ORPG_DEBUG) def on_left_up(self, evt): - self.log.log("Enter game_tree->on_left_up(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_left_up(self, evt)", ORPG_DEBUG) if self.dragging: cur = wx.StockCursor(wx.CURSOR_ARROW) self.SetCursor(cur) @@ -934,10 +935,10 @@ if(isinstance(obj,core.node_handler)): obj.on_drop(evt) self.drag_obj = None - self.log.log("Exit game_tree->on_left_up(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_left_up(self, evt)", ORPG_DEBUG) def on_label_change(self, evt): - self.log.log("Enter game_tree->on_label_change(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_label_change(self, evt)", ORPG_DEBUG) item = evt.GetItem() txt = evt.GetLabel() self.was_labeling = 0 @@ -947,10 +948,10 @@ obj.master_dom.setAttribute('name',txt) else: evt.Veto() - self.log.log("Exit game_tree->on_label_change(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_label_change(self, evt)", ORPG_DEBUG) def on_label_begin(self, evt): - self.log.log("Enter game_tree->on_label_begin(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_label_begin(self, evt)", ORPG_DEBUG) if not self.rename_flag: evt.Veto() else: @@ -958,10 +959,10 @@ item = evt.GetItem() if item == self.GetRootItem(): evt.Veto() - self.log.log("Exit game_tree->on_label_begin(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_label_begin(self, evt)", ORPG_DEBUG) def on_drag(self, evt): - self.log.log("Enter game_tree->on_drag(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->on_drag(self, evt)", ORPG_DEBUG) self.rename_flag = 0 item = self.GetSelection() obj = self.GetPyData(item) @@ -971,25 +972,25 @@ cur = wx.StockCursor(wx.CURSOR_HAND) self.SetCursor(cur) self.drag_obj = obj - self.log.log("Exit game_tree->on_drag(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->on_drag(self, evt)", ORPG_DEBUG) def is_parent_node(self, node, compare_node): - self.log.log("Enter game_tree->is_parent_node(self, node, compare_node)", ORPG_DEBUG) + self.orpgLog.log("Enter game_tree->is_parent_node(self, node, compare_node)", ORPG_DEBUG) parent_node = self.GetItemParent(node) if compare_node == parent_node: - self.log.log("parent node", ORPG_DEBUG) - self.log.log("Exit game_tree->is_parent_node(self, node, compare_node)", ORPG_DEBUG) + self.orpgLog.log("parent node", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->is_parent_node(self, node, compare_node)", ORPG_DEBUG) return 1 elif parent_node == self.root: - self.log.log("not parent", ORPG_DEBUG) - self.log.log("Exit game_tree->is_parent_node(self, node, compare_node)", ORPG_DEBUG) + self.orpgLog.log("not parent", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->is_parent_node(self, node, compare_node)", ORPG_DEBUG) return 0 else: - self.log.log("Exit game_tree->is_parent_node(self, node, compare_node)", ORPG_DEBUG) + self.orpgLog.log("Exit game_tree->is_parent_node(self, node, compare_node)", ORPG_DEBUG) return self.is_parent_node(parent_node, compare_node) CTRL_TREE_FILE = wx.NewId() diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/nodehandlers/StarWarsd20.py --- a/orpg/gametree/nodehandlers/StarWarsd20.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/nodehandlers/StarWarsd20.py Tue Aug 18 06:33:37 2009 -0500 @@ -107,7 +107,7 @@ """ def __init__(self,xml_dom,tree_node): node_handler.__init__(self,xml_dom,tree_node) - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('howtouse','HowTO use this tool',SWd20howto,'note') self.new_child_handler('general','General Information',SWd20general,'gear') @@ -291,7 +291,7 @@ node_handler.__init__(self,xml_dom, tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/nodehandlers/core.py --- a/orpg/gametree/nodehandlers/core.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/nodehandlers/core.py Tue Aug 18 06:33:37 2009 -0500 @@ -31,9 +31,9 @@ from nodehandler_version import NODEHANDLER_VERSION try: from orpg.orpg_windows import * - import orpg.dirpath + from orpg.dirpath import dir_struct from orpg.orpg_xml import * - from orpg.orpgCore import open_rpg + from orpg.orpgCore import component import webbrowser from orpg.mapper import map import os @@ -53,10 +53,10 @@ def __init__(self,xml_dom,tree_node): self.master_dom = xml_dom self.mytree_node = tree_node - self.tree = open_rpg.get_component('tree') - self.frame = open_rpg.get_component('frame') - self.chat = open_rpg.get_component('chat') - self.xml = open_rpg.get_component('xml') + self.tree = component.get('tree') + self.frame = component.get('frame') + self.chat = component.get('chat') + self.xml = component.get('xml') self.drag = True self.myeditor = None # designing self.myviewer = None # prett print @@ -392,7 +392,7 @@ def __init__(self,xml_dom,tree_node): node_handler.__init__(self,xml_dom,tree_node) self.file_node = self.master_dom._get_firstChild() - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') def on_ldclick(self,evt): file_name = self.file_node.getAttribute("name") @@ -424,7 +424,7 @@ def __init__(self,xml_dom,tree_node): node_handler.__init__(self,xml_dom,tree_node) self.file_node = self.master_dom._get_firstChild() - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') def on_ldclick(self,evt): file_name = self.file_node.getAttribute("url") @@ -455,7 +455,7 @@ """ def __init__(self,xml_dom,tree_node): node_handler.__init__(self,xml_dom,tree_node) - self.map = open_rpg.get_component('map') + self.map = component.get('map') self.mapdata = self.master_dom._get_firstChild() def on_ldclick(self,evt): diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/nodehandlers/d20.py --- a/orpg/gametree/nodehandlers/d20.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/nodehandlers/d20.py Tue Aug 18 06:33:37 2009 -0500 @@ -112,7 +112,7 @@ """ def __init__(self,xml_dom,tree_node): node_handler.__init__(self,xml_dom,tree_node) - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('howtouse','HowTO use this tool',d20howto,'note') self.new_child_handler('general','General Information',d20general,'gear') @@ -301,7 +301,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/nodehandlers/dnd35.py --- a/orpg/gametree/nodehandlers/dnd35.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/nodehandlers/dnd35.py Tue Aug 18 06:33:37 2009 -0500 @@ -45,7 +45,7 @@ self.hparent = None #a 1.5002 allow ability to run up tree, this is the - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('general','GeneralInformation',dnd35general,'gear') self.new_child_handler('inventory','MoneyAndInventory',dnd35inventory,'money') @@ -120,7 +120,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None @@ -357,7 +357,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.hparent = parent #a 1.5002 allow ability to run up tree. dnd35_char_child.__init__(self,xml_dom,tree_node,parent) - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('abilities','Abilities Scores',dnd35ability,'gear') self.new_child_handler('classes','Classes',dnd35classes,'knight') @@ -389,7 +389,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None def on_drop(self,evt): @@ -907,7 +907,7 @@ node_handler.__init__(self,xml_dom,tree_node) dnd35_char_child.__init__(self,xml_dom,tree_node,parent) - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('skills','Skills',dnd35skill,'book') self.new_child_handler('feats','Feats',dnd35feats,'book') @@ -938,7 +938,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None @@ -1358,7 +1358,7 @@ #mark3 dnd35_char_child.__init__(self,xml_dom,tree_node,parent) - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('hp','Hit Points',dnd35hp,'gear') self.new_child_handler('attacks','Attacks',dnd35attacks,'spears') @@ -1392,7 +1392,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/nodehandlers/dnd3e.py --- a/orpg/gametree/nodehandlers/dnd3e.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/nodehandlers/dnd3e.py Tue Aug 18 06:33:37 2009 -0500 @@ -233,7 +233,7 @@ #a 1.5002 top of the handler tree, this is used to flag where to stop #a 1.5002 on the way up. Changing this will break getRoot(self) - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('howtouse','HowTo use this tool',dnd3ehowto,'note') self.new_child_handler('general','GeneralInformation',dnd3egeneral,'gear') @@ -335,7 +335,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None @@ -601,7 +601,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.hparent = parent #a 1.5002 allow ability to run up tree. dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('abilities','Abilities Scores',dnd3eability,'gear') self.new_child_handler('classes','Classes',dnd3eclasses,'knight') @@ -633,7 +633,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None def on_drop(self,evt): @@ -1150,7 +1150,7 @@ node_handler.__init__(self,xml_dom,tree_node) dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('skills','Skills',dnd3eskill,'book') self.new_child_handler('feats','Feats',dnd3efeats,'book') @@ -1182,7 +1182,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None @@ -1594,7 +1594,7 @@ #mark3 dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('hp','Hit Points',dnd3ehp,'gear') self.new_child_handler('attacks','Attacks',dnd3eattacks,'spears') @@ -1628,7 +1628,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None @@ -2620,7 +2620,7 @@ self.hparent = parent #a 1.5002 allow ability to run up tree. - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('spells','Spells',dnd3espells,'book') self.new_child_handler('divine','Divine Spells',dnd3edivine,'book') @@ -2658,7 +2658,7 @@ node_handler.__init__(self,xml_dom,tree_node) self.char_hander = parent self.drag = False - self.frame = open_rpg.get_component('frame') + self.frame = component.get('frame') self.myeditor = None diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/nodehandlers/forms.py --- a/orpg/gametree/nodehandlers/forms.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/nodehandlers/forms.py Tue Aug 18 06:33:37 2009 -0500 @@ -209,9 +209,9 @@ """ def __init__(self,xml_dom,tree_node): - node_handler.__init__(self,xml_dom,tree_node) + node_handler.__init__(self,xml_dom,tree_node) self.text_elem = self.master_dom.getElementsByTagName('text')[0] - self.text = safe_get_text_node(self.text_elem) + self.text = component.get('xml').safe_get_text_node(self.text_elem) if self.text_elem.getAttribute("send_button") == "": self.text_elem.setAttribute("send_button","0") if self.text_elem.getAttribute("raw_mode") == "": @@ -410,7 +410,7 @@ def __init__(self,xml_dom,tree_node): node_handler.__init__(self,xml_dom,tree_node) self.list = self.master_dom.getElementsByTagName('list')[0] - self.options = self.list.getElementsByTagName('option') + self.options = self.list.getElementsByTagName('option') if self.list.getAttribute("send_button") == "": self.list.setAttribute("send_button","0") if self.list.getAttribute("hide_title") == "": @@ -448,7 +448,7 @@ def get_selected_text(self): node = self.get_selected_node() if node: - return safe_get_text_node(node)._get_nodeValue() + return component.get('xml').safe_get_text_node(node)._get_nodeValue() else: return "" @@ -466,7 +466,7 @@ opts = [] for opt in self.options: if opt.getAttribute("selected") == "1": - opts.append(safe_get_text_node(opt)._get_nodeValue()) + opts.append(component.get('xml').safe_get_text_node(opt)._get_nodeValue()) return opts def get_selections_index(self): @@ -494,11 +494,11 @@ def get_options(self): opts = [] for opt in self.options: - opts.append(safe_get_text_node(opt)._get_nodeValue()) + opts.append(component.get('xml').safe_get_text_node(opt)._get_nodeValue()) return opts def get_option(self,index): - return safe_get_text_node(self.options[index])._get_nodeValue() + return component.get('xml').safe_get_text_node(self.options[index])._get_nodeValue() def add_option(self,opt): elem = minidom.Element('option') @@ -514,7 +514,7 @@ self.options = self.list.getElementsByTagName('option') def edit_option(self,index,value): - safe_get_text_node(self.options[index])._set_nodeValue(value) + component.get('xml').safe_get_text_node(self.options[index])._set_nodeValue(value) def has_send_button(self): if self.list.getAttribute("send_button") == '0': diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/nodehandlers/map_miniature_nodehandler.py --- a/orpg/gametree/nodehandlers/map_miniature_nodehandler.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/nodehandlers/map_miniature_nodehandler.py Tue Aug 18 06:33:37 2009 -0500 @@ -45,8 +45,8 @@ def __init__(self,xml_dom,tree_node): node_handler.__init__(self,xml_dom,tree_node) - self.mapper = open_rpg.get_component("map") - self.session = open_rpg.get_component("session") + self.mapper = component.get("map") + self.session = component.get("session") self.miniature_dom = self.master_dom.getElementsByTagName("miniature") if self.miniature_dom: self.miniature_dom = self.miniature_dom[0] # convert to scalar @@ -120,7 +120,7 @@ self.miniature_dom.setAttribute("posy", str(pos.y)) new_xml = self.get_to_map_XML() if (self.session.my_role() != self.session.ROLE_GM) and (self.session.my_role() != self.session.ROLE_PLAYER): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use the miniature Layer") + component.get("chat").InfoPost("You must be either a player or GM to use the miniature Layer") return if new_xml: diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/nodehandlers/minilib.py --- a/orpg/gametree/nodehandlers/minilib.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/nodehandlers/minilib.py Tue Aug 18 06:33:37 2009 -0500 @@ -32,7 +32,7 @@ miniatures as sending them to the map singly or in batches. """ from core import * -import orpg.dirpath +from orpg.dirpath import dir_struct import string import map_miniature_nodehandler import orpg.mapper.map_msg @@ -189,11 +189,11 @@ if mini.getAttribute( ATTRIBUTE_URL ) == '' or mini.getAttribute( ATTRIBUTE_URL ) == 'http://': self.chat.ParsePost( self.chat.colorize(self.chat.syscolor, '"%s" is not a valid URL, the mini "%s" will not be added to the map' % ( mini.getAttribute( ATTRIBUTE_URL ), mini.getAttribute( ATTRIBUTE_NAME ) )) ) return - session = open_rpg.get_component( COMPONENT_SESSION ) + session = component.get( COMPONENT_SESSION ) if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use the miniature Layer") + component.get("chat").InfoPost("You must be either a player or GM to use the miniature Layer") return - map = open_rpg.get_component(COMPONENT_MAP) + map = component.get(COMPONENT_MAP) for loop in range( count ): msg = self.get_miniature_XML( mini, addName) msg = str("" + msg + "") @@ -202,8 +202,8 @@ def get_miniature_XML( self, mini, addName = True ): msg = orpg.mapper.map_msg.mini_msg() - map = open_rpg.get_component( COMPONENT_MAP ) - session = open_rpg.get_component( COMPONENT_SESSION ) + map = component.get( COMPONENT_MAP ) + session = component.get( COMPONENT_SESSION ) msg.init_prop( ATTRIBUTE_ID, session.get_next_id() ) for k in mini.getAttributeKeys(): # translate our attributes to map attributes @@ -272,7 +272,7 @@ self.handler = handler self.frame = frame - self.map = open_rpg.get_component('map') + self.map = component.get('map') names = self.buildList() # self.keys = self.list.keys() # self.keys.sort() diff -r 4840657c23c5 -r c54768cffbd4 orpg/gametree/nodehandlers/voxchat.py --- a/orpg/gametree/nodehandlers/voxchat.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/gametree/nodehandlers/voxchat.py Tue Aug 18 06:33:37 2009 -0500 @@ -39,10 +39,10 @@ import orpg.tools.rgbhex import orpg.tools.inputValidator -import orpg.dirpath +from orpg.dirpath import dir_struct import orpg.minidom import orpg.networking.mplay_client -from orpg.orpgCore import open_rpg +from orpg.orpgCore import component # # Good things to add: @@ -55,14 +55,14 @@ def __init__(self, xml_dom, tree_node): core.node_handler.__init__( self, xml_dom, tree_node) self.node = xml_dom - self.xml = open_rpg.get_component('xml') + self.xml = component.get('xml') def get_design_panel( self, parent ): - aliasLib = open_rpg.get_component('alias') + aliasLib = component.get('alias') aliasLib.ImportFromTree(self.node) return None def get_use_panel( self, parent ): - aliasLib = open_rpg.get_component('alias') + aliasLib = component.get('alias') aliasLib.ImportFromTree(self.node) return None diff -r 4840657c23c5 -r c54768cffbd4 orpg/main.py --- a/orpg/main.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/main.py Tue Aug 18 06:33:37 2009 -0500 @@ -33,52 +33,65 @@ from orpg.orpgCore import * from orpg_version import * from orpg.orpg_windows import * -import orpg.dirpath -import orpg.orpg_xml + +from orpg.dirpath import dir_struct + import orpg.player_list + import orpg.tools.pluginui as pluginUI -import orpg.tools.orpg_settings -import orpg.tools.orpg_log import orpg.tools.aliaslib -from orpg.tools.metamenus import MenuBarEx import orpg.tools.toolBars -import orpg.tools.passtool import orpg.tools.orpg_sound -import orpg.tools.validate import orpg.tools.rgbhex + import orpg.gametree.gametree import orpg.chat.chatwnd -import orpg.dieroller.utils + import orpg.networking.mplay_client import orpg.networking.gsclient + import orpg.mapper.map import orpg.mapper.images + import upmana.updatemana import upmana.manifest as manifest import wx.py +from orpg.dieroller.utils import roller_manager as DiceManager +from orpg.tools.orpg_log import logger +from orpg.tools.oprg_settings import settings #imported, not used yet +from orpg.tools.validate import validate +from orpg.tools.passtool import PassTool +from orpg.tools.decorators import debugging +from orpg.tools.metamenus import MenuBarEx + +#from xml.etree.ElementTree import ElementTree, Element +#from xml.etree.ElementTree import fromstring, tostring +from orpg.orpg_xml import xml #to be replaced by etree + + + #################################### ## Main Frame #################################### 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.log = open_rpg.get_component("log") - self.xml = open_rpg.get_component("xml") - self.dir_struct = open_rpg.get_component("dir_struct") - self.validate = open_rpg.get_component("validate") - self.settings = open_rpg.get_component("settings") - self.log.log("Enter orpgFrame", ORPG_DEBUG) + self.orpgLog = component.get('log') + self.xml = component.get("xml") + self.validate = component.get("validate") + self.settings = component.get("settings") + self.orpgLog.log("Enter orpgFrame", ORPG_DEBUG) self.rgbcovert = orpg.tools.rgbhex.RGBHex() self._mgr = AUI.AuiManager(self) # Determine which icon format to use icon = None - if wx.Platform == '__WXMSW__': icon = wx.Icon(orpg.dirpath.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) - else: icon = wx.Icon(orpg.dirpath.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM) - #if icon != None: self.SetIcon( icon ) worth 'less' now since it sets the icon either or. + if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) + else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM) self.SetIcon( icon ) # create session @@ -89,6 +102,7 @@ "on_status_event":self.on_status_event, "on_password_signal":self.on_password_signal, "orpgFrame":self} + self.session = orpg.networking.mplay_client.mplay_client(self.settings.get_setting("player"), call_backs) self.poll_timer = wx.Timer(self, wx.NewId()) self.Bind(wx.EVT_TIMER, self.session.poll, self.poll_timer) @@ -97,66 +111,68 @@ self.Bind(wx.EVT_TIMER, self.session.update, self.ping_timer) # create roller manager - self.DiceManager = orpg.dieroller.utils.roller_manager(self.settings.get_setting("dieroller")) + self.DiceManager = DiceManager(self.settings.get_setting("dieroller")) + component.add('DiceManager', self.DiceManager) #create password manager --SD 8/03 - self.password_manager = orpg.tools.passtool.PassTool() - open_rpg.add_component("session", self.session) - open_rpg.add_component('frame', self) - open_rpg.add_component('DiceManager', self.DiceManager) - open_rpg.add_component('password_manager', self.password_manager) + self.password_manager = component.get('password_manager') + component.add("session", self.session) + component.add('frame', self) # build frame windows self.build_menu() self.build_gui() self.build_hotkeys() - self.log.log("GUI Built", ORPG_DEBUG) - open_rpg.add_component("chat",self.chat) - open_rpg.add_component("map",self.map) - open_rpg.add_component("alias", self.aliaslib) - self.log.log("openrpg components all added", ORPG_DEBUG) + + logger.debug("GUI Built") + component.add("chat",self.chat) + component.add("map",self.map) + component.add("alias", self.aliaslib) + + self.orpgLog.log("openrpg components all added", ORPG_DEBUG) self.tree.load_tree(self.settings.get_setting("gametree")) - self.log.log("Tree Loaded", ORPG_DEBUG) + logger.debug("Tree Loaded") self.players.size_cols() - self.log.log("player window cols sized", ORPG_DEBUG) #Load the Plugins This has to be after the chat component has been added - open_rpg.add_component('pluginmenu', self.pluginMenu) + component.add('pluginmenu', self.pluginMenu) self.pluginsFrame.Start() - self.log.log("plugins reloaded and startup plugins launched", ORPG_DEBUG) + logger.debug("plugins reloaded and startup plugins launched") self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - self.log.log("Exit orpgFrame", ORPG_DEBUG) #Load Update Manager - open_rpg.add_component('updatemana', self.updateMana) - self.log.log("update manager reloaded", ORPG_DEBUG) + component.add('updatemana', self.updateMana) + logger.debug("update manager reloaded") self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - self.log.log("Exit orpgFrame", ORPG_DEBUG) + @debugging def post_show_init(self): """Some Actions need to be done after the main fram is drawn""" - self.log.log("Enter orpgFrame->post_show_init(self)", ORPG_DEBUG) self.players.size_cols() - self.log.log("Exit orpgFrame->post_show_init(self)", ORPG_DEBUG) + @debugging def get_activeplugins(self): - self.log.log("Enter orpgFrame->get_activeplugins(self)", ORPG_DEBUG) try: tmp = self.pluginsFrame.get_activeplugins() except: tmp = {} - self.log.log("Exit orpgFrame->get_activeplugins(self)", ORPG_DEBUG) return tmp + @debugging def get_startplugins(self): - self.log.log("Enter orpgFrame->get_startplugins(self)", ORPG_DEBUG) try: tmp = self.pluginsFrame.get_startplugins() except: tmp = {} - self.log.log("Exit orpgFrame->get_startplugins(self)", ORPG_DEBUG) return tmp + @debugging def on_password_signal(self,signal,type,id,data): - self.log.log("Enter orpgFrame->on_password_signal(self,signal,type,id,data)", ORPG_DEBUG) try: - self.log.log("DEBUG: password response= "+str(signal)+" (T:"+str(type)+" #"+str(id)+")", ORPG_DEBUG) + msg = ["DEBUG: password response= ", + str(signal), + " (T:", + str(type), + " #", + str(id), + ")"] + logger.debug("".join(msg)) id = int(id) type = str(type) data = str(data) @@ -167,10 +183,9 @@ elif type == "room": self.password_manager.ClearPassword("room", int(id)) else: pass except: traceback.print_exc() - self.log.log("Exit orpgFrame->on_password_signal(self,signal,type,id,data)", ORPG_DEBUG) + @debugging def build_menu(self): - self.log.log("Enter orpgFrame->build_menu()", ORPG_DEBUG) menu = \ [[ ['&OpenRPG'], @@ -247,7 +262,6 @@ self.pluginMenu.AppendItem(item) self.pluginMenu.AppendSeparator() self.mainmenu.Insert(2, self.pluginMenu, "&Plugins") - self.log.log("Exit orpgFrame->build_menu()", ORPG_DEBUG) self.updateMana = wx.Menu() mana = wx.MenuItem(self.updateMana, wx.ID_ANY, "Update Manager", "Update Manager") @@ -255,15 +269,14 @@ self.updateMana.AppendItem(mana) self.mainmenu.Insert(5, self.updateMana, "&Update Manager") - self.log.log("Exit orpgFrame->build_menu()", ORPG_DEBUG) ################################# ## All Menu Events ################################# #Tab Styles Menus + @debugging def SetTabStyles(self, *args, **kwargs): - self.log.log("Enter orpgFrame->SetTabStyles(self, *args, **kwargs)", ORPG_DEBUG) tabtheme = self.settings.get_setting('TabTheme') #This change is stable. TaS. self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful') @@ -277,11 +290,11 @@ if kwargs.has_key('style'): newstyle = kwargs['style'] else: try: newstyle = args[1] - except: self.log.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL); return + except: self.orpgLog.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL); return if kwargs.has_key('menu'): menu = kwargs['menu'] else: try: menu = args[0] - except: self.log.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL); return + except: self.orpgLog.log('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)', ORPG_GENERAL); return if kwargs.has_key('graidentTo'): graidentTo = kwargs['graidentTo'] else: graidentTo = None @@ -291,14 +304,14 @@ else: textColor = None #Run though the current tabbed window list and remove those that have been closed - tabbedwindows = open_rpg.get_component("tabbedWindows") + tabbedwindows = component.get("tabbedWindows") rgbc = orpg.tools.rgbhex.RGBHex() new = [] for wnd in tabbedwindows: try: style = wnd.GetWindowStyleFlag(); new.append(wnd) except: pass tabbedwindows = new - open_rpg.add_component("tabbedWindows", tabbedwindows) + component.add("tabbedWindows", tabbedwindows) #Run though the new list and set the proper styles tabbg = self.settings.get_setting('TabBackgroundGradient') @@ -318,36 +331,35 @@ if textColor != None: wnd.SetNonActiveTabTextColour(textColor) wnd.Refresh() + @debugging def OnMB_OpenRPGNewMap(self): - self.log.log("Enter orpgFrame->OnMB_OpenRPGNewMap(self)", ORPG_DEBUG) - self.log.log("Exit orpgFrame->OnMB_OpenRPGNewMap(self)", ORPG_DEBUG) + pass #Not Implemented yet! + @debugging def OnMB_OpenRPGTabStylesSlantedColorful(self): - self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedColorful(self)", ORPG_DEBUG) if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedColorful"): self.settings.set_setting('TabTheme', 'slanted&colorful') self.SetTabStyles("OpenRPGTabStylesSlantedColorful", FNB.FNB_VC8|FNB.FNB_COLORFUL_TABS) else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", True) - self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedColorful(self)", ORPG_DEBUG) + @debugging def OnMB_OpenRPGTabStylesSlantedBlackandWhite(self): - self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedBlackandWhite(self)", ORPG_DEBUG) if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedBlackandWhite"): self.settings.set_setting('TabTheme', 'slanted&bw') - self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite", FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) + self.SetTabStyles("OpenRPGTabStylesSlantedBlackandWhite", + FNB.FNB_VC8, graidentTo=wx.WHITE, graidentFrom=wx.WHITE, textColor=wx.BLACK) else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", True) - self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedBlackandWhite(self)", ORPG_DEBUG) + @debugging def OnMB_OpenRPGTabStylesSlantedAqua(self): - self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedAqua(self)", ORPG_DEBUG) if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedAqua"): self.settings.set_setting('TabTheme', 'slanted&aqua') - self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8, graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) + self.SetTabStyles("OpenRPGTabStylesSlantedAqua", FNB.FNB_VC8, + graidentTo=wx.Color(0, 128, 255), graidentFrom=wx.WHITE, textColor=wx.BLACK) else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", True) - self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedBlackandWhite(self)", ORPG_DEBUG) + @debugging def OnMB_OpenRPGTabStylesSlantedCustom(self): - self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesSlantedCustom(self)", ORPG_DEBUG) if self.mainmenu.GetMenuState("OpenRPGTabStylesSlantedCustom"): self.settings.set_setting('TabTheme', 'customslant') rgbc = orpg.tools.rgbhex.RGBHex() @@ -363,28 +375,25 @@ graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), textColor=wx.Color(tred, tgreen, tblue)) else: self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedCustom", True) - self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesSlantedCustom(self)", ORPG_DEBUG) + @debugging def OnMB_OpenRPGTabStylesFlatBlackandWhite(self): - self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesFlatBlackandWhite(self)", ORPG_DEBUG) if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatBlackandWhite"): self.settings.set_setting('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) - self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesFlatBlackandWhite(self)", ORPG_DEBUG) + @debugging def OnMB_OpenRPGTabStylesFlatAqua(self): - self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesFlatAqua(self)", ORPG_DEBUG) if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatAqua"): self.settings.set_setting('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) - self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesFlatAqua(self)", ORPG_DEBUG) + @debugging def OnMB_OpenRPGTabStylesFlatCustom(self): - self.log.log("Enter orpgFrame->OnMB_OpenRPGTabStylesFlatCustom(self)", ORPG_DEBUG) if self.mainmenu.GetMenuState("OpenRPGTabStylesFlatCustom"): self.settings.set_setting('TabTheme', 'customflat') rgbc = orpg.tools.rgbhex.RGBHex() @@ -400,11 +409,10 @@ graidentTo=wx.Color(tored, togreen, toblue), graidentFrom=wx.Color(fred, fgreen, fblue), textColor=wx.Color(tred, tgreen, tblue)) else: self.mainmenu.SetMenuState("OpenRPGTabStylesFlatCustom", True) - self.log.log("Exit orpgFrame->OnMB_OpenRPGTabStylesFlatCustom(self)", ORPG_DEBUG) #Window Menu + @debugging def OnMB_WindowsMenu(self, event): - self.log.log("Enter orpgFrame->OnMB_WindowsMenu(self, event)", ORPG_DEBUG) menuid = event.GetId() name = self.mainwindows[menuid] if name == 'Alias Lib': @@ -414,109 +422,97 @@ if self._mgr.GetPane(name).IsShown(): self._mgr.GetPane(name).Hide() else: self._mgr.GetPane(name).Show() self._mgr.Update() - self.log.log("Exit orpgFrame->OnMB_WindowsMenu(self, event)", ORPG_DEBUG) #OpenRPG Menu + @debugging def OnMB_OpenRPGSettings(self): - self.log.log("Enter orpgFrame->OnMB_OpenRPGSettings()", ORPG_DEBUG) dlg = orpg.tools.orpg_settings.orpgSettingsWnd(self) dlg.Centre() dlg.ShowModal() - self.log.log("Exit orpgFrame->OnMB_OpenRPGSettings()", ORPG_DEBUG) def OnMB_OpenRPGExit(self): self.OnCloseWindow(0) #Game Server Menu + @debugging def OnMB_GameServerBrowseServers(self): - self.log.log("Enter orpgFrame->OnMB_GameServerBrowseServers(self)", ORPG_DEBUG) 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() - self.log.log("Exit orpgFrame->OnMB_GameServerBrowseServers(self)", ORPG_DEBUG) + @debugging def OnMB_GameServerServerHeartbeat(self): - self.log.log("Enter orpgFrame->OnMB_GameServerServerHeartbeat(self)", ORPG_DEBUG) if self.mainmenu.GetMenuState("GameServerServerHeartbeat"): self.settings.set_setting('Heartbeat', '1') else: self.settings.set_setting('Heartbeat', '0') - self.log.log("Exit orpgFrame->OnMB_GameServerServerHeartbeat(self)", ORPG_DEBUG) + @debugging def OnMB_GameServerStartServer(self): - self.log.log("Enter orpgFrame->OnMB_GameServerStartServer(self)", ORPG_DEBUG) start_dialog = wx.ProgressDialog( "Server Loading", "Server Loading, Please Wait...", 1, self ) # Spawn the new process and close the stdout handle from it start_dialog.Update( 0 ) # Adjusted following code to work with win32, can't test for Unix # as per reported bug 586227 if wx.Platform == "__WXMSW__": - arg = '\"' + os.path.normpath(orpg.dirpath.dir_struct["home"] + 'start_server_gui.py') + '\"' + arg = '\"' + os.path.normpath(dir_struct["home"] + 'start_server_gui.py') + '\"' args = ( sys.executable, arg ) else: - arg = orpg.dirpath.dir_struct["home"] + 'start_server_gui.py' + arg = dir_struct["home"] + 'start_server_gui.py' args = (arg,arg) os.spawnv( os.P_NOWAIT, sys.executable, args ) start_dialog.Update( 1 ) start_dialog.Show(False) start_dialog.Destroy() - self.log.log("Exit orpgFrame->OnMB_GameServerStartServer(self)", ORPG_DEBUG) # Tools Menu + @debugging def OnMB_PluginControlPanel(self, evt): - self.log.log("Enter orpgFrame->OnMB_ToolsPlugins(self)", ORPG_DEBUG) if self.pluginsFrame.IsShown() == True: self.pluginsFrame.Hide() else: self.pluginsFrame.Show() - self.log.log("Exit orpgFrame->OnMB_ToolsPlugins(self)", ORPG_DEBUG) + @debugging def OnMB_UpdateManagerPanel(self, evt): - self.log.log("Enter orpgFrame->OnMB_ToolsPlugins(self)", ORPG_DEBUG) if self.updateMana.IsShown() == True: self.updateMana.Hide() else: self.updateMana.Show() - self.log.log("Exit orpgFrame->OnMB_ToolsPlugins(self)", ORPG_DEBUG) + @debugging def OnMB_ToolsLoggingLevelDebug(self): - self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelDebug(self)", ORPG_DEBUG) - lvl = self.log.getLogLevel() + lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelDebug"): lvl |= ORPG_DEBUG else: lvl &= ~ORPG_DEBUG - self.log.setLogLevel(lvl) - self.settings.set_setting('LoggingLevel', lvl) - self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelDebug(self)", ORPG_DEBUG) + logger.log_level = lvl + settings.set('LoggingLevel', lvl) + @debugging def OnMB_ToolsLoggingLevelNote(self): - self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelNote(self)", ORPG_DEBUG) - lvl = self.log.getLogLevel() + lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelNote"): lvl |= ORPG_DEBUG else: lvl &= ~ORPG_DEBUG - self.log.setLogLevel(lvl) - self.settings.set_setting('LoggingLevel', lvl) - self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelNote(self)", ORPG_DEBUG) + logger.log_level = lvl + settings.set('LoggingLevel', lvl) + @debugging def OnMB_ToolsLoggingLevelInfo(self): - self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelInfo(self)", ORPG_DEBUG) - lvl = self.log.getLogLevel() + lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelInfo"): lvl |= ORPG_INFO else: lvl &= ~ORPG_INFO - self.log.setLogLevel(lvl) - self.settings.set_setting('LoggingLevel', lvl) - self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelInfo(self)", ORPG_DEBUG) + logger.log_level = lvl + settings.set('LoggingLevel', lvl) + @debugging def OnMB_ToolsLoggingLevelGeneral(self): - self.log.log("Enter orpgFrame->OnMB_ToolsLoggingLevelGeneral(self)", ORPG_DEBUG) - lvl = self.log.getLogLevel() + lvl = logger.log_level if self.mainmenu.GetMenuState("ToolsLoggingLevelGeneral"): lvl |= ORPG_GENERAL else: lvl &= ~ORPG_GENERAL - self.log.setLogLevel(lvl) - self.settings.set_setting('LoggingLevel', lvl) - self.log.log("Exit orpgFrame->OnMB_ToolsLoggingLevelGeneral(self)", ORPG_DEBUG) + logger.log_level = lvl + settings.set('LoggingLevel', lvl) + @debugging def OnMB_ToolsPasswordManager(self): - self.log.log("Enter orpgFrame->OnMB_ToolsPasswordManager(self)", ORPG_DEBUG) if self.mainmenu.GetMenuState("ToolsPasswordManager"): self.password_manager.Enable() else: self.password_manager.Disable() - self.log.log("Exit orpgFrame->OnMB_ToolsPasswordManager(self)", ORPG_DEBUG) + @debugging def OnMB_ToolsStatusBar(self): - self.log.log("Enter orpgFrame->OnMB_ToolsStatusBar(self)", ORPG_DEBUG) if self._mgr.GetPane("Status Window").IsShown() == True: self.mainmenu.SetMenuState("ToolsStatusBar", False) self._mgr.GetPane("Status Window").Hide() @@ -524,10 +520,9 @@ self.mainmenu.SetMenuState("ToolsStatusBar", True) self._mgr.GetPane("Status Window").Show() self._mgr.Update() - self.log.log("Exit orpgFrame->OnMB_ToolsStatusBar(self)", ORPG_DEBUG) + @debugging def OnMB_ToolsSoundToolbar(self): - self.log.log("Enter orpgFrame->OnMB_ToolsSoundToolbar(self)", ORPG_DEBUG) if self._mgr.GetPane("Sound Control Toolbar").IsShown() == True: self.mainmenu.SetMenuState("ToolsSoundToolbar", False) self._mgr.GetPane("Sound Control Toolbar").Hide() @@ -535,10 +530,9 @@ self.mainmenu.SetMenuState("ToolsSoundToolbar", True) self._mgr.GetPane("Sound Control Toolbar").Show() self._mgr.Update() - self.log.log("Exit orpgFrame->OnMB_ToolsSoundToolbar(self)", ORPG_DEBUG) + @debugging def OnMB_ToolsDiceBar(self): - self.log.log("Enter orpgFrame->OnMB_ToolsDiceBar(self)", ORPG_DEBUG) if self._mgr.GetPane("Dice Tool Bar").IsShown() == True: self.mainmenu.SetMenuState("ToolsDiceBar", False) self._mgr.GetPane("Dice Tool Bar").Hide() @@ -546,10 +540,9 @@ self.mainmenu.SetMenuState("ToolsDiceBar", True) self._mgr.GetPane("Dice Tool Bar").Show() self._mgr.Update() - self.log.log("Exit orpgFrame->OnMB_ToolsDiceBar(self)", ORPG_DEBUG) + @debugging def OnMB_ToolsMapBar(self): - self.log.log("Enter orpgFrame->OnMB_ToolsMapBar(self)", ORPG_DEBUG) if self._mgr.GetPane("Map Tool Bar").IsShown() == True: self.mainmenu.SetMenuState("ToolsMapBar", False) self._mgr.GetPane("Map Tool Bar").Hide() @@ -557,29 +550,27 @@ self.mainmenu.SetMenuState("ToolsMapBar", True) self._mgr.GetPane("Map Tool Bar").Show() self._mgr.Update() - self.log.log("Exit orpgFrame->OnMB_ToolsMapBar(self)", ORPG_DEBUG) #Help Menu #Needs a custom Dialog because it is ugly on Windows + @debugging def OnMB_HelpAbout(self): - description = """OpenRPG is a Virtual Game Table that allows users to connect via a network and play table -top games with friends. 'Traipse' is an OpenRPG distro that is easy to setup and provides superb -functionality. OpenRPG is originally designed by Chris Davis.""" - - license = """OpenRPG is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the Free Software Foundation; -either version 2 of the License, or (at your option) any later version. + description = "OpenRPG is a Virtual Game Table that allows users to connect via a network and play table\n" + description += "top games with friends. 'Traipse' is an OpenRPG distro that is easy to setup and provides superb \n" + description += "functionality. OpenRPG is originally designed by Chris Davis. \n" -OpenRPG and Traipse 'OpenRPG' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. You should have received a copy of -the GNU General Public License along with Traipse 'OpenRPG'; if not, write to -the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -'Traipse' and the 'Traipse' Logo are trademarks of Mad Mathematics Laboratories.""" + license = "OpenRPG is free software; you can redistribute it and/or modify it " + license += "under the terms of the GNU General Public License as published by the Free Software Foundation; \n" + license += "either version 2 of the License, or (at your option) any later version.\n\n" + license += "OpenRPG and Traipse 'OpenRPG' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; \n" + license += "without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n" + license += "See the GNU General Public License for more details. You should have received a copy of \n" + license += "the GNU General Public License along with Traipse 'OpenRPG'; if not, write to \n" + license += "the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\n" + license += "'Traipse' and the 'Traipse' Logo are trademarks of Mad Mathematics Laboratories." info = wx.AboutDialogInfo() - info.SetIcon(wx.Icon(orpg.dirpath.dir_struct["icon"]+'splash.gif', wx.BITMAP_TYPE_GIF)) + info.SetIcon(wx.Icon(dir_struct["icon"]+'splash.gif', wx.BITMAP_TYPE_GIF)) info.SetName('Traipse') info.SetVersion('OpenRPG ' + VERSION) info.SetDescription(description) @@ -595,14 +586,17 @@ info.AddDeveloper(dev) wx.AboutBox(info) + @debugging def OnMB_HelpOnlineUserGuide(self): wb = webbrowser.get() wb.open("https://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_dev?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") @@ -611,47 +605,58 @@ ################################# ## Build the GUI ################################# + @debugging def build_gui(self): - self.log.log("Enter orpgFrame->build_gui()", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->build_gui()", ORPG_DEBUG) self.Freeze() self.validate.config_file("layout.xml","default_layout.xml") - filename = orpg.dirpath.dir_struct["user"] + "layout.xml" + + filename = dir_struct["user"] + "layout.xml" temp_file = open(filename) txt = temp_file.read() xml_dom = self.xml.parseXml(txt)._get_documentElement() temp_file.close() + + """ 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 = {} #Plugins Window self.pluginsFrame = pluginUI.PluginFrame(self) - open_rpg.add_component("plugins", self.get_activeplugins()) - open_rpg.add_component("startplugs", self.get_startplugins()) - self.log.log("Menu Created", ORPG_DEBUG) + component.add("plugins", self.get_activeplugins()) + component.add("startplugs", self.get_startplugins()) + self.orpgLog.log("Menu Created", ORPG_DEBUG) 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")) self.SetDimensions(posx, posy, w, h) - self.log.log("Dimensions Set", ORPG_DEBUG) + logger.debug("Dimensions Set") #Update Manager self.manifest = manifest.ManifestChanges() self.updateMana = upmana.updatemana.updaterFrame(self, - "OpenRPG Update Manager Beta 0.7.2", open_rpg, self.manifest, True) - self.log.log("Menu Created", ORPG_DEBUG) + "OpenRPG Update Manager Beta 0.7.2", component, self.manifest, True) + self.orpgLog.log("Menu Created", ORPG_DEBUG) 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")) self.SetDimensions(posx, posy, w, h) - self.log.log("Dimensions Set", ORPG_DEBUG) + logger.debug("Dimensions Set") # Sound Manager self.sound_player = orpg.tools.orpg_sound.orpgSound(self) - open_rpg.add_component("sound", self.sound_player) + component.add("sound", self.sound_player) wndinfo = AUI.AuiPaneInfo() menuid = wx.NewId() self.mainwindows[menuid] = "Sound Control Toolbar" @@ -677,7 +682,7 @@ wndinfo.ToolbarPane() wndinfo.Hide() self._mgr.AddPane(self.status, wndinfo) - self.log.log("Status Window Created", ORPG_DEBUG) + logger.debug("Status Window Created") # Create and show the floating dice toolbar self.dieToolBar = orpg.tools.toolBars.DiceToolBar(self, callBack = self.chat.ParsePost) @@ -691,7 +696,7 @@ wndinfo.ToolbarPane() wndinfo.Hide() self._mgr.AddPane(self.dieToolBar, wndinfo) - self.log.log("Dice Tool Bar Created", ORPG_DEBUG) + logger.debug("Dice Tool Bar Created") #Create the Map tool bar self.mapToolBar = orpg.tools.toolBars.MapToolBar(self, callBack = self.map.MapBar) @@ -705,7 +710,7 @@ wndinfo.ToolbarPane() wndinfo.Hide() self._mgr.AddPane(self.mapToolBar, wndinfo) - self.log.log("Map Tool Bar Created", ORPG_DEBUG) + logger.debug("Map Tool Bar Created") #Create the Browse Server Window self.gs = orpg.networking.gsclient.game_server_panel(self) @@ -718,23 +723,23 @@ wndinfo.MinSize(wx.Size(640,480)) wndinfo.Hide() self._mgr.AddPane(self.gs, wndinfo) - self.log.log("Game Server Window Created", ORPG_DEBUG) + logger.debug("Game Server Window Created") #Create the Alias Lib Window self.aliaslib = orpg.tools.aliaslib.AliasLib() self.aliaslib.Hide() - self.log.log("Alias Window Created", ORPG_DEBUG) + logger.debug("Alias Window Created") menuid = wx.NewId() self.windowsmenu.Append(menuid, "Alias Lib", kind=wx.ITEM_CHECK) self.windowsmenu.Check(menuid, False) self.Bind(wx.EVT_MENU, self.OnMB_WindowsMenu, id=menuid) self.mainwindows[menuid] = "Alias Lib" self.mainmenu.Insert(3, self.windowsmenu, 'Windows') - self.log.log("Windows Menu Done", ORPG_DEBUG) + logger.debug("Windows Menu Done") self._mgr.Update() if wx.VERSION_STRING > "2.8": self.Bind(AUI.EVT_AUI_PANE_CLOSE, self.onPaneClose) else: self.Bind(AUI.EVT_AUI_PANECLOSE, self.onPaneClose) - self.log.log("AUI Bindings Done", ORPG_DEBUG) + logger.debug("AUI Bindings Done") #Load the layout if one exists layout = xml_dom.getElementsByTagName("DockLayout") @@ -743,30 +748,35 @@ self._mgr.LoadPerspective(textnode._get_nodeValue()) except: pass xml_dom.unlink() - self.log.log("Perspective Loaded", ORPG_DEBUG) + self.orpgLog.log("Perspective Loaded", ORPG_DEBUG) self._mgr.GetPane("Browse Server Window").Hide() self._mgr.Update() self.Maximize(maximized) - self.log.log("GUI is all created", ORPG_DEBUG) + self.orpgLog.log("GUI is all created", ORPG_DEBUG) self.Thaw() - self.log.log("Exit orpgFrame->build_gui()", ORPG_DEBUG) + @debugging def do_tab_window(self,xml_dom,parent_wnd): - self.log.log("Enter orpgFrame->do_tab_window(self,xml_dom,parent_wnd)", ORPG_DEBUG) - + #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() for c in children: wnd = self.build_window(c,temp_wnd) name = c.getAttribute("name") temp_wnd.AddPage(wnd, name, False) - self.log.log("Exit orpgFrame->do_tab_window(self,xml_dom,parent_wnd)", ORPG_DEBUG) + + """ + 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() - self.log.log("Enter orpgFrame->build_window(" + name + ")", ORPG_DEBUG) if name == "DockLayout" or name == "dock": return dir = xml_dom.getAttribute("direction") pos = xml_dom.getAttribute("pos") @@ -836,11 +846,12 @@ wndinfo.Position(int(pos)) wndinfo.Show() self._mgr.AddPane(temp_wnd, wndinfo) - self.log.log("Exit orpgFrame->build_window(" + name + ")", ORPG_DEBUG) + self.orpgLog.log("Exit orpgFrame->build_window(" + name + ")", ORPG_DEBUG) return temp_wnd + @debugging def onPaneClose(self, evt): - self.log.log("Enter orpgFrame->onPaneClose()", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->onPaneClose()", ORPG_DEBUG) pane = evt.GetPane() #Arbitrary If ELIF fix. Items had incorrect ID's set. Finding correct ID will fix it for the iteration. #Adding ID also fixed docking. Go figure. @@ -854,11 +865,12 @@ if pane.name == wname: self.windowsmenu.Check(wndid, False); break evt.Skip() self._mgr.Update() - self.log.log("Exit orpgFrame->onPaneClose()", ORPG_DEBUG) + self.orpgLog.log("Exit orpgFrame->onPaneClose()", ORPG_DEBUG) + @debugging def saveLayout(self): - self.log.log("Enter orpgFrame->saveLayout()", ORPG_DEBUG) - filename = orpg.dirpath.dir_struct["user"] + "layout.xml" + self.orpgLog.log("Enter orpgFrame->saveLayout()", ORPG_DEBUG) + filename = dir_struct["user"] + "layout.xml" temp_file = open(filename) txt = temp_file.read() xml_dom = self.xml.parseXml(txt)._get_documentElement() @@ -885,47 +897,53 @@ temp_file = open(filename, "w") temp_file.write(xml_dom.toxml(1)) temp_file.close() - self.log.log("Exit saveLayout()", ORPG_DEBUG) + self.orpgLog.log("Exit saveLayout()", ORPG_DEBUG) + @debugging def build_hotkeys(self): - self.log.log("Enter orpgFrame->build_hotkeys(self)", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->build_hotkeys(self)", ORPG_DEBUG) self.mainmenu.accel.xaccel.extend(self.chat.get_hot_keys()) self.mainmenu.accel.xaccel.extend(self.map.get_hot_keys()) - self.log.log("Exit orpgFrame->build_hotkeys(self)", ORPG_DEBUG) + self.orpgLog.log("Exit orpgFrame->build_hotkeys(self)", ORPG_DEBUG) + @debugging def start_timer(self): - self.log.log("Enter orpgFrame->start_timer(self)", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->start_timer(self)", ORPG_DEBUG) self.poll_timer.Start(100) - s = open_rpg.get_component('settings') + s = component.get('settings') if s.get_setting("Heartbeat") == "1": self.ping_timer.Start(1000*60) - self.log.log("starting heartbeat...", ORPG_DEBUG, True) - self.log.log("Exit orpgFrame->start_timer(self)", ORPG_DEBUG) + self.orpgLog.log("starting heartbeat...", ORPG_DEBUG, True) + self.orpgLog.log("Exit orpgFrame->start_timer(self)", ORPG_DEBUG) + @debugging def kill_mplay_session(self): - self.log.log("Enter orpgFrame->kill_mplay_session(self)", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->kill_mplay_session(self)", ORPG_DEBUG) self.game_name = "" self.session.start_disconnect() - self.log.log("Exit orpgFrame->kill_mplay_session(self)", ORPG_DEBUG) + self.orpgLog.log("Exit orpgFrame->kill_mplay_session(self)", ORPG_DEBUG) + @debugging def quit_game(self, evt): - self.log.log("Enter orpgFrame->quit_game(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->quit_game(self, evt)", ORPG_DEBUG) dlg = wx.MessageDialog(self,"Exit gaming session?","Game Session",wx.YES_NO) if dlg.ShowModal() == wx.ID_YES: self.session.exitCondition.notifyAll() dlg.Destroy() self.kill_mplay_session() - self.log.log("Exit orpgFrame->quit_game(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit orpgFrame->quit_game(self, evt)", ORPG_DEBUG) + @debugging def on_status_event(self, evt): - self.log.log("Enter orpgFrame->on_status_event(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->on_status_event(self, evt)", ORPG_DEBUG) id = evt.get_id() status = evt.get_data() if id == orpg.networking.mplay_client.STATUS_SET_URL: self.status.set_url(status) - self.log.log("Exit orpgFrame->on_status_event(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit orpgFrame->on_status_event(self, evt)", ORPG_DEBUG) + @debugging def on_player_event(self, evt): - self.log.log("Enter orpgFrame->on_player_event(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->on_player_event(self, evt)", ORPG_DEBUG) id = evt.get_id() player = evt.get_data() display_name = self.chat.chat_display_name(player) @@ -939,10 +957,11 @@ elif id == orpg.networking.mplay_client.PLAYER_UPDATE: self.players.update_player(player) self.players.Refresh() - self.log.log("Exit orpgFrame->on_player_event(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit orpgFrame->on_player_event(self, evt)", ORPG_DEBUG) + @debugging def on_group_event(self, evt): - self.log.log("Enter orpgFrame->on_group_event(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->on_group_event(self, evt)", ORPG_DEBUG) id = evt.get_id() data = evt.get_data() @@ -951,15 +970,16 @@ self.password_manager.RemoveGroupData(data) self.gs.del_room(data) elif id == orpg.networking.mplay_client.GROUP_UPDATE: self.gs.update_room(data) - self.log.log("Exit orpgFrame->on_group_event(self, evt)", ORPG_DEBUG) + self.orpgLog.log("Exit orpgFrame->on_group_event(self, evt)", ORPG_DEBUG) + @debugging def on_receive(self, data, player): - self.log.log("Enter orpgFrame->on_receive(self, data, player)", ORPG_DEBUG) + self.orpgLog.log("Enter orpgFrame->on_receive(self, data, player)", ORPG_DEBUG) # see if we are ignoring this user (ignore_id,ignore_name) = self.session.get_ignore_list() for m in ignore_id: - if m == player[2]: self.log.log("ignoring message from player:" + player[0], ORPG_INFO, True); return + 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 @@ -969,7 +989,6 @@ if data[:5] == "" for the font within the first 22 values + """ + 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 + """ + 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 @@ -1012,11 +1045,9 @@ if player: data = "" + display_name + ": " + data else: data = "" + display_name + "-> " + data self.chat.Post(data) - self.log.log("Exit orpgFrame->on_receive(self, data, player)", ORPG_DEBUG) + @debugging def on_mplay_event(self, evt): - self.log.log("Enter orpgFrame->on_mplay_event(self, evt)", ORPG_DEBUG) - id = evt.get_id() if id == orpg.networking.mplay_client.MPLAY_CONNECTED: self.chat.InfoPost("Game connected!") @@ -1033,7 +1064,7 @@ ####Begin changes for Custom Exit Message by mDuo13###### elif id == orpg.networking.mplay_client.MPLAY_DISCONNECTING: - settings = open_rpg.get_component('settings') + settings = component.get('settings') custom_msg = settings.get_setting("dcmsg") custom_msg=custom_msg[:80] if custom_msg[:3]=="/me": self.chat.send_chat_message(custom_msg[3:], 3) @@ -1047,19 +1078,17 @@ self.players.reset() elif id== orpg.networking.mplay_client.MPLAY_GROUP_CHANGE_F: self.chat.SystemPost("Room access denied!") - self.log.log("Exit orpgFrame->on_mplay_event(self, evt)", ORPG_DEBUG) + @debugging def OnCloseWindow(self, event): - self.log.log("Enter orpgFrame->OnCloseWindow(self, event)", ORPG_DEBUG) dlg = wx.MessageDialog(self, "Quit OpenRPG?", "OpenRPG", wx.YES_NO) if dlg.ShowModal() == wx.ID_YES: dlg.Destroy() self.closed_confirmed() - self.log.log("Exit orpgFrame->OnCloseWindow(self, event)", ORPG_DEBUG) + @debugging def closed_confirmed(self): - self.log.log("Enter orpgFrame->closed_confirmed(self)", ORPG_DEBUG) - self.activeplugins = open_rpg.get_component('plugins') + self.activeplugins = component.get('plugins') self.aliaslib.OnMB_FileSave(None) #following lines added by mDuo13 @@ -1068,22 +1097,23 @@ plugin = self.activeplugins[plugin_fname] try: plugin.plugin_disabled() except Exception, e: - if str(e) != "'module' object has no attribute 'plugin_disabled'": - #print e traceback.print_exc() #end mDuo13 added code self.saveLayout() try: self.settings.save() - except: self.log.log("[WARNING] Error saving 'settings' component", ORPG_GENERAL, True) + except Exception: + logger.general("[WARNING] Error saving 'settings' component", True) try: self.map.pre_exit_cleanup() - except: self.log.log("[WARNING] Map error pre_exit_cleanup()", ORPG_GENERAL, True) + except Exception: + logger.general("[WARNING] Map error pre_exit_cleanup()", True) try: save_tree = string.upper(self.settings.get_setting("SaveGameTreeOnExit")) if (save_tree != "0") and (save_tree != "False") and (save_tree != "NO"): self.tree.save_tree(self.settings.get_setting("gametree")) - except: self.log.log("[WARNING] Error saving gametree", ORPG_GENERAL, True) + except Exception: + logger.general("[WARNING] Error saving gametree", True) if self.session.get_status() == orpg.networking.mplay_client.MPLAY_CONNECTED: self.kill_mplay_session() @@ -1091,7 +1121,8 @@ #Kill all the damn timers self.sound_player.timer.Stop() del self.sound_player.timer - except: self.log.log("sound didn't die properly.",ORPG_GENERAL, True) + except Exception: + logger.general("sound didn't die properly.", True) try: self.poll_timer.Stop() @@ -1102,7 +1133,9 @@ self.status.timer.Stop() del self.ping_timer; del self.poll_timer; del self.chat.parent.chat_timer del self.map.canvas.zoom_display_timer; del self.map.canvas.image_timer; del self.status.timer - except: self.log.log("some timer didn't die properly.",ORPG_GENERAL, True) + except Exception: + logger.general("some timer didn't die properly.", True) + self._mgr.UnInit() mainapp = wx.GetApp() mainapp.ExitMainLoop() @@ -1114,22 +1147,23 @@ dlg.Update(2) dlg.Show(True) self.server_pipe.write("\nkill\n") - self.log.log("Killing Server process:", ORPG_GENERAL, True) + logger.general("Killing Server process:", True) time.sleep(5) self.server_stop() self.server_pipe.close() self.std_out.close() self.server_thread.exit() dlg.Destroy() - self.log.log("Server killed:", ORPG_GENERAL, True) - except: pass - self.log.log("Exit orpgFrame->closed_confirmed(self)", ORPG_DEBUG) + logger.general("Server killed:", True) + except Exception: + pass ######################################## ## 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) @@ -1138,35 +1172,36 @@ self.Bind(wx.EVT_CLOSE, self.callback) class orpgApp(wx.App): + @debugging def OnInit(self): - self.log = orpg.tools.orpg_log.orpgLog(orpg.dirpath.dir_struct["user"] + "runlogs/") - self.log.setLogToConsol(False) - self.log.log("Main Application Start", ORPG_DEBUG) + + component.add('log', logger) + component.add('xml', xml) + #component.add('settings', settings) + component.add('validate', validate) + component.add("tabbedWindows", []) + self.manifest = manifest.ManifestChanges() - #Add the initial global components of the openrpg class - #Every class should be passed openrpg - open_rpg.add_component("log", self.log) - open_rpg.add_component("xml", orpg.orpg_xml) - open_rpg.add_component("dir_struct", orpg.dirpath.dir_struct) - open_rpg.add_component("tabbedWindows", []) - self.validate = orpg.tools.validate.Validate() - open_rpg.add_component("validate", self.validate) - self.settings = orpg.tools.orpg_settings.orpgSettings() - open_rpg.add_component("settings", self.settings) - self.log.setLogLevel(int(self.settings.get_setting('LoggingLevel'))) + + self.orpgLog = component.get('log') + self.validate = component.get('validate') + self.settings = component.get('settings') + logger.log_level = int(self.settings.get_setting('LoggingLevel')) self.called = False wx.InitAllImageHandlers() - self.splash = orpgSplashScreen(None, orpg.dirpath.dir_struct["icon"] + 'splash13.jpg', 3000, self.AfterSplash) + self.splash = orpgSplashScreen(None, dir_struct["icon"] + 'splash13.jpg', 3000, self.AfterSplash) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) self._crust = None 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: @@ -1176,6 +1211,7 @@ self._crust.shell.interp.locals['win'] = win self._crust.Show() + @debugging def AfterSplash(self,evt): if not self.called: self.splash.Hide() @@ -1190,8 +1226,9 @@ wx.CallAfter(self.splash.Close) return True + @debugging def OnExit_CleanUp(self): - self.log.log("Preforming cleanup\n", ORPG_DEBUG) + self.orpgLog.log("Preforming cleanup\n", ORPG_DEBUG) try: del os.environ["OPENRPG_BASE"] except: pass try: os.remove(os.environ["OPENRPG_BASE"] + os.sep + 'orpg' + os.sep + 'dirpath' + os.sep + 'approot.py') @@ -1199,7 +1236,8 @@ 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 - self.log.log("Main Application Exit\n\n", ORPG_DEBUG) + self.orpgLog.log("Main Application Exit\n\n", ORPG_DEBUG) diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/background_handler.py --- a/orpg/mapper/background_handler.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/background_handler.py Tue Aug 18 06:33:37 2009 -0500 @@ -86,10 +86,10 @@ thread.start_new_thread(self.canvas.layers['bg'].upload, (postdata, dlg.GetPath(), self.bg_type.GetStringSelection())) else: - try: min_url = open_rpg.get_component("cherrypy") + filename + try: min_url = component.get("cherrypy") + filename except: return min_url = dlg.GetDirectory().replace(orpg.dirpath.dir_struct["user"]+'webfiles' + os.sep, - open_rpg.get_component("cherrypy")) + '/' + filename + component.get("cherrypy")) + '/' + filename if self.bg_type.GetStringSelection() == 'Texture': self.canvas.layers['bg'].set_texture(min_url) elif self.bg_type.GetStringSelection() == 'Image': self.size = self.canvas.layers['bg'].set_image(min_url,1) @@ -138,7 +138,7 @@ def on_apply(self, evt): session=self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.use_roles()): - open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature") + component.get("chat").InfoPost("You must be a GM to use this feature") return self.canvas.layers['bg'].set_color(self.color_button.GetBackgroundColour()) diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/base_handler.py --- a/orpg/mapper/base_handler.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/base_handler.py Tue Aug 18 06:33:37 2009 -0500 @@ -30,7 +30,7 @@ from orpg.orpg_windows import * -from orpg.orpgCore import open_rpg +from orpg.orpgCore import component class base_layer_handler(wx.Panel): @@ -39,7 +39,7 @@ self.canvas = canvas self.map_frame = self.canvas.frame self.top_frame = self.canvas.frame.top_frame - self.chat = open_rpg.get_component("chat") + self.chat = component.get("chat") self.build_ctrls() self.build_menu() #self.Bind(wx.EVT_SIZE, self.on_size) diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/fog_handler.py --- a/orpg/mapper/fog_handler.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/fog_handler.py Tue Aug 18 06:33:37 2009 -0500 @@ -71,7 +71,7 @@ def on_remove(self,evt): session=self.canvas.frame.session if (session.my_role() != session.ROLE_GM): - open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature") + component.get("chat").InfoPost("You must be a GM to use this feature") return self.canvas.layers['fog'].remove_fog() self.canvas.Refresh(False) @@ -79,7 +79,7 @@ def on_showall(self,evt): session=self.canvas.frame.session if (session.my_role() != session.ROLE_GM): - open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature") + component.get("chat").InfoPost("You must be a GM to use this feature") return foglayer = self.canvas.layers['fog'] foglayer.showall() @@ -99,7 +99,7 @@ def on_hideall(self,evt): session=self.canvas.frame.session if (session.my_role() != session.ROLE_GM): - open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature") + component.get("chat").InfoPost("You must be a GM to use this feature") return foglayer=self.canvas.layers['fog'] foglayer.clear() @@ -108,7 +108,7 @@ def on_color(self,evt): session=self.canvas.frame.session if (session.my_role() != session.ROLE_GM): - open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature") + component.get("chat").InfoPost("You must be a GM to use this feature") return data = wx.ColourData() data.SetChooseFull(True) @@ -158,7 +158,7 @@ if self.drawing == True: session=self.canvas.frame.session if (session.my_role() != session.ROLE_GM): - open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature") + component.get("chat").InfoPost("You must be a GM to use this feature") else: # This code sets the mode to either new or del # depending on the action to function with the updated createregen code. diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/grid_handler.py --- a/orpg/mapper/grid_handler.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/grid_handler.py Tue Aug 18 06:33:37 2009 -0500 @@ -89,7 +89,7 @@ def on_apply(self, evt): session=self.canvas.frame.session if (session.my_role() != session.ROLE_GM): - open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature") + component.get("chat").InfoPost("You must be a GM to use this feature") return self.canvas.layers['grid'].set_grid(int(self.grid_size.GetValue()),self.grid_snap.GetValue(), diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/images.py --- a/orpg/mapper/images.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/images.py Tue Aug 18 06:33:37 2009 -0500 @@ -34,6 +34,7 @@ import time from orpg.orpg_wx import * from orpg.orpgCore import * +from orpg.dirpath import dir_struct def singleton(cls): instances = {} @@ -59,7 +60,7 @@ thread.start_new_thread(self.__loadThread, (path, image_type, imageId)) else: if self.__fetching[path] is True: thread.start_new_thread(self.__loadCacheThread, (path, image_type, imageId)) - return wx.Bitmap(open_rpg.get_component("dir_struct")["icon"] + "fetching.png", wx.BITMAP_TYPE_PNG) + return wx.Bitmap(dir_struct["icon"] + "fetching.png", wx.BITMAP_TYPE_PNG) def directLoad(self, path): # Directly load an image, no threads @@ -74,17 +75,17 @@ self.__cache[path] = (path, d[0], d[1].gettype(), None) return wx.ImageFromMime(self.__cache[path][1], self.__cache[path][2]).ConvertToBitmap() else: - open_rpg.get_component('log').log("Image refused to load or URI did not reference a valid image: " + path, + component.get('log').log("Image refused to load or URI did not reference a valid image: " + path, ORPG_GENERAL, True) return None except IOError: - open_rpg.get_component('log').log("Unable to resolve/open the specified URI; image was NOT loaded: " + path, + component.get('log').log("Unable to resolve/open the specified URI; image was NOT loaded: " + path, ORPG_GENERAL, True) return None def cleanCache(self): # Shrinks the Cache down to the proper size - try: cacheSize = int(open_rpg.get_component('settings').get_setting("ImageCacheSize")) + try: cacheSize = int(component.get('settings').get_setting("ImageCacheSize")) except: cacheSize = 32 cache = self.__cache.keys() cache.sort() @@ -99,7 +100,7 @@ finally: self.__lock.release() urllib.urlcleanup() -#Private Methods + #Private Methods def __loadThread(self, path, image_type, imageId): uriPath = urllib.unquote(path) self.__lock.acquire() @@ -112,12 +113,12 @@ self.__queue.put((self.__cache[path], image_type, imageId)) if self.__fetching.has_key(path): del self.__fetching[path] else: - open_rpg.get_component('log').log("Image refused to load or URI did not reference a valid image: " + path, + component.get('log').log("Image refused to load or URI did not reference a valid image: " + path, ORPG_GENERAL, True) del self.__fetching[path] except IOError: del self.__fetching[path] - open_rpg.get_component('log').log("Unable to resolve/open the specified URI; image was NOT laoded: " + path, + component.get('log').log("Unable to resolve/open the specified URI; image was NOT laoded: " + path, ORPG_GENERAL, True) finally: self.__lock.release() @@ -128,26 +129,26 @@ while self.__fetching.has_key(path) and self.__fetching[path] is not False: time.sleep(0.025) if (time.time()-st) > 120: - open_rpg.get_component('log').log("Timeout: " + path, ORPG_GENERAL, True) + component.get('log').log("Timeout: " + path, ORPG_GENERAL, True) break except: del self.__fetching[path] - open_rpg.get_component('log').log("Unable to resolve/open the specified URI; image was NOT loaded: " + path, ORPG_GENERAL, True) + component.get('log').log("Unable to resolve/open the specified URI; image was NOT loaded: " + path, ORPG_GENERAL, True) return self.__lock.acquire() try: - open_rpg.get_component('log').log("Adding Image to Queue from Cache: " + str(self.__cache[path]), ORPG_DEBUG) + component.get('log').log("Adding Image to Queue from Cache: " + str(self.__cache[path]), ORPG_DEBUG) self.__queue.put((self.__cache[path], image_type, imageId)) finally: self.__lock.release() -#Property Methods + #Property Methods def _getCache(self): return self.__cache def _getQueue(self): return self.__queue -#Properties + #Properties Cache = property(_getCache) Queue = property(_getQueue) diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/map.py --- a/orpg/mapper/map.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/map.py Tue Aug 18 06:33:37 2009 -0500 @@ -31,7 +31,7 @@ from map_msg import * from min_dialogs import * from map_prop_dialog import * -import orpg.dirpath +from orpg.dirpath import dir_struct import random import os import thread @@ -44,7 +44,7 @@ from images import ImageHandler from grid_handler import * from map_handler import * -from orpg.orpgCore import open_rpg +from orpg.orpgCore import component # Various marker modes for player tools on the map MARKER_MODE_NONE = 0 @@ -55,10 +55,10 @@ class MapCanvas(wx.ScrolledWindow): def __init__(self, parent, ID, isEditor=0): self.parent = parent - self.log = open_rpg.get_component("log") + self.log = component.get("log") self.log.log("Enter MapCanvas", ORPG_DEBUG) - self.settings = open_rpg.get_component("settings") - self.session = open_rpg.get_component("session") + self.settings = component.get("settings") + self.session = component.get("session") wx.ScrolledWindow.__init__(self, parent, ID, style=wx.HSCROLL | wx.VSCROLL | wx.FULL_REPAINT_ON_RESIZE | wx.SUNKEN_BORDER ) self.frame = parent @@ -120,7 +120,7 @@ def processImages(self, evt=None): self.log.log("Enter MapCanvas->processImages(self)", ORPG_DEBUG) - self.session = open_rpg.get_component("session") + self.session = component.get("session") if self.session.my_role() == self.session.ROLE_LURKER or (str(self.session.group_id) == '0' and str(self.session.status) == '1'): cidx = self.parent.get_tab_index("Background") self.parent.layer_tabs.EnableTab(cidx, False) @@ -545,8 +545,8 @@ def on_left_up(self, evt): self.log.log("Enter MapCanvas->on_left_up(self, evt)", ORPG_DEBUG) if evt.ShiftDown(): self.on_tape_up(evt) - elif open_rpg.get_component("tree").dragging: - tree = open_rpg.get_component("tree") + elif component.get("tree").dragging: + tree = component.get("tree") if tree.drag_obj.map_aware(): tree.drag_obj.on_send_to_map(evt) tree.dragging = False @@ -557,7 +557,7 @@ def on_motion(self, evt): self.log.log("Enter MapCanvas->on_motion(self, evt)", ORPG_DEBUG) if evt.ShiftDown(): self.on_tape_motion(evt) - elif evt.LeftIsDown() and open_rpg.get_component("tree").dragging: pass + elif evt.LeftIsDown() and component.get("tree").dragging: pass else: self.frame.on_motion(evt) self.log.log("Exit MapCanvas->on_motion(self, evt)", ORPG_DEBUG) @@ -628,8 +628,8 @@ def on_prop(self, evt): self.log.log("Enter MapCanvas->on_prop(self, evt)", ORPG_DEBUG) - self.session = open_rpg.get_component("session") - self.chat = open_rpg.get_component("chat") + self.session = component.get("session") + self.chat = component.get("chat") if (self.session.my_role() != self.session.ROLE_GM): self.chat.InfoPost("You must be a GM to use this feature") self.log.log("Exit MapCanvas->on_prop(self, evt)", ORPG_DEBUG) @@ -806,14 +806,14 @@ class map_wnd(wx.Panel): def __init__(self, parent, id): - self.log = open_rpg.get_component('log') + self.log = component.get('log') self.log.log("Enter map_wnd", ORPG_DEBUG) wx.Panel.__init__(self, parent, id) self.canvas = MapCanvas(self, -1) - self.session = open_rpg.get_component('session') - self.settings = open_rpg.get_component('settings') - self.chat = open_rpg.get_component('chat') - self.top_frame = open_rpg.get_component('frame') + self.session = component.get('session') + self.settings = component.get('settings') + self.chat = component.get('chat') + self.top_frame = component.get('frame') self.root_dir = os.getcwd() self.current_layer = 2 self.layer_tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS) @@ -850,7 +850,7 @@ self.chat.InfoPost("You must be a GM to use this feature") self.log.log("Exit map_wnd->load_default(self)", ORPG_DEBUG) return - f = open(orpg.dirpath.dir_struct["template"] + "default_map.xml") + f = open(dir_struct["template"] + "default_map.xml") self.new_data(f.read()) f.close() self.canvas.send_map_data("new") @@ -870,7 +870,7 @@ self.chat.InfoPost("You must be a GM to use this feature") self.log.log("Exit map_wnd->new_data(self, data)", ORPG_DEBUG) return - d = wx.FileDialog(self.GetParent(), "Save map data", orpg.dirpath.dir_struct["user"], "", "*.xml", wx.SAVE) + d = wx.FileDialog(self.GetParent(), "Save map data", dir_struct["user"], "", "*.xml", wx.SAVE) if d.ShowModal() == wx.ID_OK: f = open(d.GetPath(), "w") data = '' @@ -889,7 +889,7 @@ self.chat.InfoPost("You must be a GM to use this feature") self.log.log("Exit map_wnd->on_open(self, evt)", ORPG_DEBUG) return - d = wx.FileDialog(self.GetParent(), "Select a file", orpg.dirpath.dir_struct["user"], "", "*.xml", wx.OPEN) + d = wx.FileDialog(self.GetParent(), "Select a file", dir_struct["user"], "", "*.xml", wx.OPEN) if d.ShowModal() == wx.ID_OK: f = open(d.GetPath()) map_string = f.read() diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/map_handler.py --- a/orpg/mapper/map_handler.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/map_handler.py Tue Aug 18 06:33:37 2009 -0500 @@ -65,7 +65,7 @@ def on_apply(self, evt): session=self.canvas.frame.session if (session.my_role() != session.ROLE_GM): - open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature") + component.get("chat").InfoPost("You must be a GM to use this feature") return try: size = (int(self.width.GetValue()),int(self.height.GetValue())) except: wx.MessageBox("Invalid Map Size!","Map Properties"); return diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/min_dialogs.py --- a/orpg/mapper/min_dialogs.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/min_dialogs.py Tue Aug 18 06:33:37 2009 -0500 @@ -151,7 +151,7 @@ else: node_begin += "Unnamed Miniature'" node_begin += ">" - gametree = open_rpg.get_component('tree') + gametree = component.get('tree') node_xml = node_begin + min_xml + '' print "Sending this XML to insert_xml:" + node_xml gametree.insert_xml(node_xml) diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/miniatures.py diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/miniatures_handler.py --- a/orpg/mapper/miniatures_handler.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/miniatures_handler.py Tue Aug 18 06:33:37 2009 -0500 @@ -164,10 +164,10 @@ y = dc.DeviceToLogicalY(0) thread.start_new_thread(self.canvas.layers['miniatures'].upload, (postdata, dlg.GetPath()), {'pos':cmpPoint(x,y)}) else: - try: min_url = open_rpg.get_component("cherrypy") + filename + try: min_url = component.get("cherrypy") + filename except: return min_url = dlg.GetDirectory().replace(orpg.dirpath.dir_struct["user"]+'webfiles' + os.sep, - open_rpg.get_component("cherrypy")) + '/' + filename + component.get("cherrypy")) + '/' + filename # build url if min_url == "" or min_url == "http://": return if min_url[:7] != "http://": min_url = "http://" + min_url @@ -355,7 +355,7 @@ if self.sel_rmin.label: node_begin += self.sel_rmin.label + "'" else: node_begin += "Unnamed Miniature'" node_begin += ">" - gametree = open_rpg.get_component('tree') + gametree = component.get('tree') node_xml = node_begin + min_xml + '' #print "Sending this XML to insert_xml:" + node_xml gametree.insert_xml(str(node_xml)) @@ -746,7 +746,7 @@ ## helper functions def infoPost(self, message): - open_rpg.get_component("chat").InfoPost(message) + component.get("chat").InfoPost(message) def role_is_gm_or_player(self): session = self.canvas.frame.session diff -r 4840657c23c5 -r c54768cffbd4 orpg/mapper/whiteboard_handler.py --- a/orpg/mapper/whiteboard_handler.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/mapper/whiteboard_handler.py Tue Aug 18 06:33:37 2009 -0500 @@ -261,7 +261,7 @@ def undo_line(self,evt): session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.use_roles()): - self.top_frame.openrpg.get_component("chat").InfoPost("You must be a GM to use this feature") + self.top_frame.openrpg.get("chat").InfoPost("You must be a GM to use this feature") return self.canvas.layers['whiteboard'].undo_line() dc = self.create_dc() @@ -272,7 +272,7 @@ def delete_all_lines(self,evt): session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.use_roles()): - open_rpg.get_component("chat").InfoPost("You must be a GM to use this feature") + component.get("chat").InfoPost("You must be a GM to use this feature") return dlg = wx.MessageDialog(self, "Are you sure you want to delete all lines?","Delete All Lines",wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) if dlg.ShowModal() != wx.ID_YES: return @@ -436,7 +436,7 @@ #check to role to make sure user can draw at all.... session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.my_role()!=session.ROLE_PLAYER) and (session.use_roles()): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use this feature") + component.get("chat").InfoPost("You must be either a player or GM to use this feature") self.canvas.Refresh(False) else: line = self.canvas.layers['whiteboard'].add_line(self.line_string,self.upperleft,self.lowerright) #resetting variables for next line @@ -472,7 +472,7 @@ #check to role to make sure user can draw at all.... session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.my_role()!=session.ROLE_PLAYER) and (session.use_roles()): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use this feature") + component.get("chat").InfoPost("You must be either a player or GM to use this feature") self.canvas.Refresh(False) else: line = self.canvas.layers['whiteboard'].add_line(self.line_string,self.upperleft,self.lowerright) #resetting variables for next line @@ -566,7 +566,7 @@ self.drawing = False session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.my_role()!=session.ROLE_PLAYER) and (session.use_roles()): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use this feature") + component.get("chat").InfoPost("You must be either a player or GM to use this feature") self.canvas.Refresh(False) return #self.id +=1 @@ -584,7 +584,7 @@ def on_text_left_down(self, evt): session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.my_role()!=session.ROLE_PLAYER) and (session.use_roles()): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use this feature") + component.get("chat").InfoPost("You must be either a player or GM to use this feature") self.canvas.Refresh(False) return scale = self.canvas.layers['grid'].mapscale @@ -618,7 +618,7 @@ def on_text_right_down(self, evt, dc): session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.my_role()!=session.ROLE_PLAYER) and (session.use_roles()): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use this feature") + component.get("chat").InfoPost("You must be either a player or GM to use this feature") self.canvas.Refresh(False) return pos = evt.GetLogicalPosition(dc) @@ -632,7 +632,7 @@ def on_start_cone(self, evt): session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.my_role()!=session.ROLE_PLAYER) and (session.use_roles()): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use this feature") + component.get("chat").InfoPost("You must be either a player or GM to use this feature") self.canvas.Refresh(False) return self.cone_start = self.get_snapped_to_logical_pos(evt) @@ -748,7 +748,7 @@ def draw_temporary_circle(self, evt): session = self.canvas.frame.session if (session.my_role() != session.ROLE_GM) and (session.my_role()!=session.ROLE_PLAYER) and (session.use_roles()): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use this feature") + component.get("chat").InfoPost("You must be either a player or GM to use this feature") self.canvas.Refresh(False) return pos = self.get_snapped_to_logical_pos(evt) diff -r 4840657c23c5 -r c54768cffbd4 orpg/networking/gsclient.py --- a/orpg/networking/gsclient.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/networking/gsclient.py Tue Aug 18 06:33:37 2009 -0500 @@ -28,13 +28,13 @@ __version__ = "$Id: gsclient.py,v 1.53 2007/10/25 21:49:34 digitalxero Exp $" -import orpg.dirpath +from orpg.dirpath import dir_struct from orpg.orpg_windows import * -from orpg.orpg_xml import * +#from orpg.orpg_xml import * import meta_server_lib import orpg.tools.orpg_settings import orpg.tools.rgbhex -from orpg.orpgCore import open_rpg +from orpg.orpgCore import component import traceback gs_host = 1 @@ -99,13 +99,13 @@ def __init__(self,parent): wx.Panel.__init__(self, parent, -1) self.parent = parent - self.log = open_rpg.get_component('log') + self.log = component.get('log') self.log.log("Enter game_server_panel", ORPG_DEBUG) - self.password_manager = open_rpg.get_component('password_manager') # passtool --SD 8/03 - self.frame = open_rpg.get_component('frame') - self.session = open_rpg.get_component('session') - self.settings = open_rpg.get_component('settings') - self.xml = open_rpg.get_component('xml') + self.password_manager = component.get('password_manager') # passtool --SD 8/03 + self.frame = component.get('frame') + self.session = component.get('session') + self.settings = component.get('settings') + self.xml = component.get('xml') self.serverNameSet = 0 self.last_motd = "" self.buttons = {} @@ -570,7 +570,7 @@ def do_connect(self, address): self.log.log("Enter game_server_panel->do_connect(self, address)", ORPG_DEBUG) - chat = open_rpg.get_component('chat') + chat = component.get('chat') chat.InfoPost("Locating server at " + address + "...") if self.session.connect(address): self.frame.start_timer() diff -r 4840657c23c5 -r c54768cffbd4 orpg/networking/meta_server_lib.py --- a/orpg/networking/meta_server_lib.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/networking/meta_server_lib.py Tue Aug 18 06:33:37 2009 -0500 @@ -34,9 +34,8 @@ __version__ = "$Id: meta_server_lib.py,v 1.40 2007/04/04 01:18:42 digitalxero Exp $" from orpg.orpg_version import PROTOCOL_VERSION -from orpg.orpg_xml import * -import orpg.dirpath -import orpg.tools.validate +from orpg.orpgCore import * +from orpg.dirpath import dir_struct import urllib import orpg.minidom from threading import * @@ -79,7 +78,8 @@ print data print # build dom - xml_dom = parseXml(data) + xml = component.get('xml') + xml_dom = xml.parseXml(data) xml_dom = xml_dom._get_documentElement() return xml_dom @@ -198,17 +198,13 @@ # set them from current node - if not n.hasAttribute('name'): - n.setAttribute('name','NO_NAME_GIVEN') + if not n.hasAttribute('name'): n.setAttribute('name','NO_NAME_GIVEN') name = n.getAttribute('name') - if not n.hasAttribute('num_users'): - n.setAttribute('num_users','N/A') + if not n.hasAttribute('num_users'): n.setAttribute('num_users','N/A') num_users = n.getAttribute('num_users') - if not n.hasAttribute('address'): - n.setAttribute('address','NO_ADDRESS_GIVEN') + if not n.hasAttribute('address'): n.setAttribute('address','NO_ADDRESS_GIVEN') address = n.getAttribute('address') - if not n.hasAttribute('port'): - n.setAttribute('port','6774') + if not n.hasAttribute('port'): n.setAttribute('port','6774') port = n.getAttribute('port') n.setAttribute('meta',meta) end_point = str(address) + ":" + str(port) @@ -257,7 +253,7 @@ if META_DEBUG: print " Meta List ("+str(len(metas))+" servers)" try: metacache_lock.acquire() - ini = open(orpg.dirpath.dir_struct["user"]+"metaservers.cache","w") + ini = open(dir_struct["user"]+"metaservers.cache","w") for meta in metas: if META_DEBUG: print " Writing: "+str(meta.getAttribute('path')) ini.write(str(meta.getAttribute('path')) + " " + str(meta.getAttribute('versions')) + "\n") @@ -273,8 +269,8 @@ try: metacache_lock.acquire() # Read in the metas - orpg.tools.validate.Validate().config_file("metaservers.cache","metaservers.cache") - ini = open(orpg.dirpath.dir_struct["user"]+"metaservers.cache","r") + component.get('validate').config_file("metaservers.cache","metaservers.cache") + ini = open(dir_struct["user"]+"metaservers.cache","r") metas = ini.readlines() ini.close() return metas @@ -357,10 +353,11 @@ # get meta server URL url = "http://www.openrpg.com/openrpg_servers.php" try: - orpg.tools.validate.Validate().config_file("settings.xml","default_settings.xml") - ini = open(orpg.dirpath.dir_struct["user"]+"settings.xml","r") + component.get('validate').config_file("settings.xml","default_settings.xml") + ini = open(dir_struct["user"]+"settings.xml","r") txt = ini.read() - tree = parseXml(txt)._get_documentElement() + xml = component.get('xml') + tree = xml.parseXml(txt)._get_documentElement() ini.close() node_list = tree.getElementsByTagName("MetaServerBaseURL") if node_list: diff -r 4840657c23c5 -r c54768cffbd4 orpg/networking/mplay_client.py --- a/orpg/networking/mplay_client.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/networking/mplay_client.py Tue Aug 18 06:33:37 2009 -0500 @@ -29,7 +29,7 @@ __version__ = "$Id: mplay_client.py,v 1.71 2007/05/12 20:41:54 digitalxero Exp $" -import orpg.minidom +#import orpg.minidom import socket import Queue import thread @@ -38,22 +38,21 @@ from xml.sax.saxutils import escape from struct import pack, unpack, calcsize from string import * -from orpg.orpg_version import * +from orpg.orpg_version import CLIENT_STRING, PROTOCOL_VERSION, VERSION import errno import os import time +from orpg.orpgCore import * try: import bz2 cmpBZ2 = True -except: - cmpBZ2 = False +except: cmpBZ2 = False try: import zlib cmpZLIB = True -except: - cmpZLIB = False +except: cmpZLIB = False # This should be configurable @@ -83,7 +82,7 @@ def parseXml(data): "parse and return doc" #print data - doc = orpg.minidom.parseString(data) + doc = component.get('xml').parseXml(data) doc.normalize() return doc @@ -133,9 +132,6 @@ self.text_status = "Idle" self.statLock = Lock() self.useroles = 0 - self.ROLE_GM = "GM" - self.ROLE_PLAYER = "Player" - self.ROLE_LURKER = "Lurker" self.lastmessagetime = time.time() self.connecttime = time.time() @@ -176,15 +172,13 @@ try: if self.useCompression and self.compressionType != None: readMsg = self.compressionType.decompress(readMsg) - except: - pass + except: pass # Check the length of the message bytes = len( readMsg ) # Make sure we are still connected - if bytes == 0: - break + if bytes == 0: break else: # Pass along the message so it can be processed self.inbox.put( readMsg ) @@ -322,9 +316,10 @@ (self.name, self.ip, self.id, self.text_status, self.version, self.protocol_version, self.client_string,role) = player except Exception, e: print e - -# The IP field should really be deprecated as too many systems are NAT'd and/or behind firewalls for a -# client provided IP address to have much value. As such, we now label it as deprecated. + """ + The IP field should really be deprecated as too many systems are NAT'd and/or behind firewalls for a + client provided IP address to have much value. As such, we now label it as deprecated. + """ def toxml(self,action): xml_data = '") head = data[:end+1] msg = data[end+1:] - xml_dom = parseXml(head) + xml_dom = self.xml.parseXml(head) xml_dom = xml_dom._get_documentElement() tag_name = xml_dom._get_tagName() id = xml_dom.getAttribute("from") @@ -858,7 +851,7 @@ self.sendMsg( self.sock, self.toxml("new") ) data = self.recvMsg( self.sock ) # get new id and group_id - xml_dom = parseXml(data) + xml_dom = self.xml.parseXml(data) xml_dom = xml_dom._get_documentElement() self.id = xml_dom.getAttribute("id") self.group_id = xml_dom.getAttribute("group_id") @@ -913,3 +906,4 @@ self.unique_cookie += 1 return_str = self.id + "-" + str(self.unique_cookie) return return_str + diff -r 4840657c23c5 -r c54768cffbd4 orpg/networking/mplay_messaging.py --- a/orpg/networking/mplay_messaging.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/networking/mplay_messaging.py Tue Aug 18 06:33:37 2009 -0500 @@ -47,11 +47,11 @@ class messenger: def __init__(self, *args, **kwargs): - self.log = open_rpg.get_component("log") - self.xml = open_rpg.get_component("xml") - self.dir_struct = open_rpg.get_component("dir_struct") - self.validate = open_rpg.get_component("validate") - self.settings = open_rpg.get_component("settings") + self.log = component.get("log") + self.xml = component.get("xml") + self.dir_struct = component.get("dir_struct") + self.validate = component.get("validate") + self.settings = component.get("settings") if kwargs.has_key('isServer'): self.isServer = kwargs['isServer'] else: diff -r 4840657c23c5 -r c54768cffbd4 orpg/networking/mplay_server.py --- a/orpg/networking/mplay_server.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/networking/mplay_server.py Tue Aug 18 06:33:37 2009 -0500 @@ -45,7 +45,7 @@ from mplay_client import * from mplay_client import MPLAY_LENSIZE -import orpg.dirpath +from orpg.dirpath import dir_struct import orpg.tools.validate import gc import cgi @@ -98,7 +98,7 @@ f.close() else: - f = open(orpg.dirpath.dir_struct["template"] + "default_map.xml") + f = open(dir_struct["template"] + "default_map.xml") tree = f.read() f.close() @@ -249,7 +249,7 @@ self.boot_pwd = "" self.server_address = None # IP or Name of server to post to the meta. None means the meta will auto-detect it. self.defaultMessageFile = None - self.userPath = orpg.dirpath.dir_struct["user"] + self.userPath = dir_struct["user"] self.lobbyMapFile = "Lobby_map.xml" self.lobbyMessageFile = "LobbyMessage.html" self.banFile = "ban_list.xml" diff -r 4840657c23c5 -r c54768cffbd4 orpg/networking/mplay_server_gui.py --- a/orpg/networking/mplay_server_gui.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/networking/mplay_server_gui.py Tue Aug 18 06:33:37 2009 -0500 @@ -13,7 +13,7 @@ import sys import time import types -import orpg.dirpath +from orpg.dirpath import dir_struct import orpg.systempath from orpg.orpg_wx import * import webbrowser @@ -89,7 +89,7 @@ def __init__(self, owner ): """ Loads default configuration settings.""" - userPath = orpg.dirpath.dir_struct["user"] + userPath = dir_struct["user"] validate = orpg.tools.validate.Validate(userPath) validate.config_file( "server_ini.xml", "default_server_ini.xml" ) configDom = minidom.parse(userPath + 'server_ini.xml') @@ -150,9 +150,9 @@ self.main = main self.roomList = { 0 : "Lobby" } self._imageList = wx.ImageList( 16, 16, False ) - img = wx.Image(orpg.dirpath.dir_struct["icon"]+"player.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + img = wx.Image(dir_struct["icon"]+"player.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() self._imageList.Add( img ) - img = wx.Image(orpg.dirpath.dir_struct["icon"]+"player-whisper.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + img = wx.Image(dir_struct["icon"]+"player-whisper.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() self._imageList.Add( img ) self.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL ) @@ -296,8 +296,8 @@ def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size = (760, 560) ) - if wx.Platform == '__WXMSW__': icon = wx.Icon( orpg.dirpath.dir_struct["icon"]+'WAmisc9.ico', wx.BITMAP_TYPE_ICO ) - else: icon = wx.Icon( orpg.dirpath.dir_struct["icon"]+'connect.gif', wx.BITMAP_TYPE_GIF ) + if wx.Platform == '__WXMSW__': icon = wx.Icon( dir_struct["icon"]+'WAmisc9.ico', wx.BITMAP_TYPE_ICO ) + else: icon = wx.Icon( dir_struct["icon"]+'connect.gif', wx.BITMAP_TYPE_GIF ) self.SetIcon(icon) self.serverName = "Server Name" self.bootPwd = "" @@ -480,7 +480,7 @@ if self.STATUS == SERVER_STOPPED: # see if we already have name specified try: - userPath = orpg.dirpath.dir_struct["user"] + userPath = dir_struct["user"] validate = orpg.tools.validate.Validate(userPath) validate.config_file( "server_ini.xml", "default_server_ini.xml" ) configDom = minidom.parse(userPath + 'server_ini.xml') @@ -494,7 +494,7 @@ if serverNameEntry.ShowModal() == wx.ID_OK: self.serverName = serverNameEntry.GetValue() # see if we already have password specified try: - userPath = orpg.dirpath.dir_struct["user"] + userPath = dir_struct["user"] validate = orpg.tools.validate.Validate(userPath) validate.config_file( "server_ini.xml", "default_server_ini.xml" ) configDom = minidom.parse(userPath + 'server_ini.xml') @@ -586,7 +586,7 @@ def OnInit(self): # Make sure our image handlers are loaded before we try to display anything wx.InitAllImageHandlers() - self.splash = wx.SplashScreen(wx.Bitmap(orpg.dirpath.dir_struct["icon"]+'splash.gif'), + self.splash = wx.SplashScreen(wx.Bitmap(dir_struct["icon"]+'splash.gif'), wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT, 2000, None) diff -r 4840657c23c5 -r c54768cffbd4 orpg/orpgCore.py --- a/orpg/orpgCore.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/orpgCore.py Tue Aug 18 06:33:37 2009 -0500 @@ -60,20 +60,16 @@ class ORPGStorage(object): __components = {} - def add_component(self, key, com): + def add(self, key, com): self.__components[key] = com - def get_component(self, key): - if self.__components.has_key(key): - return self.__components[key] - else: - return None + def get(self, key): + if self.__components.has_key(key): return self.__components[key] + else: return None - def del_component(self, key): - if self.__components.has_key(key): - del self.__components[key] - else: - return + def delete(self, key): + if self.__components.has_key(key): del self.__components[key] + else: return def singleton(cls): instances = {} @@ -84,4 +80,4 @@ return getinstance ORPGStorage = singleton(ORPGStorage) -open_rpg = ORPGStorage() +component = ORPGStorage() diff -r 4840657c23c5 -r c54768cffbd4 orpg/orpg_version.py --- a/orpg/orpg_version.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/orpg_version.py Tue Aug 18 06:33:37 2009 -0500 @@ -4,7 +4,7 @@ #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed) DISTRO = "Traipse Dev" DIS_VER = "Ornery Orc" -BUILD = "090817-02" +BUILD = "090818-00" # This version is for network capability. PROTOCOL_VERSION = "1.2" diff -r 4840657c23c5 -r c54768cffbd4 orpg/orpg_windows.py --- a/orpg/orpg_windows.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/orpg_windows.py Tue Aug 18 06:33:37 2009 -0500 @@ -32,7 +32,7 @@ from orpg.orpgCore import * import orpg.tools.rgbhex import orpg.orpg_xml -import orpg.dirpath +from orpg.dirpath import dir_struct from orpg.tools.metamenus import MenuEx class img_helper: @@ -71,15 +71,15 @@ nbstyle = FNB.FNB_HIDE_ON_SINGLE_TAB|FNB.FNB_BACKGROUND_GRADIENT FNB.FlatNotebook.__init__(self, parent, -1, size=size, style=nbstyle) rgbcovert = orpg.tools.rgbhex.RGBHex() - self.log = open_rpg.get_component("log") + self.log = component.get("log") self.log.log("Enter orpgTabberWnd", ORPG_DEBUG) - self.settings = open_rpg.get_component("settings") + self.settings = component.get("settings") tabtheme = self.settings.get_setting('TabTheme') tabtext = self.settings.get_setting('TabTextColor') (tred, tgreen, tblue) = rgbcovert.rgb_tuple(tabtext) - tabbedwindows = open_rpg.get_component("tabbedWindows") + tabbedwindows = component.get("tabbedWindows") tabbedwindows.append(self) - open_rpg.add_component("tabbedWindows", tabbedwindows) + component.add("tabbedWindows", tabbedwindows) theme_dict = {'slanted&aqua': FNB.FNB_VC8, 'slanted&bw': FNB.FNB_VC8, 'flat&aqua': FNB.FNB_FANCY_TABS, 'flat&bw': FNB.FNB_FANCY_TABS, 'customflat': FNB.FNB_FANCY_TABS, 'customslant': FNB.FNB_VC8, @@ -149,15 +149,16 @@ "Open an external browser to resolve our About box links!!!" href = ref.GetHref() webbrowser.open( href ) - -# This class extends wxSplitterWindow to add an auto expand behavior. The idea is that the sash -# determines the ratio of the two windows, while the mouse position determines which -# side will get the larger share of the screen real estate. It is used instead of regular -# wxSplitterWindows if the EnableSplittersAutoExpand setting doesn't evaluate as False. -# -# Note: To be truly functional, some way of passing EVT_MOTION events to this class, even when the -# event takes place over child windows needs to be accomplished. Once this is accomplished, -# however, the class should work as written. + """ + This class extends wxSplitterWindow to add an auto expand behavior. The idea is that the sash + determines the ratio of the two windows, while the mouse position determines which + side will get the larger share of the screen real estate. It is used instead of regular + wxSplitterWindows if the EnableSplittersAutoExpand setting doesn't evaluate as False. + + Note: To be truly functional, some way of passing EVT_MOTION events to this class, even when the + event takes place over child windows needs to be accomplished. Once this is accomplished, + however, the class should work as written. + """ class orpgFocusSplitterWindow(wx.SplitterWindow): def __init__(self,parent,id = -1,AutoExpand = 1,point = wx.DefaultPosition,size = wx.DefaultSize,style=wx.SP_3D,name="splitterWindow"): @@ -255,11 +256,11 @@ self.DIE2 = wx.NewId() self.DIE = wx.NewId() self.sizer = wx.BoxSizer(wx.HORIZONTAL) - gif = wx.Image(orpg.dirpath.dir_struct["icon"]+"bold.gif", wx.BITMAP_TYPE_GIF) + gif = wx.Image(dir_struct["icon"]+"bold.gif", wx.BITMAP_TYPE_GIF) self.sizer.Add(wx.BitmapButton(self, self.BOLD, gif.ConvertToBitmap()), 0, wx.EXPAND) - gif = wx.Image(orpg.dirpath.dir_struct["icon"]+"italic.gif", wx.BITMAP_TYPE_GIF) + gif = wx.Image(dir_struct["icon"]+"italic.gif", wx.BITMAP_TYPE_GIF) self.sizer.Add(wx.BitmapButton(self, self.ITALIC, gif.ConvertToBitmap()), 0, wx.EXPAND) - gif = wx.Image(orpg.dirpath.dir_struct["icon"]+"underlined.gif", wx.BITMAP_TYPE_GIF) + gif = wx.Image(dir_struct["icon"]+"underlined.gif", wx.BITMAP_TYPE_GIF) self.sizer.Add(wx.BitmapButton(self, self.UNDER, gif.ConvertToBitmap()), 0, wx.EXPAND) self.color_button = wx.Button(self, self.COLOR, "C",wx.Point(0,0),wx.Size(22,0)) self.color_button.SetBackgroundColour(wx.BLACK) diff -r 4840657c23c5 -r c54768cffbd4 orpg/orpg_xml.py --- a/orpg/orpg_xml.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/orpg_xml.py Tue Aug 18 06:33:37 2009 -0500 @@ -29,41 +29,48 @@ from orpg import minidom import string -def toxml(root,pretty=0): - return root.toxml(pretty) +class xml: + def __init__(self): + pass + + def toxml(self, root, pretty=0): + return root.toxml(pretty) -def parseXml(s): - "parse and return doc" - try: - doc = minidom.parseString(s) - doc.normalize() - return doc - except Exception, e: - print e - return None + def parseXml(self, s): + "parse and return doc" + try: + doc = minidom.parseString(s) + doc.normalize() + return doc + except Exception, e: + print e + return None -def safe_get_text_node(xml_dom): - """ returns the child text node or creates one if doesnt exist """ - t_node = xml_dom._get_firstChild() - if t_node == None: - t_node = minidom.Text("") - t_node = xml_dom.appendChild(t_node) - return t_node + def safe_get_text_node(self, xml_dom): + """ returns the child text node or creates one if doesnt exist """ + t_node = xml_dom._get_firstChild() + if t_node == None: + t_node = minidom.Text("") + t_node = xml_dom.appendChild(t_node) + return t_node -def strip_unicode(txt): - for i in xrange(len(txt)): - if txt[i] not in string.printable: - try: txt = txt.replace(txt[i], '&#' + str(ord(txt[i])) + ';') - except: txt = txt.replace(txt[i], '{?}') - return txt + def strip_unicode(self, txt): + for i in xrange(len(txt)): + if txt[i] not in string.printable: + try: txt = txt.replace(txt[i], '&#' + str(ord(txt[i])) + ';') + except: txt = txt.replace(txt[i], '{?}') + return txt -def strip_text(txt): - # The following block strips out 8-bit characters - u_txt = "" - bad_txt_found = 0 - txt = strip_unicode(txt) - for c in txt: - if ord(c) < 128: u_txt += c - else: bad_txt_found = 1 - if bad_txt_found: print "Some non 7-bit ASCII characters found and stripped" - return u_txt + def strip_text(self, txt): + # The following block strips out 8-bit characters + u_txt = "" + bad_txt_found = 0 + txt = self.strip_unicode(txt) + for c in txt: + if ord(c) < 128: u_txt += c + else: bad_txt_found = 1 + if bad_txt_found: print "Some non 7-bit ASCII characters found and stripped" + return u_txt + + +xml = xml() diff -r 4840657c23c5 -r c54768cffbd4 orpg/player_list.py --- a/orpg/player_list.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/player_list.py Tue Aug 18 06:33:37 2009 -0500 @@ -30,7 +30,7 @@ __version__ = "$Id: player_list.py,v 1.29 2007/03/30 19:12:06 digitalxero Exp $" from orpg.orpg_windows import * -import orpg.dirpath +from orpg.dirpath import dir_struct # global definitions global ROLE_GM; ROLE_GM = "GM" @@ -78,19 +78,18 @@ class player_list(wx.ListCtrl): def __init__( self, parent): - ##wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND ) wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) - self.session = open_rpg.get_component("session") - self.settings = open_rpg.get_component('settings') - self.chat = open_rpg.get_component('chat') - self.password_manager = open_rpg.get_component("password_manager") + self.session = component.get("session") + self.settings = component.get('settings') + self.chat = component.get('chat') + self.password_manager = component.get("password_manager") # Create in image list -- for whatever reason...guess it will be nice when we can tell which is a bot self.whisperCount = 0 self._imageList = wx.ImageList( 16, 16, False ) - img = wx.Image(orpg.dirpath.dir_struct["icon"]+"player.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + img = wx.Image(dir_struct["icon"]+"player.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() self._imageList.Add( img ) - img = wx.Image(orpg.dirpath.dir_struct["icon"]+"player-whisper.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + img = wx.Image(dir_struct["icon"]+"player-whisper.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() self._imageList.Add( img ) self.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL ) # Create our column headers @@ -201,9 +200,9 @@ def on_menu_password( self, evt ): id = evt.GetId() - self.session = open_rpg.get_component("session") - self.password_manager = open_rpg.get_component("password_manager") - self.chat = open_rpg.get_component("chat") + self.session = component.get("session") + self.password_manager = component.get("password_manager") + self.chat = component.get("chat") boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) if boot_pwd != None: alter_pwd_dialog = wx.TextEntryDialog(self, @@ -215,9 +214,9 @@ def on_menu_room_rename( self, evt ): id = evt.GetId() - self.session = open_rpg.get_component("session") - self.password_manager = open_rpg.get_component("password_manager") - self.chat = open_rpg.get_component("chat") + self.session = component.get("session") + self.password_manager = component.get("password_manager") + self.chat = component.get("chat") boot_pwd = self.password_manager.GetPassword("admin",int(self.session.group_id)) if boot_pwd != None: alter_name_dialog = wx.TextEntryDialog(self,"Enter new room name: ","Change Room Name") @@ -269,9 +268,9 @@ return def on_menu_whispergroup( self, evt ): - self.session = open_rpg.get_component("session") - self.settings = open_rpg.get_component('settings') - self.chat = open_rpg.get_component('chat') + self.session = component.get("session") + self.settings = component.get('settings') + self.chat = component.get('chat') "Add/Remove players from Whisper Groups" id = evt.GetId() item = self.GetItem( self.selected_item ) @@ -298,8 +297,8 @@ def on_menu_moderate( self, evt ): "Change the moderated status of a room or player." id = evt.GetId() - self.chat = open_rpg.get_component( "chat" ) - self.session = open_rpg.get_component("session") + self.chat = component.get( "chat" ) + self.session = component.get("session") playerID = self.GetItemData( self.selected_item ) moderationString = None moderateRoomBase = "/moderate %s" @@ -327,10 +326,10 @@ self.chat.InfoPost( infoString ) def on_menu_role_change( self, evt ): - self.session = open_rpg.get_component("session") + self.session = component.get("session") "Change the role of the selected id." id = evt.GetId() - self.chat = open_rpg.get_component( "chat" ) + self.chat = component.get( "chat" ) playerID = self.GetItemData( self.selected_item ) roleString = None roleBase = "/role %d=%s" @@ -355,13 +354,13 @@ pos = wx.Point(evt.GetX(),evt.GetY()) (item, flag) = self.HitTest(pos) id = self.GetItemText(item) - self.chat = open_rpg.get_component("chat") + self.chat = component.get("chat") self.chat.set_chat_text("/w " + id + "=") def on_menu_item(self,evt): id = evt.GetId() - self.session = open_rpg.get_component("session") - self.password_manager = open_rpg.get_component("password_manager") + self.session = component.get("session") + self.password_manager = component.get("password_manager") if id == PLAYER_BOOT: id = str(self.GetItemData(self.selected_item)) @@ -369,11 +368,11 @@ if boot_pwd != None: self.session.boot_player(id,boot_pwd) elif id == PLAYER_WHISPER: id = self.GetItemText(self.selected_item) - self.chat = open_rpg.get_component("chat") + self.chat = component.get("chat") self.chat.set_chat_text("/w " + id + "=") elif id == PLAYER_IGNORE: id = str(self.GetItemData(self.selected_item)) - self.chat = open_rpg.get_component("chat") + self.chat = component.get("chat") (result,id,name) = self.session.toggle_ignore(id) if result == 0: self.chat.Post(self.chat.colorize(self.chat.syscolor, "Player " + name + " with ID:" + id +" no longer ignored")) @@ -392,7 +391,7 @@ self.selected_item = item # This if-else block makes the menu item to boot players active or inactive, as appropriate # This block is enabled for 1.7.8. Ver. 1.7.9 will boast Admin features. - #if open_rpg.get_component("session").group_id == "0": + #if component.get("session").group_id == "0": # self.menu.Enable(PLAYER_BOOT,0) # self.menu.SetLabel(PLAYER_BOOT,"Can't boot from Lobby") #else: @@ -452,10 +451,10 @@ self.colorize_player_list() self.Refresh() # play sound - setobj = open_rpg.get_component('settings') + setobj = component.get('settings') sound_file = setobj.get_setting("AddSound") if sound_file != '': - sound_player = open_rpg.get_component('sound') + sound_player = component.get('sound') sound_player.play(sound_file) self.AutoAdjust() @@ -473,10 +472,10 @@ #--------------------------------------------------------- # play sound - setobj = open_rpg.get_component('settings') + setobj = component.get('settings') sound_file = setobj.get_setting("DelSound") if sound_file != '': - sound_player = open_rpg.get_component('sound') + sound_player = component.get('sound') sound_player.play(sound_file) ic = self.GetItemCount() self.whisperCount = 0 @@ -504,8 +503,8 @@ self.AutoAdjust() def colorize_player_list(self): - session = open_rpg.get_component("session") - settings = open_rpg.get_component('settings') + session = component.get("session") + settings = component.get('settings') mode = settings.get_setting("ColorizeRoles") if mode.lower() == "0": return players = session.players diff -r 4840657c23c5 -r c54768cffbd4 orpg/plugindb.py --- a/orpg/plugindb.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/plugindb.py Tue Aug 18 06:33:37 2009 -0500 @@ -1,12 +1,13 @@ import xmltramp -import orpg.dirpath -import orpg.tools.validate +from orpg.dirpath import dir_struct +#import orpg.tools.validate from types import * +from orpg.orpgCore import component class PluginDB: def __init__(self, filename="plugindb.xml"): - self.filename = orpg.dirpath.dir_struct["user"] + filename - orpg.tools.validate.Validate().config_file(filename,"default_plugindb.xml") + self.filename = dir_struct["user"] + filename + component.get('validate').config_file(filename,"default_plugindb.xml") self.xml_dom = self.LoadDoc() def GetString(self, plugname, strname, defaultval, verbose=0): diff -r 4840657c23c5 -r c54768cffbd4 orpg/pluginhandler.py --- a/orpg/pluginhandler.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/pluginhandler.py Tue Aug 18 06:33:37 2009 -0500 @@ -1,5 +1,5 @@ from orpg.orpg_wx import * -from orpg.orpgCore import open_rpg +from orpg.orpgCore import component class PluginHandler: # Initialization subroutine. @@ -7,14 +7,14 @@ # !self : instance of self # !chat : instance of the chat window to write to def __init__(self, plugindb, parent): - self.session = open_rpg.get_component("session") - self.chat = open_rpg.get_component("chat") - self.settings = open_rpg.get_component("settings") - self.gametree = open_rpg.get_component("tree") - self.startplugs = open_rpg.get_component("startplugs") - self.xml = open_rpg.get_component("xml") - self.validate = open_rpg.get_component("validate") - self.topframe = open_rpg.get_component("frame") + self.session = component.get("session") + self.chat = component.get("chat") + self.settings = component.get("settings") + self.gametree = component.get("tree") + self.startplugs = component.get("startplugs") + self.xml = component.get("xml") + self.validate = component.get("validate") + self.topframe = component.get("frame") self.plugindb = plugindb self.parent = parent self.shortcmdlist = self.chat.chat_cmds.shortcmdlist @@ -27,7 +27,7 @@ pass def menu_start(self): - rootMenu = open_rpg.get_component("pluginmenu") + rootMenu = component.get("pluginmenu") try: self.plugin_menu() rootMenu.AppendMenu(wx.ID_ANY, self.name, self.menu) @@ -39,7 +39,7 @@ def menu_cleanup(self): self.settings.save() - rootMenu = open_rpg.get_component("pluginmenu") + rootMenu = component.get("pluginmenu") menus = rootMenu.MenuItems for mi in menus: if mi.GetText() == self.name: diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/aliaslib.py --- a/orpg/tools/aliaslib.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/tools/aliaslib.py Tue Aug 18 06:33:37 2009 -0500 @@ -33,24 +33,24 @@ from orpg.orpg_windows import createMaskedButton, orpgMultiCheckBoxDlg from orpg.tools.rgbhex import RGBHex import orpg.tools.orpg_log -import orpg.dirpath +from orpg.dirpath import dir_struct import orpg.orpg_xml import orpg.tools.validate -import orpg.tools.orpg_settings +#import orpg.tools.orpg_settings class AliasLib(wx.Frame): def __init__(self): - self.orpgframe = open_rpg.get_component('frame') - self.log = open_rpg.get_component('log') + self.orpgframe = component.get('frame') + self.log = component.get('log') self.log.log("Enter AliasLib", ORPG_DEBUG) wx.Frame.__init__(self, None, wx.ID_ANY, title="Alias Lib") self.orpgframe.Freeze() self.Freeze() self.SetOwnBackgroundColour('#EFEFEF') - self.dir_struct = open_rpg.get_component('dir_struct') - self.settings = open_rpg.get_component('settings') - self.xml = open_rpg.get_component('xml') - self.validate = open_rpg.get_component('validate') + self.dir_struct = dir_struct + self.settings = component.get('settings') + self.xml = component.get('xml') + self.validate = component.get('validate') self.filename = self.settings.get_setting('aliasfile') + '.alias' self.validate.config_file(self.filename, "default_alias.alias") self.buildMenu() @@ -64,10 +64,10 @@ self.log.log("Exit AliasLib", ORPG_DEBUG) def InitSetup(self): - self.chat = open_rpg.get_component('chat') - self.gametree = open_rpg.get_component('tree') - self.map = open_rpg.get_component('map') - self.session = open_rpg.get_component('session') + self.chat = component.get('chat') + self.gametree = component.get('tree') + self.map = component.get('map') + self.session = component.get('session') def buildMenu(self): self.log.log("Enter AliasLib->buildMenu(self)", ORPG_DEBUG) @@ -189,7 +189,7 @@ def OnMB_FileExportToTree(self, event): self.log.log("Enter AliasLib->OnMB_FileExportToTree(self, event)", ORPG_DEBUG) - #tree = open_rpg.get_component("tree") + #tree = component.get("tree") xml = '' + "\n" idx = self.aliasIdx for n in xrange(self.selectAliasWnd.GetItemCount()): @@ -216,7 +216,7 @@ self.log.log("Enter AliasLib->OnMB_FileExit(self, event)", ORPG_DEBUG) self.OnMB_FileSave(0) self.Hide() - top_frame = open_rpg.get_component('frame') + top_frame = component.get('frame') top_frame.mainmenu.Check(top_frame.mainmenu.FindMenuItem("Windows", "Alias Lib"), False) self.log.log("Exit AliasLib->OnMB_FileExit(self, event)", ORPG_DEBUG) diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/metamenus.py diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/orpg_log.py --- a/orpg/tools/orpg_log.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/tools/orpg_log.py Tue Aug 18 06:33:37 2009 -0500 @@ -25,39 +25,134 @@ # # Description: classes for orpg log messages # +from __future__ import with_statement +import sys +import os, os.path +import time -from orpg.orpgCore import * +from orpg.external.terminalwriter import TerminalWriter +from orpg.tools.decorators import pending_deprecation +from orpg.dirpath import dir_struct + +######################### +## Error Types +######################### +ORPG_CRITICAL = 1 +ORPG_GENERAL = 2 +ORPG_INFO = 4 +ORPG_NOTE = 8 +ORPG_DEBUG = 16 -class orpgLog: +class orpgLog(object): + _log_level = 7 + _log_name = None + _log_to_console = False + _io = TerminalWriter(sys.stderr) + _lvl_args = None + + def __new__(cls, *args, **kwargs): + it = cls.__dict__.get("__it__") + if it is not None: + return it + cls.__it__ = it = object.__new__(cls) + return it + def __init__(self, home_dir, filename='orpgRunLog '): - self.logToConsol = True - self.logLevel = 7 - self.logName = home_dir + filename + time.strftime( '%m-%d-%Y.txt', time.localtime( time.time() ) ) + self._lvl_args = {16: {'colorizer': {'green': True}, + 'log_string': 'DEBUG'}, + 8: {'colorizer': {'bold': True, 'green':True}, + 'log_string':'NOTE'}, + 4: {'colorizer': {'blue': True}, + 'log_string': 'INFO'}, + 2: {'colorizer': {'red': True}, + 'log_string': 'ERROR'}, + 1: {'colorizer': {'bold': True, 'red': True}, + 'log_string': 'EXCEPTION'}} + if not self.log_name: + self.log_name = home_dir + filename + time.strftime('%m-%d-%Y.txt', + time.localtime(time.time())) - def log(self, msg, type, to_consol=False): - if self.logToConsol or to_consol or type == ORPG_CRITICAL: - print msg + def debug(self, msg, to_console=False): + self.log(msg, ORPG_DEBUG, to_console) + + def note(self, msg, to_console=False): + self.log(msg, ORPG_NOTE, to_console) + + def info(self, msg, to_console=False): + self.log(msg, ORPG_INFO, to_console) + + def general(self, msg, to_console=False): + self.log(msg, ORPG_GENERAL, to_console) + + def exception(self, msg, to_console=True): + self.log(msg, ORPG_CRITICAL, to_console) + + def log(self, msg, log_type, to_console=False): + if self.log_to_console or to_console or log_type == ORPG_CRITICAL: + self._io.line(str(msg), **self._lvl_args[log_type]['colorizer']) - if type & self.logLevel or to_consol: - logMsg = time.strftime( '[%x %X] ', time.localtime( time.time() ) ) + msg + "\n" - logFile = open(self.logName, "a") - logFile.write(logMsg) - logFile.close() + + if log_type & self.log_level or to_console: + atr = {'msg': msg, 'level': self._lvl_args[log_type]['log_string']} + atr['time'] = time.strftime('[%x %X]', time.localtime(time.time())) + logMsg = '%(time)s (%(level)s) - %(msg)s\n' % (atr) + + with open(self.log_name, 'a') as f: + f.write(logMsg) + + @pending_deprecation("use logger.log_level = #") + def setLogLevel(self, log_level): + self.log_level = log_level - def setLogLevel(self, log_level): - self.logLevel = log_level + @pending_deprecation("use logger.log_level") + def getLogLevel(self): + return self.log_level + + @pending_deprecation("use logger.log_name = bla") + def setLogName(self, log_name): + self.log_name = log_name - def getLogLevel(self): - return self.logLevel + @pending_deprecation("use logger.log_name") + def getLogName(self): + return self.log_name + + @pending_deprecation("use logger.log_to_console = True/False") + def setLogToConsol(self, true_or_false): + self.log_to_consol = true_or_false + + @pending_deprecation("use logger.log_to_console") + def getLogToConsol(self): + return self.log_to_consol - def setLogName(self, log_name): - self.logName = log_name + """ + Property Methods + """ + def _get_log_level(self): + return self._log_level + def _set_log_level(self, log_level): + if not isinstance(log_level, int) or log_level < 1 or log_level > 31: + raise TypeError("The loggers level must be an int between 1 and 31") - def getLogName(self): - return self.logName + self._log_level = log_level - def setLogToConsol(self, bool): - self.logToConsol = bool + def _get_log_name(self): + return self._log_name + def _set_log_name(self, name): + if not os.access(os.path.abspath(os.path.dirname(name)), os.W_OK): + raise IOError("Could not write to the specified location") + + self._log_name = name - def getLogToConsol(self): - return self.logToConsol + def _get_log_to_console(self): + return self._log_to_console + def _set_log_to_console(self, true_or_false): + if not isinstance(true_or_false, bool): + raise TypeError("log_to_console must be a boolean value") + + self._log_to_console = true_or_false + + log_level = property(_get_log_level, _set_log_level) + log_name = property(_get_log_name, _set_log_name) + log_to_console = property(_get_log_to_console, _set_log_to_console) + +logger = orpgLog(dir_struct.get("user") + "runlogs/") diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/orpg_settings.py --- a/orpg/tools/orpg_settings.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/tools/orpg_settings.py Tue Aug 18 06:33:37 2009 -0500 @@ -27,29 +27,33 @@ # from orpg.orpg_windows import * -import orpg.dirpath +from orpg.orpgCore import component +from orpg.dirpath import dir_struct from rgbhex import * import sys import os +from orpg.orpg_xml import xml class orpgSettings: def __init__(self): - self.validate = open_rpg.get_component("validate") - self.xml = open_rpg.get_component("xml") - self.log = open_rpg.get_component("log") + self.validate = component.get("validate") + component.add('xml', xml) + self.xml = component.get("xml") + self.orpgLog = component.get("log") self.changes = [] self.validate.config_file("settings.xml","default_settings.xml") - self.filename = orpg.dirpath.dir_struct["user"] + "settings.xml" + self.filename = dir_struct["user"] + "settings.xml" temp_file = open(self.filename) txt = temp_file.read() temp_file.close() + self.xml_dom = self.xml.parseXml(txt) if self.xml_dom is None: self.rebuildSettings() self.xml_dom = self.xml_dom._get_documentElement() def rebuildSettings(self): - self.log.log("Settings file has be corrupted, rebuilding settings.", ORPG_INFO, True) + self.orpgLog.log("Settings file has be corrupted, rebuilding settings.", ORPG_INFO, True) try: os.remove(self.filename) except: pass @@ -141,9 +145,9 @@ wx.DefaultPosition,size = wx.Size(-1,-1), style=wx.RESIZE_BORDER | wx.SYSTEM_MENU | wx.CAPTION) self.Freeze() - self.validate = open_rpg.get_component("validate") - self.settings = open_rpg.get_component("settings") - self.chat = open_rpg.get_component("chat") + self.validate = component.get("validate") + self.settings = component.get("settings") + self.chat = component.get("chat") self.changes = [] self.SetMinSize((545,500)) self.tabber = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON) @@ -169,7 +173,7 @@ def build_gui(self): self.validate.config_file("settings.xml","default_settings.xml") - filename = open_rpg.get_component("dir_struct")["user"] + "settings.xml" + filename = dir_struct["user"] + "settings.xml" temp_file = open(filename) temp_file.close() children = self.settings.xml_dom._get_childNodes() @@ -215,8 +219,8 @@ def onOk(self, evt): #This will write the settings back to the XML - self.session = open_rpg.get_component("session") - tabbedwindows = open_rpg.get_component("tabbedWindows") + self.session = component.get("session") + tabbedwindows = component.get("tabbedWindows") new = [] for wnd in tabbedwindows: try: @@ -224,12 +228,12 @@ new.append(wnd) except: pass tabbedwindows = new - open_rpg.add_component("tabbedWindows", tabbedwindows) + component.add("tabbedWindows", tabbedwindows) rgbconvert = RGBHex() for i in xrange(0,len(self.changes)): self.settings.set_setting(self.changes[i][0], self.changes[i][1]) - top_frame = open_rpg.get_component('frame') + top_frame = component.get('frame') if self.changes[i][0] == 'defaultfontsize' or self.changes[i][0] == 'defaultfont': self.chat.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'), @@ -385,3 +389,6 @@ col_w = w/(cols) for i in range(0,cols): self.SetColSize(i,col_w) self.Refresh() + +settings = orpgSettings() +component.add('settings', settings) diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/orpg_sound.py --- a/orpg/tools/orpg_sound.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/tools/orpg_sound.py Tue Aug 18 06:33:37 2009 -0500 @@ -7,8 +7,8 @@ wx.Panel.__init__(self, parent, -1) self.parent = parent - self.log = open_rpg.get_component("log") - self.settings = open_rpg.get_component('settings') + self.log = component.get("log") + self.settings = component.get('settings') self.log.log("Enter orpgSound", ORPG_DEBUG) diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/passtool.py --- a/orpg/tools/passtool.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/tools/passtool.py Tue Aug 18 06:33:37 2009 -0500 @@ -27,8 +27,9 @@ # doesn't have to type passwords over and over import orpg.orpg_windows -from orpg.orpgCore import open_rpg +from orpg.orpgCore import component import traceback +#from orpg.tools.settings import settings ##################### ## Password Assistant @@ -42,19 +43,15 @@ #room password self.room = None - - class PassTool: "Password Management System" def __init__(self): - self.settings = open_rpg.get_component("settings") + self.settings = component.get("settings") #server admin password self.server = None self.groups = {} - if self.settings.get_setting('PWMannager') == 'On': - self.enabled = 1 - else: - self.enabled = 0 + if self.settings.get_setting('PWMannager') == 'On': self.enabled = 1 + else: self.enabled = 0 def DumpPasswords(self): @@ -179,3 +176,6 @@ elif type == "server": self.ClearPassword( type, groupid ) return self.ServerPass() + +#PassTool = PassTool() +component.add('password_manager', PassTool()) diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/pluginui.py --- a/orpg/tools/pluginui.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/tools/pluginui.py Tue Aug 18 06:33:37 2009 -0500 @@ -1,9 +1,9 @@ from orpg.orpg_wx import * from orpg.orpgCore import * import orpg.plugindb as plugindb -import orpg.dirpath +from orpg.dirpath import dir_struct -sys.path.append(orpg.dirpath.dir_struct["plugins"]) +sys.path.append(dir_struct["plugins"]) class PluginFrame(wx.Frame): def __init__(self, parent): @@ -278,7 +278,7 @@ self.pluginList.DeleteAllItems() self.pluginNames = [] - list_of_plugin_dir = os.listdir(orpg.dirpath.dir_struct["plugins"]) + list_of_plugin_dir = os.listdir(dir_struct["plugins"]) for p in list_of_plugin_dir: #print p[:2]; print p[-4:] if p[:2].lower()=="xx" and p[-3:]==".py": diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/scriptkit.py --- a/orpg/tools/scriptkit.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/tools/scriptkit.py Tue Aug 18 06:33:37 2009 -0500 @@ -41,11 +41,11 @@
  • openrpg - a reference to the application openrpg object. """ - self.chat = open_rpg.get_component( 'chat' ) - self.map = open_rpg.get_component( 'map' ) - self.settings = open_rpg.get_component( 'settings' ) - self.session = open_rpg.get_component('session') - self.xml = open_rpg.get_component('xml') + self.chat = component.get( 'chat' ) + self.map = component.get( 'map' ) + self.settings = component.get( 'settings' ) + self.session = component.get('session') + self.xml = component.get('xml') def addMiniatureToMap( self, min_label, min_url, unique=0 ): """Adds a new miniature icon to the map. Miniature will be labeled unless autolabel is diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/toolBars.py --- a/orpg/tools/toolBars.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/tools/toolBars.py Tue Aug 18 06:33:37 2009 -0500 @@ -33,7 +33,7 @@ ## from inputValidator import * import string -import orpg.dirpath +from orpg.dirpath import dir_struct # DICE stuff TB_IDC_D4 = wx.NewId() @@ -56,12 +56,12 @@ wx.Panel.__init__(self, parent, id, size=size) self.callback = callBack self.mapmode = 1 - self.modeicons = [orpg.dirpath.dir_struct["icon"]+"move.gif", - orpg.dirpath.dir_struct["icon"]+"draw.gif", - orpg.dirpath.dir_struct["icon"]+"tape.gif"] + self.modeicons = [dir_struct["icon"]+"move.gif", + dir_struct["icon"]+"draw.gif", + dir_struct["icon"]+"tape.gif"] # Make a sizer for everything to belong to self.sizer = wx.BoxSizer( wx.HORIZONTAL ) - bm = wx.Image(orpg.dirpath.dir_struct["icon"]+"move.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + bm = wx.Image(dir_struct["icon"]+"move.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() self.butt = wx.BitmapButton( self, TB_MAP_MODE, bm ) self.sizer.Add( self.butt,0, wx.ALIGN_CENTER ) self.Bind(wx.EVT_BUTTON, self.onToolBarClick, id=TB_MAP_MODE) @@ -98,31 +98,31 @@ self.numDieText = wx.TextCtrl( self, TB_IDC_NUMDICE, "1", size= wx.Size(50, 25), validator=MathOnlyValidator() ) self.sizer.Add( self.numDieText, 1, wx.EXPAND | wx.ALIGN_LEFT ) - bm = wx.Image(orpg.dirpath.dir_struct["icon"]+"b_d4.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + bm = wx.Image(dir_struct["icon"]+"b_d4.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() butt = wx.BitmapButton( self, TB_IDC_D4, bm, size=(bm.GetWidth(), bm.GetHeight()) ) self.sizer.Add( butt, 0, wx.ALIGN_CENTER ) self.Bind(wx.EVT_BUTTON, self.onToolBarClick, id=TB_IDC_D4) - bm = wx.Image(orpg.dirpath.dir_struct["icon"]+"b_d6.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + bm = wx.Image(dir_struct["icon"]+"b_d6.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() butt = wx.BitmapButton( self, TB_IDC_D6, bm, size=(bm.GetWidth(), bm.GetHeight()) ) self.sizer.Add( butt, 0, wx.ALIGN_CENTER ) self.Bind(wx.EVT_BUTTON, self.onToolBarClick, id=TB_IDC_D6) - bm = wx.Image(orpg.dirpath.dir_struct["icon"]+"b_d8.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + bm = wx.Image(dir_struct["icon"]+"b_d8.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() butt = wx.BitmapButton( self, TB_IDC_D8, bm, size=(bm.GetWidth(), bm.GetHeight()) ) self.sizer.Add( butt, 0, wx.ALIGN_CENTER ) self.Bind(wx.EVT_BUTTON, self.onToolBarClick, id=TB_IDC_D8) - bm = wx.Image(orpg.dirpath.dir_struct["icon"]+"b_d10.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + bm = wx.Image(dir_struct["icon"]+"b_d10.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() butt = wx.BitmapButton( self, TB_IDC_D10, bm, size=(bm.GetWidth(), bm.GetHeight()) ) self.sizer.Add( butt, 0, wx.ALIGN_CENTER ) self.Bind(wx.EVT_BUTTON, self.onToolBarClick, id=TB_IDC_D10) - bm = wx.Image(orpg.dirpath.dir_struct["icon"]+"b_d12.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + bm = wx.Image(dir_struct["icon"]+"b_d12.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() butt = wx.BitmapButton( self, TB_IDC_D12, bm, size=(bm.GetWidth(), bm.GetHeight()) ) self.sizer.Add( butt, 0, wx.ALIGN_CENTER ) self.Bind(wx.EVT_BUTTON, self.onToolBarClick, id=TB_IDC_D12) - bm = wx.Image(orpg.dirpath.dir_struct["icon"]+"b_d20.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + bm = wx.Image(dir_struct["icon"]+"b_d20.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() butt = wx.BitmapButton( self, TB_IDC_D20, bm, size=(bm.GetWidth(), bm.GetHeight()) ) self.sizer.Add( butt, 0, wx.ALIGN_CENTER ) self.Bind(wx.EVT_BUTTON, self.onToolBarClick, id=TB_IDC_D20) - bm = wx.Image(orpg.dirpath.dir_struct["icon"]+"b_d100.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() + bm = wx.Image(dir_struct["icon"]+"b_d100.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() butt = wx.BitmapButton( self, TB_IDC_D100, bm, size=(bm.GetWidth(), bm.GetHeight()) ) self.sizer.Add( butt, 0, wx.ALIGN_CENTER ) self.Bind(wx.EVT_BUTTON, self.onToolBarClick, id=TB_IDC_D100) diff -r 4840657c23c5 -r c54768cffbd4 orpg/tools/validate.py --- a/orpg/tools/validate.py Mon Aug 17 06:56:31 2009 -0500 +++ b/orpg/tools/validate.py Tue Aug 18 06:33:37 2009 -0500 @@ -6,23 +6,24 @@ # Misc. config file service methods # -import orpg.dirpath +from orpg.dirpath import dir_struct import os +from orpg.orpgCore import component class Validate: def __init__(self, userpath=None): if userpath is None: - userpath = orpg.dirpath.dir_struct["user"] + userpath = dir_struct["user"] self.__loadUserPath = userpath def config_file(self, user_file, template_file): #STEP 1: verify the template exists - if (not os.path.exists(orpg.dirpath.dir_struct["template"] + template_file)): + if (not os.path.exists(dir_struct["template"] + template_file)): return 0 #STEP 2: verify the user file exists. If it doesn't then create it from template if (not os.path.exists(self.__loadUserPath + user_file)): - default = open(orpg.dirpath.dir_struct["template"] + template_file,"r") + default = open(dir_struct["template"] + template_file,"r") file = default.read() newfile = open(self.__loadUserPath + user_file,"w") newfile.write(file) @@ -35,3 +36,6 @@ def ini_entry(self, entry_name, ini_file): pass + +validate = Validate() +component.add('validate', Validate()) diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxchatnotify.py --- a/plugins/xxchatnotify.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxchatnotify.py Tue Aug 18 06:33:37 2009 -0500 @@ -55,8 +55,8 @@ self.plugin_addcommand('/notify', self.on_notify, 'beep | flash | both | off | type all|whisper | clearsound | lsound soundfile [Local Sound Files only] | rsound http://to.sound.file [Remote Sound Files only] - This command turns on the chat notification. You can use sound files and flash by issuing /notify both') self.notify = self.plugindb.GetString('xxchatnotify', 'notify', 'off') self.type = self.plugindb.GetString('xxchatnotify', 'type', 'all') - self.mainframe = open_rpg.get_component('frame') - self.sound_player = open_rpg.get_component('sound') + self.mainframe = component.get('frame') + self.sound_player = component.get('sound') self.soundloc = self.plugindb.GetString('xxchatnotify', 'soundloc', 'local') self.soundfile = self.plugindb.GetString('xxchatnotify', 'soundfile', 'None') self.chat_settings() diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxcherrypy.py --- a/plugins/xxcherrypy.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxcherrypy.py Tue Aug 18 06:33:37 2009 -0500 @@ -55,7 +55,7 @@ del cherry_start self.cherryhost = 'http://' + self.host + ':' + str(self.port) + '/webfiles/' - open_rpg.add_component("cherrypy", self.cherryhost) + component.add("cherrypy", self.cherryhost) def plugin_disabled(self): #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin @@ -66,7 +66,7 @@ self.isServerRunning = 'off' else: pass - open_rpg.del_component("cherrypy") + component.delete("cherrypy") def on_cherrypy(self, cmdargs): args = cmdargs.split(None,-1) @@ -96,7 +96,7 @@ self.plugindb.SetString("xxcherrypy", "port", str(self.port)) # TAS self.chat.InfoPost("CherryPy Web Server is currently: " + self.isServerRunning) self.cherryhost = 'http://' + self.host + ':' + str(self.port) + '/webfiles/' - open_rpg.del_component("cherrypy"); open_rpg.add_component("cherrypy", self.cherryhost) + component.delete("cherrypy"); component.add("cherrypy", self.cherryhost) self.chat.InfoPost('CherryPy Web Server address is: ' + self.cherryhost) def startServer(self, port): diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxgvm.py --- a/plugins/xxgvm.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxgvm.py Tue Aug 18 06:33:37 2009 -0500 @@ -192,4 +192,4 @@ if len(keychain)==0: return "No variables!" else: - return lister \ No newline at end of file + return lister diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxheroinit.py --- a/plugins/xxheroinit.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxheroinit.py Tue Aug 18 06:33:37 2009 -0500 @@ -519,4 +519,4 @@ msg += " Example: heroinit (hact 1 full) : Make character index 1 perform a full action.
    " msg += " Example: heroinit (hact full) : Have your first owned character perform a full action
    " - self.chat.whisper_to_players(msg, [player[2]]) \ No newline at end of file + self.chat.whisper_to_players(msg, [player[2]]) diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxinit.py --- a/plugins/xxinit.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxinit.py Tue Aug 18 06:33:37 2009 -0500 @@ -1,7 +1,7 @@ import os import orpg.pluginhandler from string import find, replace -import orpg.dirpath +from orpg.dirpath import dir_struct class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. @@ -52,7 +52,7 @@ self.post_my_msg("Init recording on") self.toggle = 1 elif args[0] == 'help': - f = open(orpg.dirpath.dir_struct["plugins"]+ "inittool.xml","r") + f = open(dir_struct["plugins"]+ "inittool.xml","r") self.gametree.insert_xml(f.read()) f.close() elif args[0] == 'type': diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxinit2.py --- a/plugins/xxinit2.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxinit2.py Tue Aug 18 06:33:37 2009 -0500 @@ -22,7 +22,7 @@ import wx import os -import orpg.dirpath +from orpg.dirpath import dir_struct import orpg.orpg_version import orpg.plugindb import orpg.pluginhandler @@ -300,8 +300,8 @@ ############################################################### def CMD_inittool2(self, cmdargs): - f = open(orpg.dirpath.dir_struct["plugins"]+ "inittool2.xml","r") - f2 = open(orpg.dirpath.dir_struct["plugins"]+ "inittool2_player.xml","r") + f = open(dir_struct["plugins"]+ "inittool2.xml","r") + f2 = open(dir_struct["plugins"]+ "inittool2_player.xml","r") self.gametree.insert_xml(f.read()) self.gametree.insert_xml(f2.read()) f.close() diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxnamesound.py --- a/plugins/xxnamesound.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxnamesound.py Tue Aug 18 06:33:37 2009 -0500 @@ -1,9 +1,9 @@ import os import orpg.pluginhandler -import orpg.dirpath +from orpg.dirpath import dir_struct import re import string -from orpg.orpgCore import open_rpg +from orpg.orpgCore import component class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. @@ -39,13 +39,13 @@ self.names = self.plugindb.GetList("xxnamesound", "names", []) - self.soundplayer = self.sound_player = open_rpg.get_component('sound') + self.soundplayer = self.sound_player = component.get('sound') tmp = self.plugindb.GetString('xxnamesound', 'wnotify', str(self.notify)) if tmp == 'True': self.on_wnotify(None) - self.soundfile = self.plugindb.GetString('xxnamesound', 'soundfile', orpg.dirpath.dir_struct['plugins'] + 'heya.wav') + self.soundfile = self.plugindb.GetString('xxnamesound', 'soundfile', dir_struct['plugins'] + 'heya.wav') reg = [] diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxnote.py --- a/plugins/xxnote.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxnote.py Tue Aug 18 06:33:37 2009 -0500 @@ -177,4 +177,4 @@ self.chat.InfoPost('/listnotes ' + self.cmdlist['/listnotes']['help']) self.chat.InfoPost('/clearnotes ' + self.cmdlist['/clearnotes']['help']) self.chat.InfoPost('/notetonode ' + self.cmdlist['/notetonode']['help']) - self.chat.InfoPost('/viewnote ' + self.cmdlist['/viewnote']['help']) \ No newline at end of file + self.chat.InfoPost('/viewnote ' + self.cmdlist['/viewnote']['help']) diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxquotebox.py --- a/plugins/xxquotebox.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxquotebox.py Tue Aug 18 06:33:37 2009 -0500 @@ -1,5 +1,5 @@ import os -import orpg.dirpath +from orpg.dirpath import dir_struct import orpg.plugindb import orpg.pluginhandler from orpg.tools.rgbhex import RGBHex @@ -236,7 +236,7 @@ # loads up quotebox.xml as a node in the gametree def on_quotebox(self, cmdargs): - f = open(orpg.dirpath.dir_struct["plugins"]+ "quotebox.xml","r") + f = open(dir_struct["plugins"]+ "quotebox.xml","r") self.gametree.insert_xml(f.read()) f.close() return 1 diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxsimpleinit.py --- a/plugins/xxsimpleinit.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxsimpleinit.py Tue Aug 18 06:33:37 2009 -0500 @@ -10,7 +10,7 @@ # !openrpg : instance of the the base openrpg control def __init__(self, plugindb, parent): orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent) - self.orpgframe = open_rpg.get_component('frame') + self.orpgframe = component.get('frame') # The Following code should be edited to contain the proper information self.name = 'Simple Init' @@ -276,16 +276,16 @@ def __init__(self, plugin): self.plugin = plugin self.toggle = plugin.toggle - self.log = open_rpg.get_component('log') + self.log = component.get('log') self.log.log("Enter InitFrame", ORPG_DEBUG) wx.Frame.__init__(self, None, wx.ID_ANY, title="Simple Init", style=wx.DEFAULT_FRAME_STYLE) self.SetOwnBackgroundColour('#EFEFEF') - self.dir_struct = open_rpg.get_component('dir_struct') - self.settings = open_rpg.get_component('settings') - self.xml = open_rpg.get_component('xml') - self.validate = open_rpg.get_component('validate') + self.dir_struct = component.get('dir_struct') + self.settings = component.get('settings') + self.xml = component.get('xml') + self.validate = component.get('validate') self.Freeze() self.buildMenu() @@ -298,10 +298,10 @@ self.log.log("Exit InitFrame", ORPG_DEBUG) def InitSetup(self): - self.chat = open_rpg.get_component('chat') - self.gametree = open_rpg.get_component('tree') - self.map = open_rpg.get_component('map') - self.session = open_rpg.get_component('session') + self.chat = component.get('chat') + self.gametree = component.get('tree') + self.map = component.get('map') + self.session = component.get('session') self.initIdx = -1 self.Thaw() diff -r 4840657c23c5 -r c54768cffbd4 plugins/xxsmiley.py --- a/plugins/xxsmiley.py Mon Aug 17 06:56:31 2009 -0500 +++ b/plugins/xxsmiley.py Tue Aug 18 06:33:37 2009 -0500 @@ -1,6 +1,6 @@ import os import orpg.pluginhandler -import orpg.dirpath +from orpg.dirpath import dir_struct class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. @@ -25,86 +25,86 @@ self.plugin_addcommand('/smiley', self.on_smiley, '- [add|remove|help] The Smiley command') smlist = { - '>:-(' : ' ', - ':/' : ' ', - ':|' : ' ', - ':(' : ' ', - ' />:(' : ' ', - ' />=(' : ' ', - '=)' : ' ', - '=D' : ' ', - ';)' : ' ', - '=/' : ' ', - '=|' : ' ', - '=(' : ' ', - ':)' : ' ', - ':D' : ' ', - 'B)' : ' ', - ':p' : ' ', - '=\\' : ' ', - ':P' : ' ', - '=P' : ' ', - '^_^' : ' ', - '^-^' : ' ', - '^.^' : ' ', - 'n_n' : ' ', - 'n.n' : ' ', - 'n,n' : ' ', - 'I-)' : ' ', - 'n.n;' : ' ', - 'n.n;;' : ' ', - 'n_n;' : ' ', - ':-)' : ' ', - ':-D' : ' ', - ':-P' : ' ', - ':-p' : ' ', - ':-/' : ' ', - ':-|' : ' ', - ':-(' : ' ', - ':-\\' : ' ', - '-)' : ' ', - ';-)' : ' ', - ':->' : ' ', - ':-D' : ' ', - ':-P' : ' ', - ':-o' : ' ', - ':mrgreen:' : ' ', - ':lol:' : ' ', - ':-(' : ' ', - ':-|' : ' ', - ':-?' : ' ', - ':-x' : ' ', - ':shock:' : ' ', - ':cry:' : ' ', - ';_;' : ' ', - ':oops:' : ' ', - '8-)' : ' ', - ':evil:' : ' ', - ':twisted:' : ' ', - ':roll:' : ' ', - ':!:' : ' ', - ':?:' : ' ', - ':idea:' : ' ', - ':arrow:' : ' ', - ':ubergeek:' : ' ', - ':geek:' : ' ', - ':fairy:' : ' ', - ':hood:' : ' ', - ':gnome:' : ' ', - ':link:' : ' ', - ':mummy:' : ' ', - ':ogre:' : ' ', - ':medusa:' : ' ', - ':mimic:' : ' ', - ':skull:' : ' ', - ':zombie:' : ' ', - ':chocobo:' : ' ', - ':darkside:' : ' ', - ':flyingspaghetti:' : ' ', - ':rupee:' : ' ', - ':ros:' : ' ', - ':skeleton:' : ' ', - ':samurai:' : ' '} + '>:-(' : ' ', + ':/' : ' ', + ':|' : ' ', + ':(' : ' ', + ' />:(' : ' ', + ' />=(' : ' ', + '=)' : ' ', + '=D' : ' ', + ';)' : ' ', + '=/' : ' ', + '=|' : ' ', + '=(' : ' ', + ':)' : ' ', + ':D' : ' ', + 'B)' : ' ', + ':p' : ' ', + '=\\' : ' ', + ':P' : ' ', + '=P' : ' ', + '^_^' : ' ', + '^-^' : ' ', + '^.^' : ' ', + 'n_n' : ' ', + 'n.n' : ' ', + 'n,n' : ' ', + 'I-)' : ' ', + 'n.n;' : ' ', + 'n.n;;' : ' ', + 'n_n;' : ' ', + ':-)' : ' ', + ':-D' : ' ', + ':-P' : ' ', + ':-p' : ' ', + ':-/' : ' ', + ':-|' : ' ', + ':-(' : ' ', + ':-\\' : ' ', + '-)' : ' ', + ';-)' : ' ', + ':->' : ' ', + ':-D' : ' ', + ':-P' : ' ', + ':-o' : ' ', + ':mrgreen:' : ' ', + ':lol:' : ' ', + ':-(' : ' ', + ':-|' : ' ', + ':-?' : ' ', + ':-x' : ' ', + ':shock:' : ' ', + ':cry:' : ' ', + ';_;' : ' ', + ':oops:' : ' ', + '8-)' : ' ', + ':evil:' : ' ', + ':twisted:' : ' ', + ':roll:' : ' ', + ':!:' : ' ', + ':?:' : ' ', + ':idea:' : ' ', + ':arrow:' : ' ', + ':ubergeek:' : ' ', + ':geek:' : ' ', + ':fairy:' : ' ', + ':hood:' : ' ', + ':gnome:' : ' ', + ':link:' : ' ', + ':mummy:' : ' ', + ':ogre:' : ' ', + ':medusa:' : ' ', + ':mimic:' : ' ', + ':skull:' : ' ', + ':zombie:' : ' ', + ':chocobo:' : ' ', + ':darkside:' : ' ', + ':flyingspaghetti:' : ' ', + ':rupee:' : ' ', + ':ros:' : ' ', + ':skeleton:' : ' ', + ':samurai:' : ' '} self.smileylist = self.plugindb.GetDict("xxsmiley", "smileylist", smlist) @@ -132,7 +132,7 @@ if args[2].find('http') > -1: self.smileylist[args[1]] = ' ' + args[1] + '' else: - self.smileylist[args[1]] = ' ' + "\n" + self.smileylist[args[1]] = ' ' + "\n" self.chat.InfoPost('Added ' + args[1] + '    :    ' + self.smileylist[args[1]]) @@ -165,4 +165,4 @@ if myself: text = self.doSmiley(text) - return text \ No newline at end of file + return text diff -r 4840657c23c5 -r c54768cffbd4 upmana/ReadMe.txt diff -r 4840657c23c5 -r c54768cffbd4 upmana/__init__.py diff -r 4840657c23c5 -r c54768cffbd4 upmana/default_ignorelist.txt diff -r 4840657c23c5 -r c54768cffbd4 upmana/default_manifest.xml diff -r 4840657c23c5 -r c54768cffbd4 upmana/manifest.py --- a/upmana/manifest.py Mon Aug 17 06:56:31 2009 -0500 +++ b/upmana/manifest.py Tue Aug 18 06:33:37 2009 -0500 @@ -1,13 +1,13 @@ import xmltramp -import orpg.dirpath +from orpg.dirpath import dir_struct import upmana.validate from os import sep from types import * class ManifestChanges: def __init__(self, filename="updatemana.xml"): - self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + sep + filename - upmana.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + sep).config_file(filename,"default_manifest.xml") + self.filename = dir_struct["home"] + 'upmana' + sep + filename + upmana.validate.Validate(dir_struct["home"] + 'upmana' + sep).config_file(filename,"default_manifest.xml") self.xml_dom = self.LoadDoc() def GetString(self, plugname, strname, defaultval, verbose=0): diff -r 4840657c23c5 -r c54768cffbd4 upmana/tmp/tmp.txt diff -r 4840657c23c5 -r c54768cffbd4 upmana/updatemana.py --- a/upmana/updatemana.py Mon Aug 17 06:56:31 2009 -0500 +++ b/upmana/updatemana.py Tue Aug 18 06:33:37 2009 -0500 @@ -1,11 +1,11 @@ import wx import manifest -import orpg.dirpath +from orpg.dirpath import dir_struct from orpg.orpgCore import * import orpg.orpg_version import orpg.tools.orpg_log import orpg.orpg_xml -import orpg.dirpath +from orpg.dirpath import dir_struct import upmana.validate import tempfile import shutil @@ -13,7 +13,7 @@ class Updater(wx.Panel): - def __init__(self, parent, open_rpg, manifest): + def __init__(self, parent, component, manifest): wx.Panel.__init__(self, parent) ### Update Manager @@ -21,10 +21,9 @@ self.repo = hg.repository(self.ui, ".") self.c = self.repo.changectx('tip') self.manifest = manifest - self.xml = open_rpg.get_component('xml') - self.dir_struct = open_rpg.get_component("dir_struct") + self.xml = component.get('xml') self.parent = parent - self.log = open_rpg.get_component("log") + self.log = component.get("log") self.log.log("Enter updaterFrame", ORPG_DEBUG) self.SetBackgroundColour(wx.WHITE) self.sizer = wx.GridBagSizer(hgap=1, vgap=1) @@ -95,15 +94,15 @@ self.c = self.repo.changectx('tip') filename = 'ignorelist.txt' - self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + filename - upmana.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") + self.filename = dir_struct["home"] + 'upmana' + os.sep + filename + upmana.validate.Validate(dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") self.mana = self.LoadDoc() for ignore in self.ignorelist: - shutil.copy(ignore, orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep +ignore.split('/')[len(ignore.split('/')) - 1]) + shutil.copy(ignore, dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep +ignore.split('/')[len(ignore.split('/')) - 1]) hg.clean(self.repo, self.current) for ignore in self.ignorelist: - shutil.copyfile(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore) - os.remove(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1]) + shutil.copyfile(dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore) + os.remove(dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1]) def LoadDoc(self): ignore = open(self.filename) @@ -119,8 +118,8 @@ def ChooseBranch(self, evt=None): dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE) - if wx.Platform == '__WXMSW__': icon = wx.Icon(self.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) - else: icon = wx.Icon(self.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) + if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) + else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) dlg.SetIcon(icon) self.ui = ui.ui() @@ -373,8 +372,8 @@ self.manifestlog = wx.CheckListBox( self, -1, wx.DefaultPosition, wx.DefaultSize, self.manifestlist, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES) filename = 'ignorelist.txt' - self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + filename - upmana.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") + self.filename = dir_struct["home"] + 'upmana' + os.sep + filename + upmana.validate.Validate(dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") self.mana = self.LoadDoc() self.manifestlog.Bind(wx.EVT_CHECKLISTBOX, self.GetChecked) self.sizer.Add(self.manifestlog, (0,0), flag=wx.EXPAND) @@ -413,11 +412,11 @@ class updaterFrame(wx.Frame): def __init__(self, parent, title, openrpg, manifest, main): - self.dir_struct = open_rpg.get_component("dir_struct") + dir_struct = component.get("dir_struct") wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(600,480), style=wx.DEFAULT_FRAME_STYLE) - if wx.Platform == '__WXMSW__': icon = wx.Icon(self.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) - else: icon = wx.Icon(self.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) + if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) + else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) self.SetIcon(icon) self.CenterOnScreen() @@ -451,18 +450,18 @@ class updateApp(wx.App): def OnInit(self): - self.open_rpg = open_rpg + self.component = component self.main = False - self.log = orpg.tools.orpg_log.orpgLog(orpg.dirpath.dir_struct["user"] + "runlogs/") + self.log = orpg.tools.orpg_log.orpgLog(dir_struct["user"] + "runlogs/") self.log.setLogToConsol(False) self.log.log("Updater Start", ORPG_NOTE) self.manifest = manifest.ManifestChanges() - self.open_rpg.add_component("log", self.log) - self.open_rpg.add_component("xml", orpg.orpg_xml) - self.open_rpg.add_component("dir_struct", orpg.dirpath.dir_struct) + self.component.add("log", self.log) + self.component.add("xml", orpg.orpg_xml) + self.component.add("dir_struct", dir_struct) self.validate = upmana.validate.Validate() - self.open_rpg.add_component("validate", self.validate) - self.updater = updaterFrame(self, "OpenRPG Update Manager 0.7.2 (open beta)", self.open_rpg, self.manifest, self.main) + self.component.add("validate", self.validate) + self.updater = updaterFrame(self, "OpenRPG Update Manager 0.7.2 (open beta)", self.component, self.manifest, self.main) if self.manifest.GetString("updatemana", "auto_update", "") == 'on' and self.main == False: self.AutoUpdate(); self.OnExit() else: pass @@ -485,16 +484,16 @@ if capture != '': commands.pull(self.ui, self.repo, capture, rev='', update=False, force=True) filename = 'ignorelist.txt' - self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + filename - upmana.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") + self.filename = dir_struct["home"] + 'upmana' + os.sep + filename + upmana.validate.Validate(dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") self.mana = self.LoadDoc() for ignore in self.ignorelist: - shutil.copy(ignore, orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep +ignore.split('/')[len(ignore.split('/')) - 1]) + shutil.copy(ignore, dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep +ignore.split('/')[len(ignore.split('/')) - 1]) hg.clean(self.repo, self.current) for ignore in self.ignorelist: print ignore.split('/')[len(ignore.split('/')) - 1] - shutil.copyfile(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore) - os.remove(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1]) + shutil.copyfile(dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore) + os.remove(dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1]) else: print 'No default repository set, skipping Auto Update!' def LoadDoc(self): diff -r 4840657c23c5 -r c54768cffbd4 upmana/validate.py --- a/upmana/validate.py Mon Aug 17 06:56:31 2009 -0500 +++ b/upmana/validate.py Tue Aug 18 06:33:37 2009 -0500 @@ -6,23 +6,23 @@ # Misc. config file service methods # -import orpg.dirpath +from orpg.dirpath import dir_struct import os class Validate: def __init__(self, userpath=None): if userpath is None: - userpath = orpg.dirpath.dir_struct["user"] + userpath = dir_struct["user"] self.__loadUserPath = userpath def config_file(self, user_file, template_file): #STEP 1: verify the template exists - if (not os.path.exists(orpg.dirpath.dir_struct["template"] + template_file)): + if (not os.path.exists(dir_struct["template"] + template_file)): return 0 #STEP 2: verify the user file exists. If it doesn't then create it from template if (not os.path.exists(self.__loadUserPath + user_file)): - default = open(orpg.dirpath.dir_struct["template"] + template_file,"r") + default = open(dir_struct["template"] + template_file,"r") file = default.read() newfile = open(self.__loadUserPath + user_file,"w") newfile.write(file) diff -r 4840657c23c5 -r c54768cffbd4 upmana/xmltramp.py