Mercurial > traipse_dev
diff orpg/chat/chatwnd.py @ 129:43ad912b7c17 alpha
Traipse Alpha 'OpenRPG' {091003-01}
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 (Cleaning up for Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
Happy Halloween!
author | sirebral |
---|---|
date | Tue, 03 Nov 2009 08:18:46 -0600 |
parents | 217fb049bd00 |
children | d54e1328dbb1 |
line wrap: on
line diff
--- a/orpg/chat/chatwnd.py Tue Nov 03 00:52:47 2009 -0600 +++ b/orpg/chat/chatwnd.py Tue Nov 03 08:18:46 2009 -0600 @@ -71,9 +71,11 @@ from orpg.tools.validate import validate from orpg.tools.orpg_settings import settings from orpg.orpgCore import component -from orpg.tools.orpg_log import logger +from orpg.tools.orpg_log import logger, debug from orpg.tools.decorators import debugging +from xml.etree.ElementTree import tostring + NEWCHAT = False try: import wx.webview @@ -85,29 +87,29 @@ # The 'tag stripping' is implicit, because this parser echoes every # type of html data *except* the tags. class HTMLStripper(HTMLParser): - @debugging + def __init__(self): self.accum = "" self.special_tags = ['hr', 'br', 'img'] - @debugging + def handle_data(self, data): # quote cdata literally self.accum += data - @debugging + def handle_entityref(self, name): # entities must be preserved exactly self.accum += "&" + name + ";" - @debugging + def handle_starttag(self, tag, attrs): if tag in self.special_tags: self.accum += '<' + tag for attrib in attrs: self.accum += ' ' + attrib[0] + '="' + attrib[1] + '"' self.accum += '>' - @debugging + def handle_charref(self, name): # charrefs too self.accum += "&#" + name + ";" htmlstripper = HTMLStripper() # utility function; see Post(). -@debugging + def strip_html(string): "Return string tripped of html tags." htmlstripper.reset() @@ -116,7 +118,7 @@ htmlstripper.close() return htmlstripper.accum -@debugging + def log( settings, c, text ): filename = settings.get_setting('GameLogPrefix') if filename > '' and filename[0] != commands.ANTI_LOG_CHAR: @@ -148,7 +150,7 @@ # !self : instance of self # !parent : # !id : - @debugging + def __init__(self, parent, id): wx.html.HtmlWindow.__init__(self, parent, id, style=wx.SUNKEN_BORDER|wx.html.HW_SCROLLBAR_AUTO|wx.NO_FULL_REPAINT_ON_RESIZE) @@ -159,50 +161,50 @@ if "gtk2" in wx.PlatformInfo: self.SetStandardFonts() # def __init__ - end - @debugging + def onPopup(self, evt): self.PopupMenu(self.menu) - @debugging + def LeftUp(self, event): event.Skip() wx.CallAfter(self.parent.set_chat_text_focus, None) - @debugging + def build_menu(self): self.menu = wx.Menu() item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy") self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item) self.menu.AppendItem(item) - @debugging + def OnM_EditCopy(self, evt): wx.TheClipboard.UsePrimarySelection(False) wx.TheClipboard.Open() wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText())) wx.TheClipboard.Close() - @debugging + def scroll_down(self): maxrange = self.GetScrollRange(wx.VERTICAL) pagesize = self.GetScrollPageSize(wx.VERTICAL) self.Scroll(-1, maxrange-pagesize) - @debugging + def mouse_wheel(self, event): amt = event.GetWheelRotation() units = amt/(-(event.GetWheelDelta())) self.ScrollLines(units*3) - @debugging + def Header(self): return '<html><body bgcolor="' + self.parent.bgcolor + '" text="' + self.parent.textcolor + '">' - @debugging + def StripHeader(self): return self.GetPageSource().replace(self.Header(), '') - @debugging + def GetPageSource(self): return self.GetParser().GetSource() @@ -210,14 +212,14 @@ # # !self : instance of self # !linkinfo : instance of a class that contains the link information - @debugging + def OnLinkClicked(self, linkinfo): href = linkinfo.GetHref() wb = webbrowser.get() wb.open(href) # def OnLinkClicked - end - @debugging + def CalculateAllFonts(self, defaultsize): return [int(defaultsize * 0.4), int(defaultsize * 0.7), @@ -227,7 +229,7 @@ int(defaultsize * 2), int(defaultsize * 2.5)] - @debugging + def SetDefaultFontAndSize(self, fontname, fontsize): """Set 'fontname' to the default chat font. Returns current font settings in a (fontname, fontsize) tuple.""" @@ -237,7 +239,7 @@ # class chat_html_window - end if NEWCHAT: class ChatHtmlWindow(wx.webview.WebView): - @debugging + def __init__(self, parent, id): wx.webview.WebView.__init__(self, parent, id) self.parent = parent @@ -248,23 +250,23 @@ self.Bind(wx.webview.EVT_WEBVIEW_BEFORE_LOAD, self.OnLinkClicked) #Wrapers so I dont have to add special Code - @debugging + def SetPage(self, htmlstring): self.SetPageSource(htmlstring) - @debugging + def AppendToPage(self, htmlstring): self.SetPageSource(self.GetPageSource() + htmlstring) - @debugging + def GetFont(self): return self.__font - @debugging + def CalculateAllFonts(self, defaultsize): return - @debugging + def SetDefaultFontAndSize(self, fontname, fontsize): self.__font = wx.Font(int(fontsize), wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, @@ -274,22 +276,22 @@ return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize()) #Events - @debugging + def OnLinkClicked(self, linkinfo): href = linkinfo.GetHref() wb = webbrowser.get() wb.open(href) - @debugging + def onPopup(self, evt): self.PopupMenu(self.menu) - @debugging + def LeftUp(self, event): event.Skip() wx.CallAfter(self.parent.set_chat_text_focus, None) - @debugging + def OnM_EditCopy(self, evt): wx.TheClipboard.UsePrimarySelection(False) wx.TheClipboard.Open() @@ -297,30 +299,30 @@ wx.TheClipboard.Close() #Cutom Methods - @debugging + def Header(self): return "<html><head><style>body {font-size: " + str(self.GetFont().GetPointSize()) + "px;font-family: " + self.GetFont().GetFaceName() + ";color: " + self.parent.textcolor + ";background-color: " + self.parent.bgcolor + ";margin: 0;padding: 0 0;height: 100%;}</style></head><body>" - @debugging + def StripHeader(self): tmp = self.GetPageSource().split('<BODY>') if tmp[-1].find('<body>') > -1: tmp = tmp[-1].split('<body>') return tmp[-1] - @debugging + def build_menu(self): self.menu = wx.Menu() item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy") self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item) self.menu.AppendItem(item) - @debugging + def scroll_down(self): maxrange = self.GetScrollRange(wx.VERTICAL) pagesize = self.GetScrollPageSize(wx.VERTICAL) self.Scroll(-1, maxrange-pagesize) - @debugging + def mouse_wheel(self, event): amt = event.GetWheelRotation() units = amt/(-(event.GetWheelDelta())) @@ -354,7 +356,7 @@ # set_default_font(self, font, fontsize) class chat_notebook(orpgTabberWnd): - @debugging + def __init__(self, parent, size): orpgTabberWnd.__init__(self, parent, True, size=size, style=FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_NO_NAV_BUTTONS|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS) @@ -386,7 +388,7 @@ self.create_gm_tab() self.SetSelection(0) - @debugging + def get_tab_index(self, chatpanel): "Return the index of a chatpanel in the wxNotebook." @@ -394,7 +396,7 @@ if (self.GetPage(i) == chatpanel): return i - @debugging + def create_gm_tab(self): if self.GMChatPanel == None: self.GMChatPanel = chat_panel(self, -1, MAIN_TAB, 'gm') @@ -402,7 +404,7 @@ self.SetPageImage(self.GetPageCount()-1, 1) self.GMChatPanel.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) - @debugging + def create_whisper_tab(self, playerid): "Add a new chatpanel directly connected to integer 'playerid' via whispering." private_tab = chat_panel(self, -1, WHISPER_TAB, playerid) @@ -415,7 +417,7 @@ wx.CallAfter(self.AliasLib.RefreshAliases) return private_tab - @debugging + def create_group_tab(self, group_name): "Add a new chatpanel directly connected to integer 'playerid' via whispering." private_tab = chat_panel(self, -1, GROUP_TAB, group_name) @@ -427,7 +429,7 @@ wx.CallAfter(self.AliasLib.RefreshAliases) return private_tab - @debugging + def create_null_tab(self, tab_name): "Add a new chatpanel directly connected to integer 'playerid' via whispering." private_tab = chat_panel(self, -1, NULL_TAB, tab_name) @@ -439,7 +441,7 @@ wx.CallAfter(self.AliasLib.RefreshAliases) return private_tab - @debugging + def onCloseTab(self, evt): try: tabid = evt.GetSelection() except: tabid = self.GetSelection() @@ -468,16 +470,16 @@ elif panel in self.group_tabs: self.group_tabs.remove(panel) elif panel in self.null_tabs: self.null_tabs.remove(panel) - @debugging + def newMsg(self, tabid): if tabid != self.GetSelection(): self.SetPageImage(tabid, 0) - @debugging + def onPageChanging(self, event): """When private chattabs are selected, set the bitmap back to 'normal'.""" event.Skip() - @debugging + def onPageChanged(self, event): """When private chattabs are selected, set the bitmap back to 'normal'.""" selected_idx = event.GetSelection() @@ -527,7 +529,7 @@ !sendtarget: who gets outbound messages: either 'all' or a playerid """ - @debugging + def __init__(self, parent, id, tab_type, sendtarget): wx.Panel.__init__(self, parent, id) logger._set_log_to_console(False) @@ -574,7 +576,7 @@ self.fontsize = self.chatwnd.GetFont().GetPointSize() self.scroll_down() - @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.""" @@ -588,7 +590,7 @@ self.fontsize = newfontsize return (self.font, self.fontsize) - @debugging + def build_menu(self): top_frame = component.get('frame') menu = wx.Menu() @@ -680,54 +682,54 @@ top_frame.mainmenu.Insert(2, menu, '&Chat') ## Settings Menu Events - @debugging + def OnMB_ShowImages(self, event): if event.IsChecked(): self.settings.set_setting("Show_Images_In_Chat", '1') else: self.settings.set_setting("Show_Images_In_Chat", '0') - @debugging + def OnMB_StripHTML(self, event): if event.IsChecked(): self.settings.set_setting("Sstriphtml", '1') else: self.settings.set_setting("striphtml", '0') - @debugging + def OnMB_ChatTimeIndex(self, event): if event.IsChecked(): self.settings.set_setting("Chat_Time_Indexing", '1') else: self.settings.set_setting("Chat_Time_Indexing", '0') - @debugging + def OnMB_ChatAutoComplete(self, event): if event.IsChecked(): self.settings.set_setting("SuppressChatAutoComplete", '0') else: self.settings.set_setting("SuppressChatAutoComplete", '1') - @debugging + def OnMB_ShowIDinChat(self, event): if event.IsChecked(): self.settings.set_setting("ShowIDInChat", '1') else: self.settings.set_setting("ShowIDInChat", '0') - @debugging + def OnMB_LogTimeIndex(self, event): if event.IsChecked(): self.settings.set_setting("TimeStampGameLog", '1') else: self.settings.set_setting("TimeStampGameLog", '0') - @debugging + def OnMB_TabbedWhispers(self, event): if event.IsChecked(): self.settings.set_setting("tabbedwhispers", '1') else: self.settings.set_setting("tabbedwhispers", '0') - @debugging + def OnMB_GMTab(self, event): if event.IsChecked(): self.settings.set_setting("GMWhisperTab", '1') self.parent.create_gm_tab() else: self.settings.set_setting("GMWhisperTab", '0') - @debugging + def OnMB_GroupWhisperTabs(self, event): if event.IsChecked(): self.settings.set_setting("GroupWhisperTab", '1') else: self.settings.set_setting("GroupWhisperTab", '0') - @debugging + def OnMB_DiceBar(self, event): act = '0' if event.IsChecked(): @@ -741,7 +743,7 @@ for panel in self.parent.group_tabs: panel.toggle_dice(act) for panel in self.parent.null_tabs: panel.toggle_dice(act) - @debugging + def OnMB_FormatButtons(self, event): act = '0' if event.IsChecked(): @@ -756,7 +758,7 @@ for panel in self.parent.group_tabs: panel.toggle_formating(act) for panel in self.parent.null_tabs: panel.toggle_formating(act) - @debugging + def OnMB_AliasTool(self, event): act = '0' if event.IsChecked(): @@ -770,7 +772,7 @@ for panel in self.parent.group_tabs: panel.toggle_alias(act) for panel in self.parent.null_tabs:panel.toggle_alias(act) - @debugging + def OnMB_BackgroundColor(self, event): top_frame = component.get('frame') hexcolor = self.get_color() @@ -792,7 +794,7 @@ top_frame.players.Refresh() self.chatwnd.scroll_down() - @debugging + def OnMB_TextColor(self, event): top_frame = component.get('frame') hexcolor = self.get_color() @@ -814,7 +816,7 @@ top_frame.players.Refresh() self.chatwnd.scroll_down() - @debugging + def get_hot_keys(self): # dummy menus for hotkeys self.build_menu() @@ -823,7 +825,7 @@ #entries.append((wx.ACCEL_CTRL, wx.WXK_TAB, SWAP_TABS)) return entries - @debugging + def forward_tabs(self, evt): self.parent.AdvanceSelection() @@ -833,7 +835,7 @@ # This subroutine builds the controls for the chat frame # # !self : instance of self - @debugging + def build_ctrls(self): self.chatwnd = chat_html_window(self,-1) self.set_colors() @@ -881,7 +883,7 @@ self.chattxt.Bind(wx.EVT_TEXT_COPY, self.chatwnd.OnM_EditCopy) # def build_ctrls - end - @debugging + def build_bar(self): self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL) self.scroll_lock = None @@ -897,11 +899,11 @@ self.build_formating() self.build_colorbutton() - @debugging + def build_scroll(self): self.scroll_lock = wx.Button( self, wx.ID_ANY, "Scroll ON",size= wx.Size(80,25)) - @debugging + def build_alias(self): self.aliasList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultAliasName]) self.aliasButton = createMaskedButton( self, dir_struct["icon"] + 'player.gif', @@ -918,7 +920,7 @@ if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0') else: self.toggle_alias('1') - @debugging + def toggle_alias(self, act): if act == '0': self.toolbar_sizer.Show(self.aliasList, False) @@ -933,11 +935,11 @@ self.toolbar_sizer.Show(self.filterButton, True) self.toolbar_sizer.Layout() - @debugging + def build_text(self): 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.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() ) @@ -960,7 +962,7 @@ if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0') else: self.toggle_dice('1') - @debugging + def toggle_dice(self, act): if act == '0': self.toolbar_sizer.Show(self.numDieText, False) @@ -985,7 +987,7 @@ self.toolbar_sizer.Show(self.dieModText, True) self.toolbar_sizer.Layout() - @debugging + def build_formating(self): self.boldButton = createMaskedButton( self, dir_struct["icon"]+'bold.gif', 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd') @@ -999,7 +1001,7 @@ if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0') else: self.toggle_formating('1') - @debugging + def toggle_formating(self, act): if act == '0': self.toolbar_sizer.Show(self.boldButton, False) @@ -1013,7 +1015,7 @@ self.toolbar_sizer.Layout() # Heroman - Ideally, we would use static labels... - @debugging + def build_colorbutton(self): self.color_button = createMaskedButton(self, dir_struct["icon"]+'textcolor.gif', 'Text Color', wx.ID_ANY, '#bdbdbd', @@ -1026,7 +1028,7 @@ self.toolbar_sizer.Add(self.color_button, 0, wx.EXPAND) self.toolbar_sizer.Add(self.saveButton, 0, wx.EXPAND) - @debugging + def OnMotion(self, evt): contain = self.chatwnd.GetInternalRepresentation() if contain: @@ -1052,7 +1054,7 @@ # # self: duh # event: raw KeyEvent from OnChar() - @debugging + def myKeyHook(self, event): if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected thisPress = time.time() # thisPress is local temp variable @@ -1072,7 +1074,7 @@ # It checks if we need to send a not_typing message # # self: duh - @debugging + def typingTimerFunc(self, event): #following added by mDuo13 ##############refresh_counter()############## @@ -1095,7 +1097,7 @@ # self: duh # typing: boolean - @debugging + def sendTyping(self, typing): if typing: self.lastSend = time.time() # remember our send time for use in myKeyHook() @@ -1114,7 +1116,7 @@ # self instance. # # !self : instance of self - @debugging + def set_colors(self): # chat window backround color self.bgcolor = self.settings.get_setting('bgcolor') @@ -1136,19 +1138,19 @@ # # !self : instance of self # !txt : text to be inserted into the chat window - @debugging + def set_chat_text(self, txt): self.chattxt.SetValue(txt) self.chattxt.SetFocus() self.chattxt.SetInsertionPointEnd() # def set_chat_text - end - @debugging + def get_chat_text(self): return self.chattxt.GetValue() # This subroutine sets the focus to the chat window - @debugging + def set_chat_text_focus(self, event): wx.CallAfter(self.chattxt.SetFocus) # def set_chat_text_focus - end @@ -1161,7 +1163,7 @@ # # 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. - @debugging + def OnChar(self, event): s = self.chattxt.GetValue() #self.histlen = len(self.history) - 1 @@ -1302,7 +1304,7 @@ logger.debug("Exit chat_panel->OnChar(self, event)") # def OnChar - end - @debugging + def onDieRoll(self, evt): """Roll the dice based on the button pressed and the die modifiers entered, if any.""" # Get any die modifiers if they have been entered @@ -1323,7 +1325,7 @@ # # !self : instance of self # !evt : - @debugging + def on_chat_save(self, evt): f = wx.FileDialog(self,"Save Chat Buffer",".","","HTM* (*.htm*)|*.htm*|HTML (*.html)|*.html|HTM (*.htm)|*.htm",wx.SAVE) if f.ShowModal() == wx.ID_OK: @@ -1334,7 +1336,7 @@ os.chdir(dir_struct["home"]) # def on_chat_save - end - @debugging + def ResetPage(self): self.set_colors() buffertext = self.chatwnd.Header() + "\n" @@ -1346,7 +1348,7 @@ # This subroutine sets the color of selected text, or base text color if # nothing is selected - @debugging + def on_text_color(self, event): hexcolor = self.r_h.do_hex_color_dlg(self) if hexcolor != None: @@ -1370,7 +1372,7 @@ # !self : instance of self # !color : color for the text to be set # !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""" return "<font color='" + color + "'>" + text + "</font>" @@ -1381,7 +1383,7 @@ # # !self : instance of self # !event : - @debugging + def on_text_format(self, event): id = event.GetId() txt = self.chattxt.GetValue() @@ -1398,7 +1400,7 @@ self.chattxt.SetFocus() # def on_text_format - end - @debugging + def lock_scroll(self, event): if self.lockscroll: self.lockscroll = False @@ -1415,7 +1417,7 @@ # # !self : instance of self # !event : - @debugging + def pop_textpop(self, event): """searchable popup text view of chatbuffer""" h_buffertext = self.ResetPage() @@ -1426,35 +1428,35 @@ # # !self : instance of self # !event : - @debugging + def OnSize(self, event=None): event.Skip() wx.CallAfter(self.scroll_down) # def OnSize - end - @debugging + def scroll_down(self): self.Freeze() self.chatwnd.scroll_down() self.Thaw() ###### message helpers ###### - @debugging + def PurgeChat(self): self.set_colors() self.chatwnd.SetPage(self.chatwnd.Header()) - @debugging + def system_message(self, text): self.send_chat_message(text,chat_msg.SYSTEM_MESSAGE) self.SystemPost(text) - @debugging + def info_message(self, text): self.send_chat_message(text,chat_msg.INFO_MESSAGE) self.InfoPost(text) - @debugging + def get_gms(self): the_gms = [] for playerid in self.session.players: @@ -1462,7 +1464,7 @@ if self.session.players[playerid][7]=="GM" and self.session.group_id != '0': the_gms += [playerid] return the_gms - @debugging + def GetName(self): self.AliasLib = component.get('alias') player = self.session.get_my_info() @@ -1473,7 +1475,7 @@ return [self.chat_display_name([self.AliasLib.alias[0], player[1], player[2]]), self.AliasLib.alias[1]] return [self.chat_display_name(player), "Default"] - @debugging + def GetFilteredText(self, text): advregex = re.compile('\"(.*?)\"', re.I) self.AliasLib = component.get('alias') @@ -1488,7 +1490,7 @@ text = text.replace(match, newmatch) return text - @debugging + def emote_message(self, text): text = self.NormalizeParse(text) text = self.colorize(self.emotecolor, text) @@ -1507,7 +1509,7 @@ text = "** " + name + " " + text + " **" self.EmotePost(text) - @debugging + def whisper_to_players(self, text, player_ids): tabbed_whispers_p = self.settings.get_setting("tabbedwhispers") # Heroman - apply any filtering selected @@ -1534,7 +1536,7 @@ if self.session.is_valid_id(id): self.send_chat_message(text,chat_msg.WHISPER_MESSAGE,id) else: self.InfoPost(id + " Unknown!") - @debugging + def send_chat_message(self, text, type=chat_msg.CHAT_MESSAGE, player_id="all"): #########send_msg()############# send = 1 @@ -1560,7 +1562,7 @@ del msg #### incoming chat message handler ##### - @debugging + def post_incoming_msg(self, msg, player): # pull data @@ -1684,20 +1686,20 @@ component.get('sound').play(sound_file) #### Posting helpers ##### - @debugging + def InfoPost(self, s): self.Post(self.colorize(self.infocolor, s), c='info') - @debugging + def SystemPost(self, s): self.Post(self.colorize(self.syscolor, s), c='system') - @debugging + def EmotePost(self, s): self.Post(self.colorize(self.emotecolor, s), c='emote') #### Standard Post method ##### - @debugging + def Post(self, s="", send=False, myself=False, c='post'): strip_p = self.settings.get_setting("striphtml") strip_img = self.settings.get_setting("Show_Images_In_Chat")#moved back 7-11-05. --mDuo13 @@ -1794,7 +1796,7 @@ # # time indexing for chat display only (don't log time indexing) # added by Snowdog 4/04 - @debugging + def TimeIndexString(self): try: mtime = "" @@ -1808,13 +1810,13 @@ return "[ERROR]" #### Post with parsing dice #### - @debugging + def ParsePost(self, s, send=False, myself=False): s = self.NormalizeParse(s) self.set_colors() self.Post(s,send,myself) - @debugging + def NormalizeParse(self, s): for plugin_fname in self.activeplugins.keys(): plugin = self.activeplugins[plugin_fname] @@ -1830,24 +1832,25 @@ self.parsed = 1 return s - @debugging + def ParseFilter(self, s): s = self.GetFilteredText(s) return s - @debugging + def ParseNode(self, s): """Parses player input for embedded nodes rolls""" cur_loc = 0 #[a-zA-Z0-9 _\-\.] - reg = re.compile("(!@([a-zA-Z0-9 _\-\./]+(::[a-zA-Z0-9 _\-\./]+)*)@!)") + debug(s) + reg = re.compile("(!@(.*?)@!)") matches = reg.findall(s) for i in xrange(0,len(matches)): newstr = self.ParseNode(self.resolve_nodes(matches[i][1])) s = s.replace(matches[i][0], newstr, 1) return s - @debugging + def ParseDice(self, s): """Parses player input for embedded dice rolls""" reg = re.compile("\[([^]]*?)\]") @@ -1866,7 +1869,7 @@ else: s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "<!-- Official Roll -->] => " + newstr, 1) return s - @debugging + def PraseUnknowns(self, s): # Uses a tuple. Usage: ?Label}dY. If no Label is assigned then use ?}DY newstr = "0" @@ -1888,7 +1891,7 @@ # This subroutine builds a chat display name. # - @debugging + def chat_display_name(self, player): if self.settings.get_setting("ShowIDInChat") == "0": display_name = player[0] @@ -1898,7 +1901,7 @@ # This subroutine will get a hex color and return it, or return nothing # - @debugging + def get_color(self): data = wx.ColourData() data.SetChooseFull(True) @@ -1914,7 +1917,7 @@ return None # def get_color - end - @debugging + def replace_quotes(self, s): in_tag = 0 i = 0 @@ -1931,47 +1934,41 @@ i += 1 return rs - @debugging - def resolve_loop(self, dom, nodeName, doLoop = False): - for node in dom: - if node._get_tagName() != 'nodehandler': - continue - if doLoop and node.getAttribute('class') != 'textctrl_handler' and node.hasChildNodes(): - (found, node) = self.resolve_loop(node.getChildren(), nodeName, doLoop) - if not found: - continue - if node.getAttribute('name') != nodeName: - continue - foundNode = node - return (True, foundNode) - return (False, '') + def resolve_loop(self, node, path, step, depth): + debug((node.get('name'), step, depth)) + if step == depth: + self.resolution(node) + else: + child_list = node.findall('nodehandler') + debug(child_list) + for child in child_list: + if step == depth: break + if child.get('name') == path[step]: + debug(('Step', child.get('name'), step, path, path[step])) + node = child + step += 1 + self.resolve_loop(node, path, step, depth) - @debugging + def resolution(self, node): + debug(node) + if self.passed == False: + self.passed = True + if node.get('class') == 'textctrl_handler': self.data = str(node.find('text').text) + else: self.data = 'Nodehandler for '+ node.get('class') + ' not done!' or 'No Data!' + else: + self.data = '' + pass + def resolve_nodes(self, s): + self.passed = False + self.data = 'No Data!' value = "" - node_path_list = s.split("::") + path = s.split('::') + depth = len(path) gametree = component.get('tree') - dom = gametree.master_dom.getChildren() - for nodeName in node_path_list: - (found, node) = self.resolve_loop(dom, nodeName) - if not found: - break - dom = node.getChildren() - if not found: - dom = gametree.master_dom.getChildren() - loop = False - if len(node_path_list) == 1: - loop = True - for nodeName in node_path_list: - (found, node) = self.resolve_loop(dom, nodeName, loop) - if not found: - break - dom = node.getChildren() - loop = True - if found: - text = node.getElementsByTagName('text') - node = text[0]._get_firstChild() - value = node._get_nodeValue() - else: - value = s - return value + dom = gametree.xml_root.getchildren() + for node in dom: + debug((node.get('name'), path[0])) + if node.get('name') == path[0]: + self.resolve_loop(node, path, 1, len(path)) + return self.data