comparison orpg/chat/chatwnd.py @ 66:c54768cffbd4 ornery-dev

Traipse Dev 'OpenRPG' {090818-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc''s main goal is to offer more advanced features and enhance the productivity of the user. Update Summary: *Unstable* This is the first wave of Code Refinement updates. Includes new material from Core Beta; new debugger material (partially implemented), beginnings of switch to etree, TerminalWriter, and a little more. open_rpg has been renamed to component; functioning now as component.get(), component.add(), component.delete(). This version has known bugs, specifically with the gametree and nodes. I think the XML files where not removed during testing of Core and switching back.
author sirebral
date Tue, 18 Aug 2009 06:33:37 -0500
parents c160f26ecf65
children 8fb07d0a1ca0
comparison
equal deleted inserted replaced
65:4840657c23c5 66:c54768cffbd4
43 ## 43 ##
44 ## Module Loading 44 ## Module Loading
45 ## 45 ##
46 from orpg.orpg_windows import * 46 from orpg.orpg_windows import *
47 from orpg.player_list import WG_LIST 47 from orpg.player_list import WG_LIST
48 import orpg.dirpath 48 from orpg.dirpath import dir_struct
49 import orpg.tools.rgbhex 49 import orpg.tools.rgbhex
50 import orpg.tools.inputValidator 50 import orpg.tools.inputValidator
51 from orpg.tools.metamenus import MenuEx 51 #from orpg.tools.metamenus import MenuEx #Needed?
52 from orpg.orpgCore import open_rpg 52 from orpg.orpgCore import component
53 import webbrowser 53 import webbrowser
54 from string import * 54 from string import *
55 from orpg.orpg_version import VERSION 55 from orpg.orpg_version import VERSION
56 import commands 56 import commands
57 import chat_msg 57 import chat_msg
64 import sys 64 import sys
65 import cStringIO # for reading inline imagedata as a stream 65 import cStringIO # for reading inline imagedata as a stream
66 from HTMLParser import HTMLParser 66 from HTMLParser import HTMLParser
67 import chat_util 67 import chat_util
68 import traceback 68 import traceback
69 from orpg.tools.decorators import debugging
69 NEWCHAT = False 70 NEWCHAT = False
70 try: 71 try:
71 import wx.webview 72 import wx.webview
72 NEWCHAT = True 73 NEWCHAT = True
73 except: pass 74 except: pass
109 #filename = time.strftime( filename, time.localtime( time.time() ) ) 110 #filename = time.strftime( filename, time.localtime( time.time() ) )
110 timestamp = time.ctime(time.time()) 111 timestamp = time.ctime(time.time())
111 header = '[%s] : ' % ( timestamp ); 112 header = '[%s] : ' % ( timestamp );
112 if settings.get_setting('TimeStampGameLog') != '1': header = '' 113 if settings.get_setting('TimeStampGameLog') != '1': header = ''
113 try: 114 try:
114 f = open( orpg.dirpath.dir_struct["user"] + filename, 'a' ) 115 f = open( dir_struct["user"] + filename, 'a' )
115 f.write( '<div class="'+c+'">%s%s</div>\n' % ( header, text ) ) 116 f.write( '<div class="'+c+'">%s%s</div>\n' % ( header, text ) )
116 f.close() 117 f.close()
117 except: 118 except:
118 print "could not open " + orpg.dirpath.dir_struct["user"] + filename + ", ignoring..." 119 print "could not open " + dir_struct["user"] + filename + ", ignoring..."
119 pass 120 pass
120 121
121 # This class displayes the chat information in html? 122 # This class displayes the chat information in html?
122 # 123 #
123 # Defines: 124 # Defines:
305 # destroy_private_tab(self, chatpanel) 306 # destroy_private_tab(self, chatpanel)
306 # OnPageChanged(self, event) 307 # OnPageChanged(self, event)
307 # set_default_font(self, font, fontsize) 308 # set_default_font(self, font, fontsize)
308 309
309 class chat_notebook(orpgTabberWnd): 310 class chat_notebook(orpgTabberWnd):
311 @debugging
310 def __init__(self, parent, size): 312 def __init__(self, parent, size):
311 self.log = open_rpg.get_component("log") 313 orpgTabberWnd.__init__(self, parent, True, size=size,
312 self.log.log("Enter chat_notebook", ORPG_DEBUG) 314 style=FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_NO_NAV_BUTTONS|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS)
313 orpgTabberWnd.__init__(self, parent, True, size=size, style=FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_NO_NAV_BUTTONS|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS) 315 self.settings = component.get("settings")
314 self.settings = open_rpg.get_component("settings")
315 self.whisper_tabs = [] 316 self.whisper_tabs = []
316 self.group_tabs = [] 317 self.group_tabs = []
317 self.null_tabs = [] 318 self.null_tabs = []
318 self.il = wx.ImageList(16, 16) 319 self.il = wx.ImageList(16, 16)
319 bmp = wx.Bitmap(orpg.dirpath.dir_struct["icon"]+'player.gif') 320 bmp = wx.Bitmap(dir_struct["icon"]+'player.gif')
320 self.il.Add(bmp) 321 self.il.Add(bmp)
321 bmp = wx.Bitmap(orpg.dirpath.dir_struct["icon"]+'clear.gif') 322 bmp = wx.Bitmap(dir_struct["icon"]+'clear.gif')
322 self.il.Add(bmp) 323 self.il.Add(bmp)
323 self.SetImageList(self.il) 324 self.SetImageList(self.il)
324 # Create "main" chatpanel tab, undeletable, connected to 'public' room. 325 # Create "main" chatpanel tab, undeletable, connected to 'public' room.
325 self.MainChatPanel = chat_panel(self, -1, MAIN_TAB, 'all') 326 self.MainChatPanel = chat_panel(self, -1, MAIN_TAB, 'all')
326 self.AddPage(self.MainChatPanel, "Main Room") 327 self.AddPage(self.MainChatPanel, "Main Room")
331 # Hook up event handler for flipping tabs 332 # Hook up event handler for flipping tabs
332 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.onPageChanged) 333 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.onPageChanged)
333 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.onPageChanging) 334 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.onPageChanging)
334 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.onCloseTab) 335 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.onCloseTab)
335 # html font/fontsize is global to all the notebook tabs. 336 # html font/fontsize is global to all the notebook tabs.
336 self.font, self.fontsize = self.MainChatPanel.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'), self.settings.get_setting('defaultfontsize')) 337 self.font, self.fontsize = self.MainChatPanel.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'),
338 self.settings.get_setting('defaultfontsize'))
337 self.GMChatPanel = None 339 self.GMChatPanel = None
338 if self.settings.get_setting("GMWhisperTab") == '1': 340 if self.settings.get_setting("GMWhisperTab") == '1':
339 self.create_gm_tab() 341 self.create_gm_tab()
340 self.SetSelection(0) 342 self.SetSelection(0)
341 self.log.log("Exit chat_notebook", ORPG_DEBUG) 343
342 344 @debugging
343 def get_tab_index(self, chatpanel): 345 def get_tab_index(self, chatpanel):
344 "Return the index of a chatpanel in the wxNotebook." 346 "Return the index of a chatpanel in the wxNotebook."
345 self.log.log("Enter chat_notebook->get_tab_index(self, chatpanel)", ORPG_DEBUG)
346 347
347 for i in xrange(self.GetPageCount()): 348 for i in xrange(self.GetPageCount()):
348 if (self.GetPage(i) == chatpanel): 349 if (self.GetPage(i) == chatpanel):
349 self.log.log("Exit chat_notebook->get_tab_index(self, chatpanel)", ORPG_DEBUG)
350 return i 350 return i
351 351
352 @debugging
352 def create_gm_tab(self): 353 def create_gm_tab(self):
353 self.log.log("Enter chat_notebook->create_gm_tab(self)", ORPG_DEBUG)
354 if self.GMChatPanel == None: 354 if self.GMChatPanel == None:
355 self.GMChatPanel = chat_panel(self, -1, MAIN_TAB, 'gm') 355 self.GMChatPanel = chat_panel(self, -1, MAIN_TAB, 'gm')
356 self.AddPage(self.GMChatPanel, "GM", False) 356 self.AddPage(self.GMChatPanel, "GM", False)
357 self.SetPageImage(self.GetPageCount()-1, 1) 357 self.SetPageImage(self.GetPageCount()-1, 1)
358 self.GMChatPanel.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) 358 self.GMChatPanel.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize)
359 self.log.log("Exit chat_notebook->create_gm_tab(self)", ORPG_DEBUG) 359
360 360 @debugging
361 def create_whisper_tab(self, playerid): 361 def create_whisper_tab(self, playerid):
362 "Add a new chatpanel directly connected to integer 'playerid' via whispering." 362 "Add a new chatpanel directly connected to integer 'playerid' via whispering."
363 self.log.log("Enter chat_notebook->create_whisper_tab(self," + str(playerid) +")", ORPG_DEBUG)
364 private_tab = chat_panel(self, -1, WHISPER_TAB, playerid) 363 private_tab = chat_panel(self, -1, WHISPER_TAB, playerid)
365 playername = strip_html(self.MainChatPanel.session.get_player_by_player_id(playerid)[0]) 364 playername = strip_html(self.MainChatPanel.session.get_player_by_player_id(playerid)[0])
366 self.AddPage(private_tab, playername, False) 365 self.AddPage(private_tab, playername, False)
367 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) 366 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize)
368 self.whisper_tabs.append(private_tab) 367 self.whisper_tabs.append(private_tab)
369 self.newMsg(self.GetPageCount()-1) 368 self.newMsg(self.GetPageCount()-1)
370 self.AliasLib = open_rpg.get_component('alias') 369 self.AliasLib = component.get('alias')
371 wx.CallAfter(self.AliasLib.RefreshAliases) 370 wx.CallAfter(self.AliasLib.RefreshAliases)
372 self.log.log("Exit chat_notebook->create_whisper_tab(self, playerid)", ORPG_DEBUG)
373 return private_tab 371 return private_tab
374 372
373 @debugging
375 def create_group_tab(self, group_name): 374 def create_group_tab(self, group_name):
376 "Add a new chatpanel directly connected to integer 'playerid' via whispering." 375 "Add a new chatpanel directly connected to integer 'playerid' via whispering."
377 self.log.log("Enter chat_notebook->create_group_tab(self, group_name)", ORPG_DEBUG)
378 private_tab = chat_panel(self, -1, GROUP_TAB, group_name) 376 private_tab = chat_panel(self, -1, GROUP_TAB, group_name)
379 self.AddPage(private_tab, group_name, False) 377 self.AddPage(private_tab, group_name, False)
380 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) 378 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize)
381 self.group_tabs.append(private_tab) 379 self.group_tabs.append(private_tab)
382 self.newMsg(self.GetPageCount()-1) 380 self.newMsg(self.GetPageCount()-1)
383 self.AliasLib = open_rpg.get_component('alias') 381 self.AliasLib = component.get('alias')
384 wx.CallAfter(self.AliasLib.RefreshAliases) 382 wx.CallAfter(self.AliasLib.RefreshAliases)
385 self.log.log("Exit chat_notebook->create_group_tab(self, group_name)", ORPG_DEBUG)
386 return private_tab 383 return private_tab
387 384
385 @debugging
388 def create_null_tab(self, tab_name): 386 def create_null_tab(self, tab_name):
389 "Add a new chatpanel directly connected to integer 'playerid' via whispering." 387 "Add a new chatpanel directly connected to integer 'playerid' via whispering."
390 self.log.log("Enter chat_notebook->create_null_tab(self, tab_name)", ORPG_DEBUG)
391 private_tab = chat_panel(self, -1, NULL_TAB, tab_name) 388 private_tab = chat_panel(self, -1, NULL_TAB, tab_name)
392 self.AddPage(private_tab, tab_name, False) 389 self.AddPage(private_tab, tab_name, False)
393 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) 390 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize)
394 self.null_tabs.append(private_tab) 391 self.null_tabs.append(private_tab)
395 self.newMsg(self.GetPageCount()-1) 392 self.newMsg(self.GetPageCount()-1)
396 self.AliasLib = open_rpg.get_component('alias') 393 self.AliasLib = component.get('alias')
397 wx.CallAfter(self.AliasLib.RefreshAliases) 394 wx.CallAfter(self.AliasLib.RefreshAliases)
398 self.log.log("Exit chat_notebook->create_null_tab(self, tab_name)", ORPG_DEBUG)
399 return private_tab 395 return private_tab
400 396
397 @debugging
401 def onCloseTab(self, evt): 398 def onCloseTab(self, evt):
402 self.log.log("Enter chat_notebook->onCloseTab(self, evt)", ORPG_DEBUG)
403 try: tabid = evt.GetSelection() 399 try: tabid = evt.GetSelection()
404 except: tabid = self.GetSelection() 400 except: tabid = self.GetSelection()
405 401
406 if self.GetPageText(tabid) == 'Main Room': 402 if self.GetPageText(tabid) == 'Main Room':
407 #send no close error to chat 403 #send no close error to chat
424 self.settings.set_setting("GMWhisperTab", "0") 420 self.settings.set_setting("GMWhisperTab", "0")
425 panel = self.GetPage(tabid) 421 panel = self.GetPage(tabid)
426 if panel in self.whisper_tabs: self.whisper_tabs.remove(panel) 422 if panel in self.whisper_tabs: self.whisper_tabs.remove(panel)
427 elif panel in self.group_tabs: self.group_tabs.remove(panel) 423 elif panel in self.group_tabs: self.group_tabs.remove(panel)
428 elif panel in self.null_tabs: self.null_tabs.remove(panel) 424 elif panel in self.null_tabs: self.null_tabs.remove(panel)
429 self.log.log("Exit chat_notebook->onCloseTab(self, evt)", ORPG_DEBUG) 425
430 426 @debugging
431 def newMsg(self, tabid): 427 def newMsg(self, tabid):
432 self.log.log("Enter chat_notebook->newMsg(self, tabid)", ORPG_DEBUG)
433 if tabid != self.GetSelection(): self.SetPageImage(tabid, 0) 428 if tabid != self.GetSelection(): self.SetPageImage(tabid, 0)
434 self.log.log("Exit chat_notebook->newMsg(self, tabid)", ORPG_DEBUG) 429
435 430 @debugging
436 def onPageChanging(self, event): 431 def onPageChanging(self, event):
437 """When private chattabs are selected, set the bitmap back to 'normal'.""" 432 """When private chattabs are selected, set the bitmap back to 'normal'."""
438 self.log.log("Enter chat_notebook->onPageChanging(self, event)", ORPG_DEBUG)
439 event.Skip() 433 event.Skip()
440 self.log.log("Exit chat_notebook->onPageChanging(self, event)", ORPG_DEBUG) 434
441 435 @debugging
442 def onPageChanged(self, event): 436 def onPageChanged(self, event):
443 """When private chattabs are selected, set the bitmap back to 'normal'.""" 437 """When private chattabs are selected, set the bitmap back to 'normal'."""
444 self.log.log("Enter chat_notebook->onPageChanged(self, event)", ORPG_DEBUG)
445 selected_idx = event.GetSelection() 438 selected_idx = event.GetSelection()
446 self.SetPageImage(selected_idx, 1) 439 self.SetPageImage(selected_idx, 1)
447 page = self.GetPage(selected_idx) 440 page = self.GetPage(selected_idx)
448 #wx.CallAfter(page.set_chat_text_focus, 0) 441 #wx.CallAfter(page.set_chat_text_focus, 0)
449 event.Skip() 442 event.Skip()
450 self.log.log("Exit chat_notebook->onPageChanged(self, event)", ORPG_DEBUG)
451 443
452 """ 444 """
453 This class defines and builds the Chat Frame for OpenRPG 445 This class defines and builds the Chat Frame for OpenRPG
454 446
455 Inherits: wxPanel 447 Inherits: wxPanel
488 !id : 480 !id :
489 !openrpg : 481 !openrpg :
490 !sendtarget: who gets outbound messages: either 'all' or a playerid 482 !sendtarget: who gets outbound messages: either 'all' or a playerid
491 """ 483 """
492 484
485 @debugging
493 def __init__(self, parent, id, tab_type, sendtarget): 486 def __init__(self, parent, id, tab_type, sendtarget):
494 self.log = open_rpg.get_component("log")
495 self.log.log("Enter chat_panel", ORPG_DEBUG)
496 wx.Panel.__init__(self, parent, id) 487 wx.Panel.__init__(self, parent, id)
497 self.session = open_rpg.get_component('session') 488 self.session = component.get('session')
498 self.settings = open_rpg.get_component('settings') 489 self.settings = component.get('settings')
499 self.activeplugins = open_rpg.get_component('plugins') 490 self.activeplugins = component.get('plugins')
500 self.parent = parent 491 self.parent = parent
501 # who receives outbound messages, either "all" or "playerid" string 492 # who receives outbound messages, either "all" or "playerid" string
502 self.sendtarget = sendtarget 493 self.sendtarget = sendtarget
503 self.type = tab_type 494 self.type = tab_type
504 self.sound_player = open_rpg.get_component('sound') 495 self.sound_player = component.get('sound')
505 # create die roller manager 496 # create die roller manager
506 self.DiceManager = open_rpg.get_component('DiceManager') 497 self.DiceManager = component.get('DiceManager')
507 # create rpghex tool 498 # create rpghex tool
508 self.r_h = orpg.tools.rgbhex.RGBHex() 499 self.r_h = orpg.tools.rgbhex.RGBHex()
509 self.h = 0 500 self.h = 0
510 self.set_colors() 501 self.set_colors()
511 self.version = VERSION 502 self.version = VERSION
526 self.lastSend = 0 # this is used to help implement the player typing indicator 517 self.lastSend = 0 # this is used to help implement the player typing indicator
527 self.lastPress = 0 # this is used to help implement the player typing indicator 518 self.lastPress = 0 # this is used to help implement the player typing indicator
528 self.Bind(wx.EVT_SIZE, self.OnSize) 519 self.Bind(wx.EVT_SIZE, self.OnSize)
529 self.build_ctrls() 520 self.build_ctrls()
530 #openrpg dir 521 #openrpg dir
531 self.root_dir = orpg.dirpath.dir_struct["home"] 522 self.root_dir = dir_struct["home"]
532 # html font/fontsize is global to all the notebook tabs. 523 # html font/fontsize is global to all the notebook tabs.
533 StartupFont = self.settings.get_setting("defaultfont") 524 StartupFont = self.settings.get_setting("defaultfont")
534 StartupFontSize = self.settings.get_setting("defaultfontsize") 525 StartupFontSize = self.settings.get_setting("defaultfontsize")
535 if(StartupFont != "") and (StartupFontSize != ""): 526 if(StartupFont != "") and (StartupFontSize != ""):
536 try: self.set_default_font(StartupFont, int(StartupFontSize)) 527 try: self.set_default_font(StartupFont, int(StartupFontSize))
537 except: pass 528 except: pass
538 self.font = self.chatwnd.GetFont().GetFaceName() 529 self.font = self.chatwnd.GetFont().GetFaceName()
539 self.fontsize = self.chatwnd.GetFont().GetPointSize() 530 self.fontsize = self.chatwnd.GetFont().GetPointSize()
540 self.scroll_down() 531 self.scroll_down()
541 self.log.log("Exit chat_panel", ORPG_DEBUG) 532
542 533 @debugging
543 def set_default_font(self, fontname=None, fontsize=None): 534 def set_default_font(self, fontname=None, fontsize=None):
544 """Set all chatpanels to new default fontname/fontsize. Returns current font settings in a (fontname, fontsize) tuple.""" 535 """Set all chatpanels to new default fontname/fontsize. Returns current font settings in a (fontname, fontsize) tuple."""
545 self.log.log("Enter chat_panel->set_default_font(self, fontname=None, fontsize=None)", ORPG_DEBUG)
546 if (fontname is not None): newfont = fontname 536 if (fontname is not None): newfont = fontname
547 else: newfont = self.font 537 else: newfont = self.font
548 if (fontsize is not None): newfontsize = int(fontsize) 538 if (fontsize is not None): newfontsize = int(fontsize)
549 else: newfontsize = int(self.fontsize) 539 else: newfontsize = int(self.fontsize)
550 self.chatwnd.SetDefaultFontAndSize(newfont, newfontsize) 540 self.chatwnd.SetDefaultFontAndSize(newfont, newfontsize)
551 self.InfoPost("Font is now " + newfont + " point size " + `newfontsize`) 541 self.InfoPost("Font is now " + newfont + " point size " + `newfontsize`)
552 self.font = newfont 542 self.font = newfont
553 self.fontsize = newfontsize 543 self.fontsize = newfontsize
554 self.log.log("Exit chat_panel->set_default_font(self, fontname=None, fontsize=None)", ORPG_DEBUG)
555 return (self.font, self.fontsize) 544 return (self.font, self.fontsize)
556 545
546 @debugging
557 def build_menu(self): 547 def build_menu(self):
558 self.log.log("Enter chat_panel->build_menu(self)", ORPG_DEBUG) 548 top_frame = component.get('frame')
559 top_frame = open_rpg.get_component('frame')
560 menu = wx.Menu() 549 menu = wx.Menu()
561 item = wx.MenuItem(menu, wx.ID_ANY, "&Background color", "Background color") 550 item = wx.MenuItem(menu, wx.ID_ANY, "&Background color", "Background color")
562 top_frame.Bind(wx.EVT_MENU, self.OnMB_BackgroundColor, item) 551 top_frame.Bind(wx.EVT_MENU, self.OnMB_BackgroundColor, item)
563 menu.AppendItem(item) 552 menu.AppendItem(item)
564 item = wx.MenuItem(menu, wx.ID_ANY, "&Text color", "Text color") 553 item = wx.MenuItem(menu, wx.ID_ANY, "&Text color", "Text color")
590 wndmenu = wx.Menu() 579 wndmenu = wx.Menu()
591 tabmenu = wx.Menu() 580 tabmenu = wx.Menu()
592 toolmenu = wx.Menu() 581 toolmenu = wx.Menu()
593 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Show Images", "Show Images", wx.ITEM_CHECK) 582 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Show Images", "Show Images", wx.ITEM_CHECK)
594 top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowImages, item) 583 top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowImages, item)
584
595 wndmenu.AppendItem(item) 585 wndmenu.AppendItem(item)
596 if self.settings.get_setting("Show_Images_In_Chat") == '1': item.Check(True) 586 if self.settings.get_setting("Show_Images_In_Chat") == '1': item.Check(True)
597 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Strip HTML", "Strip HTML", wx.ITEM_CHECK) 587 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Strip HTML", "Strip HTML", wx.ITEM_CHECK)
598 top_frame.Bind(wx.EVT_MENU, self.OnMB_StripHTML, item) 588 top_frame.Bind(wx.EVT_MENU, self.OnMB_StripHTML, item)
599 wndmenu.AppendItem(item) 589 wndmenu.AppendItem(item)
641 toolmenu.AppendItem(item) 631 toolmenu.AppendItem(item)
642 if self.settings.get_setting("AliasTool_On") == '1': item.Check(True) 632 if self.settings.get_setting("AliasTool_On") == '1': item.Check(True)
643 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tool Bars', toolmenu) 633 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tool Bars', toolmenu)
644 menu.AppendMenu(wx.ID_ANY, 'Chat Settings', settingmenu) 634 menu.AppendMenu(wx.ID_ANY, 'Chat Settings', settingmenu)
645 top_frame.mainmenu.Insert(2, menu, '&Chat') 635 top_frame.mainmenu.Insert(2, menu, '&Chat')
646 self.log.log("Exit chat_panel->build_menu(self)", ORPG_DEBUG)
647 636
648 ## Settings Menu Events 637 ## Settings Menu Events
638 @debugging
649 def OnMB_ShowImages(self, event): 639 def OnMB_ShowImages(self, event):
650 self.log.log("Enter chat_panel->OnMB_ShowImages(self, event)", ORPG_DEBUG)
651 if event.IsChecked(): self.settings.set_setting("Show_Images_In_Chat", '1') 640 if event.IsChecked(): self.settings.set_setting("Show_Images_In_Chat", '1')
652 else: self.settings.set_setting("Show_Images_In_Chat", '0') 641 else: self.settings.set_setting("Show_Images_In_Chat", '0')
653 self.log.log("Exit chat_panel->OnMB_ShowImages(self, event)", ORPG_DEBUG) 642
654 643 @debugging
655 def OnMB_StripHTML(self, event): 644 def OnMB_StripHTML(self, event):
656 self.log.log("Enter chat_panel->OnMB_StripHTML(self, event)", ORPG_DEBUG)
657 if event.IsChecked(): self.settings.set_setting("Sstriphtml", '1') 645 if event.IsChecked(): self.settings.set_setting("Sstriphtml", '1')
658 else: self.settings.set_setting("striphtml", '0') 646 else: self.settings.set_setting("striphtml", '0')
659 self.log.log("Exit chat_panel->OnMB_StripHTML(self, event)", ORPG_DEBUG) 647
660 648 @debugging
661 def OnMB_ChatTimeIndex(self, event): 649 def OnMB_ChatTimeIndex(self, event):
662 self.log.log("Enter chat_panel->OnMB_ChatTimeIndex(self, event)", ORPG_DEBUG)
663 if event.IsChecked(): self.settings.set_setting("Chat_Time_Indexing", '1') 650 if event.IsChecked(): self.settings.set_setting("Chat_Time_Indexing", '1')
664 else: self.settings.set_setting("Chat_Time_Indexing", '0') 651 else: self.settings.set_setting("Chat_Time_Indexing", '0')
665 self.log.log("Exit chat_panel->OnMB_ChatTimeIndex(self, event)", ORPG_DEBUG) 652
666 653 @debugging
667 def OnMB_ChatAutoComplete(self, event): 654 def OnMB_ChatAutoComplete(self, event):
668 self.log.log("Enter chat_panel->OnMB_ChatAutoComplete(self, event)", ORPG_DEBUG)
669 if event.IsChecked(): self.settings.set_setting("SuppressChatAutoComplete", '0') 655 if event.IsChecked(): self.settings.set_setting("SuppressChatAutoComplete", '0')
670 else: self.settings.set_setting("SuppressChatAutoComplete", '1') 656 else: self.settings.set_setting("SuppressChatAutoComplete", '1')
671 self.log.log("Exit chat_panel->OnMB_ChatAutoComplete(self, event)", ORPG_DEBUG) 657
672 658 @debugging
673 def OnMB_ShowIDinChat(self, event): 659 def OnMB_ShowIDinChat(self, event):
674 self.log.log("Enter chat_panel->OnMB_ShowIDinChat(self, event)", ORPG_DEBUG)
675 if event.IsChecked(): self.settings.set_setting("ShowIDInChat", '1') 660 if event.IsChecked(): self.settings.set_setting("ShowIDInChat", '1')
676 else: self.settings.set_setting("ShowIDInChat", '0') 661 else: self.settings.set_setting("ShowIDInChat", '0')
677 self.log.log("Exit chat_panel->OnMB_ShowIDinChat(self, event)", ORPG_DEBUG) 662
678 663 @debugging
679 def OnMB_LogTimeIndex(self, event): 664 def OnMB_LogTimeIndex(self, event):
680 self.log.log("Enter chat_panel->OnMB_LogTimeIndex(self, event)", ORPG_DEBUG)
681 if event.IsChecked(): self.settings.set_setting("TimeStampGameLog", '1') 665 if event.IsChecked(): self.settings.set_setting("TimeStampGameLog", '1')
682 else: self.settings.set_setting("TimeStampGameLog", '0') 666 else: self.settings.set_setting("TimeStampGameLog", '0')
683 self.log.log("Exit chat_panel->OnMB_LogTimeIndex(self, event)", ORPG_DEBUG) 667
684 668 @debugging
685 def OnMB_TabbedWhispers(self, event): 669 def OnMB_TabbedWhispers(self, event):
686 self.log.log("Enter chat_panel->OnMB_TabbedWhispers(self, event)", ORPG_DEBUG)
687 if event.IsChecked(): self.settings.set_setting("tabbedwhispers", '1') 670 if event.IsChecked(): self.settings.set_setting("tabbedwhispers", '1')
688 else: self.settings.set_setting("tabbedwhispers", '0') 671 else: self.settings.set_setting("tabbedwhispers", '0')
689 self.log.log("Exit chat_panel->OnMB_TabbedWhispers(self, event)", ORPG_DEBUG) 672
690 673 @debugging
691 def OnMB_GMTab(self, event): 674 def OnMB_GMTab(self, event):
692 self.log.log("Enter chat_panel->OnMB_GMTab(self, event)", ORPG_DEBUG)
693 if event.IsChecked(): 675 if event.IsChecked():
694 self.settings.set_setting("GMWhisperTab", '1') 676 self.settings.set_setting("GMWhisperTab", '1')
695 self.parent.create_gm_tab() 677 self.parent.create_gm_tab()
696 else: self.settings.set_setting("GMWhisperTab", '0') 678 else: self.settings.set_setting("GMWhisperTab", '0')
697 self.log.log("Exit chat_panel->OnMB_GMTab(self, event)", ORPG_DEBUG) 679
698 680 @debugging
699 def OnMB_GroupWhisperTabs(self, event): 681 def OnMB_GroupWhisperTabs(self, event):
700 self.log.log("Enter chat_panel->OnMB_GroupWhisperTabs(self, event)", ORPG_DEBUG)
701 if event.IsChecked(): self.settings.set_setting("GroupWhisperTab", '1') 682 if event.IsChecked(): self.settings.set_setting("GroupWhisperTab", '1')
702 else: self.settings.set_setting("GroupWhisperTab", '0') 683 else: self.settings.set_setting("GroupWhisperTab", '0')
703 self.log.log("Exit chat_panel->OnMB_GroupWhisperTabs(self, event)", ORPG_DEBUG) 684
704 685 @debugging
705
706 def OnMB_DiceBar(self, event): 686 def OnMB_DiceBar(self, event):
707 self.log.log("Enter chat_panel->OnMB_DiceBar(self, event)", ORPG_DEBUG)
708 act = '0' 687 act = '0'
709 if event.IsChecked(): 688 if event.IsChecked():
710 self.settings.set_setting("DiceButtons_On", '1') 689 self.settings.set_setting("DiceButtons_On", '1')
711 act = '1' 690 act = '1'
712 else: self.settings.set_setting("DiceButtons_On", '0') 691 else: self.settings.set_setting("DiceButtons_On", '0')
714 try: self.parent.GMChatPanel.toggle_dice(act) 693 try: self.parent.GMChatPanel.toggle_dice(act)
715 except: pass 694 except: pass
716 for panel in self.parent.whisper_tabs: panel.toggle_dice(act) 695 for panel in self.parent.whisper_tabs: panel.toggle_dice(act)
717 for panel in self.parent.group_tabs: panel.toggle_dice(act) 696 for panel in self.parent.group_tabs: panel.toggle_dice(act)
718 for panel in self.parent.null_tabs: panel.toggle_dice(act) 697 for panel in self.parent.null_tabs: panel.toggle_dice(act)
719 self.log.log("Exit chat_panel->OnMB_DiceBar(self, event)", ORPG_DEBUG) 698
720 699 @debugging
721 def OnMB_FormatButtons(self, event): 700 def OnMB_FormatButtons(self, event):
722 self.log.log("Enter chat_panel->OnMB_FormatButtons(self, event)", ORPG_DEBUG)
723 act = '0' 701 act = '0'
724 if event.IsChecked(): 702 if event.IsChecked():
725 self.settings.set_setting("FormattingButtons_On", '1') 703 self.settings.set_setting("FormattingButtons_On", '1')
726 act = '1' 704 act = '1'
727 else: 705 else:
730 try: self.parent.GMChatPanel.toggle_formating(act) 708 try: self.parent.GMChatPanel.toggle_formating(act)
731 except: pass 709 except: pass
732 for panel in self.parent.whisper_tabs: panel.toggle_formating(act) 710 for panel in self.parent.whisper_tabs: panel.toggle_formating(act)
733 for panel in self.parent.group_tabs: panel.toggle_formating(act) 711 for panel in self.parent.group_tabs: panel.toggle_formating(act)
734 for panel in self.parent.null_tabs: panel.toggle_formating(act) 712 for panel in self.parent.null_tabs: panel.toggle_formating(act)
735 self.log.log("Exit chat_panel->OnMB_FormatButtons(self, event)", ORPG_DEBUG) 713
736 714 @debugging
737 def OnMB_AliasTool(self, event): 715 def OnMB_AliasTool(self, event):
738 self.log.log("Enter chat_panel->OnMB_AliasTool(self, event)", ORPG_DEBUG)
739 act = '0' 716 act = '0'
740 if event.IsChecked(): 717 if event.IsChecked():
741 self.settings.set_setting("AliasTool_On", '1') 718 self.settings.set_setting("AliasTool_On", '1')
742 act = '1' 719 act = '1'
743 else: self.settings.set_setting("AliasTool_On", '0') 720 else: self.settings.set_setting("AliasTool_On", '0')
745 try: self.parent.GMChatPanel.toggle_alias(act) 722 try: self.parent.GMChatPanel.toggle_alias(act)
746 except: pass 723 except: pass
747 for panel in self.parent.whisper_tabs: panel.toggle_alias(act) 724 for panel in self.parent.whisper_tabs: panel.toggle_alias(act)
748 for panel in self.parent.group_tabs: panel.toggle_alias(act) 725 for panel in self.parent.group_tabs: panel.toggle_alias(act)
749 for panel in self.parent.null_tabs:panel.toggle_alias(act) 726 for panel in self.parent.null_tabs:panel.toggle_alias(act)
750 self.log.log("Exit chat_panel->OnMB_AliasTool(self, event)", ORPG_DEBUG) 727
751 728 @debugging
752 def OnMB_BackgroundColor(self, event): 729 def OnMB_BackgroundColor(self, event):
753 self.log.log("Enter chat_panel->OnMB_BackgroundColor(self, event)", ORPG_DEBUG) 730 top_frame = component.get('frame')
754 top_frame = open_rpg.get_component('frame')
755 hexcolor = self.get_color() 731 hexcolor = self.get_color()
756 if hexcolor != None: 732 if hexcolor != None:
757 self.bgcolor = hexcolor 733 self.bgcolor = hexcolor
758 self.settings.set_setting('bgcolor', hexcolor) 734 self.settings.set_setting('bgcolor', hexcolor)
759 self.chatwnd.SetPage(self.ResetPage()) 735 self.chatwnd.SetPage(self.ResetPage())
768 top_frame.tree.Refresh() 744 top_frame.tree.Refresh()
769 top_frame.players.SetBackgroundColour('white') 745 top_frame.players.SetBackgroundColour('white')
770 top_frame.players.SetForegroundColour('black') 746 top_frame.players.SetForegroundColour('black')
771 top_frame.players.Refresh() 747 top_frame.players.Refresh()
772 self.chatwnd.scroll_down() 748 self.chatwnd.scroll_down()
773 self.log.log("Exit chat_panel->OnMB_BackgroundColor(self, event)", ORPG_DEBUG) 749
774 750 @debugging
775 def OnMB_TextColor(self, event): 751 def OnMB_TextColor(self, event):
776 self.log.log("Enter chat_panel->OnMB_TextColor(self, event)", ORPG_DEBUG) 752 top_frame = component.get('frame')
777 top_frame = open_rpg.get_component('frame')
778 hexcolor = self.get_color() 753 hexcolor = self.get_color()
779 if hexcolor != None: 754 if hexcolor != None:
780 self.textcolor = hexcolor 755 self.textcolor = hexcolor
781 self.settings.set_setting('textcolor', hexcolor) 756 self.settings.set_setting('textcolor', hexcolor)
782 self.chatwnd.SetPage(self.ResetPage()) 757 self.chatwnd.SetPage(self.ResetPage())
791 top_frame.tree.Refresh() 766 top_frame.tree.Refresh()
792 top_frame.players.SetBackgroundColour('white') 767 top_frame.players.SetBackgroundColour('white')
793 top_frame.players.SetForegroundColour('black') 768 top_frame.players.SetForegroundColour('black')
794 top_frame.players.Refresh() 769 top_frame.players.Refresh()
795 self.chatwnd.scroll_down() 770 self.chatwnd.scroll_down()
796 self.log.log("Exit chat_panel->OnMB_TextColor(self, event)", ORPG_DEBUG) 771
797 772 @debugging
798
799 def get_hot_keys(self): 773 def get_hot_keys(self):
800 self.log.log("Enter chat_panel->get_hot_keys(self)", ORPG_DEBUG)
801 # dummy menus for hotkeys 774 # dummy menus for hotkeys
802 self.build_menu() 775 self.build_menu()
803 entries = [] 776 entries = []
804 entries.append((wx.ACCEL_CTRL, ord('H'), self.setChatFocusMenu.GetId())) 777 entries.append((wx.ACCEL_CTRL, ord('H'), self.setChatFocusMenu.GetId()))
805 #entries.append((wx.ACCEL_CTRL, wx.WXK_TAB, SWAP_TABS)) 778 #entries.append((wx.ACCEL_CTRL, wx.WXK_TAB, SWAP_TABS))
806 self.log.log("Enter chat_panel->get_hot_keys(self)", ORPG_DEBUG)
807 return entries 779 return entries
808 780
781 @debugging
809 def forward_tabs(self, evt): 782 def forward_tabs(self, evt):
810 self.log.log("Enter chat_panel->swap_tabs(self, evt)", ORPG_DEBUG)
811 self.parent.AdvanceSelection() 783 self.parent.AdvanceSelection()
812 self.log.log("Exit chat_panel->swap_tabs(self, evt)", ORPG_DEBUG)
813 784
814 def back_tabs(self, evt): 785 def back_tabs(self, evt):
815 self.log.log("Enter chat_panel->swap_tabs(self, evt)", ORPG_DEBUG)
816 self.parent.AdvanceSelection(False) 786 self.parent.AdvanceSelection(False)
817 self.log.log("Exit chat_panel->swap_tabs(self, evt)", ORPG_DEBUG)
818 787
819 # This subroutine builds the controls for the chat frame 788 # This subroutine builds the controls for the chat frame
820 # 789 #
821 # !self : instance of self 790 # !self : instance of self
791 @debugging
822 def build_ctrls(self): 792 def build_ctrls(self):
823 self.log.log("Enter chat_panel->build_ctrls(self)", ORPG_DEBUG)
824 self.chatwnd = chat_html_window(self,-1) 793 self.chatwnd = chat_html_window(self,-1)
825 self.set_colors() 794 self.set_colors()
826 wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header()) 795 wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header())
827 if (self.sendtarget == "all"): 796 if (self.sendtarget == "all"):
828 wx.CallAfter(self.Post, self.colorize(self.syscolor, "<b>Welcome to <a href='http://www.openrpg.com'>OpenRPG</a> version " + self.version + "... </b>")) 797 wx.CallAfter(self.Post, self.colorize(self.syscolor,
798 "<b>Welcome to <a href='http://www.openrpg.com'>OpenRPG</a> version " + self.version + "... </b>"))
829 #self.chat_cmds.on_help() 799 #self.chat_cmds.on_help()
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 ) 800 self.chattxt = orpg.tools.predTextCtrl.predTextCtrl(self, -1, "",
801 style=wx.TE_PROCESS_ENTER |wx.TE_PROCESS_TAB|wx.TE_LINEWRAP,
802 keyHook = self.myKeyHook, validator=None )
831 self.build_bar() 803 self.build_bar()
832 self.basesizer = wx.BoxSizer(wx.VERTICAL) 804 self.basesizer = wx.BoxSizer(wx.VERTICAL)
833 self.basesizer.Add( self.chatwnd, 1, wx.EXPAND ) 805 self.basesizer.Add( self.chatwnd, 1, wx.EXPAND )
834 self.basesizer.Add( self.toolbar_sizer, 0, wx.EXPAND ) 806 self.basesizer.Add( self.toolbar_sizer, 0, wx.EXPAND )
835 self.basesizer.Add( self.chattxt, 0, wx.EXPAND ) 807 self.basesizer.Add( self.chattxt, 0, wx.EXPAND )
860 self.Bind(wx.EVT_BUTTON, self.pop_textpop, self.textpop_lock) 832 self.Bind(wx.EVT_BUTTON, self.pop_textpop, self.textpop_lock)
861 self.Bind(wx.EVT_BUTTON, self.lock_scroll, self.scroll_lock) 833 self.Bind(wx.EVT_BUTTON, self.lock_scroll, self.scroll_lock)
862 self.chattxt.Bind(wx.EVT_MOUSEWHEEL, self.chatwnd.mouse_wheel) 834 self.chattxt.Bind(wx.EVT_MOUSEWHEEL, self.chatwnd.mouse_wheel)
863 self.chattxt.Bind(wx.EVT_CHAR, self.chattxt.OnChar) 835 self.chattxt.Bind(wx.EVT_CHAR, self.chattxt.OnChar)
864 self.chattxt.Bind(wx.EVT_TEXT_COPY, self.textCopy) 836 self.chattxt.Bind(wx.EVT_TEXT_COPY, self.textCopy)
865 self.log.log("Exit chat_panel->build_ctrls(self)", ORPG_DEBUG)
866 # def build_ctrls - end 837 # def build_ctrls - end
867 838
839 @debugging
868 def textCopy(self, event): 840 def textCopy(self, event):
869 if self.chattxt.GetStringSelection() == '': self.chatwnd.OnM_EditCopy(None) 841 if self.chattxt.GetStringSelection() == '': self.chatwnd.OnM_EditCopy(None)
870 else: self.chatwnd.Copy() 842 else: self.chatwnd.Copy()
871 843
844 @debugging
872 def build_bar(self): 845 def build_bar(self):
873 self.log.log("Enter chat_panel->build_bar(self)", ORPG_DEBUG)
874 self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL) 846 self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL)
875 self.scroll_lock = None 847 self.scroll_lock = None
876 self.numDieText = None 848 self.numDieText = None
877 self.dieModText = None 849 self.dieModText = None
878 if self.settings.get_setting('Toolbar_On') == "1": 850 if self.settings.get_setting('Toolbar_On') == "1":
882 self.build_text() 854 self.build_text()
883 self.toolbar_sizer.Add( self.textpop_lock, 0, wx.EXPAND ) 855 self.toolbar_sizer.Add( self.textpop_lock, 0, wx.EXPAND )
884 self.toolbar_sizer.Add(self.scroll_lock,0,wx.EXPAND) 856 self.toolbar_sizer.Add(self.scroll_lock,0,wx.EXPAND)
885 self.build_formating() 857 self.build_formating()
886 self.build_colorbutton() 858 self.build_colorbutton()
887 self.log.log("Exit chat_panel->build_bar(self)", ORPG_DEBUG) 859
888 860 @debugging
889 def build_scroll(self): 861 def build_scroll(self):
890 self.log.log("Enter chat_panel->build_scroll(self)", ORPG_DEBUG)
891 self.scroll_lock = wx.Button( self, wx.ID_ANY, "Scroll ON",size= wx.Size(80,25)) 862 self.scroll_lock = wx.Button( self, wx.ID_ANY, "Scroll ON",size= wx.Size(80,25))
892 self.log.log("Exit chat_panel->build_scroll(self)", ORPG_DEBUG) 863
893 864 @debugging
894 def build_alias(self): 865 def build_alias(self):
895 self.log.log("Enter chat_panel->build_alias(self)", ORPG_DEBUG)
896 self.aliasList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultAliasName]) 866 self.aliasList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultAliasName])
897 self.aliasButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"] + 'player.gif', 'Refresh list of aliases from Game Tree', wx.ID_ANY, '#bdbdbd' ) 867 self.aliasButton = createMaskedButton( self, dir_struct["icon"] + 'player.gif',
868 'Refresh list of aliases from Game Tree', wx.ID_ANY, '#bdbdbd' )
898 self.aliasList.SetSelection(0) 869 self.aliasList.SetSelection(0)
899 self.filterList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultFilterName]) 870 self.filterList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultFilterName])
900 self.filterButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"] + 'add_filter.gif', 'Refresh list of filters from Game Tree', wx.ID_ANY, '#bdbdbd' ) 871 self.filterButton = createMaskedButton( self, dir_struct["icon"] + 'add_filter.gif',
872 'Refresh list of filters from Game Tree', wx.ID_ANY, '#bdbdbd' )
901 self.filterList.SetSelection(0) 873 self.filterList.SetSelection(0)
902 self.toolbar_sizer.Add( self.aliasButton, 0, wx.EXPAND ) 874 self.toolbar_sizer.Add( self.aliasButton, 0, wx.EXPAND )
903 self.toolbar_sizer.Add( self.aliasList,0,wx.EXPAND) 875 self.toolbar_sizer.Add( self.aliasList,0,wx.EXPAND)
904 self.toolbar_sizer.Add( self.filterButton, 0, wx.EXPAND ) 876 self.toolbar_sizer.Add( self.filterButton, 0, wx.EXPAND )
905 self.toolbar_sizer.Add( self.filterList,0,wx.EXPAND) 877 self.toolbar_sizer.Add( self.filterList,0,wx.EXPAND)
906 if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0') 878 if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0')
907 else: self.toggle_alias('1') 879 else: self.toggle_alias('1')
908 self.log.log("Exit chat_panel->build_alias(self)", ORPG_DEBUG) 880
909 881 @debugging
910 def toggle_alias(self, act): 882 def toggle_alias(self, act):
911 self.log.log("Enter chat_panel->toggle_alias(self, " + str(act) + ")", ORPG_DEBUG)
912 if act == '0': 883 if act == '0':
913 self.toolbar_sizer.Show(self.aliasList, False) 884 self.toolbar_sizer.Show(self.aliasList, False)
914 self.toolbar_sizer.Show(self.filterList, False) 885 self.toolbar_sizer.Show(self.filterList, False)
915 self.toolbar_sizer.Show(self.aliasButton, False) 886 self.toolbar_sizer.Show(self.aliasButton, False)
916 self.toolbar_sizer.Show(self.filterButton, False) 887 self.toolbar_sizer.Show(self.filterButton, False)
919 self.toolbar_sizer.Show(self.aliasList, True) 890 self.toolbar_sizer.Show(self.aliasList, True)
920 self.toolbar_sizer.Show(self.filterList, True) 891 self.toolbar_sizer.Show(self.filterList, True)
921 self.toolbar_sizer.Show(self.aliasButton, True) 892 self.toolbar_sizer.Show(self.aliasButton, True)
922 self.toolbar_sizer.Show(self.filterButton, True) 893 self.toolbar_sizer.Show(self.filterButton, True)
923 self.toolbar_sizer.Layout() 894 self.toolbar_sizer.Layout()
924 self.log.log("Exit chat_panel->toggle_alias(self, act)", ORPG_DEBUG) 895
925 896 @debugging
926 def build_text(self): 897 def build_text(self):
927 self.log.log("Enter chat_panel->build_text(self)", ORPG_DEBUG) 898 self.textpop_lock = createMaskedButton(self, dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd')
928 self.textpop_lock = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd') 899
929 self.log.log("Exit chat_panel->build_text(self)", ORPG_DEBUG) 900 @debugging
930
931 def build_dice(self): 901 def build_dice(self):
932 self.log.log("Enter chat_panel->build_dice(self)", ORPG_DEBUG)
933 self.numDieText = wx.TextCtrl( self, wx.ID_ANY, "1", size= wx.Size(25, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) 902 self.numDieText = wx.TextCtrl( self, wx.ID_ANY, "1", size= wx.Size(25, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() )
934 self.dieModText = wx.TextCtrl( self, wx.ID_ANY, "", size= wx.Size(50, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) 903 self.dieModText = wx.TextCtrl( self, wx.ID_ANY, "", size= wx.Size(50, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() )
935 self.d4Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d4.gif', 'Roll d4', wx.ID_ANY) 904 self.d4Button = createMaskedButton(self, dir_struct["icon"]+'b_d4.gif', 'Roll d4', wx.ID_ANY)
936 self.d6Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d6.gif', 'Roll d6', wx.ID_ANY) 905 self.d6Button = createMaskedButton(self, dir_struct["icon"]+'b_d6.gif', 'Roll d6', wx.ID_ANY)
937 self.d8Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d8.gif', 'Roll d8', wx.ID_ANY) 906 self.d8Button = createMaskedButton(self, dir_struct["icon"]+'b_d8.gif', 'Roll d8', wx.ID_ANY)
938 self.d10Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d10.gif', 'Roll d10', wx.ID_ANY) 907 self.d10Button = createMaskedButton(self, dir_struct["icon"]+'b_d10.gif', 'Roll d10', wx.ID_ANY)
939 self.d12Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d12.gif', 'Roll d12', wx.ID_ANY) 908 self.d12Button = createMaskedButton(self, dir_struct["icon"]+'b_d12.gif', 'Roll d12', wx.ID_ANY)
940 self.d20Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d20.gif', 'Roll d20', wx.ID_ANY) 909 self.d20Button = createMaskedButton(self, dir_struct["icon"]+'b_d20.gif', 'Roll d20', wx.ID_ANY)
941 self.d100Button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'b_d100.gif', 'Roll d100', wx.ID_ANY) 910 self.d100Button = createMaskedButton(self, dir_struct["icon"]+'b_d100.gif', 'Roll d100', wx.ID_ANY)
942 self.toolbar_sizer.Add( self.numDieText, 0, wx.ALIGN_CENTER | wx.EXPAND) 911 self.toolbar_sizer.Add( self.numDieText, 0, wx.ALIGN_CENTER | wx.EXPAND)
943 self.toolbar_sizer.Add( self.d4Button, 0 ,wx.EXPAND) 912 self.toolbar_sizer.Add( self.d4Button, 0 ,wx.EXPAND)
944 self.toolbar_sizer.Add( self.d6Button, 0 ,wx.EXPAND) 913 self.toolbar_sizer.Add( self.d6Button, 0 ,wx.EXPAND)
945 self.toolbar_sizer.Add( self.d8Button, 0 ,wx.EXPAND) 914 self.toolbar_sizer.Add( self.d8Button, 0 ,wx.EXPAND)
946 self.toolbar_sizer.Add( self.d10Button, 0 ,wx.EXPAND) 915 self.toolbar_sizer.Add( self.d10Button, 0 ,wx.EXPAND)
948 self.toolbar_sizer.Add( self.d20Button, 0 ,wx.EXPAND) 917 self.toolbar_sizer.Add( self.d20Button, 0 ,wx.EXPAND)
949 self.toolbar_sizer.Add( self.d100Button, 0 ,wx.EXPAND) 918 self.toolbar_sizer.Add( self.d100Button, 0 ,wx.EXPAND)
950 self.toolbar_sizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 ) 919 self.toolbar_sizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 )
951 if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0') 920 if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0')
952 else: self.toggle_dice('1') 921 else: self.toggle_dice('1')
953 self.log.log("Exit chat_panel->build_dice(self)", ORPG_DEBUG) 922
954 923 @debugging
955 def toggle_dice(self, act): 924 def toggle_dice(self, act):
956 self.log.log("Enter chat_panel->toggle_dice(self, "+ str(act) + ")", ORPG_DEBUG)
957 if act == '0': 925 if act == '0':
958 self.toolbar_sizer.Show(self.numDieText, False) 926 self.toolbar_sizer.Show(self.numDieText, False)
959 self.toolbar_sizer.Show(self.d4Button, False) 927 self.toolbar_sizer.Show(self.d4Button, False)
960 self.toolbar_sizer.Show(self.d6Button, False) 928 self.toolbar_sizer.Show(self.d6Button, False)
961 self.toolbar_sizer.Show(self.d8Button, False) 929 self.toolbar_sizer.Show(self.d8Button, False)
974 self.toolbar_sizer.Show(self.d12Button, True) 942 self.toolbar_sizer.Show(self.d12Button, True)
975 self.toolbar_sizer.Show(self.d20Button, True) 943 self.toolbar_sizer.Show(self.d20Button, True)
976 self.toolbar_sizer.Show(self.d100Button, True) 944 self.toolbar_sizer.Show(self.d100Button, True)
977 self.toolbar_sizer.Show(self.dieModText, True) 945 self.toolbar_sizer.Show(self.dieModText, True)
978 self.toolbar_sizer.Layout() 946 self.toolbar_sizer.Layout()
979 self.log.log("Exit chat_panel->toggle_dice(self, "+ str(act) + ")", ORPG_DEBUG) 947
980 948 @debugging
981 def build_formating(self): 949 def build_formating(self):
982 self.log.log("Enter chat_panel->build_formating(self)", ORPG_DEBUG) 950 self.boldButton = createMaskedButton( self, dir_struct["icon"]+'bold.gif',
983 self.boldButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'bold.gif', 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd') 951 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd')
984 self.italicButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'italic.gif', 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' ) 952 self.italicButton = createMaskedButton( self, dir_struct["icon"]+'italic.gif',
985 self.underlineButton = createMaskedButton( self, orpg.dirpath.dir_struct["icon"]+'underlined.gif', 'Underline the selected text', wx.ID_ANY, '#bdbdbd' ) 953 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' )
954 self.underlineButton = createMaskedButton( self, dir_struct["icon"]+'underlined.gif',
955 'Underline the selected text', wx.ID_ANY, '#bdbdbd' )
986 self.toolbar_sizer.Add( self.boldButton, 0, wx.EXPAND ) 956 self.toolbar_sizer.Add( self.boldButton, 0, wx.EXPAND )
987 self.toolbar_sizer.Add( self.italicButton, 0, wx.EXPAND ) 957 self.toolbar_sizer.Add( self.italicButton, 0, wx.EXPAND )
988 self.toolbar_sizer.Add( self.underlineButton, 0, wx.EXPAND ) 958 self.toolbar_sizer.Add( self.underlineButton, 0, wx.EXPAND )
989 if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0') 959 if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0')
990 else: self.toggle_formating('1') 960 else: self.toggle_formating('1')
991 self.log.log("Exit chat_panel->build_formating(self)", ORPG_DEBUG) 961
992 962 @debugging
993 def toggle_formating(self, act): 963 def toggle_formating(self, act):
994 self.log.log("Enter chat_panel->toggle_formating(self, " + str(act) + ")", ORPG_DEBUG)
995 if act == '0': 964 if act == '0':
996 self.toolbar_sizer.Show(self.boldButton, False) 965 self.toolbar_sizer.Show(self.boldButton, False)
997 self.toolbar_sizer.Show(self.italicButton, False) 966 self.toolbar_sizer.Show(self.italicButton, False)
998 self.toolbar_sizer.Show(self.underlineButton, False) 967 self.toolbar_sizer.Show(self.underlineButton, False)
999 self.toolbar_sizer.Layout() 968 self.toolbar_sizer.Layout()
1000 else: 969 else:
1001 self.toolbar_sizer.Show(self.boldButton, True) 970 self.toolbar_sizer.Show(self.boldButton, True)
1002 self.toolbar_sizer.Show(self.italicButton, True) 971 self.toolbar_sizer.Show(self.italicButton, True)
1003 self.toolbar_sizer.Show(self.underlineButton, True) 972 self.toolbar_sizer.Show(self.underlineButton, True)
1004 self.toolbar_sizer.Layout() 973 self.toolbar_sizer.Layout()
1005 self.log.log("Exit chat_panel->toggle_formating(self, " + str(act) + ")", ORPG_DEBUG)
1006 974
1007 # Heroman - Ideally, we would use static labels... 975 # Heroman - Ideally, we would use static labels...
976 @debugging
1008 def build_colorbutton(self): 977 def build_colorbutton(self):
1009 self.log.log("Enter chat_panel->build_colorbutton(self)", ORPG_DEBUG) 978 self.color_button = createMaskedButton(self, dir_struct["icon"]+'textcolor.gif',
1010 self.color_button = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'textcolor.gif',
1011 'Text Color', wx.ID_ANY, '#bdbdbd', 979 'Text Color', wx.ID_ANY, '#bdbdbd',
1012 wx.BITMAP_TYPE_GIF) 980 wx.BITMAP_TYPE_GIF)
1013 981
1014 self.saveButton = createMaskedButton(self, orpg.dirpath.dir_struct["icon"]+'save.bmp', 982 self.saveButton = createMaskedButton(self, dir_struct["icon"]+'save.bmp',
1015 'Save the chatbuffer', wx.ID_ANY, 983 'Save the chatbuffer', wx.ID_ANY,
1016 '#c0c0c0', wx.BITMAP_TYPE_BMP ) 984 '#c0c0c0', wx.BITMAP_TYPE_BMP )
1017 self.color_button.SetBackgroundColour(self.settings.get_setting('mytextcolor')) 985 self.color_button.SetBackgroundColour(self.settings.get_setting('mytextcolor'))
1018 self.toolbar_sizer.Add(self.color_button, 0, wx.EXPAND) 986 self.toolbar_sizer.Add(self.color_button, 0, wx.EXPAND)
1019 self.toolbar_sizer.Add(self.saveButton, 0, wx.EXPAND) 987 self.toolbar_sizer.Add(self.saveButton, 0, wx.EXPAND)
1020 self.log.log("Exit chat_panel->build_colorbutton(self)", ORPG_DEBUG) 988
1021 989 @debugging
1022 def OnMotion(self, evt): 990 def OnMotion(self, evt):
1023 self.log.log("Enter chat_panel->OnMotion(self, evt)", ORPG_DEBUG)
1024 contain = self.chatwnd.GetInternalRepresentation() 991 contain = self.chatwnd.GetInternalRepresentation()
1025 if contain: 992 if contain:
1026 sx = sy = 0 993 sx = sy = 0
1027 x = y = 0 994 x = y = 0
1028 (sx,sy) = self.chatwnd.GetViewStart() 995 (sx,sy) = self.chatwnd.GetViewStart()
1034 if lnk: 1001 if lnk:
1035 try: 1002 try:
1036 link = lnk.GetHref() 1003 link = lnk.GetHref()
1037 self.session.set_status_url(link) 1004 self.session.set_status_url(link)
1038 except: pass 1005 except: pass
1039 else: self.log.log("Error, self.chatwnd.GetInternalRepresentation() return None", ORPG_GENERAL) 1006 else: logger.general("Error, self.chatwnd.GetInternalRepresentation() return None")
1040 evt.Skip() 1007 evt.Skip()
1041 self.log.log("Exit chat_panel->OnMotion(self, evt)", ORPG_DEBUG)
1042 1008
1043 # This subroutine is registered with predTextCtrl to be run for every OnChar event 1009 # This subroutine is registered with predTextCtrl to be run for every OnChar event
1044 # It checks if we need to send a typing message 1010 # It checks if we need to send a typing message
1045 1011
1046 # 1012 #
1047 # self: duh 1013 # self: duh
1048 # event: raw KeyEvent from OnChar() 1014 # event: raw KeyEvent from OnChar()
1015 @debugging
1049 def myKeyHook(self, event): 1016 def myKeyHook(self, event):
1050 self.log.log("Enter chat_panel->myKeyHook(self, event)", ORPG_DEBUG)
1051 if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected 1017 if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected
1052 thisPress = time.time() # thisPress is local temp variable 1018 thisPress = time.time() # thisPress is local temp variable
1053 if (thisPress - self.lastSend) > 4: # Check to see if it's been 5 seconds since our last notice 1019 if (thisPress - self.lastSend) > 4: # Check to see if it's been 5 seconds since our last notice
1054 # If we're not already typing, then self.lastSend will be 0 1020 # If we're not already typing, then self.lastSend will be 0
1055 self.sendTyping(1) # send a not typing event here (1 for True) 1021 self.sendTyping(1) # send a not typing event here (1 for True)
1056 self.lastPress = thisPress # either way, record the time of this keystroke for use in 1022 self.lastPress = thisPress # either way, record the time of this keystroke for use in
1057 # self.typingTimerFunc() 1023 # self.typingTimerFunc()
1058 if self.settings.get_setting('SuppressChatAutoComplete') == '1': 1024 if self.settings.get_setting('SuppressChatAutoComplete') == '1':
1059 self.log.log("Exit chat_panel->myKeyHook(self, event) return 1", ORPG_DEBUG) 1025 logger.debug("Exit chat_panel->myKeyHook(self, event) return 1")
1060 return 1 1026 return 1
1061 else: 1027 else:
1062 self.log.log("Exit chat_panel->myKeyHook(self, event) return 0", ORPG_DEBUG) 1028 loger.debug("Exit chat_panel->myKeyHook(self, event) return 0")
1063 return 0 1029 return 0
1064 1030
1065 # This subroutine gets called once a second by the typing Timer 1031 # This subroutine gets called once a second by the typing Timer
1066 # It checks if we need to send a not_typing message 1032 # It checks if we need to send a not_typing message
1067 # 1033 #
1068 # self: duh 1034 # self: duh
1035 @debugging
1069 def typingTimerFunc(self, event): 1036 def typingTimerFunc(self, event):
1070 #following added by mDuo13 1037 #following added by mDuo13
1071 ##############refresh_counter()############## 1038 ##############refresh_counter()##############
1072 for plugin_fname in self.activeplugins.keys(): 1039 for plugin_fname in self.activeplugins.keys():
1073 plugin = self.activeplugins[plugin_fname] 1040 plugin = self.activeplugins[plugin_fname]
1074 try: plugin.refresh_counter() 1041 try: plugin.refresh_counter()
1075 except Exception, e: 1042 except Exception, e:
1076 if str(e) != "'module' object has no attribute 'refresh_counter'": 1043 if str(e) != "'module' object has no attribute 'refresh_counter'":
1077 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1044 logger.general(traceback.format_exc())
1078 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1045 logger.general("EXCEPTION: " + str(e))
1079 #end mDuo13 added code 1046 #end mDuo13 added code
1080 if self.lastSend: # This will be zero when not typing, so equiv to if is_typing 1047 if self.lastSend: # This will be zero when not typing, so equiv to if is_typing
1081 thisTime = time.time() # thisTime is a local temp variable 1048 thisTime = time.time() # thisTime is a local temp variable
1082 if (thisTime - self.lastPress) > 4: # Check to see if it's been 5 seconds since our last keystroke 1049 if (thisTime - self.lastPress) > 4: # Check to see if it's been 5 seconds since our last keystroke
1083 # If we're not already typing, then self.lastSend will be 0 1050 # If we're not already typing, then self.lastSend will be 0
1085 self.sendTyping(0) # send a typing event here (0 for False) 1052 self.sendTyping(0) # send a typing event here (0 for False)
1086 # This subroutine actually takes care of sending the messages for typing/not_typing events 1053 # This subroutine actually takes care of sending the messages for typing/not_typing events
1087 # 1054 #
1088 # self: duh 1055 # self: duh
1089 # typing: boolean 1056 # typing: boolean
1057
1058 @debugging
1090 def sendTyping(self, typing): 1059 def sendTyping(self, typing):
1091 self.log.log("Enter chat_panel->sendTyping(self, typing)", ORPG_DEBUG)
1092 if typing: 1060 if typing:
1093 self.lastSend = time.time() # remember our send time for use in myKeyHook() 1061 self.lastSend = time.time() # remember our send time for use in myKeyHook()
1094 #I think this is cleaner 1062 #I think this is cleaner
1095 status_text = self.settings.get_setting('TypingStatusAlias') 1063 status_text = self.settings.get_setting('TypingStatusAlias')
1096 if status_text == "" or status_text == None: status_text = "Typing" 1064 if status_text == "" or status_text == None: status_text = "Typing"
1099 self.lastSend = 0 # set lastSend to zero to indicate we're not typing 1067 self.lastSend = 0 # set lastSend to zero to indicate we're not typing
1100 #I think this is cleaner 1068 #I think this is cleaner
1101 status_text = self.settings.get_setting('IdleStatusAlias') 1069 status_text = self.settings.get_setting('IdleStatusAlias')
1102 if status_text == "" or status_text == None: status_text = "Idle" 1070 if status_text == "" or status_text == None: status_text = "Idle"
1103 self.session.set_text_status(status_text) 1071 self.session.set_text_status(status_text)
1104 self.log.log("Exit chat_panel->sendTyping(self, typing)", ORPG_DEBUG)
1105 1072
1106 # This subroutine sets the colors of the chat based on the settings in the 1073 # This subroutine sets the colors of the chat based on the settings in the
1107 # self instance. 1074 # self instance.
1108 # 1075 #
1109 # !self : instance of self 1076 # !self : instance of self
1077 @debugging
1110 def set_colors(self): 1078 def set_colors(self):
1111 self.log.log("Enter chat_panel->set_colors(self)", ORPG_DEBUG)
1112 # chat window backround color 1079 # chat window backround color
1113 self.bgcolor = self.settings.get_setting('bgcolor') 1080 self.bgcolor = self.settings.get_setting('bgcolor')
1114 # chat window normal text color 1081 # chat window normal text color
1115 self.textcolor = self.settings.get_setting('textcolor') 1082 self.textcolor = self.settings.get_setting('textcolor')
1116 # color of text player types 1083 # color of text player types
1121 self.infocolor = self.settings.get_setting('infocolor') 1088 self.infocolor = self.settings.get_setting('infocolor')
1122 # color of emotes 1089 # color of emotes
1123 self.emotecolor = self.settings.get_setting('emotecolor') 1090 self.emotecolor = self.settings.get_setting('emotecolor')
1124 # color of whispers 1091 # color of whispers
1125 self.whispercolor = self.settings.get_setting('whispercolor') 1092 self.whispercolor = self.settings.get_setting('whispercolor')
1126 self.log.log("Exit chat_panel->set_colors(self)", ORPG_DEBUG)
1127 # def set_colors - end 1093 # def set_colors - end
1128 1094
1129 # This subroutine will insert text into the chat window 1095 # This subroutine will insert text into the chat window
1130 # 1096 #
1131 # !self : instance of self 1097 # !self : instance of self
1132 # !txt : text to be inserted into the chat window 1098 # !txt : text to be inserted into the chat window
1099 @debugging
1133 def set_chat_text(self, txt): 1100 def set_chat_text(self, txt):
1134 self.log.log("Enter chat_panel->set_chat_text(self, txt)", ORPG_DEBUG)
1135 self.chattxt.SetValue(txt) 1101 self.chattxt.SetValue(txt)
1136 self.chattxt.SetFocus() 1102 self.chattxt.SetFocus()
1137 self.chattxt.SetInsertionPointEnd() 1103 self.chattxt.SetInsertionPointEnd()
1138 self.log.log("Exit chat_panel->set_chat_text(self, txt)", ORPG_DEBUG)
1139 # def set_chat_text - end 1104 # def set_chat_text - end
1140 1105
1106 @debugging
1141 def get_chat_text(self): 1107 def get_chat_text(self):
1142 self.log.log("Enter chat_panel->get_chat_text(self)", ORPG_DEBUG)
1143 self.log.log("Enter chat_panel->get_chat_text(self)", ORPG_DEBUG)
1144 return self.chattxt.GetValue() 1108 return self.chattxt.GetValue()
1145 1109
1146 # This subroutine sets the focus to the chat window 1110 # This subroutine sets the focus to the chat window
1111 @debugging
1147 def set_chat_text_focus(self, event): 1112 def set_chat_text_focus(self, event):
1148 self.log.log("Enter chat_panel->set_chat_text_focus(self, event)", ORPG_DEBUG)
1149 wx.CallAfter(self.chattxt.SetFocus) 1113 wx.CallAfter(self.chattxt.SetFocus)
1150 self.log.log("Exit chat_panel->set_chat_text_focus(self, event)", ORPG_DEBUG)
1151 # def set_chat_text_focus - end 1114 # def set_chat_text_focus - end
1152 1115
1153 # This subrtouine grabs the user input and make the special keys and 1116 # This subrtouine grabs the user input and make the special keys and
1154 # modifiers work. 1117 # modifiers work.
1155 # 1118 #
1156 # !self : instance of self 1119 # !self : instance of self
1157 # !event : 1120 # !event :
1158 # 1121 #
1159 # Note: self.chattxt now handles it's own Key events. It does, however still 1122 # Note: self.chattxt now handles it's own Key events. It does, however still
1160 # call it's parent's (self) OnChar to handle "default" behavior. 1123 # call it's parent's (self) OnChar to handle "default" behavior.
1124 @debugging
1161 def OnChar(self, event): 1125 def OnChar(self, event):
1162 self.log.log("Enter chat_panel->OnChar(self, event)", ORPG_DEBUG)
1163 s = self.chattxt.GetValue() 1126 s = self.chattxt.GetValue()
1164 #self.histlen = len(self.history) - 1 1127 #self.histlen = len(self.history) - 1
1165 1128
1166 ## RETURN KEY (no matter if there is text in chattxt) 1129 ## RETURN KEY (no matter if there is text in chattxt)
1167 # This section is run even if there is nothing in the chattxt (as opposed to the next wx.WXK_RETURN handler 1130 # This section is run even if there is nothing in the chattxt (as opposed to the next wx.WXK_RETURN handler
1168 if event.GetKeyCode() == wx.WXK_RETURN: 1131 if event.GetKeyCode() == wx.WXK_RETURN:
1169 self.log.log("event.GetKeyCode() == wx.WXK_RETURN", ORPG_DEBUG) 1132 logger.debug("event.GetKeyCode() == wx.WXK_RETURN")
1170 self.set_colors() 1133 self.set_colors()
1171 if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected 1134 if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected
1172 self.sendTyping(0) # Send a "not_typing" event on enter key press 1135 self.sendTyping(0) # Send a "not_typing" event on enter key press
1173 macroText="" 1136 macroText=""
1174 1137 recycle_bin = {wx.WXK_F1: 'event.GetKeyCode() == wx.WXK_F1', wx.WXK_F2: 'event.GetKeyCode() == wx.WXK_F2',
1175 1138 wx.WXK_F3: 'event.GetKeyCode() == wx.WXK_F3', wx.WXK_F4: 'event.GetKeyCode() == wx.WXK_F4',
1176 recycle_bin = {wx.WXK_F1: 'event.GetKeyCode() == wx.WXK_F1', wx.WXK_F2: 'event.GetKeyCode() == wx.WXK_F2', wx.WXK_F3: 'event.GetKeyCode() == wx.WXK_F3', wx.WXK_F4: 'event.GetKeyCode() == wx.WXK_F4', wx.WXK_F5: 'event.GetKeyCode() == wx.WXK_F5', wx.WXK_F6: 'event.GetKeyCode() == wx.WXK_F6', wx.WXK_F7: 'event.GetKeyCode() == wx.WXK_F7', wx.WXK_F8: 'event.GetKeyCode() == wx.WXK_F8', wx.WXK_F9: 'event.GetKeyCode() == wx.WXK_F9', wx.WXK_F10: 'event.GetKeyCode() == wx.WXK_F10', wx.WXK_F11: 'event.GetKeyCode() == wx.WXK_F11', wx.WXK_F12: 'event.GetKeyCode() == wx.WXK_F12'} 1139 wx.WXK_F5: 'event.GetKeyCode() == wx.WXK_F5', wx.WXK_F6: 'event.GetKeyCode() == wx.WXK_F6',
1177 # Recycle Bin and Lambda should reduce this whole IF ELIF statement block. 1140 wx.WXK_F7: 'event.GetKeyCode() == wx.WXK_F7', wx.WXK_F8: 'event.GetKeyCode() == wx.WXK_F8',
1141 wx.WXK_F9: 'event.GetKeyCode() == wx.WXK_F9', wx.WXK_F10: 'event.GetKeyCode() == wx.WXK_F10',
1142 wx.WXK_F11: 'event.GetKeyCode() == wx.WXK_F11', wx.WXK_F12: 'event.GetKeyCode() == wx.WXK_F12'}
1143
1178 bin_event = event.GetKeyCode() 1144 bin_event = event.GetKeyCode()
1179 if recycle_bin.has_key(bin_event): 1145 if recycle_bin.has_key(bin_event):
1180 self.log.log(lambda bin_event: recycle_bin[bin_event], ORPG_DEBUG) 1146 logger.debug(lambda bin_event: recycle_bin[bin_event])
1181 macroText = self.settings.get_setting(recycle_bin[bin_event][29:]) 1147 macroText = self.settings.get_setting(recycle_bin[bin_event][29:])
1182 recycle_bin = {}; del bin_event 1148 recycle_bin = {}; del bin_event
1183 1149
1184 # Append to the existing typed text as needed and make sure the status doesn't change back. 1150 # Append to the existing typed text as needed and make sure the status doesn't change back.
1185 if len(macroText): 1151 if len(macroText):
1186 self.sendTyping(0) 1152 self.sendTyping(0)
1187 s = macroText 1153 s = macroText
1188 1154
1189 ## RETURN KEY (and not text in control) 1155 ## RETURN KEY (and not text in control)
1190 if (event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText): 1156 if (event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText):
1191 self.log.log("(event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText)", ORPG_DEBUG) 1157 logger.debug("(event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText)")
1192 self.histidx = -1 1158 self.histidx = -1
1193 self.temptext = "" 1159 self.temptext = ""
1194 self.history = [s] + self.history#prepended instead of appended now, so higher index = greater age 1160 self.history = [s] + self.history#prepended instead of appended now, so higher index = greater age
1195 if not len(macroText): self.chattxt.SetValue("") 1161 if not len(macroText): self.chattxt.SetValue("")
1196 # play sound 1162 # play sound
1200 s = self.ParsePost( s, True, True ) 1166 s = self.ParsePost( s, True, True )
1201 else: self.chat_cmds.docmd(s) # emote is in chatutils.py 1167 else: self.chat_cmds.docmd(s) # emote is in chatutils.py
1202 1168
1203 ## UP KEY 1169 ## UP KEY
1204 elif event.GetKeyCode() == wx.WXK_UP: 1170 elif event.GetKeyCode() == wx.WXK_UP:
1205 self.log.log("event.GetKeyCode() == wx.WXK_UP", ORPG_DEBUG) 1171 logger.debug("event.GetKeyCode() == wx.WXK_UP")
1206 if self.histidx < len(self.history)-1: 1172 if self.histidx < len(self.history)-1:
1207 #text that's not in history but also hasn't been sent to chat gets stored in self.temptext 1173 #text that's not in history but also hasn't been sent to chat gets stored in self.temptext
1208 #this way if someone presses the up key, they don't lose their current message permanently 1174 #this way if someone presses the up key, they don't lose their current message permanently
1209 #(unless they also press enter at the time) 1175 #(unless they also press enter at the time)
1210 if self.histidx is -1: self.temptext = self.chattxt.GetValue() 1176 if self.histidx is -1: self.temptext = self.chattxt.GetValue()
1216 #self.InfoPost("**Going up? I don't think so.**") 1182 #self.InfoPost("**Going up? I don't think so.**")
1217 #print self.histidx, "in",self.history 1183 #print self.histidx, "in",self.history
1218 1184
1219 ## DOWN KEY 1185 ## DOWN KEY
1220 elif event.GetKeyCode() == wx.WXK_DOWN: 1186 elif event.GetKeyCode() == wx.WXK_DOWN:
1221 self.log.log("event.GetKeyCode() == wx.WXK_DOWN", ORPG_DEBUG) 1187 logger.debug("event.GetKeyCode() == wx.WXK_DOWN")
1222 #histidx of -1 indicates currently viewing text that's not in self.history 1188 #histidx of -1 indicates currently viewing text that's not in self.history
1223 if self.histidx > -1: 1189 if self.histidx > -1:
1224 self.histidx -= 1 1190 self.histidx -= 1
1225 if self.histidx is -1: #remember, it just decreased 1191 if self.histidx is -1: #remember, it just decreased
1226 self.chattxt.SetValue(self.temptext) 1192 self.chattxt.SetValue(self.temptext)
1230 #self.InfoPost("**Going down? I don't think so.**") 1196 #self.InfoPost("**Going down? I don't think so.**")
1231 #print self.histidx, "in",self.history 1197 #print self.histidx, "in",self.history
1232 1198
1233 ## TAB KEY 1199 ## TAB KEY
1234 elif event.GetKeyCode() == wx.WXK_TAB: 1200 elif event.GetKeyCode() == wx.WXK_TAB:
1235 self.log.log("event.GetKeyCode() == wx.WXK_TAB", ORPG_DEBUG) 1201 logger.debug("event.GetKeyCode() == wx.WXK_TAB")
1236 if s !="": 1202 if s !="":
1237 found = 0 1203 found = 0
1238 nicks = [] 1204 nicks = []
1239 testnick = "" 1205 testnick = ""
1240 inlength = len(s) 1206 inlength = len(s)
1269 else: ## not online, and no text in chattxt box 1235 else: ## not online, and no text in chattxt box
1270 self.Post(self.colorize(self.syscolor, " ** That's the Tab key, Dave")) 1236 self.Post(self.colorize(self.syscolor, " ** That's the Tab key, Dave"))
1271 1237
1272 ## PAGE UP 1238 ## PAGE UP
1273 elif event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP): 1239 elif event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP):
1274 self.log.log("event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP)", ORPG_DEBUG) 1240 logger.debug("event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP)")
1275 self.chatwnd.ScrollPages(-1) 1241 self.chatwnd.ScrollPages(-1)
1276 if not self.lockscroll: self.lock_scroll(0) 1242 if not self.lockscroll: self.lock_scroll(0)
1277 1243
1278 ## PAGE DOWN 1244 ## PAGE DOWN
1279 elif event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN): 1245 elif event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN):
1280 self.log.log("event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN)", ORPG_DEBUG) 1246 logger.debug("event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN)")
1281 if not self.lockscroll: self.lock_scroll(0) 1247 if not self.lockscroll: self.lock_scroll(0)
1282 if ((self.chatwnd.GetScrollRange(1)-self.chatwnd.GetScrollPos(1)-self.chatwnd.GetScrollThumb(1) < 30) and self.lockscroll): 1248 if ((self.chatwnd.GetScrollRange(1)-self.chatwnd.GetScrollPos(1)-self.chatwnd.GetScrollThumb(1) < 30) and self.lockscroll):
1283 self.lock_scroll(0) 1249 self.lock_scroll(0)
1284 self.chatwnd.ScrollPages(1) 1250 self.chatwnd.ScrollPages(1)
1285 1251
1286 ## END 1252 ## END
1287 elif event.GetKeyCode() == wx.WXK_END: 1253 elif event.GetKeyCode() == wx.WXK_END:
1288 self.log.log("event.GetKeyCode() == wx.WXK_END", ORPG_DEBUG) 1254 logger.debug("event.GetKeyCode() == wx.WXK_END", ORPG_DEBUG)
1289 if self.lockscroll: 1255 if self.lockscroll:
1290 self.lock_scroll(0) 1256 self.lock_scroll(0)
1291 self.Post() 1257 self.Post()
1292 event.Skip() 1258 event.Skip()
1293 1259
1294 ## NOTHING 1260 ## NOTHING
1295 else: event.Skip() 1261 else: event.Skip()
1296 self.log.log("Exit chat_panel->OnChar(self, event)", ORPG_DEBUG) 1262 logger.debug("Exit chat_panel->OnChar(self, event)", ORPG_DEBUG)
1297 # def OnChar - end 1263 # def OnChar - end
1298 1264
1265 @debugging
1299 def onDieRoll(self, evt): 1266 def onDieRoll(self, evt):
1300 """Roll the dice based on the button pressed and the die modifiers entered, if any.""" 1267 """Roll the dice based on the button pressed and the die modifiers entered, if any."""
1301 self.log.log("Enter chat_panel->onDieRoll(self, evt)", ORPG_DEBUG)
1302 # Get any die modifiers if they have been entered 1268 # Get any die modifiers if they have been entered
1303 numDie = self.numDieText.GetValue() 1269 numDie = self.numDieText.GetValue()
1304 dieMod = self.dieModText.GetValue() 1270 dieMod = self.dieModText.GetValue()
1305 dieText = numDie 1271 dieText = numDie
1306 # Now, apply and roll die mods based on the button that was pressed 1272 # Now, apply and roll die mods based on the button that was pressed
1309 if len(dieMod) and dieMod[0] not in "*/-+": dieMod = "+" + dieMod 1275 if len(dieMod) and dieMod[0] not in "*/-+": dieMod = "+" + dieMod
1310 dieText += dieMod 1276 dieText += dieMod
1311 dieText = "[" + dieText + "]" 1277 dieText = "[" + dieText + "]"
1312 self.ParsePost(dieText, 1, 1) 1278 self.ParsePost(dieText, 1, 1)
1313 self.chattxt.SetFocus() 1279 self.chattxt.SetFocus()
1314 self.log.log("Exit chat_panel->onDieRoll(self, evt)", ORPG_DEBUG)
1315 1280
1316 # This subroutine saves a chat buffer as html to a file chosen via a 1281 # This subroutine saves a chat buffer as html to a file chosen via a
1317 # FileDialog. 1282 # FileDialog.
1318 # 1283 #
1319 # !self : instance of self 1284 # !self : instance of self
1320 # !evt : 1285 # !evt :
1286 @debugging
1321 def on_chat_save(self, evt): 1287 def on_chat_save(self, evt):
1322 self.log.log("Enter chat_panel->on_chat_save(self, evt)", ORPG_DEBUG)
1323 f = wx.FileDialog(self,"Save Chat Buffer",".","","HTM* (*.htm*)|*.htm*|HTML (*.html)|*.html|HTM (*.htm)|*.htm",wx.SAVE) 1288 f = wx.FileDialog(self,"Save Chat Buffer",".","","HTM* (*.htm*)|*.htm*|HTML (*.html)|*.html|HTM (*.htm)|*.htm",wx.SAVE)
1324 if f.ShowModal() == wx.ID_OK: 1289 if f.ShowModal() == wx.ID_OK:
1325 file = open(f.GetPath(), "w") 1290 file = open(f.GetPath(), "w")
1326 file.write(self.ResetPage() + "</body></html>") 1291 file.write(self.ResetPage() + "</body></html>")
1327 file.close() 1292 file.close()
1328 f.Destroy() 1293 f.Destroy()
1329 os.chdir(self.root_dir) 1294 os.chdir(self.root_dir)
1330 self.log.log("Exit chat_panel->on_chat_save(self, evt)", ORPG_DEBUG)
1331 # def on_chat_save - end 1295 # def on_chat_save - end
1332 1296
1297 @debugging
1333 def ResetPage(self): 1298 def ResetPage(self):
1334 self.set_colors() 1299 self.set_colors()
1335 buffertext = self.chatwnd.Header() + "\n" 1300 buffertext = self.chatwnd.Header() + "\n"
1336 buffertext += chat_util.strip_body_tags(self.chatwnd.StripHeader()).replace("<br>", "<br />").replace('</html>', '').replace("<br />", "<br />\n").replace("\n\n", '') 1301 buffertext += chat_util.strip_body_tags(self.chatwnd.StripHeader()).replace("<br>",
1302 "<br />").replace('</html>',
1303 '').replace("<br />",
1304 "<br />\n").replace("\n\n", '')
1337 return buffertext 1305 return buffertext
1338 1306
1339 # This subroutine sets the color of selected text, or base text color if 1307 # This subroutine sets the color of selected text, or base text color if
1340 # nothing is selected 1308 # nothing is selected
1309 @debugging
1341 def on_text_color(self, event): 1310 def on_text_color(self, event):
1342 self.log.log("Enter chat_panel->on_text_color(self, event)", ORPG_DEBUG)
1343 hexcolor = self.r_h.do_hex_color_dlg(self) 1311 hexcolor = self.r_h.do_hex_color_dlg(self)
1344 if hexcolor != None: 1312 if hexcolor != None:
1345 (beg,end) = self.chattxt.GetSelection() 1313 (beg,end) = self.chattxt.GetSelection()
1346 if beg != end: 1314 if beg != end:
1347 txt = self.chattxt.GetValue() 1315 txt = self.chattxt.GetValue()
1353 self.color_button.SetBackgroundColour(hexcolor) 1321 self.color_button.SetBackgroundColour(hexcolor)
1354 self.mytextcolor = hexcolor 1322 self.mytextcolor = hexcolor
1355 self.settings.set_setting('mytextcolor',hexcolor) 1323 self.settings.set_setting('mytextcolor',hexcolor)
1356 self.set_colors() 1324 self.set_colors()
1357 self.Post() 1325 self.Post()
1358 self.log.log("Exit chat_panel->on_text_color(self, event)", ORPG_DEBUG)
1359 # def on_text_color - end 1326 # def on_text_color - end
1360 1327
1361 # This subroutine take a color and a text string and formats it into html. 1328 # This subroutine take a color and a text string and formats it into html.
1362 # 1329 #
1363 # !self : instance of self 1330 # !self : instance of self
1364 # !color : color for the text to be set 1331 # !color : color for the text to be set
1365 # !text : text string to be included in the html. 1332 # !text : text string to be included in the html.
1333 @debugging
1366 def colorize(self, color, text): 1334 def colorize(self, color, text):
1367 """Puts font tags of 'color' around 'text' value, and returns the string""" 1335 """Puts font tags of 'color' around 'text' value, and returns the string"""
1368 self.log.log("Enter chat_panel->colorize(self, color, text)", ORPG_DEBUG)
1369 self.log.log("Exit chat_panel->colorize(self, color, text)", ORPG_DEBUG)
1370 return "<font color='" + color + "'>" + text + "</font>" 1336 return "<font color='" + color + "'>" + text + "</font>"
1371 # def colorize - end 1337 # def colorize - end
1372 1338
1373 # This subroutine takes and event and inserts text with the basic format 1339 # This subroutine takes and event and inserts text with the basic format
1374 # tags included. 1340 # tags included.
1375 # 1341 #
1376 # !self : instance of self 1342 # !self : instance of self
1377 # !event : 1343 # !event :
1344 @debugging
1378 def on_text_format(self, event): 1345 def on_text_format(self, event):
1379 self.log.log("Enter chat_panel->on_text_format(self, event)", ORPG_DEBUG)
1380 id = event.GetId() 1346 id = event.GetId()
1381 txt = self.chattxt.GetValue() 1347 txt = self.chattxt.GetValue()
1382 (beg,end) = self.chattxt.GetSelection() 1348 (beg,end) = self.chattxt.GetSelection()
1383 if beg != end: sel_txt = txt[beg:end] 1349 if beg != end: sel_txt = txt[beg:end]
1384 else: sel_txt = txt 1350 else: sel_txt = txt
1388 if beg != end: txt = txt[:beg] + sel_txt + txt[end:] 1354 if beg != end: txt = txt[:beg] + sel_txt + txt[end:]
1389 else: txt = sel_txt 1355 else: txt = sel_txt
1390 self.chattxt.SetValue(txt) 1356 self.chattxt.SetValue(txt)
1391 self.chattxt.SetInsertionPointEnd() 1357 self.chattxt.SetInsertionPointEnd()
1392 self.chattxt.SetFocus() 1358 self.chattxt.SetFocus()
1393 self.log.log("Exit chat_panel->on_text_format(self, event)", ORPG_DEBUG)
1394 # def on_text_format - end 1359 # def on_text_format - end
1395 1360
1361 @debugging
1396 def lock_scroll(self, event): 1362 def lock_scroll(self, event):
1397 self.log.log("Enter chat_panel->lock_scroll(self, event)", ORPG_DEBUG)
1398 if self.lockscroll: 1363 if self.lockscroll:
1399 self.lockscroll = False 1364 self.lockscroll = False
1400 self.scroll_lock.SetLabel("Scroll ON") 1365 self.scroll_lock.SetLabel("Scroll ON")
1401 if len(self.storedata) != 0: 1366 if len(self.storedata) != 0:
1402 for line in self.storedata: self.chatwnd.AppendToPage(line) 1367 for line in self.storedata: self.chatwnd.AppendToPage(line)
1403 self.storedata = [] 1368 self.storedata = []
1404 self.scroll_down() 1369 self.scroll_down()
1405 else: 1370 else:
1406 self.lockscroll = True 1371 self.lockscroll = True
1407 self.scroll_lock.SetLabel("Scroll OFF") 1372 self.scroll_lock.SetLabel("Scroll OFF")
1408 self.log.log("Exit chat_panel->lock_scroll(self, event)", ORPG_DEBUG)
1409 1373
1410 # This subroutine will popup a text window with the chatbuffer contents 1374 # This subroutine will popup a text window with the chatbuffer contents
1411 # 1375 #
1412 # !self : instance of self 1376 # !self : instance of self
1413 # !event : 1377 # !event :
1378 @debugging
1414 def pop_textpop(self, event): 1379 def pop_textpop(self, event):
1415 """searchable popup text view of chatbuffer""" 1380 """searchable popup text view of chatbuffer"""
1416 self.log.log("Enter chat_panel->pop_textpop(self, event)", ORPG_DEBUG)
1417 h_buffertext = self.ResetPage() 1381 h_buffertext = self.ResetPage()
1418 h_dlg = orpgScrolledMessageFrameEditor(self, h_buffertext, "Text View of Chat Window", None, (500,300)) 1382 h_dlg = orpgScrolledMessageFrameEditor(self, h_buffertext, "Text View of Chat Window", None, (500,300))
1419 h_dlg.Show(True) 1383 h_dlg.Show(True)
1420 self.log.log("Exit chat_panel->pop_textpop(self, event)", ORPG_DEBUG)
1421 1384
1422 # This subroutine will change the dimension of the window 1385 # This subroutine will change the dimension of the window
1423 # 1386 #
1424 # !self : instance of self 1387 # !self : instance of self
1425 # !event : 1388 # !event :
1389 @debugging
1426 def OnSize(self, event=None): 1390 def OnSize(self, event=None):
1427 self.log.log("Enter chat_panel->OnSize(self, event=None)", ORPG_DEBUG)
1428 event.Skip() 1391 event.Skip()
1429 wx.CallAfter(self.scroll_down) 1392 wx.CallAfter(self.scroll_down)
1430 self.log.log("Exit chat_panel->OnSize(self, event=None)", ORPG_DEBUG)
1431 # def OnSize - end 1393 # def OnSize - end
1432 1394
1395 @debugging
1433 def scroll_down(self): 1396 def scroll_down(self):
1434 self.Freeze() 1397 self.Freeze()
1435 self.chatwnd.scroll_down() 1398 self.chatwnd.scroll_down()
1436 self.Thaw() 1399 self.Thaw()
1437 1400
1438 ###### message helpers ###### 1401 ###### message helpers ######
1402 @debugging
1439 def PurgeChat(self): 1403 def PurgeChat(self):
1440 self.set_colors() 1404 self.set_colors()
1441 self.chatwnd.SetPage(self.chatwnd.Header()) 1405 self.chatwnd.SetPage(self.chatwnd.Header())
1442 1406
1407 @debugging
1443 def system_message(self, text): 1408 def system_message(self, text):
1444 self.log.log("Enter chat_panel->system_message(self, text)", ORPG_DEBUG)
1445 self.send_chat_message(text,chat_msg.SYSTEM_MESSAGE) 1409 self.send_chat_message(text,chat_msg.SYSTEM_MESSAGE)
1446 self.SystemPost(text) 1410 self.SystemPost(text)
1447 self.log.log("Exit chat_panel->system_message(self, text)", ORPG_DEBUG) 1411
1448 1412 @debugging
1449 def info_message(self, text): 1413 def info_message(self, text):
1450 self.log.log("Enter chat_panel->info_message(self, text)", ORPG_DEBUG)
1451 self.send_chat_message(text,chat_msg.INFO_MESSAGE) 1414 self.send_chat_message(text,chat_msg.INFO_MESSAGE)
1452 self.InfoPost(text) 1415 self.InfoPost(text)
1453 self.log.log("Exit chat_panel->info_message(self, text)", ORPG_DEBUG) 1416
1454 1417 @debugging
1455 def get_gms(self): 1418 def get_gms(self):
1456 self.log.log("Enter chat_panel->get_gms(self)", ORPG_DEBUG)
1457 the_gms = [] 1419 the_gms = []
1458 for playerid in self.session.players: 1420 for playerid in self.session.players:
1459 if len(self.session.players[playerid])>7: 1421 if len(self.session.players[playerid])>7:
1460 if self.session.players[playerid][7]=="GM" and self.session.group_id != '0': the_gms += [playerid] 1422 if self.session.players[playerid][7]=="GM" and self.session.group_id != '0': the_gms += [playerid]
1461 self.log.log("Exit chat_panel->get_gms(self)", ORPG_DEBUG)
1462 return the_gms 1423 return the_gms
1463 1424
1425 @debugging
1464 def GetName(self): 1426 def GetName(self):
1465 self.log.log("Enter chat_panel->GetName(self)", ORPG_DEBUG) 1427 self.AliasLib = component.get('alias')
1466 self.AliasLib = open_rpg.get_component('alias')
1467 player = self.session.get_my_info() 1428 player = self.session.get_my_info()
1468 if self.AliasLib != None: 1429 if self.AliasLib != None:
1469 self.AliasLib.alias = self.aliasList.GetStringSelection(); 1430 self.AliasLib.alias = self.aliasList.GetStringSelection();
1470 if self.AliasLib.alias[0] != self.defaultAliasName: 1431 if self.AliasLib.alias[0] != self.defaultAliasName:
1471 self.log.log("Exit chat_panel->GetName(self)", ORPG_DEBUG) 1432 logger.debug("Exit chat_panel->GetName(self)")
1472 return [self.chat_display_name([self.AliasLib.alias[0], player[1], player[2]]), self.AliasLib.alias[1]] 1433 return [self.chat_display_name([self.AliasLib.alias[0], player[1], player[2]]), self.AliasLib.alias[1]]
1473 self.log.log("Exit chat_panel->GetName(self)", ORPG_DEBUG)
1474 return [self.chat_display_name(player), "Default"] 1434 return [self.chat_display_name(player), "Default"]
1475 1435
1436 @debugging
1476 def GetFilteredText(self, text): 1437 def GetFilteredText(self, text):
1477 self.log.log("Enter chat_panel->GetFilteredText(self, text)", ORPG_DEBUG)
1478 advregex = re.compile('\"(.*?)\"', re.I) 1438 advregex = re.compile('\"(.*?)\"', re.I)
1479 self.AliasLib = open_rpg.get_component('alias') 1439 self.AliasLib = component.get('alias')
1480 if self.AliasLib != None: 1440 if self.AliasLib != None:
1481 self.AliasLib.filter = self.filterList.GetSelection()-1; 1441 self.AliasLib.filter = self.filterList.GetSelection()-1;
1482 for rule in self.AliasLib.filterRegEx: 1442 for rule in self.AliasLib.filterRegEx:
1483 if not self.advancedFilter: text = re.sub(rule[0], rule[1], text) 1443 if not self.advancedFilter: text = re.sub(rule[0], rule[1], text)
1484 else: 1444 else:
1485 for m in advregex.finditer(text): 1445 for m in advregex.finditer(text):
1486 match = m.group(0) 1446 match = m.group(0)
1487 newmatch = re.sub(rule[0], rule[1], match) 1447 newmatch = re.sub(rule[0], rule[1], match)
1488 text = text.replace(match, newmatch) 1448 text = text.replace(match, newmatch)
1489 self.log.log("Exit chat_panel->GetFilteredText(self, text)", ORPG_DEBUG)
1490 return text 1449 return text
1491 1450
1451 @debugging
1492 def emote_message(self, text): 1452 def emote_message(self, text):
1493 self.log.log("Enter chat_panel->emote_message(self, text)", ORPG_DEBUG)
1494 text = self.NormalizeParse(text) 1453 text = self.NormalizeParse(text)
1495 text = self.colorize(self.emotecolor, text) 1454 text = self.colorize(self.emotecolor, text)
1496 1455
1497 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(text,chat_msg.EMOTE_MESSAGE) 1456 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(text,chat_msg.EMOTE_MESSAGE)
1498 elif self.type == MAIN_TAB and self.sendtarget == "gm": 1457 elif self.type == MAIN_TAB and self.sendtarget == "gm":
1505 elif self.type == WHISPER_TAB: self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(self.sendtarget)) 1464 elif self.type == WHISPER_TAB: self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(self.sendtarget))
1506 elif self.type == NULL_TAB: pass 1465 elif self.type == NULL_TAB: pass
1507 name = self.GetName()[0] 1466 name = self.GetName()[0]
1508 text = "** " + name + " " + text + " **" 1467 text = "** " + name + " " + text + " **"
1509 self.EmotePost(text) 1468 self.EmotePost(text)
1510 self.log.log("Exit chat_panel->emote_message(self, text)", ORPG_DEBUG) 1469
1511 1470 @debugging
1512 def whisper_to_players(self, text, player_ids): 1471 def whisper_to_players(self, text, player_ids):
1513 self.log.log("Enter chat_panel->whisper_to_players(self, text, player_ids)", ORPG_DEBUG)
1514 tabbed_whispers_p = self.settings.get_setting("tabbedwhispers") 1472 tabbed_whispers_p = self.settings.get_setting("tabbedwhispers")
1515 # Heroman - apply any filtering selected 1473 # Heroman - apply any filtering selected
1516 text = self.NormalizeParse(text) 1474 text = self.NormalizeParse(text)
1517 player_names = "" 1475 player_names = ""
1518 # post to our chat before we colorize 1476 # post to our chat before we colorize
1533 text = self.colorize(self.mytextcolor, text) 1491 text = self.colorize(self.mytextcolor, text)
1534 for id in player_ids: 1492 for id in player_ids:
1535 id = id.strip() 1493 id = id.strip()
1536 if self.session.is_valid_id(id): self.send_chat_message(text,chat_msg.WHISPER_MESSAGE,id) 1494 if self.session.is_valid_id(id): self.send_chat_message(text,chat_msg.WHISPER_MESSAGE,id)
1537 else: self.InfoPost(id + " Unknown!") 1495 else: self.InfoPost(id + " Unknown!")
1538 self.log.log("Exit chat_panel->whisper_to_players(self, text, player_ids)", ORPG_DEBUG) 1496
1539 1497 @debugging
1540 def send_chat_message(self, text, type=chat_msg.CHAT_MESSAGE, player_id="all"): 1498 def send_chat_message(self, text, type=chat_msg.CHAT_MESSAGE, player_id="all"):
1541 self.log.log("Enter chat_panel->send_chat_message(self, text, type, player_id)", ORPG_DEBUG)
1542 #########send_msg()############# 1499 #########send_msg()#############
1543 send = 1 1500 send = 1
1544 for plugin_fname in self.activeplugins.keys(): 1501 for plugin_fname in self.activeplugins.keys():
1545 plugin = self.activeplugins[plugin_fname] 1502 plugin = self.activeplugins[plugin_fname]
1546 try: text, send = plugin.send_msg(text, send) 1503 try: text, send = plugin.send_msg(text, send)
1547 except Exception, e: 1504 except Exception, e:
1548 if str(e) != "'module' object has no attribute 'send_msg'": 1505 if str(e) != "'module' object has no attribute 'send_msg'":
1549 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1506 logger.general(traceback.format_exc())
1550 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1507 logger.general("EXCEPTION: " + str(e))
1551 msg = chat_msg.chat_msg() 1508 msg = chat_msg.chat_msg()
1552 msg.set_text(text) 1509 msg.set_text(text)
1553 msg.set_type(type) 1510 msg.set_type(type)
1554 turnedoff = False 1511 turnedoff = False
1555 if self.settings.get_setting("ShowIDInChat") == "1": 1512 if self.settings.get_setting("ShowIDInChat") == "1":
1559 1516
1560 if turnedoff: self.settings.set_setting("ShowIDInChat", "1") 1517 if turnedoff: self.settings.set_setting("ShowIDInChat", "1")
1561 msg.set_alias(playername) 1518 msg.set_alias(playername)
1562 if send: self.session.send(msg.toxml(),player_id) 1519 if send: self.session.send(msg.toxml(),player_id)
1563 del msg 1520 del msg
1564 self.log.log("Exit chat_panel->send_chat_message(self, text, type, player_id)", ORPG_DEBUG)
1565 1521
1566 #### incoming chat message handler ##### 1522 #### incoming chat message handler #####
1523 @debugging
1567 def post_incoming_msg(self, msg, player): 1524 def post_incoming_msg(self, msg, player):
1568 self.log.log("Enter chat_panel->post_incoming_msg(self, msg, player)", ORPG_DEBUG)
1569 1525
1570 # pull data 1526 # pull data
1571 type = msg.get_type() 1527 type = msg.get_type()
1572 text = msg.get_text() 1528 text = msg.get_text()
1573 alias = msg.get_alias() 1529 alias = msg.get_alias()
1580 for plugin_fname in self.activeplugins.keys(): 1536 for plugin_fname in self.activeplugins.keys():
1581 plugin = self.activeplugins[plugin_fname] 1537 plugin = self.activeplugins[plugin_fname]
1582 try: text, type, name = plugin.plugin_incoming_msg(text, type, display_name, player) 1538 try: text, type, name = plugin.plugin_incoming_msg(text, type, display_name, player)
1583 except Exception, e: 1539 except Exception, e:
1584 if str(e) != "'module' object has no attribute 'receive_msg'": 1540 if str(e) != "'module' object has no attribute 'receive_msg'":
1585 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1541 logger.general(traceback.format_exc())
1586 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1542 logger.general("EXCEPTION: " + str(e))
1587 #end mDuo13 added code 1543 #end mDuo13 added code
1588 #image stripping for players' names 1544 #image stripping for players' names
1589 strip_img = self.settings.get_setting("Show_Images_In_Chat") 1545 strip_img = self.settings.get_setting("Show_Images_In_Chat")
1590 if (strip_img == "0"): display_name = chat_util.strip_img_tags(display_name) 1546 if (strip_img == "0"): display_name = chat_util.strip_img_tags(display_name)
1591 #end image stripping. --mDuo13, July 11th, 2005 1547 #end image stripping. --mDuo13, July 11th, 2005
1666 msg = name + whisperingstring + text 1622 msg = name + whisperingstring + text
1667 if type == chat_msg.WHISPER_MESSAGE: self.parent.MainChatPanel.Post(msg) 1623 if type == chat_msg.WHISPER_MESSAGE: self.parent.MainChatPanel.Post(msg)
1668 else: self.parent.MainChatPanel.EmotePost("**" + msg + "**") 1624 else: self.parent.MainChatPanel.EmotePost("**" + msg + "**")
1669 self.parent.newMsg(0) 1625 self.parent.newMsg(0)
1670 except Exception, e: 1626 except Exception, e:
1671 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1627 logger.general(traceback.format_exc())
1672 self.log.log("EXCEPTION: 'Error in posting whisper message': " + str(e), ORPG_GENERAL) 1628 logger.general("EXCEPTION: 'Error in posting whisper message': " + str(e))
1673 elif (type == chat_msg.EMOTE_MESSAGE): 1629 elif (type == chat_msg.EMOTE_MESSAGE):
1674 text = "** " + display_name + " " + text + " **" 1630 text = "** " + display_name + " " + text + " **"
1675 self.EmotePost(text) 1631 self.EmotePost(text)
1676 self.parent.newMsg(0) 1632 self.parent.newMsg(0)
1677 elif (type == chat_msg.INFO_MESSAGE): 1633 elif (type == chat_msg.INFO_MESSAGE):
1684 self.parent.newMsg(0) 1640 self.parent.newMsg(0)
1685 # playe sound 1641 # playe sound
1686 sound_file = self.settings.get_setting(recvSound) 1642 sound_file = self.settings.get_setting(recvSound)
1687 if sound_file != '': 1643 if sound_file != '':
1688 self.sound_player.play(sound_file) 1644 self.sound_player.play(sound_file)
1689 self.log.log("Exit chat_panel->post_incoming_msg(self, msg, player)", ORPG_DEBUG)
1690 #### Posting helpers ##### 1645 #### Posting helpers #####
1691 1646
1647 @debugging
1692 def InfoPost(self, s): 1648 def InfoPost(self, s):
1693 self.log.log("Enter chat_panel->InfoPost(self, s)", ORPG_DEBUG)
1694 self.Post(self.colorize(self.infocolor, s), c='info') 1649 self.Post(self.colorize(self.infocolor, s), c='info')
1695 self.log.log("Exit chat_panel->InfoPost(self, s)", ORPG_DEBUG) 1650
1696 1651 @debugging
1697 def SystemPost(self, s): 1652 def SystemPost(self, s):
1698 self.log.log("Enter chat_panel->SystemPost(self, s)", ORPG_DEBUG)
1699 self.Post(self.colorize(self.syscolor, s), c='system') 1653 self.Post(self.colorize(self.syscolor, s), c='system')
1700 self.log.log("Exit chat_panel->SystemPost(self, s)", ORPG_DEBUG) 1654
1701 1655 @debugging
1702 def EmotePost(self, s): 1656 def EmotePost(self, s):
1703 self.log.log("Enter chat_panel->EmotePost(self, s)", ORPG_DEBUG)
1704 self.Post(self.colorize(self.emotecolor, s), c='emote') 1657 self.Post(self.colorize(self.emotecolor, s), c='emote')
1705 self.log.log("Exit chat_panel->EmotePost(self, s)", ORPG_DEBUG)
1706 1658
1707 #### Standard Post method ##### 1659 #### Standard Post method #####
1660 @debugging
1708 def Post(self, s="", send=False, myself=False, c='post'): 1661 def Post(self, s="", send=False, myself=False, c='post'):
1709 self.log.log("Enter chat_panel->Post(self, s, send, myself)", ORPG_DEBUG)
1710 strip_p = self.settings.get_setting("striphtml") 1662 strip_p = self.settings.get_setting("striphtml")
1711 strip_img = self.settings.get_setting("Show_Images_In_Chat")#moved back 7-11-05. --mDuo13 1663 strip_img = self.settings.get_setting("Show_Images_In_Chat")#moved back 7-11-05. --mDuo13
1712 if (strip_p == "1"): s = strip_html(s) 1664 if (strip_p == "1"): s = strip_html(s)
1713 if (strip_img == "0"): s = chat_util.strip_img_tags(s) 1665 if (strip_img == "0"): s = chat_util.strip_img_tags(s)
1714 s = chat_util.simple_html_repair(s) 1666 s = chat_util.simple_html_repair(s)
1729 for plugin_fname in self.activeplugins.keys(): 1681 for plugin_fname in self.activeplugins.keys():
1730 plugin = self.activeplugins[plugin_fname] 1682 plugin = self.activeplugins[plugin_fname]
1731 try: s = plugin.post_msg(s, myself) 1683 try: s = plugin.post_msg(s, myself)
1732 except Exception, e: 1684 except Exception, e:
1733 if str(e) != "'module' object has no attribute 'post_msg'": 1685 if str(e) != "'module' object has no attribute 'post_msg'":
1734 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1686 logger.general(traceback.format_exc())
1735 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1687 logger.general("EXCEPTION: " + str(e))
1736 #end mDuo13 added code 1688 #end mDuo13 added code
1737 if myself: 1689 if myself:
1738 name = "<b>" + display_name + "</b>: " 1690 name = "<b>" + display_name + "</b>: "
1739 s = self.colorize(self.mytextcolor, s) 1691 s = self.colorize(self.mytextcolor, s)
1740 else: name = "" 1692 else: name = ""
1760 plugin = self.activeplugins[plugin_fname] 1712 plugin = self.activeplugins[plugin_fname]
1761 try: 1713 try:
1762 s2 = plugin.post_msg(s2, myself) 1714 s2 = plugin.post_msg(s2, myself)
1763 except Exception, e: 1715 except Exception, e:
1764 if str(e) != "'module' object has no attribute 'post_msg'": 1716 if str(e) != "'module' object has no attribute 'post_msg'":
1765 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1717 logger.general(traceback.format_exc())
1766 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1718 logger.general("EXCEPTION: " + str(e))
1767 if s2 != "": 1719 if s2 != "":
1768 #Italici the messages from tabbed whispers 1720 #Italici the messages from tabbed whispers
1769 if self.type == WHISPER_TAB or self.type == GROUP_TAB or self.sendtarget == 'gm': 1721 if self.type == WHISPER_TAB or self.type == GROUP_TAB or self.sendtarget == 'gm':
1770 s2 = s2 + '</i>' 1722 s2 = s2 + '</i>'
1771 name = '<i>' + name 1723 name = '<i>' + name
1794 self.whisper_to_players(self.settings.get_setting("gwtext") + s, members) 1746 self.whisper_to_players(self.settings.get_setting("gwtext") + s, members)
1795 elif self.type == WHISPER_TAB: self.whisper_to_players(s, [self.sendtarget]) 1747 elif self.type == WHISPER_TAB: self.whisper_to_players(s, [self.sendtarget])
1796 elif self.type == NULL_TAB: pass 1748 elif self.type == NULL_TAB: pass
1797 else: self.InfoPost("Failed to send message, unknown send type for this tab") 1749 else: self.InfoPost("Failed to send message, unknown send type for this tab")
1798 self.parsed=0 1750 self.parsed=0
1799 self.log.log("Exit chat_panel->Post(self, s, send, myself)", ORPG_DEBUG)
1800 1751
1801 # 1752 #
1802 # TimeIndexString() 1753 # TimeIndexString()
1803 # 1754 #
1804 # time indexing for chat display only (don't log time indexing) 1755 # time indexing for chat display only (don't log time indexing)
1805 # added by Snowdog 4/04 1756 # added by Snowdog 4/04
1757 @debugging
1806 def TimeIndexString(self): 1758 def TimeIndexString(self):
1807 self.log.log("Enter chat_panel->TimeIndexString(self)", ORPG_DEBUG)
1808 try: 1759 try:
1809 mtime = "" 1760 mtime = ""
1810 if self.settings.get_setting('Chat_Time_Indexing') == "0": pass 1761 if self.settings.get_setting('Chat_Time_Indexing') == "0": pass
1811 elif self.settings.get_setting('Chat_Time_Indexing') == "1": 1762 elif self.settings.get_setting('Chat_Time_Indexing') == "1":
1812 mtime = time.strftime("[%I:%M:%S] ", time.localtime()) 1763 mtime = time.strftime("[%I:%M:%S] ", time.localtime())
1813 self.log.log("Exit chat_panel->TimeIndexString(self)", ORPG_DEBUG)
1814 return mtime 1764 return mtime
1815 except Exception, e: 1765 except Exception, e:
1816 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1766 logger.general(traceback.format_exc())
1817 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1767 logger.general("EXCEPTION: " + str(e))
1818 return "[ERROR]" 1768 return "[ERROR]"
1819 1769
1820 #### Post with parsing dice #### 1770 #### Post with parsing dice ####
1771 @debugging
1821 def ParsePost(self, s, send=False, myself=False): 1772 def ParsePost(self, s, send=False, myself=False):
1822 self.log.log("Enter chat_panel->ParsePost(self, s, send, myself)", ORPG_DEBUG)
1823 s = self.NormalizeParse(s) 1773 s = self.NormalizeParse(s)
1824 self.set_colors() 1774 self.set_colors()
1825 self.Post(s,send,myself) 1775 self.Post(s,send,myself)
1826 self.log.log("Exit chat_panel->ParsePost(self, s, send, myself)", ORPG_DEBUG) 1776
1827 1777 @debugging
1828 def NormalizeParse(self, s): 1778 def NormalizeParse(self, s):
1829 self.log.log("Enter chat_panel->NormalizeParse(self, s)", ORPG_DEBUG)
1830 for plugin_fname in self.activeplugins.keys(): 1779 for plugin_fname in self.activeplugins.keys():
1831 plugin = self.activeplugins[plugin_fname] 1780 plugin = self.activeplugins[plugin_fname]
1832 try: s = plugin.pre_parse(s) 1781 try: s = plugin.pre_parse(s)
1833 except Exception, e: 1782 except Exception, e:
1834 if str(e) != "'module' object has no attribute 'post_msg'": 1783 if str(e) != "'module' object has no attribute 'post_msg'":
1835 self.log.log(traceback.format_exc(), ORPG_GENERAL) 1784 logger.general(traceback.format_exc())
1836 self.log.log("EXCEPTION: " + str(e), ORPG_GENERAL) 1785 logger.general("EXCEPTION: " + str(e))
1837 if self.parsed == 0: 1786 if self.parsed == 0:
1838 s = self.ParseNode(s) 1787 s = self.ParseNode(s)
1839 s = self.ParseDice(s) 1788 s = self.ParseDice(s)
1840 s = self.ParseFilter(s) 1789 s = self.ParseFilter(s)
1841 self.parsed = 1 1790 self.parsed = 1
1842 self.log.log("Exit chat_panel->NormalizeParse(self, s)", ORPG_DEBUG)
1843 return s 1791 return s
1844 1792
1793 @debugging
1845 def ParseFilter(self, s): 1794 def ParseFilter(self, s):
1846 self.log.log("Enter chat_panel->ParseFilter(self, s)", ORPG_DEBUG)
1847 s = self.GetFilteredText(s) 1795 s = self.GetFilteredText(s)
1848 self.log.log("Exit chat_panel->ParseFilter(self, s)", ORPG_DEBUG)
1849 return s 1796 return s
1850 1797
1798 @debugging
1851 def ParseNode(self, s): 1799 def ParseNode(self, s):
1852 """Parses player input for embedded nodes rolls""" 1800 """Parses player input for embedded nodes rolls"""
1853 self.log.log("Enter chat_panel->ParseNode(self, s)", ORPG_DEBUG)
1854 cur_loc = 0 1801 cur_loc = 0
1855 #[a-zA-Z0-9 _\-\.] 1802 #[a-zA-Z0-9 _\-\.]
1856 reg = re.compile("(!@([a-zA-Z0-9 _\-\./]+(::[a-zA-Z0-9 _\-\./]+)*)@!)") 1803 reg = re.compile("(!@([a-zA-Z0-9 _\-\./]+(::[a-zA-Z0-9 _\-\./]+)*)@!)")
1857 matches = reg.findall(s) 1804 matches = reg.findall(s)
1858 for i in xrange(0,len(matches)): 1805 for i in xrange(0,len(matches)):
1859 newstr = self.ParseNode(self.resolve_nodes(matches[i][1])) 1806 newstr = self.ParseNode(self.resolve_nodes(matches[i][1]))
1860 s = s.replace(matches[i][0], newstr, 1) 1807 s = s.replace(matches[i][0], newstr, 1)
1861 self.log.log("Exit chat_panel->ParseNode(self, s)", ORPG_DEBUG)
1862 return s 1808 return s
1863 1809
1810 @debugging
1864 def ParseDice(self, s): 1811 def ParseDice(self, s):
1865 """Parses player input for embedded dice rolls""" 1812 """Parses player input for embedded dice rolls"""
1866 self.log.log("Enter chat_panel->ParseDice(self, s)", ORPG_DEBUG)
1867 reg = re.compile("\[([^]]*?)\]") 1813 reg = re.compile("\[([^]]*?)\]")
1868 matches = reg.findall(s) 1814 matches = reg.findall(s)
1869 for i in xrange(0,len(matches)): 1815 for i in xrange(0,len(matches)):
1870 newstr = self.PraseUnknowns(matches[i]) 1816 newstr = self.PraseUnknowns(matches[i])
1871 qmode = 0 1817 qmode = 0
1876 try: newstr = self.DiceManager.proccessRoll(newstr) 1822 try: newstr = self.DiceManager.proccessRoll(newstr)
1877 except: pass 1823 except: pass
1878 if qmode == 1: 1824 if qmode == 1:
1879 s = s.replace("[" + matches[i] + "]", "<!-- Official Roll [" + newstr1 + "] => " + newstr + "-->" + newstr, 1) 1825 s = s.replace("[" + matches[i] + "]", "<!-- Official Roll [" + newstr1 + "] => " + newstr + "-->" + newstr, 1)
1880 else: s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "<!-- Official Roll -->] => " + newstr, 1) 1826 else: s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "<!-- Official Roll -->] => " + newstr, 1)
1881 self.log.log("Exit chat_panel->ParseDice(self, s)", ORPG_DEBUG)
1882 return s 1827 return s
1883 1828
1829 @debugging
1884 def PraseUnknowns(self, s): 1830 def PraseUnknowns(self, s):
1885 # Uses a tuple. Usage: ?Label}dY. If no Label is assigned then use ?}DY 1831 # Uses a tuple. Usage: ?Label}dY. If no Label is assigned then use ?}DY
1886 self.log.log("Enter chat_panel->PraseUnknowns(self, s)", ORPG_DEBUG)
1887 newstr = "0" 1832 newstr = "0"
1888 reg = re.compile("(\?\{*)([a-zA-Z ]*)(\}*)") 1833 reg = re.compile("(\?\{*)([a-zA-Z ]*)(\}*)")
1889 matches = reg.findall(s) 1834 matches = reg.findall(s)
1890 for i in xrange(0,len(matches)): 1835 for i in xrange(0,len(matches)):
1891 lb = "Replace '?' with: " 1836 lb = "Replace '?' with: "
1897 dlg.SetTitle("Enter Value for " + matches[i][1]) 1842 dlg.SetTitle("Enter Value for " + matches[i][1])
1898 if dlg.ShowModal() == wx.ID_OK: newstr = dlg.GetValue() 1843 if dlg.ShowModal() == wx.ID_OK: newstr = dlg.GetValue()
1899 if newstr == '': newstr = '0' 1844 if newstr == '': newstr = '0'
1900 s = s.replace(matches[i][0], newstr, 1).replace(matches[i][1], '', 1).replace(matches[i][2], '', 1) 1845 s = s.replace(matches[i][0], newstr, 1).replace(matches[i][1], '', 1).replace(matches[i][2], '', 1)
1901 dlg.Destroy() 1846 dlg.Destroy()
1902 self.log.log("Exit chat_panel->PraseUnknowns(self, s)", ORPG_DEBUG)
1903 return s 1847 return s
1904 1848
1905 # This subroutine builds a chat display name. 1849 # This subroutine builds a chat display name.
1906 # 1850 #
1851 @debugging
1907 def chat_display_name(self, player): 1852 def chat_display_name(self, player):
1908 self.log.log("Enter chat_panel->chat_display_name(self, player)", ORPG_DEBUG)
1909 if self.settings.get_setting("ShowIDInChat") == "0": 1853 if self.settings.get_setting("ShowIDInChat") == "0":
1910 display_name = player[0] 1854 display_name = player[0]
1911 else: 1855 else:
1912 display_name = "("+player[2]+") " + player[0] 1856 display_name = "("+player[2]+") " + player[0]
1913 self.log.log("Exit chat_panel->chat_display_name(self, player)", ORPG_DEBUG)
1914 return display_name 1857 return display_name
1915 1858
1916 # This subroutine will get a hex color and return it, or return nothing 1859 # This subroutine will get a hex color and return it, or return nothing
1917 # 1860 #
1861 @debugging
1918 def get_color(self): 1862 def get_color(self):
1919 self.log.log("Enter chat_panel->get_color(self)", ORPG_DEBUG)
1920 data = wx.ColourData() 1863 data = wx.ColourData()
1921 data.SetChooseFull(True) 1864 data.SetChooseFull(True)
1922 dlg = wx.ColourDialog(self, data) 1865 dlg = wx.ColourDialog(self, data)
1923 if dlg.ShowModal() == wx.ID_OK: 1866 if dlg.ShowModal() == wx.ID_OK:
1924 data = dlg.GetColourData() 1867 data = dlg.GetColourData()
1925 (red,green,blue) = data.GetColour().Get() 1868 (red,green,blue) = data.GetColour().Get()
1926 hexcolor = self.r_h.hexstring(red, green, blue) 1869 hexcolor = self.r_h.hexstring(red, green, blue)
1927 dlg.Destroy() 1870 dlg.Destroy()
1928 self.log.log("Exit chat_panel->get_color(self) return hexcolor", ORPG_DEBUG)
1929 return hexcolor 1871 return hexcolor
1930 else: 1872 else:
1931 dlg.Destroy() 1873 dlg.Destroy()
1932 self.log.log("Exit chat_panel->get_color(self) return None", ORPG_DEBUG)
1933 return None 1874 return None
1934 # def get_color - end 1875 # def get_color - end
1935 1876
1877 @debugging
1936 def replace_quotes(self, s): 1878 def replace_quotes(self, s):
1937 self.log.log("Enter chat_panel->replace_quotes(self, s)", ORPG_DEBUG)
1938 in_tag = 0 1879 in_tag = 0
1939 i = 0 1880 i = 0
1940 rs = s[:] 1881 rs = s[:]
1941 for c in s: 1882 for c in s:
1942 if c == "<": 1883 if c == "<":
1946 in_tag -= 1 1887 in_tag -= 1
1947 elif c == '"': 1888 elif c == '"':
1948 if in_tag: 1889 if in_tag:
1949 rs = rs[:i] + "'" + rs[i+1:] 1890 rs = rs[:i] + "'" + rs[i+1:]
1950 i += 1 1891 i += 1
1951 self.log.log("Exit chat_panel->replace_quotes(self, s)", ORPG_DEBUG)
1952 return rs 1892 return rs
1953 1893
1894 @debugging
1954 def resolve_loop(self, dom, nodeName, doLoop = False): 1895 def resolve_loop(self, dom, nodeName, doLoop = False):
1955 self.log.log("Enter chat_panel->resolve_loop(self, dom, nodeName)", ORPG_DEBUG)
1956 for node in dom: 1896 for node in dom:
1957 if node._get_tagName() != 'nodehandler': 1897 if node._get_tagName() != 'nodehandler':
1958 continue 1898 continue
1959 if doLoop and node.getAttribute('class') != 'textctrl_handler' and node.hasChildNodes(): 1899 if doLoop and node.getAttribute('class') != 'textctrl_handler' and node.hasChildNodes():
1960 (found, node) = self.resolve_loop(node.getChildren(), nodeName, doLoop) 1900 (found, node) = self.resolve_loop(node.getChildren(), nodeName, doLoop)
1961 if not found: 1901 if not found:
1962 continue 1902 continue
1963 if node.getAttribute('name') != nodeName: 1903 if node.getAttribute('name') != nodeName:
1964 continue 1904 continue
1965 foundNode = node 1905 foundNode = node
1966 self.log.log("Exit chat_panel->resolve_loop(self, dom, path) return (True, value)", ORPG_DEBUG)
1967 return (True, foundNode) 1906 return (True, foundNode)
1968 self.log.log("Exit chat_panel->resolve_loop(self, dom, path) return (False, '')", ORPG_DEBUG)
1969 return (False, '') 1907 return (False, '')
1970 1908
1909 @debugging
1971 def resolve_nodes(self, s): 1910 def resolve_nodes(self, s):
1972 self.log.log("Enter chat_panel->resolve_nodes(self, s)", ORPG_DEBUG)
1973 value = "" 1911 value = ""
1974 node_path_list = s.split("::") 1912 node_path_list = s.split("::")
1975 gametree = open_rpg.get_component('tree') 1913 gametree = component.get('tree')
1976 dom = gametree.master_dom.getChildren() 1914 dom = gametree.master_dom.getChildren()
1977 for nodeName in node_path_list: 1915 for nodeName in node_path_list:
1978 (found, node) = self.resolve_loop(dom, nodeName) 1916 (found, node) = self.resolve_loop(dom, nodeName)
1979 if not found: 1917 if not found:
1980 break 1918 break
1994 text = node.getElementsByTagName('text') 1932 text = node.getElementsByTagName('text')
1995 node = text[0]._get_firstChild() 1933 node = text[0]._get_firstChild()
1996 value = node._get_nodeValue() 1934 value = node._get_nodeValue()
1997 else: 1935 else:
1998 value = s 1936 value = s
1999 self.log.log("Exit chat_panel->resolve_nodes(self, s)", ORPG_DEBUG)
2000 return value 1937 return value