annotate orpg/chat/chatwnd.py @ 34:1fb663829ef6 ornery-orc

Traipse 'OpenRPG' {100504-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 (Patch-2) http://traipse.assembla.com/wiki/show/traipse/Patch-2 New Features: New Namespace method with two new syntaxes New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New Namespace FutureCheck helps ensure you don't receive an incorrect node New Namespace 2.0 documentation in the User Manual New Namespace plugin, Allows Traipse users to use the Standard syntax !@ :: @! New Mini Library with minis from Devin Knight New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode New to Update Manager, checks Repo for updates on software start New to Mini Lib node, change title in design mode New to Game Tree, never lose a node, appends a number to the end of corrupted trees New to Server GUI, Traipse Suite's Debug Console New Warhammer PC Sheet Updates: Update to White Board layer, uses a pencil image for color button Update to Grid Layer, uses a grid image for color button Update to Chat Window, size of drop down menus Update to default lobby message Update to template Text node Update to 4e PC Sheet node Update to how display names are acquired Update to Server, added some 'Pious' technology Update to features node Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues Fix to URL2Link plugin, modified regex compilation should remove memory leak Fix to mapy.py, a roll back due to zoomed grid issues Fix to whiteboard_handler, Circles work by you clicking the center of the circle Fix to Servers parse_incoming_dom which was outdated and did not respect XML Fix to a broken link in the server welcome message Fix to InterParse and logger requiring traceback Fix to Update Manager Status Bar Fix to failed image and erroneous pop up Fix to Mini Lib node that was preventing use Fix to plugins that parce dice but did not call InterParse Fix to nodes for name changing by double click Fix to Game Tree, node ordering on drag and drop corrected Fix to Game Tree, corrupted error message was not showing Fix to Update Manager, checks for internet connection Fix to Update Manager, Auto Update corrections Fix to Server GUI's broadcast, room, player messaging
author sirebral
date Tue, 04 May 2010 10:43:29 -0500
parents fc48380f0c9f
children
rev   line source
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
2 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
3 # openrpg-dev@lists.sourceforge.net
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
4 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
5 # This program is free software; you can redistribute it and/or modify
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
6 # it under the terms of the GNU General Public License as published by
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
8 # (at your option) any later version.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
9 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
10 # This program is distributed in the hope that it will be useful,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
13 # GNU General Public License for more details.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
14 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
15 # You should have received a copy of the GNU General Public License
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
16 # along with this program; if not, write to the Free Software
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
18 # --
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
19 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
20 # File: chatutils.py
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
21 # Author: Chris Davis
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
22 # Maintainer:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
23 # Version:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
24 # $Id: chatwnd.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
25 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
26 # Description: This file contains some of the basic definitions for the chat
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
27 # utilities in the orpg project.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
28 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
29 # History
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
30 # 2002-01-20 HeroMan
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
31 # + Added 4 dialog items on toolbar in support of Alias Library Functionallity
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
32 # + Shrunk the text view button to an image
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
33 # 2005-04-25 Snowdog
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
34 # + Added simple_html_repair() to post() to fix malformed html in the chat window
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
35 # + Added strip_script_tags() to post() to remove crash point. See chat_util.py
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
36 # 2005-04-25 Snowdog
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
37 # + Added simple_html_repair() to post() to fix malformed html in the chat window
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
38 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
39
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
40 __version__ = "$Id: chatwnd.py,v Traipse 'Ornery-Orc' prof.ebral Exp $"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
41
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
42
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
43 ##
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
44 ## Module Loading
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
45 ##
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
46 import os, time, re, sys, traceback, webbrowser, commands, chat_msg, chat_util
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
47
30
8e77f169f324 Traipse 'OpenRPG' {100219-00}
sirebral
parents: 28
diff changeset
48 from orpg.orpg_version import VERSION, DISTRO, DIS_VER, BUILD
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
49 from orpg.orpg_windows import *
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
50 from orpg.player_list import WG_LIST
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
51 from orpg.dirpath import dir_struct
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
52 from string import *
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
53
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
54 import cStringIO # for reading inline imagedata as a stream
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
55 from HTMLParser import HTMLParser
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
56 from wx.lib.expando import EVT_ETC_LAYOUT_NEEDED
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
57
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
58 import orpg.tools.rgbhex
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
59 import orpg.tools.inputValidator
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
60 from orpg.tools.validate import validate
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
61 from orpg.tools.orpg_settings import settings
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
62 import orpg.tools.predTextCtrl
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
63 from orpg.tools.orpg_log import logger, debug
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
64 from orpg.tools.InterParse import Parse
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
65 from orpg.orpgCore import component
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
66 from xml.etree.ElementTree import tostring
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
67
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
68 from orpg.networking.mplay_client import MPLAY_CONNECTED
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
69 NEWCHAT = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
70 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
71 import wx.webview
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
72 NEWCHAT = True
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
73 except: pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
74 NEWCHAT = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
75
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
76 # Global parser for stripping HTML tags:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
77 # The 'tag stripping' is implicit, because this parser echoes every
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
78 # type of html data *except* the tags.
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
79 class HTMLStripper(HTMLParser):
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
80
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
81 def __init__(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
82 self.accum = ""
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
83 self.special_tags = ['hr', 'br', 'img']
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
84
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
85 def handle_data(self, data):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
86 self.accum += data
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
87
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
88 def handle_entityref(self, name):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
89 self.accum += "&" + name + ";"
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
90
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
91 def handle_starttag(self, tag, attrs):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
92 if tag in self.special_tags:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
93 self.accum += '<' + tag
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
94 for attrib in attrs: self.accum += ' ' + attrib[0] + '="' + attrib[1] + '"'
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
95 self.accum += '>'
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
96
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
97 def handle_charref(self, name):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
98 self.accum += "&#" + name + ";"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
99 htmlstripper = HTMLStripper()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
100
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
101
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
102 def strip_html(string):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
103 "Return string tripped of html tags."
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
104 htmlstripper.reset()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
105 htmlstripper.accum = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
106 htmlstripper.feed(string)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
107 htmlstripper.close()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
108 return htmlstripper.accum
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
109
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
110
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
111 def log( settings, c, text ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
112 filename = settings.get_setting('GameLogPrefix')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
113 if filename > '' and filename[0] != commands.ANTI_LOG_CHAR:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
114 filename = filename + time.strftime( '-%Y-%m-%d.html', time.localtime( time.time() ) )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
115 timestamp = time.ctime(time.time())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
116 header = '[%s] : ' % ( timestamp );
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
117 if settings.get_setting('TimeStampGameLog') != '1': header = ''
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
118 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
119 f = open( dir_struct["user"] + filename, 'a' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
120 f.write( '<div class="'+c+'">%s%s</div>\n' % ( header, text ) )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
121 f.close()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
122 except Exception, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
123 print "could not open " + dir_struct["user"] + filename + ", ignoring..."
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
124 print 'Error given', e
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
125 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
126
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
127 # This class displayes the chat information in html?
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
128 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
129 # Defines:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
130 # __init__(self, parent, id)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
131 # OnLinkClicked(self, linkinfo)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
132 # CalculateAllFonts(self, defaultsize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
133 # SetDefaultFontAndSize(self, fontname)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
134 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
135 class chat_html_window(wx.html.HtmlWindow):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
136 """ a wxHTMLwindow that will load links """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
137
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
138 def __init__(self, parent, id):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
139 wx.html.HtmlWindow.__init__(self, parent, id,
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
140 style=wx.SUNKEN_BORDER|wx.html.HW_SCROLLBAR_AUTO|wx.NO_FULL_REPAINT_ON_RESIZE)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
141 self.parent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
142 self.build_menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
143 self.Bind(wx.EVT_LEFT_UP, self.LeftUp)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
144 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
145 if "gtk2" in wx.PlatformInfo: self.SetStandardFonts()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
146
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
147 def onPopup(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
148 self.PopupMenu(self.menu)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
149
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
150 def LeftUp(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
151 event.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
152 wx.CallAfter(self.parent.set_chat_text_focus, None)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
153
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
154 def build_menu(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
155 self.menu = wx.Menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
156 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
157 self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
158 self.menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
159
27
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 18
diff changeset
160 def OnM_EditCopy(self, evt):
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 18
diff changeset
161 wx.TheClipboard.UsePrimarySelection(False)
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 18
diff changeset
162 wx.TheClipboard.Open()
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 18
diff changeset
163 wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText()))
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 18
diff changeset
164 wx.TheClipboard.Close()
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
165
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
166 def scroll_down(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
167 maxrange = self.GetScrollRange(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
168 pagesize = self.GetScrollPageSize(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
169 self.Scroll(-1, maxrange-pagesize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
170
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
171 def mouse_wheel(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
172 amt = event.GetWheelRotation()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
173 units = amt/(-(event.GetWheelDelta()))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
174 self.ScrollLines(units*3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
175
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
176
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
177 def Header(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
178 return '<html><body bgcolor="' + self.parent.bgcolor + '" text="' + self.parent.textcolor + '">'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
179
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
180
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
181 def StripHeader(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
182 return self.GetPageSource().replace(self.Header(), '')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
183
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
184
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
185 def GetPageSource(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
186 return self.GetParser().GetSource()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
187
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
188 def OnLinkClicked(self, linkinfo):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
189 href = linkinfo.GetHref()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
190 wb = webbrowser.get()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
191 wb.open(href)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
192
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
193 def CalculateAllFonts(self, defaultsize):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
194 return [int(defaultsize * 0.4),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
195 int(defaultsize * 0.7),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
196 int(defaultsize),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
197 int(defaultsize * 1.3),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
198 int(defaultsize * 1.7),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
199 int(defaultsize * 2),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
200 int(defaultsize * 2.5)]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
201
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
202 def SetDefaultFontAndSize(self, fontname, fontsize):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
203 """Set 'fontname' to the default chat font.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
204 Returns current font settings in a (fontname, fontsize) tuple."""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
205 self.SetFonts(fontname, "", self.CalculateAllFonts(int(fontsize)))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
206 return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
207
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
208 # class chat_html_window - end
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
209 if NEWCHAT:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
210 class ChatHtmlWindow(wx.webview.WebView):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
211
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
212 def __init__(self, parent, id):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
213 wx.webview.WebView.__init__(self, parent, id)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
214 self.parent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
215 self.__font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName='Ariel')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
216 self.build_menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
217 self.Bind(wx.EVT_LEFT_UP, self.LeftUp)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
218 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
219 self.Bind(wx.webview.EVT_WEBVIEW_BEFORE_LOAD, self.OnLinkClicked)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
220
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
221 def SetPage(self, htmlstring):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
222 self.SetPageSource(htmlstring)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
223
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
224 def AppendToPage(self, htmlstring):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
225 self.SetPageSource(self.GetPageSource() + htmlstring)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
226
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
227 def GetFont(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
228 return self.__font
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
229
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
230 def CalculateAllFonts(self, defaultsize):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
231 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
232
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
233 def SetDefaultFontAndSize(self, fontname, fontsize):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
234 self.__font = wx.Font(int(fontsize),
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
235 wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL,
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
236 wx.FONTWEIGHT_NORMAL, faceName=fontname)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
237 try: self.SetPageSource(self.Header() + self.StripHeader())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
238 except Exception, e: print e
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
239 return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
240
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
241 #Events
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
242 def OnLinkClicked(self, linkinfo):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
243 href = linkinfo.GetHref()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
244 wb = webbrowser.get()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
245 wb.open(href)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
246
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
247 def onPopup(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
248 self.PopupMenu(self.menu)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
249
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
250 def LeftUp(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
251 event.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
252 wx.CallAfter(self.parent.set_chat_text_focus, None)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
253
27
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 18
diff changeset
254 def OnM_EditCopy(self, evt):
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 18
diff changeset
255 wx.TheClipboard.UsePrimarySelection(False)
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 18
diff changeset
256 wx.TheClipboard.Open()
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 18
diff changeset
257 wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText()))
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
258 wx.TheClipboard.Close()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
259
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
260 #Cutom Methods
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
261 def Header(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
262 return "<html><head><style>body {font-size: " + str(self.GetFont().GetPointSize()) + "px;font-family: " + self.GetFont().GetFaceName() + ";color: " + self.parent.textcolor + ";background-color: " + self.parent.bgcolor + ";margin: 0;padding: 0 0;height: 100%;}</style></head><body>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
263
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
264 def StripHeader(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
265 tmp = self.GetPageSource().split('<BODY>')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
266 if tmp[-1].find('<body>') > -1: tmp = tmp[-1].split('<body>')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
267 return tmp[-1]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
268
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
269 def build_menu(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
270 self.menu = wx.Menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
271 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
272 self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
273 self.menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
274
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
275 def scroll_down(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
276 maxrange = self.GetScrollRange(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
277 pagesize = self.GetScrollPageSize(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
278 self.Scroll(-1, maxrange-pagesize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
279
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
280 def mouse_wheel(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
281 amt = event.GetWheelRotation()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
282 units = amt/(-(event.GetWheelDelta()))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
283 self.ScrollLines(units*3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
284 chat_html_window = ChatHtmlWindow
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
285
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
286 #########################
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
287 #chat frame window
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
288 #########################
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
289 # These are kinda global...and static..and should be located somewhere else
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
290 # then the middle of a file between two classes.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
291
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
292 ###################
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
293 # Tab Types
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
294 ###################
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
295 MAIN_TAB = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
296 WHISPER_TAB = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
297 GROUP_TAB = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
298 NULL_TAB = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
299
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
300 # This class defines the tabbed 'notebook' that holds multiple chatpanels.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
301 # It's the widget attached to the main application frame.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
302 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
303 # Inherits: wxNotebook
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
304 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
305 # Defines:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
306 # create_private_tab(self, playerid)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
307 # get_tab_index(self, chatpanel)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
308 # destroy_private_tab(self, chatpanel)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
309 # OnPageChanged(self, event)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
310 # set_default_font(self, font, fontsize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
311
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
312 class chat_notebook(orpgTabberWnd):
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
313
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
314 def __init__(self, parent, size):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
315 orpgTabberWnd.__init__(self, parent, True, size=size,
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
316 style=FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_NO_NAV_BUTTONS|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
317 self.settings = component.get("settings")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
318 self.whisper_tabs = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
319 self.group_tabs = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
320 self.null_tabs = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
321 self.il = wx.ImageList(16, 16)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
322 bmp = wx.Bitmap(dir_struct["icon"]+'player.gif')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
323 self.il.Add(bmp)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
324 bmp = wx.Bitmap(dir_struct["icon"]+'clear.gif')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
325 self.il.Add(bmp)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
326 self.SetImageList(self.il)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
327 # Create "main" chatpanel tab, undeletable, connected to 'public' room.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
328 self.MainChatPanel = chat_panel(self, -1, MAIN_TAB, 'all')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
329 self.AddPage(self.MainChatPanel, "Main Room")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
330 self.SetPageImage(0, 1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
331 self.chat_timer = wx.Timer(self, wx.NewId())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
332 self.Bind(wx.EVT_TIMER, self.MainChatPanel.typingTimerFunc)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
333 self.chat_timer.Start(1000)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
334 # Hook up event handler for flipping tabs
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
335 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.onPageChanged)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
336 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.onPageChanging)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
337 self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.onCloseTab)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
338 # html font/fontsize is global to all the notebook tabs.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
339 self.font, self.fontsize = self.MainChatPanel.chatwnd.SetDefaultFontAndSize(self.settings.get_setting('defaultfont'), self.settings.get_setting('defaultfontsize'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
340 self.GMChatPanel = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
341 if self.settings.get_setting("GMWhisperTab") == '1':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
342 self.create_gm_tab()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
343 self.SetSelection(0)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
344
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
345 def get_tab_index(self, chatpanel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
346 "Return the index of a chatpanel in the wxNotebook."
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
347 for i in xrange(self.GetPageCount()):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
348 if (self.GetPage(i) == chatpanel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
349 return i
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
350
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
351 def create_gm_tab(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
352 if self.GMChatPanel == None:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
353 self.GMChatPanel = chat_panel(self, -1, MAIN_TAB, 'gm')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
354 self.AddPage(self.GMChatPanel, "GM", False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
355 self.SetPageImage(self.GetPageCount()-1, 1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
356 self.GMChatPanel.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
357
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
358 def create_whisper_tab(self, playerid):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
359 "Add a new chatpanel directly connected to integer 'playerid' via whispering."
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
360 private_tab = chat_panel(self, -1, WHISPER_TAB, playerid)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
361 playername = strip_html(self.MainChatPanel.session.get_player_by_player_id(playerid)[0])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
362 self.AddPage(private_tab, playername, False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
363 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
364 self.whisper_tabs.append(private_tab)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
365 self.newMsg(self.GetPageCount()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
366 self.AliasLib = component.get('alias')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
367 wx.CallAfter(self.AliasLib.RefreshAliases)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
368 return private_tab
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
369
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
370 def create_group_tab(self, group_name):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
371 "Add a new chatpanel directly connected to integer 'playerid' via whispering."
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
372 private_tab = chat_panel(self, -1, GROUP_TAB, group_name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
373 self.AddPage(private_tab, group_name, False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
374 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
375 self.group_tabs.append(private_tab)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
376 self.newMsg(self.GetPageCount()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
377 self.AliasLib = component.get('alias')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
378 wx.CallAfter(self.AliasLib.RefreshAliases)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
379 return private_tab
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
380
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
381 def create_null_tab(self, tab_name):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
382 "Add a new chatpanel directly connected to integer 'playerid' via whispering."
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
383 private_tab = chat_panel(self, -1, NULL_TAB, tab_name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
384 self.AddPage(private_tab, tab_name, False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
385 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
386 self.null_tabs.append(private_tab)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
387 self.newMsg(self.GetPageCount()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
388 self.AliasLib = component.get('alias')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
389 wx.CallAfter(self.AliasLib.RefreshAliases)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
390 return private_tab
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
391
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
392 def onCloseTab(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
393 try: tabid = evt.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
394 except: tabid = self.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
395 if self.GetPageText(tabid) == 'Main Room':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
396 #send no close error to chat
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
397 evt.Veto()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
398 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
399 if self.GetPageText(tabid) == 'GM':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
400 msg = "Are You Sure You Want To Close This Page?"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
401 dlg = wx.MessageDialog(self, msg, "NotebookCtrl Question",
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
402 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
403 if wx.Platform != '__WXMAC__':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
404 dlg.SetFont(wx.Font(8, wx.NORMAL, wx.NORMAL, wx.NORMAL, False))
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
405
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
406 if dlg.ShowModal() in [wx.ID_NO]:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
407 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
408 evt.Veto()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
409 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
410 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
411 self.GMChatPanel = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
412 self.settings.set_setting("GMWhisperTab", "0")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
413 panel = self.GetPage(tabid)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
414 if panel in self.whisper_tabs: self.whisper_tabs.remove(panel)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
415 elif panel in self.group_tabs: self.group_tabs.remove(panel)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
416 elif panel in self.null_tabs: self.null_tabs.remove(panel)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
417
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
418 def newMsg(self, tabid):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
419 if tabid != self.GetSelection(): self.SetPageImage(tabid, 0)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
420
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
421 def onPageChanging(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
422 """When private chattabs are selected, set the bitmap back to 'normal'."""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
423 event.Skip()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
424
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
425 def onPageChanged(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
426 """When private chattabs are selected, set the bitmap back to 'normal'."""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
427 selected_idx = event.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
428 self.SetPageImage(selected_idx, 1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
429 page = self.GetPage(selected_idx)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
430 event.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
431
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
432 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
433 This class defines and builds the Chat Frame for OpenRPG
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
434
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
435 Inherits: wxPanel
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
436
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
437 Defines:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
438 __init__((self, parent, id, openrpg, sendtarget)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
439 build_ctrls(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
440 on_buffer_size(self,evt)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
441 set_colors(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
442 set_buffersize(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
443 set_chat_text(self,txt)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
444 OnChar(self,event)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
445 on_chat_save(self,evt)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
446 on_text_color(self,event)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
447 colorize(self, color, text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
448 on_text_format(self,event)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
449 OnSize(self,event)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
450 scroll_down(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
451 InfoPost(self,s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
452 Post(self,s="",send=False,myself=False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
453 ParsePost(self,s,send=False,myself=False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
454 ParseDice(self,s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
455 ParseNodes(self,s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
456 get_sha_checksum(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
457 get_color(self)
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 0
diff changeset
458
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
459 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
460
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
461 class chat_panel(wx.Panel):
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 0
diff changeset
462
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
463 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
464 This is the initialization subroutine
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
465
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
466 !self : instance of self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
467 !parent : parent that defines the chatframe
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
468 !id :
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
469 !openrpg :
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 0
diff changeset
470 !sendtarget: who gets outbound messages: either 'all' or a playerid
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 0
diff changeset
471 """
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
472
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
473
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
474 def __init__(self, parent, id, tab_type, sendtarget):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
475 wx.Panel.__init__(self, parent, id)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
476 logger._set_log_to_console(False)
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
477 self.session = component.get('session')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
478 self.settings = component.get('settings')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
479 self.activeplugins = component.get('plugins')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
480 self.parent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
481 # who receives outbound messages, either "all" or "playerid" string
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
482 self.sendtarget = sendtarget
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
483 self.type = tab_type
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
484 self.r_h = orpg.tools.rgbhex.RGBHex()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
485 self.h = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
486 self.set_colors()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
487 self.version = VERSION
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
488 self.histidx = -1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
489 self.temptext = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
490 self.history = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
491 self.storedata = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
492 #self.lasthistevt = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
493 self.parsed=0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
494 #chat commands
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
495 self.lockscroll = False # set the default to scrolling on.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
496 self.chat_cmds = commands.chat_commands(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
497 self.html_strip = strip_html
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
498 self.f_keys = {wx.WXK_F1: 'event.GetKeyCode() == wx.WXK_F1', wx.WXK_F2: 'event.GetKeyCode() == wx.WXK_F2',
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
499 wx.WXK_F3: 'event.GetKeyCode() == wx.WXK_F3', wx.WXK_F4: 'event.GetKeyCode() == wx.WXK_F4',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
500 wx.WXK_F5: 'event.GetKeyCode() == wx.WXK_F5', wx.WXK_F6: 'event.GetKeyCode() == wx.WXK_F6',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
501 wx.WXK_F7: 'event.GetKeyCode() == wx.WXK_F7', wx.WXK_F8: 'event.GetKeyCode() == wx.WXK_F8',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
502 wx.WXK_F9: 'event.GetKeyCode() == wx.WXK_F9', wx.WXK_F10: 'event.GetKeyCode() == wx.WXK_F10',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
503 wx.WXK_F11: 'event.GetKeyCode() == wx.WXK_F11', wx.WXK_F12: 'event.GetKeyCode() == wx.WXK_F12'}
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
504 #Alias Lib stuff
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
505 self.defaultAliasName = 'Real Name'
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
506 self.defaultFilterName = 'No Filter'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
507 self.advancedFilter = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
508 self.lastSend = 0 # this is used to help implement the player typing indicator
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
509 self.lastPress = 0 # this is used to help implement the player typing indicator
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
510 self.Bind(wx.EVT_SIZE, self.OnSize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
511 self.Bind(EVT_ETC_LAYOUT_NEEDED, self.OnSize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
512 self.build_ctrls()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
513 StartupFont = self.settings.get_setting("defaultfont")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
514 StartupFontSize = self.settings.get_setting("defaultfontsize")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
515 if(StartupFont != "") and (StartupFontSize != ""):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
516 try: self.set_default_font(StartupFont, int(StartupFontSize))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
517 except: pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
518 self.font = self.chatwnd.GetFont().GetFaceName()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
519 self.fontsize = self.chatwnd.GetFont().GetPointSize()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
520 self.scroll_down()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
521
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
522 def set_default_font(self, fontname=None, fontsize=None):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
523 """Set all chatpanels to new default fontname/fontsize.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
524 Returns current font settings in a (fontname, fontsize) tuple."""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
525 if (fontname is not None): newfont = fontname
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
526 else: newfont = self.font
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
527 if (fontsize is not None): newfontsize = int(fontsize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
528 else: newfontsize = int(self.fontsize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
529 self.chatwnd.SetDefaultFontAndSize(newfont, newfontsize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
530 self.InfoPost("Font is now " + newfont + " point size " + `newfontsize`)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
531 self.font = newfont
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
532 self.fontsize = newfontsize
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
533 return (self.font, self.fontsize)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
534
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
535 def build_menu(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
536 top_frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
537 menu = wx.Menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
538 item = wx.MenuItem(menu, wx.ID_ANY, "&Background color", "Background color")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
539 top_frame.Bind(wx.EVT_MENU, self.OnMB_BackgroundColor, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
540 menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
541 item = wx.MenuItem(menu, wx.ID_ANY, "&Text color", "Text color")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
542 top_frame.Bind(wx.EVT_MENU, self.OnMB_TextColor, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
543 menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
544 menu.AppendSeparator()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
545 item = wx.MenuItem(menu, wx.ID_ANY, "&Chat Focus\tCtrl-H", "Chat Focus")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
546 self.setChatFocusMenu = item
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
547 top_frame.Bind(wx.EVT_MENU, self.set_chat_text_focus, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
548 menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
549 menu.AppendSeparator()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
550 item = wx.MenuItem(menu, wx.ID_ANY, "Toggle &Scroll Lock", "Toggle Scroll Lock")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
551 top_frame.Bind(wx.EVT_MENU, self.lock_scroll, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
552 menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
553 item = wx.MenuItem(menu, wx.ID_ANY, "Save Chat &Log", "Save Chat Log")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
554 top_frame.Bind(wx.EVT_MENU, self.on_chat_save, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
555 menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
556 item = wx.MenuItem(menu, wx.ID_ANY, "Text &View", "Text View")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
557 top_frame.Bind(wx.EVT_MENU, self.pop_textpop, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
558 menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
559 item = wx.MenuItem(menu, wx.ID_ANY, "Forward Tab\tCtrl+Tab", "Swap Tabs")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
560 top_frame.Bind(wx.EVT_MENU, self.forward_tabs, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
561 menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
562 item = wx.MenuItem(menu, wx.ID_ANY, "Forward Tab\tCtrl+Shift+Tab", "Swap Tabs")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
563 top_frame.Bind(wx.EVT_MENU, self.back_tabs, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
564 menu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
565 menu.AppendSeparator()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
566 settingmenu = wx.Menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
567 wndmenu = wx.Menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
568 tabmenu = wx.Menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
569 toolmenu = wx.Menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
570 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Show Images", "Show Images", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
571 top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowImages, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
572
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
573 wndmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
574 if self.settings.get_setting("Show_Images_In_Chat") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
575 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Strip HTML", "Strip HTML", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
576 top_frame.Bind(wx.EVT_MENU, self.OnMB_StripHTML, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
577 wndmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
578 if self.settings.get_setting("striphtml") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
579 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Chat Time Index", "Chat Time Index", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
580 top_frame.Bind(wx.EVT_MENU, self.OnMB_ChatTimeIndex, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
581 wndmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
582 if self.settings.get_setting("Chat_Time_Indexing") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
583 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Chat Auto Complete", "Chat Auto Complete", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
584 top_frame.Bind(wx.EVT_MENU, self.OnMB_ChatAutoComplete, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
585 wndmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
586 if self.settings.get_setting("SuppressChatAutoComplete") == '0': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
587 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Show ID in Chat", "Show ID in Chat", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
588 top_frame.Bind(wx.EVT_MENU, self.OnMB_ShowIDinChat, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
589 wndmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
590 if self.settings.get_setting("ShowIDInChat") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
591 item = wx.MenuItem(wndmenu, wx.ID_ANY, "Log Time Index", "Log Time Index", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
592 top_frame.Bind(wx.EVT_MENU, self.OnMB_LogTimeIndex, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
593 wndmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
594 if self.settings.get_setting("TimeStampGameLog") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
595 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Window', wndmenu )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
596 item = wx.MenuItem(tabmenu, wx.ID_ANY, "Tabbed Whispers", "Tabbed Whispers", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
597 top_frame.Bind(wx.EVT_MENU, self.OnMB_TabbedWhispers, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
598 tabmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
599 if self.settings.get_setting("tabbedwhispers") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
600 item = wx.MenuItem(tabmenu, wx.ID_ANY, "GM Tab", "GM Tab", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
601 top_frame.Bind(wx.EVT_MENU, self.OnMB_GMTab, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
602 tabmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
603 if self.settings.get_setting("GMWhisperTab") == '1':item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
604 item = wx.MenuItem(tabmenu, wx.ID_ANY, "Group Whisper Tabs", "Group Whisper Tabs", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
605 top_frame.Bind(wx.EVT_MENU, self.OnMB_GroupWhisperTabs, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
606 tabmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
607 if self.settings.get_setting("GroupWhisperTab") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
608 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tabs', tabmenu)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
609 item = wx.MenuItem(toolmenu, wx.ID_ANY, "Dice Bar", "Dice Bar", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
610 top_frame.Bind(wx.EVT_MENU, self.OnMB_DiceBar, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
611 toolmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
612 if self.settings.get_setting("DiceButtons_On") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
613 item = wx.MenuItem(toolmenu, wx.ID_ANY, "Format Buttons", "Format Buttons", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
614 top_frame.Bind(wx.EVT_MENU, self.OnMB_FormatButtons, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
615 toolmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
616 if self.settings.get_setting("FormattingButtons_On") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
617 item = wx.MenuItem(toolmenu, wx.ID_ANY, "Alias Tool", "Alias Tool", wx.ITEM_CHECK)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
618 top_frame.Bind(wx.EVT_MENU, self.OnMB_AliasTool, item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
619 toolmenu.AppendItem(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
620 if self.settings.get_setting("AliasTool_On") == '1': item.Check(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
621 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tool Bars', toolmenu)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
622 menu.AppendMenu(wx.ID_ANY, 'Chat Settings', settingmenu)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
623 top_frame.mainmenu.Insert(2, menu, '&Chat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
624
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
625 ## Settings Menu Events
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
626 def OnMB_ShowImages(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
627 if event.IsChecked(): self.settings.set_setting("Show_Images_In_Chat", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
628 else: self.settings.set_setting("Show_Images_In_Chat", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
629
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
630 def OnMB_StripHTML(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
631 if event.IsChecked(): self.settings.set_setting("striphtml", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
632 else: self.settings.set_setting("striphtml", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
633
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
634 def OnMB_ChatTimeIndex(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
635 if event.IsChecked(): self.settings.set_setting("Chat_Time_Indexing", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
636 else: self.settings.set_setting("Chat_Time_Indexing", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
637
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
638 def OnMB_ChatAutoComplete(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
639 if event.IsChecked(): self.settings.set_setting("SuppressChatAutoComplete", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
640 else: self.settings.set_setting("SuppressChatAutoComplete", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
641
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
642 def OnMB_ShowIDinChat(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
643 if event.IsChecked(): self.settings.set_setting("ShowIDInChat", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
644 else: self.settings.set_setting("ShowIDInChat", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
645
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
646 def OnMB_LogTimeIndex(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
647 if event.IsChecked(): self.settings.set_setting("TimeStampGameLog", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
648 else: self.settings.set_setting("TimeStampGameLog", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
649
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
650 def OnMB_TabbedWhispers(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
651 if event.IsChecked(): self.settings.set_setting("tabbedwhispers", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
652 else: self.settings.set_setting("tabbedwhispers", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
653
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
654 def OnMB_GMTab(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
655 if event.IsChecked():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
656 self.settings.set_setting("GMWhisperTab", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
657 self.parent.create_gm_tab()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
658 else: self.settings.set_setting("GMWhisperTab", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
659
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
660 def OnMB_GroupWhisperTabs(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
661 if event.IsChecked(): self.settings.set_setting("GroupWhisperTab", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
662 else: self.settings.set_setting("GroupWhisperTab", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
663
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
664 def OnMB_DiceBar(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
665 act = '0'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
666 if event.IsChecked():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
667 self.settings.set_setting("DiceButtons_On", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
668 act = '1'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
669 else: self.settings.set_setting("DiceButtons_On", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
670 self.toggle_dice(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
671 try: self.parent.GMChatPanel.toggle_dice(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
672 except: pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
673 for panel in self.parent.whisper_tabs: panel.toggle_dice(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
674 for panel in self.parent.group_tabs: panel.toggle_dice(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
675 for panel in self.parent.null_tabs: panel.toggle_dice(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
676
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
677 def OnMB_FormatButtons(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
678 act = '0'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
679 if event.IsChecked():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
680 self.settings.set_setting("FormattingButtons_On", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
681 act = '1'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
682 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
683 self.settings.set_setting("FormattingButtons_On", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
684 self.toggle_formating(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
685 try: self.parent.GMChatPanel.toggle_formating(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
686 except: pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
687 for panel in self.parent.whisper_tabs: panel.toggle_formating(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
688 for panel in self.parent.group_tabs: panel.toggle_formating(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
689 for panel in self.parent.null_tabs: panel.toggle_formating(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
690
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
691 def OnMB_AliasTool(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
692 act = '0'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
693 if event.IsChecked():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
694 self.settings.set_setting("AliasTool_On", '1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
695 act = '1'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
696 else: self.settings.set_setting("AliasTool_On", '0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
697 self.toggle_alias(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
698 try: self.parent.GMChatPanel.toggle_alias(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
699 except: pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
700 for panel in self.parent.whisper_tabs: panel.toggle_alias(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
701 for panel in self.parent.group_tabs: panel.toggle_alias(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
702 for panel in self.parent.null_tabs:panel.toggle_alias(act)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
703
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
704 def OnMB_BackgroundColor(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
705 top_frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
706 hexcolor = self.get_color()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
707 if hexcolor != None:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
708 self.bgcolor = hexcolor
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
709 self.settings.set_setting('bgcolor', hexcolor)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
710 self.chatwnd.SetPage(self.ResetPage())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
711 if self.settings.get_setting('ColorTree') == '1':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
712 top_frame.tree.SetBackgroundColour(self.settings.get_setting('bgcolor'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
713 top_frame.tree.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
714 top_frame.players.SetBackgroundColour(self.settings.get_setting('bgcolor'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
715 top_frame.players.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
716 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
717 top_frame.tree.SetBackgroundColour('white')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
718 top_frame.tree.SetForegroundColour('black')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
719 top_frame.tree.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
720 top_frame.players.SetBackgroundColour('white')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
721 top_frame.players.SetForegroundColour('black')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
722 top_frame.players.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
723 self.chatwnd.scroll_down()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
724
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
725
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
726 def OnMB_TextColor(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
727 top_frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
728 hexcolor = self.get_color()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
729 if hexcolor != None:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
730 self.textcolor = hexcolor
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
731 self.settings.set_setting('textcolor', hexcolor)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
732 self.chatwnd.SetPage(self.ResetPage())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
733 if self.settings.get_setting('ColorTree') == '1':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
734 top_frame.tree.SetForegroundColour(self.settings.get_setting('textcolor'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
735 top_frame.tree.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
736 top_frame.players.SetForegroundColour(self.settings.get_setting('textcolor'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
737 top_frame.players.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
738 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
739 top_frame.tree.SetBackgroundColour('white')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
740 top_frame.tree.SetForegroundColour('black')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
741 top_frame.tree.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
742 top_frame.players.SetBackgroundColour('white')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
743 top_frame.players.SetForegroundColour('black')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
744 top_frame.players.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
745 self.chatwnd.scroll_down()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
746
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
747
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
748 def get_hot_keys(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
749 # dummy menus for hotkeys
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
750 self.build_menu()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
751 entries = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
752 entries.append((wx.ACCEL_CTRL, ord('H'), self.setChatFocusMenu.GetId()))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
753 return entries
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
754
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
755
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
756 def forward_tabs(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
757 self.parent.AdvanceSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
758
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
759 def back_tabs(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
760 self.parent.AdvanceSelection(False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
761
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
762 def build_ctrls(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
763 self.chatwnd = chat_html_window(self,-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
764 self.set_colors()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
765 wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header())
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
766 welcome = "<b>Welcome to <a href='http://www.knowledgearcana.com/traipse-openrpg/'>"
30
8e77f169f324 Traipse 'OpenRPG' {100219-00}
sirebral
parents: 28
diff changeset
767 welcome += DISTRO +'</a> '+ DIS_VER +' {'+BUILD+'},'
8e77f169f324 Traipse 'OpenRPG' {100219-00}
sirebral
parents: 28
diff changeset
768 welcome += ' built on OpenRPG '+ VERSION +'</b>'
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
769 if (self.sendtarget == "all"):
30
8e77f169f324 Traipse 'OpenRPG' {100219-00}
sirebral
parents: 28
diff changeset
770 wx.CallAfter(self.Post, self.colorize(self.syscolor, welcome))
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
771 self.chattxt = orpg.tools.predTextCtrl.predTextCtrl(self, -1, "",
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
772 style=wx.TE_PROCESS_ENTER |wx.TE_PROCESS_TAB|wx.TE_LINEWRAP,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
773 keyHook = self.myKeyHook, validator=None )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
774 self.build_bar()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
775 self.basesizer = wx.BoxSizer(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
776 self.basesizer.Add( self.chatwnd, 1, wx.EXPAND )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
777 self.basesizer.Add( self.toolbar_sizer, 0, wx.EXPAND )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
778 self.basesizer.Add( self.chattxt, 0, wx.EXPAND )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
779 self.SetSizer(self.basesizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
780 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
781 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
782 #events
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
783 self.Bind(wx.EVT_BUTTON, self.on_text_format, self.boldButton)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
784 self.Bind(wx.EVT_BUTTON, self.on_text_format, self.italicButton)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
785 self.Bind(wx.EVT_BUTTON, self.on_text_format, self.underlineButton)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
786 self.Bind(wx.EVT_BUTTON, self.on_text_color, self.color_button)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
787 self.Bind(wx.EVT_BUTTON, self.on_chat_save, self.saveButton)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
788 self.Bind(wx.EVT_BUTTON, self.onDieRoll, self.d4Button)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
789 self.Bind(wx.EVT_BUTTON, self.onDieRoll, self.d6Button)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
790 self.Bind(wx.EVT_BUTTON, self.onDieRoll, self.d8Button)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
791 self.Bind(wx.EVT_BUTTON, self.onDieRoll, self.d10Button)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
792 self.Bind(wx.EVT_BUTTON, self.onDieRoll, self.d12Button)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
793 self.Bind(wx.EVT_BUTTON, self.onDieRoll, self.d20Button)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
794 self.Bind(wx.EVT_BUTTON, self.onDieRoll, self.d100Button)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
795 self.dieIDs = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
796 self.dieIDs[self.d4Button.GetId()] = 'd4'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
797 self.dieIDs[self.d6Button.GetId()] = 'd6'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
798 self.dieIDs[self.d8Button.GetId()] = 'd8'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
799 self.dieIDs[self.d10Button.GetId()] = 'd10'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
800 self.dieIDs[self.d12Button.GetId()] = 'd12'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
801 self.dieIDs[self.d20Button.GetId()] = 'd20'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
802 self.dieIDs[self.d100Button.GetId()] = 'd100'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
803 self.Bind(wx.EVT_BUTTON, self.pop_textpop, self.textpop_lock)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
804 self.Bind(wx.EVT_BUTTON, self.lock_scroll, self.scroll_lock)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
805 self.chattxt.Bind(wx.EVT_MOUSEWHEEL, self.chatwnd.mouse_wheel)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
806 self.chattxt.Bind(wx.EVT_CHAR, self.chattxt.OnChar)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
807 self.chattxt.Bind(wx.EVT_KEY_DOWN, self.on_chat_key_down)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
808 self.chattxt.Bind(wx.EVT_TEXT_COPY, self.chatwnd.OnM_EditCopy)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
809
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
810 def build_bar(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
811 self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
812 self.scroll_lock = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
813 self.numDieText = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
814 self.dieModText = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
815 if self.settings.get_setting('Toolbar_On') == "1":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
816 self.build_alias()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
817 self.build_dice()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
818 self.build_scroll()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
819 self.build_text()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
820 self.toolbar_sizer.Add(self.textpop_lock, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
821 self.toolbar_sizer.Add(self.scroll_lock, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
822 self.build_formating()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
823 self.build_colorbutton()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
824
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
825 def build_scroll(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
826 self.scroll_lock = wx.Button( self, wx.ID_ANY, "Scroll ON",size= wx.Size(80,25))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
827
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
828 def build_alias(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
829 self.aliasSizer = wx.BoxSizer(wx.HORIZONTAL)
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
830 self.aliasList = wx.Choice(self, wx.ID_ANY, size=(120, 25), choices=[self.defaultAliasName])
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
831 self.aliasButton = createMaskedButton( self, dir_struct["icon"] + 'player.gif',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
832 'Refresh list of aliases from Game Tree',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
833 wx.ID_ANY, '#bdbdbd' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
834 self.aliasList.SetSelection(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
835 self.filterList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultFilterName])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
836 self.filterButton = createMaskedButton( self, dir_struct["icon"] + 'add_filter.gif',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
837 'Refresh list of filters from Game Tree',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
838 wx.ID_ANY, '#bdbdbd' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
839 self.filterList.SetSelection(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
840
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
841 self.aliasSizer.Add( self.aliasButton, 0, wx.EXPAND )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
842 self.aliasSizer.Add( self.aliasList,0,wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
843 self.aliasSizer.Add( self.filterButton, 0, wx.EXPAND )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
844 self.aliasSizer.Add( self.filterList,0,wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
845
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
846 self.toolbar_sizer.Add(self.aliasSizer, 0, wx.EXPAND)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
847
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
848 if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
849 else: self.toggle_alias('1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
850
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
851 def toggle_alias(self, act):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
852 if act == '0': self.toolbar_sizer.Show(self.aliasSizer, False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
853 else: self.toolbar_sizer.Show(self.aliasSizer, True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
854 self.toolbar_sizer.Layout()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
855
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
856 def build_text(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
857 self.textpop_lock = createMaskedButton(self, dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
858
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
859
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
860 def build_dice(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
861 self.diceSizer = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
862 self.numDieText = wx.TextCtrl( self, wx.ID_ANY, "1",
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
863 size= wx.Size(25, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
864 self.dieModText = wx.TextCtrl( self, wx.ID_ANY, "",
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
865 size= wx.Size(50, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
866 self.d4Button = createMaskedButton(self, dir_struct["icon"]+'b_d4.gif', 'Roll d4', wx.ID_ANY)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
867 self.d6Button = createMaskedButton(self, dir_struct["icon"]+'b_d6.gif', 'Roll d6', wx.ID_ANY)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
868 self.d8Button = createMaskedButton(self, dir_struct["icon"]+'b_d8.gif', 'Roll d8', wx.ID_ANY)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
869 self.d10Button = createMaskedButton(self, dir_struct["icon"]+'b_d10.gif', 'Roll d10', wx.ID_ANY)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
870 self.d12Button = createMaskedButton(self, dir_struct["icon"]+'b_d12.gif', 'Roll d12', wx.ID_ANY)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
871 self.d20Button = createMaskedButton(self, dir_struct["icon"]+'b_d20.gif', 'Roll d20', wx.ID_ANY)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
872 self.d100Button = createMaskedButton(self, dir_struct["icon"]+'b_d100.gif', 'Roll d100', wx.ID_ANY)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
873
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
874 self.diceSizer.Add( self.numDieText, 0, wx.ALIGN_CENTER | wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
875 self.diceSizer.Add( self.d4Button, 0 ,wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
876 self.diceSizer.Add( self.d6Button, 0 ,wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
877 self.diceSizer.Add( self.d8Button, 0 ,wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
878 self.diceSizer.Add( self.d10Button, 0 ,wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
879 self.diceSizer.Add( self.d12Button, 0 ,wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
880 self.diceSizer.Add( self.d20Button, 0 ,wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
881 self.diceSizer.Add( self.d100Button, 0 ,wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
882 self.diceSizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
883
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
884 self.toolbar_sizer.Add( self.diceSizer, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
885 if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
886 else: self.toggle_dice('1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
887
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
888
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
889 def toggle_dice(self, act):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
890 if act == '0': self.toolbar_sizer.Show(self.diceSizer, False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
891 else: self.toolbar_sizer.Show(self.diceSizer, True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
892 self.toolbar_sizer.Layout()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
893
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
894
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
895 def build_formating(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
896 self.formatSizer = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
897 self.boldButton = createMaskedButton( self, dir_struct["icon"]+'bold.gif',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
898 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
899 self.italicButton = createMaskedButton( self, dir_struct["icon"]+'italic.gif',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
900 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
901 self.underlineButton = createMaskedButton( self, dir_struct["icon"]+'underlined.gif',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
902 'Underline the selected text', wx.ID_ANY, '#bdbdbd' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
903
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
904 self.formatSizer.Add( self.boldButton, 0, wx.EXPAND )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
905 self.formatSizer.Add( self.italicButton, 0, wx.EXPAND )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
906 self.formatSizer.Add( self.underlineButton, 0, wx.EXPAND )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
907 self.toolbar_sizer.Add( self.formatSizer, 0, wx.EXPAND )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
908 if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
909 else: self.toggle_formating('1')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
910
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
911
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
912 def toggle_formating(self, act):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
913 if act == '0': self.toolbar_sizer.Show(self.formatSizer, False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
914 else: self.toolbar_sizer.Show(self.formatSizer, True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
915 self.toolbar_sizer.Layout()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
916
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
917 def build_colorbutton(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
918 self.color_button = createMaskedButton(self, dir_struct["icon"]+'textcolor.gif',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
919 'Text Color', wx.ID_ANY, '#bdbdbd',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
920 wx.BITMAP_TYPE_GIF)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
921
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
922 self.saveButton = createMaskedButton(self, dir_struct["icon"]+'save.bmp',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
923 'Save the chatbuffer', wx.ID_ANY,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
924 '#c0c0c0', wx.BITMAP_TYPE_BMP )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
925 self.color_button.SetBackgroundColour(self.settings.get_setting('mytextcolor'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
926 self.toolbar_sizer.Add(self.color_button, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
927 self.toolbar_sizer.Add(self.saveButton, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
928
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
929
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
930 def OnMotion(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
931 contain = self.chatwnd.GetInternalRepresentation()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
932 if contain:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
933 sx = sy = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
934 x = y = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
935 (sx,sy) = self.chatwnd.GetViewStart()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
936 (sx1,sy1) = self.chatwnd.GetScrollPixelsPerUnit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
937 sx = sx*sx1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
938 sy = sy*sy1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
939 (x,y) = evt.GetPosition()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
940 lnk = contain.GetLink(sx+x,sy+y)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
941 if lnk:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
942 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
943 link = lnk.GetHref()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
944 self.session.set_status_url(link)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
945 except: pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
946 else: logger.general("Error, self.chatwnd.GetInternalRepresentation() return None")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
947 evt.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
948
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
949 def myKeyHook(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
950 if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
951 thisPress = time.time() # thisPress is local temp variable
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
952 if (thisPress - self.lastSend) > 4: # Check to see if it's been 5 seconds since our last notice
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
953 # If we're not already typing, then self.lastSend will be 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
954 self.sendTyping(1) # send a not typing event here (1 for True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
955 self.lastPress = thisPress # either way, record the time of this keystroke for use in
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
956 # self.typingTimerFunc()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
957 if self.settings.get_setting('SuppressChatAutoComplete') == '1':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
958 logger.debug("Exit chat_panel->myKeyHook(self, event) return 1")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
959 return 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
960 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
961 logger.debug("Exit chat_panel->myKeyHook(self, event) return 0")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
962 return 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
963
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
964 def typingTimerFunc(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
965 #following added by mDuo13
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
966 ##############refresh_counter()##############
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
967 for plugin_fname in self.activeplugins.keys():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
968 plugin = self.activeplugins[plugin_fname]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
969 try: plugin.refresh_counter()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
970 except Exception, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
971 if str(e) != "'module' object has no attribute 'refresh_counter'":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
972 logger.general(traceback.format_exc())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
973 logger.general("EXCEPTION: " + str(e))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
974 #end mDuo13 added code
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
975 if self.lastSend: # This will be zero when not typing, so equiv to if is_typing
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
976 thisTime = time.time() # thisTime is a local temp variable
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
977 if (thisTime - self.lastPress) > 4: # Check to see if it's been 5 seconds since our last keystroke
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
978 # If we're not already typing, then self.lastSend will be 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
979
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
980 self.sendTyping(0) # send a typing event here (0 for False)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
981
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
982 def sendTyping(self, typing):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
983 if typing:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
984 self.lastSend = time.time() # remember our send time for use in myKeyHook()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
985 #I think this is cleaner
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
986 status_text = self.settings.get_setting('TypingStatusAlias')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
987 if status_text == "" or status_text == None: status_text = "Typing"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
988 self.session.set_text_status(status_text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
989 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
990 self.lastSend = 0 # set lastSend to zero to indicate we're not typing
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
991 #I think this is cleaner
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
992 status_text = self.settings.get_setting('IdleStatusAlias')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
993 if status_text == "" or status_text == None: status_text = "Idle"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
994 self.session.set_text_status(status_text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
995
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
996 def set_colors(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
997 # chat window backround color
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
998 self.bgcolor = self.settings.get_setting('bgcolor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
999 # chat window normal text color
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1000 self.textcolor = self.settings.get_setting('textcolor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1001 # color of text player types
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1002 self.mytextcolor = self.settings.get_setting('mytextcolor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1003 # color of system warnings
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1004 self.syscolor = self.settings.get_setting('syscolor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1005 # color of system info messages
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1006 self.infocolor = self.settings.get_setting('infocolor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1007 # color of emotes
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1008 self.emotecolor = self.settings.get_setting('emotecolor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1009 # color of whispers
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1010 self.whispercolor = self.settings.get_setting('whispercolor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1011
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1012 def set_chat_text(self, txt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1013 self.chattxt.SetValue(txt)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1014 self.chattxt.SetFocus()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1015 self.chattxt.SetInsertionPointEnd()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1016
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1017
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1018 def get_chat_text(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1019 return self.chattxt.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1020
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1021 # This subroutine sets the focus to the chat window
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1022
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1023 def set_chat_text_focus(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1024 wx.CallAfter(self.chattxt.SetFocus)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1025
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1026 def submit_chat_text(self, s):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1027 self.histidx = -1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1028 self.temptext = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1029 self.history = [s] + self.history
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1030
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1031 # play sound
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1032 sound_file = self.settings.get_setting("SendSound")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1033 if sound_file != '': component.get('sound').play(sound_file)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1034 if s[0] != "/": ## it's not a slash command
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1035 s = Parse.Post(s, self, True, True)
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1036 else: self.chat_cmds.docmd(s) # emote is in chatutils.py
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1037
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1038 def on_chat_key_down(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1039 s = self.chattxt.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1040 if event.GetKeyCode() == wx.WXK_RETURN and not event.ShiftDown():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1041 logger.debug("event.GetKeyCode() == wx.WXK_RETURN")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1042 self.set_colors()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1043 if self.session.get_status() == MPLAY_CONNECTED:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1044 self.sendTyping(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1045 if len(s):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1046 self.chattxt.SetValue('')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1047 s = s.replace('\n', '<br />')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1048 self.submit_chat_text(s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1049 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1050 event.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1051
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1052 def OnChar(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1053 s = self.chattxt.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1054
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1055 macroText = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1056 s_key = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1057 if self.f_keys.has_key(event.GetKeyCode()): s_key = self.f_keys[event.GetKeyCode()]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1058
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1059 if s_key: macroText = settings.get(s_key[29:])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1060
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1061 # Append to the existing typed text as needed and make sure the status doesn't change back.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1062 if len(macroText):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1063 self.sendTyping(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1064 self.submit_chat_text(macroText)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1065
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1066 ## UP KEY
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1067 elif event.GetKeyCode() == wx.WXK_UP:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1068 logger.debug("event.GetKeyCode() == wx.WXK_UP")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1069 if self.histidx < len(self.history)-1:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1070 if self.histidx is -1: self.temptext = self.chattxt.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1071 self.histidx += 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1072 self.chattxt.SetValue(self.history[self.histidx])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1073 self.chattxt.SetInsertionPointEnd()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1074 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1075 self.histidx = len(self.history) -1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1076
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1077 ## DOWN KEY
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1078 elif event.GetKeyCode() == wx.WXK_DOWN:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1079 logger.debug("event.GetKeyCode() == wx.WXK_DOWN")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1080 #histidx of -1 indicates currently viewing text that's not in self.history
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1081 if self.histidx > -1:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1082 self.histidx -= 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1083 if self.histidx is -1: #remember, it just decreased
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1084 self.chattxt.SetValue(self.temptext)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1085 else: self.chattxt.SetValue(self.history[self.histidx])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1086 self.chattxt.SetInsertionPointEnd()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1087 else: self.histidx = -1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1088
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1089 ## TAB KEY
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1090 elif event.GetKeyCode() == wx.WXK_TAB:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1091 logger.debug("event.GetKeyCode() == wx.WXK_TAB")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1092 if s !="":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1093 found = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1094 nicks = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1095 testnick = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1096 inlength = len(s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1097 for getnames in self.session.players.keys():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1098 striphtmltag = re.compile ('<[^>]+>*')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1099 testnick = striphtmltag.sub ("", self.session.players[getnames][0])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1100 if string.lower(s) == string.lower(testnick[:inlength]):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1101 found = found + 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1102 nicks[len(nicks):]=[testnick]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1103 if found == 0: ## no nick match
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1104 self.Post(self.colorize(self.syscolor," ** No match found"))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1105 elif found > 1: ## matched more than 1, tell user what matched
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1106 nickstring = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1107 nicklist = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1108 for foundnicks in nicks:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1109 nickstring = nickstring + foundnicks + ", "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1110 nicklist.append(foundnicks)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1111 nickstring = nickstring[:-2]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1112 self.Post(self.colorize(self.syscolor, " ** Multiple matches found: " + nickstring))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1113 # set text to the prefix match between first two matches
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1114 settext = re.match(''.join(map(lambda x: '(%s?)' % x, string.lower(nicklist[0]))), string.lower(nicklist[1])).group()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1115 # run through the rest of the nicks
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1116 for i in nicklist:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1117 settext = re.match(''.join(map(lambda x: '(%s?)' % x, string.lower(i))), string.lower(settext)).group()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1118 if settext:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1119 self.chattxt.SetValue(settext)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1120 self.chattxt.SetInsertionPointEnd()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1121 else: ## put the matched name in the chattxt box
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1122 settext = nicks[0] + ": "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1123 self.chattxt.SetValue(settext)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1124 self.chattxt.SetInsertionPointEnd()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1125 else: ## not online, and no text in chattxt box
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1126 self.Post(self.colorize(self.syscolor, " ** That's the Tab key, Dave"))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1127
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1128 ## PAGE UP
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1129 elif event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1130 logger.debug("event.GetKeyCode() in (wx.WXK_PRIOR, wx.WXK_PAGEUP)")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1131 self.chatwnd.ScrollPages(-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1132 if not self.lockscroll: self.lock_scroll(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1133
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1134 ## PAGE DOWN
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1135 elif event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1136 logger.debug("event.GetKeyCode() in (wx.WXK_NEXT, wx.WXK_PAGEDOWN)")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1137 if not self.lockscroll: self.lock_scroll(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1138 if ((self.chatwnd.GetScrollRange(1)-self.chatwnd.GetScrollPos(1)-self.chatwnd.GetScrollThumb(1) < 30) and self.lockscroll):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1139 self.lock_scroll(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1140 self.chatwnd.ScrollPages(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1141
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1142 ## END
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1143 elif event.GetKeyCode() == wx.WXK_END:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1144 logger.debug("event.GetKeyCode() == wx.WXK_END")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1145 if self.lockscroll:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1146 self.lock_scroll(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1147 self.Post()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1148 event.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1149
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1150 elif event.GetKeyCode() == wx.WXK_RETURN and event.ShiftDown():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1151 st = self.chattxt.GetValue().split('\x0b')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1152 st += '\n'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1153 i = self.chattxt.GetInsertionPoint()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1154 self.chattxt.SetValue(''.join(st))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1155 self.chattxt.SetInsertionPoint(i+1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1156 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1157
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1158 ## NOTHING
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1159 else: event.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1160 logger.debug("Exit chat_panel->OnChar(self, event)")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1161
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1162 def onDieRoll(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1163 """Roll the dice based on the button pressed and the die modifiers entered, if any."""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1164 # Get any die modifiers if they have been entered
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1165 numDie = self.numDieText.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1166 dieMod = self.dieModText.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1167 dieText = numDie
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1168 # Now, apply and roll die mods based on the button that was pressed
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1169 id = evt.GetId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1170 if self.dieIDs.has_key(id): dieText += self.dieIDs[id]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1171 if len(dieMod) and dieMod[0] not in "*/-+": dieMod = "+" + dieMod
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1172 dieText += dieMod
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1173 dieText = "[" + dieText + "]"
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1174 Parse.Post(dieText, self, 1, 1)
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1175 self.chattxt.SetFocus()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1176
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1177 def on_chat_save(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1178 f = wx.FileDialog(self,"Save Chat Buffer",".","","HTM* (*.htm*)|*.htm*|HTML (*.html)|*.html|HTM (*.htm)|*.htm",wx.SAVE)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1179 if f.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1180 file = open(f.GetPath(), "w")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1181 file.write(self.ResetPage() + "</body></html>")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1182 file.close()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1183 f.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1184 os.chdir(dir_struct["home"])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1185
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1186 def ResetPage(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1187 self.set_colors()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1188 buffertext = self.chatwnd.Header() + "\n"
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1189 buffertext += chat_util.strip_body_tags(self.chatwnd.StripHeader()).replace("<br>",
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1190 "<br />").replace('</html>',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1191 '').replace("<br />",
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1192 "<br />\n").replace("\n\n", '')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1193 return buffertext
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1194
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1195 def on_text_color(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1196 hexcolor = self.r_h.do_hex_color_dlg(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1197 if hexcolor != None:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1198 (beg,end) = self.chattxt.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1199 if beg != end:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1200 txt = self.chattxt.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1201 txt = txt[:beg]+self.colorize(hexcolor,txt[beg:end]) +txt[end:]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1202 self.chattxt.SetValue(txt)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1203 self.chattxt.SetInsertionPointEnd()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1204 self.chattxt.SetFocus()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1205 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1206 self.color_button.SetBackgroundColour(hexcolor)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1207 self.mytextcolor = hexcolor
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1208 self.settings.set_setting('mytextcolor',hexcolor)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1209 self.set_colors()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1210 self.Post()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1211
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1212 def colorize(self, color, text):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1213 """Puts font tags of 'color' around 'text' value, and returns the string"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1214 return "<font color='" + color + "'>" + text + "</font>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1215
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1216 def on_text_format(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1217 id = event.GetId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1218 txt = self.chattxt.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1219 (beg,end) = self.chattxt.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1220 if beg != end: sel_txt = txt[beg:end]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1221 else: sel_txt = txt
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1222 if id == self.boldButton.GetId(): sel_txt = "<b>" + sel_txt + "</b>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1223 elif id == self.italicButton.GetId(): sel_txt = "<i>" + sel_txt + "</i>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1224 elif id == self.underlineButton.GetId(): sel_txt = "<u>" + sel_txt + "</u>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1225 if beg != end: txt = txt[:beg] + sel_txt + txt[end:]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1226 else: txt = sel_txt
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1227 self.chattxt.SetValue(txt)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1228 self.chattxt.SetInsertionPointEnd()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1229 self.chattxt.SetFocus()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1230
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1231 def lock_scroll(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1232 if self.lockscroll:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1233 self.lockscroll = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1234 self.scroll_lock.SetLabel("Scroll ON")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1235 if len(self.storedata) != 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1236 for line in self.storedata: self.chatwnd.AppendToPage(line)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1237 self.storedata = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1238 self.scroll_down()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1239 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1240 self.lockscroll = True
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1241 self.scroll_lock.SetLabel("Scroll OFF")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1242
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1243 def pop_textpop(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1244 """searchable popup text view of chatbuffer"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1245 h_buffertext = self.ResetPage()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1246 h_dlg = orpgScrolledMessageFrameEditor(self, h_buffertext, "Text View of Chat Window", None, (500,300))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1247 h_dlg.Show(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1248
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1249 def OnSize(self, event=None):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1250 event.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1251 wx.CallAfter(self.scroll_down)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1252
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1253 def scroll_down(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1254 self.Freeze()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1255 self.chatwnd.scroll_down()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1256 self.Thaw()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1257
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1258 ###### message helpers ######
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1259
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1260 def PurgeChat(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1261 self.set_colors()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1262 self.chatwnd.SetPage(self.chatwnd.Header())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1263
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1264 def system_message(self, text):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1265 self.send_chat_message(text,chat_msg.SYSTEM_MESSAGE)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1266 self.SystemPost(text)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1267
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1268 def info_message(self, text):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1269 self.send_chat_message(text,chat_msg.INFO_MESSAGE)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1270 self.InfoPost(text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1271
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1272 def get_gms(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1273 the_gms = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1274 for playerid in self.session.players:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1275 if len(self.session.players[playerid])>7:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1276 if self.session.players[playerid][7]=="GM" and self.session.group_id != '0': the_gms += [playerid]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1277 return the_gms
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1278
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1279 def GetName(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1280 self.AliasLib = component.get('alias')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1281 player = self.session.get_my_info()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1282 if self.AliasLib != None:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1283 self.AliasLib.alias = self.aliasList.GetStringSelection();
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1284 if self.AliasLib.alias[0] != self.defaultAliasName:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1285 logger.debug("Exit chat_panel->GetName(self)")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1286 return [self.chat_display_name([self.AliasLib.alias[0], player[1], player[2]]), self.AliasLib.alias[1]]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1287 return [self.chat_display_name(player), "Default"]
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1288
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1289 def GetFilteredText(self, text):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1290 advregex = re.compile('\"(.*?)\"', re.I)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1291 self.AliasLib = component.get('alias')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1292 if self.AliasLib != None:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1293 self.AliasLib.filter = self.filterList.GetSelection()-1;
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1294 for rule in self.AliasLib.filterRegEx:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1295 if not self.advancedFilter: text = re.sub(rule[0], rule[1], text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1296 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1297 for m in advregex.finditer(text):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1298 match = m.group(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1299 newmatch = re.sub(rule[0], rule[1], match)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1300 text = text.replace(match, newmatch)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1301 return text
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1302
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1303 def emote_message(self, text):
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1304 text = Parse.Normalize(text, self)
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1305 text = self.colorize(self.emotecolor, text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1306 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(text,chat_msg.EMOTE_MESSAGE)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1307 elif self.type == MAIN_TAB and self.sendtarget == "gm":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1308 msg_type = chat_msg.WHISPER_EMOTE_MESSAGE
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1309 the_gms = self.get_gms()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1310 for each_gm in the_gms: self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(each_gm))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1311 elif self.type == GROUP_TAB and WG_LIST.has_key(self.sendtarget):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1312 for pid in WG_LIST[self.sendtarget]:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1313 self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(pid))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1314 elif self.type == WHISPER_TAB: self.send_chat_message(text,chat_msg.WHISPER_EMOTE_MESSAGE, str(self.sendtarget))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1315 elif self.type == NULL_TAB: pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1316 name = self.GetName()[0]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1317 text = "** " + name + " " + text + " **"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1318 self.EmotePost(text)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1319
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1320 def whisper_to_players(self, text, player_ids):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1321 tabbed_whispers_p = self.settings.get_setting("tabbedwhispers")
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1322 text = Parse.Normalize(text, self)
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1323 player_names = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1324 for m in player_ids:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1325 id = m.strip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1326 if self.session.is_valid_id(id):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1327 returned_name = self.session.get_player_by_player_id(id)[0]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1328 player_names += returned_name
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1329 player_names += ", "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1330 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1331 player_names += " Unknown!"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1332 player_names += ", "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1333 comma = ","
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1334 comma.join(player_ids)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1335 if (self.sendtarget == "all"):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1336 self.InfoPost("<i>whispering to "+ player_names + " " + text + "</i> ")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1337 text = self.colorize(self.mytextcolor, text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1338 for id in player_ids:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1339 id = id.strip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1340 if self.session.is_valid_id(id): self.send_chat_message(text,chat_msg.WHISPER_MESSAGE,id)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1341 else: self.InfoPost(id + " Unknown!")
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1342
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1343
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1344 def send_chat_message(self, text, type=chat_msg.CHAT_MESSAGE, player_id="all"):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1345 #########send_msg()#############
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1346 send = 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1347 for plugin_fname in self.activeplugins.keys():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1348 plugin = self.activeplugins[plugin_fname]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1349 try: text, send = plugin.send_msg(text, send)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1350 except Exception, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1351 if str(e) != "'module' object has no attribute 'send_msg'":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1352 logger.general(traceback.format_exc())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1353 logger.general("EXCEPTION: " + str(e))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1354 msg = chat_msg.chat_msg()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1355 msg.set_text(text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1356 msg.set_type(type)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1357 turnedoff = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1358 if self.settings.get_setting("ShowIDInChat") == "1":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1359 turnedoff = True
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1360 self.settings.set_setting("ShowIDInChat", "0")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1361 playername = self.GetName()[0]
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1362
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1363 if turnedoff: self.settings.set_setting("ShowIDInChat", "1")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1364 msg.set_alias(playername)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1365 if send: self.session.send(msg.toxml(),player_id)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1366 del msg
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1367
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1368 def post_incoming_msg(self, msg, player):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1369 type = msg.get_type()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1370 text = msg.get_text()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1371 alias = msg.get_alias()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1372 # who sent us the message?
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1373 if alias: display_name = self.chat_display_name([alias, player[1], player[2]])
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1374 else: display_name = self.chat_display_name(player)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1375
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1376 ######### START plugin_incoming_msg() ###########
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1377 for plugin_fname in self.activeplugins.keys():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1378 plugin = self.activeplugins[plugin_fname]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1379 try: text, type, name = plugin.plugin_incoming_msg(text, type, display_name, player)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1380 except Exception, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1381 if str(e) != "'module' object has no attribute 'receive_msg'":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1382 logger.general(traceback.format_exc())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1383 logger.general("EXCEPTION: " + str(e))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1384 strip_img = self.settings.get_setting("Show_Images_In_Chat")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1385 if (strip_img == "0"): display_name = chat_util.strip_img_tags(display_name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1386 recvSound = "RecvSound"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1387 # act on the type of messsage
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1388
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1389 if (type == chat_msg.CHAT_MESSAGE):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1390 text = "<b>" + display_name + "</b>: " + text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1391 self.Post(text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1392 self.parent.newMsg(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1393 elif type == chat_msg.WHISPER_MESSAGE or type == chat_msg.WHISPER_EMOTE_MESSAGE:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1394 tabbed_whispers_p = self.settings.get_setting("tabbedwhispers")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1395 displaypanel = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1396 whisperingstring = " (whispering): "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1397 panelexists = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1398 GMWhisperTab = self.settings.get_setting("GMWhisperTab")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1399 GroupWhisperTab = self.settings.get_setting("GroupWhisperTab")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1400 name = '<i><b>' + display_name + '</b>: '
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1401 text += '</i>'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1402 panelexists = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1403 created = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1404 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1405 if GMWhisperTab == '1':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1406 the_gms = self.get_gms()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1407 #Check if whisper if from a GM
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1408 if player[2] in the_gms:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1409 msg = name + ' (GM Whisper:) ' + text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1410 if type == chat_msg.WHISPER_MESSAGE: self.parent.GMChatPanel.Post(msg)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1411 else: self.parent.GMChatPanel.EmotePost("**" + msg + "**")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1412 idx = self.parent.get_tab_index(self.parent.GMChatPanel)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1413 self.parent.newMsg(idx)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1414 panelexists = 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1415 #See if message if from someone in our groups or for a whisper tab we already have
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1416 if not panelexists and GroupWhisperTab == "1":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1417 for panel in self.parent.group_tabs:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1418 if WG_LIST.has_key(panel.sendtarget) and WG_LIST[panel.sendtarget].has_key(int(player[2])):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1419 msg = name + text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1420 if type == chat_msg.WHISPER_MESSAGE: panel.Post(msg)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1421 else: panel.EmotePost("**" + msg + "**")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1422 idx = self.parent.get_tab_index(panel)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1423 self.parent.newMsg(idx)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1424 panelexists = 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1425 break
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1426 if not panelexists and tabbed_whispers_p == "1":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1427 for panel in self.parent.whisper_tabs:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1428 #check for whisper tabs as well, to save the number of loops
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1429 if panel.sendtarget == player[2]:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1430 msg = name + whisperingstring + text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1431 if type == chat_msg.WHISPER_MESSAGE: panel.Post(msg)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1432 else: panel.EmotePost("**" + msg + "**")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1433 idx = self.parent.get_tab_index(panel)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1434 self.parent.newMsg(idx)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1435 panelexists = 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1436 break
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1437 #We did not fint the tab
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1438 if not panelexists:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1439 #If we get here the tab was not found
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1440 if GroupWhisperTab == "1":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1441 for group in WG_LIST.keys():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1442 #Check if this group has the player in it
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1443 if WG_LIST[group].has_key(int(player[2])):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1444 #Yup, post message. Player may be in more then 1 group so continue as well
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1445 panel = self.parent.create_group_tab(group)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1446 msg = name + text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1447 if type == chat_msg.WHISPER_MESSAGE: wx.CallAfter(panel.Post, msg)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1448 else: wx.CallAfter(panel.EmotePost, "**" + msg + "**")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1449 created = 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1450 #Check to see if we should create a whisper tab
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1451 if not created and tabbed_whispers_p == "1":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1452 panel = self.parent.create_whisper_tab(player[2])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1453 msg = name + whisperingstring + text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1454 if type == chat_msg.WHISPER_MESSAGE: wx.CallAfter(panel.Post, msg)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1455 else: wx.CallAfter(panel.EmotePost, "**" + msg + "**")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1456 created = 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1457 #Final check
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1458 if not created:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1459 #No tabs to create, just send the message to the main chat tab
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1460 msg = name + whisperingstring + text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1461 if type == chat_msg.WHISPER_MESSAGE: self.parent.MainChatPanel.Post(msg)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1462 else: self.parent.MainChatPanel.EmotePost("**" + msg + "**")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1463 self.parent.newMsg(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1464 except Exception, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1465 logger.general(traceback.format_exc())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1466 logger.general("EXCEPTION: 'Error in posting whisper message': " + str(e))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1467 elif (type == chat_msg.EMOTE_MESSAGE):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1468 text = "** " + display_name + " " + text + " **"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1469 self.EmotePost(text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1470 self.parent.newMsg(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1471 elif (type == chat_msg.INFO_MESSAGE):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1472 text = "<b>" + display_name + "</b>: " + text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1473 self.InfoPost(text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1474 self.parent.newMsg(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1475 elif (type == chat_msg.SYSTEM_MESSAGE):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1476 text = "<b>" + display_name + "</b>: " + text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1477 self.SystemPost(text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1478 self.parent.newMsg(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1479 # playe sound
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1480 sound_file = self.settings.get_setting(recvSound)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1481 if sound_file != '':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1482 component.get('sound').play(sound_file)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1483
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1484 #### Posting helpers #####
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1485
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1486 def InfoPost(self, s):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1487 self.Post(self.colorize(self.infocolor, s), c='info')
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1488
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1489 def SystemPost(self, s):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1490 self.Post(self.colorize(self.syscolor, s), c='system')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1491
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1492 def EmotePost(self, s):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1493 self.Post(self.colorize(self.emotecolor, s), c='emote')
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1494
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1495 #### Standard Post method #####
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1496
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1497 def Post(self, s="", send=False, myself=False, c='post'):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1498 strip_p = self.settings.get_setting("striphtml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1499 strip_img = self.settings.get_setting("Show_Images_In_Chat")#moved back 7-11-05. --mDuo13
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1500 if (strip_p == "1"): s = strip_html(s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1501 if (strip_img == "0"): s = chat_util.strip_img_tags(s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1502 s = chat_util.simple_html_repair(s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1503 s = chat_util.strip_script_tags(s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1504 s = chat_util.strip_li_tags(s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1505 s = chat_util.strip_body_tags(s) #7-27-05 mDuo13
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 0
diff changeset
1506 s = chat_util.strip_misalignment_tags(s) #7-27-05 mDuo13
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1507 aliasInfo = self.GetName()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1508 display_name = aliasInfo[0]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1509 if aliasInfo[1] != 'Default':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1510 defaultcolor = self.settings.get_setting("mytextcolor")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1511 self.settings.set_setting("mytextcolor", aliasInfo[1])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1512 self.set_colors()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1513 newline = ''
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1514 #following added by mDuo13
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1515 #########post_msg() - other##########
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1516 if not myself and not send:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1517 for plugin_fname in self.activeplugins.keys():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1518 plugin = self.activeplugins[plugin_fname]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1519 try: s = plugin.post_msg(s, myself)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1520 except Exception, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1521 if str(e) != "'module' object has no attribute 'post_msg'":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1522 logger.general(traceback.format_exc())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1523 logger.general("EXCEPTION: " + str(e))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1524 #end mDuo13 added code
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1525 if myself:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1526 name = "<b>" + display_name + "</b>: "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1527 s = self.colorize(self.mytextcolor, s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1528 else: name = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1529 if aliasInfo[1] != 'Default':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1530 self.settings.set_setting("mytextcolor", defaultcolor)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1531 self.set_colors()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1532 lineHasText = 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1533 try: lineHasText = strip_html(s).replace("&nbsp;","").replace(" ","").strip()!=""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1534 except:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1535 lineHasText = 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1536 if lineHasText:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1537 #following added by mDuo13
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1538 if myself:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1539 s2 = s
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1540 ########post_msg() - self #######
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1541 for plugin_fname in self.activeplugins.keys():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1542 plugin = self.activeplugins[plugin_fname]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1543 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1544 s2 = plugin.post_msg(s2, myself)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1545 except Exception, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1546 if str(e) != "'module' object has no attribute 'post_msg'":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1547 logger.general(traceback.format_exc())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1548 logger.general("EXCEPTION: " + str(e))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1549 if s2 != "":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1550 #Italici the messages from tabbed whispers
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1551 if self.type == WHISPER_TAB or self.type == GROUP_TAB or self.sendtarget == 'gm':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1552 s2 = s2 + '</i>'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1553 name = '<i>' + name
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1554 if self.type == WHISPER_TAB: name += " (whispering): "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1555 elif self.type == GROUP_TAB: name += self.settings.get_setting("gwtext") + ' '
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1556 elif self.sendtarget == 'gm': name += " (whispering to GM) "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1557 newline = "<div class='"+c+"'> " + self.TimeIndexString() + name + s2 + "</div>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1558 log( self.settings, c, name+s2 )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1559 else:
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1560 newline = "<div class='"+c+"'> " + self.TimeIndexString() + name + s + "</div>"
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1561 log( self.settings, c, name+s )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1562 else: send = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1563 newline = chat_util.strip_unicode(newline)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1564 if self.lockscroll == 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1565 self.chatwnd.AppendToPage(newline)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1566 self.scroll_down()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1567 else: self.storedata.append(newline)
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 0
diff changeset
1568 if send:
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1569 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(s)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1570 elif self.type == MAIN_TAB and self.sendtarget == "gm":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1571 the_gms = self.get_gms()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1572 self.whisper_to_players(s, the_gms)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1573 elif self.type == GROUP_TAB and WG_LIST.has_key(self.sendtarget):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1574 members = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1575 for pid in WG_LIST[self.sendtarget]: members.append(str(WG_LIST[self.sendtarget][pid]))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1576 self.whisper_to_players(self.settings.get_setting("gwtext") + s, members)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1577 elif self.type == WHISPER_TAB: self.whisper_to_players(s, [self.sendtarget])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1578 elif self.type == NULL_TAB: pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1579 else: self.InfoPost("Failed to send message, unknown send type for this tab")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1580 self.parsed=0
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1581
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1582 def TimeIndexString(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1583 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1584 mtime = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1585 if self.settings.get_setting('Chat_Time_Indexing') == "0": pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1586 elif self.settings.get_setting('Chat_Time_Indexing') == "1":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1587 mtime = time.strftime("[%I:%M:%S] ", time.localtime())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1588 return mtime
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1589 except Exception, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1590 logger.general(traceback.format_exc())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1591 logger.general("EXCEPTION: " + str(e))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1592 return "[ERROR]"
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1593
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1594 # This subroutine builds a chat display name.
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1595 #
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1596 def chat_display_name(self, player):
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1597 if player == None:
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1598 player = ['<b><i><u>Server Administrator</u>-></i></b> ', '127.0.0.1', '0']
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1599 if self.settings.get_setting("ShowIDInChat") == "0": display_name = player[0]
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents: 30
diff changeset
1600 else: display_name = "("+player[2]+") " + player[0]
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1601 return display_name
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1602
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1603 # This subroutine will get a hex color and return it, or return nothing
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1604 #
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1605 def get_color(self):
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1606 data = wx.ColourData()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1607 data.SetChooseFull(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1608 dlg = wx.ColourDialog(self, data)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1609 if dlg.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1610 data = dlg.GetColourData()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1611 (red,green,blue) = data.GetColour().Get()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1612 hexcolor = self.r_h.hexstring(red, green, blue)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1613 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1614 return hexcolor
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1615 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1616 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1617 return None
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1618
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1619 # def get_color - end
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1620 def replace_quotes(self, s):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1621 in_tag = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1622 i = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1623 rs = s[:]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1624 for c in s:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1625 if c == "<": in_tag += 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1626 elif c == ">":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1627 if in_tag: in_tag -= 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1628 elif c == '"':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1629 if in_tag: rs = rs[:i] + "'" + rs[i+1:]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1630 i += 1
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1631 return rs
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 27
diff changeset
1632