# HG changeset patch # User sirebral # Date 1257257926 21600 # Node ID 43ad912b7c17fbebf0d117efb86720290b00a297 # Parent fba298d65cf82114f90fb4d4e503436802464de1 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! diff -r fba298d65cf8 -r 43ad912b7c17 orpg/chat/chatwnd.py --- 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 '' - @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 "" - @debugging + def StripHeader(self): tmp = self.GetPageSource().split('') if tmp[-1].find('') > -1: tmp = tmp[-1].split('') 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 "" + text + "" @@ -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 + "] => " + 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 diff -r fba298d65cf8 -r 43ad912b7c17 orpg/gametree/gametree.py --- a/orpg/gametree/gametree.py Tue Nov 03 00:52:47 2009 -0600 +++ b/orpg/gametree/gametree.py Tue Nov 03 08:18:46 2009 -0600 @@ -42,8 +42,7 @@ from orpg.orpg_xml import xml from orpg.tools.validate import validate -from orpg.tools.orpg_log import logger -from orpg.tools.decorators import debugging +from orpg.tools.orpg_log import logger, debug from orpg.tools.orpg_settings import settings from orpg.gametree.nodehandlers import containers, forms, dnd3e, dnd35, chatmacro from orpg.gametree.nodehandlers import map_miniature_nodehandler @@ -84,7 +83,7 @@ TOP_FEATURES = wx.NewId() class game_tree(wx.TreeCtrl): - @debugging + def __init__(self, parent, id): wx.TreeCtrl.__init__(self,parent,id, wx.DefaultPosition, wx.DefaultSize,style=wx.TR_EDIT_LABELS | wx.TR_HAS_BUTTONS) @@ -121,18 +120,18 @@ self.image_cache = {} logger.debug("Exit game_tree") - @debugging + def add_nodehandler(self, nodehandler, nodeclass): if not self.nodehandlers.has_key(nodehandler): self.nodehandlers[nodehandler] = nodeclass else: logger.debug("Nodehandler for " + nodehandler + " already exists!") - @debugging + def remove_nodehandler(self, nodehandler): if self.nodehandlers.has_key(nodehandler): del self.nodehandlers[nodehandler] else: logger.debug("No nodehandler for " + nodehandler + " exists!") - @debugging + def init_nodehandlers(self): self.add_nodehandler('group_handler', containers.group_handler) self.add_nodehandler('tabber_handler', containers.tabber_handler) @@ -159,7 +158,7 @@ # event = wxKeyEvent # set to be called by wxWindows by EVT_CHAR macro in __init__ - @debugging + def on_key_up(self, evt): key_code = evt.GetKeyCode() if self.dragging and (key_code == wx.WXK_SHIFT): @@ -174,7 +173,7 @@ self.drag_obj = None evt.Skip() - @debugging + def on_char(self, evt): key_code = evt.GetKeyCode() curSelection = self.GetSelection() # Get the current selection @@ -200,7 +199,7 @@ self.EditLabel(curSelection) evt.Skip() - @debugging + def locate_valid_tree(self, error, msg): ## --Snowdog 3/05 """prompts the user to locate a new tree file or create a new one""" response = wx.MessageDialog(self, msg, error, wx.YES|wx.NO|wx.ICON_ERROR) @@ -220,7 +219,7 @@ self.load_tree(error=1) return - @debugging + def load_tree(self, filename=dir_struct["user"]+'tree.xml', error=0): self.settings.change("gametree", filename) #check file exists @@ -291,7 +290,7 @@ validate.config_file("tree.xml","default_tree.xml") self.load_tree(error=1) - @debugging + def build_std_menu(self, obj=None): # build useful menu useful_menu = wx.Menu() @@ -353,14 +352,14 @@ 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) - @debugging + def do_std_menu(self, evt, obj): 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) - @debugging + def strip_html(self, player): ret_string = "" x = 0 @@ -374,7 +373,7 @@ logger.debug(ret_string) return ret_string - @debugging + def on_receive_data(self, data, player): if iselement(data): tostring(data) @@ -383,13 +382,13 @@ data = data[6:end] self.insert_xml(data) - @debugging + def on_send_to_chat(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.on_send_to_chat(evt) - @debugging + def on_whisper_to(self, evt): players = self.session.get_players() opts = [] @@ -412,7 +411,7 @@ player_ids.append(players[s][2]) self.chat.whisper_to_players(obj.tohtml(),player_ids) - @debugging + def on_export_html(self, evt): f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","HTML (*.html)|*.html",wx.SAVE) if f.ShowModal() == wx.ID_OK: @@ -429,29 +428,29 @@ f.Destroy() os.chdir(dir_struct["home"]) - @debugging + def indifferent(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.usefulness("indifferent") - @debugging + def useful(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.usefulness("useful") - @debugging + def useless(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.usefulness("useless") - @debugging + def on_email(self,evt): pass - @debugging + def on_send_to(self, evt): players = self.session.get_players() opts = [] @@ -473,7 +472,7 @@ for s in selections: self.session.send(xmldata,players[s][2]) dlg.Destroy() - @debugging + def on_icon(self, evt): icons = self.icons.keys() icons.sort() @@ -485,19 +484,20 @@ obj.change_icon(key) dlg.Destroy() - @debugging + def on_wizard(self, evt): item = self.GetSelection() + debug((item)) obj = self.GetPyData(item) - name = "New " + obj.master_dom.getAttribute("name") - icon = obj.master_dom.getAttribute("icon") + name = "New " + obj.xml_root.get("name") + icon = obj.xml_root.get("icon") xml_data = "" xml_data += xml.toxml(obj) xml_data += "" self.insert_xml(xml_data) logger.debug(xml_data) - @debugging + def on_clone(self, evt): item = self.GetSelection() obj = self.GetPyData(item) @@ -514,7 +514,7 @@ break self.load_xml(clone_xml, parent_node, prev_sib) - @debugging + def on_save(self, evt): """save node to a xml file""" item = self.GetSelection() @@ -522,7 +522,7 @@ obj.on_save(evt) os.chdir(dir_struct["home"]) - @debugging + def on_save_tree_as(self, evt): f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.SAVE) if f.ShowModal() == wx.ID_OK: @@ -531,18 +531,18 @@ f.Destroy() os.chdir(dir_struct["home"]) - @debugging + def on_save_tree(self, evt=None): filename = self.settings.get_setting("gametree") self.save_tree(filename) - @debugging + def save_tree(self, filename=dir_struct["user"]+'tree.xml'): self.xml_root.set("version",GAMETREE_VERSION) settings.change("gametree",filename) ElementTree(self.xml_root).write(filename) - @debugging + def on_load_new_tree(self, evt): f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.OPEN) if f.ShowModal() == wx.ID_OK: @@ -551,7 +551,7 @@ f.Destroy() os.chdir(dir_struct["home"]) - @debugging + def on_insert_file(self, evt): """loads xml file into the tree""" if self.last_save_dir == ".": @@ -563,7 +563,7 @@ f.Destroy() os.chdir(dir_struct["home"]) - @debugging + def on_insert_url(self, evt): """loads xml url into the tree""" dlg = wx.TextEntryDialog(self,"URL?","Insert URL", "http://") @@ -573,35 +573,35 @@ self.insert_xml(file.read()) dlg.Destroy() - @debugging + def on_insert_features(self, evt): self.insert_xml(open(dir_struct["template"]+"feature.xml","r").read()) - @debugging + def on_tree_prop(self, evt): dlg = gametree_prop_dlg(self, self.settings) if dlg.ShowModal() == wx.ID_OK: pass dlg.Destroy() - @debugging + def on_node_design(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.on_design(evt) - @debugging + def on_node_use(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.on_use(evt) - @debugging + def on_node_pp(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.on_html_view(evt) - @debugging + def on_del(self, evt): status_value = "none" try: @@ -634,7 +634,7 @@ msg.ShowModal() msg.Destroy() - @debugging + def on_about(self, evt): item = self.GetSelection() obj = self.GetPyData(item) @@ -642,13 +642,13 @@ about.ShowModal() about.Destroy() - @debugging + def on_send_to_map(self, evt): item = self.GetSelection() obj = self.GetPyData(item) if hasattr(obj,"on_send_to_map"): obj.on_send_to_map(evt) - @debugging + def insert_xml(self, txt): #Updated to allow safe merging of gametree files #without leaving an unusable and undeletable node. @@ -673,7 +673,7 @@ self.xml_root.append(new_xml) self.load_xml(new_xml,self.root,self.root) - @debugging + def build_img_list(self): """make image list""" helper = img_helper() @@ -687,7 +687,7 @@ self.icons[key] = self._imageList.Add(img) self.SetImageList(self._imageList) - @debugging + def load_xml(self, xml_element, parent_node, prev_node=None): #add the first tree node i = 0 @@ -725,7 +725,7 @@ return new_tree_node - @debugging + def cached_load_of_image(self, bmp_in, new_tree_node): image_list = self.GetImageList() img = wx.ImageFromBitmap(bmp_in) @@ -743,7 +743,7 @@ self.SetItemImage(new_tree_node,image_index, wx.TreeItemIcon_Selected) return image_index - @debugging + def on_rclick(self, evt): pt = evt.GetPosition() (item, flag) = self.HitTest(pt) @@ -754,7 +754,7 @@ else: self.PopupMenu(self.top_menu) else: self.PopupMenu(self.top_menu,pt) - @debugging + def on_ldclick(self, evt): self.rename_flag = 0 pt = evt.GetPosition() @@ -770,7 +770,7 @@ elif action == "print": obj.on_html_view(evt) elif action == "chat": self.on_send_to_chat(evt) - @debugging + def on_left_down(self, evt): pt = evt.GetPosition() (item, flag) = self.HitTest(pt) @@ -784,7 +784,7 @@ else: self.SelectItem(item) evt.Skip() - @debugging + def on_left_up(self, evt): if self.dragging: cur = wx.StockCursor(wx.CURSOR_ARROW) @@ -807,7 +807,7 @@ self.traverse(child, function, data) child, cookie = self.GetNextChild(root, cookie) - @debugging + def on_label_change(self, evt): item = evt.GetItem() txt = evt.GetLabel() @@ -815,10 +815,10 @@ self.rename_flag = 0 if txt != "": obj = self.GetPyData(item) - obj.master_dom.setAttribute('name',txt) + obj.xml_root.setAttribute('name',txt) else: evt.Veto() - @debugging + def on_label_begin(self, evt): if not self.rename_flag: evt.Veto() else: @@ -827,7 +827,7 @@ if item == self.GetRootItem(): evt.Veto() - @debugging + def on_drag(self, evt): self.rename_flag = 0 item = self.GetSelection() @@ -839,7 +839,7 @@ self.SetCursor(cur) self.drag_obj = obj - @debugging + def is_parent_node(self, node, compare_node): parent_node = self.GetItemParent(node) if compare_node == parent_node: @@ -859,7 +859,7 @@ CTRL_PRINT = wx.NewId() class gametree_prop_dlg(wx.Dialog): - @debugging + def __init__(self, parent, settings): wx.Dialog.__init__(self, parent, wx.ID_ANY, "Game Tree Properties") self.settings = settings @@ -918,7 +918,7 @@ self.Fit() self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK) - @debugging + def on_ok(self,evt): self.settings.change("gametree",self.ctrls[CTRL_TREE_FILE].GetValue()) self.settings.change("SaveGameTreeOnExit",str(self.ctrls[CTRL_YES].GetValue())) diff -r fba298d65cf8 -r 43ad912b7c17 orpg/gametree/nodehandlers/forms.py --- a/orpg/gametree/nodehandlers/forms.py Tue Nov 03 00:52:47 2009 -0600 +++ b/orpg/gametree/nodehandlers/forms.py Tue Nov 03 08:18:46 2009 -0600 @@ -264,7 +264,7 @@ def on_text(self,evt): txt = self.text.GetValue() - txt = strip_text(txt) + #txt = strip_text(txt) ##Does not seem to exist. self.handler.text_elem.text = txt def on_send(self,evt): @@ -343,7 +343,7 @@ self.handler.rename(txt) if id == F_TEXT: txt = self.text.GetValue() - txt = strip_text(txt) + #txt = strip_text(txt) ##Does not seem to exist. self.handler.text_elem.text = txt def on_button(self,evt): diff -r fba298d65cf8 -r 43ad912b7c17 orpg/orpg_version.py --- a/orpg/orpg_version.py Tue Nov 03 00:52:47 2009 -0600 +++ b/orpg/orpg_version.py Tue Nov 03 08:18:46 2009 -0600 @@ -4,7 +4,7 @@ #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed) DISTRO = "Traipse Alpha" DIS_VER = "Ornery Orc" -BUILD = "091003-00" +BUILD = "091003-01" # This version is for network capability. PROTOCOL_VERSION = "1.2"