comparison orpg/chat/chatwnd.py @ 59:5aff3ef1ae46 ornery-dev

New dev branch for Ornery Orc. Adds CSS styling to chat messages. Updates Update Manager to 0.7.1. Fixes problem with gametree and names. Adds a multi- line text entry, grows as you type more lines; not reactive to Shift-Enter, yet.
author sirebral
date Tue, 11 Aug 2009 17:48:30 -0500
parents 4385a7d0efd1
children c160f26ecf65
comparison
equal deleted inserted replaced
58:27e58b0483e7 59:5aff3ef1ae46
68 import traceback 68 import traceback
69 NEWCHAT = False 69 NEWCHAT = False
70 try: 70 try:
71 import wx.webview 71 import wx.webview
72 NEWCHAT = True 72 NEWCHAT = True
73 except: 73 except: pass
74 pass
75 NEWCHAT = False 74 NEWCHAT = False
76 75
77 # Global parser for stripping HTML tags: 76 # Global parser for stripping HTML tags:
78 # The 'tag stripping' is implicit, because this parser echoes every 77 # The 'tag stripping' is implicit, because this parser echoes every
79 # type of html data *except* the tags. 78 # type of html data *except* the tags.
86 def handle_entityref(self, name): # entities must be preserved exactly 85 def handle_entityref(self, name): # entities must be preserved exactly
87 self.accum += "&" + name + ";" 86 self.accum += "&" + name + ";"
88 def handle_starttag(self, tag, attrs): 87 def handle_starttag(self, tag, attrs):
89 if tag in self.special_tags: 88 if tag in self.special_tags:
90 self.accum += '<' + tag 89 self.accum += '<' + tag
91 for attrib in attrs: 90 for attrib in attrs: self.accum += ' ' + attrib[0] + '="' + attrib[1] + '"'
92 self.accum += ' ' + attrib[0] + '="' + attrib[1] + '"'
93 self.accum += '>' 91 self.accum += '>'
94 def handle_charref(self, name): # charrefs too 92 def handle_charref(self, name): # charrefs too
95 self.accum += "&#" + name + ";" 93 self.accum += "&#" + name + ";"
96 htmlstripper = HTMLStripper() 94 htmlstripper = HTMLStripper()
97 95
109 if filename > '' and filename[0] != commands.ANTI_LOG_CHAR: 107 if filename > '' and filename[0] != commands.ANTI_LOG_CHAR:
110 filename = filename + time.strftime( '-%Y-%m-%d.html', time.localtime( time.time() ) ) 108 filename = filename + time.strftime( '-%Y-%m-%d.html', time.localtime( time.time() ) )
111 #filename = time.strftime( filename, time.localtime( time.time() ) ) 109 #filename = time.strftime( filename, time.localtime( time.time() ) )
112 timestamp = time.ctime(time.time()) 110 timestamp = time.ctime(time.time())
113 header = '[%s] : ' % ( timestamp ); 111 header = '[%s] : ' % ( timestamp );
114 if settings.get_setting('TimeStampGameLog') != '1': 112 if settings.get_setting('TimeStampGameLog') != '1': header = ''
115 header = ''
116 try: 113 try:
117 f = open( orpg.dirpath.dir_struct["user"] + filename, 'a' ) 114 f = open( orpg.dirpath.dir_struct["user"] + filename, 'a' )
118 f.write( '%s%s<br />\n' % ( header, text ) ) 115 f.write( '%s%s<br />\n' % ( header, text ) )
119 f.close() 116 f.close()
120 except: 117 except:
140 wx.html.HtmlWindow.__init__(self, parent, id, style=wx.SUNKEN_BORDER | wx.html.HW_SCROLLBAR_AUTO|wx.NO_FULL_REPAINT_ON_RESIZE) 137 wx.html.HtmlWindow.__init__(self, parent, id, style=wx.SUNKEN_BORDER | wx.html.HW_SCROLLBAR_AUTO|wx.NO_FULL_REPAINT_ON_RESIZE)
141 self.parent = parent 138 self.parent = parent
142 self.build_menu() 139 self.build_menu()
143 self.Bind(wx.EVT_LEFT_UP, self.LeftUp) 140 self.Bind(wx.EVT_LEFT_UP, self.LeftUp)
144 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup) 141 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup)
145 if "gtk2" in wx.PlatformInfo: 142 if "gtk2" in wx.PlatformInfo: self.SetStandardFonts()
146 self.SetStandardFonts() 143 # def __init__ - end
147 # def __init__ - end
148 144
149 def onPopup(self, evt): 145 def onPopup(self, evt):
150 self.PopupMenu(self.menu) 146 self.PopupMenu(self.menu)
151 147
152 def LeftUp(self, event): 148 def LeftUp(self, event):
214 class ChatHtmlWindow(wx.webview.WebView): 210 class ChatHtmlWindow(wx.webview.WebView):
215 def __init__(self, parent, id): 211 def __init__(self, parent, id):
216 wx.webview.WebView.__init__(self, parent, id) 212 wx.webview.WebView.__init__(self, parent, id)
217 213
218 self.parent = parent 214 self.parent = parent
219
220 self.__font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName='Ariel') 215 self.__font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName='Ariel')
221 216
222 self.build_menu() 217 self.build_menu()
223 self.Bind(wx.EVT_LEFT_UP, self.LeftUp) 218 self.Bind(wx.EVT_LEFT_UP, self.LeftUp)
224 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup) 219 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup)
237 def CalculateAllFonts(self, defaultsize): 232 def CalculateAllFonts(self, defaultsize):
238 return 233 return
239 234
240 def SetDefaultFontAndSize(self, fontname, fontsize): 235 def SetDefaultFontAndSize(self, fontname, fontsize):
241 self.__font = wx.Font(int(fontsize), wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName=fontname) 236 self.__font = wx.Font(int(fontsize), wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName=fontname)
242 try: 237 try: self.SetPageSource(self.Header() + self.StripHeader())
243 self.SetPageSource(self.Header() + self.StripHeader()) 238 except Exception, e: print e
244 except Exception, e:
245 print e
246 return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize()) 239 return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize())
247 240
248 #Events 241 #Events
249 def OnLinkClicked(self, linkinfo): 242 def OnLinkClicked(self, linkinfo):
250 href = linkinfo.GetHref() 243 href = linkinfo.GetHref()
265 def Header(self): 258 def Header(self):
266 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>" 259 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>"
267 260
268 def StripHeader(self): 261 def StripHeader(self):
269 tmp = self.GetPageSource().split('<BODY>') 262 tmp = self.GetPageSource().split('<BODY>')
270 if tmp[-1].find('<body>') > -1: 263 if tmp[-1].find('<body>') > -1: tmp = tmp[-1].split('<body>')
271 tmp = tmp[-1].split('<body>')
272
273 return tmp[-1] 264 return tmp[-1]
274 265
275 def build_menu(self): 266 def build_menu(self):
276 self.menu = wx.Menu() 267 self.menu = wx.Menu()
277 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy") 268 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy")
407 self.log.log("Exit chat_notebook->create_null_tab(self, tab_name)", ORPG_DEBUG) 398 self.log.log("Exit chat_notebook->create_null_tab(self, tab_name)", ORPG_DEBUG)
408 return private_tab 399 return private_tab
409 400
410 def onCloseTab(self, evt): 401 def onCloseTab(self, evt):
411 self.log.log("Enter chat_notebook->onCloseTab(self, evt)", ORPG_DEBUG) 402 self.log.log("Enter chat_notebook->onCloseTab(self, evt)", ORPG_DEBUG)
412 try: 403 try: tabid = evt.GetSelection()
413 tabid = evt.GetSelection() 404 except: tabid = self.GetSelection()
414 except:
415 tabid = self.GetSelection()
416 405
417 if self.GetPageText(tabid) == 'Main Room': 406 if self.GetPageText(tabid) == 'Main Room':
418 #send no close error to chat 407 #send no close error to chat
419 evt.Veto() 408 evt.Veto()
420 return 409 return
432 return 421 return
433 dlg.Destroy() 422 dlg.Destroy()
434 self.GMChatPanel = None 423 self.GMChatPanel = None
435 self.settings.set_setting("GMWhisperTab", "0") 424 self.settings.set_setting("GMWhisperTab", "0")
436 panel = self.GetPage(tabid) 425 panel = self.GetPage(tabid)
437 if panel in self.whisper_tabs: 426 if panel in self.whisper_tabs: self.whisper_tabs.remove(panel)
438 self.whisper_tabs.remove(panel) 427 elif panel in self.group_tabs: self.group_tabs.remove(panel)
439 elif panel in self.group_tabs: 428 elif panel in self.null_tabs: self.null_tabs.remove(panel)
440 self.group_tabs.remove(panel)
441 elif panel in self.null_tabs:
442 self.null_tabs.remove(panel)
443 self.log.log("Exit chat_notebook->onCloseTab(self, evt)", ORPG_DEBUG) 429 self.log.log("Exit chat_notebook->onCloseTab(self, evt)", ORPG_DEBUG)
444 430
445 def newMsg(self, tabid): 431 def newMsg(self, tabid):
446 self.log.log("Enter chat_notebook->newMsg(self, tabid)", ORPG_DEBUG) 432 self.log.log("Enter chat_notebook->newMsg(self, tabid)", ORPG_DEBUG)
447 if tabid != self.GetSelection(): 433 if tabid != self.GetSelection(): self.SetPageImage(tabid, 0)
448 self.SetPageImage(tabid, 0)
449 self.log.log("Exit chat_notebook->newMsg(self, tabid)", ORPG_DEBUG) 434 self.log.log("Exit chat_notebook->newMsg(self, tabid)", ORPG_DEBUG)
450 435
451 def onPageChanging(self, event): 436 def onPageChanging(self, event):
452 """When private chattabs are selected, set the bitmap back to 'normal'.""" 437 """When private chattabs are selected, set the bitmap back to 'normal'."""
453 self.log.log("Enter chat_notebook->onPageChanging(self, event)", ORPG_DEBUG) 438 self.log.log("Enter chat_notebook->onPageChanging(self, event)", ORPG_DEBUG)
462 page = self.GetPage(selected_idx) 447 page = self.GetPage(selected_idx)
463 #wx.CallAfter(page.set_chat_text_focus, 0) 448 #wx.CallAfter(page.set_chat_text_focus, 0)
464 event.Skip() 449 event.Skip()
465 self.log.log("Exit chat_notebook->onPageChanged(self, event)", ORPG_DEBUG) 450 self.log.log("Exit chat_notebook->onPageChanged(self, event)", ORPG_DEBUG)
466 451
467 # This class defines and builds the Chat Frame for OpenRPG 452 """
468 # 453 This class defines and builds the Chat Frame for OpenRPG
469 # Inherits: wxPanel 454
470 # 455 Inherits: wxPanel
471 # Defines: 456
472 # __init__((self, parent, id, openrpg, sendtarget) 457 Defines:
473 # build_ctrls(self) 458 __init__((self, parent, id, openrpg, sendtarget)
474 # on_buffer_size(self,evt) 459 build_ctrls(self)
475 # set_colors(self) 460 on_buffer_size(self,evt)
476 # set_buffersize(self) 461 set_colors(self)
477 # set_chat_text(self,txt) 462 set_buffersize(self)
478 # OnChar(self,event) 463 set_chat_text(self,txt)
479 # on_chat_save(self,evt) 464 OnChar(self,event)
480 # on_text_color(self,event) 465 on_chat_save(self,evt)
481 # colorize(self, color, text) 466 on_text_color(self,event)
482 # on_text_format(self,event) 467 colorize(self, color, text)
483 # OnSize(self,event) 468 on_text_format(self,event)
484 # scroll_down(self) 469 OnSize(self,event)
485 # InfoPost(self,s) 470 scroll_down(self)
486 # Post(self,s="",send=False,myself=False) 471 InfoPost(self,s)
487 # ParsePost(self,s,send=False,myself=False) 472 Post(self,s="",send=False,myself=False)
488 # ParseDice(self,s) 473 ParsePost(self,s,send=False,myself=False)
489 # ParseNodes(self,s) 474 ParseDice(self,s)
490 # get_sha_checksum(self) 475 ParseNodes(self,s)
491 # get_color(self) 476 get_sha_checksum(self)
492 # 477 get_color(self)
478
479 """
493 480
494 class chat_panel(wx.Panel): 481 class chat_panel(wx.Panel):
495 482
496 # This is the initialization subroutine 483 """
497 # 484 This is the initialization subroutine
498 # !self : instance of self 485
499 # !parent : parent that defines the chatframe 486 !self : instance of self
500 # !id : 487 !parent : parent that defines the chatframe
501 # !openrpg : 488 !id :
502 # !sendtarget: who gets outbound messages: either 'all' or a playerid 489 !openrpg :
490 !sendtarget: who gets outbound messages: either 'all' or a playerid
491 """
492
503 def __init__(self, parent, id, tab_type, sendtarget): 493 def __init__(self, parent, id, tab_type, sendtarget):
504 self.log = open_rpg.get_component("log") 494 self.log = open_rpg.get_component("log")
505 self.log.log("Enter chat_panel", ORPG_DEBUG) 495 self.log.log("Enter chat_panel", ORPG_DEBUG)
506 wx.Panel.__init__(self, parent, id) 496 wx.Panel.__init__(self, parent, id)
507 self.session = open_rpg.get_component('session') 497 self.session = open_rpg.get_component('session')
541 self.root_dir = orpg.dirpath.dir_struct["home"] 531 self.root_dir = orpg.dirpath.dir_struct["home"]
542 # html font/fontsize is global to all the notebook tabs. 532 # html font/fontsize is global to all the notebook tabs.
543 StartupFont = self.settings.get_setting("defaultfont") 533 StartupFont = self.settings.get_setting("defaultfont")
544 StartupFontSize = self.settings.get_setting("defaultfontsize") 534 StartupFontSize = self.settings.get_setting("defaultfontsize")
545 if(StartupFont != "") and (StartupFontSize != ""): 535 if(StartupFont != "") and (StartupFontSize != ""):
546 try: 536 try: self.set_default_font(StartupFont, int(StartupFontSize))
547 self.set_default_font(StartupFont, int(StartupFontSize)) 537 except: pass
548 except:
549 pass
550 self.font = self.chatwnd.GetFont().GetFaceName() 538 self.font = self.chatwnd.GetFont().GetFaceName()
551 self.fontsize = self.chatwnd.GetFont().GetPointSize() 539 self.fontsize = self.chatwnd.GetFont().GetPointSize()
552 self.scroll_down() 540 self.scroll_down()
553 self.log.log("Exit chat_panel", ORPG_DEBUG) 541 self.log.log("Exit chat_panel", ORPG_DEBUG)
554 542
555 def set_default_font(self, fontname=None, fontsize=None): 543 def set_default_font(self, fontname=None, fontsize=None):
556 """Set all chatpanels to new default fontname/fontsize. Returns current font settings in a (fontname, fontsize) tuple.""" 544 """Set all chatpanels to new default fontname/fontsize. Returns current font settings in a (fontname, fontsize) tuple."""
557 self.log.log("Enter chat_panel->set_default_font(self, fontname=None, fontsize=None)", ORPG_DEBUG) 545 self.log.log("Enter chat_panel->set_default_font(self, fontname=None, fontsize=None)", ORPG_DEBUG)
558 if (fontname is not None): 546 if (fontname is not None): newfont = fontname
559 newfont = fontname 547 else: newfont = self.font
560 else: 548 if (fontsize is not None): newfontsize = int(fontsize)
561 newfont = self.font 549 else: newfontsize = int(self.fontsize)
562 if (fontsize is not None):
563 newfontsize = int(fontsize)
564 else:
565 newfontsize = int(self.fontsize)
566 self.chatwnd.SetDefaultFontAndSize(newfont, newfontsize) 550 self.chatwnd.SetDefaultFontAndSize(newfont, newfontsize)
567 self.InfoPost("Font is now " + newfont + " point size " + `newfontsize`) 551 self.InfoPost("Font is now " + newfont + " point size " + `newfontsize`)
568 self.font = newfont 552 self.font = newfont
569 self.fontsize = newfontsize 553 self.fontsize = newfontsize
570 self.log.log("Exit chat_panel->set_default_font(self, fontname=None, fontsize=None)", ORPG_DEBUG) 554 self.log.log("Exit chat_panel->set_default_font(self, fontname=None, fontsize=None)", ORPG_DEBUG)
607 tabmenu = wx.Menu() 591 tabmenu = wx.Menu()
608 toolmenu = wx.Menu() 592 toolmenu = wx.Menu()
609 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Show Images", "Show Images", wx.ITEM_CHECK) 593 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Show Images", "Show Images", wx.ITEM_CHECK)
610 top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowImages, item) 594 top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowImages, item)
611 wndmenu.AppendItem(item) 595 wndmenu.AppendItem(item)
612 if self.settings.get_setting("Show_Images_In_Chat") == '1': 596 if self.settings.get_setting("Show_Images_In_Chat") == '1': item.Check(True)
613 item.Check(True)
614 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Strip HTML", "Strip HTML", wx.ITEM_CHECK) 597 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Strip HTML", "Strip HTML", wx.ITEM_CHECK)
615 top_frame.Bind(wx.EVT_MENU, self.OnMB_StripHTML, item) 598 top_frame.Bind(wx.EVT_MENU, self.OnMB_StripHTML, item)
616 wndmenu.AppendItem(item) 599 wndmenu.AppendItem(item)
617 if self.settings.get_setting("striphtml") == '1': 600 if self.settings.get_setting("striphtml") == '1': item.Check(True)
618 item.Check(True)
619 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Chat Time Index", "Chat Time Index", wx.ITEM_CHECK) 601 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Chat Time Index", "Chat Time Index", wx.ITEM_CHECK)
620 top_frame.Bind(wx.EVT_MENU, self.OnMB_ChatTimeIndex, item) 602 top_frame.Bind(wx.EVT_MENU, self.OnMB_ChatTimeIndex, item)
621 wndmenu.AppendItem(item) 603 wndmenu.AppendItem(item)
622 if self.settings.get_setting("Chat_Time_Indexing") == '1': 604 if self.settings.get_setting("Chat_Time_Indexing") == '1': item.Check(True)
623 item.Check(True)
624 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Chat Auto Complete", "Chat Auto Complete", wx.ITEM_CHECK) 605 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Chat Auto Complete", "Chat Auto Complete", wx.ITEM_CHECK)
625 top_frame.Bind(wx.EVT_MENU, self.OnMB_ChatAutoComplete, item) 606 top_frame.Bind(wx.EVT_MENU, self.OnMB_ChatAutoComplete, item)
626 wndmenu.AppendItem(item) 607 wndmenu.AppendItem(item)
627 if self.settings.get_setting("SuppressChatAutoComplete") == '0': 608 if self.settings.get_setting("SuppressChatAutoComplete") == '0': item.Check(True)
628 item.Check(True)
629 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Show ID in Chat", "Show ID in Chat", wx.ITEM_CHECK) 609 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Show ID in Chat", "Show ID in Chat", wx.ITEM_CHECK)
630 top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowIDinChat, item) 610 top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowIDinChat, item)
631 wndmenu.AppendItem(item) 611 wndmenu.AppendItem(item)
632 if self.settings.get_setting("ShowIDInChat") == '1': 612 if self.settings.get_setting("ShowIDInChat") == '1': item.Check(True)
633 item.Check(True)
634 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Log Time Index", "Log Time Index", wx.ITEM_CHECK) 613 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Log Time Index", "Log Time Index", wx.ITEM_CHECK)
635 top_frame.Bind(wx.EVT_MENU, self.OnMB_LogTimeIndex, item) 614 top_frame.Bind(wx.EVT_MENU, self.OnMB_LogTimeIndex, item)
636 wndmenu.AppendItem(item) 615 wndmenu.AppendItem(item)
637 if self.settings.get_setting("TimeStampGameLog") == '1': 616 if self.settings.get_setting("TimeStampGameLog") == '1': item.Check(True)
638 item.Check(True)
639 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Window', wndmenu ) 617 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Window', wndmenu )
640 item = wx.MenuItem(tabmenu, wx.ID_ANY, "Tabbed Whispers", "Tabbed Whispers", wx.ITEM_CHECK) 618 item = wx.MenuItem(tabmenu, wx.ID_ANY, "Tabbed Whispers", "Tabbed Whispers", wx.ITEM_CHECK)
641 top_frame.Bind(wx.EVT_MENU, self.OnMB_TabbedWhispers, item) 619 top_frame.Bind(wx.EVT_MENU, self.OnMB_TabbedWhispers, item)
642 tabmenu.AppendItem(item) 620 tabmenu.AppendItem(item)
643 if self.settings.get_setting("tabbedwhispers") == '1': 621 if self.settings.get_setting("tabbedwhispers") == '1': item.Check(True)
644 item.Check(True)
645 item = wx.MenuItem(tabmenu, wx.ID_ANY, "GM Tab", "GM Tab", wx.ITEM_CHECK) 622 item = wx.MenuItem(tabmenu, wx.ID_ANY, "GM Tab", "GM Tab", wx.ITEM_CHECK)
646 top_frame.Bind(wx.EVT_MENU, self.OnMB_GMTab, item) 623 top_frame.Bind(wx.EVT_MENU, self.OnMB_GMTab, item)
647 tabmenu.AppendItem(item) 624 tabmenu.AppendItem(item)
648 if self.settings.get_setting("GMWhisperTab") == '1': 625 if self.settings.get_setting("GMWhisperTab") == '1':item.Check(True)
649 item.Check(True)
650 item = wx.MenuItem(tabmenu, wx.ID_ANY, "Group Whisper Tabs", "Group Whisper Tabs", wx.ITEM_CHECK) 626 item = wx.MenuItem(tabmenu, wx.ID_ANY, "Group Whisper Tabs", "Group Whisper Tabs", wx.ITEM_CHECK)
651 top_frame.Bind(wx.EVT_MENU, self.OnMB_GroupWhisperTabs, item) 627 top_frame.Bind(wx.EVT_MENU, self.OnMB_GroupWhisperTabs, item)
652 tabmenu.AppendItem(item) 628 tabmenu.AppendItem(item)
653 if self.settings.get_setting("GroupWhisperTab") == '1': 629 if self.settings.get_setting("GroupWhisperTab") == '1': item.Check(True)
654 item.Check(True)
655 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tabs', tabmenu) 630 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tabs', tabmenu)
656 item = wx.MenuItem(toolmenu, wx.ID_ANY, "Dice Bar", "Dice Bar", wx.ITEM_CHECK) 631 item = wx.MenuItem(toolmenu, wx.ID_ANY, "Dice Bar", "Dice Bar", wx.ITEM_CHECK)
657 top_frame.Bind(wx.EVT_MENU, self.OnMB_DiceBar, item) 632 top_frame.Bind(wx.EVT_MENU, self.OnMB_DiceBar, item)
658 toolmenu.AppendItem(item) 633 toolmenu.AppendItem(item)
659 if self.settings.get_setting("DiceButtons_On") == '1': 634 if self.settings.get_setting("DiceButtons_On") == '1': item.Check(True)
660 item.Check(True)
661 item = wx.MenuItem(toolmenu, wx.ID_ANY, "Format Buttons", "Format Buttons", wx.ITEM_CHECK) 635 item = wx.MenuItem(toolmenu, wx.ID_ANY, "Format Buttons", "Format Buttons", wx.ITEM_CHECK)
662 top_frame.Bind(wx.EVT_MENU, self.OnMB_FormatButtons, item) 636 top_frame.Bind(wx.EVT_MENU, self.OnMB_FormatButtons, item)
663 toolmenu.AppendItem(item) 637 toolmenu.AppendItem(item)
664 if self.settings.get_setting("FormattingButtons_On") == '1': 638 if self.settings.get_setting("FormattingButtons_On") == '1': item.Check(True)
665 item.Check(True)
666 item = wx.MenuItem(toolmenu, wx.ID_ANY, "Alias Tool", "Alias Tool", wx.ITEM_CHECK) 639 item = wx.MenuItem(toolmenu, wx.ID_ANY, "Alias Tool", "Alias Tool", wx.ITEM_CHECK)
667 top_frame.Bind(wx.EVT_MENU, self.OnMB_AliasTool, item) 640 top_frame.Bind(wx.EVT_MENU, self.OnMB_AliasTool, item)
668 toolmenu.AppendItem(item) 641 toolmenu.AppendItem(item)
669 if self.settings.get_setting("AliasTool_On") == '1': 642 if self.settings.get_setting("AliasTool_On") == '1': item.Check(True)
670 item.Check(True)
671 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tool Bars', toolmenu) 643 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tool Bars', toolmenu)
672 menu.AppendMenu(wx.ID_ANY, 'Chat Settings', settingmenu) 644 menu.AppendMenu(wx.ID_ANY, 'Chat Settings', settingmenu)
673 top_frame.mainmenu.Insert(2, menu, '&Chat') 645 top_frame.mainmenu.Insert(2, menu, '&Chat')
674 self.log.log("Exit chat_panel->build_menu(self)", ORPG_DEBUG) 646 self.log.log("Exit chat_panel->build_menu(self)", ORPG_DEBUG)
675 647
676 ## Settings Menu Events 648 ## Settings Menu Events
677 def OnMB_ShowImages(self, event): 649 def OnMB_ShowImages(self, event):
678 self.log.log("Enter chat_panel->OnMB_ShowImages(self, event)", ORPG_DEBUG) 650 self.log.log("Enter chat_panel->OnMB_ShowImages(self, event)", ORPG_DEBUG)
679 if event.IsChecked(): 651 if event.IsChecked(): self.settings.set_setting("Show_Images_In_Chat", '1')
680 self.settings.set_setting("Show_Images_In_Chat", '1') 652 else: self.settings.set_setting("Show_Images_In_Chat", '0')
681 else:
682 self.settings.set_setting("Show_Images_In_Chat", '0')
683 self.log.log("Exit chat_panel->OnMB_ShowImages(self, event)", ORPG_DEBUG) 653 self.log.log("Exit chat_panel->OnMB_ShowImages(self, event)", ORPG_DEBUG)
684 654
685 def OnMB_StripHTML(self, event): 655 def OnMB_StripHTML(self, event):
686 self.log.log("Enter chat_panel->OnMB_StripHTML(self, event)", ORPG_DEBUG) 656 self.log.log("Enter chat_panel->OnMB_StripHTML(self, event)", ORPG_DEBUG)
687 if event.IsChecked(): 657 if event.IsChecked(): self.settings.set_setting("Sstriphtml", '1')
688 self.settings.set_setting("Sstriphtml", '1') 658 else: self.settings.set_setting("striphtml", '0')
689 else:
690 self.settings.set_setting("striphtml", '0')
691 self.log.log("Exit chat_panel->OnMB_StripHTML(self, event)", ORPG_DEBUG) 659 self.log.log("Exit chat_panel->OnMB_StripHTML(self, event)", ORPG_DEBUG)
692 660
693 def OnMB_ChatTimeIndex(self, event): 661 def OnMB_ChatTimeIndex(self, event):
694 self.log.log("Enter chat_panel->OnMB_ChatTimeIndex(self, event)", ORPG_DEBUG) 662 self.log.log("Enter chat_panel->OnMB_ChatTimeIndex(self, event)", ORPG_DEBUG)
695 if event.IsChecked(): 663 if event.IsChecked(): self.settings.set_setting("Chat_Time_Indexing", '1')
696 self.settings.set_setting("Chat_Time_Indexing", '1') 664 else: self.settings.set_setting("Chat_Time_Indexing", '0')
697 else:
698 self.settings.set_setting("Chat_Time_Indexing", '0')
699 self.log.log("Exit chat_panel->OnMB_ChatTimeIndex(self, event)", ORPG_DEBUG) 665 self.log.log("Exit chat_panel->OnMB_ChatTimeIndex(self, event)", ORPG_DEBUG)
700 666
701 def OnMB_ChatAutoComplete(self, event): 667 def OnMB_ChatAutoComplete(self, event):
702 self.log.log("Enter chat_panel->OnMB_ChatAutoComplete(self, event)", ORPG_DEBUG) 668 self.log.log("Enter chat_panel->OnMB_ChatAutoComplete(self, event)", ORPG_DEBUG)
703 if event.IsChecked(): 669 if event.IsChecked(): self.settings.set_setting("SuppressChatAutoComplete", '0')
704 self.settings.set_setting("SuppressChatAutoComplete", '0') 670 else: self.settings.set_setting("SuppressChatAutoComplete", '1')
705 else:
706 self.settings.set_setting("SuppressChatAutoComplete", '1')
707 self.log.log("Exit chat_panel->OnMB_ChatAutoComplete(self, event)", ORPG_DEBUG) 671 self.log.log("Exit chat_panel->OnMB_ChatAutoComplete(self, event)", ORPG_DEBUG)
708 672
709 def OnMB_ShowIDinChat(self, event): 673 def OnMB_ShowIDinChat(self, event):
710 self.log.log("Enter chat_panel->OnMB_ShowIDinChat(self, event)", ORPG_DEBUG) 674 self.log.log("Enter chat_panel->OnMB_ShowIDinChat(self, event)", ORPG_DEBUG)
711 if event.IsChecked(): 675 if event.IsChecked(): self.settings.set_setting("ShowIDInChat", '1')
712 self.settings.set_setting("ShowIDInChat", '1') 676 else: self.settings.set_setting("ShowIDInChat", '0')
713 else:
714 self.settings.set_setting("ShowIDInChat", '0')
715 self.log.log("Exit chat_panel->OnMB_ShowIDinChat(self, event)", ORPG_DEBUG) 677 self.log.log("Exit chat_panel->OnMB_ShowIDinChat(self, event)", ORPG_DEBUG)
716 678
717 def OnMB_LogTimeIndex(self, event): 679 def OnMB_LogTimeIndex(self, event):
718 self.log.log("Enter chat_panel->OnMB_LogTimeIndex(self, event)", ORPG_DEBUG) 680 self.log.log("Enter chat_panel->OnMB_LogTimeIndex(self, event)", ORPG_DEBUG)
719 if event.IsChecked(): 681 if event.IsChecked(): self.settings.set_setting("TimeStampGameLog", '1')
720 self.settings.set_setting("TimeStampGameLog", '1') 682 else: self.settings.set_setting("TimeStampGameLog", '0')
721 else:
722 self.settings.set_setting("TimeStampGameLog", '0')
723 self.log.log("Exit chat_panel->OnMB_LogTimeIndex(self, event)", ORPG_DEBUG) 683 self.log.log("Exit chat_panel->OnMB_LogTimeIndex(self, event)", ORPG_DEBUG)
724 684
725 def OnMB_TabbedWhispers(self, event): 685 def OnMB_TabbedWhispers(self, event):
726 self.log.log("Enter chat_panel->OnMB_TabbedWhispers(self, event)", ORPG_DEBUG) 686 self.log.log("Enter chat_panel->OnMB_TabbedWhispers(self, event)", ORPG_DEBUG)
727 if event.IsChecked(): 687 if event.IsChecked(): self.settings.set_setting("tabbedwhispers", '1')
728 self.settings.set_setting("tabbedwhispers", '1') 688 else: self.settings.set_setting("tabbedwhispers", '0')
729 else:
730 self.settings.set_setting("tabbedwhispers", '0')
731 self.log.log("Exit chat_panel->OnMB_TabbedWhispers(self, event)", ORPG_DEBUG) 689 self.log.log("Exit chat_panel->OnMB_TabbedWhispers(self, event)", ORPG_DEBUG)
732 690
733 def OnMB_GMTab(self, event): 691 def OnMB_GMTab(self, event):
734 self.log.log("Enter chat_panel->OnMB_GMTab(self, event)", ORPG_DEBUG) 692 self.log.log("Enter chat_panel->OnMB_GMTab(self, event)", ORPG_DEBUG)
735 if event.IsChecked(): 693 if event.IsChecked():
736 self.settings.set_setting("GMWhisperTab", '1') 694 self.settings.set_setting("GMWhisperTab", '1')
737 self.parent.create_gm_tab() 695 self.parent.create_gm_tab()
738 else: 696 else: self.settings.set_setting("GMWhisperTab", '0')
739 self.settings.set_setting("GMWhisperTab", '0')
740 self.log.log("Exit chat_panel->OnMB_GMTab(self, event)", ORPG_DEBUG) 697 self.log.log("Exit chat_panel->OnMB_GMTab(self, event)", ORPG_DEBUG)
741 698
742 def OnMB_GroupWhisperTabs(self, event): 699 def OnMB_GroupWhisperTabs(self, event):
743 self.log.log("Enter chat_panel->OnMB_GroupWhisperTabs(self, event)", ORPG_DEBUG) 700 self.log.log("Enter chat_panel->OnMB_GroupWhisperTabs(self, event)", ORPG_DEBUG)
744 if event.IsChecked(): 701 if event.IsChecked(): self.settings.set_setting("GroupWhisperTab", '1')
745 self.settings.set_setting("GroupWhisperTab", '1') 702 else: self.settings.set_setting("GroupWhisperTab", '0')
746 else:
747 self.settings.set_setting("GroupWhisperTab", '0')
748 self.log.log("Exit chat_panel->OnMB_GroupWhisperTabs(self, event)", ORPG_DEBUG) 703 self.log.log("Exit chat_panel->OnMB_GroupWhisperTabs(self, event)", ORPG_DEBUG)
749 704
750 705
751 def OnMB_DiceBar(self, event): 706 def OnMB_DiceBar(self, event):
752 self.log.log("Enter chat_panel->OnMB_DiceBar(self, event)", ORPG_DEBUG) 707 self.log.log("Enter chat_panel->OnMB_DiceBar(self, event)", ORPG_DEBUG)
753 act = '0' 708 act = '0'
754 if event.IsChecked(): 709 if event.IsChecked():
755 self.settings.set_setting("DiceButtons_On", '1') 710 self.settings.set_setting("DiceButtons_On", '1')
756 act = '1' 711 act = '1'
757 else: 712 else: self.settings.set_setting("DiceButtons_On", '0')
758 self.settings.set_setting("DiceButtons_On", '0')
759 self.toggle_dice(act) 713 self.toggle_dice(act)
760 try: 714 try: self.parent.GMChatPanel.toggle_dice(act)
761 self.parent.GMChatPanel.toggle_dice(act) 715 except: pass
762 except: 716 for panel in self.parent.whisper_tabs: panel.toggle_dice(act)
763 pass 717 for panel in self.parent.group_tabs: panel.toggle_dice(act)
764 for panel in self.parent.whisper_tabs: 718 for panel in self.parent.null_tabs: panel.toggle_dice(act)
765 panel.toggle_dice(act)
766 for panel in self.parent.group_tabs:
767 panel.toggle_dice(act)
768 for panel in self.parent.null_tabs:
769 panel.toggle_dice(act)
770 self.log.log("Exit chat_panel->OnMB_DiceBar(self, event)", ORPG_DEBUG) 719 self.log.log("Exit chat_panel->OnMB_DiceBar(self, event)", ORPG_DEBUG)
771 720
772 def OnMB_FormatButtons(self, event): 721 def OnMB_FormatButtons(self, event):
773 self.log.log("Enter chat_panel->OnMB_FormatButtons(self, event)", ORPG_DEBUG) 722 self.log.log("Enter chat_panel->OnMB_FormatButtons(self, event)", ORPG_DEBUG)
774 act = '0' 723 act = '0'
776 self.settings.set_setting("FormattingButtons_On", '1') 725 self.settings.set_setting("FormattingButtons_On", '1')
777 act = '1' 726 act = '1'
778 else: 727 else:
779 self.settings.set_setting("FormattingButtons_On", '0') 728 self.settings.set_setting("FormattingButtons_On", '0')
780 self.toggle_formating(act) 729 self.toggle_formating(act)
781 try: 730 try: self.parent.GMChatPanel.toggle_formating(act)
782 self.parent.GMChatPanel.toggle_formating(act) 731 except: pass
783 except: 732 for panel in self.parent.whisper_tabs: panel.toggle_formating(act)
784 pass 733 for panel in self.parent.group_tabs: panel.toggle_formating(act)
785 for panel in self.parent.whisper_tabs: 734 for panel in self.parent.null_tabs: panel.toggle_formating(act)
786 panel.toggle_formating(act)
787 for panel in self.parent.group_tabs:
788 panel.toggle_formating(act)
789 for panel in self.parent.null_tabs:
790 panel.toggle_formating(act)
791 self.log.log("Exit chat_panel->OnMB_FormatButtons(self, event)", ORPG_DEBUG) 735 self.log.log("Exit chat_panel->OnMB_FormatButtons(self, event)", ORPG_DEBUG)
792 736
793 def OnMB_AliasTool(self, event): 737 def OnMB_AliasTool(self, event):
794 self.log.log("Enter chat_panel->OnMB_AliasTool(self, event)", ORPG_DEBUG) 738 self.log.log("Enter chat_panel->OnMB_AliasTool(self, event)", ORPG_DEBUG)
795 act = '0' 739 act = '0'
796 if event.IsChecked(): 740 if event.IsChecked():
797 self.settings.set_setting("AliasTool_On", '1') 741 self.settings.set_setting("AliasTool_On", '1')
798 act = '1' 742 act = '1'
799 else: 743 else: self.settings.set_setting("AliasTool_On", '0')
800 self.settings.set_setting("AliasTool_On", '0')
801 self.toggle_alias(act) 744 self.toggle_alias(act)
802 try: 745 try: self.parent.GMChatPanel.toggle_alias(act)
803 self.parent.GMChatPanel.toggle_alias(act) 746 except: pass
804 except: 747 for panel in self.parent.whisper_tabs: panel.toggle_alias(act)
805 pass 748 for panel in self.parent.group_tabs: panel.toggle_alias(act)
806 for panel in self.parent.whisper_tabs: 749 for panel in self.parent.null_tabs:panel.toggle_alias(act)
807 panel.toggle_alias(act)
808 for panel in self.parent.group_tabs:
809 panel.toggle_alias(act)
810 for panel in self.parent.null_tabs:
811 panel.toggle_alias(act)
812 self.log.log("Exit chat_panel->OnMB_AliasTool(self, event)", ORPG_DEBUG) 750 self.log.log("Exit chat_panel->OnMB_AliasTool(self, event)", ORPG_DEBUG)
813 751
814 def OnMB_BackgroundColor(self, event): 752 def OnMB_BackgroundColor(self, event):
815 self.log.log("Enter chat_panel->OnMB_BackgroundColor(self, event)", ORPG_DEBUG) 753 self.log.log("Enter chat_panel->OnMB_BackgroundColor(self, event)", ORPG_DEBUG)
816 top_frame = open_rpg.get_component('frame') 754 top_frame = open_rpg.get_component('frame')
887 self.set_colors() 825 self.set_colors()
888 wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header()) 826 wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header())
889 if (self.sendtarget == "all"): 827 if (self.sendtarget == "all"):
890 wx.CallAfter(self.Post, self.colorize(self.syscolor, "<b>Welcome to <a href='http://www.openrpg.com'>OpenRPG</a> version " + self.version + "... </b>")) 828 wx.CallAfter(self.Post, self.colorize(self.syscolor, "<b>Welcome to <a href='http://www.openrpg.com'>OpenRPG</a> version " + self.version + "... </b>"))
891 #self.chat_cmds.on_help() 829 #self.chat_cmds.on_help()
892 self.chattxt = orpg.tools.predTextCtrl.predTextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB,keyHook = self.myKeyHook, validator=None ) 830 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 )
893 self.build_bar() 831 self.build_bar()
894 self.basesizer = wx.BoxSizer(wx.VERTICAL) 832 self.basesizer = wx.BoxSizer(wx.VERTICAL)
895 self.basesizer.Add( self.chatwnd,1,wx.EXPAND ) 833 self.basesizer.Add( self.chatwnd, 1, wx.EXPAND )
896 self.basesizer.Add( self.toolbar_sizer, 0, wx.EXPAND ) 834 self.basesizer.Add( self.toolbar_sizer, 0, wx.EXPAND )
897 self.basesizer.Add( self.chattxt, 0, wx.EXPAND ) 835 self.basesizer.Add( self.chattxt, 0, wx.EXPAND )
898 self.SetSizer(self.basesizer) 836 self.SetSizer(self.basesizer)
899 self.SetAutoLayout(True) 837 self.SetAutoLayout(True)
900 self.Fit() 838 self.Fit()
926 self.chattxt.Bind(wx.EVT_TEXT_COPY, self.textCopy) 864 self.chattxt.Bind(wx.EVT_TEXT_COPY, self.textCopy)
927 self.log.log("Exit chat_panel->build_ctrls(self)", ORPG_DEBUG) 865 self.log.log("Exit chat_panel->build_ctrls(self)", ORPG_DEBUG)
928 # def build_ctrls - end 866 # def build_ctrls - end
929 867
930 def textCopy(self, event): 868 def textCopy(self, event):
931 if self.chattxt.GetStringSelection() == '': 869 if self.chattxt.GetStringSelection() == '': self.chatwnd.OnM_EditCopy(None)
932 self.chatwnd.OnM_EditCopy(None) 870 else: self.chatwnd.Copy()
933 else:
934 self.chatwnd.Copy()
935 871
936 def build_bar(self): 872 def build_bar(self):
937 self.log.log("Enter chat_panel->build_bar(self)", ORPG_DEBUG) 873 self.log.log("Enter chat_panel->build_bar(self)", ORPG_DEBUG)
938 self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL) 874 self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL)
939 self.scroll_lock = None 875 self.scroll_lock = None
965 self.filterList.SetSelection(0) 901 self.filterList.SetSelection(0)
966 self.toolbar_sizer.Add( self.aliasButton, 0, wx.EXPAND ) 902 self.toolbar_sizer.Add( self.aliasButton, 0, wx.EXPAND )
967 self.toolbar_sizer.Add( self.aliasList,0,wx.EXPAND) 903 self.toolbar_sizer.Add( self.aliasList,0,wx.EXPAND)
968 self.toolbar_sizer.Add( self.filterButton, 0, wx.EXPAND ) 904 self.toolbar_sizer.Add( self.filterButton, 0, wx.EXPAND )
969 self.toolbar_sizer.Add( self.filterList,0,wx.EXPAND) 905 self.toolbar_sizer.Add( self.filterList,0,wx.EXPAND)
970 if self.settings.get_setting('AliasTool_On') == '0': 906 if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0')
971 self.toggle_alias('0') 907 else: self.toggle_alias('1')
972 else:
973 self.toggle_alias('1')
974 self.log.log("Exit chat_panel->build_alias(self)", ORPG_DEBUG) 908 self.log.log("Exit chat_panel->build_alias(self)", ORPG_DEBUG)
975 909
976 def toggle_alias(self, act): 910 def toggle_alias(self, act):
977 self.log.log("Enter chat_panel->toggle_alias(self, " + str(act) + ")", ORPG_DEBUG) 911 self.log.log("Enter chat_panel->toggle_alias(self, " + str(act) + ")", ORPG_DEBUG)
978 if act == '0': 912 if act == '0':
1012 self.toolbar_sizer.Add( self.d10Button, 0 ,wx.EXPAND) 946 self.toolbar_sizer.Add( self.d10Button, 0 ,wx.EXPAND)
1013 self.toolbar_sizer.Add( self.d12Button, 0 ,wx.EXPAND) 947 self.toolbar_sizer.Add( self.d12Button, 0 ,wx.EXPAND)
1014 self.toolbar_sizer.Add( self.d20Button, 0 ,wx.EXPAND) 948 self.toolbar_sizer.Add( self.d20Button, 0 ,wx.EXPAND)
1015 self.toolbar_sizer.Add( self.d100Button, 0 ,wx.EXPAND) 949 self.toolbar_sizer.Add( self.d100Button, 0 ,wx.EXPAND)
1016 self.toolbar_sizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 ) 950 self.toolbar_sizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 )
1017 if self.settings.get_setting('DiceButtons_On') == '0': 951 if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0')
1018 self.toggle_dice('0') 952 else: self.toggle_dice('1')
1019 else:
1020 self.toggle_dice('1')
1021 self.log.log("Exit chat_panel->build_dice(self)", ORPG_DEBUG) 953 self.log.log("Exit chat_panel->build_dice(self)", ORPG_DEBUG)
1022 954
1023 def toggle_dice(self, act): 955 def toggle_dice(self, act):
1024 self.log.log("Enter chat_panel->toggle_dice(self, "+ str(act) + ")", ORPG_DEBUG) 956 self.log.log("Enter chat_panel->toggle_dice(self, "+ str(act) + ")", ORPG_DEBUG)
1025 if act == '0': 957 if act == '0':
1052 self.italicButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'italic.gif', 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' ) 984 self.italicButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'italic.gif', 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' )
1053 self.underlineButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'underlined.gif', 'Underline the selected text', wx.ID_ANY, '#bdbdbd' ) 985 self.underlineButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'underlined.gif', 'Underline the selected text', wx.ID_ANY, '#bdbdbd' )
1054 self.toolbar_sizer.Add( self.boldButton, 0, wx.EXPAND ) 986 self.toolbar_sizer.Add( self.boldButton, 0, wx.EXPAND )
1055 self.toolbar_sizer.Add( self.italicButton, 0, wx.EXPAND ) 987 self.toolbar_sizer.Add( self.italicButton, 0, wx.EXPAND )
1056 self.toolbar_sizer.Add( self.underlineButton, 0, wx.EXPAND ) 988 self.toolbar_sizer.Add( self.underlineButton, 0, wx.EXPAND )
1057 if self.settings.get_setting('FormattingButtons_On') == '0': 989 if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0')
1058 self.toggle_formating('0') 990 else: self.toggle_formating('1')
1059 else:
1060 self.toggle_formating('1')
1061 self.log.log("Exit chat_panel->build_formating(self)", ORPG_DEBUG) 991 self.log.log("Exit chat_panel->build_formating(self)", ORPG_DEBUG)
1062 992
1063 def toggle_formating(self, act): 993 def toggle_formating(self, act):
1064 self.log.log("Enter chat_panel->toggle_formating(self, " + str(act) + ")", ORPG_DEBUG) 994 self.log.log("Enter chat_panel->toggle_formating(self, " + str(act) + ")", ORPG_DEBUG)
1065 if act == '0': 995 if act == '0':
1099 lnk = contain.GetLink(sx+x,sy+y) 1029 lnk = contain.GetLink(sx+x,sy+y)
1100 if lnk: 1030 if lnk:
1101 try: 1031 try:
1102 link = lnk.GetHref() 1032 link = lnk.GetHref()
1103 self.session.set_status_url(link) 1033 self.session.set_status_url(link)
1104 except: 1034 except: pass
1105 pass 1035 else: self.log.log("Error, self.chatwnd.GetInternalRepresentation() return None", ORPG_GENERAL)
1106 else:
1107 self.log.log("Error, self.chatwnd.GetInternalRepresentation() return None", ORPG_GENERAL)
1108 evt.Skip() 1036 evt.Skip()
1109 self.log.log("Exit chat_panel->OnMotion(self, evt)", ORPG_DEBUG) 1037 self.log.log("Exit chat_panel->OnMotion(self, evt)", ORPG_DEBUG)
1110 1038
1111 # This subroutine is registered with predTextCtrl to be run for every OnChar event 1039 # This subroutine is registered with predTextCtrl to be run for every OnChar event
1112 # It checks if we need to send a typing message 1040 # It checks if we need to send a typing message
1137 def typingTimerFunc(self, event): 1065 def typingTimerFunc(self, event):
1138 #following added by mDuo13 1066 #following added by mDuo13
1139 ##############refresh_counter()############## 1067 ##############refresh_counter()##############
1140 for plugin_fname in self.activeplugins.keys(): 1068 for plugin_fname in self.activeplugins.keys():
1141 plugin = self.activeplugins[plugin_fname] 1069 plugin = self.activeplugins[plugin_fname]
1142 try: 1070 try: plugin.refresh_counter()
1143 plugin.refresh_counter()
1144 except Exception, e: 1071 except Exception, e:
1145 if str(e) != "'module' object has no attribute 'refresh_counter'": 1072 if str(e) != "'module' object has no attribute 'refresh_counter'":
1146 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1073 self.log.log(traceback.format_exc(), ORPG_GENERAL)
1147 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1074 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL)
1148 #end mDuo13 added code 1075 #end mDuo13 added code
1160 self.log.log("Enter chat_panel->sendTyping(self, typing)", ORPG_DEBUG) 1087 self.log.log("Enter chat_panel->sendTyping(self, typing)", ORPG_DEBUG)
1161 if typing: 1088 if typing:
1162 self.lastSend = time.time() # remember our send time for use in myKeyHook() 1089 self.lastSend = time.time() # remember our send time for use in myKeyHook()
1163 #I think this is cleaner 1090 #I think this is cleaner
1164 status_text = self.settings.get_setting('TypingStatusAlias') 1091 status_text = self.settings.get_setting('TypingStatusAlias')
1165 if status_text == "" or status_text == None: 1092 if status_text == "" or status_text == None: status_text = "Typing"
1166 status_text = "Typing"
1167 self.session.set_text_status(status_text) 1093 self.session.set_text_status(status_text)
1168 else: 1094 else:
1169 self.lastSend = 0 # set lastSend to zero to indicate we're not typing 1095 self.lastSend = 0 # set lastSend to zero to indicate we're not typing
1170 #I think this is cleaner 1096 #I think this is cleaner
1171 status_text = self.settings.get_setting('IdleStatusAlias') 1097 status_text = self.settings.get_setting('IdleStatusAlias')
1172 if status_text == "" or status_text == None: 1098 if status_text == "" or status_text == None: status_text = "Idle"
1173 status_text = "Idle"
1174 self.session.set_text_status(status_text) 1099 self.session.set_text_status(status_text)
1175 self.log.log("Exit chat_panel->sendTyping(self, typing)", ORPG_DEBUG) 1100 self.log.log("Exit chat_panel->sendTyping(self, typing)", ORPG_DEBUG)
1176 1101
1177 # This subroutine sets the colors of the chat based on the settings in the 1102 # This subroutine sets the colors of the chat based on the settings in the
1178 # self instance. 1103 # self instance.
1261 if (event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText): 1186 if (event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText):
1262 self.log.log("(event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText)", ORPG_DEBUG) 1187 self.log.log("(event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText)", ORPG_DEBUG)
1263 self.histidx = -1 1188 self.histidx = -1
1264 self.temptext = "" 1189 self.temptext = ""
1265 self.history = [s] + self.history#prepended instead of appended now, so higher index = greater age 1190 self.history = [s] + self.history#prepended instead of appended now, so higher index = greater age
1266 if not len(macroText): 1191 if not len(macroText): self.chattxt.SetValue("")
1267 self.chattxt.SetValue("")
1268 # play sound 1192 # play sound
1269 sound_file = self.settings.get_setting("SendSound") 1193 sound_file = self.settings.get_setting("SendSound")
1270 if sound_file != '': 1194 if sound_file != '': self.sound_player.play(sound_file)
1271 self.sound_player.play(sound_file)
1272 if s[0] != "/": ## it's not a slash command 1195 if s[0] != "/": ## it's not a slash command
1273 s = self.ParsePost( s, True, True ) 1196 s = self.ParsePost( s, True, True )
1274 else: 1197 else: self.chat_cmds.docmd(s) # emote is in chatutils.py
1275 self.chat_cmds.docmd(s) # emote is in chatutils.py
1276 1198
1277 ## UP KEY 1199 ## UP KEY
1278 elif event.GetKeyCode() == wx.WXK_UP: 1200 elif event.GetKeyCode() == wx.WXK_UP:
1279 self.log.log("event.GetKeyCode() == wx.WXK_UP", ORPG_DEBUG) 1201 self.log.log("event.GetKeyCode() == wx.WXK_UP", ORPG_DEBUG)
1280 if self.histidx < len(self.history)-1: 1202 if self.histidx < len(self.history)-1:
1281 #text that's not in history but also hasn't been sent to chat gets stored in self.temptext 1203 #text that's not in history but also hasn't been sent to chat gets stored in self.temptext
1282 #this way if someone presses the up key, they don't lose their current message permanently 1204 #this way if someone presses the up key, they don't lose their current message permanently
1283 #(unless they also press enter at the time) 1205 #(unless they also press enter at the time)
1284 if self.histidx is -1: 1206 if self.histidx is -1: self.temptext = self.chattxt.GetValue()
1285 self.temptext = self.chattxt.GetValue()
1286 self.histidx += 1 1207 self.histidx += 1
1287 self.chattxt.SetValue(self.history[self.histidx]) 1208 self.chattxt.SetValue(self.history[self.histidx])
1288 self.chattxt.SetInsertionPointEnd() 1209 self.chattxt.SetInsertionPointEnd()
1289 else: 1210 else:
1290 self.histidx = len(self.history) -1#in case it got too high somehow, this should fix it 1211 self.histidx = len(self.history) -1#in case it got too high somehow, this should fix it
1297 #histidx of -1 indicates currently viewing text that's not in self.history 1218 #histidx of -1 indicates currently viewing text that's not in self.history
1298 if self.histidx > -1: 1219 if self.histidx > -1:
1299 self.histidx -= 1 1220 self.histidx -= 1
1300 if self.histidx is -1: #remember, it just decreased 1221 if self.histidx is -1: #remember, it just decreased
1301 self.chattxt.SetValue(self.temptext) 1222 self.chattxt.SetValue(self.temptext)
1302 else: 1223 else: self.chattxt.SetValue(self.history[self.histidx])
1303 self.chattxt.SetValue(self.history[self.histidx])
1304 self.chattxt.SetInsertionPointEnd() 1224 self.chattxt.SetInsertionPointEnd()
1305 else: 1225 else: self.histidx = -1 #just in case it somehow got below -1, this should fix it
1306 self.histidx = -1 #just in case it somehow got below -1, this should fix it
1307 #self.InfoPost("**Going down? I don't think so.**") 1226 #self.InfoPost("**Going down? I don't think so.**")
1308 #print self.histidx, "in",self.history 1227 #print self.histidx, "in",self.history
1309 1228
1310 ## TAB KEY 1229 ## TAB KEY
1311 elif event.GetKeyCode() == wx.WXK_TAB: 1230 elif event.GetKeyCode() == wx.WXK_TAB:
1348 1267
1349 ## PAGE UP 1268 ## PAGE UP
1350 elif event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP): 1269 elif event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP):
1351 self.log.log("event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP)", ORPG_DEBUG) 1270 self.log.log("event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP)", ORPG_DEBUG)
1352 self.chatwnd.ScrollPages(-1) 1271 self.chatwnd.ScrollPages(-1)
1353 if not self.lockscroll: 1272 if not self.lockscroll: self.lock_scroll(0)
1354 self.lock_scroll(0)
1355 1273
1356 ## PAGE DOWN 1274 ## PAGE DOWN
1357 elif event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN): 1275 elif event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN):
1358 self.log.log("event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN)", ORPG_DEBUG) 1276 self.log.log("event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN)", ORPG_DEBUG)
1359 if not self.lockscroll: 1277 if not self.lockscroll: self.lock_scroll(0)
1360 self.lock_scroll(0)
1361 if ((self.chatwnd.GetScrollRange(1)-self.chatwnd.GetScrollPos(1)-self.chatwnd.GetScrollThumb(1) < 30) and self.lockscroll): 1278 if ((self.chatwnd.GetScrollRange(1)-self.chatwnd.GetScrollPos(1)-self.chatwnd.GetScrollThumb(1) < 30) and self.lockscroll):
1362 self.lock_scroll(0) 1279 self.lock_scroll(0)
1363 self.chatwnd.ScrollPages(1) 1280 self.chatwnd.ScrollPages(1)
1364 1281
1365 ## END 1282 ## END
1369 self.lock_scroll(0) 1286 self.lock_scroll(0)
1370 self.Post() 1287 self.Post()
1371 event.Skip() 1288 event.Skip()
1372 1289
1373 ## NOTHING 1290 ## NOTHING
1374 else: 1291 else: event.Skip()
1375 event.Skip()
1376 self.log.log("Exit chat_panel->OnChar(self, event)", ORPG_DEBUG) 1292 self.log.log("Exit chat_panel->OnChar(self, event)", ORPG_DEBUG)
1377 # def OnChar - end 1293 # def OnChar - end
1378 1294
1379 def onDieRoll(self, evt): 1295 def onDieRoll(self, evt):
1380 """Roll the dice based on the button pressed and the die modifiers entered, if any.""" 1296 """Roll the dice based on the button pressed and the die modifiers entered, if any."""
1383 numDie = self.numDieText.GetValue() 1299 numDie = self.numDieText.GetValue()
1384 dieMod = self.dieModText.GetValue() 1300 dieMod = self.dieModText.GetValue()
1385 dieText = numDie 1301 dieText = numDie
1386 # Now, apply and roll die mods based on the button that was pressed 1302 # Now, apply and roll die mods based on the button that was pressed
1387 id = evt.GetId() 1303 id = evt.GetId()
1388 if self.dieIDs.has_key(id): 1304 if self.dieIDs.has_key(id): dieText += self.dieIDs[id]
1389 dieText += self.dieIDs[id] 1305 if len(dieMod) and dieMod[0] not in "*/-+": dieMod = "+" + dieMod
1390 if len(dieMod) and dieMod[0] not in "*/-+":
1391 dieMod = "+" + dieMod
1392 dieText += dieMod 1306 dieText += dieMod
1393 dieText = "[" + dieText + "]" 1307 dieText = "[" + dieText + "]"
1394 self.ParsePost(dieText, 1, 1) 1308 self.ParsePost(dieText, 1, 1)
1395 self.chattxt.SetFocus() 1309 self.chattxt.SetFocus()
1396 self.log.log("Exit chat_panel->onDieRoll(self, evt)", ORPG_DEBUG) 1310 self.log.log("Exit chat_panel->onDieRoll(self, evt)", ORPG_DEBUG)
1460 def on_text_format(self, event): 1374 def on_text_format(self, event):
1461 self.log.log("Enter chat_panel->on_text_format(self, event)", ORPG_DEBUG) 1375 self.log.log("Enter chat_panel->on_text_format(self, event)", ORPG_DEBUG)
1462 id = event.GetId() 1376 id = event.GetId()
1463 txt = self.chattxt.GetValue() 1377 txt = self.chattxt.GetValue()
1464 (beg,end) = self.chattxt.GetSelection() 1378 (beg,end) = self.chattxt.GetSelection()
1465 if beg != end: 1379 if beg != end: sel_txt = txt[beg:end]
1466 sel_txt = txt[beg:end] 1380 else: sel_txt = txt
1467 else: 1381 if id == self.boldButton.GetId(): sel_txt = "<b>" + sel_txt + "</b>"
1468 sel_txt = txt 1382 elif id == self.italicButton.GetId(): sel_txt = "<i>" + sel_txt + "</i>"
1469 if id == self.boldButton.GetId(): 1383 elif id == self.underlineButton.GetId(): sel_txt = "<u>" + sel_txt + "</u>"
1470 sel_txt = "<b>" + sel_txt + "</b>" 1384 if beg != end: txt = txt[:beg] + sel_txt + txt[end:]
1471 elif id == self.italicButton.GetId(): 1385 else: txt = sel_txt
1472 sel_txt = "<i>" + sel_txt + "</i>"
1473 elif id == self.underlineButton.GetId():
1474 sel_txt = "<u>" + sel_txt + "</u>"
1475 if beg != end:
1476 txt = txt[:beg] + sel_txt + txt[end:]
1477 else:
1478 txt = sel_txt
1479 self.chattxt.SetValue(txt) 1386 self.chattxt.SetValue(txt)
1480 self.chattxt.SetInsertionPointEnd() 1387 self.chattxt.SetInsertionPointEnd()
1481 self.chattxt.SetFocus() 1388 self.chattxt.SetFocus()
1482 self.log.log("Exit chat_panel->on_text_format(self, event)", ORPG_DEBUG) 1389 self.log.log("Exit chat_panel->on_text_format(self, event)", ORPG_DEBUG)
1483 # def on_text_format - end 1390 # def on_text_format - end
1486 self.log.log("Enter chat_panel->lock_scroll(self, event)", ORPG_DEBUG) 1393 self.log.log("Enter chat_panel->lock_scroll(self, event)", ORPG_DEBUG)
1487 if self.lockscroll: 1394 if self.lockscroll:
1488 self.lockscroll = False 1395 self.lockscroll = False
1489 self.scroll_lock.SetLabel("Scroll ON") 1396 self.scroll_lock.SetLabel("Scroll ON")
1490 if len(self.storedata) != 0: 1397 if len(self.storedata) != 0:
1491 for line in self.storedata: 1398 for line in self.storedata: self.chatwnd.AppendToPage(line)
1492 self.chatwnd.AppendToPage(line)
1493 self.storedata = [] 1399 self.storedata = []
1494 self.scroll_down() 1400 self.scroll_down()
1495 else: 1401 else:
1496 self.lockscroll = True 1402 self.lockscroll = True
1497 self.scroll_lock.SetLabel("Scroll OFF") 1403 self.scroll_lock.SetLabel("Scroll OFF")
1545 def get_gms(self): 1451 def get_gms(self):
1546 self.log.log("Enter chat_panel->get_gms(self)", ORPG_DEBUG) 1452 self.log.log("Enter chat_panel->get_gms(self)", ORPG_DEBUG)
1547 the_gms = [] 1453 the_gms = []
1548 for playerid in self.session.players: 1454 for playerid in self.session.players:
1549 if len(self.session.players[playerid])>7: 1455 if len(self.session.players[playerid])>7:
1550 if self.session.players[playerid][7]=="GM" and self.session.group_id != '0': 1456 if self.session.players[playerid][7]=="GM" and self.session.group_id != '0': the_gms += [playerid]
1551 the_gms += [playerid]
1552 self.log.log("Exit chat_panel->get_gms(self)", ORPG_DEBUG) 1457 self.log.log("Exit chat_panel->get_gms(self)", ORPG_DEBUG)
1553 return the_gms 1458 return the_gms
1554 1459
1555 def GetName(self): 1460 def GetName(self):
1556 self.log.log("Enter chat_panel->GetName(self)", ORPG_DEBUG) 1461 self.log.log("Enter chat_panel->GetName(self)", ORPG_DEBUG)
1569 advregex = re.compile('\"(.*?)\"', re.I) 1474 advregex = re.compile('\"(.*?)\"', re.I)
1570 self.AliasLib = open_rpg.get_component('alias') 1475 self.AliasLib = open_rpg.get_component('alias')
1571 if self.AliasLib != None: 1476 if self.AliasLib != None:
1572 self.AliasLib.filter = self.filterList.GetSelection()-1; 1477 self.AliasLib.filter = self.filterList.GetSelection()-1;
1573 for rule in self.AliasLib.filterRegEx: 1478 for rule in self.AliasLib.filterRegEx:
1574 if not self.advancedFilter: 1479 if not self.advancedFilter: text = re.sub(rule[0], rule[1], text)
1575 text = re.sub(rule[0], rule[1], text)
1576 else: 1480 else:
1577 for m in advregex.finditer(text): 1481 for m in advregex.finditer(text):
1578 match = m.group(0) 1482 match = m.group(0)
1579 newmatch = re.sub(rule[0], rule[1], match) 1483 newmatch = re.sub(rule[0], rule[1], match)
1580 text = text.replace(match, newmatch) 1484 text = text.replace(match, newmatch)
1584 def emote_message(self, text): 1488 def emote_message(self, text):
1585 self.log.log("Enter chat_panel->emote_message(self, text)", ORPG_DEBUG) 1489 self.log.log("Enter chat_panel->emote_message(self, text)", ORPG_DEBUG)
1586 text = self.NormalizeParse(text) 1490 text = self.NormalizeParse(text)
1587 text = self.colorize(self.emotecolor, text) 1491 text = self.colorize(self.emotecolor, text)
1588 1492
1589 if self.type == MAIN_TAB and self.sendtarget == 'all': 1493 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(text,chat_msg.EMOTE_MESSAGE)
1590 self.send_chat_message(text,chat_msg.EMOTE_MESSAGE)
1591 elif self.type == MAIN_TAB and self.sendtarget == "gm": 1494 elif self.type == MAIN_TAB and self.sendtarget == "gm":
1592 msg_type = chat_msg.WHISPER_EMOTE_MESSAGE 1495 msg_type = chat_msg.WHISPER_EMOTE_MESSAGE
1593 the_gms = self.get_gms() 1496 the_gms = self.get_gms()
1594 for each_gm in the_gms: 1497 for each_gm in the_gms: self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(each_gm))
1595 self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(each_gm))
1596 elif self.type == GROUP_TAB and WG_LIST.has_key(self.sendtarget): 1498 elif self.type == GROUP_TAB and WG_LIST.has_key(self.sendtarget):
1597 for pid in WG_LIST[self.sendtarget]: 1499 for pid in WG_LIST[self.sendtarget]:
1598 self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(pid)) 1500 self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(pid))
1599 elif self.type == WHISPER_TAB: 1501 elif self.type == WHISPER_TAB: self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(self.sendtarget))
1600 self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(self.sendtarget)) 1502 elif self.type == NULL_TAB: pass
1601 elif self.type == NULL_TAB:
1602 pass
1603 name = self.GetName()[0] 1503 name = self.GetName()[0]
1604 text = "** " + name + " " + text + " **" 1504 text = "** " + name + " " + text + " **"
1605 self.EmotePost(text) 1505 self.EmotePost(text)
1606 self.log.log("Exit chat_panel->emote_message(self, text)", ORPG_DEBUG) 1506 self.log.log("Exit chat_panel->emote_message(self, text)", ORPG_DEBUG)
1607 1507
1627 self.InfoPost("<i>whispering to "+ player_names + " " + text + "</i> ") 1527 self.InfoPost("<i>whispering to "+ player_names + " " + text + "</i> ")
1628 # colorize and loop, sending whisper messages to all valid clients 1528 # colorize and loop, sending whisper messages to all valid clients
1629 text = self.colorize(self.mytextcolor, text) 1529 text = self.colorize(self.mytextcolor, text)
1630 for id in player_ids: 1530 for id in player_ids:
1631 id = id.strip() 1531 id = id.strip()
1632 if self.session.is_valid_id(id): 1532 if self.session.is_valid_id(id): self.send_chat_message(text,chat_msg.WHISPER_MESSAGE,id)
1633 self.send_chat_message(text,chat_msg.WHISPER_MESSAGE,id) 1533 else: self.InfoPost(id + " Unknown!")
1634 else:
1635 self.InfoPost(id + " Unknown!")
1636 self.log.log("Exit chat_panel->whisper_to_players(self, text, player_ids)", ORPG_DEBUG) 1534 self.log.log("Exit chat_panel->whisper_to_players(self, text, player_ids)", ORPG_DEBUG)
1637 1535
1638 def send_chat_message(self, text, type=chat_msg.CHAT_MESSAGE, player_id="all"): 1536 def send_chat_message(self, text, type=chat_msg.CHAT_MESSAGE, player_id="all"):
1639 self.log.log("Enter chat_panel->send_chat_message(self, text, type, player_id)", ORPG_DEBUG) 1537 self.log.log("Enter chat_panel->send_chat_message(self, text, type, player_id)", ORPG_DEBUG)
1640 #########send_msg()############# 1538 #########send_msg()#############
1641 send = 1 1539 send = 1
1642 for plugin_fname in self.activeplugins.keys(): 1540 for plugin_fname in self.activeplugins.keys():
1643 plugin = self.activeplugins[plugin_fname] 1541 plugin = self.activeplugins[plugin_fname]
1644 try: 1542 try: text, send = plugin.send_msg(text, send)
1645 text, send = plugin.send_msg(text, send)
1646 except Exception, e: 1543 except Exception, e:
1647 if str(e) != "'module' object has no attribute 'send_msg'": 1544 if str(e) != "'module' object has no attribute 'send_msg'":
1648 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1545 self.log.log(traceback.format_exc(), ORPG_GENERAL)
1649 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1546 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL)
1650 msg = chat_msg.chat_msg() 1547 msg = chat_msg.chat_msg()
1654 if self.settings.get_setting("ShowIDInChat") == "1": 1551 if self.settings.get_setting("ShowIDInChat") == "1":
1655 turnedoff = True 1552 turnedoff = True
1656 self.settings.set_setting("ShowIDInChat", "0") 1553 self.settings.set_setting("ShowIDInChat", "0")
1657 playername = self.GetName()[0] 1554 playername = self.GetName()[0]
1658 1555
1659 if turnedoff: 1556 if turnedoff: self.settings.set_setting("ShowIDInChat", "1")
1660 self.settings.set_setting("ShowIDInChat", "1")
1661 msg.set_alias(playername) 1557 msg.set_alias(playername)
1662 if send: 1558 if send: self.session.send(msg.toxml(),player_id)
1663 self.session.send(msg.toxml(),player_id)
1664 del msg 1559 del msg
1665 self.log.log("Exit chat_panel->send_chat_message(self, text, type, player_id)", ORPG_DEBUG) 1560 self.log.log("Exit chat_panel->send_chat_message(self, text, type, player_id)", ORPG_DEBUG)
1666 1561
1667 #### incoming chat message handler ##### 1562 #### incoming chat message handler #####
1668 def post_incoming_msg(self, msg, player): 1563 def post_incoming_msg(self, msg, player):
1671 # pull data 1566 # pull data
1672 type = msg.get_type() 1567 type = msg.get_type()
1673 text = msg.get_text() 1568 text = msg.get_text()
1674 alias = msg.get_alias() 1569 alias = msg.get_alias()
1675 # who sent us the message? 1570 # who sent us the message?
1676 if alias: 1571 if alias: display_name = self.chat_display_name([alias, player[1], player[2]])
1677 display_name = self.chat_display_name([alias, player[1], player[2]]) 1572 elif player: display_name = self.chat_display_name(player)
1678 elif player: 1573 else: display_name = "Server Administrator"
1679 display_name = self.chat_display_name(player)
1680 else:
1681 display_name = "Server Administrator"
1682 1574
1683 ######### START plugin_incoming_msg() ########### 1575 ######### START plugin_incoming_msg() ###########
1684 for plugin_fname in self.activeplugins.keys(): 1576 for plugin_fname in self.activeplugins.keys():
1685 plugin = self.activeplugins[plugin_fname] 1577 plugin = self.activeplugins[plugin_fname]
1686 try: 1578 try: text, type, name = plugin.plugin_incoming_msg(text, type, display_name, player)
1687 text, type, name = plugin.plugin_incoming_msg(text, type, display_name, player)
1688 except Exception, e: 1579 except Exception, e:
1689 if str(e) != "'module' object has no attribute 'receive_msg'": 1580 if str(e) != "'module' object has no attribute 'receive_msg'":
1690 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1581 self.log.log(traceback.format_exc(), ORPG_GENERAL)
1691 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1582 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL)
1692 #end mDuo13 added code 1583 #end mDuo13 added code
1693 #image stripping for players' names 1584 #image stripping for players' names
1694 strip_img = self.settings.get_setting("Show_Images_In_Chat") 1585 strip_img = self.settings.get_setting("Show_Images_In_Chat")
1695 if (strip_img == "0"): 1586 if (strip_img == "0"): display_name = chat_util.strip_img_tags(display_name)
1696 display_name = chat_util.strip_img_tags(display_name)
1697 #end image stripping. --mDuo13, July 11th, 2005 1587 #end image stripping. --mDuo13, July 11th, 2005
1698 # default sound 1588 # default sound
1699 recvSound = "RecvSound" 1589 recvSound = "RecvSound"
1700 # act on the type of messsage 1590 # act on the type of messsage
1701 if (type == chat_msg.CHAT_MESSAGE): 1591 if (type == chat_msg.CHAT_MESSAGE):
1717 if GMWhisperTab == '1': 1607 if GMWhisperTab == '1':
1718 the_gms = self.get_gms() 1608 the_gms = self.get_gms()
1719 #Check if whisper if from a GM 1609 #Check if whisper if from a GM
1720 if player[2] in the_gms: 1610 if player[2] in the_gms:
1721 msg = name + ' (GM Whisper:) ' + text 1611 msg = name + ' (GM Whisper:) ' + text
1722 if type == chat_msg.WHISPER_MESSAGE: 1612 if type == chat_msg.WHISPER_MESSAGE: self.parent.GMChatPanel.Post(msg)
1723 self.parent.GMChatPanel.Post(msg) 1613 else: self.parent.GMChatPanel.EmotePost("**" + msg + "**")
1724 else:
1725 self.parent.GMChatPanel.EmotePost("**" + msg + "**")
1726 idx = self.parent.get_tab_index(self.parent.GMChatPanel) 1614 idx = self.parent.get_tab_index(self.parent.GMChatPanel)
1727 self.parent.newMsg(idx) 1615 self.parent.newMsg(idx)
1728 panelexists = 1 1616 panelexists = 1
1729 #See if message if from someone in our groups or for a whisper tab we already have 1617 #See if message if from someone in our groups or for a whisper tab we already have
1730 if not panelexists and GroupWhisperTab == "1": 1618 if not panelexists and GroupWhisperTab == "1":
1731 for panel in self.parent.group_tabs: 1619 for panel in self.parent.group_tabs:
1732 if WG_LIST.has_key(panel.sendtarget) and WG_LIST[panel.sendtarget].has_key(int(player[2])): 1620 if WG_LIST.has_key(panel.sendtarget) and WG_LIST[panel.sendtarget].has_key(int(player[2])):
1733 msg = name + text 1621 msg = name + text
1734 if type == chat_msg.WHISPER_MESSAGE: 1622 if type == chat_msg.WHISPER_MESSAGE: panel.Post(msg)
1735 panel.Post(msg) 1623 else: panel.EmotePost("**" + msg + "**")
1736 else:
1737 panel.EmotePost("**" + msg + "**")
1738 idx = self.parent.get_tab_index(panel) 1624 idx = self.parent.get_tab_index(panel)
1739 self.parent.newMsg(idx) 1625 self.parent.newMsg(idx)
1740 panelexists = 1 1626 panelexists = 1
1741 break 1627 break
1742 if not panelexists and tabbed_whispers_p == "1": 1628 if not panelexists and tabbed_whispers_p == "1":
1743 for panel in self.parent.whisper_tabs: 1629 for panel in self.parent.whisper_tabs:
1744 #check for whisper tabs as well, to save the number of loops 1630 #check for whisper tabs as well, to save the number of loops
1745 if panel.sendtarget == player[2]: 1631 if panel.sendtarget == player[2]:
1746 msg = name + whisperingstring + text 1632 msg = name + whisperingstring + text
1747 if type == chat_msg.WHISPER_MESSAGE: 1633 if type == chat_msg.WHISPER_MESSAGE: panel.Post(msg)
1748 panel.Post(msg) 1634 else: panel.EmotePost("**" + msg + "**")
1749 else:
1750 panel.EmotePost("**" + msg + "**")
1751 idx = self.parent.get_tab_index(panel) 1635 idx = self.parent.get_tab_index(panel)
1752 self.parent.newMsg(idx) 1636 self.parent.newMsg(idx)
1753 panelexists = 1 1637 panelexists = 1
1754 break 1638 break
1755 #We did not fint the tab 1639 #We did not fint the tab
1760 #Check if this group has the player in it 1644 #Check if this group has the player in it
1761 if WG_LIST[group].has_key(int(player[2])): 1645 if WG_LIST[group].has_key(int(player[2])):
1762 #Yup, post message. Player may be in more then 1 group so continue as well 1646 #Yup, post message. Player may be in more then 1 group so continue as well
1763 panel = self.parent.create_group_tab(group) 1647 panel = self.parent.create_group_tab(group)
1764 msg = name + text 1648 msg = name + text
1765 if type == chat_msg.WHISPER_MESSAGE: 1649 if type == chat_msg.WHISPER_MESSAGE: wx.CallAfter(panel.Post, msg)
1766 wx.CallAfter(panel.Post, msg) 1650 else: wx.CallAfter(panel.EmotePost, "**" + msg + "**")
1767 else:
1768 wx.CallAfter(panel.EmotePost, "**" + msg + "**")
1769 created = 1 1651 created = 1
1770 #Check to see if we should create a whisper tab 1652 #Check to see if we should create a whisper tab
1771 if not created and tabbed_whispers_p == "1": 1653 if not created and tabbed_whispers_p == "1":
1772 panel = self.parent.create_whisper_tab(player[2]) 1654 panel = self.parent.create_whisper_tab(player[2])
1773 msg = name + whisperingstring + text 1655 msg = name + whisperingstring + text
1774 if type == chat_msg.WHISPER_MESSAGE: 1656 if type == chat_msg.WHISPER_MESSAGE: wx.CallAfter(panel.Post, msg)
1775 wx.CallAfter(panel.Post, msg) 1657 else: wx.CallAfter(panel.EmotePost, "**" + msg + "**")
1776 else:
1777 wx.CallAfter(panel.EmotePost, "**" + msg + "**")
1778 created = 1 1658 created = 1
1779 #Final check 1659 #Final check
1780 if not created: 1660 if not created:
1781 #No tabs to create, just send the message to the main chat tab 1661 #No tabs to create, just send the message to the main chat tab
1782 msg = name + whisperingstring + text 1662 msg = name + whisperingstring + text
1783 if type == chat_msg.WHISPER_MESSAGE: 1663 if type == chat_msg.WHISPER_MESSAGE: self.parent.MainChatPanel.Post(msg)
1784 self.parent.MainChatPanel.Post(msg) 1664 else: self.parent.MainChatPanel.EmotePost("**" + msg + "**")
1785 else:
1786 self.parent.MainChatPanel.EmotePost("**" + msg + "**")
1787 self.parent.newMsg(0) 1665 self.parent.newMsg(0)
1788 except Exception, e: 1666 except Exception, e:
1789 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1667 self.log.log(traceback.format_exc(), ORPG_GENERAL)
1790 self.log.log("EXCEPTION: 'Error in posting whisper message': " + str(e), ORPG_GENERAL) 1668 self.log.log("EXCEPTION: 'Error in posting whisper message': " + str(e), ORPG_GENERAL)
1791 elif (type == chat_msg.EMOTE_MESSAGE): 1669 elif (type == chat_msg.EMOTE_MESSAGE):
1807 self.log.log("Exit chat_panel->post_incoming_msg(self, msg, player)", ORPG_DEBUG) 1685 self.log.log("Exit chat_panel->post_incoming_msg(self, msg, player)", ORPG_DEBUG)
1808 #### Posting helpers ##### 1686 #### Posting helpers #####
1809 1687
1810 def InfoPost(self, s): 1688 def InfoPost(self, s):
1811 self.log.log("Enter chat_panel->InfoPost(self, s)", ORPG_DEBUG) 1689 self.log.log("Enter chat_panel->InfoPost(self, s)", ORPG_DEBUG)
1812 self.Post(self.colorize(self.infocolor, s)) 1690 self.Post(self.colorize(self.infocolor, s), c='info')
1813 self.log.log("Exit chat_panel->InfoPost(self, s)", ORPG_DEBUG) 1691 self.log.log("Exit chat_panel->InfoPost(self, s)", ORPG_DEBUG)
1814 1692
1815 def SystemPost(self, s): 1693 def SystemPost(self, s):
1816 self.log.log("Enter chat_panel->SystemPost(self, s)", ORPG_DEBUG) 1694 self.log.log("Enter chat_panel->SystemPost(self, s)", ORPG_DEBUG)
1817 self.Post(self.colorize(self.syscolor, s)) 1695 self.Post(self.colorize(self.syscolor, s), c='system')
1818 self.log.log("Exit chat_panel->SystemPost(self, s)", ORPG_DEBUG) 1696 self.log.log("Exit chat_panel->SystemPost(self, s)", ORPG_DEBUG)
1819 1697
1820 def EmotePost(self, s): 1698 def EmotePost(self, s):
1821 self.log.log("Enter chat_panel->EmotePost(self, s)", ORPG_DEBUG) 1699 self.log.log("Enter chat_panel->EmotePost(self, s)", ORPG_DEBUG)
1822 self.Post(self.colorize(self.emotecolor, s)) 1700 self.Post(self.colorize(self.emotecolor, s), c='emote')
1823 self.log.log("Exit chat_panel->EmotePost(self, s)", ORPG_DEBUG) 1701 self.log.log("Exit chat_panel->EmotePost(self, s)", ORPG_DEBUG)
1824 1702
1825 #### Standard Post method ##### 1703 #### Standard Post method #####
1826 def Post(self, s="", send=False, myself=False): 1704 def Post(self, s="", send=False, myself=False, c='post'):
1827 self.log.log("Enter chat_panel->Post(self, s, send, myself)", ORPG_DEBUG) 1705 self.log.log("Enter chat_panel->Post(self, s, send, myself)", ORPG_DEBUG)
1828 strip_p = self.settings.get_setting("striphtml") 1706 strip_p = self.settings.get_setting("striphtml")
1829 strip_img = self.settings.get_setting("Show_Images_In_Chat")#moved back 7-11-05. --mDuo13 1707 strip_img = self.settings.get_setting("Show_Images_In_Chat")#moved back 7-11-05. --mDuo13
1830 if (strip_p == "1"): 1708 if (strip_p == "1"): s = strip_html(s)
1831 s = strip_html(s) 1709 if (strip_img == "0"): s = chat_util.strip_img_tags(s)
1832 if (strip_img == "0"):
1833 s = chat_util.strip_img_tags(s)
1834 s = chat_util.simple_html_repair(s) 1710 s = chat_util.simple_html_repair(s)
1835 s = chat_util.strip_script_tags(s) 1711 s = chat_util.strip_script_tags(s)
1836 s = chat_util.strip_li_tags(s) 1712 s = chat_util.strip_li_tags(s)
1837 s = chat_util.strip_body_tags(s)#7-27-05 mDuo13 1713 s = chat_util.strip_body_tags(s) #7-27-05 mDuo13
1838 s = chat_util.strip_misalignment_tags(s)#7-27-05 mDuo13 1714 s = chat_util.strip_misalignment_tags(s) #7-27-05 mDuo13
1839 aliasInfo = self.GetName() 1715 aliasInfo = self.GetName()
1840 display_name = aliasInfo[0] 1716 display_name = aliasInfo[0]
1841 if aliasInfo[1] != 'Default': 1717 if aliasInfo[1] != 'Default':
1842 defaultcolor = self.settings.get_setting("mytextcolor") 1718 defaultcolor = self.settings.get_setting("mytextcolor")
1843 self.settings.set_setting("mytextcolor", aliasInfo[1]) 1719 self.settings.set_setting("mytextcolor", aliasInfo[1])
1846 #following added by mDuo13 1722 #following added by mDuo13
1847 #########post_msg() - other########## 1723 #########post_msg() - other##########
1848 if not myself and not send: 1724 if not myself and not send:
1849 for plugin_fname in self.activeplugins.keys(): 1725 for plugin_fname in self.activeplugins.keys():
1850 plugin = self.activeplugins[plugin_fname] 1726 plugin = self.activeplugins[plugin_fname]
1851 try: 1727 try: s = plugin.post_msg(s, myself)
1852 s = plugin.post_msg(s, myself)
1853 except Exception, e: 1728 except Exception, e:
1854 if str(e) != "'module' object has no attribute 'post_msg'": 1729 if str(e) != "'module' object has no attribute 'post_msg'":
1855 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1730 self.log.log(traceback.format_exc(), ORPG_GENERAL)
1856 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1731 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL)
1857 #end mDuo13 added code 1732 #end mDuo13 added code
1858 if myself: 1733 if myself:
1859 name = "<b>" + display_name + "</b>: " 1734 name = "<b>" + display_name + "</b>: "
1860 s = self.colorize(self.mytextcolor, s) 1735 s = self.colorize(self.mytextcolor, s)
1861 else: 1736 else: name = ""
1862 name = ""
1863 if aliasInfo[1] != 'Default': 1737 if aliasInfo[1] != 'Default':
1864 self.settings.set_setting("mytextcolor", defaultcolor) 1738 self.settings.set_setting("mytextcolor", defaultcolor)
1865 self.set_colors() 1739 self.set_colors()
1866 #following line based on sourceforge patch #880403 from mDuo 1740 #following line based on sourceforge patch #880403 from mDuo
1867 # EDIT: Had to rework blank line check to handle malformed HTML throwing error. 1741 # EDIT: Had to rework blank line check to handle malformed HTML throwing error.
1868 # this limits the effectiveness of this check -SD 1742 # this limits the effectiveness of this check -SD
1869 lineHasText = 1 1743 lineHasText = 1
1870 try: 1744 try: lineHasText = strip_html(s).replace("&nbsp;","").replace(" ","").strip()!=""
1871 lineHasText = strip_html(s).replace("&nbsp;","").replace(" ","").strip()!=""
1872 except: 1745 except:
1873 # HTML parser has errored out (most likely). Being as all we are doing is 1746 # HTML parser has errored out (most likely). Being as all we are doing is
1874 # scanning for empty/blank lines anyway there is no harm in letting a 1747 # scanning for empty/blank lines anyway there is no harm in letting a
1875 # troublesome message though. Worst case is a blank line to chat. 1748 # troublesome message though. Worst case is a blank line to chat.
1876 lineHasText = 1 1749 lineHasText = 1
1890 if s2 != "": 1763 if s2 != "":
1891 #Italici the messages from tabbed whispers 1764 #Italici the messages from tabbed whispers
1892 if self.type == WHISPER_TAB or self.type == GROUP_TAB or self.sendtarget == 'gm': 1765 if self.type == WHISPER_TAB or self.type == GROUP_TAB or self.sendtarget == 'gm':
1893 s2 = s2 + '</i>' 1766 s2 = s2 + '</i>'
1894 name = '<i>' + name 1767 name = '<i>' + name
1895 if self.type == WHISPER_TAB: 1768 if self.type == WHISPER_TAB: name += " (whispering): "
1896 name += " (whispering): " 1769 elif self.type == GROUP_TAB: name += self.settings.get_setting("gwtext") + ' '
1897 elif self.type == GROUP_TAB: 1770 elif self.sendtarget == 'gm': name += " (whispering to GM) "
1898 name += self.settings.get_setting("gwtext") + ' ' 1771 newline = self.TimeIndexString() + "<div class='"+c+"'> " +name + s2 + "</div>"
1899 elif self.sendtarget == 'gm': 1772 log( self.settings, c+' '+name + s2 )
1900 name += " (whispering to GM) "
1901 newline = self.TimeIndexString() + name + s2 + "<br />"
1902 log( self.settings, name + s2 )
1903 else: 1773 else:
1904 newline = self.TimeIndexString() + name + s + "<br />" 1774 newline = self.TimeIndexString() + "<div class='"+c+"'> " +name + s + "</div>"
1905 log( self.settings, name + s ) 1775 log( self.settings, c+' '+name + s )
1906 else: 1776 else: send = False
1907 send = False
1908 newline = chat_util.strip_unicode(newline) 1777 newline = chat_util.strip_unicode(newline)
1909 if self.lockscroll == 0: 1778 if self.lockscroll == 0:
1910 self.chatwnd.AppendToPage(newline) 1779 self.chatwnd.AppendToPage(newline)
1911 self.scroll_down() 1780 self.scroll_down()
1912 else: 1781 else: self.storedata.append(newline)
1913 self.storedata.append(newline)
1914 if send: 1782 if send:
1915 if self.type == MAIN_TAB and self.sendtarget == 'all': 1783 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(s)
1916 self.send_chat_message(s)
1917 elif self.type == MAIN_TAB and self.sendtarget == "gm": 1784 elif self.type == MAIN_TAB and self.sendtarget == "gm":
1918 the_gms = self.get_gms() 1785 the_gms = self.get_gms()
1919 self.whisper_to_players(s, the_gms) 1786 self.whisper_to_players(s, the_gms)
1920 elif self.type == GROUP_TAB and WG_LIST.has_key(self.sendtarget): 1787 elif self.type == GROUP_TAB and WG_LIST.has_key(self.sendtarget):
1921 members = [] 1788 members = []
1922 for pid in WG_LIST[self.sendtarget]: 1789 for pid in WG_LIST[self.sendtarget]: members.append(str(WG_LIST[self.sendtarget][pid]))
1923 members.append(str(WG_LIST[self.sendtarget][pid]))
1924 self.whisper_to_players(self.settings.get_setting("gwtext") + s, members) 1790 self.whisper_to_players(self.settings.get_setting("gwtext") + s, members)
1925 elif self.type == WHISPER_TAB: 1791 elif self.type == WHISPER_TAB: self.whisper_to_players(s, [self.sendtarget])
1926 self.whisper_to_players(s, [self.sendtarget]) 1792 elif self.type == NULL_TAB: pass
1927 elif self.type == NULL_TAB: 1793 else: self.InfoPost("Failed to send message, unknown send type for this tab")
1928 pass
1929 else:
1930 self.InfoPost("Failed to send message, unknown send type for this tab")
1931 self.parsed=0 1794 self.parsed=0
1932 self.log.log("Exit chat_panel->Post(self, s, send, myself)", ORPG_DEBUG) 1795 self.log.log("Exit chat_panel->Post(self, s, send, myself)", ORPG_DEBUG)
1933 1796
1934 # 1797 #
1935 # TimeIndexString() 1798 # TimeIndexString()
1938 # added by Snowdog 4/04 1801 # added by Snowdog 4/04
1939 def TimeIndexString(self): 1802 def TimeIndexString(self):
1940 self.log.log("Enter chat_panel->TimeIndexString(self)", ORPG_DEBUG) 1803 self.log.log("Enter chat_panel->TimeIndexString(self)", ORPG_DEBUG)
1941 try: 1804 try:
1942 mtime = "" 1805 mtime = ""
1943 if self.settings.get_setting('Chat_Time_Indexing') == "0": 1806 if self.settings.get_setting('Chat_Time_Indexing') == "0": pass
1944 pass
1945 elif self.settings.get_setting('Chat_Time_Indexing') == "1": 1807 elif self.settings.get_setting('Chat_Time_Indexing') == "1":
1946 mtime = time.strftime("[%I:%M:%S] ", time.localtime()) 1808 mtime = time.strftime("[%I:%M:%S] ", time.localtime())
1947 self.log.log("Exit chat_panel->TimeIndexString(self)", ORPG_DEBUG) 1809 self.log.log("Exit chat_panel->TimeIndexString(self)", ORPG_DEBUG)
1948 return mtime 1810 return mtime
1949 except Exception, e: 1811 except Exception, e:
1961 1823
1962 def NormalizeParse(self, s): 1824 def NormalizeParse(self, s):
1963 self.log.log("Enter chat_panel->NormalizeParse(self, s)", ORPG_DEBUG) 1825 self.log.log("Enter chat_panel->NormalizeParse(self, s)", ORPG_DEBUG)
1964 for plugin_fname in self.activeplugins.keys(): 1826 for plugin_fname in self.activeplugins.keys():
1965 plugin = self.activeplugins[plugin_fname] 1827 plugin = self.activeplugins[plugin_fname]
1966 try: 1828 try: s = plugin.pre_parse(s)
1967 s = plugin.pre_parse(s)
1968 except Exception, e: 1829 except Exception, e:
1969 if str(e) != "'module' object has no attribute 'post_msg'": 1830 if str(e) != "'module' object has no attribute 'post_msg'":
1970 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1831 self.log.log(traceback.format_exc(), ORPG_GENERAL)
1971 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1832 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL)
1972 if self.parsed == 0: 1833 if self.parsed == 0:
2006 qmode = 0 1867 qmode = 0
2007 newstr1 = newstr 1868 newstr1 = newstr
2008 if newstr[0].lower() == 'q': 1869 if newstr[0].lower() == 'q':
2009 newstr = newstr[1:] 1870 newstr = newstr[1:]
2010 qmode = 1 1871 qmode = 1
2011 try: 1872 try: newstr = self.DiceManager.proccessRoll(newstr)
2012 newstr = self.DiceManager.proccessRoll(newstr) 1873 except: pass
2013 except:
2014 pass
2015 if qmode == 1: 1874 if qmode == 1:
2016 s = s.replace("[" + matches[i] + "]", "<!-- Official Roll [" + newstr1 + "] => " + newstr + "-->" + newstr, 1) 1875 s = s.replace("[" + matches[i] + "]", "<!-- Official Roll [" + newstr1 + "] => " + newstr + "-->" + newstr, 1)
2017 else: 1876 else: s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "<!-- Official Roll -->] => " + newstr, 1)
2018 s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "<!-- Official Roll -->] => " + newstr, 1)
2019 self.log.log("Exit chat_panel->ParseDice(self, s)", ORPG_DEBUG) 1877 self.log.log("Exit chat_panel->ParseDice(self, s)", ORPG_DEBUG)
2020 return s 1878 return s
2021 1879
2022 def PraseUnknowns(self, s): 1880 def PraseUnknowns(self, s):
2023 # Uses a tuple. Usage: ?Label}dY. If no Label is assigned then use ?}DY 1881 # Uses a tuple. Usage: ?Label}dY. If no Label is assigned then use ?}DY
2031 lb = matches[i][1] + "?: " 1889 lb = matches[i][1] + "?: "
2032 dlg = wx.TextEntryDialog(self, lb, "Missing Value?") 1890 dlg = wx.TextEntryDialog(self, lb, "Missing Value?")
2033 dlg.SetValue('') 1891 dlg.SetValue('')
2034 if matches[i][0] != '': 1892 if matches[i][0] != '':
2035 dlg.SetTitle("Enter Value for " + matches[i][1]) 1893 dlg.SetTitle("Enter Value for " + matches[i][1])
2036 if dlg.ShowModal() == wx.ID_OK: 1894 if dlg.ShowModal() == wx.ID_OK: newstr = dlg.GetValue()
2037 newstr = dlg.GetValue() 1895 if newstr == '': newstr = '0'
2038 if newstr == '':
2039 newstr = '0'
2040 s = s.replace(matches[i][0], newstr, 1).replace(matches[i][1], '', 1).replace(matches[i][2], '', 1) 1896 s = s.replace(matches[i][0], newstr, 1).replace(matches[i][1], '', 1).replace(matches[i][2], '', 1)
2041 dlg.Destroy() 1897 dlg.Destroy()
2042 self.log.log("Exit chat_panel->PraseUnknowns(self, s)", ORPG_DEBUG) 1898 self.log.log("Exit chat_panel->PraseUnknowns(self, s)", ORPG_DEBUG)
2043 return s 1899 return s
2044 1900