Mercurial > traipse_dev
comparison orpg/chat/chatwnd.py @ 129:43ad912b7c17 alpha
Traipse Alpha 'OpenRPG' {091003-01}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for
developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds
fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of
the user.
Update Summary (Cleaning up for Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
Happy Halloween!
author | sirebral |
---|---|
date | Tue, 03 Nov 2009 08:18:46 -0600 |
parents | 217fb049bd00 |
children | d54e1328dbb1 |
comparison
equal
deleted
inserted
replaced
128:fba298d65cf8 | 129:43ad912b7c17 |
---|---|
69 from wx.lib.expando import EVT_ETC_LAYOUT_NEEDED | 69 from wx.lib.expando import EVT_ETC_LAYOUT_NEEDED |
70 | 70 |
71 from orpg.tools.validate import validate | 71 from orpg.tools.validate import validate |
72 from orpg.tools.orpg_settings import settings | 72 from orpg.tools.orpg_settings import settings |
73 from orpg.orpgCore import component | 73 from orpg.orpgCore import component |
74 from orpg.tools.orpg_log import logger | 74 from orpg.tools.orpg_log import logger, debug |
75 from orpg.tools.decorators import debugging | 75 from orpg.tools.decorators import debugging |
76 | |
77 from xml.etree.ElementTree import tostring | |
76 | 78 |
77 NEWCHAT = False | 79 NEWCHAT = False |
78 try: | 80 try: |
79 import wx.webview | 81 import wx.webview |
80 NEWCHAT = True | 82 NEWCHAT = True |
83 | 85 |
84 # Global parser for stripping HTML tags: | 86 # Global parser for stripping HTML tags: |
85 # The 'tag stripping' is implicit, because this parser echoes every | 87 # The 'tag stripping' is implicit, because this parser echoes every |
86 # type of html data *except* the tags. | 88 # type of html data *except* the tags. |
87 class HTMLStripper(HTMLParser): | 89 class HTMLStripper(HTMLParser): |
88 @debugging | 90 |
89 def __init__(self): | 91 def __init__(self): |
90 self.accum = "" | 92 self.accum = "" |
91 self.special_tags = ['hr', 'br', 'img'] | 93 self.special_tags = ['hr', 'br', 'img'] |
92 @debugging | 94 |
93 def handle_data(self, data): # quote cdata literally | 95 def handle_data(self, data): # quote cdata literally |
94 self.accum += data | 96 self.accum += data |
95 @debugging | 97 |
96 def handle_entityref(self, name): # entities must be preserved exactly | 98 def handle_entityref(self, name): # entities must be preserved exactly |
97 self.accum += "&" + name + ";" | 99 self.accum += "&" + name + ";" |
98 @debugging | 100 |
99 def handle_starttag(self, tag, attrs): | 101 def handle_starttag(self, tag, attrs): |
100 if tag in self.special_tags: | 102 if tag in self.special_tags: |
101 self.accum += '<' + tag | 103 self.accum += '<' + tag |
102 for attrib in attrs: self.accum += ' ' + attrib[0] + '="' + attrib[1] + '"' | 104 for attrib in attrs: self.accum += ' ' + attrib[0] + '="' + attrib[1] + '"' |
103 self.accum += '>' | 105 self.accum += '>' |
104 @debugging | 106 |
105 def handle_charref(self, name): # charrefs too | 107 def handle_charref(self, name): # charrefs too |
106 self.accum += "&#" + name + ";" | 108 self.accum += "&#" + name + ";" |
107 htmlstripper = HTMLStripper() | 109 htmlstripper = HTMLStripper() |
108 | 110 |
109 # utility function; see Post(). | 111 # utility function; see Post(). |
110 @debugging | 112 |
111 def strip_html(string): | 113 def strip_html(string): |
112 "Return string tripped of html tags." | 114 "Return string tripped of html tags." |
113 htmlstripper.reset() | 115 htmlstripper.reset() |
114 htmlstripper.accum = "" | 116 htmlstripper.accum = "" |
115 htmlstripper.feed(string) | 117 htmlstripper.feed(string) |
116 htmlstripper.close() | 118 htmlstripper.close() |
117 return htmlstripper.accum | 119 return htmlstripper.accum |
118 | 120 |
119 @debugging | 121 |
120 def log( settings, c, text ): | 122 def log( settings, c, text ): |
121 filename = settings.get_setting('GameLogPrefix') | 123 filename = settings.get_setting('GameLogPrefix') |
122 if filename > '' and filename[0] != commands.ANTI_LOG_CHAR: | 124 if filename > '' and filename[0] != commands.ANTI_LOG_CHAR: |
123 filename = filename + time.strftime( '-%Y-%m-%d.html', time.localtime( time.time() ) ) | 125 filename = filename + time.strftime( '-%Y-%m-%d.html', time.localtime( time.time() ) ) |
124 #filename = time.strftime( filename, time.localtime( time.time() ) ) | 126 #filename = time.strftime( filename, time.localtime( time.time() ) ) |
146 # initialization subroutine | 148 # initialization subroutine |
147 # | 149 # |
148 # !self : instance of self | 150 # !self : instance of self |
149 # !parent : | 151 # !parent : |
150 # !id : | 152 # !id : |
151 @debugging | 153 |
152 def __init__(self, parent, id): | 154 def __init__(self, parent, id): |
153 wx.html.HtmlWindow.__init__(self, parent, id, | 155 wx.html.HtmlWindow.__init__(self, parent, id, |
154 style=wx.SUNKEN_BORDER|wx.html.HW_SCROLLBAR_AUTO|wx.NO_FULL_REPAINT_ON_RESIZE) | 156 style=wx.SUNKEN_BORDER|wx.html.HW_SCROLLBAR_AUTO|wx.NO_FULL_REPAINT_ON_RESIZE) |
155 self.parent = parent | 157 self.parent = parent |
156 self.build_menu() | 158 self.build_menu() |
157 self.Bind(wx.EVT_LEFT_UP, self.LeftUp) | 159 self.Bind(wx.EVT_LEFT_UP, self.LeftUp) |
158 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup) | 160 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup) |
159 if "gtk2" in wx.PlatformInfo: self.SetStandardFonts() | 161 if "gtk2" in wx.PlatformInfo: self.SetStandardFonts() |
160 # def __init__ - end | 162 # def __init__ - end |
161 | 163 |
162 @debugging | 164 |
163 def onPopup(self, evt): | 165 def onPopup(self, evt): |
164 self.PopupMenu(self.menu) | 166 self.PopupMenu(self.menu) |
165 | 167 |
166 @debugging | 168 |
167 def LeftUp(self, event): | 169 def LeftUp(self, event): |
168 event.Skip() | 170 event.Skip() |
169 wx.CallAfter(self.parent.set_chat_text_focus, None) | 171 wx.CallAfter(self.parent.set_chat_text_focus, None) |
170 | 172 |
171 @debugging | 173 |
172 def build_menu(self): | 174 def build_menu(self): |
173 self.menu = wx.Menu() | 175 self.menu = wx.Menu() |
174 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy") | 176 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy") |
175 self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item) | 177 self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item) |
176 self.menu.AppendItem(item) | 178 self.menu.AppendItem(item) |
177 | 179 |
178 @debugging | 180 |
179 def OnM_EditCopy(self, evt): | 181 def OnM_EditCopy(self, evt): |
180 wx.TheClipboard.UsePrimarySelection(False) | 182 wx.TheClipboard.UsePrimarySelection(False) |
181 wx.TheClipboard.Open() | 183 wx.TheClipboard.Open() |
182 wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText())) | 184 wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText())) |
183 wx.TheClipboard.Close() | 185 wx.TheClipboard.Close() |
184 | 186 |
185 @debugging | 187 |
186 def scroll_down(self): | 188 def scroll_down(self): |
187 maxrange = self.GetScrollRange(wx.VERTICAL) | 189 maxrange = self.GetScrollRange(wx.VERTICAL) |
188 pagesize = self.GetScrollPageSize(wx.VERTICAL) | 190 pagesize = self.GetScrollPageSize(wx.VERTICAL) |
189 self.Scroll(-1, maxrange-pagesize) | 191 self.Scroll(-1, maxrange-pagesize) |
190 | 192 |
191 @debugging | 193 |
192 def mouse_wheel(self, event): | 194 def mouse_wheel(self, event): |
193 amt = event.GetWheelRotation() | 195 amt = event.GetWheelRotation() |
194 units = amt/(-(event.GetWheelDelta())) | 196 units = amt/(-(event.GetWheelDelta())) |
195 self.ScrollLines(units*3) | 197 self.ScrollLines(units*3) |
196 | 198 |
197 @debugging | 199 |
198 def Header(self): | 200 def Header(self): |
199 return '<html><body bgcolor="' + self.parent.bgcolor + '" text="' + self.parent.textcolor + '">' | 201 return '<html><body bgcolor="' + self.parent.bgcolor + '" text="' + self.parent.textcolor + '">' |
200 | 202 |
201 @debugging | 203 |
202 def StripHeader(self): | 204 def StripHeader(self): |
203 return self.GetPageSource().replace(self.Header(), '') | 205 return self.GetPageSource().replace(self.Header(), '') |
204 | 206 |
205 @debugging | 207 |
206 def GetPageSource(self): | 208 def GetPageSource(self): |
207 return self.GetParser().GetSource() | 209 return self.GetParser().GetSource() |
208 | 210 |
209 # This subroutine fires up the webbrowser when a link is clicked. | 211 # This subroutine fires up the webbrowser when a link is clicked. |
210 # | 212 # |
211 # !self : instance of self | 213 # !self : instance of self |
212 # !linkinfo : instance of a class that contains the link information | 214 # !linkinfo : instance of a class that contains the link information |
213 @debugging | 215 |
214 def OnLinkClicked(self, linkinfo): | 216 def OnLinkClicked(self, linkinfo): |
215 href = linkinfo.GetHref() | 217 href = linkinfo.GetHref() |
216 wb = webbrowser.get() | 218 wb = webbrowser.get() |
217 wb.open(href) | 219 wb.open(href) |
218 # def OnLinkClicked - end | 220 # def OnLinkClicked - end |
219 | 221 |
220 @debugging | 222 |
221 def CalculateAllFonts(self, defaultsize): | 223 def CalculateAllFonts(self, defaultsize): |
222 return [int(defaultsize * 0.4), | 224 return [int(defaultsize * 0.4), |
223 int(defaultsize * 0.7), | 225 int(defaultsize * 0.7), |
224 int(defaultsize), | 226 int(defaultsize), |
225 int(defaultsize * 1.3), | 227 int(defaultsize * 1.3), |
226 int(defaultsize * 1.7), | 228 int(defaultsize * 1.7), |
227 int(defaultsize * 2), | 229 int(defaultsize * 2), |
228 int(defaultsize * 2.5)] | 230 int(defaultsize * 2.5)] |
229 | 231 |
230 @debugging | 232 |
231 def SetDefaultFontAndSize(self, fontname, fontsize): | 233 def SetDefaultFontAndSize(self, fontname, fontsize): |
232 """Set 'fontname' to the default chat font. | 234 """Set 'fontname' to the default chat font. |
233 Returns current font settings in a (fontname, fontsize) tuple.""" | 235 Returns current font settings in a (fontname, fontsize) tuple.""" |
234 self.SetFonts(fontname, "", self.CalculateAllFonts(int(fontsize))) | 236 self.SetFonts(fontname, "", self.CalculateAllFonts(int(fontsize))) |
235 return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize()) | 237 return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize()) |
236 | 238 |
237 # class chat_html_window - end | 239 # class chat_html_window - end |
238 if NEWCHAT: | 240 if NEWCHAT: |
239 class ChatHtmlWindow(wx.webview.WebView): | 241 class ChatHtmlWindow(wx.webview.WebView): |
240 @debugging | 242 |
241 def __init__(self, parent, id): | 243 def __init__(self, parent, id): |
242 wx.webview.WebView.__init__(self, parent, id) | 244 wx.webview.WebView.__init__(self, parent, id) |
243 self.parent = parent | 245 self.parent = parent |
244 self.__font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName='Ariel') | 246 self.__font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName='Ariel') |
245 self.build_menu() | 247 self.build_menu() |
246 self.Bind(wx.EVT_LEFT_UP, self.LeftUp) | 248 self.Bind(wx.EVT_LEFT_UP, self.LeftUp) |
247 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup) | 249 self.Bind(wx.EVT_RIGHT_DOWN, self.onPopup) |
248 self.Bind(wx.webview.EVT_WEBVIEW_BEFORE_LOAD, self.OnLinkClicked) | 250 self.Bind(wx.webview.EVT_WEBVIEW_BEFORE_LOAD, self.OnLinkClicked) |
249 | 251 |
250 #Wrapers so I dont have to add special Code | 252 #Wrapers so I dont have to add special Code |
251 @debugging | 253 |
252 def SetPage(self, htmlstring): | 254 def SetPage(self, htmlstring): |
253 self.SetPageSource(htmlstring) | 255 self.SetPageSource(htmlstring) |
254 | 256 |
255 @debugging | 257 |
256 def AppendToPage(self, htmlstring): | 258 def AppendToPage(self, htmlstring): |
257 self.SetPageSource(self.GetPageSource() + htmlstring) | 259 self.SetPageSource(self.GetPageSource() + htmlstring) |
258 | 260 |
259 @debugging | 261 |
260 def GetFont(self): | 262 def GetFont(self): |
261 return self.__font | 263 return self.__font |
262 | 264 |
263 @debugging | 265 |
264 def CalculateAllFonts(self, defaultsize): | 266 def CalculateAllFonts(self, defaultsize): |
265 return | 267 return |
266 | 268 |
267 @debugging | 269 |
268 def SetDefaultFontAndSize(self, fontname, fontsize): | 270 def SetDefaultFontAndSize(self, fontname, fontsize): |
269 self.__font = wx.Font(int(fontsize), | 271 self.__font = wx.Font(int(fontsize), |
270 wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, | 272 wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, |
271 wx.FONTWEIGHT_NORMAL, faceName=fontname) | 273 wx.FONTWEIGHT_NORMAL, faceName=fontname) |
272 try: self.SetPageSource(self.Header() + self.StripHeader()) | 274 try: self.SetPageSource(self.Header() + self.StripHeader()) |
273 except Exception, e: print e | 275 except Exception, e: print e |
274 return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize()) | 276 return (self.GetFont().GetFaceName(), self.GetFont().GetPointSize()) |
275 | 277 |
276 #Events | 278 #Events |
277 @debugging | 279 |
278 def OnLinkClicked(self, linkinfo): | 280 def OnLinkClicked(self, linkinfo): |
279 href = linkinfo.GetHref() | 281 href = linkinfo.GetHref() |
280 wb = webbrowser.get() | 282 wb = webbrowser.get() |
281 wb.open(href) | 283 wb.open(href) |
282 | 284 |
283 @debugging | 285 |
284 def onPopup(self, evt): | 286 def onPopup(self, evt): |
285 self.PopupMenu(self.menu) | 287 self.PopupMenu(self.menu) |
286 | 288 |
287 @debugging | 289 |
288 def LeftUp(self, event): | 290 def LeftUp(self, event): |
289 event.Skip() | 291 event.Skip() |
290 wx.CallAfter(self.parent.set_chat_text_focus, None) | 292 wx.CallAfter(self.parent.set_chat_text_focus, None) |
291 | 293 |
292 @debugging | 294 |
293 def OnM_EditCopy(self, evt): | 295 def OnM_EditCopy(self, evt): |
294 wx.TheClipboard.UsePrimarySelection(False) | 296 wx.TheClipboard.UsePrimarySelection(False) |
295 wx.TheClipboard.Open() | 297 wx.TheClipboard.Open() |
296 wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText())) | 298 wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText())) |
297 wx.TheClipboard.Close() | 299 wx.TheClipboard.Close() |
298 | 300 |
299 #Cutom Methods | 301 #Cutom Methods |
300 @debugging | 302 |
301 def Header(self): | 303 def Header(self): |
302 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>" | 304 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>" |
303 | 305 |
304 @debugging | 306 |
305 def StripHeader(self): | 307 def StripHeader(self): |
306 tmp = self.GetPageSource().split('<BODY>') | 308 tmp = self.GetPageSource().split('<BODY>') |
307 if tmp[-1].find('<body>') > -1: tmp = tmp[-1].split('<body>') | 309 if tmp[-1].find('<body>') > -1: tmp = tmp[-1].split('<body>') |
308 return tmp[-1] | 310 return tmp[-1] |
309 | 311 |
310 @debugging | 312 |
311 def build_menu(self): | 313 def build_menu(self): |
312 self.menu = wx.Menu() | 314 self.menu = wx.Menu() |
313 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy") | 315 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy") |
314 self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item) | 316 self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item) |
315 self.menu.AppendItem(item) | 317 self.menu.AppendItem(item) |
316 | 318 |
317 @debugging | 319 |
318 def scroll_down(self): | 320 def scroll_down(self): |
319 maxrange = self.GetScrollRange(wx.VERTICAL) | 321 maxrange = self.GetScrollRange(wx.VERTICAL) |
320 pagesize = self.GetScrollPageSize(wx.VERTICAL) | 322 pagesize = self.GetScrollPageSize(wx.VERTICAL) |
321 self.Scroll(-1, maxrange-pagesize) | 323 self.Scroll(-1, maxrange-pagesize) |
322 | 324 |
323 @debugging | 325 |
324 def mouse_wheel(self, event): | 326 def mouse_wheel(self, event): |
325 amt = event.GetWheelRotation() | 327 amt = event.GetWheelRotation() |
326 units = amt/(-(event.GetWheelDelta())) | 328 units = amt/(-(event.GetWheelDelta())) |
327 self.ScrollLines(units*3) | 329 self.ScrollLines(units*3) |
328 chat_html_window = ChatHtmlWindow | 330 chat_html_window = ChatHtmlWindow |
352 # destroy_private_tab(self, chatpanel) | 354 # destroy_private_tab(self, chatpanel) |
353 # OnPageChanged(self, event) | 355 # OnPageChanged(self, event) |
354 # set_default_font(self, font, fontsize) | 356 # set_default_font(self, font, fontsize) |
355 | 357 |
356 class chat_notebook(orpgTabberWnd): | 358 class chat_notebook(orpgTabberWnd): |
357 @debugging | 359 |
358 def __init__(self, parent, size): | 360 def __init__(self, parent, size): |
359 orpgTabberWnd.__init__(self, parent, True, size=size, | 361 orpgTabberWnd.__init__(self, parent, True, size=size, |
360 style=FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_NO_NAV_BUTTONS|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS) | 362 style=FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_NO_NAV_BUTTONS|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS) |
361 self.settings = component.get("settings") | 363 self.settings = component.get("settings") |
362 self.whisper_tabs = [] | 364 self.whisper_tabs = [] |
384 self.GMChatPanel = None | 386 self.GMChatPanel = None |
385 if self.settings.get_setting("GMWhisperTab") == '1': | 387 if self.settings.get_setting("GMWhisperTab") == '1': |
386 self.create_gm_tab() | 388 self.create_gm_tab() |
387 self.SetSelection(0) | 389 self.SetSelection(0) |
388 | 390 |
389 @debugging | 391 |
390 def get_tab_index(self, chatpanel): | 392 def get_tab_index(self, chatpanel): |
391 "Return the index of a chatpanel in the wxNotebook." | 393 "Return the index of a chatpanel in the wxNotebook." |
392 | 394 |
393 for i in xrange(self.GetPageCount()): | 395 for i in xrange(self.GetPageCount()): |
394 if (self.GetPage(i) == chatpanel): | 396 if (self.GetPage(i) == chatpanel): |
395 return i | 397 return i |
396 | 398 |
397 @debugging | 399 |
398 def create_gm_tab(self): | 400 def create_gm_tab(self): |
399 if self.GMChatPanel == None: | 401 if self.GMChatPanel == None: |
400 self.GMChatPanel = chat_panel(self, -1, MAIN_TAB, 'gm') | 402 self.GMChatPanel = chat_panel(self, -1, MAIN_TAB, 'gm') |
401 self.AddPage(self.GMChatPanel, "GM", False) | 403 self.AddPage(self.GMChatPanel, "GM", False) |
402 self.SetPageImage(self.GetPageCount()-1, 1) | 404 self.SetPageImage(self.GetPageCount()-1, 1) |
403 self.GMChatPanel.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) | 405 self.GMChatPanel.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) |
404 | 406 |
405 @debugging | 407 |
406 def create_whisper_tab(self, playerid): | 408 def create_whisper_tab(self, playerid): |
407 "Add a new chatpanel directly connected to integer 'playerid' via whispering." | 409 "Add a new chatpanel directly connected to integer 'playerid' via whispering." |
408 private_tab = chat_panel(self, -1, WHISPER_TAB, playerid) | 410 private_tab = chat_panel(self, -1, WHISPER_TAB, playerid) |
409 playername = strip_html(self.MainChatPanel.session.get_player_by_player_id(playerid)[0]) | 411 playername = strip_html(self.MainChatPanel.session.get_player_by_player_id(playerid)[0]) |
410 self.AddPage(private_tab, playername, False) | 412 self.AddPage(private_tab, playername, False) |
413 self.newMsg(self.GetPageCount()-1) | 415 self.newMsg(self.GetPageCount()-1) |
414 self.AliasLib = component.get('alias') | 416 self.AliasLib = component.get('alias') |
415 wx.CallAfter(self.AliasLib.RefreshAliases) | 417 wx.CallAfter(self.AliasLib.RefreshAliases) |
416 return private_tab | 418 return private_tab |
417 | 419 |
418 @debugging | 420 |
419 def create_group_tab(self, group_name): | 421 def create_group_tab(self, group_name): |
420 "Add a new chatpanel directly connected to integer 'playerid' via whispering." | 422 "Add a new chatpanel directly connected to integer 'playerid' via whispering." |
421 private_tab = chat_panel(self, -1, GROUP_TAB, group_name) | 423 private_tab = chat_panel(self, -1, GROUP_TAB, group_name) |
422 self.AddPage(private_tab, group_name, False) | 424 self.AddPage(private_tab, group_name, False) |
423 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) | 425 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) |
425 self.newMsg(self.GetPageCount()-1) | 427 self.newMsg(self.GetPageCount()-1) |
426 self.AliasLib = component.get('alias') | 428 self.AliasLib = component.get('alias') |
427 wx.CallAfter(self.AliasLib.RefreshAliases) | 429 wx.CallAfter(self.AliasLib.RefreshAliases) |
428 return private_tab | 430 return private_tab |
429 | 431 |
430 @debugging | 432 |
431 def create_null_tab(self, tab_name): | 433 def create_null_tab(self, tab_name): |
432 "Add a new chatpanel directly connected to integer 'playerid' via whispering." | 434 "Add a new chatpanel directly connected to integer 'playerid' via whispering." |
433 private_tab = chat_panel(self, -1, NULL_TAB, tab_name) | 435 private_tab = chat_panel(self, -1, NULL_TAB, tab_name) |
434 self.AddPage(private_tab, tab_name, False) | 436 self.AddPage(private_tab, tab_name, False) |
435 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) | 437 private_tab.chatwnd.SetDefaultFontAndSize(self.font, self.fontsize) |
437 self.newMsg(self.GetPageCount()-1) | 439 self.newMsg(self.GetPageCount()-1) |
438 self.AliasLib = component.get('alias') | 440 self.AliasLib = component.get('alias') |
439 wx.CallAfter(self.AliasLib.RefreshAliases) | 441 wx.CallAfter(self.AliasLib.RefreshAliases) |
440 return private_tab | 442 return private_tab |
441 | 443 |
442 @debugging | 444 |
443 def onCloseTab(self, evt): | 445 def onCloseTab(self, evt): |
444 try: tabid = evt.GetSelection() | 446 try: tabid = evt.GetSelection() |
445 except: tabid = self.GetSelection() | 447 except: tabid = self.GetSelection() |
446 | 448 |
447 if self.GetPageText(tabid) == 'Main Room': | 449 if self.GetPageText(tabid) == 'Main Room': |
466 panel = self.GetPage(tabid) | 468 panel = self.GetPage(tabid) |
467 if panel in self.whisper_tabs: self.whisper_tabs.remove(panel) | 469 if panel in self.whisper_tabs: self.whisper_tabs.remove(panel) |
468 elif panel in self.group_tabs: self.group_tabs.remove(panel) | 470 elif panel in self.group_tabs: self.group_tabs.remove(panel) |
469 elif panel in self.null_tabs: self.null_tabs.remove(panel) | 471 elif panel in self.null_tabs: self.null_tabs.remove(panel) |
470 | 472 |
471 @debugging | 473 |
472 def newMsg(self, tabid): | 474 def newMsg(self, tabid): |
473 if tabid != self.GetSelection(): self.SetPageImage(tabid, 0) | 475 if tabid != self.GetSelection(): self.SetPageImage(tabid, 0) |
474 | 476 |
475 @debugging | 477 |
476 def onPageChanging(self, event): | 478 def onPageChanging(self, event): |
477 """When private chattabs are selected, set the bitmap back to 'normal'.""" | 479 """When private chattabs are selected, set the bitmap back to 'normal'.""" |
478 event.Skip() | 480 event.Skip() |
479 | 481 |
480 @debugging | 482 |
481 def onPageChanged(self, event): | 483 def onPageChanged(self, event): |
482 """When private chattabs are selected, set the bitmap back to 'normal'.""" | 484 """When private chattabs are selected, set the bitmap back to 'normal'.""" |
483 selected_idx = event.GetSelection() | 485 selected_idx = event.GetSelection() |
484 self.SetPageImage(selected_idx, 1) | 486 self.SetPageImage(selected_idx, 1) |
485 page = self.GetPage(selected_idx) | 487 page = self.GetPage(selected_idx) |
525 !id : | 527 !id : |
526 !openrpg : | 528 !openrpg : |
527 !sendtarget: who gets outbound messages: either 'all' or a playerid | 529 !sendtarget: who gets outbound messages: either 'all' or a playerid |
528 """ | 530 """ |
529 | 531 |
530 @debugging | 532 |
531 def __init__(self, parent, id, tab_type, sendtarget): | 533 def __init__(self, parent, id, tab_type, sendtarget): |
532 wx.Panel.__init__(self, parent, id) | 534 wx.Panel.__init__(self, parent, id) |
533 logger._set_log_to_console(False) | 535 logger._set_log_to_console(False) |
534 self.session = component.get('session') | 536 self.session = component.get('session') |
535 self.settings = component.get('settings') | 537 self.settings = component.get('settings') |
572 except: pass | 574 except: pass |
573 self.font = self.chatwnd.GetFont().GetFaceName() | 575 self.font = self.chatwnd.GetFont().GetFaceName() |
574 self.fontsize = self.chatwnd.GetFont().GetPointSize() | 576 self.fontsize = self.chatwnd.GetFont().GetPointSize() |
575 self.scroll_down() | 577 self.scroll_down() |
576 | 578 |
577 @debugging | 579 |
578 def set_default_font(self, fontname=None, fontsize=None): | 580 def set_default_font(self, fontname=None, fontsize=None): |
579 """Set all chatpanels to new default fontname/fontsize. | 581 """Set all chatpanels to new default fontname/fontsize. |
580 Returns current font settings in a (fontname, fontsize) tuple.""" | 582 Returns current font settings in a (fontname, fontsize) tuple.""" |
581 if (fontname is not None): newfont = fontname | 583 if (fontname is not None): newfont = fontname |
582 else: newfont = self.font | 584 else: newfont = self.font |
586 self.InfoPost("Font is now " + newfont + " point size " + `newfontsize`) | 588 self.InfoPost("Font is now " + newfont + " point size " + `newfontsize`) |
587 self.font = newfont | 589 self.font = newfont |
588 self.fontsize = newfontsize | 590 self.fontsize = newfontsize |
589 return (self.font, self.fontsize) | 591 return (self.font, self.fontsize) |
590 | 592 |
591 @debugging | 593 |
592 def build_menu(self): | 594 def build_menu(self): |
593 top_frame = component.get('frame') | 595 top_frame = component.get('frame') |
594 menu = wx.Menu() | 596 menu = wx.Menu() |
595 item = wx.MenuItem(menu, wx.ID_ANY, "&Background color", "Background color") | 597 item = wx.MenuItem(menu, wx.ID_ANY, "&Background color", "Background color") |
596 top_frame.Bind(wx.EVT_MENU, self.OnMB_BackgroundColor, item) | 598 top_frame.Bind(wx.EVT_MENU, self.OnMB_BackgroundColor, item) |
678 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tool Bars', toolmenu) | 680 settingmenu.AppendMenu(wx.ID_ANY, 'Chat Tool Bars', toolmenu) |
679 menu.AppendMenu(wx.ID_ANY, 'Chat Settings', settingmenu) | 681 menu.AppendMenu(wx.ID_ANY, 'Chat Settings', settingmenu) |
680 top_frame.mainmenu.Insert(2, menu, '&Chat') | 682 top_frame.mainmenu.Insert(2, menu, '&Chat') |
681 | 683 |
682 ## Settings Menu Events | 684 ## Settings Menu Events |
683 @debugging | 685 |
684 def OnMB_ShowImages(self, event): | 686 def OnMB_ShowImages(self, event): |
685 if event.IsChecked(): self.settings.set_setting("Show_Images_In_Chat", '1') | 687 if event.IsChecked(): self.settings.set_setting("Show_Images_In_Chat", '1') |
686 else: self.settings.set_setting("Show_Images_In_Chat", '0') | 688 else: self.settings.set_setting("Show_Images_In_Chat", '0') |
687 | 689 |
688 @debugging | 690 |
689 def OnMB_StripHTML(self, event): | 691 def OnMB_StripHTML(self, event): |
690 if event.IsChecked(): self.settings.set_setting("Sstriphtml", '1') | 692 if event.IsChecked(): self.settings.set_setting("Sstriphtml", '1') |
691 else: self.settings.set_setting("striphtml", '0') | 693 else: self.settings.set_setting("striphtml", '0') |
692 | 694 |
693 @debugging | 695 |
694 def OnMB_ChatTimeIndex(self, event): | 696 def OnMB_ChatTimeIndex(self, event): |
695 if event.IsChecked(): self.settings.set_setting("Chat_Time_Indexing", '1') | 697 if event.IsChecked(): self.settings.set_setting("Chat_Time_Indexing", '1') |
696 else: self.settings.set_setting("Chat_Time_Indexing", '0') | 698 else: self.settings.set_setting("Chat_Time_Indexing", '0') |
697 | 699 |
698 @debugging | 700 |
699 def OnMB_ChatAutoComplete(self, event): | 701 def OnMB_ChatAutoComplete(self, event): |
700 if event.IsChecked(): self.settings.set_setting("SuppressChatAutoComplete", '0') | 702 if event.IsChecked(): self.settings.set_setting("SuppressChatAutoComplete", '0') |
701 else: self.settings.set_setting("SuppressChatAutoComplete", '1') | 703 else: self.settings.set_setting("SuppressChatAutoComplete", '1') |
702 | 704 |
703 @debugging | 705 |
704 def OnMB_ShowIDinChat(self, event): | 706 def OnMB_ShowIDinChat(self, event): |
705 if event.IsChecked(): self.settings.set_setting("ShowIDInChat", '1') | 707 if event.IsChecked(): self.settings.set_setting("ShowIDInChat", '1') |
706 else: self.settings.set_setting("ShowIDInChat", '0') | 708 else: self.settings.set_setting("ShowIDInChat", '0') |
707 | 709 |
708 @debugging | 710 |
709 def OnMB_LogTimeIndex(self, event): | 711 def OnMB_LogTimeIndex(self, event): |
710 if event.IsChecked(): self.settings.set_setting("TimeStampGameLog", '1') | 712 if event.IsChecked(): self.settings.set_setting("TimeStampGameLog", '1') |
711 else: self.settings.set_setting("TimeStampGameLog", '0') | 713 else: self.settings.set_setting("TimeStampGameLog", '0') |
712 | 714 |
713 @debugging | 715 |
714 def OnMB_TabbedWhispers(self, event): | 716 def OnMB_TabbedWhispers(self, event): |
715 if event.IsChecked(): self.settings.set_setting("tabbedwhispers", '1') | 717 if event.IsChecked(): self.settings.set_setting("tabbedwhispers", '1') |
716 else: self.settings.set_setting("tabbedwhispers", '0') | 718 else: self.settings.set_setting("tabbedwhispers", '0') |
717 | 719 |
718 @debugging | 720 |
719 def OnMB_GMTab(self, event): | 721 def OnMB_GMTab(self, event): |
720 if event.IsChecked(): | 722 if event.IsChecked(): |
721 self.settings.set_setting("GMWhisperTab", '1') | 723 self.settings.set_setting("GMWhisperTab", '1') |
722 self.parent.create_gm_tab() | 724 self.parent.create_gm_tab() |
723 else: self.settings.set_setting("GMWhisperTab", '0') | 725 else: self.settings.set_setting("GMWhisperTab", '0') |
724 | 726 |
725 @debugging | 727 |
726 def OnMB_GroupWhisperTabs(self, event): | 728 def OnMB_GroupWhisperTabs(self, event): |
727 if event.IsChecked(): self.settings.set_setting("GroupWhisperTab", '1') | 729 if event.IsChecked(): self.settings.set_setting("GroupWhisperTab", '1') |
728 else: self.settings.set_setting("GroupWhisperTab", '0') | 730 else: self.settings.set_setting("GroupWhisperTab", '0') |
729 | 731 |
730 @debugging | 732 |
731 def OnMB_DiceBar(self, event): | 733 def OnMB_DiceBar(self, event): |
732 act = '0' | 734 act = '0' |
733 if event.IsChecked(): | 735 if event.IsChecked(): |
734 self.settings.set_setting("DiceButtons_On", '1') | 736 self.settings.set_setting("DiceButtons_On", '1') |
735 act = '1' | 737 act = '1' |
739 except: pass | 741 except: pass |
740 for panel in self.parent.whisper_tabs: panel.toggle_dice(act) | 742 for panel in self.parent.whisper_tabs: panel.toggle_dice(act) |
741 for panel in self.parent.group_tabs: panel.toggle_dice(act) | 743 for panel in self.parent.group_tabs: panel.toggle_dice(act) |
742 for panel in self.parent.null_tabs: panel.toggle_dice(act) | 744 for panel in self.parent.null_tabs: panel.toggle_dice(act) |
743 | 745 |
744 @debugging | 746 |
745 def OnMB_FormatButtons(self, event): | 747 def OnMB_FormatButtons(self, event): |
746 act = '0' | 748 act = '0' |
747 if event.IsChecked(): | 749 if event.IsChecked(): |
748 self.settings.set_setting("FormattingButtons_On", '1') | 750 self.settings.set_setting("FormattingButtons_On", '1') |
749 act = '1' | 751 act = '1' |
754 except: pass | 756 except: pass |
755 for panel in self.parent.whisper_tabs: panel.toggle_formating(act) | 757 for panel in self.parent.whisper_tabs: panel.toggle_formating(act) |
756 for panel in self.parent.group_tabs: panel.toggle_formating(act) | 758 for panel in self.parent.group_tabs: panel.toggle_formating(act) |
757 for panel in self.parent.null_tabs: panel.toggle_formating(act) | 759 for panel in self.parent.null_tabs: panel.toggle_formating(act) |
758 | 760 |
759 @debugging | 761 |
760 def OnMB_AliasTool(self, event): | 762 def OnMB_AliasTool(self, event): |
761 act = '0' | 763 act = '0' |
762 if event.IsChecked(): | 764 if event.IsChecked(): |
763 self.settings.set_setting("AliasTool_On", '1') | 765 self.settings.set_setting("AliasTool_On", '1') |
764 act = '1' | 766 act = '1' |
768 except: pass | 770 except: pass |
769 for panel in self.parent.whisper_tabs: panel.toggle_alias(act) | 771 for panel in self.parent.whisper_tabs: panel.toggle_alias(act) |
770 for panel in self.parent.group_tabs: panel.toggle_alias(act) | 772 for panel in self.parent.group_tabs: panel.toggle_alias(act) |
771 for panel in self.parent.null_tabs:panel.toggle_alias(act) | 773 for panel in self.parent.null_tabs:panel.toggle_alias(act) |
772 | 774 |
773 @debugging | 775 |
774 def OnMB_BackgroundColor(self, event): | 776 def OnMB_BackgroundColor(self, event): |
775 top_frame = component.get('frame') | 777 top_frame = component.get('frame') |
776 hexcolor = self.get_color() | 778 hexcolor = self.get_color() |
777 if hexcolor != None: | 779 if hexcolor != None: |
778 self.bgcolor = hexcolor | 780 self.bgcolor = hexcolor |
790 top_frame.players.SetBackgroundColour('white') | 792 top_frame.players.SetBackgroundColour('white') |
791 top_frame.players.SetForegroundColour('black') | 793 top_frame.players.SetForegroundColour('black') |
792 top_frame.players.Refresh() | 794 top_frame.players.Refresh() |
793 self.chatwnd.scroll_down() | 795 self.chatwnd.scroll_down() |
794 | 796 |
795 @debugging | 797 |
796 def OnMB_TextColor(self, event): | 798 def OnMB_TextColor(self, event): |
797 top_frame = component.get('frame') | 799 top_frame = component.get('frame') |
798 hexcolor = self.get_color() | 800 hexcolor = self.get_color() |
799 if hexcolor != None: | 801 if hexcolor != None: |
800 self.textcolor = hexcolor | 802 self.textcolor = hexcolor |
812 top_frame.players.SetBackgroundColour('white') | 814 top_frame.players.SetBackgroundColour('white') |
813 top_frame.players.SetForegroundColour('black') | 815 top_frame.players.SetForegroundColour('black') |
814 top_frame.players.Refresh() | 816 top_frame.players.Refresh() |
815 self.chatwnd.scroll_down() | 817 self.chatwnd.scroll_down() |
816 | 818 |
817 @debugging | 819 |
818 def get_hot_keys(self): | 820 def get_hot_keys(self): |
819 # dummy menus for hotkeys | 821 # dummy menus for hotkeys |
820 self.build_menu() | 822 self.build_menu() |
821 entries = [] | 823 entries = [] |
822 entries.append((wx.ACCEL_CTRL, ord('H'), self.setChatFocusMenu.GetId())) | 824 entries.append((wx.ACCEL_CTRL, ord('H'), self.setChatFocusMenu.GetId())) |
823 #entries.append((wx.ACCEL_CTRL, wx.WXK_TAB, SWAP_TABS)) | 825 #entries.append((wx.ACCEL_CTRL, wx.WXK_TAB, SWAP_TABS)) |
824 return entries | 826 return entries |
825 | 827 |
826 @debugging | 828 |
827 def forward_tabs(self, evt): | 829 def forward_tabs(self, evt): |
828 self.parent.AdvanceSelection() | 830 self.parent.AdvanceSelection() |
829 | 831 |
830 def back_tabs(self, evt): | 832 def back_tabs(self, evt): |
831 self.parent.AdvanceSelection(False) | 833 self.parent.AdvanceSelection(False) |
832 | 834 |
833 # This subroutine builds the controls for the chat frame | 835 # This subroutine builds the controls for the chat frame |
834 # | 836 # |
835 # !self : instance of self | 837 # !self : instance of self |
836 @debugging | 838 |
837 def build_ctrls(self): | 839 def build_ctrls(self): |
838 self.chatwnd = chat_html_window(self,-1) | 840 self.chatwnd = chat_html_window(self,-1) |
839 self.set_colors() | 841 self.set_colors() |
840 wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header()) | 842 wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header()) |
841 if (self.sendtarget == "all"): | 843 if (self.sendtarget == "all"): |
879 self.chattxt.Bind(wx.EVT_MOUSEWHEEL, self.chatwnd.mouse_wheel) | 881 self.chattxt.Bind(wx.EVT_MOUSEWHEEL, self.chatwnd.mouse_wheel) |
880 self.chattxt.Bind(wx.EVT_CHAR, self.chattxt.OnChar) | 882 self.chattxt.Bind(wx.EVT_CHAR, self.chattxt.OnChar) |
881 self.chattxt.Bind(wx.EVT_TEXT_COPY, self.chatwnd.OnM_EditCopy) | 883 self.chattxt.Bind(wx.EVT_TEXT_COPY, self.chatwnd.OnM_EditCopy) |
882 # def build_ctrls - end | 884 # def build_ctrls - end |
883 | 885 |
884 @debugging | 886 |
885 def build_bar(self): | 887 def build_bar(self): |
886 self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL) | 888 self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL) |
887 self.scroll_lock = None | 889 self.scroll_lock = None |
888 self.numDieText = None | 890 self.numDieText = None |
889 self.dieModText = None | 891 self.dieModText = None |
895 self.toolbar_sizer.Add( self.textpop_lock, 0, wx.EXPAND ) | 897 self.toolbar_sizer.Add( self.textpop_lock, 0, wx.EXPAND ) |
896 self.toolbar_sizer.Add(self.scroll_lock,0,wx.EXPAND) | 898 self.toolbar_sizer.Add(self.scroll_lock,0,wx.EXPAND) |
897 self.build_formating() | 899 self.build_formating() |
898 self.build_colorbutton() | 900 self.build_colorbutton() |
899 | 901 |
900 @debugging | 902 |
901 def build_scroll(self): | 903 def build_scroll(self): |
902 self.scroll_lock = wx.Button( self, wx.ID_ANY, "Scroll ON",size= wx.Size(80,25)) | 904 self.scroll_lock = wx.Button( self, wx.ID_ANY, "Scroll ON",size= wx.Size(80,25)) |
903 | 905 |
904 @debugging | 906 |
905 def build_alias(self): | 907 def build_alias(self): |
906 self.aliasList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultAliasName]) | 908 self.aliasList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultAliasName]) |
907 self.aliasButton = createMaskedButton( self, dir_struct["icon"] + 'player.gif', | 909 self.aliasButton = createMaskedButton( self, dir_struct["icon"] + 'player.gif', |
908 'Refresh list of aliases from Game Tree', wx.ID_ANY, '#bdbdbd' ) | 910 'Refresh list of aliases from Game Tree', wx.ID_ANY, '#bdbdbd' ) |
909 self.aliasList.SetSelection(0) | 911 self.aliasList.SetSelection(0) |
916 self.toolbar_sizer.Add( self.filterButton, 0, wx.EXPAND ) | 918 self.toolbar_sizer.Add( self.filterButton, 0, wx.EXPAND ) |
917 self.toolbar_sizer.Add( self.filterList,0,wx.EXPAND) | 919 self.toolbar_sizer.Add( self.filterList,0,wx.EXPAND) |
918 if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0') | 920 if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0') |
919 else: self.toggle_alias('1') | 921 else: self.toggle_alias('1') |
920 | 922 |
921 @debugging | 923 |
922 def toggle_alias(self, act): | 924 def toggle_alias(self, act): |
923 if act == '0': | 925 if act == '0': |
924 self.toolbar_sizer.Show(self.aliasList, False) | 926 self.toolbar_sizer.Show(self.aliasList, False) |
925 self.toolbar_sizer.Show(self.filterList, False) | 927 self.toolbar_sizer.Show(self.filterList, False) |
926 self.toolbar_sizer.Show(self.aliasButton, False) | 928 self.toolbar_sizer.Show(self.aliasButton, False) |
931 self.toolbar_sizer.Show(self.filterList, True) | 933 self.toolbar_sizer.Show(self.filterList, True) |
932 self.toolbar_sizer.Show(self.aliasButton, True) | 934 self.toolbar_sizer.Show(self.aliasButton, True) |
933 self.toolbar_sizer.Show(self.filterButton, True) | 935 self.toolbar_sizer.Show(self.filterButton, True) |
934 self.toolbar_sizer.Layout() | 936 self.toolbar_sizer.Layout() |
935 | 937 |
936 @debugging | 938 |
937 def build_text(self): | 939 def build_text(self): |
938 self.textpop_lock = createMaskedButton(self, dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd') | 940 self.textpop_lock = createMaskedButton(self, dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd') |
939 | 941 |
940 @debugging | 942 |
941 def build_dice(self): | 943 def build_dice(self): |
942 self.numDieText = wx.TextCtrl( self, wx.ID_ANY, "1", size= wx.Size(25, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) | 944 self.numDieText = wx.TextCtrl( self, wx.ID_ANY, "1", size= wx.Size(25, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) |
943 self.dieModText = wx.TextCtrl( self, wx.ID_ANY, "", size= wx.Size(50, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) | 945 self.dieModText = wx.TextCtrl( self, wx.ID_ANY, "", size= wx.Size(50, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) |
944 self.d4Button = createMaskedButton(self, dir_struct["icon"]+'b_d4.gif', 'Roll d4', wx.ID_ANY) | 946 self.d4Button = createMaskedButton(self, dir_struct["icon"]+'b_d4.gif', 'Roll d4', wx.ID_ANY) |
945 self.d6Button = createMaskedButton(self, dir_struct["icon"]+'b_d6.gif', 'Roll d6', wx.ID_ANY) | 947 self.d6Button = createMaskedButton(self, dir_struct["icon"]+'b_d6.gif', 'Roll d6', wx.ID_ANY) |
958 self.toolbar_sizer.Add( self.d100Button, 0 ,wx.EXPAND) | 960 self.toolbar_sizer.Add( self.d100Button, 0 ,wx.EXPAND) |
959 self.toolbar_sizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 ) | 961 self.toolbar_sizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 ) |
960 if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0') | 962 if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0') |
961 else: self.toggle_dice('1') | 963 else: self.toggle_dice('1') |
962 | 964 |
963 @debugging | 965 |
964 def toggle_dice(self, act): | 966 def toggle_dice(self, act): |
965 if act == '0': | 967 if act == '0': |
966 self.toolbar_sizer.Show(self.numDieText, False) | 968 self.toolbar_sizer.Show(self.numDieText, False) |
967 self.toolbar_sizer.Show(self.d4Button, False) | 969 self.toolbar_sizer.Show(self.d4Button, False) |
968 self.toolbar_sizer.Show(self.d6Button, False) | 970 self.toolbar_sizer.Show(self.d6Button, False) |
983 self.toolbar_sizer.Show(self.d20Button, True) | 985 self.toolbar_sizer.Show(self.d20Button, True) |
984 self.toolbar_sizer.Show(self.d100Button, True) | 986 self.toolbar_sizer.Show(self.d100Button, True) |
985 self.toolbar_sizer.Show(self.dieModText, True) | 987 self.toolbar_sizer.Show(self.dieModText, True) |
986 self.toolbar_sizer.Layout() | 988 self.toolbar_sizer.Layout() |
987 | 989 |
988 @debugging | 990 |
989 def build_formating(self): | 991 def build_formating(self): |
990 self.boldButton = createMaskedButton( self, dir_struct["icon"]+'bold.gif', | 992 self.boldButton = createMaskedButton( self, dir_struct["icon"]+'bold.gif', |
991 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd') | 993 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd') |
992 self.italicButton = createMaskedButton( self, dir_struct["icon"]+'italic.gif', | 994 self.italicButton = createMaskedButton( self, dir_struct["icon"]+'italic.gif', |
993 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' ) | 995 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' ) |
997 self.toolbar_sizer.Add( self.italicButton, 0, wx.EXPAND ) | 999 self.toolbar_sizer.Add( self.italicButton, 0, wx.EXPAND ) |
998 self.toolbar_sizer.Add( self.underlineButton, 0, wx.EXPAND ) | 1000 self.toolbar_sizer.Add( self.underlineButton, 0, wx.EXPAND ) |
999 if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0') | 1001 if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0') |
1000 else: self.toggle_formating('1') | 1002 else: self.toggle_formating('1') |
1001 | 1003 |
1002 @debugging | 1004 |
1003 def toggle_formating(self, act): | 1005 def toggle_formating(self, act): |
1004 if act == '0': | 1006 if act == '0': |
1005 self.toolbar_sizer.Show(self.boldButton, False) | 1007 self.toolbar_sizer.Show(self.boldButton, False) |
1006 self.toolbar_sizer.Show(self.italicButton, False) | 1008 self.toolbar_sizer.Show(self.italicButton, False) |
1007 self.toolbar_sizer.Show(self.underlineButton, False) | 1009 self.toolbar_sizer.Show(self.underlineButton, False) |
1011 self.toolbar_sizer.Show(self.italicButton, True) | 1013 self.toolbar_sizer.Show(self.italicButton, True) |
1012 self.toolbar_sizer.Show(self.underlineButton, True) | 1014 self.toolbar_sizer.Show(self.underlineButton, True) |
1013 self.toolbar_sizer.Layout() | 1015 self.toolbar_sizer.Layout() |
1014 | 1016 |
1015 # Heroman - Ideally, we would use static labels... | 1017 # Heroman - Ideally, we would use static labels... |
1016 @debugging | 1018 |
1017 def build_colorbutton(self): | 1019 def build_colorbutton(self): |
1018 self.color_button = createMaskedButton(self, dir_struct["icon"]+'textcolor.gif', | 1020 self.color_button = createMaskedButton(self, dir_struct["icon"]+'textcolor.gif', |
1019 'Text Color', wx.ID_ANY, '#bdbdbd', | 1021 'Text Color', wx.ID_ANY, '#bdbdbd', |
1020 wx.BITMAP_TYPE_GIF) | 1022 wx.BITMAP_TYPE_GIF) |
1021 | 1023 |
1024 '#c0c0c0', wx.BITMAP_TYPE_BMP ) | 1026 '#c0c0c0', wx.BITMAP_TYPE_BMP ) |
1025 self.color_button.SetBackgroundColour(self.settings.get_setting('mytextcolor')) | 1027 self.color_button.SetBackgroundColour(self.settings.get_setting('mytextcolor')) |
1026 self.toolbar_sizer.Add(self.color_button, 0, wx.EXPAND) | 1028 self.toolbar_sizer.Add(self.color_button, 0, wx.EXPAND) |
1027 self.toolbar_sizer.Add(self.saveButton, 0, wx.EXPAND) | 1029 self.toolbar_sizer.Add(self.saveButton, 0, wx.EXPAND) |
1028 | 1030 |
1029 @debugging | 1031 |
1030 def OnMotion(self, evt): | 1032 def OnMotion(self, evt): |
1031 contain = self.chatwnd.GetInternalRepresentation() | 1033 contain = self.chatwnd.GetInternalRepresentation() |
1032 if contain: | 1034 if contain: |
1033 sx = sy = 0 | 1035 sx = sy = 0 |
1034 x = y = 0 | 1036 x = y = 0 |
1050 # It checks if we need to send a typing message | 1052 # It checks if we need to send a typing message |
1051 | 1053 |
1052 # | 1054 # |
1053 # self: duh | 1055 # self: duh |
1054 # event: raw KeyEvent from OnChar() | 1056 # event: raw KeyEvent from OnChar() |
1055 @debugging | 1057 |
1056 def myKeyHook(self, event): | 1058 def myKeyHook(self, event): |
1057 if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected | 1059 if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected |
1058 thisPress = time.time() # thisPress is local temp variable | 1060 thisPress = time.time() # thisPress is local temp variable |
1059 if (thisPress - self.lastSend) > 4: # Check to see if it's been 5 seconds since our last notice | 1061 if (thisPress - self.lastSend) > 4: # Check to see if it's been 5 seconds since our last notice |
1060 # If we're not already typing, then self.lastSend will be 0 | 1062 # If we're not already typing, then self.lastSend will be 0 |
1070 | 1072 |
1071 # This subroutine gets called once a second by the typing Timer | 1073 # This subroutine gets called once a second by the typing Timer |
1072 # It checks if we need to send a not_typing message | 1074 # It checks if we need to send a not_typing message |
1073 # | 1075 # |
1074 # self: duh | 1076 # self: duh |
1075 @debugging | 1077 |
1076 def typingTimerFunc(self, event): | 1078 def typingTimerFunc(self, event): |
1077 #following added by mDuo13 | 1079 #following added by mDuo13 |
1078 ##############refresh_counter()############## | 1080 ##############refresh_counter()############## |
1079 for plugin_fname in self.activeplugins.keys(): | 1081 for plugin_fname in self.activeplugins.keys(): |
1080 plugin = self.activeplugins[plugin_fname] | 1082 plugin = self.activeplugins[plugin_fname] |
1093 # This subroutine actually takes care of sending the messages for typing/not_typing events | 1095 # This subroutine actually takes care of sending the messages for typing/not_typing events |
1094 # | 1096 # |
1095 # self: duh | 1097 # self: duh |
1096 # typing: boolean | 1098 # typing: boolean |
1097 | 1099 |
1098 @debugging | 1100 |
1099 def sendTyping(self, typing): | 1101 def sendTyping(self, typing): |
1100 if typing: | 1102 if typing: |
1101 self.lastSend = time.time() # remember our send time for use in myKeyHook() | 1103 self.lastSend = time.time() # remember our send time for use in myKeyHook() |
1102 #I think this is cleaner | 1104 #I think this is cleaner |
1103 status_text = self.settings.get_setting('TypingStatusAlias') | 1105 status_text = self.settings.get_setting('TypingStatusAlias') |
1112 | 1114 |
1113 # This subroutine sets the colors of the chat based on the settings in the | 1115 # This subroutine sets the colors of the chat based on the settings in the |
1114 # self instance. | 1116 # self instance. |
1115 # | 1117 # |
1116 # !self : instance of self | 1118 # !self : instance of self |
1117 @debugging | 1119 |
1118 def set_colors(self): | 1120 def set_colors(self): |
1119 # chat window backround color | 1121 # chat window backround color |
1120 self.bgcolor = self.settings.get_setting('bgcolor') | 1122 self.bgcolor = self.settings.get_setting('bgcolor') |
1121 # chat window normal text color | 1123 # chat window normal text color |
1122 self.textcolor = self.settings.get_setting('textcolor') | 1124 self.textcolor = self.settings.get_setting('textcolor') |
1134 | 1136 |
1135 # This subroutine will insert text into the chat window | 1137 # This subroutine will insert text into the chat window |
1136 # | 1138 # |
1137 # !self : instance of self | 1139 # !self : instance of self |
1138 # !txt : text to be inserted into the chat window | 1140 # !txt : text to be inserted into the chat window |
1139 @debugging | 1141 |
1140 def set_chat_text(self, txt): | 1142 def set_chat_text(self, txt): |
1141 self.chattxt.SetValue(txt) | 1143 self.chattxt.SetValue(txt) |
1142 self.chattxt.SetFocus() | 1144 self.chattxt.SetFocus() |
1143 self.chattxt.SetInsertionPointEnd() | 1145 self.chattxt.SetInsertionPointEnd() |
1144 # def set_chat_text - end | 1146 # def set_chat_text - end |
1145 | 1147 |
1146 @debugging | 1148 |
1147 def get_chat_text(self): | 1149 def get_chat_text(self): |
1148 return self.chattxt.GetValue() | 1150 return self.chattxt.GetValue() |
1149 | 1151 |
1150 # This subroutine sets the focus to the chat window | 1152 # This subroutine sets the focus to the chat window |
1151 @debugging | 1153 |
1152 def set_chat_text_focus(self, event): | 1154 def set_chat_text_focus(self, event): |
1153 wx.CallAfter(self.chattxt.SetFocus) | 1155 wx.CallAfter(self.chattxt.SetFocus) |
1154 # def set_chat_text_focus - end | 1156 # def set_chat_text_focus - end |
1155 | 1157 |
1156 # This subrtouine grabs the user input and make the special keys and | 1158 # This subrtouine grabs the user input and make the special keys and |
1159 # !self : instance of self | 1161 # !self : instance of self |
1160 # !event : | 1162 # !event : |
1161 # | 1163 # |
1162 # Note: self.chattxt now handles it's own Key events. It does, however still | 1164 # Note: self.chattxt now handles it's own Key events. It does, however still |
1163 # call it's parent's (self) OnChar to handle "default" behavior. | 1165 # call it's parent's (self) OnChar to handle "default" behavior. |
1164 @debugging | 1166 |
1165 def OnChar(self, event): | 1167 def OnChar(self, event): |
1166 s = self.chattxt.GetValue() | 1168 s = self.chattxt.GetValue() |
1167 #self.histlen = len(self.history) - 1 | 1169 #self.histlen = len(self.history) - 1 |
1168 | 1170 |
1169 ## RETURN KEY (no matter if there is text in chattxt) | 1171 ## RETURN KEY (no matter if there is text in chattxt) |
1300 ## NOTHING | 1302 ## NOTHING |
1301 else: event.Skip() | 1303 else: event.Skip() |
1302 logger.debug("Exit chat_panel->OnChar(self, event)") | 1304 logger.debug("Exit chat_panel->OnChar(self, event)") |
1303 # def OnChar - end | 1305 # def OnChar - end |
1304 | 1306 |
1305 @debugging | 1307 |
1306 def onDieRoll(self, evt): | 1308 def onDieRoll(self, evt): |
1307 """Roll the dice based on the button pressed and the die modifiers entered, if any.""" | 1309 """Roll the dice based on the button pressed and the die modifiers entered, if any.""" |
1308 # Get any die modifiers if they have been entered | 1310 # Get any die modifiers if they have been entered |
1309 numDie = self.numDieText.GetValue() | 1311 numDie = self.numDieText.GetValue() |
1310 dieMod = self.dieModText.GetValue() | 1312 dieMod = self.dieModText.GetValue() |
1321 # This subroutine saves a chat buffer as html to a file chosen via a | 1323 # This subroutine saves a chat buffer as html to a file chosen via a |
1322 # FileDialog. | 1324 # FileDialog. |
1323 # | 1325 # |
1324 # !self : instance of self | 1326 # !self : instance of self |
1325 # !evt : | 1327 # !evt : |
1326 @debugging | 1328 |
1327 def on_chat_save(self, evt): | 1329 def on_chat_save(self, evt): |
1328 f = wx.FileDialog(self,"Save Chat Buffer",".","","HTM* (*.htm*)|*.htm*|HTML (*.html)|*.html|HTM (*.htm)|*.htm",wx.SAVE) | 1330 f = wx.FileDialog(self,"Save Chat Buffer",".","","HTM* (*.htm*)|*.htm*|HTML (*.html)|*.html|HTM (*.htm)|*.htm",wx.SAVE) |
1329 if f.ShowModal() == wx.ID_OK: | 1331 if f.ShowModal() == wx.ID_OK: |
1330 file = open(f.GetPath(), "w") | 1332 file = open(f.GetPath(), "w") |
1331 file.write(self.ResetPage() + "</body></html>") | 1333 file.write(self.ResetPage() + "</body></html>") |
1332 file.close() | 1334 file.close() |
1333 f.Destroy() | 1335 f.Destroy() |
1334 os.chdir(dir_struct["home"]) | 1336 os.chdir(dir_struct["home"]) |
1335 # def on_chat_save - end | 1337 # def on_chat_save - end |
1336 | 1338 |
1337 @debugging | 1339 |
1338 def ResetPage(self): | 1340 def ResetPage(self): |
1339 self.set_colors() | 1341 self.set_colors() |
1340 buffertext = self.chatwnd.Header() + "\n" | 1342 buffertext = self.chatwnd.Header() + "\n" |
1341 buffertext += chat_util.strip_body_tags(self.chatwnd.StripHeader()).replace("<br>", | 1343 buffertext += chat_util.strip_body_tags(self.chatwnd.StripHeader()).replace("<br>", |
1342 "<br />").replace('</html>', | 1344 "<br />").replace('</html>', |
1344 "<br />\n").replace("\n\n", '') | 1346 "<br />\n").replace("\n\n", '') |
1345 return buffertext | 1347 return buffertext |
1346 | 1348 |
1347 # This subroutine sets the color of selected text, or base text color if | 1349 # This subroutine sets the color of selected text, or base text color if |
1348 # nothing is selected | 1350 # nothing is selected |
1349 @debugging | 1351 |
1350 def on_text_color(self, event): | 1352 def on_text_color(self, event): |
1351 hexcolor = self.r_h.do_hex_color_dlg(self) | 1353 hexcolor = self.r_h.do_hex_color_dlg(self) |
1352 if hexcolor != None: | 1354 if hexcolor != None: |
1353 (beg,end) = self.chattxt.GetSelection() | 1355 (beg,end) = self.chattxt.GetSelection() |
1354 if beg != end: | 1356 if beg != end: |
1368 # This subroutine take a color and a text string and formats it into html. | 1370 # This subroutine take a color and a text string and formats it into html. |
1369 # | 1371 # |
1370 # !self : instance of self | 1372 # !self : instance of self |
1371 # !color : color for the text to be set | 1373 # !color : color for the text to be set |
1372 # !text : text string to be included in the html. | 1374 # !text : text string to be included in the html. |
1373 @debugging | 1375 |
1374 def colorize(self, color, text): | 1376 def colorize(self, color, text): |
1375 """Puts font tags of 'color' around 'text' value, and returns the string""" | 1377 """Puts font tags of 'color' around 'text' value, and returns the string""" |
1376 return "<font color='" + color + "'>" + text + "</font>" | 1378 return "<font color='" + color + "'>" + text + "</font>" |
1377 # def colorize - end | 1379 # def colorize - end |
1378 | 1380 |
1379 # This subroutine takes and event and inserts text with the basic format | 1381 # This subroutine takes and event and inserts text with the basic format |
1380 # tags included. | 1382 # tags included. |
1381 # | 1383 # |
1382 # !self : instance of self | 1384 # !self : instance of self |
1383 # !event : | 1385 # !event : |
1384 @debugging | 1386 |
1385 def on_text_format(self, event): | 1387 def on_text_format(self, event): |
1386 id = event.GetId() | 1388 id = event.GetId() |
1387 txt = self.chattxt.GetValue() | 1389 txt = self.chattxt.GetValue() |
1388 (beg,end) = self.chattxt.GetSelection() | 1390 (beg,end) = self.chattxt.GetSelection() |
1389 if beg != end: sel_txt = txt[beg:end] | 1391 if beg != end: sel_txt = txt[beg:end] |
1396 self.chattxt.SetValue(txt) | 1398 self.chattxt.SetValue(txt) |
1397 self.chattxt.SetInsertionPointEnd() | 1399 self.chattxt.SetInsertionPointEnd() |
1398 self.chattxt.SetFocus() | 1400 self.chattxt.SetFocus() |
1399 # def on_text_format - end | 1401 # def on_text_format - end |
1400 | 1402 |
1401 @debugging | 1403 |
1402 def lock_scroll(self, event): | 1404 def lock_scroll(self, event): |
1403 if self.lockscroll: | 1405 if self.lockscroll: |
1404 self.lockscroll = False | 1406 self.lockscroll = False |
1405 self.scroll_lock.SetLabel("Scroll ON") | 1407 self.scroll_lock.SetLabel("Scroll ON") |
1406 if len(self.storedata) != 0: | 1408 if len(self.storedata) != 0: |
1413 | 1415 |
1414 # This subroutine will popup a text window with the chatbuffer contents | 1416 # This subroutine will popup a text window with the chatbuffer contents |
1415 # | 1417 # |
1416 # !self : instance of self | 1418 # !self : instance of self |
1417 # !event : | 1419 # !event : |
1418 @debugging | 1420 |
1419 def pop_textpop(self, event): | 1421 def pop_textpop(self, event): |
1420 """searchable popup text view of chatbuffer""" | 1422 """searchable popup text view of chatbuffer""" |
1421 h_buffertext = self.ResetPage() | 1423 h_buffertext = self.ResetPage() |
1422 h_dlg = orpgScrolledMessageFrameEditor(self, h_buffertext, "Text View of Chat Window", None, (500,300)) | 1424 h_dlg = orpgScrolledMessageFrameEditor(self, h_buffertext, "Text View of Chat Window", None, (500,300)) |
1423 h_dlg.Show(True) | 1425 h_dlg.Show(True) |
1424 | 1426 |
1425 # This subroutine will change the dimension of the window | 1427 # This subroutine will change the dimension of the window |
1426 # | 1428 # |
1427 # !self : instance of self | 1429 # !self : instance of self |
1428 # !event : | 1430 # !event : |
1429 @debugging | 1431 |
1430 def OnSize(self, event=None): | 1432 def OnSize(self, event=None): |
1431 event.Skip() | 1433 event.Skip() |
1432 wx.CallAfter(self.scroll_down) | 1434 wx.CallAfter(self.scroll_down) |
1433 # def OnSize - end | 1435 # def OnSize - end |
1434 | 1436 |
1435 @debugging | 1437 |
1436 def scroll_down(self): | 1438 def scroll_down(self): |
1437 self.Freeze() | 1439 self.Freeze() |
1438 self.chatwnd.scroll_down() | 1440 self.chatwnd.scroll_down() |
1439 self.Thaw() | 1441 self.Thaw() |
1440 | 1442 |
1441 ###### message helpers ###### | 1443 ###### message helpers ###### |
1442 @debugging | 1444 |
1443 def PurgeChat(self): | 1445 def PurgeChat(self): |
1444 self.set_colors() | 1446 self.set_colors() |
1445 self.chatwnd.SetPage(self.chatwnd.Header()) | 1447 self.chatwnd.SetPage(self.chatwnd.Header()) |
1446 | 1448 |
1447 @debugging | 1449 |
1448 def system_message(self, text): | 1450 def system_message(self, text): |
1449 self.send_chat_message(text,chat_msg.SYSTEM_MESSAGE) | 1451 self.send_chat_message(text,chat_msg.SYSTEM_MESSAGE) |
1450 self.SystemPost(text) | 1452 self.SystemPost(text) |
1451 | 1453 |
1452 @debugging | 1454 |
1453 def info_message(self, text): | 1455 def info_message(self, text): |
1454 self.send_chat_message(text,chat_msg.INFO_MESSAGE) | 1456 self.send_chat_message(text,chat_msg.INFO_MESSAGE) |
1455 self.InfoPost(text) | 1457 self.InfoPost(text) |
1456 | 1458 |
1457 @debugging | 1459 |
1458 def get_gms(self): | 1460 def get_gms(self): |
1459 the_gms = [] | 1461 the_gms = [] |
1460 for playerid in self.session.players: | 1462 for playerid in self.session.players: |
1461 if len(self.session.players[playerid])>7: | 1463 if len(self.session.players[playerid])>7: |
1462 if self.session.players[playerid][7]=="GM" and self.session.group_id != '0': the_gms += [playerid] | 1464 if self.session.players[playerid][7]=="GM" and self.session.group_id != '0': the_gms += [playerid] |
1463 return the_gms | 1465 return the_gms |
1464 | 1466 |
1465 @debugging | 1467 |
1466 def GetName(self): | 1468 def GetName(self): |
1467 self.AliasLib = component.get('alias') | 1469 self.AliasLib = component.get('alias') |
1468 player = self.session.get_my_info() | 1470 player = self.session.get_my_info() |
1469 if self.AliasLib != None: | 1471 if self.AliasLib != None: |
1470 self.AliasLib.alias = self.aliasList.GetStringSelection(); | 1472 self.AliasLib.alias = self.aliasList.GetStringSelection(); |
1471 if self.AliasLib.alias[0] != self.defaultAliasName: | 1473 if self.AliasLib.alias[0] != self.defaultAliasName: |
1472 logger.debug("Exit chat_panel->GetName(self)") | 1474 logger.debug("Exit chat_panel->GetName(self)") |
1473 return [self.chat_display_name([self.AliasLib.alias[0], player[1], player[2]]), self.AliasLib.alias[1]] | 1475 return [self.chat_display_name([self.AliasLib.alias[0], player[1], player[2]]), self.AliasLib.alias[1]] |
1474 return [self.chat_display_name(player), "Default"] | 1476 return [self.chat_display_name(player), "Default"] |
1475 | 1477 |
1476 @debugging | 1478 |
1477 def GetFilteredText(self, text): | 1479 def GetFilteredText(self, text): |
1478 advregex = re.compile('\"(.*?)\"', re.I) | 1480 advregex = re.compile('\"(.*?)\"', re.I) |
1479 self.AliasLib = component.get('alias') | 1481 self.AliasLib = component.get('alias') |
1480 if self.AliasLib != None: | 1482 if self.AliasLib != None: |
1481 self.AliasLib.filter = self.filterList.GetSelection()-1; | 1483 self.AliasLib.filter = self.filterList.GetSelection()-1; |
1486 match = m.group(0) | 1488 match = m.group(0) |
1487 newmatch = re.sub(rule[0], rule[1], match) | 1489 newmatch = re.sub(rule[0], rule[1], match) |
1488 text = text.replace(match, newmatch) | 1490 text = text.replace(match, newmatch) |
1489 return text | 1491 return text |
1490 | 1492 |
1491 @debugging | 1493 |
1492 def emote_message(self, text): | 1494 def emote_message(self, text): |
1493 text = self.NormalizeParse(text) | 1495 text = self.NormalizeParse(text) |
1494 text = self.colorize(self.emotecolor, text) | 1496 text = self.colorize(self.emotecolor, text) |
1495 | 1497 |
1496 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(text,chat_msg.EMOTE_MESSAGE) | 1498 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(text,chat_msg.EMOTE_MESSAGE) |
1505 elif self.type == NULL_TAB: pass | 1507 elif self.type == NULL_TAB: pass |
1506 name = self.GetName()[0] | 1508 name = self.GetName()[0] |
1507 text = "** " + name + " " + text + " **" | 1509 text = "** " + name + " " + text + " **" |
1508 self.EmotePost(text) | 1510 self.EmotePost(text) |
1509 | 1511 |
1510 @debugging | 1512 |
1511 def whisper_to_players(self, text, player_ids): | 1513 def whisper_to_players(self, text, player_ids): |
1512 tabbed_whispers_p = self.settings.get_setting("tabbedwhispers") | 1514 tabbed_whispers_p = self.settings.get_setting("tabbedwhispers") |
1513 # Heroman - apply any filtering selected | 1515 # Heroman - apply any filtering selected |
1514 text = self.NormalizeParse(text) | 1516 text = self.NormalizeParse(text) |
1515 player_names = "" | 1517 player_names = "" |
1532 for id in player_ids: | 1534 for id in player_ids: |
1533 id = id.strip() | 1535 id = id.strip() |
1534 if self.session.is_valid_id(id): self.send_chat_message(text,chat_msg.WHISPER_MESSAGE,id) | 1536 if self.session.is_valid_id(id): self.send_chat_message(text,chat_msg.WHISPER_MESSAGE,id) |
1535 else: self.InfoPost(id + " Unknown!") | 1537 else: self.InfoPost(id + " Unknown!") |
1536 | 1538 |
1537 @debugging | 1539 |
1538 def send_chat_message(self, text, type=chat_msg.CHAT_MESSAGE, player_id="all"): | 1540 def send_chat_message(self, text, type=chat_msg.CHAT_MESSAGE, player_id="all"): |
1539 #########send_msg()############# | 1541 #########send_msg()############# |
1540 send = 1 | 1542 send = 1 |
1541 for plugin_fname in self.activeplugins.keys(): | 1543 for plugin_fname in self.activeplugins.keys(): |
1542 plugin = self.activeplugins[plugin_fname] | 1544 plugin = self.activeplugins[plugin_fname] |
1558 msg.set_alias(playername) | 1560 msg.set_alias(playername) |
1559 if send: self.session.send(msg.toxml(),player_id) | 1561 if send: self.session.send(msg.toxml(),player_id) |
1560 del msg | 1562 del msg |
1561 | 1563 |
1562 #### incoming chat message handler ##### | 1564 #### incoming chat message handler ##### |
1563 @debugging | 1565 |
1564 def post_incoming_msg(self, msg, player): | 1566 def post_incoming_msg(self, msg, player): |
1565 | 1567 |
1566 # pull data | 1568 # pull data |
1567 type = msg.get_type() | 1569 type = msg.get_type() |
1568 text = msg.get_text() | 1570 text = msg.get_text() |
1682 sound_file = self.settings.get_setting(recvSound) | 1684 sound_file = self.settings.get_setting(recvSound) |
1683 if sound_file != '': | 1685 if sound_file != '': |
1684 component.get('sound').play(sound_file) | 1686 component.get('sound').play(sound_file) |
1685 #### Posting helpers ##### | 1687 #### Posting helpers ##### |
1686 | 1688 |
1687 @debugging | 1689 |
1688 def InfoPost(self, s): | 1690 def InfoPost(self, s): |
1689 self.Post(self.colorize(self.infocolor, s), c='info') | 1691 self.Post(self.colorize(self.infocolor, s), c='info') |
1690 | 1692 |
1691 @debugging | 1693 |
1692 def SystemPost(self, s): | 1694 def SystemPost(self, s): |
1693 self.Post(self.colorize(self.syscolor, s), c='system') | 1695 self.Post(self.colorize(self.syscolor, s), c='system') |
1694 | 1696 |
1695 @debugging | 1697 |
1696 def EmotePost(self, s): | 1698 def EmotePost(self, s): |
1697 self.Post(self.colorize(self.emotecolor, s), c='emote') | 1699 self.Post(self.colorize(self.emotecolor, s), c='emote') |
1698 | 1700 |
1699 #### Standard Post method ##### | 1701 #### Standard Post method ##### |
1700 @debugging | 1702 |
1701 def Post(self, s="", send=False, myself=False, c='post'): | 1703 def Post(self, s="", send=False, myself=False, c='post'): |
1702 strip_p = self.settings.get_setting("striphtml") | 1704 strip_p = self.settings.get_setting("striphtml") |
1703 strip_img = self.settings.get_setting("Show_Images_In_Chat")#moved back 7-11-05. --mDuo13 | 1705 strip_img = self.settings.get_setting("Show_Images_In_Chat")#moved back 7-11-05. --mDuo13 |
1704 if (strip_p == "1"): s = strip_html(s) | 1706 if (strip_p == "1"): s = strip_html(s) |
1705 if (strip_img == "0"): s = chat_util.strip_img_tags(s) | 1707 if (strip_img == "0"): s = chat_util.strip_img_tags(s) |
1792 # | 1794 # |
1793 # TimeIndexString() | 1795 # TimeIndexString() |
1794 # | 1796 # |
1795 # time indexing for chat display only (don't log time indexing) | 1797 # time indexing for chat display only (don't log time indexing) |
1796 # added by Snowdog 4/04 | 1798 # added by Snowdog 4/04 |
1797 @debugging | 1799 |
1798 def TimeIndexString(self): | 1800 def TimeIndexString(self): |
1799 try: | 1801 try: |
1800 mtime = "" | 1802 mtime = "" |
1801 if self.settings.get_setting('Chat_Time_Indexing') == "0": pass | 1803 if self.settings.get_setting('Chat_Time_Indexing') == "0": pass |
1802 elif self.settings.get_setting('Chat_Time_Indexing') == "1": | 1804 elif self.settings.get_setting('Chat_Time_Indexing') == "1": |
1806 logger.general(traceback.format_exc()) | 1808 logger.general(traceback.format_exc()) |
1807 logger.general("EXCEPTION: " + str(e)) | 1809 logger.general("EXCEPTION: " + str(e)) |
1808 return "[ERROR]" | 1810 return "[ERROR]" |
1809 | 1811 |
1810 #### Post with parsing dice #### | 1812 #### Post with parsing dice #### |
1811 @debugging | 1813 |
1812 def ParsePost(self, s, send=False, myself=False): | 1814 def ParsePost(self, s, send=False, myself=False): |
1813 s = self.NormalizeParse(s) | 1815 s = self.NormalizeParse(s) |
1814 self.set_colors() | 1816 self.set_colors() |
1815 self.Post(s,send,myself) | 1817 self.Post(s,send,myself) |
1816 | 1818 |
1817 @debugging | 1819 |
1818 def NormalizeParse(self, s): | 1820 def NormalizeParse(self, s): |
1819 for plugin_fname in self.activeplugins.keys(): | 1821 for plugin_fname in self.activeplugins.keys(): |
1820 plugin = self.activeplugins[plugin_fname] | 1822 plugin = self.activeplugins[plugin_fname] |
1821 try: s = plugin.pre_parse(s) | 1823 try: s = plugin.pre_parse(s) |
1822 except Exception, e: | 1824 except Exception, e: |
1828 s = self.ParseDice(s) | 1830 s = self.ParseDice(s) |
1829 s = self.ParseFilter(s) | 1831 s = self.ParseFilter(s) |
1830 self.parsed = 1 | 1832 self.parsed = 1 |
1831 return s | 1833 return s |
1832 | 1834 |
1833 @debugging | 1835 |
1834 def ParseFilter(self, s): | 1836 def ParseFilter(self, s): |
1835 s = self.GetFilteredText(s) | 1837 s = self.GetFilteredText(s) |
1836 return s | 1838 return s |
1837 | 1839 |
1838 @debugging | 1840 |
1839 def ParseNode(self, s): | 1841 def ParseNode(self, s): |
1840 """Parses player input for embedded nodes rolls""" | 1842 """Parses player input for embedded nodes rolls""" |
1841 cur_loc = 0 | 1843 cur_loc = 0 |
1842 #[a-zA-Z0-9 _\-\.] | 1844 #[a-zA-Z0-9 _\-\.] |
1843 reg = re.compile("(!@([a-zA-Z0-9 _\-\./]+(::[a-zA-Z0-9 _\-\./]+)*)@!)") | 1845 debug(s) |
1846 reg = re.compile("(!@(.*?)@!)") | |
1844 matches = reg.findall(s) | 1847 matches = reg.findall(s) |
1845 for i in xrange(0,len(matches)): | 1848 for i in xrange(0,len(matches)): |
1846 newstr = self.ParseNode(self.resolve_nodes(matches[i][1])) | 1849 newstr = self.ParseNode(self.resolve_nodes(matches[i][1])) |
1847 s = s.replace(matches[i][0], newstr, 1) | 1850 s = s.replace(matches[i][0], newstr, 1) |
1848 return s | 1851 return s |
1849 | 1852 |
1850 @debugging | 1853 |
1851 def ParseDice(self, s): | 1854 def ParseDice(self, s): |
1852 """Parses player input for embedded dice rolls""" | 1855 """Parses player input for embedded dice rolls""" |
1853 reg = re.compile("\[([^]]*?)\]") | 1856 reg = re.compile("\[([^]]*?)\]") |
1854 matches = reg.findall(s) | 1857 matches = reg.findall(s) |
1855 for i in xrange(0,len(matches)): | 1858 for i in xrange(0,len(matches)): |
1864 if qmode == 1: | 1867 if qmode == 1: |
1865 s = s.replace("[" + matches[i] + "]", "<!-- Official Roll [" + newstr1 + "] => " + newstr + "-->" + newstr, 1) | 1868 s = s.replace("[" + matches[i] + "]", "<!-- Official Roll [" + newstr1 + "] => " + newstr + "-->" + newstr, 1) |
1866 else: s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "<!-- Official Roll -->] => " + newstr, 1) | 1869 else: s = s.replace("[" + matches[i] + "]", "[" + newstr1 + "<!-- Official Roll -->] => " + newstr, 1) |
1867 return s | 1870 return s |
1868 | 1871 |
1869 @debugging | 1872 |
1870 def PraseUnknowns(self, s): | 1873 def PraseUnknowns(self, s): |
1871 # Uses a tuple. Usage: ?Label}dY. If no Label is assigned then use ?}DY | 1874 # Uses a tuple. Usage: ?Label}dY. If no Label is assigned then use ?}DY |
1872 newstr = "0" | 1875 newstr = "0" |
1873 reg = re.compile("(\?\{*)([a-zA-Z ]*)(\}*)") | 1876 reg = re.compile("(\?\{*)([a-zA-Z ]*)(\}*)") |
1874 matches = reg.findall(s) | 1877 matches = reg.findall(s) |
1886 dlg.Destroy() | 1889 dlg.Destroy() |
1887 return s | 1890 return s |
1888 | 1891 |
1889 # This subroutine builds a chat display name. | 1892 # This subroutine builds a chat display name. |
1890 # | 1893 # |
1891 @debugging | 1894 |
1892 def chat_display_name(self, player): | 1895 def chat_display_name(self, player): |
1893 if self.settings.get_setting("ShowIDInChat") == "0": | 1896 if self.settings.get_setting("ShowIDInChat") == "0": |
1894 display_name = player[0] | 1897 display_name = player[0] |
1895 else: | 1898 else: |
1896 display_name = "("+player[2]+") " + player[0] | 1899 display_name = "("+player[2]+") " + player[0] |
1897 return display_name | 1900 return display_name |
1898 | 1901 |
1899 # This subroutine will get a hex color and return it, or return nothing | 1902 # This subroutine will get a hex color and return it, or return nothing |
1900 # | 1903 # |
1901 @debugging | 1904 |
1902 def get_color(self): | 1905 def get_color(self): |
1903 data = wx.ColourData() | 1906 data = wx.ColourData() |
1904 data.SetChooseFull(True) | 1907 data.SetChooseFull(True) |
1905 dlg = wx.ColourDialog(self, data) | 1908 dlg = wx.ColourDialog(self, data) |
1906 if dlg.ShowModal() == wx.ID_OK: | 1909 if dlg.ShowModal() == wx.ID_OK: |
1912 else: | 1915 else: |
1913 dlg.Destroy() | 1916 dlg.Destroy() |
1914 return None | 1917 return None |
1915 # def get_color - end | 1918 # def get_color - end |
1916 | 1919 |
1917 @debugging | 1920 |
1918 def replace_quotes(self, s): | 1921 def replace_quotes(self, s): |
1919 in_tag = 0 | 1922 in_tag = 0 |
1920 i = 0 | 1923 i = 0 |
1921 rs = s[:] | 1924 rs = s[:] |
1922 for c in s: | 1925 for c in s: |
1929 if in_tag: | 1932 if in_tag: |
1930 rs = rs[:i] + "'" + rs[i+1:] | 1933 rs = rs[:i] + "'" + rs[i+1:] |
1931 i += 1 | 1934 i += 1 |
1932 return rs | 1935 return rs |
1933 | 1936 |
1934 @debugging | 1937 def resolve_loop(self, node, path, step, depth): |
1935 def resolve_loop(self, dom, nodeName, doLoop = False): | 1938 debug((node.get('name'), step, depth)) |
1939 if step == depth: | |
1940 self.resolution(node) | |
1941 else: | |
1942 child_list = node.findall('nodehandler') | |
1943 debug(child_list) | |
1944 for child in child_list: | |
1945 if step == depth: break | |
1946 if child.get('name') == path[step]: | |
1947 debug(('Step', child.get('name'), step, path, path[step])) | |
1948 node = child | |
1949 step += 1 | |
1950 self.resolve_loop(node, path, step, depth) | |
1951 | |
1952 def resolution(self, node): | |
1953 debug(node) | |
1954 if self.passed == False: | |
1955 self.passed = True | |
1956 if node.get('class') == 'textctrl_handler': self.data = str(node.find('text').text) | |
1957 else: self.data = 'Nodehandler for '+ node.get('class') + ' not done!' or 'No Data!' | |
1958 else: | |
1959 self.data = '' | |
1960 pass | |
1961 | |
1962 def resolve_nodes(self, s): | |
1963 self.passed = False | |
1964 self.data = 'No Data!' | |
1965 value = "" | |
1966 path = s.split('::') | |
1967 depth = len(path) | |
1968 gametree = component.get('tree') | |
1969 dom = gametree.xml_root.getchildren() | |
1936 for node in dom: | 1970 for node in dom: |
1937 if node._get_tagName() != 'nodehandler': | 1971 debug((node.get('name'), path[0])) |
1938 continue | 1972 if node.get('name') == path[0]: |
1939 if doLoop and node.getAttribute('class') != 'textctrl_handler' and node.hasChildNodes(): | 1973 self.resolve_loop(node, path, 1, len(path)) |
1940 (found, node) = self.resolve_loop(node.getChildren(), nodeName, doLoop) | 1974 return self.data |
1941 if not found: | |
1942 continue | |
1943 if node.getAttribute('name') != nodeName: | |
1944 continue | |
1945 foundNode = node | |
1946 return (True, foundNode) | |
1947 return (False, '') | |
1948 | |
1949 @debugging | |
1950 def resolve_nodes(self, s): | |
1951 value = "" | |
1952 node_path_list = s.split("::") | |
1953 gametree = component.get('tree') | |
1954 dom = gametree.master_dom.getChildren() | |
1955 for nodeName in node_path_list: | |
1956 (found, node) = self.resolve_loop(dom, nodeName) | |
1957 if not found: | |
1958 break | |
1959 dom = node.getChildren() | |
1960 if not found: | |
1961 dom = gametree.master_dom.getChildren() | |
1962 loop = False | |
1963 if len(node_path_list) == 1: | |
1964 loop = True | |
1965 for nodeName in node_path_list: | |
1966 (found, node) = self.resolve_loop(dom, nodeName, loop) | |
1967 if not found: | |
1968 break | |
1969 dom = node.getChildren() | |
1970 loop = True | |
1971 if found: | |
1972 text = node.getElementsByTagName('text') | |
1973 node = text[0]._get_firstChild() | |
1974 value = node._get_nodeValue() | |
1975 else: | |
1976 value = s | |
1977 return value |