Mercurial > traipse_dev
diff orpg/chat/chatwnd.py @ 138:1ed2feab0db9 alpha
Traipse Alpha 'OpenRPG' {091021-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 (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
Pretty important update that can help remove thousands of dead children from your gametree.
Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check
your gametree and look for dead children!!
New Gametree Recursion method, mapping, and context sensitivity. !!Alpha Still- Watch out for infinite loops!!
New Syntax added for custom PC sheets
Tip of the Day added, from Core and community
Fixed Whiteboard ID to prevent random line or text deleting. Appended tr_ to ID's to prevent non updated clients from
ruining the fix.
author | sirebral |
---|---|
date | Sat, 21 Nov 2009 03:19:34 -0600 |
parents | b4e02e8cd314 |
children | 2ffc5de126c8 |
line wrap: on
line diff
--- a/orpg/chat/chatwnd.py Wed Nov 18 19:57:52 2009 -0600 +++ b/orpg/chat/chatwnd.py Sat Nov 21 03:19:34 2009 -0600 @@ -228,7 +228,7 @@ return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize()) # class chat_html_window - end -if NEWCHAT: +if NEWCHAT: class ChatHtmlWindow(wx.webview.WebView): def __init__(self, parent, id): @@ -241,23 +241,18 @@ self.Bind(wx.webview.EVT_WEBVIEW_BEFORE_LOAD, self.OnLinkClicked) #Wrapers so I dont have to add special Code - def SetPage(self, htmlstring): self.SetPageSource(htmlstring) - - def AppendToPage(self, htmlstring): + def AppendToPage(self, htmlstring): self.SetPageSource(self.GetPageSource() + htmlstring) - def GetFont(self): return self.__font - def CalculateAllFonts(self, defaultsize): return - def SetDefaultFontAndSize(self, fontname, fontsize): self.__font = wx.Font(int(fontsize), wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, @@ -267,22 +262,18 @@ return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize()) #Events - def OnLinkClicked(self, linkinfo): href = linkinfo.GetHref() wb = webbrowser.get() wb.open(href) - def onPopup(self, evt): self.PopupMenu(self.menu) - def LeftUp(self, event): event.Skip() wx.CallAfter(self.parent.set_chat_text_focus, None) - def OnM_EditCopy(self, evt): wx.TheClipboard.UsePrimarySelection(False) wx.TheClipboard.Open() @@ -290,30 +281,25 @@ wx.TheClipboard.Close() #Cutom Methods - 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>" - def StripHeader(self): tmp = self.GetPageSource().split('<BODY>') if tmp[-1].find('<body>') > -1: tmp = tmp[-1].split('<body>') return tmp[-1] - 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) - def scroll_down(self): maxrange = self.GetScrollRange(wx.VERTICAL) pagesize = self.GetScrollPageSize(wx.VERTICAL) self.Scroll(-1, maxrange-pagesize) - def mouse_wheel(self, event): amt = event.GetWheelRotation() units = amt/(-(event.GetWheelDelta())) @@ -379,7 +365,6 @@ self.create_gm_tab() self.SetSelection(0) - def get_tab_index(self, chatpanel): "Return the index of a chatpanel in the wxNotebook." @@ -387,7 +372,6 @@ if (self.GetPage(i) == chatpanel): return i - def create_gm_tab(self): if self.GMChatPanel == None: self.GMChatPanel = chat_panel(self, -1, MAIN_TAB, 'gm') @@ -395,7 +379,6 @@ self.SetPageImage(self.GetPageCount()-1, 1) self.GMChatPanel.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) - 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) @@ -408,7 +391,6 @@ wx.CallAfter(self.AliasLib.RefreshAliases) return private_tab - 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) @@ -420,7 +402,6 @@ wx.CallAfter(self.AliasLib.RefreshAliases) return private_tab - 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) @@ -432,11 +413,9 @@ wx.CallAfter(self.AliasLib.RefreshAliases) return private_tab - def onCloseTab(self, evt): try: tabid = evt.GetSelection() except: tabid = self.GetSelection() - if self.GetPageText(tabid) == 'Main Room': #send no close error to chat evt.Veto() @@ -445,7 +424,6 @@ msg = "Are You Sure You Want To Close This Page?" dlg = wx.MessageDialog(self, msg, "NotebookCtrl Question", wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) - if wx.Platform != '__WXMAC__': dlg.SetFont(wx.Font(8, wx.NORMAL, wx.NORMAL, wx.NORMAL, False)) @@ -461,16 +439,13 @@ elif panel in self.group_tabs: self.group_tabs.remove(panel) elif panel in self.null_tabs: self.null_tabs.remove(panel) - def newMsg(self, tabid): if tabid != self.GetSelection(): self.SetPageImage(tabid, 0) - def onPageChanging(self, event): """When private chattabs are selected, set the bitmap back to 'normal'.""" event.Skip() - def onPageChanged(self, event): """When private chattabs are selected, set the bitmap back to 'normal'.""" selected_idx = event.GetSelection() @@ -567,7 +542,6 @@ self.fontsize = self.chatwnd.GetFont().GetPointSize() self.scroll_down() - 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.""" @@ -581,7 +555,6 @@ self.fontsize = newfontsize return (self.font, self.fontsize) - def build_menu(self): top_frame = component.get('frame') menu = wx.Menu() @@ -673,54 +646,44 @@ top_frame.mainmenu.Insert(2, menu, '&Chat') ## Settings Menu Events - 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') - def OnMB_StripHTML(self, event): - if event.IsChecked(): self.settings.set_setting("Sstriphtml", '1') + if event.IsChecked(): self.settings.set_setting("striphtml", '1') else: self.settings.set_setting("striphtml", '0') - 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') - def OnMB_ChatAutoComplete(self, event): if event.IsChecked(): self.settings.set_setting("SuppressChatAutoComplete", '0') else: self.settings.set_setting("SuppressChatAutoComplete", '1') - def OnMB_ShowIDinChat(self, event): if event.IsChecked(): self.settings.set_setting("ShowIDInChat", '1') else: self.settings.set_setting("ShowIDInChat", '0') - def OnMB_LogTimeIndex(self, event): if event.IsChecked(): self.settings.set_setting("TimeStampGameLog", '1') else: self.settings.set_setting("TimeStampGameLog", '0') - def OnMB_TabbedWhispers(self, event): if event.IsChecked(): self.settings.set_setting("tabbedwhispers", '1') else: self.settings.set_setting("tabbedwhispers", '0') - 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') - def OnMB_GroupWhisperTabs(self, event): if event.IsChecked(): self.settings.set_setting("GroupWhisperTab", '1') else: self.settings.set_setting("GroupWhisperTab", '0') - def OnMB_DiceBar(self, event): act = '0' if event.IsChecked(): @@ -734,7 +697,6 @@ for panel in self.parent.group_tabs: panel.toggle_dice(act) for panel in self.parent.null_tabs: panel.toggle_dice(act) - def OnMB_FormatButtons(self, event): act = '0' if event.IsChecked(): @@ -749,7 +711,6 @@ for panel in self.parent.group_tabs: panel.toggle_formating(act) for panel in self.parent.null_tabs: panel.toggle_formating(act) - def OnMB_AliasTool(self, event): act = '0' if event.IsChecked(): @@ -763,7 +724,6 @@ for panel in self.parent.group_tabs: panel.toggle_alias(act) for panel in self.parent.null_tabs:panel.toggle_alias(act) - def OnMB_BackgroundColor(self, event): top_frame = component.get('frame') hexcolor = self.get_color() @@ -842,7 +802,7 @@ self.basesizer = wx.BoxSizer(wx.VERTICAL) self.basesizer.Add( self.chatwnd, 1, wx.EXPAND ) self.basesizer.Add( self.toolbar_sizer, 0, wx.EXPAND ) - self.basesizer.Add( self.chattxt, 0, wx.EXPAND ) + self.basesizer.Add( self.chattxt, 0, wx.EXPAND ) self.SetSizer(self.basesizer) self.SetAutoLayout(True) self.Fit() @@ -874,7 +834,6 @@ self.chattxt.Bind(wx.EVT_TEXT_COPY, self.chatwnd.OnM_EditCopy) # def build_ctrls - end - def build_bar(self): self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL) self.scroll_lock = None @@ -896,14 +855,16 @@ def build_alias(self): - self.aliasSizer = wx.BoxSizer(wx.HORIZONTAL) ## Future ## Add these to a sizer, then turn the toolbar_sizer into a grid so these can adjust to the frame. + self.aliasSizer = wx.BoxSizer(wx.HORIZONTAL) self.aliasList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultAliasName]) self.aliasButton = createMaskedButton( self, dir_struct["icon"] + 'player.gif', - 'Refresh list of aliases from Game Tree', wx.ID_ANY, '#bdbdbd' ) + '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, dir_struct["icon"] + 'add_filter.gif', - 'Refresh list of filters from Game Tree', wx.ID_ANY, '#bdbdbd' ) + 'Refresh list of filters from Game Tree', + wx.ID_ANY, '#bdbdbd' ) self.filterList.SetSelection(0) self.aliasSizer.Add( self.aliasButton, 0, wx.EXPAND ) @@ -1711,9 +1672,9 @@ except: # HTML parser has errored out (most likely). Being as all we are doing is # scanning for empty/blank lines anyway there is no harm in letting a - # troublesome message though. Worst case is a blank line to chat. + # troublesome message though. Worst case is a blank line to chat. lineHasText = 1 - if lineHasText: + if lineHasText: #following added by mDuo13 if myself: s2 = s @@ -1740,8 +1701,8 @@ newline = "<div class='"+c+"'> " + self.TimeIndexString() + name + s + "</div>" log( self.settings, c, name+s ) else: send = False - newline = component.get('xml').strip_unicode(newline) - if self.lockscroll == 0: + newline = chat_util.strip_unicode(newline) + if self.lockscroll == 0: self.chatwnd.AppendToPage(newline) self.scroll_down() else: self.storedata.append(newline) @@ -1783,7 +1744,6 @@ s = self.NormalizeParse(s) self.set_colors() self.Post(s,send,myself) - def NormalizeParse(self, s): for plugin_fname in self.activeplugins.keys(): @@ -1799,7 +1759,6 @@ s = self.ParseFilter(s) self.parsed = 1 return s - def ParseFilter(self, s): s = self.GetFilteredText(s) @@ -1815,7 +1774,6 @@ newstr = self.ParseNode(self.resolve_nodes(matches[i][1])) s = s.replace(matches[i][0], newstr, 1) return s - def ParseDice(self, s): """Parses player input for embedded dice rolls""" @@ -1834,7 +1792,6 @@ s = s.replace("[" + matches[i] + "]", "<!-- Official Roll [" + newstr1 + "] => " + newstr + "-->" + newstr, 1) else: s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "<!-- Official Roll -->] => " + newstr, 1) return s - def PraseUnknowns(self, s): # Uses a tuple. Usage: ?Label}dY. If no Label is assigned then use ?}DY @@ -1857,7 +1814,6 @@ # This subroutine builds a chat display name. # - def chat_display_name(self, player): if self.settings.get_setting("ShowIDInChat") == "0": display_name = player[0] @@ -1867,7 +1823,6 @@ # This subroutine will get a hex color and return it, or return nothing # - def get_color(self): data = wx.ColourData() data.SetChooseFull(True) @@ -1883,7 +1838,6 @@ return None # def get_color - end - def replace_quotes(self, s): in_tag = 0 i = 0 @@ -1910,14 +1864,26 @@ if child.get('name') == path[step]: node = child step += 1 - if node.get('class') in ('dnd35char_handler', "SWd20char_handler", "d20char_handler", "dnd3echar_handler"): self.resolve_cust_loop(node, path, step, depth) + if node.get('class') in ('dnd35char_handler', "SWd20char_handler", "d20char_handler", "dnd3echar_handler"): self.resolve_cust_loop(node, path, step, depth) + elif node.get('class') == 'rpg_grid_handler': self.resolve_grid(node, path, step, depth) else: self.resolve_loop(node, path, step, depth) + + def resolve_grid(self, node, path, step, depth): + if step == depth: + self.data = 'Invalid Grid Reference!' + return + cell = tuple(path[step].strip('(').strip(')').split(',')) + grid = node.find('grid') + rows = grid.findall('row') + col = rows[int(cell[0])].findall('cell') + self.data = col[int(cell[1])].text or 'No Cell Data!' + return + def resolve_cust_loop(self, node, path, step, depth): node_class = node.get('class') if step == depth: self.resolution(node) - ##Build Abilities dictionary## if node_class not in ('d20char_handler', "SWd20char_handler"): ab = node.find('character').find('abilities') else: ab = node.find('abilities') @@ -1930,7 +1896,6 @@ if node_class not in ('d20char_handler', "SWd20char_handler"): ab = node.find('character').find('saves') else: ab = node.find('saves') ab_list = ab.findall('save') - for save in ab_list: pc_stats[save.get('name')] = ( str(save.get('base')), str(int(save.get('magmod')) + int(save.get('miscmod')) + int(pc_stats[save.get('stat')][1]) ) ) if save.get('name') == 'Fortitude': abbr = 'Fort' @@ -1938,65 +1903,62 @@ if save.get('name') == 'Will': abbr = 'Will' pc_stats[abbr] = ( str(save.get('base')), str(int(save.get('magmod')) + int(save.get('miscmod')) + int(pc_stats[save.get('stat')][1]) ) ) - if path[step] == 'Skill': + if path[step].lower() == 'skill': if node_class not in ('d20char_handler', "SWd20char_handler"): node = node.find('snf') node = node.find('skills') child_list = node.findall('skill') for child in child_list: - if path[step+1] == child.get('name'): + if path[step+1].lower() == child.get('name').lower(): if step+2 == depth: self.data = child.get('rank') - elif path[step+2] == 'Check': - self.data = 'Skill Check: ' + child.get('name') + ' [1d20+'+str( int(child.get('rank')) + int(pc_stats[child.get('stat')][1]) )+']' + elif path[step+2].lower() == 'check': + self.data = '<b>Skill Check:</b> ' + child.get('name') + ' [1d20+'+str( int(child.get('rank')) + int(pc_stats[child.get('stat')][1]) )+']' return - if path[step] == 'Feat': + if path[step].lower() == 'feat': if node_class not in ('d20char_handler', "SWd20char_handler"): node = node.find('snf') node = node.find('feats') child_list = node.findall('feat') for child in child_list: - if path[step+1] == child.get('name'): - if step+2 == depth: self.data = child.get('name') + ': ' + child.get('desc') + if path[step+1].lower() == child.get('name').lower(): + if step+2 == depth: self.data = '<b>'+child.get('name')+'</b>'+': '+child.get('desc') return - - if path[step] == 'Cast': + if path[step].lower() == 'cast': if node_class not in ('d20char_handler', "SWd20char_handler"): node = node.find('snp') node = node.find('spells') child_list = node.findall('spell') for child in child_list: - if path[step+1] == child.get('name'): - if step+2 == depth: self.data = child.get('name') + ': ' + child.get('desc') + if path[step+1].lower() == child.get('name').lower(): + if step+2 == depth: self.data = '<b>'+child.get('name')+'</b>'+': '+child.get('desc') return - - if path[step] == 'Attack': + if path[step].lower() == 'attack': if node_class not in ('d20char_handler', "SWd20char_handler"): node = node.find('combat') - if path[step+1] == 'Melee' or path[step+1] == 'M': + if path[step+1].lower() == 'melee' or path[step+1].lower() == 'm': + bonus_text = '(Melee)' bonus = node.find('attacks') bonus = bonus.find('melee') bonus = bonus.attrib; d = 0 - elif path[step+1] == 'Ranged' or path[step+1] == 'R': + elif path[step+1].lower() == 'ranged' or path[step+1].lower() == 'r': + bonus_text = '(Ranged)' bonus = node.find('attacks') bonus = bonus.find('ranged') bonus = bonus.attrib; d = 0 for b in bonus: d += int(bonus[b]) bonus = str(d) - if path[step+2] == None: - self.data = bonus + if path[step+2] == None: self.data = bonus else: weapons = node.find('attacks') weapons = weapons.findall('weapon') for child in weapons: - if path[step+2] == child.get('name'): - self.data = 'Attack: '+child.get('name')+' [1d20+'+bonus+'] ' + 'Damage: ['+child.get('damage')+']' + if path[step+2].lower() == child.get('name').lower(): + self.data = '<b>Attack: '+bonus_text+'</b> '+child.get('name')+' [1d20+'+bonus+'] ' + 'Damage: ['+child.get('damage')+']' return - elif pc_stats.has_key(path[step]): if step+1 == depth: self.data = pc_stats[path[step]][0] + ' +('+pc_stats[path[step]][1]+')' - elif path[step+1] == 'Mod': self.data = pc_stats[path[step]][1] - elif path[step+1] == 'Check': self.data = path[step] + ' Check: [1d20+' + str(pc_stats[path[step]][1]) +']' + elif path[step+1].lower() == 'mod': self.data = pc_stats[path[step]][1] + elif path[step+1].lower() == 'check': self.data = '<b>'+path[step]+' Check:</b> [1d20+'+str(pc_stats[path[step]][1])+']' return - def resolution(self, node): if self.passed == False: self.passed = True @@ -2026,6 +1988,7 @@ depth = len(path) self.gametree = component.get('tree') node = self.gametree.tree_map[path[0]]['node'] - if node.get('class') in ('dnd35char_handler', "SWd20char_handler", "d20char_handler", "dnd3echar_handler"): self.resolve_cust_loop(node, path, 1, depth) + if node.get('class') in ('dnd35char_handler', "SWd20char_handler", "d20char_handler", "dnd3echar_handler"): self.resolve_cust_loop(node, path, 1, depth) + elif node.get('class') == 'rpg_grid_handler': self.resolve_grid(node, path, 1, depth) else: self.resolve_loop(node, path, 1, depth) return self.data