annotate orpg/gametree/nodehandlers/dnd3e.py @ 200:43a91298ac33 alpha

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