comparison orpg/chat/chatwnd.py @ 133:37d26a98883f alpha

Traipse Alpha 'OpenRPG' {091010-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 (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 **Pretty important update that can help remove thousands of dead children from your gametree. **Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! **New Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!! Dead Node Children, now that's a O O -v-v- Happy Halloween!
author sirebral
date Tue, 10 Nov 2009 12:11:13 -0600
parents fe4dc5817d5e
children b4e02e8cd314
comparison
equal deleted inserted replaced
132:fe4dc5817d5e 133:37d26a98883f
41 41
42 42
43 ## 43 ##
44 ## Module Loading 44 ## Module Loading
45 ## 45 ##
46 import os, time, re, sys, traceback, webbrowser, commands, chat_msg, chat_util
47
48 from orpg.orpg_version import VERSION
46 from orpg.orpg_windows import * 49 from orpg.orpg_windows import *
47 from orpg.player_list import WG_LIST 50 from orpg.player_list import WG_LIST
48 from orpg.dirpath import dir_struct 51 from orpg.dirpath import dir_struct
52 #from orpg.tools.metamenus import MenuEx #Needed?
53 from string import *
54
55 import cStringIO # for reading inline imagedata as a stream
56 from HTMLParser import HTMLParser
57 from wx.lib.expando import EVT_ETC_LAYOUT_NEEDED
58
49 import orpg.tools.rgbhex 59 import orpg.tools.rgbhex
50 import orpg.tools.inputValidator 60 import orpg.tools.inputValidator
51 #from orpg.tools.metamenus import MenuEx #Needed?
52
53 import webbrowser
54 from string import *
55 from orpg.orpg_version import VERSION
56 import commands
57 import chat_msg
58 import time
59 import orpg.tools.predTextCtrl
60 from orpg.networking.mplay_client import MPLAY_CONNECTED # needed to only send typing/not_typing messages while connected
61 import os
62 import time
63 import re
64 import sys
65 import cStringIO # for reading inline imagedata as a stream
66 from HTMLParser import HTMLParser
67 import chat_util
68 import traceback
69 from wx.lib.expando import EVT_ETC_LAYOUT_NEEDED
70
71 from orpg.tools.validate import validate 61 from orpg.tools.validate import validate
72 from orpg.tools.orpg_settings import settings 62 from orpg.tools.orpg_settings import settings
63 import orpg.tools.predTextCtrl
64 from orpg.tools.orpg_log import logger, debug
73 from orpg.orpgCore import component 65 from orpg.orpgCore import component
74 from orpg.tools.orpg_log import logger, debug
75 from orpg.tools.decorators import debugging
76
77 from xml.etree.ElementTree import tostring 66 from xml.etree.ElementTree import tostring
67
68 from orpg.networking.mplay_client import MPLAY_CONNECTED # needed to only send typing/not_typing messages while connected
78 69
79 NEWCHAT = False 70 NEWCHAT = False
80 try: 71 try:
81 import wx.webview 72 import wx.webview
82 NEWCHAT = True 73 NEWCHAT = True
892 if self.settings.get_setting('Toolbar_On') == "1": 883 if self.settings.get_setting('Toolbar_On') == "1":
893 self.build_alias() 884 self.build_alias()
894 self.build_dice() 885 self.build_dice()
895 self.build_scroll() 886 self.build_scroll()
896 self.build_text() 887 self.build_text()
897 self.toolbar_sizer.Add( self.textpop_lock, 0, wx.EXPAND ) 888 self.toolbar_sizer.Add(self.textpop_lock, 0, wx.EXPAND)
898 self.toolbar_sizer.Add(self.scroll_lock,0,wx.EXPAND) 889 self.toolbar_sizer.Add(self.scroll_lock, 0, wx.EXPAND)
899 self.build_formating() 890 self.build_formating()
900 self.build_colorbutton() 891 self.build_colorbutton()
901 892
902 893
903 def build_scroll(self): 894 def build_scroll(self):
904 self.scroll_lock = wx.Button( self, wx.ID_ANY, "Scroll ON",size= wx.Size(80,25)) 895 self.scroll_lock = wx.Button( self, wx.ID_ANY, "Scroll ON",size= wx.Size(80,25))
905 896
906 897
907 def build_alias(self): 898 def build_alias(self):
899 self.aliasSizer = wx.BoxSizer(wx.HORIZONTAL) ## Future ## Add these to a sizer, then turn the toolbar_sizer into a grid so these can adjust to the frame.
908 self.aliasList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultAliasName]) 900 self.aliasList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultAliasName])
909 self.aliasButton = createMaskedButton( self, dir_struct["icon"] + 'player.gif', 901 self.aliasButton = createMaskedButton( self, dir_struct["icon"] + 'player.gif',
910 'Refresh list of aliases from Game Tree', wx.ID_ANY, '#bdbdbd' ) 902 'Refresh list of aliases from Game Tree', wx.ID_ANY, '#bdbdbd' )
911 self.aliasList.SetSelection(0) 903 self.aliasList.SetSelection(0)
912 self.filterList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultFilterName]) 904 self.filterList = wx.Choice(self, wx.ID_ANY, size=(100, 25), choices=[self.defaultFilterName])
913 self.filterButton = createMaskedButton( self, dir_struct["icon"] + 'add_filter.gif', 905 self.filterButton = createMaskedButton( self, dir_struct["icon"] + 'add_filter.gif',
914 'Refresh list of filters from Game Tree', wx.ID_ANY, '#bdbdbd' ) 906 'Refresh list of filters from Game Tree', wx.ID_ANY, '#bdbdbd' )
915 self.filterList.SetSelection(0) 907 self.filterList.SetSelection(0)
916 self.toolbar_sizer.Add( self.aliasButton, 0, wx.EXPAND ) 908
917 self.toolbar_sizer.Add( self.aliasList,0,wx.EXPAND) 909 self.aliasSizer.Add( self.aliasButton, 0, wx.EXPAND )
918 self.toolbar_sizer.Add( self.filterButton, 0, wx.EXPAND ) 910 self.aliasSizer.Add( self.aliasList,0,wx.EXPAND)
919 self.toolbar_sizer.Add( self.filterList,0,wx.EXPAND) 911 self.aliasSizer.Add( self.filterButton, 0, wx.EXPAND )
912 self.aliasSizer.Add( self.filterList,0,wx.EXPAND)
913
914 self.toolbar_sizer.Add(self.aliasSizer, 0, wx.EXPAND)
915
920 if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0') 916 if self.settings.get_setting('AliasTool_On') == '0': self.toggle_alias('0')
921 else: self.toggle_alias('1') 917 else: self.toggle_alias('1')
922 918
923 919
924 def toggle_alias(self, act): 920 def toggle_alias(self, act):
925 if act == '0': 921 if act == '0': self.toolbar_sizer.Show(self.aliasSizer, False)
926 self.toolbar_sizer.Show(self.aliasList, False) 922 else: self.toolbar_sizer.Show(self.aliasSizer, True)
927 self.toolbar_sizer.Show(self.filterList, False) 923 self.toolbar_sizer.Layout()
928 self.toolbar_sizer.Show(self.aliasButton, False)
929 self.toolbar_sizer.Show(self.filterButton, False)
930 self.toolbar_sizer.Layout()
931 else:
932 self.toolbar_sizer.Show(self.aliasList, True)
933 self.toolbar_sizer.Show(self.filterList, True)
934 self.toolbar_sizer.Show(self.aliasButton, True)
935 self.toolbar_sizer.Show(self.filterButton, True)
936 self.toolbar_sizer.Layout()
937
938 924
939 def build_text(self): 925 def build_text(self):
940 self.textpop_lock = createMaskedButton(self, dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd') 926 self.textpop_lock = createMaskedButton(self, dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd')
941 927
942 928
1182 wx.WXK_F7: 'event.GetKeyCode() == wx.WXK_F7', wx.WXK_F8: 'event.GetKeyCode() == wx.WXK_F8', 1168 wx.WXK_F7: 'event.GetKeyCode() == wx.WXK_F7', wx.WXK_F8: 'event.GetKeyCode() == wx.WXK_F8',
1183 wx.WXK_F9: 'event.GetKeyCode() == wx.WXK_F9', wx.WXK_F10: 'event.GetKeyCode() == wx.WXK_F10', 1169 wx.WXK_F9: 'event.GetKeyCode() == wx.WXK_F9', wx.WXK_F10: 'event.GetKeyCode() == wx.WXK_F10',
1184 wx.WXK_F11: 'event.GetKeyCode() == wx.WXK_F11', wx.WXK_F12: 'event.GetKeyCode() == wx.WXK_F12'} 1170 wx.WXK_F11: 'event.GetKeyCode() == wx.WXK_F11', wx.WXK_F12: 'event.GetKeyCode() == wx.WXK_F12'}
1185 1171
1186 bin_event = event.GetKeyCode() 1172 bin_event = event.GetKeyCode()
1187 if recycle_bin.has_key(bin_event): 1173 if recycle_bin.has_key(bin_event):
1188 logger.debug(lambda bin_event: recycle_bin[bin_event]) 1174 logger.debug(lambda bin_event: recycle_bin[bin_event])
1189 macroText = self.settings.get_setting(recycle_bin[bin_event][29:]) 1175 macroText = self.settings.get_setting(recycle_bin[bin_event][29:])
1190 recycle_bin = {}; del bin_event 1176 recycle_bin = {}; del bin_event
1191 1177
1192 # Append to the existing typed text as needed and make sure the status doesn't change back. 1178 # Append to the existing typed text as needed and make sure the status doesn't change back.
1839 1825
1840 def ParseNode(self, s): 1826 def ParseNode(self, s):
1841 """Parses player input for embedded nodes rolls""" 1827 """Parses player input for embedded nodes rolls"""
1842 cur_loc = 0 1828 cur_loc = 0
1843 #[a-zA-Z0-9 _\-\.] 1829 #[a-zA-Z0-9 _\-\.]
1844 debug(s)
1845 reg = re.compile("(!@(.*?)@!)") 1830 reg = re.compile("(!@(.*?)@!)")
1846 matches = reg.findall(s) 1831 matches = reg.findall(s)
1847 for i in xrange(0,len(matches)): 1832 for i in xrange(0,len(matches)):
1848 newstr = self.ParseNode(self.resolve_nodes(matches[i][1])) 1833 newstr = self.ParseNode(self.resolve_nodes(matches[i][1]))
1849 s = s.replace(matches[i][0], newstr, 1) 1834 s = s.replace(matches[i][0], newstr, 1)
1932 rs = rs[:i] + "'" + rs[i+1:] 1917 rs = rs[:i] + "'" + rs[i+1:]
1933 i += 1 1918 i += 1
1934 return rs 1919 return rs
1935 1920
1936 def resolve_loop(self, node, path, step, depth): 1921 def resolve_loop(self, node, path, step, depth):
1937 debug((node.get('name'), step, depth))
1938 if step == depth: 1922 if step == depth:
1939 self.resolution(node) 1923 self.resolution(node)
1940 else: 1924 else:
1941 child_list = node.findall('nodehandler') 1925 child_list = node.findall('nodehandler')
1942 debug(child_list)
1943 for child in child_list: 1926 for child in child_list:
1944 if step == depth: break 1927 if step == depth: break
1945 if child.get('name') == path[step]: 1928 if child.get('name') == path[step]:
1946 debug(('Step', child.get('name'), step, path, path[step]))
1947 node = child 1929 node = child
1948 step += 1 1930 step += 1
1949 self.resolve_loop(node, path, step, depth) 1931 self.resolve_loop(node, path, step, depth)
1950 1932
1951 def resolution(self, node): 1933 def resolution(self, node):
1952 debug((node))
1953 if self.passed == False: 1934 if self.passed == False:
1954 self.passed = True 1935 self.passed = True
1955 if node.get('class') == 'textctrl_handler': self.data = str(node.find('text').text) 1936 if node.get('class') == 'textctrl_handler': self.data = str(node.find('text').text)
1956 else: self.data = 'Nodehandler for '+ node.get('class') + ' not done!' or 'No Data!' 1937 else: self.data = 'Nodehandler for '+ node.get('class') + ' not done!' or 'No Data!'
1957 else: 1938 else:
1978 path = s.split('::') 1959 path = s.split('::')
1979 depth = len(path) 1960 depth = len(path)
1980 self.gametree = component.get('tree') 1961 self.gametree = component.get('tree')
1981 dom = self.gametree.xml_root.getchildren() 1962 dom = self.gametree.xml_root.getchildren()
1982 for node in dom: 1963 for node in dom:
1983 debug((node.get('name'), path[0]))
1984 if node.get('name') == path[0]: 1964 if node.get('name') == path[0]:
1985 self.resolve_loop(node, path, 1, len(path)) 1965 self.resolve_loop(node, path, 1, len(path))
1986 return self.data 1966 return self.data