annotate orpg/gametree/nodehandlers/dnd3e.py @ 39:ed322725b928 ornery-orc tip

Traipse 'OpenRPG' {110114-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 (Closed) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order New to Server GUI, can now clear log New Earthdawn Dieroller New IronClaw roller, sheet, and image New ShapeShifter PC Sheet Updates: Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence. Update to Browser Server window. Display rooms with ' " & cleaner Update to Server. Handles ' " & cleaner Update to Dieroller. Cleaner, more effecient expression system Update to Hidden Die plugin, allows for non standard dice rolls Update to location.py, allows for more portable references when starting Traipse Update to the Features node Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to Server, removing wxPython dependencies where not needed Fix to metaservers.xml file not being created Fix to Single and Double quotes in Whiteboard text Fix to Background images not showing when using the Image Server Fix to Duplicate chat names appearing Fix to Server GUI's logging output Fix to FNB.COLORFUL_TABS bug Fix to Gametree for XSLT Sheets Fix to Gametree for locating gametree files Fix to Send to Chat from Gametree Fix to Gametree, renaming and remapping operates correctly Fix to aliaslib, prevents error caused when SafeHTML is sent None
author sirebral
date Fri, 14 Jan 2011 05:24:52 -0600
parents d02e9197c066
children
rev   line source
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
3 # openrpg-dev@lists.sourceforge.net
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
4 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
5 # This program is free software; you can redistribute it and/or modify
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
6 # it under the terms of the GNU General Public License as published by
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
8 # (at your option) any later version.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
9 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
10 # This program is distributed in the hope that it will be useful,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
13 # GNU General Public License for more details.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
14 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
15 # You should have received a copy of the GNU General Public License
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
16 # along with this program; if not, write to the Free Software
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
18 # --
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
19 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
20 # File: dnd3e.py
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
21 # Author: Chris Davis & Digitalxero
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
22 # Maintainer: leadb
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
23 # Version:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
24 # $Id: dnd3e.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
25 #
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
26 # Description: The file contains code for the dnd3e nodehanlers
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
27 #
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
28
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
29 from core import *
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
30 from containers import *
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
31 from string import * #a 1.6003
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
32 from inspect import * #a 1.9001
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
33 from orpg.dirpath import dir_struct
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
34 from orpg.tools.orpg_log import debug
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
35 from xml.etree.ElementTree import parse
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
36 from orpg.tools.InterParse import Parse
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
37
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
38 dnd3e_EXPORT = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
39 ############Global Stuff##############
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
40
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
41 HP_CUR = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
42 HP_MAX = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
43 PP_CUR = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
44 PP_MAX = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
45 PP_FRE = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
46 PP_MFRE = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
47 HOWTO_MAX = wx.NewId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
48
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
49 def getRoot (node): # a 1.5002 this whole function is new.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
50 root = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
51 target = node
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
52 while target != None:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
53 root = target
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
54 target = target.hparent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
55 return root
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
56
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
57 # if a method runs getRoot for its instance and assigns the
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
58 # value returned to self.root, you can get to instances X via Y
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
59 # instance handle via invocation
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
60 # --------------- --- -----------
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
61 # classes via self.root.classes
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
62 # abilities via self.root.abilities
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
63 # pp via self.root.pp
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
64 # general via self.root.general
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
65 # saves via self.root.saves
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
66 # attacks via self.root.attacks
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
67 # ac via self.root.ac
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
68 # feats via self.root.feats
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
69 # spells via self.root.spells
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
70 # divine via self.root.divine
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
71 # powers via self.root.powers
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
72 # inventory via self.root.inventory
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
73 # hp via self.root.hp
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
74 # skills via self.root.skills
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
75 #... if other instances are needed and the instance exists uniquely,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
76 # add to the instance you need access to in the __init__ section the following:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
77 # self.hparent = parent # or handler if a wx instance, also add up chain
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
78 # self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
79 # self.root.{instance handle} = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
80 # # replace {instance handle} with your designation
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
81 # then, where you need access to the instance, simply add this to the instance
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
82 # that needs to reference
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
83 # self.hparent = getRoot(self) # in the init section, if not already there
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
84 # self.root = getRoot(self) # also in the init
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
85 # then to refer to the instance where you need it:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
86 # self.root.{instance handle}.{whatever you need}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
87 # # replace {instance handle} with your designation
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
88 # # replace {whatever you need} with the attribute/method u want.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
89
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
90 def safeGetAttr(node, label, defRetV=None):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
91 cna=node.attrib
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
92 for key in cna:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
93 if key == label: return cna[key]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
94 return defRetV
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
95
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
96
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
97 ########End of My global Stuff########
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
98 ########Start of Main Node Handlers#######
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
99 class dnd3echar_handler(container_handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
100 """ Node handler for a dnd3e charactor
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
101 <nodehandler name='?' module='dnd3e' class='dnd3echar_handler2' />
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
102 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
103 def __init__(self,xml_dom,tree_node):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
104 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
105 self.Version = "v1.901" #a 1.6000 general documentation, usage.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
106
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
107 print "dnd3echar_handler - version:", self.Version #m 1.6000
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
108
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
109 self.hparent = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
110 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
111 self.child_handlers = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
112 self.new_child_handler('howtouse','HowTo use this tool',dnd3ehowto,'note')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
113 self.new_child_handler('general','GeneralInformation',dnd3egeneral,'gear')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
114 self.new_child_handler('inventory','MoneyAndInventory',dnd3einventory,'money')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
115 self.new_child_handler('character','ClassesAndStats',dnd3eclassnstats,'knight')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
116 self.new_child_handler('snf','SkillsAndFeats',dnd3eskillsnfeats,'book')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
117 self.new_child_handler('combat','Combat',dnd3ecombat,'spears')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
118 self.new_child_handler('snp','SpellsAndPowers',dnd3esnp,'flask')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
119 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
120
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
121 def new_child_handler(self,tag,text,handler_class,icon='gear'):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
122 node_list = self.xml.findall(tag)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
123 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
124 i = self.tree.icons[icon]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
125 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
126 handler = handler_class(node_list[0],new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
127 tree.SetPyData(new_tree_node,handler)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
128 self.child_handlers[tag] = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
129
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
130 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
131 return tabbed_panel(parent,self,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
132
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
133 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
134 return tabbed_panel(parent,self,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
135
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
136 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
137 html_str = "<table><tr><td colspan=2 >"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
138 html_str += self.general.tohtml()+"</td></tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
139 html_str += "<tr><td width='50%' valign=top >"+self.abilities.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
140 html_str += "<P>" + self.saves.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
141 html_str += "<P>" + self.attacks.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
142 html_str += "<P>" + self.ac.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
143 html_str += "<P>" + self.feats.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
144 html_str += "<P>" + self.spells.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
145 html_str += "<P>" + self.divine.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
146 html_str += "<P>" + self.powers.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
147 html_str += "<P>" + self.inventory.tohtml() +"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
148 html_str += "<td width='50%' valign=top >"+self.classes.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
149 html_str += "<P>" + self.hp.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
150 html_str += "<P>" + self.pp.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
151 html_str += "<P>" + self.skills.tohtml() +"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
152 html_str += "</tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
153 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
154
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
155 def about(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
156 """html_str = "<img src='" + dir_struct["icon"]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
157 html_str += "dnd3e_logo.gif' ><br><b>dnd3e Character Tool "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
158 html_str += self.Version+"</b>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
159 html_str += "<br>by Dj Gilcrease<br>digitalxero@gmail.com"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
160 return html_str"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
161 text = 'dnd3e Character Tool' + self.Version +'\n'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
162 text += 'by Dj Gilcrease digitalxero@gmail.com'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
163 return text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
164
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
165 ########Core Handlers are done now############
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
166 ########Onto the Sub Nodes########
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
167 ##Primary Sub Node##
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
168
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
169 class outline_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
170 def __init__(self, parent, handler, wnd, txt,):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
171 self.parent = parent #a 1.9001
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
172 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
173 self.panel = wnd(self,handler)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
174 self.sizer = wx.StaticBoxSizer(wx.StaticBox(self,-1,txt), wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
175
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
176 self.sizer.Add(self.panel, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
177 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
178 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
179 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
180
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
181 class dnd3e_char_child(node_handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
182 """ Node Handler for skill. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
183 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
184 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
185 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
186 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
187 self.char_hander = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
188 self.drag = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
189 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
190 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
191
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
192 def on_drop(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
193 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
194
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
195 def on_rclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
196 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
197
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
198 def on_ldclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
199 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
200
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
201 def on_html(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
202 html_str = self.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
203 wnd = http_html_window(self.frame.note,-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
204 wnd.title = self.xml.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
205 self.frame.add_panel(wnd)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
206 wnd.SetPage(html_str)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
207
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
208 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
209 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
210
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
211 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
212 return self.get_design_panel(parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
213
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
214 def delete(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
215 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
216
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
217 ###Child Nodes Organized the way they are in the XML for easier viewing#### #m 1.5002 corrected typo.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
218 class dnd3ehowto(dnd3e_char_child): #m 1.5002 corrected string below to reflect "how to"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
219 """ Node Handler for how to instructions. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
220 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
221 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
222 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
223 dnd3e_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
224 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
225
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
226 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
227 wnd = howto_panel(parent, self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
228 wnd.title = "How To"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
229 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
230
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
231 class howto_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
232 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
233 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
234
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
235 pname = handler.xml.set("name", 'How To')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
236 self.sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'How To'), wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
237 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
238 n_list = self.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
239 for n in n_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
240 self.sizer.Add(wx.StaticText(self, -1, n.text), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
241 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
242 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
243 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
244
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
245 class dnd3egeneral(dnd3e_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
246 """ Node Handler for general information. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
247 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
248 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
249 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
250 dnd3e_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
251 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
252 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
253 self.root.general = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
254 self.charName = self.get_char_name()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
255
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
256 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
257 wnd = outline_panel(parent,self,gen_grid,"General Information")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
258 wnd.title = "General Info"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
259 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
260
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
261 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
262 n_list = self.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
263 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>General Information</th></tr><tr><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
264 for n in n_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
265 html_str += "<B>"+n.tag.capitalize() +":</B> "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
266 html_str += n.text + ", "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
267 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
268 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
269
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
270 def on_name_change(self,name):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
271 self.char_hander.rename(name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
272 self.charName = name
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
273
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
274 def get_char_name( self ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
275 node = self.xml.findall( 'name' )[0]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
276 return node.text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
277
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
278 class gen_grid(wx.grid.Grid):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
279 """grid for gen info"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
280 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
281 pname = handler.xml.set("name", 'General')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
282 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
283
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
284 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
285 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
286 self.handler = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
287 n_list = handler.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
288 self.CreateGrid(len(n_list),2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
289 self.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
290 self.SetColLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
291 self.n_list = n_list
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
292 i = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
293 for i in range(len(n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
294
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
295 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
296 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
297 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
298 value = self.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
299 self.n_list[row].text = value
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
300 if row==0: self.handler.on_name_change(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
301
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
302 def refresh_row(self,rowi):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
303 self.SetCellValue(rowi,0,self.n_list[rowi].tag)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
304 self.SetReadOnly(rowi,0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
305 self.SetCellValue(rowi,1,self.n_list[rowi].text)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
306 self.AutoSizeColumn(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
307
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
308 class dnd3einventory(dnd3e_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
309 """ Node Handler for general information. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
310 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
311 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
312 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
313 dnd3e_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
314 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
315 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
316 self.root.inventory = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
317
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
318 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
319 wnd = inventory_pane(parent, self) #outline_panel(parent,self,inventory_grid,"Inventory")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
320 wnd.title = "Inventory"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
321 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
322
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
323 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
324 n_list = self.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
325 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>General Information</th></tr><tr><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
326 for n in n_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
327 html_str += "<B>"+n.tag.capitalize()+":</B> "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
328 html_str += n.text + "<br>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
329 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
330 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
331
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
332 class inventory_pane(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
333 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
334 wx.Panel.__init__(self, parent, wx.ID_ANY)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
335 self.n_list = handler.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
336 self.autosize = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
337 self.sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Inventory"), wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
338 self.lang = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Languages")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
339 self.gear = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Gear")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
340 self.magic = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Magic")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
341 self.grid = wx.grid.Grid(self, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
342 self.grid.CreateGrid(len(self.n_list)-3,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
343 self.grid.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
344 self.grid.SetColLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
345 for i in xrange(len(self.n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
346 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
347 sizer1.Add(self.grid, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
348 sizer1.Add(self.lang, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
349 self.sizer.Add(sizer1, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
350 sizer2 = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
351 sizer2.Add(self.gear, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
352 sizer2.Add(self.magic, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
353 self.sizer.Add(sizer2, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
354 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
355 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
356 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
357 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.lang)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
358 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.gear)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
359 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.magic)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
360 self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.on_cell_change, self.grid)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
361
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
362 def fillTextNode(self, name, value):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
363 if name == 'Languages': self.lang.SetValue(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
364 elif name == 'Gear': self.gear.SetValue(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
365 elif name == 'Magic': self.magic.SetValue(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
366
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
367 def onTextNodeChange(self, event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
368 id = event.GetId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
369 if id == self.gear.GetId():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
370 nodeName = 'Gear'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
371 value = self.gear.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
372 elif id == self.magic.GetId():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
373 nodeName = 'Magic'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
374 value = self.magic.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
375 elif id == self.lang.GetId():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
376 nodeName = 'Languages'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
377 value = self.lang.GetValue()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
378 for node in self.n_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
379 if node.tag == nodeName:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
380 node.text = value
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
381
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
382 def saveMoney(self, row, col):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
383 value = self.grid.GetCellValue(row, col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
384 self.n_list[row].text = value
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
385
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
386 def on_cell_change(self, evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
387 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
388 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
389 self.grid.AutoSizeColumn(col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
390 wx.CallAfter(self.saveMoney, row, col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
391
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
392 def refresh_row(self, row):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
393 tagname = self.n_list[row].tag
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
394 value = self.n_list[row].text
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
395 if tagname == 'Gear': self.fillTextNode(tagname, value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
396 elif tagname == 'Magic': self.fillTextNode(tagname, value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
397 elif tagname == 'Languages': self.fillTextNode(tagname, value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
398 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
399 self.grid.SetCellValue(row, 0, tagname)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
400 self.grid.SetReadOnly(row, 0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
401 self.grid.SetCellValue(row, 1, value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
402 self.grid.AutoSize()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
403
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
404
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
405 class dnd3eclassnstats(dnd3e_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
406 """ Node handler for a dnd3e charactor
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
407 <nodehandler name='?' module='dnd3e' class='dnd3echar_handler2' />
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
408 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
409 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
410 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
411 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
412 dnd3e_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
413 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
414 self.child_handlers = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
415 self.new_child_handler('abilities','Abilities Scores',dnd3eability,'gear')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
416 self.new_child_handler('classes','Classes',dnd3eclasses,'knight')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
417 self.new_child_handler('saves','Saves',dnd3esaves,'skull')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
418 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
419
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
420 def new_child_handler(self,tag,text,handler_class,icon='gear'):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
421 node_list = self.xml.findall(tag)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
422 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
423 i = self.tree.icons[icon]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
424 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
425 handler = handler_class(node_list[0],new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
426 tree.SetPyData(new_tree_node,handler)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
427 self.child_handlers[tag] = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
428
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
429 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
430 return tabbed_panel(parent,self,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
431
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
432 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
433 print 'here'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
434 return tabbed_panel(parent,self,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
435
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
436 class class_char_child(node_handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
437 """ Node Handler for skill. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
438 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
439 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
440 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
441 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
442 self.char_hander = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
443 self.drag = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
444 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
445 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
446
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
447 def on_drop(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
448 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
449
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
450 def on_rclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
451 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
452
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
453 def on_ldclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
454 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
455
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
456 def on_html(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
457 html_str = self.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
458 wnd = http_html_window(self.frame.note,-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
459 wnd.title = self.xml.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
460 self.frame.add_panel(wnd)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
461 wnd.SetPage(html_str)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
462
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
463 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
464 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
465
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
466 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
467 return self.get_design_panel(parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
468
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
469 def delete(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
470 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
471
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
472 class dnd3eability(class_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
473 """ Node Handler for ability. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
474 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
475 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
476 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
477 class_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
478 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
479 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
480 self.root.abilities = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
481 self.abilities = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
482 node_list = self.xml.findall('stat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
483 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
484 icons = tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
485 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
486 name = n.get('abbr')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
487 self.abilities[name] = n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
488 new_tree_node = tree.AppendItem( self.mytree_node, name, icons['gear'], icons['gear'] )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
489 tree.SetPyData( new_tree_node, self )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
490
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
491 def on_rclick( self, evt ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
492 item = self.tree.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
493 name = self.tree.GetItemText( item )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
494 if not item == self.mytree_node:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
495 mod = self.get_mod( name )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
496 if mod >= 0: mod1 = "+"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
497 else: mod1 = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
498 chat = self.chat
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
499 txt = '%s check: [1d20%s%s]' % ( name, mod1, mod )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
500 chat.ParsePost( txt, True, True )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
501
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
502 def get_mod(self,abbr):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
503 score = int(self.abilities[abbr].get('base'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
504 mod = (score - 10) / 2
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
505 mod = int(mod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
506 return mod
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
507
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
508 def set_score(self,abbr,score):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
509 if score >= 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
510 self.abilities[abbr].set("base",str(score))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
511
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
512 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
513 wnd = outline_panel(parent,self,abil_grid,"Abilities")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
514 wnd.title = "Abilities (edit)"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
515 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
516
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
517 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
518 html_str = """<table border='1' width=100%><tr BGCOLOR=#E9E9E9 ><th width='50%'>Ability</th>
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
519 <th>Base</th><th>Modifier</th></tr>"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
520 node_list = self.xml.findall('stat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
521 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
522 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
523 abbr = n.get('abbr')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
524 base = n.get('base')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
525 mod = str(self.get_mod(abbr))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
526 if int(mod) >= 0: mod1 = "+"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
527 else: mod1 = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
528 html_str = (html_str + "<tr ALIGN='center'><td>"+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
529 name+"</td><td>"+base+'</td><td>%s%s</td></tr>' % (mod1, mod))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
530 html_str = html_str + "</table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
531 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
532
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
533 class abil_grid(wx.grid.Grid):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
534 """grid for abilities"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
535 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
536 pname = handler.xml.set("name", 'Stats')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
537 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
538 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
539
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
540 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
541 self.Bind(wx.EVT_SIZE, self.on_size)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
542 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
543 self.handler = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
544 stats = handler.xml.findall('stat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
545 self.CreateGrid(len(stats),3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
546 self.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
547 col_names = ['Ability','Score','Modifier']
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
548 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
549 self.stats = stats
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
550 i = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
551 for i in range(len(stats)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
552 self.char_wnd = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
553
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
554 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
555 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
556 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
557 value = self.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
558 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
559 int(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
560 self.stats[row].set('base',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
561 self.refresh_row(row)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
562 except:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
563 self.SetCellValue(row,col,"0")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
564 if self.char_wnd: self.char_wnd.refresh_data()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
565
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
566 def refresh_row(self,rowi):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
567 s = self.stats[rowi]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
568 name = s.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
569 abbr = s.get('abbr')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
570 self.SetCellValue(rowi,0,name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
571 self.SetReadOnly(rowi,0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
572 self.SetCellValue(rowi,1,s.get('base'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
573 self.SetCellValue(rowi,2,str(self.handler.get_mod(abbr)))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
574 self.SetReadOnly(rowi,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
575 self.root.saves.refresh_data()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
576 self.root.attacks.refreshMRdata()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
577
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
578 def on_size(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
579 (w,h) = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
580 cols = self.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
581 col_w = w/(cols+2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
582 self.SetColSize(0,col_w*3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
583 for i in range(1,cols): self.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
584 evt.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
585 self.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
586
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
587 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
588 for r in range(self.GetNumberRows()-1): self.refresh_row(r)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
589
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
590 class dnd3eclasses(class_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
591 """ Node Handler for classes. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
592 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
593 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
594 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
595 class_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
596 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
597 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
598 self.root.classes = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
599
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
600 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
601 wnd = outline_panel(parent,self,class_panel,"Classes")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
602 wnd.title = "Classes"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
603 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
604
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
605 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
606 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Classes</th></tr><tr><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
607 n_list = self.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
608 for n in n_list: html_str += n.get('name') + " ("+n.get('level')+"), "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
609 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
610 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
611
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
612 def get_char_lvl( self, attr ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
613 node_list = self.xml.findall('class')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
614 tot = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
615 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
616 lvl = n.get('level')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
617 tot += int(lvl)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
618 type = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
619 if attr == "level": return lvl
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
620 elif attr == "class": return type
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
621 if attr == "lvl": return tot
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
622
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
623 def get_class_lvl( self, classN ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
624 node_list = self.xml.findall('class')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
625 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
626 lvl = n.get('level')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
627 type = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
628 if classN == type: return lvl
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
629
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
630 class class_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
631 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
632 pname = handler.xml.set("name", 'Class')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
633
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
634 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
635 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
636 sizer = wx.BoxSizer(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
637 sizer.Add(self.grid, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
638
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
639 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
640 sizer1.Add(wx.Button(self, 10, "Remove Class"), 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
641 sizer1.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
642 sizer1.Add(wx.Button(self, 20, "Add Class"), 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
643
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
644 sizer.Add(sizer1, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
645 self.sizer = sizer
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
646 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
647 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
648 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
649
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
650 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
651 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
652 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
653
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
654 n_list = handler.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
655 self.n_list = n_list
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
656 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
657 self.grid.CreateGrid(len(n_list),2,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
658 self.grid.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
659 self.grid.SetColLabelValue(0,"Class")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
660 self.grid.SetColLabelValue(1,"Level")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
661 for i in range(len(n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
662 self.temp_dom = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
663
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
664 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
665 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
666 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
667 value = self.grid.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
668 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
669 int(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
670 self.n_list[row].set('level',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
671 except: self.grid.SetCellValue(row,col,"1")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
672
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
673 def refresh_row(self,i):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
674 n = self.n_list[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
675 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
676 level = n.get('level')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
677 self.grid.SetCellValue(i,0,name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
678 self.grid.SetReadOnly(i,0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
679 self.grid.SetCellValue(i,1,level)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
680
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
681 def on_remove(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
682 rows = self.grid.GetNumberRows()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
683 for i in range(rows):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
684 if self.grid.IsInSelection(i,0):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
685 self.grid.DeleteRows(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
686 self.xml.remove(self.n_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
687
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
688 def on_add(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
689 if not self.temp_dom:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
690 tree = parse(dir_struct["dnd3e"]+"dnd3eclasses.xml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
691 xml_dom = tree.getroot()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
692 self.temp_dom = xml_dom
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
693 f_list = self.temp_dom.findall('class')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
694 opts = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
695 for f in f_list: opts.append(f.get('name'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
696 dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
697 if dlg.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
698 i = dlg.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
699 new_node = self.xml.append(f_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
700 self.grid.AppendRows(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
701 self.refresh_row(self.grid.GetNumberRows()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
702 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
703
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
704 def on_size(self,event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
705 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
706 self.grid.SetDimensions(0,0,s[0],s[1]-25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
707 self.sizer.SetDimension(0,s[1]-25,s[0],25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
708 (w,h) = self.grid.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
709 cols = self.grid.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
710 col_w = w/(cols)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
711 for i in range(0,cols): self.grid.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
712
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
713
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
714 class dnd3esaves(class_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
715 """ Node Handler for saves. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
716 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
717 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
718 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
719 class_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
720 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
721 self.saveGridFrame = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
722
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
723 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
724 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
725
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
726 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
727 self.root.saves = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
728 node_list = self.xml.findall('save')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
729 self.saves={}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
730 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
731 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
732 self.saves[name] = n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
733 new_tree_node = tree.AppendItem(self.mytree_node,name,icons['gear'],icons['gear'])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
734 tree.SetPyData(new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
735
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
736
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
737 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
738 # of the attack chart.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
739 # count backwards, maintains context despite "removes"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
740 for i in range(len(self.saveGridFrame)-1,-1,-1):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
741 x = self.saveGridFrame[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
742 if x == None: x.refresh_data()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
743 else: self.saveGridFrame.remove(x)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
744
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
745 def get_mod(self,name):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
746 save = self.saves[name]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
747 stat = save.get('stat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
748 stat_mod = self.root.abilities.get_mod(stat)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
749 base = int(save.get('base'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
750 miscmod = int(save.get('miscmod'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
751 magmod = int(save.get('magmod'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
752 total = stat_mod + base + miscmod + magmod
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
753 return total
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
754
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
755 def on_rclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
756 item = self.tree.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
757 name = self.tree.GetItemText(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
758 if item == self.mytree_node:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
759 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
760 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
761 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
762 mod = self.get_mod(name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
763 if mod >= 0: mod1 = "+"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
764 else: mod1 = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
765 chat = self.chat
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
766 txt = '%s save: [1d20%s%s]' % (name, mod1, mod)
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
767 Parse.Post( txt, self.chat, True, True )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
768
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
769 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
770 wnd = outline_panel(parent,self,save_grid,"Saves")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
771 wnd.title = "Saves"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
772 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
773
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
774 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
775 html_str = """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 >
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
776 <th width='30%'>Save</th>
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
777 <th>Key</th><th>Base</th><th>Abil</th><th>Magic</th>
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
778 <th>Misc</th><th>Total</th></tr>"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
779 node_list = self.xml.findall('save')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
780 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
781 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
782 stat = n.get('stat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
783 base = n.get('base')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
784 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+base+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
785 stat_mod = self.root.abilities.get_mod(stat)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
786
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
787 mag = n.get('magmod')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
788 misc = n.get('miscmod')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
789 mod = str(self.get_mod(name))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
790 if mod >= 0: mod1 = "+"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
791 else: mod1 = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
792 html_str = html_str + "<td>"+str(stat_mod)+"</td><td>"+mag+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
793 html_str = html_str + '<td>'+misc+'</td><td>%s%s</td></tr>' % (mod1, mod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
794 html_str = html_str + "</table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
795 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
796
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
797 #mark6
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
798 class save_grid(wx.grid.Grid):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
799 """grid for saves"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
800 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
801 pname = handler.xml.set("name", 'Saves')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
802 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
803 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
804 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
805 self.Bind(wx.EVT_SIZE, self.on_size)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
806 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
807 self.handler = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
808 saves = handler.xml.findall('save')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
809 self.CreateGrid(len(saves),7)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
810 self.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
811 col_names = ['Save','Key','base','Abil','Magic','Misc','Total']
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
812 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
813 self.saves = saves
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
814 i = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
815 for i in range(len(saves)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
816 climber = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
817 nameNode = climber.GetClassName()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
818 while nameNode != 'wxFrame':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
819 climber = climber.parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
820 nameNode = climber.GetClassName()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
821 masterFrame=climber
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
822 masterFrame.refresh_data=self.refresh_data
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
823 handler.saveGridFrame.append(masterFrame)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
824
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
825 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
826 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
827 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
828 value = self.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
829 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
830 int(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
831 if col == 2: self.saves[row].set('base',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
832 elif col == 4: self.saves[row].set('magmod',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
833 elif col == 5: self.saves[row].set('miscmod',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
834 self.refresh_row(row)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
835 except: self.SetCellValue(row,col,"0")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
836
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
837 def refresh_row(self,rowi):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
838 s = self.saves[rowi]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
839 name = s.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
840 self.SetCellValue(rowi,0,name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
841 self.SetReadOnly(rowi,0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
842 stat = s.get('stat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
843 self.SetCellValue(rowi,1,stat)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
844 self.SetReadOnly(rowi,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
845 self.SetCellValue(rowi,2,s.get('base'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
846 self.SetCellValue(rowi,3,str(self.root.abilities.get_mod(stat)))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
847 self.SetReadOnly(rowi,3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
848 self.SetCellValue(rowi,4,s.get('magmod'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
849 self.SetCellValue(rowi,5,s.get('miscmod'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
850 mod = str(self.handler.get_mod(name))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
851 self.SetCellValue(rowi,6,mod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
852 self.SetReadOnly(rowi,6)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
853
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
854 def on_size(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
855 (w,h) = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
856 cols = self.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
857 col_w = w/(cols+2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
858 self.SetColSize(0,col_w*3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
859 for i in range(1,cols): self.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
860 evt.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
861 self.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
862
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
863 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
864 for r in range(self.GetNumberRows()): self.refresh_row(r)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
865
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
866 class dnd3eskillsnfeats(dnd3e_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
867 """ Node handler for a dnd3e charactor
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
868 <nodehandler name='?' module='dnd3e' class='dnd3echar_handler2' />
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
869 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
870 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
871 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
872 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
873 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
874 dnd3e_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
875 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
876 self.child_handlers = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
877 self.new_child_handler('skills','Skills',dnd3eskill,'book')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
878 self.new_child_handler('feats','Feats',dnd3efeats,'book')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
879 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
880
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
881 def new_child_handler(self,tag,text,handler_class,icon='gear'):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
882 node_list = self.xml.findall(tag)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
883 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
884 i = self.tree.icons[icon]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
885 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
886 handler = handler_class(node_list[0],new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
887 tree.SetPyData(new_tree_node,handler)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
888 self.child_handlers[tag] = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
889
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
890 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
891 return tabbed_panel(parent,self,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
892
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
893 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
894 return tabbed_panel(parent,self,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
895
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
896 class skills_char_child(node_handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
897 """ Node Handler for skill. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
898 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
899 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
900 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
901 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
902 self.char_hander = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
903 self.drag = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
904 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
905 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
906
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
907 def on_drop(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
908 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
909
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
910 def on_rclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
911 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
912
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
913 def on_ldclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
914 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
915
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
916 def on_html(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
917 html_str = self.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
918 wnd = http_html_window(self.frame.note,-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
919 wnd.title = self.xml.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
920 self.frame.add_panel(wnd)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
921 wnd.SetPage(html_str)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
922
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
923 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
924 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
925
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
926 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
927 return self.get_design_panel(parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
928
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
929 def delete(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
930 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
931
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
932 class dnd3eskill(skills_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
933 """ Node Handler for skill. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
934 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
935 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
936 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
937 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
938 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
939 self.root.skills = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
940
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
941 skills_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
942 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
943 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
944 node_list = self.xml.findall('skill')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
945
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
946 self.skills={}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
947 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
948 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
949 self.skills[name] = n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
950 skill_check = self.skills[name]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
951 ranks = int(skill_check.get('rank'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
952 trained = int(skill_check.get('untrained'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
953 if ranks > 0 or trained == 1:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
954 new_tree_node = tree.AppendItem(self.mytree_node,name,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
955 icons['gear'],icons['gear'])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
956 else: continue
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
957 tree.SetPyData(new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
958
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
959
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
960 def refresh_skills(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
961 #Adding this so when you update the grid the tree will reflect
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
962 #The change. -mgt
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
963 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
964 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
965 tree.CollapseAndReset(self.mytree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
966 node_list = self.xml.findall('skill')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
967 self.skills={}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
968 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
969 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
970 self.skills[name] = n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
971 skill_check = self.skills[name]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
972 ranks = int(skill_check.get('rank'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
973 trained = int(skill_check.get('untrained'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
974 if ranks > 0 or trained == 1:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
975 new_tree_node = tree.AppendItem(self.mytree_node,name,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
976 icons['gear'],icons['gear'])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
977 else: continue
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
978 tree.SetPyData(new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
979
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
980 def get_mod(self,name):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
981 skill = self.skills[name]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
982 stat = skill.get('stat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
983 stat_mod = self.root.abilities.get_mod(stat)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
984 rank = int(skill.get('rank'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
985 misc = int(skill.get('misc'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
986 total = stat_mod + rank + misc
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
987 return total
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
988
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
989 def on_rclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
990 item = self.tree.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
991 name = self.tree.GetItemText(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
992 if item == self.mytree_node: return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
993 ac = self.root.ac.get_check_pen()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
994 skill = self.skills[name]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
995 untr = skill.get('untrained')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
996 rank = skill.get('rank')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
997 if eval('%s == 0' % (untr)):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
998 if eval('%s == 0' % (rank)):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
999 res = 'You fumble around, accomplishing nothing'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1000 txt = '%s Skill Check: %s' % (name, res)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1001 chat = self.chat
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1002 chat.Post(txt,True,True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1003 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1004 armor = ''
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1005 acCp = ''
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1006 if ac < 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1007 armorCheck = int(skill.get('armorcheck'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1008 if armorCheck == 1:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1009 acCp=ac
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1010 armor = '(includes Armor Penalty of %s)' % (acCp)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1011 if item == self.mytree_node:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1012 dnd3e_char_child.on_ldclick(self,evt)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1013 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1014 mod = self.get_mod(name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1015 if mod >= 0: mod1 = "+"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1016 else: mod1 = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1017 chat = self.chat
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1018 txt = '%s Skill Check: [1d20%s%s%s] %s' % (
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1019 name, mod1, mod, acCp, armor)
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
1020 Parse.Post( txt, self.chat, True, True )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1021
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1022 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1023 wnd = outline_panel(parent,self,skill_grid,"Skills")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1024 wnd.title = "Skills (edit)"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1025 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1026
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1027 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1028 html_str = """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 >
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1029 <th width='30%'>Skill</th><th>Key</th>
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1030 <th>Rank</th><th>Abil</th><th>Misc</th><th>Total</th></tr>"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1031 node_list = self.xml.findall('skill')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1032
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1033 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1034 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1035 stat = n.get('stat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1036 rank = n.get('rank')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1037 untr = n.get('untrained')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1038 #Filter unsuable skills out of pretty print -mgt
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1039 if eval('%s > 0' % (rank)) or eval('%s == 1' % (untr)):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1040 if eval('%s >=1' % (rank)):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1041 html_str += "<tr ALIGN='center' bgcolor='#CCCCFF'><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1042 html_str += name+"</td><td>"+stat+"</td><td>"+rank+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1043 elif eval('%s == 1' % (untr)):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1044 html_str += "<tr ALIGN='center' bgcolor='#C0FF40'><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1045 html_str += name+"</td><td>"+stat+"</td><td>"+rank+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1046 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1047 html_str += "<tr ALIGN='center'><td>"+name+"</td><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1048 html_str += stat+"</td><td>"+rank+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1049 else: continue
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1050 stat_mod = self.root.abilities.get_mod(stat)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1051 misc = n.get('misc')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1052 mod = str(self.get_mod(name))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1053 if mod >= 0: mod1 = "+"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1054 else: mod1 = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1055 html_str += "<td>"+str(stat_mod)+"</td><td>"+misc #m 1.6009 str()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1056 html_str += '</td><td>%s%s</td></tr>' % (mod1, mod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1057 html_str = html_str + "</table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1058 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1059
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1060
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1061 class skill_grid(wx.grid.Grid):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1062 """ panel for skills """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1063 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1064 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1065 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1066 pname = handler.xml.set("name", 'Skills')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1067
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1068 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1069 self.Bind(wx.EVT_SIZE, self.on_size)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1070 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1071 self.handler = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1072 skills = handler.xml.findall('skill')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1073
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1074 self.CreateGrid(len(skills),6)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1075 self.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1076 col_names = ['Skill','Key','Rank','Abil','Misc','Total']
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1077 for i in range(len(col_names)):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1078 self.SetColLabelValue(i,col_names[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1079 rowi = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1080 self.skills = skills
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1081 for i in range(len(skills)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1082
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1083 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1084 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1085 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1086 value = self.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1087 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1088 int(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1089 if col == 2: self.skills[row].set('rank',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1090 elif col ==4: self.skills[row].set('misc',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1091 self.refresh_row(row)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1092 except: self.SetCellValue(row,col,"0")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1093 self.handler.refresh_skills()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1094
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1095 def refresh_row(self,rowi):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1096 s = self.skills[rowi]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1097 name = s.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1098 self.SetCellValue(rowi,0,name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1099 self.SetReadOnly(rowi,0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1100 stat = s.get('stat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1101 self.SetCellValue(rowi,1,stat)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1102 self.SetReadOnly(rowi,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1103 self.SetCellValue(rowi,2,s.get('rank'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1104 if self.root.abilities: stat_mod=self.root.abilities.get_mod(stat)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1105 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1106 stat_mod = -6
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1107 print "Please advise dnd3e maintainer alert 1.5002 raised"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1108
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1109 self.SetCellValue(rowi,3,str(stat_mod))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1110 self.SetReadOnly(rowi,3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1111 self.SetCellValue(rowi,4,s.get('misc'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1112 mod = str(self.handler.get_mod(name))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1113 self.SetCellValue(rowi,5,mod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1114 self.SetReadOnly(rowi,5)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1115
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1116 def on_size(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1117 (w,h) = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1118 cols = self.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1119 col_w = w/(cols+2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1120 self.SetColSize(0,col_w*3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1121 for i in range(1,cols): self.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1122 evt.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1123 self.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1124
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1125 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1126 for r in range(self.GetNumberRows()): self.refresh_row(r)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1127
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1128
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1129 class dnd3efeats(skills_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1130 """ Node Handler for classes. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1131 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1132 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1133 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1134 skills_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1135 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1136 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1137 self.root.feats = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1138
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1139 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1140 setTitle="Feats - " + self.root.general.charName
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1141 wnd = outline_panel(parent,self,feat_panel,setTitle)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1142 wnd.title = "Feats"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1143 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1144
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1145 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1146 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Feats</th></tr><tr><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1147 n_list = self.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1148 for n in n_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1149 html_str += n.get('name')+ ", "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1150 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1151 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1152
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1153 class feat_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1154 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1155
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1156 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1157 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1158 pname = handler.xml.set("name", 'Feats')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1159 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1160 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1161 sizer = wx.BoxSizer(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1162 sizer.Add(self.grid, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1163 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1164 sizer1.Add(wx.Button(self, 10, "Remove Feat"), 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1165 sizer1.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1166 sizer1.Add(wx.Button(self, 20, "Add Feat"), 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1167 sizer.Add(sizer1, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1168 self.sizer = sizer
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1169 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1170 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1171 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1172 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1173 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1174 n_list = handler.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1175 self.n_list = n_list
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1176 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1177 self.grid.CreateGrid(len(n_list),3,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1178 self.grid.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1179 self.grid.SetColLabelValue(0,"Feat")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1180 self.grid.SetColLabelValue(1,"Type")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1181 self.grid.SetColLabelValue(2,"Reference")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1182 for i in range(len(n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1183 self.temp_dom = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1184
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1185 def refresh_row(self,i):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1186 feat = self.n_list[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1187 name = feat.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1188 type = feat.get('type')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1189 desc = feat.get('desc')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1190 self.grid.SetCellValue(i,0,name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1191 self.grid.SetReadOnly(i,0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1192 self.grid.SetCellValue(i,1,type)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1193 self.grid.SetReadOnly(i,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1194 self.grid.SetCellValue(i,2,desc)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1195 self.grid.SetReadOnly(i,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1196
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1197 def on_remove(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1198 rows = self.grid.GetNumberRows()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1199 for i in range(rows):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1200 if self.grid.IsInSelection(i,0):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1201 self.grid.DeleteRows(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1202 self.xml.remove(self.n_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1203
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1204 def on_add(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1205
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1206 if not self.temp_dom:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1207 tree = parse(dir_struct["dnd3e"]+"dnd3efeats.xml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1208 temp_dom = tree.getroot()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1209 f_list = temp_dom.findall('feat')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1210 opts = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1211 for f in f_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1212 opts.append(f.get('name') + " - [" +
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1213 f.get('type') + "] - " + f.get('desc'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1214 dlg = wx.SingleChoiceDialog(self,'Choose Feat','Feats',opts)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1215 if dlg.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1216 i = dlg.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1217 new_node = self.xml.append(f_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1218 self.grid.AppendRows(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1219 self.refresh_row(self.grid.GetNumberRows()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1220 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1221
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1222
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1223 def on_size(self,event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1224 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1225 self.grid.SetDimensions(0,0,s[0],s[1]-25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1226 self.sizer.SetDimension(0,s[1]-25,s[0],25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1227 (w,h) = self.grid.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1228 cols = self.grid.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1229 col_w = w/(cols)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1230 for i in range(0,cols):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1231 self.grid.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1232
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1233 class dnd3ecombat(dnd3e_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1234 """ Node handler for a dnd3e charactor
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1235 <nodehandler name='?' module='dnd3e' class='dnd3echar_handler2' />
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1236 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1237 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1238
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1239 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1240
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1241 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1242 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1243 dnd3e_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1244 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1245 self.child_handlers = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1246 self.new_child_handler('hp','Hit Points',dnd3ehp,'gear')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1247 self.new_child_handler('attacks','Attacks',dnd3eattacks,'spears')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1248 self.new_child_handler('ac','Armor',dnd3earmor,'spears')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1249 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1250
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1251 def new_child_handler(self,tag,text,handler_class,icon='gear'):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1252 node_list = self.xml.findall(tag)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1253 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1254 i = self.tree.icons[icon]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1255 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1256 handler = handler_class(node_list[0],new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1257 tree.SetPyData(new_tree_node,handler)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1258 self.child_handlers[tag] = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1259
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1260 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1261 return tabbed_panel(parent,self,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1262
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1263 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1264 return tabbed_panel(parent,self,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1265
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1266
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1267 class combat_char_child(node_handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1268 """ Node Handler for combat. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1269 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1270 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1271 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1272 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1273 self.char_hander = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1274 self.drag = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1275 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1276 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1277
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1278 def on_drop(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1279 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1280
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1281 def on_rclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1282 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1283
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1284 def on_ldclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1285 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1286
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1287 def on_html(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1288 html_str = self.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1289 wnd = http_html_window(self.frame.note,-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1290 wnd.title = self.xml.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1291 self.frame.add_panel(wnd)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1292 wnd.SetPage(html_str)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1293
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1294 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1295 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1296
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1297 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1298 return self.get_design_panel(parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1299
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1300 def delete(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1301 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1302
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1303 class dnd3ehp(combat_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1304 """ Node Handler for hit points. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1305 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1306 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1307 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1308 combat_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1309 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1310 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1311 self.root.hp = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1312
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1313 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1314 wnd = outline_panel(parent,self,hp_panel,"Hit Points")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1315 wnd.title = "Hit Points"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1316 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1317
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1318 def on_rclick( self, evt ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1319 chp = self.xml.get('current')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1320 mhp = self.xml.get('max')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1321 txt = '((HP: %s / %s))' % ( chp, mhp )
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
1322 Parse.Post( txt, self.chat, True, True )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1323
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1324 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1325 html_str = "<table width=100% border=1 >"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1326 html_str += "<tr BGCOLOR=#E9E9E9 ><th colspan=4>Hit Points</th></tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1327 html_str += "<tr><th>Max:</th>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1328 html_str += "<td>"+self.xml.get('max')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1329 html_str += "<th>Current:</th>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1330 html_str += "<td>"+self.xml.get('current')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1331 html_str += "</tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1332 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1333
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1334 class hp_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1335 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1336 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1337 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1338 pname = handler.xml.set("name", 'HitPoints')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1339 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1340 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1341 self.sizer.AddMany([ (wx.StaticText(self, -1, "HP Current:"), 0,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1342 wx.ALIGN_CENTER_VERTICAL),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1343 (wx.TextCtrl(self, HP_CUR,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1344 self.xml.get('current')), 0, wx.EXPAND),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1345 (wx.StaticText(self, -1, "HP Max:"), 0, wx.ALIGN_CENTER_VERTICAL),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1346 (wx.TextCtrl(self, HP_MAX, self.xml.get('max')),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1347 0, wx.EXPAND),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1348 ])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1349 self.sizer.AddGrowableCol(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1350 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1351 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1352 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1353 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_MAX)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1354 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_CUR)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1355
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1356 def on_text(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1357 id = evt.GetId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1358 if id == HP_CUR: self.xml.set('current',evt.GetString())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1359 elif id == HP_MAX: self.xml.set('max',evt.GetString())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1360
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1361 def on_size(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1362 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1363 self.sizer.SetDimension(0,0,s[0],s[1])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1364
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1365 class dnd3eattacks(combat_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1366 """ Node Handler for attacks. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1367 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1368 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1369 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1370 combat_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1371 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1372 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1373 self.root.attacks = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1374 self.mrFrame = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1375 self.updateFootNotes = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1376 self.updateFootNotes = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1377 self.html_str = "<html><body>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1378 self.html_str += ("<br> This character has weapons with no "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1379 "footnotes. This program will "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1380 "add footnotes to the weapons which have names that still match "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1381 "the orginal names. If you have changed the weapon name, you "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1382 "will see some weapons with a footnote of 'X', you will have "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1383 "to either delete and re-add the weapon, or research "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1384 "and add the correct footnotes for the weapon.\n"+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1385 "<br> Please be aware, that only the bow/sling footnote is "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1386 "being used to affect changes to rolls; implemenation of other "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1387 "footnotes to automaticly adjust rolls will be completed as "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1388 "soon as time allows." +
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1389 "<br><br>Update to character:"+self.root.general.charName+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1390 "<br><br>"+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1391 """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 >
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1392 <th width='80%'>Weapon Name</th><th>Added Footnote</th></tr>\n""")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1393 self.temp_dom={}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1394 node_list = self.xml.findall('melee')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1395 self.melee = node_list[0]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1396 node_list = self.xml.findall('ranged')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1397 self.ranged = node_list[0]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1398 self.refresh_weapons()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1399 if self.updateFootNotes == True:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1400 self.updateFootNotes = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1401 name = self.root.general.charName
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1402 self.html_str += "</table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1403 self.html_str += "</body> </html> "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1404 masterFrame = self.root.frame
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1405 title = name+"'s weapons' update to have footnotes"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1406 fnFrame = wx.Frame(masterFrame, -1, title)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1407 fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1408 fnFrame.panel.SetPage(self.html_str)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1409 fnFrame.Show()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1410
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1411
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1412
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1413 def refreshMRdata(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1414 # of the attack chart.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1415 # count backwards, maintains context despite "removes"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1416 for i in range(len(self.mrFrame)-1,-1,-1):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1417 x = self.mrFrame[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1418 if x == None: x.refreshMRdata() #a 1.9001
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1419 else: self.mrFrame.remove(x)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1420
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1421 def refresh_weapons(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1422 self.weapons = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1423
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1424 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1425 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1426 tree.CollapseAndReset(self.mytree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1427 node_list = self.xml.findall('weapon')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1428 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1429 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1430 fn = safeGetAttr(n,'fn')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1431 if fn == None:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1432 self.updateFootNotes=True
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1433 self.updateFootN(n)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1434 new_tree_node = tree.AppendItem(
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1435 self.mytree_node,name,icons['sword'],icons['sword'])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1436 tree.SetPyData(new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1437 self.weapons[name]=n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1438
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1439 def updateFootN(self,n):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1440 if not self.temp_dom:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1441 tree = parse(dir_struct["dnd3e"]+"dnd3eweapons.xml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1442 self.temp_dom = tree.getroot()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1443 nameF = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1444 w_list = self.temp_dom.findall('weapon')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1445 found = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1446 for w in w_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1447 if nameF == w.get('name'):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1448 found = True
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1449 fnN = safeGetAttr(n,'fn')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1450 if fnN == None or fnN == 'None':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1451 fnW = w.get('fn')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1452 self.html_str += ("<tr ALIGN='center'><td>"+nameF+"</td>"+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1453 "<td>"+fnW+"</td></tr>\n")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1454 n.set('fn',fnW)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1455 break
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1456 if not found:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1457 self.html_str += ("<tr ALIGN='center'><td>"+nameF+" - Custom "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1458 "Weapon, research "+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1459 "and update manually; setting footnote to indicate custom</td>"+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1460 "<td>"+'X'+"</td></tr>\n")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1461 n.set('fn','X')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1462
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1463 def get_mod(self,type='m'):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1464 (base, base2, base3, base4, base5, base6, stat_mod, misc) \
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1465 = self.get_attack_data(type)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1466 return int(base + misc + int(stat_mod))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1467
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1468 def get_attack_data(self,type='m'):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1469 if type=='m' or type=='0':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1470 stat = 'Str'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1471 temp = self.melee
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1472 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1473 stat = 'Dex'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1474 temp = self.ranged
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1475 stat_mod = -7
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1476 stat_mod = self.root.abilities.get_mod(stat)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1477 base = int(temp.get('base'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1478 base2 = int(temp.get('second'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1479 base3 = int(temp.get('third'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1480 base4 = int(temp.get('forth'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1481 base5 = int(temp.get('fifth'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1482 base6 = int(temp.get('sixth'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1483 misc = int(temp.get('misc'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1484 return (base, base2, base3, base4, base5, base6, stat_mod ,misc)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1485
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1486 def on_rclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1487 item = self.tree.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1488
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1489 name = self.tree.GetItemText(item)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1490 if item == self.mytree_node:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1491 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1492 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1493
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1494 mod = int(self.weapons[name].get('mod'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1495 wepMod = mod #a 1.5008
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1496 footNotes = safeGetAttr(self.weapons[name],'fn','')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1497 cat = self.weapons[name].get('category') #a1.6001
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1498 result = split(cat,"-",2) #a 1.6001
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1499 if len(result) < 2: #a 1.6021 this if & else
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1500 print "warning: 1.6002 unable to interpret weapon category"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1501 print "format 'type weapon-[Range|Melee]', probably missing"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1502 print "the hyphen. Assuming Melee"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1503 print "weapon name: ",name
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1504 tres="Melee"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1505 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1506 tres=result[1]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1507 if tres == 'Melee': #a 1.6001 #m 1.6022 use of tres here and...
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1508 rangeOrMelee = 'm' #a 1.5008 code demote for next comment block
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1509 elif tres == 'Ranged': #m 1.6001 (was just else) #m 1.6022 here
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1510 rangeOrMelee = 'r' #a 1.5008
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1511 else:#a 1.6001 add this whole else clause.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1512 print "warning: 1.6001 unable to interpret weapon category"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1513 print "treating weapon as Melee, please correct xml"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1514 print "weapon name:",name
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1515 rangeOrMelee ='m'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1516 mod = mod + self.get_mod(rangeOrMelee) #a 1.5008
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1517 chat = self.chat
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1518 dmg = self.weapons[name].get('damage')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1519
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1520 #a 1.6003 start code fix instance a
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1521 result = split(dmg,"/",2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1522 dmg = result[0]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1523 monkLvl = self.root.classes.get_class_lvl('Monk') # a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1524 if dmg == "Monk Med":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1525 if monkLvl == None: #a 1.5009
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1526 txt = 'Attempting to use monk attack, but has no monk '
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1527 txt += 'levels, please choose a different attack.'
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
1528 Parse.Post( txt, self.chat, True, True )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1529 return #a 1.5009
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1530 else: #a 1.5009
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1531 lvl=int(monkLvl)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1532 if lvl <= 3: dmg = "1d6"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1533 elif lvl <= 7: dmg = "1d8"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1534 elif lvl <= 11: dmg = "1d10"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1535 elif lvl <= 15: dmg = "2d6"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1536 elif lvl <= 19: dmg = "2d8"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1537 elif lvl <= 20: dmg = "2d10"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1538 if dmg == "Monk Small":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1539 if monkLvl == None:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1540 txt = 'Attempting to use monk attack, but has no monk '
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1541 txt += 'levels, please choose a different attack.'
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
1542 Parse.Post( txt, self.chat, True, True )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1543 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1544 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1545 lvl=int(monkLvl)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1546 if lvl <= 3: dmg = "1d4"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1547 elif lvl <= 7: dmg = "1d6"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1548 elif lvl <= 11: dmg = "1d8"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1549 elif lvl <= 15: dmg = "1d10"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1550 elif lvl <= 20: dmg = "2d6"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1551 flu = ''
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1552 str_mod = self.root.abilities.get_mod('Str') #a 1.5007,11,12,13
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1553 if rangeOrMelee == 'r': #a 1.5008
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1554
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1555 if find(footNotes,'b') > -1:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1556 if str_mod >= 0: str_mod = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1557 else: str_mod = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1558 mod2 = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1559 if str_mod >= 0: mod2 = "+"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1560 aStrengthMod = mod2 + str(str_mod) #a 1.5008 applicable strength mod
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1561 if find(name ,"Flurry of Blows") > -1: #a 1.6012
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1562 flu = '-2'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1563 (base, base2, base3, base4, base5, base6, stat_mod, misc)\
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1564 = self.get_attack_data(rangeOrMelee) #a 1.5008
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1565 self.sendRoll(base ,stat_mod,misc,wepMod,name,flu,dmg,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1566 aStrengthMod,'',True,rollAnyWay=True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1567 if flu != '':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1568 self.sendRoll(base ,stat_mod,misc,wepMod,name,flu,dmg,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1569 aStrengthMod) #a 1.6021
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1570
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1571 self.sendRoll(base2,stat_mod,misc,wepMod,name,flu,dmg,aStrengthMod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1572 self.sendRoll(base3,stat_mod,misc,wepMod,name,flu,dmg,aStrengthMod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1573 self.sendRoll(base4,stat_mod,misc,wepMod,name,flu,dmg,aStrengthMod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1574 self.sendRoll(base5,stat_mod,misc,wepMod,name,flu,dmg,aStrengthMod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1575 self.sendRoll(base6,stat_mod,misc,wepMod,name,flu,dmg,aStrengthMod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1576
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1577
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1578 def sendRoll(self,base,stat_mod,misc,wepMod,name,flu,dmg,aStrengthMod,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1579 spacer="",pname=False,rollAnyWay=False):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1580 if base != 0 or rollAnyWay:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1581 base = base + int(stat_mod) + misc + wepMod #m 1.5008
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1582 if base >= 0: mod1 = "+"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1583 else: mod1 = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1584 txt = '%s ' % (spacer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1585 txt += '%s Attack Roll: <b>[1d20%s%s%s]</b>' % (name, mod1, base, flu)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1586 txt += ' ===> Damage: <b>[%s%s]</b>' % (dmg, aStrengthMod)
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
1587 Parse.Post( txt, self.chat, True, True )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1588
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1589 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1590 wnd = outline_panel(parent,self,attack_panel,"Attacks")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1591 wnd.title = "Attacks"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1592 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1593
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1594 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1595 melee = self.get_attack_data('m')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1596 ranged = self.get_attack_data('r')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1597 html_str = ("""<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 >"""+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1598 "<th>Attack</th><th>Total</th><th >Base</th>"+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1599 "<th>Abil</th><th>Misc</th></tr>")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1600 html_str += "<tr ALIGN='center' ><th >Melee:</th>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1601 html_str += "<td>"+str(melee[0]+melee[1]+melee[2])+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1602 html_str += "<td>"+str(melee[0])+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1603 html_str += "<td>"+str(melee[1])+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1604 html_str += "<td>"+str(melee[2])+"</td></tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1605
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1606 html_str += "<tr ALIGN='center' ><th >Ranged:</th>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1607 html_str += "<td>"+str(ranged[0]+ranged[1]+ranged[2])+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1608 html_str += "<td>"+str(ranged[0])+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1609 html_str += "<td>"+str(ranged[1])+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1610 html_str += "<td>"+str(ranged[2])+"</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1611
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1612 n_list = self.xml.findall('weapon')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1613 for n in n_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1614 mod = n.get('mod')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1615 if mod >= 0: mod1 = "+"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1616 else: mod1 = ""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1617 ran = n.get('range')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1618 total = str(int(mod) + self.get_mod(ran))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1619 html_str += """<P><table width=100% border=1 ><tr BGCOLOR=#E9E9E9 >
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1620 <th colspan=2>Weapon</th>
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1621 <th>Attack</th><th >Damage</th><th>Critical</th></tr>"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1622 html_str += "<tr ALIGN='center' ><td colspan=2>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1623 html_str += n.get('name')+"</td><td>"+total+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1624 html_str += "<td>"+n.get('damage')+"</td><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1625 html_str += n.get('critical')+"</td></tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1626 html_str += """<tr BGCOLOR=#E9E9E9 ><th>Range</th><th>Weight</th>
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1627 <th>Type</th><th>Size</th><th>Misc Mod</th></tr>"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1628 html_str += "<tr ALIGN='center'><td>"+ran+"</td><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1629 html_str += n.get('weight')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1630 html_str += "<td>"+n.get('type')+"</td><td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1631 html_str += n.get('size')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1632 html_str += '<td>%s%s</td></tr>' % (mod1, mod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1633 html_str += """<tr><th BGCOLOR=#E9E9E9 colspan=2>Footnotes:</th>"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1634 html_str += "<th colspan=3>"+safeGetAttr(n,'fn','')+"</th></tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1635 html_str += '</table>'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1636 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1637
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1638 class attack_grid(wx.grid.Grid):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1639 """grid for attacks"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1640 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1641 pname = handler.xml.set("name", 'Melee')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1642 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1643 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1644
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1645 self.root = getRoot(self) #a 1.9001
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1646 self.parent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1647 self.handler = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1648 self.rows = (self.handler.melee,self.handler.ranged)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1649 self.CreateGrid(2,10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1650 self.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1651 col_names = ['Type','base','base 2','base 3','base 4','base 5',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1652 'base 6','abil','misc','Total']
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1653 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1654 self.SetCellValue(0,0,"Melee")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1655 self.SetCellValue(1,0,"Ranged")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1656 self.refresh_data()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1657 self.Bind(wx.EVT_SIZE, self.on_size)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1658 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1659 climber = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1660 nameNode = climber.GetClassName()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1661 while nameNode != 'wxFrame':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1662 climber = climber.parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1663 nameNode = climber.GetClassName()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1664 masterFrame=climber
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1665 masterFrame.refreshMRdata=self.refresh_data
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1666 handler.mrFrame.append(masterFrame)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1667
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1668
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1669 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1670 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1671 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1672 value = self.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1673 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1674 int(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1675 if col==1: self.rows[row].set('base',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1676 elif col==2: self.rows[row].set('second',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1677 elif col==3: self.rows[row].set('third',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1678 elif col==4: self.rows[row].set('forth',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1679 elif col==5: self.rows[row].set('fifth',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1680 elif col==6: self.rows[row].set('sixth',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1681 elif col==8: self.rows[row].set('misc',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1682 self.parent.refresh_data()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1683 except: self.SetCellValue(row,col,"0")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1684
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1685 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1686 melee = self.handler.get_attack_data('m')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1687 ranged = self.handler.get_attack_data('r')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1688 tmelee = int(melee[0]) + int(melee[6]) + int(melee[7])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1689 tranged = int(ranged[0]) + int(ranged[6]) + int(ranged[7])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1690 for i in range(0,8): #a 1.5005
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1691 self.SetCellValue(0,i+1,str(melee[i]))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1692 self.SetCellValue(1,i+1,str(ranged[i]))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1693 self.SetCellValue(0,9,str(tmelee))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1694 self.SetCellValue(1,9,str(tranged))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1695 self.SetReadOnly(0,0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1696 self.SetReadOnly(1,0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1697 self.SetReadOnly(0,7)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1698 self.SetReadOnly(1,7)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1699 self.SetReadOnly(0,9)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1700 self.SetReadOnly(1,9)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1701
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1702 def on_size(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1703 (w,h) = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1704 cols = self.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1705 col_w = w/(cols+1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1706 self.SetColSize(0,col_w*2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1707 for i in range(1,cols): self.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1708 evt.Skip()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1709 self.Refresh()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1710
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1711 class weapon_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1712 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1713 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1714 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1715 pname = handler.xml.set("name", 'Weapons')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1716 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1717 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1718 sizer = wx.BoxSizer(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1719 sizer.Add(self.grid, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1720 sizer2 = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1721 sizer2.Add(wx.Button(self, 10, "Remove Weapon"), 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1722 sizer2.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1723 sizer2.Add(wx.Button(self, 20, "Add Weapon"), 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1724 sizer.Add(sizer2, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1725 sizer.Add(wx.StaticText(self, -1, "Right click a weapon's footnote to see what the footnotes mean."),0, wx.EXPAND)#a 1.5012
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1726 self.sizer = sizer
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1727 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1728 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1729 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1730 self.sizer2 = sizer2
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1731 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1732 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1733 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1734 self.grid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.on_gridRclick)#a 1.5012
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1735
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1736 n_list = handler.xml.findall('weapon')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1737 self.n_list = n_list
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1738 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1739 self.handler = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1740 self.colAttr = ['name','damage','mod','critical','type','weight',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1741 'range','size','Total','fn', 'comment']
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1742 col_names = ['Name','Damage','To hit\nmod','Critical','Type','Weight',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1743 'Range','Size','Total','Foot\nnotes','Comment']
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1744 gridColCount=len(col_names)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1745 self.grid.CreateGrid(len(n_list),gridColCount,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1746 self.grid.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1747 for i in range(gridColCount): self.grid.SetColLabelValue(i,col_names[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1748 self.refresh_data()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1749 self.temp_dom = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1750
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1751
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1752 #mark4
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1753 #a 1.5012 add entire method.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1754 def on_gridRclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1755 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1756 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1757 value = self.grid.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1758 if col == 9 and value != 'None':
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1759 n = self.n_list[row]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1760 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1761 handler = self.hparent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1762 # A handler is a node, and nodes have a reference to
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1763 # the master frame
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1764 masterFrame = handler.frame
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1765 title = name+"'s Special Weapon Characteristics"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1766 fnFrame = wx.Frame(masterFrame, -1, title)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1767 fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1768 if not self.temp_dom:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1769 tree = parse(dir_struct["dnd3e"]+"dnd3eweapons.xml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1770 xml_dom = tree.getroot()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1771 self.temp_dom = xml_dom
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1772 f_list = self.temp_dom.findall('f') # the footnotes
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1773 n = self.n_list[row]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1774 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1775 footnotes = n.get('fn')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1776 html_str = "<html><body>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1777 html_str += """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 >
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1778 <th width='10%'>Note</th><th>Description</th></tr>\n"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1779 if footnotes == "":
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1780 html_str += "<tr ALIGN='center'><td></td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1781 html_str += " <td>This weapon has no footnotes</td></tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1782 for i in range(len(footnotes)):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1783 aNote=footnotes[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1784 found=False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1785 for f in f_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1786 if f.get('mark') == aNote:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1787 found=True
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1788 text=f.get('txt')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1789 html_str += ("<tr ALIGN='center'><td>"+aNote+"</td>"+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1790 "<td>"+text+"</td></tr>\n")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1791 if not found:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1792 html_str += ("<tr ALIGN='center'><td>"+aNote+"</td>"+
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1793 "<td>is not a recognized footnote</td></tr>\n")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1794
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1795 html_str += "</table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1796 html_str += "</body> </html> "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1797 fnFrame.panel.SetPage(html_str)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1798 fnFrame.Show()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1799 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1800 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1801
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1802
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1803 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1804 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1805 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1806 value = self.grid.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1807 if col == 2 and not int(value): # special case for mod, demoted
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1808 value = "0" #a 5.012 demoted
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1809 self.n_list[row].set('mod',value) # a 5.012 demoted
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1810 if not (col == 9 and value == "None" and
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1811 self.n_list[row].get('fn') == "None"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1812 ): #a 5.012 special case for footnotes
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1813 self.n_list[row].set(self.colAttr[col],value)#a 5.012
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1814
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1815
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1816 def refresh_row(self,i):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1817 n = self.n_list[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1818 fn = n.get('fn')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1819 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1820 mod = n.get('mod')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1821 ran = n.get('range')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1822 total = str(int(mod) + self.handler.get_mod(ran))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1823 self.grid.SetCellValue(i,0,name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1824 self.grid.SetCellValue(i,1,n.get('damage'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1825 self.grid.SetCellValue(i,2,mod)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1826 self.grid.SetCellValue(i,3,n.get('critical'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1827 self.grid.SetCellValue(i,4,n.get('type'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1828 self.grid.SetCellValue(i,5,n.get('weight'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1829 self.grid.SetCellValue(i,6,ran)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1830 self.grid.SetCellValue(i,7,n.get('size') )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1831 self.grid.SetCellValue(i,8,total)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1832 self.grid.SetCellValue(i,9,safeGetAttr(n,'fn','None')) #a 1.5012
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1833 self.grid.SetCellValue(i,10,safeGetAttr(n,'comment','')) #a 1.5012
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1834 self.grid.SetReadOnly(i,8)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1835
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1836 def on_remove(self,evt): #o 1.6011 correcting wrongful deletion
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1837 rows = self.grid.GetNumberRows()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1838 for i in range(rows-1,-1,-1): #a 1.6011 or you lose context
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1839 if self.grid.IsInSelection(i,0):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1840 self.grid.DeleteRows(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1841 self.xml.remove(self.n_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1842 self.n_list = self.xml.findall('weapon')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1843 self.handler.refresh_weapons()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1844
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1845 def on_add(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1846 if not self.temp_dom:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1847 tree = parse(dir_struct["dnd3e"]+"dnd3eweapons.xml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1848 xml_dom = tree.getroot()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1849 self.temp_dom = xml_dom
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1850 f_list = self.temp_dom.findall('weapon')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1851 opts = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1852 for f in f_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1853 opts.append(f.get('name'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1854 dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1855 if dlg.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1856 i = dlg.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1857 new_node = self.xml.append(f_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1858 self.grid.AppendRows(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1859 self.n_list = self.xml.findall('weapon')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1860 self.refresh_row(self.grid.GetNumberRows()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1861 self.handler.refresh_weapons()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1862 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1863
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1864 def on_size(self,event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1865 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1866 self.grid.SetDimensions(0,0,s[0],s[1]-40)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1867 self.sizer.SetDimension(0,s[1]-40,s[0],25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1868 self.sizer2.SetDimension(0,s[1]-15,s[0],15)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1869 (w,h) = self.grid.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1870 cols = self.grid.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1871 col_w = w/(cols+1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1872 self.grid.SetColSize(0,col_w*2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1873 for i in range(1,cols): self.grid.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1874
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1875 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1876 for i in range(len(self.n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1877
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1878
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1879 class attack_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1880 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1881 pname = handler.xml.set("name", 'Melee')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1882 self.parent = parent #a 1.9001
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1883 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1884 self.a_grid = attack_grid(self, handler)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1885 self.w_panel = weapon_panel(self, handler)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1886 self.sizer = wx.BoxSizer(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1887 self.sizer.Add(self.a_grid, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1888 self.sizer.Add(self.w_panel, 2, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1889 self.Bind(wx.EVT_SIZE, self.on_size)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1890
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1891 def on_size(self,event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1892 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1893 self.sizer.SetDimension(0,0,s[0],s[1])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1894
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1895 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1896 self.w_panel.refresh_data()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1897 self.a_grid.refresh_data()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1898
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1899
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1900 class dnd3earmor(combat_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1901 """ Node Handler for ac. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1902 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1903 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1904 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1905 combat_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1906 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1907 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1908 self.root.ac = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1909
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1910 def get_spell_failure(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1911 return self.get_total('spellfailure')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1912
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1913 def get_total_weight(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1914 return self.get_total('weight')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1915
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1916 def get_check_pen(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1917 return self.get_total('checkpenalty')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1918
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1919 def get_armor_class(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1920 ac_total = 10
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1921
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1922 ac_total += self.get_total('bonus')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1923 dex_mod = self.root.abilities.get_mod('Dex')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1924 max_dex = self.get_max_dex()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1925 if dex_mod < max_dex: ac_total += dex_mod
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1926 else: ac_total += max_dex
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1927 return ac_total
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1928
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1929 def get_max_dex(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1930 armor_list = self.xml.findall('armor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1931 dex = 10
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1932 for a in armor_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1933 temp = int(a.get("maxdex"))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1934 if temp < dex: dex = temp
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1935 return dex
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1936
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1937 def get_total(self,attr):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1938 armor_list = self.xml.findall('armor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1939 total = 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1940 for a in armor_list: total += int(a.get(attr))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1941 return total
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1942
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1943 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1944 wnd = outline_panel(parent,self,ac_panel,"Armor")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1945 wnd.title = "Armor"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1946 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1947
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1948 def on_rclick( self, evt ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1949 ac = self.get_armor_class()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1950 fac = (int(ac)-(self.root.abilities.get_mod('Dex')))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1951 txt = '((AC: %s Normal, %s Flatfoot))' % ( ac, fac ) #a 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
1952 Parse.Post( txt, self.chat, True, True )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1953
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1954 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1955 html_str = """<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 >
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1956 <th>AC</th><th>Check Penalty</th><th >Spell Failure</th>
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1957 <th>Max Dex</th><th>Total Weight</th></tr>"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1958 html_str += "<tr ALIGN='center' >"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1959 html_str += "<td>"+str(self.get_armor_class())+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1960 html_str += "<td>"+str(self.get_check_pen())+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1961 html_str += "<td>"+str(self.get_spell_failure())+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1962 html_str += "<td>"+str(self.get_max_dex())+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1963 html_str += "<td>"+str(self.get_total_weight())+"</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1964 n_list = self.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1965 for n in n_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1966 html_str += """<P><table width=100% border=1 ><tr BGCOLOR=#E9E9E9 >
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1967 <th colspan=3>Armor</th><th>Type</th><th >Bonus</th></tr>"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1968 html_str += "<tr ALIGN='center' >"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1969 html_str += "<td colspan=3>"+n.get('name')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1970 html_str += "<td>"+n.get('type')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1971 html_str += "<td>"+n.get('bonus')+"</td></tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1972 html_str += """<tr BGCOLOR=#E9E9E9 >"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1973 html_str += "<th>Check Penalty</th><th>Spell Failure</th>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1974 html_str += "<th>Max Dex</th><th>Speed</th><th>Weight</th></tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1975 html_str += "<tr ALIGN='center'>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1976 html_str += "<td>"+n.get('checkpenalty')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1977 html_str += "<td>"+n.get('spellfailure')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1978 html_str += "<td>"+n.get('maxdex')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1979 html_str += "<td>"+n.get('speed')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1980 html_str += "<td>"+n.get('weight')+"</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1981 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1982
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1983
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1984 class ac_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1985 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1986 pname = handler.xml.set("name", 'Armor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1987 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1988 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1989 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1990 sizer = wx.BoxSizer(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1991 sizer.Add(self.grid, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1992 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1993 sizer1.Add(wx.Button(self, 10, "Remove Armor"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1994 sizer1.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1995 sizer1.Add(wx.Button(self, 20, "Add Armor"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1996 sizer.Add(sizer1, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1997 self.sizer = sizer
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1998 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1999 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2000 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2001 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2002 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2003 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2004 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2005 n_list = handler.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2006 self.n_list = n_list
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2007 col_names = ['Armor','bonus','maxdex','cp','sf','weight','speed','type']
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2008 self.grid.CreateGrid(len(n_list),len(col_names),1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2009 self.grid.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2010 for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2011 self.atts =['name','bonus','maxdex','checkpenalty',
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2012 'spellfailure','weight','speed','type']
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2013 for i in range(len(n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2014 self.temp_dom = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2015
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2016
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2017 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2018 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2019 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2020 value = self.grid.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2021 if col >= 1 and col <= 5:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2022 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2023 int(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2024 self.n_list[row].set(self.atts[col],value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2025 except: self.grid.SetCellValue(row,col,"0")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2026 else: self.n_list[row].set(self.atts[col],value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2027
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2028 def refresh_row(self,i):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2029 n = self.n_list[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2030 for y in range(len(self.atts)): self.grid.SetCellValue(i,y,n.get(self.atts[y]))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2031
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2032 def on_remove(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2033 rows = self.grid.GetNumberRows()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2034 for i in range(rows):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2035 if self.grid.IsInSelection(i,0):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2036 self.grid.DeleteRows(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2037 self.xml.remove(self.n_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2038
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2039 def on_add(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2040 if not self.temp_dom:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2041 tree = parse(dir_struct["dnd3e"]+"dnd3earmor.xml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2042 xml_dom = tree.getroot()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2043 self.temp_dom = xml_dom
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2044 f_list = self.temp_dom.findall('armor')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2045 opts = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2046 for f in f_list: opts.append(f.get('name'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2047 dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2048 if dlg.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2049 i = dlg.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2050 new_node = self.xml.append(f_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2051 self.grid.AppendRows(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2052 self.refresh_row(self.grid.GetNumberRows()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2053 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2054
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2055 def on_size(self,event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2056 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2057 self.grid.SetDimensions(0,0,s[0],s[1]-25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2058 self.sizer.SetDimension(0,s[1]-25,s[0],25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2059 (w,h) = self.grid.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2060 cols = self.grid.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2061 col_w = w/(cols+2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2062 self.grid.SetColSize(0,col_w*3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2063 for i in range(1,cols): self.grid.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2064
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2065
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2066 class dnd3esnp(dnd3e_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2067 """ Node Handler for power points. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2068 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2069 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2070 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2071 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2072 dnd3e_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2073 self.hparent = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2074 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2075 self.child_handlers = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2076 self.new_child_handler('spells','Spells',dnd3espells,'book')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2077 self.new_child_handler('divine','Divine Spells',dnd3edivine,'book')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2078 self.new_child_handler('powers','Powers',dnd3epowers,'book')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2079 self.new_child_handler('pp','Power Points',dnd3epp,'gear')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2080 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2081
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2082 def new_child_handler(self,tag,text,handler_class,icon='gear'):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2083 node_list = self.xml.findall(tag)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2084 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2085 i = self.tree.icons[icon]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2086 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2087 handler = handler_class(node_list[0],new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2088 tree.SetPyData(new_tree_node,handler)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2089 self.child_handlers[tag] = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2090
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2091 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2092 return tabbed_panel(parent,self,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2093
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2094 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2095 return tabbed_panel(parent,self,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2096
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2097
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2098 class snp_char_child(node_handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2099 """ Node Handler for skill. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2100 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2101 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2102 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2103 node_handler.__init__(self,xml_dom,tree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2104 self.char_hander = parent
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2105 self.drag = False
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2106 self.frame = component.get('frame')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2107 self.myeditor = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2108
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2109 def on_drop(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2110 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2111
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2112 def on_rclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2113 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2114
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2115 def on_ldclick(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2116 return
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2117
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2118 def on_html(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2119 html_str = self.tohtml()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2120 wnd = http_html_window(self.frame.note,-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2121 wnd.title = self.xml.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2122 self.frame.add_panel(wnd)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2123 wnd.SetPage(html_str)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2124
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2125 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2126 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2127
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2128 def get_use_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2129 return self.get_design_panel(parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2130
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2131 def delete(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2132 pass
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2133
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2134
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2135 class dnd3espells(snp_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2136 """ Node Handler for classes. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2137 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2138 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2139 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2140 snp_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2141 self.hparent = parent #a 1.5002 allow ability to run up tree.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2142 self.root = getRoot(self) #a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2143 self.root.spells = self #a 1.6009
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2144
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2145
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2146 node_list = self.xml.findall( 'spell' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2147 self.spells = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2148 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2149 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2150 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2151 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2152 self.spells[ name ] = n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2153 new_tree_node = tree.AppendItem( self.mytree_node, name, icons['gear'], icons['gear'] )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2154 tree.SetPyData( new_tree_node, self )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2155
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2156 def on_rclick( self, evt ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2157 item = self.tree.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2158 name = self.tree.GetItemText( item )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2159 if item == self.mytree_node:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2160 dnd3e_char_child.on_ldclick( self, evt )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2161 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2162 level = self.spells[ name ].get( 'level' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2163 descr = self.spells[ name ].get( 'desc' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2164 use = self.spells[ name ].get( 'used' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2165 memrz = self.spells[ name ].get( 'memrz' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2166 use += '+1'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2167 charNameL=self.root.general.charName #a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2168 left = eval( '%s - ( %s )' % ( memrz, use ) )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2169 if left < 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2170 txt = '%s Tried to cast %s but has used all of them for today,'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2171 txt +='"Please rest so I can cast more."' % ( charNameL, name ) #a 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2172 Parse.Post( txt, self.chat, True, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2173 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2174 txt = '%s casts %s ( level %s, "%s" )' % ( charNameL, name, level, descr )#a f 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2175 Parse.Post( txt, self.chat, True, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2176 s = ''
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2177 if left != 1: s = 's'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2178 txt = '%s can cast %s %d more time%s' % ( charNameL, name, left, s ) #a 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2179 Parse.Post( txt, self.chat, False, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2180 self.spells[ name ].set( 'used', `eval( use )` )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2181
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2182 def refresh_spells(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2183 self.spells = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2184 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2185 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2186 tree.CollapseAndReset(self.mytree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2187 node_list = self.xml.findall('spell')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2188 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2189 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2190 new_tree_node = tree.AppendItem(self.mytree_node,name,icons['gear'],icons['gear'])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2191 tree.SetPyData(new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2192 self.spells[name]=n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2193
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2194 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2195 wnd = outline_panel(parent,self,spells_panel,"Spells")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2196 wnd.title = "Spells"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2197 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2198
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2199 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2200 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Arcane Spells</th></tr><tr><td><br>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2201 n_list = self.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2202 for n in n_list: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2203 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2204 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2205
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2206 def get_char_lvl( self, attr ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2207 return self.char_hander.get_char_lvl(attr)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2208
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2209 class spells_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2210 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2211 pname = handler.xml.set("name", 'Arcane Spells')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2212 self.hparent = handler #a 1.5002 allow ability to run up tree.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2213 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2214 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2215 self.handler = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2216 sizer = wx.BoxSizer(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2217 sizer.Add(self.grid, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2218 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2219 sizer1.Add(wx.Button(self, 10, "Remove Spell"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2220 sizer1.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2221 sizer1.Add(wx.Button(self, 20, "Add Spell"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2222 sizer1.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2223 sizer1.Add(wx.Button(self, 30, "Refresh Spells"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2224 sizer.Add(sizer1, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2225 self.sizer = sizer
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2226 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2227 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2228 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2229 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2230 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2231 self.Bind(wx.EVT_BUTTON, self.on_refresh_spells, id=30)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2232 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2233 n_list = handler.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2234 self.n_list = n_list
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2235 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2236 self.grid.CreateGrid(len(n_list),4,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2237 self.grid.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2238 self.grid.SetColLabelValue(0,"No.")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2239 self.grid.SetColLabelValue(1,"Lvl")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2240 self.grid.SetColLabelValue(2,"Spell")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2241 self.grid.SetColLabelValue(3,"Desc")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2242 for i in range(len(n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2243 self.temp_dom = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2244
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2245 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2246 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2247 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2248 value = self.grid.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2249 if col == 0: self.n_list[row].set('memrz',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2250
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2251 def refresh_row(self,i):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2252 spell = self.n_list[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2253 memrz = spell.get('memrz')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2254 name = spell.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2255 type = spell.get('desc')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2256 level = spell.get('level')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2257 self.grid.SetCellValue(i,0,memrz)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2258 self.grid.SetCellValue(i,2,name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2259 self.grid.SetReadOnly(i,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2260 self.grid.SetCellValue(i,3,type)
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2261 self.grid.SetReadOnly(i,3)
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2262 self.grid.SetCellValue(i,1,level)
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2263 self.grid.SetReadOnly(i,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2264
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2265 def on_remove(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2266 rows = self.grid.GetNumberRows()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2267 for i in range(rows):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2268 if self.grid.IsInSelection(i,0):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2269 self.grid.DeleteRows(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2270 self.xml.remove(self.n_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2271
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2272 def on_add(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2273 if not self.temp_dom:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2274 tree = parse(dir_struct["dnd3e"]+"dnd3espells.xml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2275 xml_dom = tree.getroot()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2276 self.temp_dom = xml_dom
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2277 f_list = self.temp_dom.findall('spell')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2278 opts = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2279 #lvl = int(dnd3e_char_child.get_char_lvl('level'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2280 #castlvl = eval('%s/2' % (lvl))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2281 for f in f_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2282 spelllvl = f.get('level')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2283 opts.append("(" + f.get('level') + ")" + f.get('name'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2284 dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2285 if dlg.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2286 i = dlg.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2287 new_node = self.xml.append(f_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2288 self.grid.AppendRows(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2289 self.n_list = self.xml.findall('spell')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2290 self.refresh_row(self.grid.GetNumberRows()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2291 self.handler.refresh_spells()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2292 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2293
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2294 def on_refresh_spells( self, evt ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2295 f_list = self.xml.findall('spell')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2296 for spell in f_list: spell.set( 'used', '0' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2297
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2298 def on_size(self,event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2299 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2300 self.grid.SetDimensions(0,0,s[0],s[1]-25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2301 self.sizer.SetDimension(0,s[1]-25,s[0],25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2302 (w,h) = self.grid.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2303 cols = self.grid.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2304 col_w = w/(cols)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2305 for i in range(0,cols): self.grid.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2306 self.grid.SetColSize(0,w * 0.10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2307 self.grid.SetColSize(1,w * 0.10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2308 self.grid.SetColSize(2,w * 0.30)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2309 self.grid.SetColSize(3,w * 0.50)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2310
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2311 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2312 for i in range(len(self.n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2313
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2314 class dnd3edivine(snp_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2315 """ Node Handler for classes. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2316 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2317 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2318 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2319 snp_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2320 self.hparent = parent #a 1.5002 allow ability to run up tree.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2321 self.root = getRoot(self) #a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2322 self.root.divine = self #a 1.6009
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2323 node_list = self.xml.findall( 'gift' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2324 self.spells = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2325 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2326 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2327 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2328 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2329 self.spells[ name ] = n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2330 new_tree_node = tree.AppendItem( self.mytree_node, name, icons['flask'], icons['flask'] )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2331 tree.SetPyData( new_tree_node, self )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2332
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2333 def on_rclick( self, evt ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2334 charNameL=self.root.general.charName #a f 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2335 item = self.tree.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2336 name = self.tree.GetItemText( item )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2337 if item == self.mytree_node:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2338 dnd3e_char_child.on_ldclick( self, evt )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2339 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2340 level = self.spells[ name ].get( 'level' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2341 descr = self.spells[ name ].get( 'desc' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2342 use = self.spells[ name ].get( 'used' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2343 memrz = self.spells[ name ].get( 'memrz' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2344 use += '+1'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2345 left = eval( '%s - ( %s )' % ( memrz, use ) )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2346 if left < 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2347 txt = '%s Tried to cast %s but has used all of them for today,' #m 1.5002 break in 2.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2348 txt += "Please rest so I can cast more."' % ( charNameL, name )' #a 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2349 Parse.Post( txt, self.chat, True, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2350 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2351 txt = '%s casts %s ( level %s, "%s" )' % ( charNameL, name, level, descr ) #a 5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2352 Parse.Post( txt, self.chat, True, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2353 s = ''
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2354 if left != 1: s = 's'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2355 txt = '%s can cast %s %d more time%s' % ( charNameL, name, left, s ) #a 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2356 Parse.Post( txt, self.chat, False, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2357 self.spells[ name ].set( 'used', `eval( use )` )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2358
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2359 def refresh_spells(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2360 self.spells = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2361 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2362 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2363 tree.CollapseAndReset(self.mytree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2364 node_list = self.xml.findall('gift')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2365 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2366 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2367 new_tree_node = tree.AppendItem(self.mytree_node,name,icons['flask'],icons['flask'])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2368 tree.SetPyData(new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2369 self.spells[name]=n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2370
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2371 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2372 wnd = outline_panel(parent,self,divine_panel,"Spells")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2373 wnd.title = "Spells"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2374 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2375
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2376 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2377 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Divine Spells</th></tr><tr><td><br>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2378 n_list = self.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2379 for n in n_list: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2380 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2381 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2382
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2383 def get_char_lvl( self, attr ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2384 return self.char_hander.get_char_lvl(attr)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2385
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2386 class divine_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2387 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2388 pname = handler.xml.set("name", 'Divine Spells')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2389 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2390 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2391 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2392 self.handler = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2393 sizer = wx.BoxSizer(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2394 sizer.Add(self.grid, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2395 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2396 sizer1.Add(wx.Button(self, 10, "Remove Spell"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2397 sizer1.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2398 sizer1.Add(wx.Button(self, 20, "Add Spell"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2399 sizer1.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2400 sizer1.Add(wx.Button(self, 30, "Refresh Spells"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2401 sizer.Add(sizer1, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2402 self.sizer = sizer
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2403 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2404 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2405 self.Fit()
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2406
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2407 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2408 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2409 self.Bind(wx.EVT_BUTTON, self.on_refresh_spells, id=30)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2410 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2411
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2412 n_list = handler.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2413 self.n_list = n_list
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2414 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2415 self.grid.CreateGrid(len(n_list),4,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2416 self.grid.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2417 self.grid.SetColLabelValue(0,"No.")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2418 self.grid.SetColLabelValue(1,"Lvl")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2419 self.grid.SetColLabelValue(2,"Spell")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2420 self.grid.SetColLabelValue(3,"Desc")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2421 for i in range(len(n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2422 self.temp_dom = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2423
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2424 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2425 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2426 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2427 value = self.grid.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2428 if col == 0: self.n_list[row].set('memrz',value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2429
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2430 def refresh_row(self,i):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2431 spell = self.n_list[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2432 memrz = spell.get('memrz')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2433 name = spell.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2434 type = spell.get('desc')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2435 level = spell.get('level')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2436 self.grid.SetCellValue(i,0,memrz)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2437 self.grid.SetCellValue(i,2,name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2438 self.grid.SetReadOnly(i,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2439 self.grid.SetCellValue(i,3,type)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2440 self.grid.SetReadOnly(i,3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2441 self.grid.SetCellValue(i,1,level)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2442 self.grid.SetReadOnly(i,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2443
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2444 def on_remove(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2445 rows = self.grid.GetNumberRows()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2446 for i in range(rows):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2447 if self.grid.IsInSelection(i,0):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2448 self.grid.DeleteRows(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2449 self.xml.remove(self.n_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2450
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2451 def on_add(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2452 if not self.temp_dom:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2453 tree = parse(dir_struct["dnd3e"]+"dnd3edivine.xml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2454 xml_dom = tree.getroot()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2455 self.temp_dom = xml_dom
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2456 f_list = self.temp_dom.findall('gift')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2457 opts = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2458 for f in f_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2459 spelllvl = f.get('level')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2460 opts.append("(" + f.get('level') + ")" + f.get('name'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2461 dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2462 if dlg.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2463 i = dlg.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2464 new_node = self.xml.append(f_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2465 self.grid.AppendRows(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2466 self.n_list = self.xml.findall('gift')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2467 self.refresh_row(self.grid.GetNumberRows()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2468 self.handler.refresh_spells()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2469 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2470
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2471 def on_refresh_spells( self, evt ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2472 f_list = self.xml.findall('gift')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2473 for spell in f_list: spell.set( 'used', '0' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2474
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2475 def on_size(self,event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2476 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2477 self.grid.SetDimensions(0,0,s[0],s[1]-25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2478 self.sizer.SetDimension(0,s[1]-25,s[0],25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2479 (w,h) = self.grid.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2480 cols = self.grid.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2481 col_w = w/(cols)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2482 for i in range(0,cols): self.grid.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2483 self.grid.SetColSize(0,w * 0.10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2484 self.grid.SetColSize(1,w * 0.10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2485 self.grid.SetColSize(2,w * 0.30)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2486 self.grid.SetColSize(3,w * 0.50)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2487
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2488 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2489 for i in range(len(self.n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2490
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2491
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2492 class dnd3epowers(snp_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2493 """ Node Handler for classes. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2494 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2495 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2496 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2497 snp_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2498 self.hparent = parent #a 1.5002 allow ability to run up tree.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2499 self.root = getRoot(self) #a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2500 self.root.powers = self #a 1.6009
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2501
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2502 node_list = self.xml.findall( 'power' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2503 self.powers = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2504 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2505 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2506 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2507 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2508 self.powers[ name ] = n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2509 new_tree_node = tree.AppendItem( self.mytree_node, name,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2510 icons['gear'], icons['gear'] )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2511 tree.SetPyData( new_tree_node, self )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2512
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2513 def on_rclick( self, evt ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2514 charNameL = self.root.general.charName #a f 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2515
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2516 item = self.tree.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2517 name = self.tree.GetItemText( item )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2518 charNameL = self.root.general.charName #a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2519 if item == self.mytree_node:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2520 dnd3e_char_child.on_ldclick( self, evt )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2521 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2522 level = int(self.powers[ name ].get( 'level' ))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2523 descr = self.powers[ name ].get( 'desc' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2524 #use can be removed -mgt
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2525 #use = self.powers[ name ].get( 'used' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2526 points = self.powers[ name ].get( 'point' )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2527 #cpp and fre are strings without the eval -mgt
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2528 cpp = eval(self.root.pp.get_char_pp('current1')) #a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2529 fre = eval(self.root.pp.get_char_pp('free')) #a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2530 if level == 0 and fre > 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2531 left = eval('%s - ( %s )' % ( fre, points ))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2532 numcast = eval('%s / %s' % (left, points))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2533 if left < 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2534 #In theory you should never see this -mgt
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2535 txt = ('%s doesnt have enough PowerPoints to use %s'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2536 % ( charNameL, name )) #a 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2537 Parse.Post( txt, self.chat, True, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2538 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2539 txt = ('%s uses %s as a Free Talent ( level %s, "%s" )'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2540 % ( charNameL, name, level, descr )) #a 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2541 Parse.Post( txt, self.chat, True, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2542 s = ''
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2543 if left != 1: s = 's'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2544 txt = '%s has %d Free Talent%s left' % ( charNameL, numcast, s ) #a 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2545 Parse.Post( txt, self.chat, False, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2546 self.root.pp.set_char_pp('free',left) #a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2547 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2548 left = eval('%s - ( %s )' % ( cpp, points ))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2549 #numcast = eval('%s / %s' % (left, points))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2550 if left < 0:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2551 txt = '%s doesnt have enough PowerPoints to use %s' % ( charNameL, name ) #m 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2552 Parse.Post( txt, self.chat, True, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2553 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2554 txt = '%s uses %s ( level %s, "%s" )' % ( charNameL, name, level, descr ) #m 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2555 Parse.Post( txt, self.chat, True, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2556 s = ''
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2557 if left != 1:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2558 s = 's'
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2559 #numcast is meaningless here -mgt
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2560 #txt = '%s can use %s %d more time%s' % ( charNameL, name, numcast, s ) #m 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2561 #txt += ' - And has %d more PowerpointsP left' % (left)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2562 txt = '%s has %d more Powerpoint%s' % ( charNameL, left, s ) #m 1.5002
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 28
diff changeset
2563 Parse.Post( txt, self.chat, False, False )
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2564 self.root.pp.set_char_pp('current1',left) #a 1.5002
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2565
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2566 def refresh_powers(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2567 self.powers = {}
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2568 tree = self.tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2569 icons = self.tree.icons
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2570 tree.CollapseAndReset(self.mytree_node)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2571 node_list = self.xml.findall('power')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2572 for n in node_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2573 name = n.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2574 new_tree_node = tree.AppendItem(self.mytree_node,name,icons['gear'],icons['gear'])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2575 tree.SetPyData(new_tree_node,self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2576 self.powers[name]=n
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2577
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2578 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2579 wnd = outline_panel(parent,self,power_panel,"Powers")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2580 wnd.title = "Powers"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2581 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2582
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2583 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2584 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Powers</th></tr><tr><td><br>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2585 n_list = self.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2586 for n in n_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2587 html_str += "(" + n.get('level') + ") " + n.get('name')+ ", "
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2588 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2589 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2590
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2591
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2592 class power_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2593 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2594 #m 1.5015 corrected typo, was Pionic.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2595 pname = handler.xml.set("name", 'Psionic Powers')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2596 self.hparent = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2597 self.root = getRoot(self) #a (debug) 1.5002,1.5014
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2598
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2599 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2600 self.grid = wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2601 self.handler = handler
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2602 sizer = wx.BoxSizer(wx.VERTICAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2603 sizer.Add(self.grid, 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2604
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2605 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2606 sizer1.Add(wx.Button(self, 10, "Remove Power"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2607 sizer1.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2608 sizer1.Add(wx.Button(self, 20, "Add Power"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2609 sizer1.Add(wx.Size(10,10))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2610 sizer1.Add(wx.Button(self, 30, "Refresh Power"), 1, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2611
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2612 sizer.Add(sizer1, 0, wx.EXPAND)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2613 self.sizer = sizer
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2614 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2615 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2616 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2617 #self.Bind(wx.EVT_SIZE, self.on_size)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2618
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2619 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2620 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2621 self.Bind(wx.EVT_BUTTON, self.on_refresh_powers, id=30)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2622 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2623 n_list = handler.xml.getchildren()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2624 self.n_list = n_list
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2625 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2626 self.grid.CreateGrid(len(n_list),5,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2627 self.grid.SetRowLabelSize(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2628 self.grid.SetColLabelValue(0,"PP")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2629 self.grid.SetColLabelValue(1,"Lvl")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2630 self.grid.SetColLabelValue(2,"Power")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2631 self.grid.SetColLabelValue(3,"Desc")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2632 self.grid.SetColLabelValue(4,"Type")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2633 for i in range(len(n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2634 self.refresh_data()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2635 self.temp_dom = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2636
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2637 def on_cell_change(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2638 row = evt.GetRow()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2639 col = evt.GetCol()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2640 value = self.grid.GetCellValue(row,col)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2641
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2642 def refresh_row(self,i):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2643 power = self.n_list[i]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2644 point = power.get('point')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2645 name = power.get('name')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2646 type = power.get('desc')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2647 test = power.get('test')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2648 level = power.get('level')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2649 self.grid.SetCellValue(i,0,point)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2650 self.grid.SetReadOnly(i,0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2651 self.grid.SetCellValue(i,1,level)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2652 self.grid.SetReadOnly(i,1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2653 self.grid.SetCellValue(i,2,name)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2654 self.grid.SetReadOnly(i,2)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2655 self.grid.SetCellValue(i,3,type)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2656 self.grid.SetReadOnly(i,3)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2657 self.grid.SetCellValue(i,4,test)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2658 self.grid.SetReadOnly(i,4)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2659
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2660 def on_remove(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2661 rows = self.grid.GetNumberRows()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2662 for i in range(rows):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2663 if self.grid.IsInSelection(i,0):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2664 self.grid.DeleteRows(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2665 self.xml.remove(self.n_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2666
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2667 def on_add(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2668 if not self.temp_dom:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2669 tree = parse(dir_struct["dnd3e"]+"dnd3epowers.xml")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2670 xml_dom = tree.getroot()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2671 self.temp_dom = xml_dom
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2672 f_list = self.temp_dom.findall('power')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2673 opts = []
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2674 for f in f_list:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2675 spelllvl = f.get('level')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2676 opts.append("(" + f.get('level') + ") - " +
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2677 f.get('name') + " - " + f.get('test'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2678 dlg = wx.SingleChoiceDialog(self,'Choose Power','Powers',opts)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2679 if dlg.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2680 i = dlg.GetSelection()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2681 new_node = self.xml.append(f_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2682 self.grid.AppendRows(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2683 self.n_list = self.xml.findall('power')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2684 self.refresh_row(self.grid.GetNumberRows()-1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2685 self.handler.refresh_powers()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2686 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2687
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2688 def on_remove(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2689 rows = self.grid.GetNumberRows()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2690 for i in range(rows):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2691 if self.grid.IsInSelection(i,0):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2692 self.grid.DeleteRows(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2693 self.xml.remove(self.n_list[i])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2694 self.n_list = self.xml.findall('weapon')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2695 self.handler.refresh_powers()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2696
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2697 def on_refresh_powers( self, evt ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2698 self.root.pp.set_char_pp('current1',self.root.pp.get_char_pp('max1'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2699 self.root.pp.set_char_pp('free',self.root.pp.get_char_pp('maxfree'))
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2700
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2701 def on_size(self,event):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2702 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2703 self.grid.SetDimensions(0,0,s[0],s[1]-25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2704 self.sizer.SetDimension(0,s[1]-25,s[0],25)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2705 (w,h) = self.grid.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2706 cols = self.grid.GetNumberCols()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2707 col_w = w/(cols)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2708 for i in range(0,cols): self.grid.SetColSize(i,col_w)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2709 self.grid.SetColSize(0,w * 0.05)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2710 self.grid.SetColSize(1,w * 0.05)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2711 self.grid.SetColSize(2,w * 0.30)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2712 self.grid.SetColSize(3,w * 0.30)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2713 self.grid.SetColSize(4,w * 0.30)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2714
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2715 def refresh_data(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2716 for i in range(len(self.n_list)): self.refresh_row(i)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2717
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2718 class dnd3epp(snp_char_child):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2719 """ Node Handler for power points. This handler will be
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2720 created by dnd3echar_handler.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2721 """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2722 def __init__(self,xml_dom,tree_node,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2723 snp_char_child.__init__(self,xml_dom,tree_node,parent)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2724 self.hparent = parent #a 1.5002 allow ability to run up tree.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2725 self.root = getRoot(self)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2726 self.root.pp = self
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2727 self.ppPanel=None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2728
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2729 def get_design_panel(self,parent):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2730 wnd = outline_panel(parent,self,pp_panel,"Power Points")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2731 wnd.title = "Power Points"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2732 return wnd
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2733
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2734
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2735 def tohtml(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2736 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 >"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2737 html_str += "<th colspan=7>Power Points</th>" #a 1.6010
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2738 html_str += "</tr><tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2739 html_str += "<th colspan=2>Max:</th>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2740 html_str += "<td>"+self.xml.get('max1')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2741 html_str += "<th colspan=3>Max Talents/day:</th>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2742 html_str += "<td>"+self.xml.get('maxfree')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2743 html_str += "</tr><tr>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2744 html_str += "<th colspan=2>Current:</th>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2745 html_str += "<td>"+self.xml.get('current1')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2746 html_str += "<th colspan=3>Current Talents/day:</th>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2747 html_str += "<td>"+self.xml.get('free')+"</td>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2748 html_str += "</tr></table>"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2749 return html_str
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2750
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2751 def get_char_pp( self, attr ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2752 pp = self.xml.get(attr)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2753 return pp
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2754
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2755 def set_char_pp( self, attr, evl ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2756 qSub = str(evl) #a 1.5014 must force it to be a string for next call.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2757 self.xml.set(attr, qSub)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2758
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2759 class pp_panel(wx.Panel):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2760 def __init__(self, parent, handler):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2761 wx.Panel.__init__(self, parent, -1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2762 self.hparent = handler #a 1.5002 allow ability to run up tree.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2763 self.hparent.ppPanel=self #a 1.5xx
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2764
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2765 pname = handler.xml.set("name", 'PowerPoints')
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2766 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2767 self.xml = handler.xml
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2768
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2769 self.static1= wx.StaticText(self, -1, "PP Current:") #a 1.5015
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2770 self.dyn1= wx.TextCtrl(self, PP_CUR,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2771 self.xml.get('current1')) #a 1.5015
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2772 self.dyn3= wx.TextCtrl(self, PP_FRE,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2773 self.xml.get('free')) #a 1.5015
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2774 self.sizer.AddMany([ (self.static1, 0, wx.ALIGN_CENTER_VERTICAL),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2775 (self.dyn1, 0, wx.EXPAND),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2776 (wx.StaticText(self, -1, "PP Max:"), 0, wx.ALIGN_CENTER_VERTICAL),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2777 (wx.TextCtrl(self, PP_MAX,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2778 self.xml.get('max1')), 0, wx.EXPAND),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2779 (wx.StaticText(self, -1, "Current Free Talants per day:"),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2780 0, wx.ALIGN_CENTER_VERTICAL),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2781 (self.dyn3, 0, wx.EXPAND), #a 1.5015
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2782 (wx.StaticText(self, -1, "Max Free Talants per day:"),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2783 0, wx.ALIGN_CENTER_VERTICAL),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2784 (wx.TextCtrl(self, PP_MFRE,
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2785 self.xml.get('maxfree')), 0, wx.EXPAND),
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2786 ])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2787
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2788 self.sizer.AddGrowableCol(1)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2789 self.SetSizer(self.sizer)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2790 self.SetAutoLayout(True)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2791 self.Fit()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2792 self.Bind(wx.EVT_TEXT, self.on_text, id=PP_MAX)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2793 self.Bind(wx.EVT_TEXT, self.on_text, id=PP_CUR)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2794 self.Bind(wx.EVT_TEXT, self.on_text, id=PP_FRE)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2795 self.Bind(wx.EVT_TEXT, self.on_text, id=PP_MFRE)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2796
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2797 def on_text(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2798 id = evt.GetId()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2799 if id == PP_CUR: self.xml.set('current1',evt.GetString())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2800 elif id == PP_MAX: self.xml.set('max1',evt.GetString())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2801 elif id == PP_FRE: self.xml.set('free',evt.GetString())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2802 elif id == PP_MFRE: self.xml.set('maxfree',evt.GetString())
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2803
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2804 def on_size(self,evt):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2805 s = self.GetClientSizeTuple()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2806 self.sizer.SetDimension(0,0,s[0],s[1])
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2807
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2808 #a 5.015 this whole function.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2809 def on_refresh(self,attr,value):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2810 if attr == 'current1': self.dyn1.SetValue(value)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2811 else: self.dyn3.SetValue(value)