comparison orpg/chat/chatwnd.py @ 178:ff19dd30064b alpha

Traipse Alpha 'OpenRPG' {100114-02} 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 (Keeping up with Beta) New Features: Added Bookmarks 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 New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image
author sirebral
date Thu, 14 Jan 2010 12:45:14 -0600
parents 537a6bbac9bd
children 4b2884f29a72
comparison
equal deleted inserted replaced
177:60dde67c4ed6 178:ff19dd30064b
166 self.menu = wx.Menu() 166 self.menu = wx.Menu()
167 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy") 167 item = wx.MenuItem(self.menu, wx.ID_ANY, "Copy", "Copy")
168 self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item) 168 self.Bind(wx.EVT_MENU, self.OnM_EditCopy, item)
169 self.menu.AppendItem(item) 169 self.menu.AppendItem(item)
170 170
171
172 def OnM_EditCopy(self, evt): 171 def OnM_EditCopy(self, evt):
173 wx.TheClipboard.UsePrimarySelection(False) 172 wx.TheClipboard.UsePrimarySelection(False)
174 wx.TheClipboard.Open() 173 wx.TheClipboard.Open()
175 wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText())) 174 wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText()))
176 wx.TheClipboard.Close() 175 wx.TheClipboard.Close()
522 self.parsed=0 521 self.parsed=0
523 #chat commands 522 #chat commands
524 self.lockscroll = False # set the default to scrolling on. 523 self.lockscroll = False # set the default to scrolling on.
525 self.chat_cmds = commands.chat_commands(self) 524 self.chat_cmds = commands.chat_commands(self)
526 self.html_strip = strip_html 525 self.html_strip = strip_html
526 self.f_keys = {wx.WXK_F1: 'event.GetKeyCode() == wx.WXK_F1', wx.WXK_F2: 'event.GetKeyCode() == wx.WXK_F2',
527 wx.WXK_F3: 'event.GetKeyCode() == wx.WXK_F3', wx.WXK_F4: 'event.GetKeyCode() == wx.WXK_F4',
528 wx.WXK_F5: 'event.GetKeyCode() == wx.WXK_F5', wx.WXK_F6: 'event.GetKeyCode() == wx.WXK_F6',
529 wx.WXK_F7: 'event.GetKeyCode() == wx.WXK_F7', wx.WXK_F8: 'event.GetKeyCode() == wx.WXK_F8',
530 wx.WXK_F9: 'event.GetKeyCode() == wx.WXK_F9', wx.WXK_F10: 'event.GetKeyCode() == wx.WXK_F10',
531 wx.WXK_F11: 'event.GetKeyCode() == wx.WXK_F11', wx.WXK_F12: 'event.GetKeyCode() == wx.WXK_F12'}
527 #Alias Lib stuff 532 #Alias Lib stuff
528 self.defaultAliasName = 'Use Real Name' 533 self.defaultAliasName = 'Use Real Name'
529 self.defaultFilterName = 'No Filter' 534 self.defaultFilterName = 'No Filter'
530 self.advancedFilter = False 535 self.advancedFilter = False
531 self.lastSend = 0 # this is used to help implement the player typing indicator 536 self.lastSend = 0 # this is used to help implement the player typing indicator
829 self.dieIDs[self.d100Button.GetId()] = 'd100' 834 self.dieIDs[self.d100Button.GetId()] = 'd100'
830 self.Bind(wx.EVT_BUTTON, self.pop_textpop, self.textpop_lock) 835 self.Bind(wx.EVT_BUTTON, self.pop_textpop, self.textpop_lock)
831 self.Bind(wx.EVT_BUTTON, self.lock_scroll, self.scroll_lock) 836 self.Bind(wx.EVT_BUTTON, self.lock_scroll, self.scroll_lock)
832 self.chattxt.Bind(wx.EVT_MOUSEWHEEL, self.chatwnd.mouse_wheel) 837 self.chattxt.Bind(wx.EVT_MOUSEWHEEL, self.chatwnd.mouse_wheel)
833 self.chattxt.Bind(wx.EVT_CHAR, self.chattxt.OnChar) 838 self.chattxt.Bind(wx.EVT_CHAR, self.chattxt.OnChar)
839 self.chattxt.Bind(wx.EVT_KEY_DOWN, self.on_chat_key_down)
834 self.chattxt.Bind(wx.EVT_TEXT_COPY, self.chatwnd.OnM_EditCopy) 840 self.chattxt.Bind(wx.EVT_TEXT_COPY, self.chatwnd.OnM_EditCopy)
835 # def build_ctrls - end 841 # def build_ctrls - end
836 842
837 def build_bar(self): 843 def build_bar(self):
838 self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL) 844 self.toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL)
1090 # !self : instance of self 1096 # !self : instance of self
1091 # !event : 1097 # !event :
1092 # 1098 #
1093 # Note: self.chattxt now handles it's own Key events. It does, however still 1099 # Note: self.chattxt now handles it's own Key events. It does, however still
1094 # call it's parent's (self) OnChar to handle "default" behavior. 1100 # call it's parent's (self) OnChar to handle "default" behavior.
1101
1102 def submit_chat_text(self, s):
1103 self.histidx = -1
1104 self.temptext = ""
1105 self.history = [s] + self.history
1106 #if not len(macroText): self.chattxt.SetValue("")
1107
1108 # play sound
1109 sound_file = self.settings.get_setting("SendSound")
1110 if sound_file != '': component.get('sound').play(sound_file)
1111 if s[0] != "/": ## it's not a slash command
1112 s = self.ParsePost( s, True, True )
1113 else: self.chat_cmds.docmd(s) # emote is in chatutils.py
1114
1115 def on_chat_key_down(self, event):
1116 s = self.chattxt.GetValue()
1117 if event.GetKeyCode() == wx.WXK_RETURN and not event.ShiftDown():
1118 logger.debug("event.GetKeyCode() == wx.WXK_RETURN")
1119 self.set_colors()
1120 if self.session.get_status() == MPLAY_CONNECTED:
1121 self.sendTyping(0)
1122 if len(s):
1123 self.chattxt.SetValue('')
1124 s = s.replace('\n', '<br />')
1125 self.submit_chat_text(s)
1126 return
1127 event.Skip()
1095 1128
1096 def OnChar(self, event): 1129 def OnChar(self, event):
1097 s = self.chattxt.GetValue() 1130 s = self.chattxt.GetValue()
1098 #self.histlen = len(self.history) - 1 1131
1099 1132 macroText = ""
1100 ## RETURN KEY (no matter if there is text in chattxt) 1133 s_key = False
1101 # This section is run even if there is nothing in the chattxt (as opposed to the next wx.WXK_RETURN handler 1134 if self.f_keys.has_key(event.GetKeyCode()): s_key = self.f_keys[event.GetKeyCode()]
1102 if event.GetKeyCode() == wx.WXK_RETURN: 1135
1103 logger.debug("event.GetKeyCode() == wx.WXK_RETURN") 1136 if s_key: macroText = settings.get(s_key[29:])
1104 self.set_colors()
1105 if self.session.get_status() == MPLAY_CONNECTED: # only do if we're connected
1106 self.sendTyping(0) # Send a "not_typing" event on enter key press
1107 macroText=""
1108 recycle_bin = {wx.WXK_F1: 'event.GetKeyCode() == wx.WXK_F1', wx.WXK_F2: 'event.GetKeyCode() == wx.WXK_F2',
1109 wx.WXK_F3: 'event.GetKeyCode() == wx.WXK_F3', wx.WXK_F4: 'event.GetKeyCode() == wx.WXK_F4',
1110 wx.WXK_F5: 'event.GetKeyCode() == wx.WXK_F5', wx.WXK_F6: 'event.GetKeyCode() == wx.WXK_F6',
1111 wx.WXK_F7: 'event.GetKeyCode() == wx.WXK_F7', wx.WXK_F8: 'event.GetKeyCode() == wx.WXK_F8',
1112 wx.WXK_F9: 'event.GetKeyCode() == wx.WXK_F9', wx.WXK_F10: 'event.GetKeyCode() == wx.WXK_F10',
1113 wx.WXK_F11: 'event.GetKeyCode() == wx.WXK_F11', wx.WXK_F12: 'event.GetKeyCode() == wx.WXK_F12'}
1114
1115 bin_event = event.GetKeyCode()
1116 if recycle_bin.has_key(bin_event):
1117 logger.debug(lambda bin_event: recycle_bin[bin_event])
1118 macroText = self.settings.get_setting(recycle_bin[bin_event][29:])
1119 recycle_bin = {}; del bin_event
1120 1137
1121 # Append to the existing typed text as needed and make sure the status doesn't change back. 1138 # Append to the existing typed text as needed and make sure the status doesn't change back.
1122 if len(macroText): 1139 if len(macroText):
1123 self.sendTyping(0) 1140 self.sendTyping(0)
1124 s = macroText 1141 self.submit_chat_text(macroText)
1125
1126 ## RETURN KEY (and not text in control)
1127 if (event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText):
1128 logger.debug("(event.GetKeyCode() == wx.WXK_RETURN and len(s)) or len(macroText)")
1129 self.histidx = -1
1130 self.temptext = ""
1131 self.history = [s] + self.history#prepended instead of appended now, so higher index = greater age
1132 if not len(macroText): self.chattxt.SetValue("")
1133 # play sound
1134 sound_file = self.settings.get_setting("SendSound")
1135 if sound_file != '': component.get('sound').play(sound_file)
1136 if s[0] != "/": ## it's not a slash command
1137 s = self.ParsePost( s, True, True )
1138 else: self.chat_cmds.docmd(s) # emote is in chatutils.py
1139 1142
1140 ## UP KEY 1143 ## UP KEY
1141 elif event.GetKeyCode() == wx.WXK_UP: 1144 elif event.GetKeyCode() == wx.WXK_UP:
1142 logger.debug("event.GetKeyCode() == wx.WXK_UP") 1145 logger.debug("event.GetKeyCode() == wx.WXK_UP")
1143 if self.histidx < len(self.history)-1: 1146 if self.histidx < len(self.history)-1:
1225 logger.debug("event.GetKeyCode() == wx.WXK_END") 1228 logger.debug("event.GetKeyCode() == wx.WXK_END")
1226 if self.lockscroll: 1229 if self.lockscroll:
1227 self.lock_scroll(0) 1230 self.lock_scroll(0)
1228 self.Post() 1231 self.Post()
1229 event.Skip() 1232 event.Skip()
1233
1234 elif event.GetKeyCode() == wx.WXK_RETURN and event.ShiftDown():
1235 st = self.chattxt.GetValue().split('\x0b')
1236 st += '\n'
1237 i = self.chattxt.GetInsertionPoint()
1238 self.chattxt.SetValue(''.join(st))
1239 self.chattxt.SetInsertionPoint(i+1)
1240 return
1230 1241
1231 ## NOTHING 1242 ## NOTHING
1232 else: event.Skip() 1243 else: event.Skip()
1233 logger.debug("Exit chat_panel->OnChar(self, event)") 1244 logger.debug("Exit chat_panel->OnChar(self, event)")
1234 # def OnChar - end 1245 # def OnChar - end
1937 self.passed = False 1948 self.passed = False
1938 self.data = 'Invalid Reference!' 1949 self.data = 'Invalid Reference!'
1939 value = "" 1950 value = ""
1940 path = s.split('::') 1951 path = s.split('::')
1941 depth = len(path) 1952 depth = len(path)
1942 self.gametree = component.get('tree_back') 1953 self.gametree = component.get('tree_fs')
1943 try: node = self.gametree.tree_map[path[0]]['node'] 1954 try: node = self.gametree.tree_map[path[0]]['node']
1944 except Exception, e: return self.data 1955 except Exception, e: return self.data
1945 if node.get('class') in ('dnd35char_handler', 1956 if node.get('class') in ('dnd35char_handler',
1946 "SWd20char_handler", 1957 "SWd20char_handler",
1947 "d20char_handler", 1958 "d20char_handler",