Mercurial > traipse_dev
comparison orpg/chat/chatwnd.py @ 136:b4e02e8cd314 alpha
Traipse Alpha 'OpenRPG' {091016-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 Gametree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!!
author | sirebral |
---|---|
date | Mon, 16 Nov 2009 19:13:41 -0600 |
parents | 37d26a98883f |
children | 1ed2feab0db9 |
comparison
equal
deleted
inserted
replaced
134:82c47d583493 | 136:b4e02e8cd314 |
---|---|
913 | 913 |
914 self.toolbar_sizer.Add(self.aliasSizer, 0, wx.EXPAND) | 914 self.toolbar_sizer.Add(self.aliasSizer, 0, wx.EXPAND) |
915 | 915 |
916 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') |
917 else: self.toggle_alias('1') | 917 else: self.toggle_alias('1') |
918 | |
919 | 918 |
920 def toggle_alias(self, act): | 919 def toggle_alias(self, act): |
921 if act == '0': self.toolbar_sizer.Show(self.aliasSizer, False) | 920 if act == '0': self.toolbar_sizer.Show(self.aliasSizer, False) |
922 else: self.toolbar_sizer.Show(self.aliasSizer, True) | 921 else: self.toolbar_sizer.Show(self.aliasSizer, True) |
923 self.toolbar_sizer.Layout() | 922 self.toolbar_sizer.Layout() |
925 def build_text(self): | 924 def build_text(self): |
926 self.textpop_lock = createMaskedButton(self, dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd') | 925 self.textpop_lock = createMaskedButton(self, dir_struct["icon"]+'note.gif', 'Open Text View Of Chat Session', wx.ID_ANY, '#bdbdbd') |
927 | 926 |
928 | 927 |
929 def build_dice(self): | 928 def build_dice(self): |
930 self.numDieText = wx.TextCtrl( self, wx.ID_ANY, "1", size= wx.Size(25, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) | 929 self.diceSizer = wx.BoxSizer(wx.HORIZONTAL) |
931 self.dieModText = wx.TextCtrl( self, wx.ID_ANY, "", size= wx.Size(50, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) | 930 self.numDieText = wx.TextCtrl( self, wx.ID_ANY, "1", |
931 size= wx.Size(25, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) | |
932 self.dieModText = wx.TextCtrl( self, wx.ID_ANY, "", | |
933 size= wx.Size(50, 25), validator=orpg.tools.inputValidator.MathOnlyValidator() ) | |
932 self.d4Button = createMaskedButton(self, dir_struct["icon"]+'b_d4.gif', 'Roll d4', wx.ID_ANY) | 934 self.d4Button = createMaskedButton(self, dir_struct["icon"]+'b_d4.gif', 'Roll d4', wx.ID_ANY) |
933 self.d6Button = createMaskedButton(self, dir_struct["icon"]+'b_d6.gif', 'Roll d6', wx.ID_ANY) | 935 self.d6Button = createMaskedButton(self, dir_struct["icon"]+'b_d6.gif', 'Roll d6', wx.ID_ANY) |
934 self.d8Button = createMaskedButton(self, dir_struct["icon"]+'b_d8.gif', 'Roll d8', wx.ID_ANY) | 936 self.d8Button = createMaskedButton(self, dir_struct["icon"]+'b_d8.gif', 'Roll d8', wx.ID_ANY) |
935 self.d10Button = createMaskedButton(self, dir_struct["icon"]+'b_d10.gif', 'Roll d10', wx.ID_ANY) | 937 self.d10Button = createMaskedButton(self, dir_struct["icon"]+'b_d10.gif', 'Roll d10', wx.ID_ANY) |
936 self.d12Button = createMaskedButton(self, dir_struct["icon"]+'b_d12.gif', 'Roll d12', wx.ID_ANY) | 938 self.d12Button = createMaskedButton(self, dir_struct["icon"]+'b_d12.gif', 'Roll d12', wx.ID_ANY) |
937 self.d20Button = createMaskedButton(self, dir_struct["icon"]+'b_d20.gif', 'Roll d20', wx.ID_ANY) | 939 self.d20Button = createMaskedButton(self, dir_struct["icon"]+'b_d20.gif', 'Roll d20', wx.ID_ANY) |
938 self.d100Button = createMaskedButton(self, dir_struct["icon"]+'b_d100.gif', 'Roll d100', wx.ID_ANY) | 940 self.d100Button = createMaskedButton(self, dir_struct["icon"]+'b_d100.gif', 'Roll d100', wx.ID_ANY) |
939 self.toolbar_sizer.Add( self.numDieText, 0, wx.ALIGN_CENTER | wx.EXPAND) | 941 |
940 self.toolbar_sizer.Add( self.d4Button, 0 ,wx.EXPAND) | 942 self.diceSizer.Add( self.numDieText, 0, wx.ALIGN_CENTER | wx.EXPAND) |
941 self.toolbar_sizer.Add( self.d6Button, 0 ,wx.EXPAND) | 943 self.diceSizer.Add( self.d4Button, 0 ,wx.EXPAND) |
942 self.toolbar_sizer.Add( self.d8Button, 0 ,wx.EXPAND) | 944 self.diceSizer.Add( self.d6Button, 0 ,wx.EXPAND) |
943 self.toolbar_sizer.Add( self.d10Button, 0 ,wx.EXPAND) | 945 self.diceSizer.Add( self.d8Button, 0 ,wx.EXPAND) |
944 self.toolbar_sizer.Add( self.d12Button, 0 ,wx.EXPAND) | 946 self.diceSizer.Add( self.d10Button, 0 ,wx.EXPAND) |
945 self.toolbar_sizer.Add( self.d20Button, 0 ,wx.EXPAND) | 947 self.diceSizer.Add( self.d12Button, 0 ,wx.EXPAND) |
946 self.toolbar_sizer.Add( self.d100Button, 0 ,wx.EXPAND) | 948 self.diceSizer.Add( self.d20Button, 0 ,wx.EXPAND) |
947 self.toolbar_sizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 ) | 949 self.diceSizer.Add( self.d100Button, 0 ,wx.EXPAND) |
950 self.diceSizer.Add( self.dieModText, 0, wx.ALIGN_CENTER, 5 ) | |
951 | |
952 self.toolbar_sizer.Add( self.diceSizer, 0, wx.EXPAND) | |
948 if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0') | 953 if self.settings.get_setting('DiceButtons_On') == '0': self.toggle_dice('0') |
949 else: self.toggle_dice('1') | 954 else: self.toggle_dice('1') |
950 | 955 |
951 | 956 |
952 def toggle_dice(self, act): | 957 def toggle_dice(self, act): |
953 if act == '0': | 958 if act == '0': self.toolbar_sizer.Show(self.diceSizer, False) |
954 self.toolbar_sizer.Show(self.numDieText, False) | 959 else: self.toolbar_sizer.Show(self.diceSizer, True) |
955 self.toolbar_sizer.Show(self.d4Button, False) | 960 self.toolbar_sizer.Layout() |
956 self.toolbar_sizer.Show(self.d6Button, False) | |
957 self.toolbar_sizer.Show(self.d8Button, False) | |
958 self.toolbar_sizer.Show(self.d10Button, False) | |
959 self.toolbar_sizer.Show(self.d12Button, False) | |
960 self.toolbar_sizer.Show(self.d20Button, False) | |
961 self.toolbar_sizer.Show(self.d100Button, False) | |
962 self.toolbar_sizer.Show(self.dieModText, False) | |
963 self.toolbar_sizer.Layout() | |
964 else: | |
965 self.toolbar_sizer.Show(self.numDieText, True) | |
966 self.toolbar_sizer.Show(self.d4Button, True) | |
967 self.toolbar_sizer.Show(self.d6Button, True) | |
968 self.toolbar_sizer.Show(self.d8Button, True) | |
969 self.toolbar_sizer.Show(self.d10Button, True) | |
970 self.toolbar_sizer.Show(self.d12Button, True) | |
971 self.toolbar_sizer.Show(self.d20Button, True) | |
972 self.toolbar_sizer.Show(self.d100Button, True) | |
973 self.toolbar_sizer.Show(self.dieModText, True) | |
974 self.toolbar_sizer.Layout() | |
975 | 961 |
976 | 962 |
977 def build_formating(self): | 963 def build_formating(self): |
964 self.formatSizer = wx.BoxSizer(wx.HORIZONTAL) | |
978 self.boldButton = createMaskedButton( self, dir_struct["icon"]+'bold.gif', | 965 self.boldButton = createMaskedButton( self, dir_struct["icon"]+'bold.gif', |
979 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd') | 966 'Make the selected text Bold', wx.ID_ANY, '#bdbdbd') |
980 self.italicButton = createMaskedButton( self, dir_struct["icon"]+'italic.gif', | 967 self.italicButton = createMaskedButton( self, dir_struct["icon"]+'italic.gif', |
981 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' ) | 968 'Italicize the selected text', wx.ID_ANY, '#bdbdbd' ) |
982 self.underlineButton = createMaskedButton( self, dir_struct["icon"]+'underlined.gif', | 969 self.underlineButton = createMaskedButton( self, dir_struct["icon"]+'underlined.gif', |
983 'Underline the selected text', wx.ID_ANY, '#bdbdbd' ) | 970 'Underline the selected text', wx.ID_ANY, '#bdbdbd' ) |
984 self.toolbar_sizer.Add( self.boldButton, 0, wx.EXPAND ) | 971 |
985 self.toolbar_sizer.Add( self.italicButton, 0, wx.EXPAND ) | 972 self.formatSizer.Add( self.boldButton, 0, wx.EXPAND ) |
986 self.toolbar_sizer.Add( self.underlineButton, 0, wx.EXPAND ) | 973 self.formatSizer.Add( self.italicButton, 0, wx.EXPAND ) |
974 self.formatSizer.Add( self.underlineButton, 0, wx.EXPAND ) | |
975 self.toolbar_sizer.Add( self.formatSizer, 0, wx.EXPAND ) | |
987 if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0') | 976 if self.settings.get_setting('FormattingButtons_On') == '0': self.toggle_formating('0') |
988 else: self.toggle_formating('1') | 977 else: self.toggle_formating('1') |
989 | 978 |
990 | 979 |
991 def toggle_formating(self, act): | 980 def toggle_formating(self, act): |
992 if act == '0': | 981 if act == '0': self.toolbar_sizer.Show(self.formatSizer, False) |
993 self.toolbar_sizer.Show(self.boldButton, False) | 982 else: self.toolbar_sizer.Show(self.formatSizer, True) |
994 self.toolbar_sizer.Show(self.italicButton, False) | 983 self.toolbar_sizer.Layout() |
995 self.toolbar_sizer.Show(self.underlineButton, False) | |
996 self.toolbar_sizer.Layout() | |
997 else: | |
998 self.toolbar_sizer.Show(self.boldButton, True) | |
999 self.toolbar_sizer.Show(self.italicButton, True) | |
1000 self.toolbar_sizer.Show(self.underlineButton, True) | |
1001 self.toolbar_sizer.Layout() | |
1002 | 984 |
1003 # Heroman - Ideally, we would use static labels... | 985 # Heroman - Ideally, we would use static labels... |
1004 | 986 |
1005 def build_colorbutton(self): | 987 def build_colorbutton(self): |
1006 self.color_button = createMaskedButton(self, dir_struct["icon"]+'textcolor.gif', | 988 self.color_button = createMaskedButton(self, dir_struct["icon"]+'textcolor.gif', |
1073 logger.general("EXCEPTION: " + str(e)) | 1055 logger.general("EXCEPTION: " + str(e)) |
1074 #end mDuo13 added code | 1056 #end mDuo13 added code |
1075 if self.lastSend: # This will be zero when not typing, so equiv to if is_typing | 1057 if self.lastSend: # This will be zero when not typing, so equiv to if is_typing |
1076 thisTime = time.time() # thisTime is a local temp variable | 1058 thisTime = time.time() # thisTime is a local temp variable |
1077 if (thisTime - self.lastPress) > 4: # Check to see if it's been 5 seconds since our last keystroke | 1059 if (thisTime - self.lastPress) > 4: # Check to see if it's been 5 seconds since our last keystroke |
1078 # If we're not already typing, then self.lastSend will be 0 | 1060 # If we're not already typing, then self.lastSend will be 0 |
1079 | 1061 |
1080 self.sendTyping(0) # send a typing event here (0 for False) | 1062 self.sendTyping(0) # send a typing event here (0 for False) |
1081 # This subroutine actually takes care of sending the messages for typing/not_typing events | 1063 # This subroutine actually takes care of sending the messages for typing/not_typing events |
1082 # | 1064 # |
1083 # self: duh | 1065 # self: duh |
1926 for child in child_list: | 1908 for child in child_list: |
1927 if step == depth: break | 1909 if step == depth: break |
1928 if child.get('name') == path[step]: | 1910 if child.get('name') == path[step]: |
1929 node = child | 1911 node = child |
1930 step += 1 | 1912 step += 1 |
1931 self.resolve_loop(node, path, step, depth) | 1913 if node.get('class') in ('dnd35char_handler', "SWd20char_handler", "d20char_handler", "dnd3echar_handler"): self.resolve_cust_loop(node, path, step, depth) |
1914 else: self.resolve_loop(node, path, step, depth) | |
1915 | |
1916 def resolve_cust_loop(self, node, path, step, depth): | |
1917 node_class = node.get('class') | |
1918 if step == depth: | |
1919 self.resolution(node) | |
1920 | |
1921 ##Build Abilities dictionary## | |
1922 if node_class not in ('d20char_handler', "SWd20char_handler"): ab = node.find('character').find('abilities') | |
1923 else: ab = node.find('abilities') | |
1924 ab_list = ab.findall('stat'); pc_stats = {} | |
1925 | |
1926 for ability in ab_list: | |
1927 pc_stats[ability.get('name')] = ( str(ability.get('base')), str((int(ability.get('base'))-10)/2) ) | |
1928 pc_stats[ability.get('abbr')] = ( str(ability.get('base')), str((int(ability.get('base'))-10)/2) ) | |
1929 | |
1930 if node_class not in ('d20char_handler', "SWd20char_handler"): ab = node.find('character').find('saves') | |
1931 else: ab = node.find('saves') | |
1932 ab_list = ab.findall('save') | |
1933 | |
1934 for save in ab_list: | |
1935 pc_stats[save.get('name')] = ( str(save.get('base')), str(int(save.get('magmod')) + int(save.get('miscmod')) + int(pc_stats[save.get('stat')][1]) ) ) | |
1936 if save.get('name') == 'Fortitude': abbr = 'Fort' | |
1937 if save.get('name') == 'Reflex': abbr = 'Ref' | |
1938 if save.get('name') == 'Will': abbr = 'Will' | |
1939 pc_stats[abbr] = ( str(save.get('base')), str(int(save.get('magmod')) + int(save.get('miscmod')) + int(pc_stats[save.get('stat')][1]) ) ) | |
1940 | |
1941 if path[step] == 'Skill': | |
1942 if node_class not in ('d20char_handler', "SWd20char_handler"): node = node.find('snf') | |
1943 node = node.find('skills') | |
1944 child_list = node.findall('skill') | |
1945 for child in child_list: | |
1946 if path[step+1] == child.get('name'): | |
1947 if step+2 == depth: self.data = child.get('rank') | |
1948 elif path[step+2] == 'Check': | |
1949 self.data = 'Skill Check: ' + child.get('name') + ' [1d20+'+str( int(child.get('rank')) + int(pc_stats[child.get('stat')][1]) )+']' | |
1950 return | |
1951 | |
1952 if path[step] == 'Feat': | |
1953 if node_class not in ('d20char_handler', "SWd20char_handler"): node = node.find('snf') | |
1954 node = node.find('feats') | |
1955 child_list = node.findall('feat') | |
1956 for child in child_list: | |
1957 if path[step+1] == child.get('name'): | |
1958 if step+2 == depth: self.data = child.get('name') + ': ' + child.get('desc') | |
1959 return | |
1960 | |
1961 if path[step] == 'Cast': | |
1962 if node_class not in ('d20char_handler', "SWd20char_handler"): node = node.find('snp') | |
1963 node = node.find('spells') | |
1964 child_list = node.findall('spell') | |
1965 for child in child_list: | |
1966 if path[step+1] == child.get('name'): | |
1967 if step+2 == depth: self.data = child.get('name') + ': ' + child.get('desc') | |
1968 return | |
1969 | |
1970 if path[step] == 'Attack': | |
1971 if node_class not in ('d20char_handler', "SWd20char_handler"): node = node.find('combat') | |
1972 if path[step+1] == 'Melee' or path[step+1] == 'M': | |
1973 bonus = node.find('attacks') | |
1974 bonus = bonus.find('melee') | |
1975 bonus = bonus.attrib; d = 0 | |
1976 elif path[step+1] == 'Ranged' or path[step+1] == 'R': | |
1977 bonus = node.find('attacks') | |
1978 bonus = bonus.find('ranged') | |
1979 bonus = bonus.attrib; d = 0 | |
1980 for b in bonus: | |
1981 d += int(bonus[b]) | |
1982 bonus = str(d) | |
1983 if path[step+2] == None: | |
1984 self.data = bonus | |
1985 else: | |
1986 weapons = node.find('attacks') | |
1987 weapons = weapons.findall('weapon') | |
1988 for child in weapons: | |
1989 if path[step+2] == child.get('name'): | |
1990 self.data = 'Attack: '+child.get('name')+' [1d20+'+bonus+'] ' + 'Damage: ['+child.get('damage')+']' | |
1991 return | |
1992 | |
1993 elif pc_stats.has_key(path[step]): | |
1994 if step+1 == depth: self.data = pc_stats[path[step]][0] + ' +('+pc_stats[path[step]][1]+')' | |
1995 elif path[step+1] == 'Mod': self.data = pc_stats[path[step]][1] | |
1996 elif path[step+1] == 'Check': self.data = path[step] + ' Check: [1d20+' + str(pc_stats[path[step]][1]) +']' | |
1997 return | |
1998 | |
1932 | 1999 |
1933 def resolution(self, node): | 2000 def resolution(self, node): |
1934 if self.passed == False: | 2001 if self.passed == False: |
1935 self.passed = True | 2002 self.passed = True |
1936 if node.get('class') == 'textctrl_handler': self.data = str(node.find('text').text) | 2003 if node.get('class') == 'textctrl_handler': self.data = str(node.find('text').text) |
1937 else: self.data = 'Nodehandler for '+ node.get('class') + ' not done!' or 'No Data!' | 2004 else: self.data = 'Nodehandler for '+ node.get('class') + ' not done!' or 'Invalid Reference!' |
1938 else: | 2005 else: |
1939 self.data = '' | 2006 self.data = '' |
1940 pass | 2007 pass |
1941 self.data = self.ParseMap(self.data, node) | 2008 self.data = self.ParseMap(self.data, node) |
1942 | 2009 |
1943 def ParseMap(self, s, node): | 2010 def ParseMap(self, s, node): |
1944 """Parses player input for embedded nodes rolls""" | 2011 """Parses player input for embedded nodes rolls""" |
1945 cur_loc = 0 | 2012 cur_loc = 0 |
1946 reg = re.compile("(!!(.*?)!!)") | 2013 reg = re.compile("(!!(.*?)!!)") |
1947 matches = reg.findall(s) | 2014 matches = reg.findall(s) |
1948 print matches | |
1949 for i in xrange(0,len(matches)): | 2015 for i in xrange(0,len(matches)): |
1950 newstr = txt = '!@' + node.get('map') + '::' + matches[i][1] + '@!' | 2016 newstr = txt = '!@' + node.get('map') + '::' + matches[i][1] + '@!' |
1951 s = s.replace(matches[i][0], newstr, 1) | 2017 s = s.replace(matches[i][0], newstr, 1) |
1952 s = self.ParseNode(s) | 2018 s = self.ParseNode(s) |
1953 return s | 2019 return s |
1954 | 2020 |
1955 def resolve_nodes(self, s): | 2021 def resolve_nodes(self, s): |
1956 self.passed = False | 2022 self.passed = False |
1957 self.data = 'No Data!' | 2023 self.data = 'Invalid Reference!' |
1958 value = "" | 2024 value = "" |
1959 path = s.split('::') | 2025 path = s.split('::') |
1960 depth = len(path) | 2026 depth = len(path) |
1961 self.gametree = component.get('tree') | 2027 self.gametree = component.get('tree') |
1962 dom = self.gametree.xml_root.getchildren() | 2028 node = self.gametree.tree_map[path[0]]['node'] |
1963 for node in dom: | 2029 if node.get('class') in ('dnd35char_handler', "SWd20char_handler", "d20char_handler", "dnd3echar_handler"): self.resolve_cust_loop(node, path, 1, depth) |
1964 if node.get('name') == path[0]: | 2030 else: self.resolve_loop(node, path, 1, depth) |
1965 self.resolve_loop(node, path, 1, len(path)) | |
1966 return self.data | 2031 return self.data |