Mercurial > traipse_dev
diff orpg/chat/chatwnd.py @ 66:c54768cffbd4 ornery-dev
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.
author | sirebral |
---|---|
date | Tue, 18 Aug 2009 06:33:37 -0500 |
parents | c160f26ecf65 |
children | 8fb07d0a1ca0 |
line wrap: on
line diff
--- 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( '<div class="'+c+'">%s%s</div>\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, "<b>Welcome to <a href='http://www.openrpg.com'>OpenRPG</a> version " + self.version + "... </b>")) + wx.CallAfter(self.Post, self.colorize(self.syscolor, + "<b>Welcome to <a href='http://www.openrpg.com'>OpenRPG</a> version " + self.version + "... </b>")) #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("<br>", "<br />").replace('</html>', '').replace("<br />", "<br />\n").replace("\n\n", '') + buffertext += chat_util.strip_body_tags(self.chatwnd.StripHeader()).replace("<br>", + "<br />").replace('</html>', + '').replace("<br />", + "<br />\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 "<font color='" + color + "'>" + text + "</font>" # 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 = "<b>" + display_name + "</b>: " @@ -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] + "]", "<!-- Official Roll [" + newstr1 + "] => " + newstr + "-->" + newstr, 1) else: s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "<!-- Official Roll -->] => " + 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