comparison orpg/chat/chatwnd.py @ 212:13054be69834 beta

Traipse Beta 'OpenRPG' {100428-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) 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 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 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
author sirebral
date Wed, 28 Apr 2010 08:08:09 -0500
parents fb08f5731b5e
children bb7b9648792c
comparison
equal deleted inserted replaced
194:44ef45e77880 212:13054be69834
43 ## 43 ##
44 ## Module Loading 44 ## Module Loading
45 ## 45 ##
46 import os, time, re, sys, traceback, webbrowser, commands, chat_msg, chat_util 46 import os, time, re, sys, traceback, webbrowser, commands, chat_msg, chat_util
47 47
48 from orpg.orpg_version import VERSION 48 from orpg.orpg_version import VERSION, DISTRO, DIS_VER, BUILD
49 from orpg.orpg_windows import * 49 from orpg.orpg_windows import *
50 from orpg.player_list import WG_LIST 50 from orpg.player_list import WG_LIST
51 from orpg.dirpath import dir_struct 51 from orpg.dirpath import dir_struct
52 from string import * 52 from string import *
53 53
761 761
762 def build_ctrls(self): 762 def build_ctrls(self):
763 self.chatwnd = chat_html_window(self,-1) 763 self.chatwnd = chat_html_window(self,-1)
764 self.set_colors() 764 self.set_colors()
765 wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header()) 765 wx.CallAfter(self.chatwnd.SetPage, self.chatwnd.Header())
766 welcome = "<b>Welcome to <a href='http://www.knowledgearcana.com/traipse-openrpg/'>"
767 welcome += DISTRO +'</a> '+ DIS_VER +' {'+BUILD+'},'
768 welcome += ' built on OpenRPG '+ VERSION +'</b>'
766 if (self.sendtarget == "all"): 769 if (self.sendtarget == "all"):
767 wx.CallAfter(self.Post, self.colorize(self.syscolor, 770 wx.CallAfter(self.Post, self.colorize(self.syscolor, welcome))
768 "<b>Welcome to <a href='http://www.openrpg.com'>OpenRPG</a> version " + self.version + "... </b>"))
769 self.chattxt = orpg.tools.predTextCtrl.predTextCtrl(self, -1, "", 771 self.chattxt = orpg.tools.predTextCtrl.predTextCtrl(self, -1, "",
770 style=wx.TE_PROCESS_ENTER |wx.TE_PROCESS_TAB|wx.TE_LINEWRAP, 772 style=wx.TE_PROCESS_ENTER |wx.TE_PROCESS_TAB|wx.TE_LINEWRAP,
771 keyHook = self.myKeyHook, validator=None ) 773 keyHook = self.myKeyHook, validator=None )
772 self.build_bar() 774 self.build_bar()
773 self.basesizer = wx.BoxSizer(wx.VERTICAL) 775 self.basesizer = wx.BoxSizer(wx.VERTICAL)
1028 1030
1029 # play sound 1031 # play sound
1030 sound_file = self.settings.get_setting("SendSound") 1032 sound_file = self.settings.get_setting("SendSound")
1031 if sound_file != '': component.get('sound').play(sound_file) 1033 if sound_file != '': component.get('sound').play(sound_file)
1032 if s[0] != "/": ## it's not a slash command 1034 if s[0] != "/": ## it's not a slash command
1033 s = self.ParsePost( s, True, True ) 1035 s = Parse.Post(s, self, True, True)
1034 else: self.chat_cmds.docmd(s) # emote is in chatutils.py 1036 else: self.chat_cmds.docmd(s) # emote is in chatutils.py
1035 1037
1036 def on_chat_key_down(self, event): 1038 def on_chat_key_down(self, event):
1037 s = self.chattxt.GetValue() 1039 s = self.chattxt.GetValue()
1038 if event.GetKeyCode() == wx.WXK_RETURN and not event.ShiftDown(): 1040 if event.GetKeyCode() == wx.WXK_RETURN and not event.ShiftDown():
1167 id = evt.GetId() 1169 id = evt.GetId()
1168 if self.dieIDs.has_key(id): dieText += self.dieIDs[id] 1170 if self.dieIDs.has_key(id): dieText += self.dieIDs[id]
1169 if len(dieMod) and dieMod[0] not in "*/-+": dieMod = "+" + dieMod 1171 if len(dieMod) and dieMod[0] not in "*/-+": dieMod = "+" + dieMod
1170 dieText += dieMod 1172 dieText += dieMod
1171 dieText = "[" + dieText + "]" 1173 dieText = "[" + dieText + "]"
1172 self.ParsePost(dieText, 1, 1) 1174 Parse.Post(dieText, self, 1, 1)
1173 self.chattxt.SetFocus() 1175 self.chattxt.SetFocus()
1174 1176
1175 def on_chat_save(self, evt): 1177 def on_chat_save(self, evt):
1176 f = wx.FileDialog(self,"Save Chat Buffer",".","","HTM* (*.htm*)|*.htm*|HTML (*.html)|*.html|HTM (*.htm)|*.htm",wx.SAVE) 1178 f = wx.FileDialog(self,"Save Chat Buffer",".","","HTM* (*.htm*)|*.htm*|HTML (*.html)|*.html|HTM (*.htm)|*.htm",wx.SAVE)
1177 if f.ShowModal() == wx.ID_OK: 1179 if f.ShowModal() == wx.ID_OK:
1297 newmatch = re.sub(rule[0], rule[1], match) 1299 newmatch = re.sub(rule[0], rule[1], match)
1298 text = text.replace(match, newmatch) 1300 text = text.replace(match, newmatch)
1299 return text 1301 return text
1300 1302
1301 def emote_message(self, text): 1303 def emote_message(self, text):
1302 text = Parse.Normalize(text) 1304 text = Parse.Normalize(text, self)
1303 text = self.colorize(self.emotecolor, text) 1305 text = self.colorize(self.emotecolor, text)
1304 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(text,chat_msg.EMOTE_MESSAGE) 1306 if self.type == MAIN_TAB and self.sendtarget == 'all': self.send_chat_message(text,chat_msg.EMOTE_MESSAGE)
1305 elif self.type == MAIN_TAB and self.sendtarget == "gm": 1307 elif self.type == MAIN_TAB and self.sendtarget == "gm":
1306 msg_type = chat_msg.WHISPER_EMOTE_MESSAGE 1308 msg_type = chat_msg.WHISPER_EMOTE_MESSAGE
1307 the_gms = self.get_gms() 1309 the_gms = self.get_gms()
1315 text = "** " + name + " " + text + " **" 1317 text = "** " + name + " " + text + " **"
1316 self.EmotePost(text) 1318 self.EmotePost(text)
1317 1319
1318 def whisper_to_players(self, text, player_ids): 1320 def whisper_to_players(self, text, player_ids):
1319 tabbed_whispers_p = self.settings.get_setting("tabbedwhispers") 1321 tabbed_whispers_p = self.settings.get_setting("tabbedwhispers")
1320 text = Parse.Normalize(text) 1322 text = Parse.Normalize(text, self)
1321 player_names = "" 1323 player_names = ""
1322 for m in player_ids: 1324 for m in player_ids:
1323 id = m.strip() 1325 id = m.strip()
1324 if self.session.is_valid_id(id): 1326 if self.session.is_valid_id(id):
1325 returned_name = self.session.get_player_by_player_id(id)[0] 1327 returned_name = self.session.get_player_by_player_id(id)[0]
1382 logger.general("EXCEPTION: " + str(e)) 1384 logger.general("EXCEPTION: " + str(e))
1383 strip_img = self.settings.get_setting("Show_Images_In_Chat") 1385 strip_img = self.settings.get_setting("Show_Images_In_Chat")
1384 if (strip_img == "0"): display_name = chat_util.strip_img_tags(display_name) 1386 if (strip_img == "0"): display_name = chat_util.strip_img_tags(display_name)
1385 recvSound = "RecvSound" 1387 recvSound = "RecvSound"
1386 # act on the type of messsage 1388 # act on the type of messsage
1389
1387 if (type == chat_msg.CHAT_MESSAGE): 1390 if (type == chat_msg.CHAT_MESSAGE):
1388 text = "<b>" + display_name + "</b>: " + text 1391 text = "<b>" + display_name + "</b>: " + text
1389 self.Post(text) 1392 self.Post(text)
1390 self.parent.newMsg(0) 1393 self.parent.newMsg(0)
1391 elif type == chat_msg.WHISPER_MESSAGE or type == chat_msg.WHISPER_EMOTE_MESSAGE: 1394 elif type == chat_msg.WHISPER_MESSAGE or type == chat_msg.WHISPER_EMOTE_MESSAGE:
1587 except Exception, e: 1590 except Exception, e:
1588 logger.general(traceback.format_exc()) 1591 logger.general(traceback.format_exc())
1589 logger.general("EXCEPTION: " + str(e)) 1592 logger.general("EXCEPTION: " + str(e))
1590 return "[ERROR]" 1593 return "[ERROR]"
1591 1594
1592 def ParsePost(self, s, send=False, myself=False):
1593 s = Parse.Normalize(s)
1594 self.set_colors()
1595 self.Post(s,send,myself)
1596
1597 # This subroutine builds a chat display name. 1595 # This subroutine builds a chat display name.
1598 # 1596 #
1599 def chat_display_name(self, player): 1597 def chat_display_name(self, player):
1600 if self.settings.get_setting("ShowIDInChat") == "0": 1598 if self.settings.get_setting("ShowIDInChat") == "0":
1601 display_name = player[0] 1599 display_name = player[0]