Mercurial > traipse_dev
annotate orpg/gametree/nodehandlers/StarWarsd20.py @ 245:682032381be8 beta
Traipse Beta 'OpenRPG' {101130-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user.
Update Summary (Closing/Closed)
New Features:
New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order
New to Server GUI, can now clear log
New Earthdawn Dieroller
New IronClaw roller, sheet, and image
Updates:
Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence.
Update to Browser Server window. Display rooms with ' " & cleaner
Update to Server. Handles ' " & cleaner
Update to Dieroller. Cleaner, more effecient expression system
Update to Hidden Die plugin, allows for non standard dice rolls
Fixes:
Fix to InterParse that was causing an Infernal Loop with Namespace Internal
Fix to XML data, removed old Minidom and switched to Element Tree
Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread
Fix to metaservers.xml file not being created
Fix to Single and Double quotes in Whiteboard text
Fix to Background images not showing when using the Image Server
Fix to Duplicate chat names appearing
Fix to Server GUI's logging output
Fix to FNB.COLORFUL_TABS bug
Fix to Gametree for XSLT Sheets
Fix to Gametree for locating gametree files
Fix to Send to Chat from Gametree
Fix to Gametree, renaming and remapping operates correctly
Fix to aliaslib, prevents error caused when SafeHTML is sent None
author | sirebral |
---|---|
date | Tue, 30 Nov 2010 02:34:58 -0600 |
parents | dcae32e219f1 |
children |
rev | line source |
---|---|
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1 # Copyright (C) 2000-2001 The OpenRPG Project |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
2 # |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
3 # openrpg-dev@lists.sourceforge.net |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
4 # |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
5 # This program is free software; you can redistribute it and/or modify |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
6 # it under the terms of the GNU General Public License as published by |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
7 # the Free Software Foundation; either version 2 of the License, or |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
8 # (at your option) any later version. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
9 # |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
10 # This program is distributed in the hope that it will be useful, |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
13 # GNU General Public License for more details. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
14 # |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
15 # You should have received a copy of the GNU General Public License |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
16 # along with this program; if not, write to the Free Software |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
18 # -- |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
19 # |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
20 # File: StarWarsd20.py |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
21 # Author: Chris Davis; Mark Twombley |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
22 # Maintainer: Mark Twombley |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
23 # Version: |
184 | 24 # $Id: StarWarsd20.py,v Traipse 'Ornery-Orc' prof.ebral Exp $ |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
25 # |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
26 # Description: The file contains code for the StarWarsd20 nodehanlers |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
27 # |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
28 |
184 | 29 __version__ = "$Id: StarWarsd20.py,v Traipse 'Ornery-Orc' prof.ebral Exp $" |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
30 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
31 from core import * |
152 | 32 from containers import * |
135 | 33 from orpg.tools.orpg_log import debug |
34 from xml.etree.ElementTree import parse | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
35 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
36 SWD20_EXPORT = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
37 ############################ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
38 ## StarWarsd20 character node handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
39 ############################ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
40 ##The whole look and easy of use redone by Digitalxero |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
41 class container_handler(node_handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
42 """ should not be used! only a base class! |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
43 <nodehandler name='?' module='core' class='container_handler' /> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
44 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
45 def __init__(self,xml_dom,tree_node): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
46 node_handler.__init__(self,xml_dom,tree_node) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
47 self.load_children() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
48 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
49 def load_children(self): |
135 | 50 children = self.xml.getchildren() |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
51 for c in children: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
52 self.tree.load_xml(c,self.mytree_node) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
53 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
54 def on_drop(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
55 drag_obj = self.tree.drag_obj |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
56 #if self.is_my_child(self.mytree_node,drag_obj.mytree_node): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
57 # return |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
58 if drag_obj == self: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
59 return |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
60 opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
61 if opt == wx.YES: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
62 xml_dom = self.tree.drag_obj.delete() |
135 | 63 xml_dom = self.xml.insertBefore(xml_dom,None) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
64 self.tree.load_xml(xml_dom, self.mytree_node) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
65 self.tree.Expand(self.mytree_node) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
66 elif opt == wx.NO: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
67 node_handler.on_drop(self,evt) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
68 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
69 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
70 cookie = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
71 html_str = "<table border=\"1\" ><tr><td>" |
135 | 72 html_str += "<b>"+self.xml.get("name") + "</b>" |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
73 html_str += "</td></tr>\n" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
74 html_str += "<tr><td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
75 max = tree.GetChildrenCount(handler.mytree_node) |
152 | 76 try: (child,cookie)=self.tree.GetFirstChild(self.mytree_node,cookie) |
77 except: (child,cookie)=self.tree.GetFirstChild(self.mytree_node) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
78 obj = self.tree.GetPyData(child) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
79 for m in xrange(max): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
80 html_str += "<p>" + obj.tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
81 if m < max-1: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
82 child = self.tree.GetNextSibling(child) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
83 obj = self.tree.GetPyData(child) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
84 html_str += "</td></tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
85 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
86 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
87 def get_size_constraint(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
88 return 1 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
89 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
90 def get_char_name( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
91 return self.child_handlers['general'].get_char_name() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
92 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
93 def get_char_lvl( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
94 return self.child_handlers['classes'].get_char_lvl(attr) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
95 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
96 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
97 class SWd20char_handler(node_handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
98 """ Node handler for a SWd20 charactor |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
99 <nodehandler name='?' module='StarWarsd20' class='SWd20char_handler' /> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
100 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
101 def __init__(self,xml_dom,tree_node): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
102 node_handler.__init__(self,xml_dom,tree_node) |
66 | 103 self.frame = component.get('frame') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
104 self.child_handlers = {} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
105 self.new_child_handler('howtouse','HowTO use this tool',SWd20howto,'note') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
106 self.new_child_handler('general','General Information',SWd20general,'gear') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
107 self.new_child_handler('inventory','Money and Inventory',SWd20inventory,'money') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
108 self.new_child_handler('abilities','Abilities Scores',SWd20ability,'gear') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
109 self.new_child_handler('classes','Classes',SWd20classes,'knight') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
110 self.new_child_handler('saves','Saves',SWd20saves,'skull') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
111 self.new_child_handler('skills','Skills',SWd20skill,'book') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
112 self.new_child_handler('feats','Feats',SWd20feats,'book') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
113 self.new_child_handler('wp','Wound Points',SWd20hp,'gear') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
114 self.new_child_handler('vp','Vitality Points',SWd20vp,'gear') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
115 self.new_child_handler('attacks','Attacks',SWd20attacks,'spears') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
116 self.new_child_handler('ac','Armor',SWd20armor,'spears') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
117 self.myeditor = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
118 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
119 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
120 def on_version(self,old_version): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
121 node_handler.on_version(self,old_version) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
122 if old_version == "": |
135 | 123 tree = parse(dir_struct["nodes"]+"StarWars_d20character.xml") |
124 xml_dom = tree.getroot() | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
125 ## add new nodes |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
126 for tag in ("howtouse","inventory","powers","divine","pp"): |
135 | 127 node_list = xml_dom.findall(tag) |
128 self.xml.append(node_list[0]) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
129 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
130 ## add new atts |
135 | 131 melee_attack = self.xml.findall('melee')[0] |
132 melee_attack.set("second","0") | |
133 melee_attack.set("third","0") | |
134 melee_attack.set("forth","0") | |
135 melee_attack.set("fifth","0") | |
136 melee_attack.set("sixth","0") | |
137 range_attack = self.xml.findall('ranged')[0] | |
138 range_attack.set("second","0") | |
139 range_attack.set("third","0") | |
140 range_attack.set("forth","0") | |
141 range_attack.set("fifth","0") | |
142 range_attack.set("sixth","0") | |
143 gen_list = self.xml.findall('general')[0] | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
144 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
145 for tag in ("currentxp","xptolevel"): |
135 | 146 node_list = xml_dom.findall(tag) |
147 gen_list.append(node_list[0]) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
148 print old_version |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
149 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
150 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
151 def get_char_name( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
152 return self.child_handlers['general'].get_char_name() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
153 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
154 def get_char_lvl( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
155 return self.child_handlers['classes'].get_char_lvl(attr) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
156 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
157 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
158 def new_child_handler(self,tag,text,handler_class,icon='gear'): |
135 | 159 node_list = self.xml.findall(tag) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
160 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
161 i = self.tree.icons[icon] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
162 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
163 handler = handler_class(node_list[0],new_tree_node,self) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
164 tree.SetPyData(new_tree_node,handler) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
165 self.child_handlers[tag] = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
166 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
167 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
168 return tabbed_panel(parent,self,1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
169 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
170 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
171 def get_use_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
172 return tabbed_panel(parent,self,2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
173 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
174 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
175 html_str = "<table><tr><td colspan=2 >"+self.child_handlers['general'].tohtml()+"</td></tr>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
176 html_str += "<tr><td width='50%' valign=top >"+self.child_handlers['abilities'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
177 html_str += "<P>" + self.child_handlers['saves'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
178 html_str += "<P>" + self.child_handlers['attacks'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
179 html_str += "<P>" + self.child_handlers['ac'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
180 html_str += "<P>" + self.child_handlers['feats'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
181 html_str += "<P>" + self.child_handlers['inventory'].tohtml() +"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
182 html_str += "<td width='50%' valign=top >"+self.child_handlers['classes'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
183 html_str += "<P>" + self.child_handlers['wp'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
184 html_str += "<P>" + self.child_handlers['vp'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
185 html_str += "<P>" + self.child_handlers['skills'].tohtml() +"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
186 html_str += "</tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
187 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
188 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
189 def about(self): |
152 | 190 """html_str = "<img src='" + dir_struct["icon"]+'d20_logo.gif' "><br /><b>d20 Character Tool v0.7 beta</b>" |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
191 html_str += "<br />by Chris Davis<br />chris@rpgarchive.com" |
152 | 192 return html_str""" |
193 text = 'd20 Character Tool 0.7 beta\n' | |
194 text += 'by Chris Davis chris@rpgarchive.com' | |
195 return text | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
196 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
197 def get_char_name( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
198 return self.child_handlers['general'].get_char_name() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
199 def get_armor_class( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
200 return self.child_handlers['ac'].get_armor_class() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
201 def get_max_hp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
202 return self.child_handlers['wp'].get_max_hp() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
203 def get_current_hp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
204 return self.child_handlers['wp'].get_current_hp() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
205 def get_max_vp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
206 return self.child_handlers['vp'].get_max_vp() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
207 def get_current_vp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
208 return self.child_handlers['vp'].get_current_vp() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
209 def get_char_lvl( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
210 return self.child_handlers['classes'].get_char_lvl(attr) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
211 |
152 | 212 """ Removed to use the supplied Tabbed Panel |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
213 class tabbed_panel(wx.Notebook): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
214 def __init__(self, parent, handler, mode): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
215 wx.Notebook.__init__(self, parent, -1, size=(1200,800)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
216 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
217 self.parent = parent |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
218 tree = self.handler.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
219 max = tree.GetChildrenCount(handler.mytree_node, False) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
220 cookie = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
221 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
222 (child,cookie)=tree.GetFirstChild(handler.mytree_node,cookie) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
223 except: # If this happens we probably have a newer version of wxPython |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
224 (child,cookie)=tree.GetFirstChild(handler.mytree_node) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
225 obj = tree.GetPyData(child) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
226 for m in xrange(max): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
227 |
152 | 228 if mode == 1: panel = obj.get_design_panel(self) |
229 else: panel = obj.get_use_panel(self) | |
135 | 230 name = obj.xml.get("name") |
152 | 231 if panel: self.AddPage(panel,name) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
232 if m < max-1: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
233 child = tree.GetNextSibling(child) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
234 obj = tree.GetPyData(child) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
235 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
236 def about(self): |
67 | 237 html_str = "<img src='" + dir_struct["icon"]+'d20_logo.gif' "><br /><b>d20 Character Tool v0.7 beta</b>" |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
238 html_str += "<br />by Chris Davis<br />chris@rpgarchive.com" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
239 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
240 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
241 def get_char_name( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
242 return self.child_handlers['general'].get_char_name() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
243 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
244 def get_char_lvl( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
245 return self.child_handlers['classes'].get_char_lvl(attr) |
152 | 246 """ |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
247 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
248 class SWd20_char_child(node_handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
249 """ Node Handler for skill. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
250 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
251 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
252 def __init__(self, xml_dom, tree_node, parent): |
135 | 253 node_handler.__init__(self, xml_dom, tree_node) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
254 self.char_hander = parent |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
255 self.drag = False |
66 | 256 self.frame = component.get('frame') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
257 self.myeditor = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
258 |
135 | 259 def on_drop(self, evt): |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
260 pass |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
261 |
135 | 262 def on_rclick(self, evt): |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
263 pass |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
264 |
135 | 265 def on_ldclick(self, evt): |
266 return | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
267 |
135 | 268 def on_html(self, evt): |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
269 html_str = self.tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
270 wnd = http_html_window(self.frame.note,-1) |
135 | 271 wnd.title = self.xml.get('name') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
272 self.frame.add_panel(wnd) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
273 wnd.SetPage(html_str) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
274 |
135 | 275 def get_design_panel(self, parent): |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
276 pass |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
277 |
135 | 278 def get_use_panel(self, parent): |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
279 return self.get_design_panel(parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
280 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
281 def delete(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
282 pass |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
283 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
284 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
285 class SWd20skill(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
286 """ Node Handler for skill. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
287 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
288 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
289 def __init__(self, xml_dom, tree_node, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
290 SWd20_char_child.__init__(self, xml_dom, tree_node, parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
291 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
292 icons = self.tree.icons |
135 | 293 node_list = self.xml.findall('skill') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
294 self.skills={} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
295 for n in node_list: |
135 | 296 name = n.get('name') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
297 self.skills[name] = n |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
298 new_tree_node = tree.AppendItem(self.mytree_node,name,icons['gear'],icons['gear']) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
299 tree.SetPyData(new_tree_node,self) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
300 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
301 def get_mod(self,name): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
302 skill = self.skills[name] |
135 | 303 stat = skill.get('stat') |
304 ac = int(skill.get('armorcheck')) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
305 if ac: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
306 ac = self.char_hander.child_handlers['ac'].get_check_pen() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
307 stat_mod = self.char_hander.child_handlers['abilities'].get_mod(stat) |
135 | 308 rank = int(skill.get('rank')) |
309 misc = int(skill.get('misc')) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
310 total = stat_mod + rank + misc + ac |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
311 return total |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
312 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
313 def on_rclick(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
314 #updated with code for untrained use check |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
315 item = self.tree.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
316 name = self.tree.GetItemText(item) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
317 skill = self.skills[name] |
135 | 318 rank = int(skill.get('rank')) |
319 untrained = int(skill.get('untrained')) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
320 chat = self.chat |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
321 if item == self.mytree_node: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
322 SWd20_char_child.on_ldclick(self,evt) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
323 else: |
152 | 324 if rank == 0 and untrained == 0: chat.Post("Can't use untrained!",True,True) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
325 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
326 mod = self.get_mod(name) |
152 | 327 if mod >= 0: mod1 = "+" |
328 else: mod1 = "" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
329 txt = '%s Skill Check: [1d20%s%s]' % (name, mod1, mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
330 chat.ParsePost(txt,True,True) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
331 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
332 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
333 wnd = outline_panel(parent,self,skill_grid,"Skills") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
334 wnd.title = "Skills (edit)" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
335 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
336 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
337 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
338 html_str = """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 ><th width='30%'>Skill</th><th>Key</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
339 <th>Rank</th><th>Abil</th><th>Misc</th><th>Total</th></tr>""" |
135 | 340 node_list = self.xml.findall('skill') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
341 for n in node_list: |
135 | 342 name = n.get('name') |
343 stat = n.get('stat') | |
344 rank = n.get('rank') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
345 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+rank+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
346 stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) |
135 | 347 misc = n.get('misc') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
348 mod = str(self.get_mod(name)) |
152 | 349 if mod >= 0: mod1 = "+" |
350 else: mod1 = "" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
351 html_str = html_str + "<td>"+stat_mod+"</td><td>"+misc+'</td><td>%s%s</td></tr>' % (mod1, mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
352 html_str = html_str + "</table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
353 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
354 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
355 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
356 class SWd20ability(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
357 """ Node Handler for ability. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
358 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
359 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
360 def __init__(self, xml_dom, tree_node, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
361 SWd20_char_child.__init__(self, xml_dom, tree_node, parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
362 self.abilities = {} |
135 | 363 node_list = self.xml.findall('stat') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
364 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
365 icons = tree.icons |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
366 for n in node_list: |
135 | 367 name = n.get('abbr') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
368 self.abilities[name] = n |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
369 new_tree_node = tree.AppendItem( self.mytree_node, name, icons['gear'], icons['gear'] ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
370 tree.SetPyData( new_tree_node, self ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
371 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
372 def on_rclick( self, evt ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
373 item = self.tree.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
374 name = self.tree.GetItemText( item ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
375 if item == self.mytree_node: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
376 SWd20_char_child.on_ldclick( self, evt ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
377 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
378 mod = self.get_mod( name ) |
152 | 379 if mod >= 0: mod1 = "+" |
380 else: mod1 = "" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
381 chat = self.chat |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
382 txt = '%s check: [1d20%s%s]' % ( name, mod1, mod ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
383 chat.ParsePost( txt, True, True ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
384 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
385 def get_mod(self,abbr): |
135 | 386 score = int(self.abilities[abbr].get('base')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
387 mod = (score - 10) / 2 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
388 return mod |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
389 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
390 def set_score(self,abbr,score): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
391 if score >= 0: |
135 | 392 self.abilities[abbr].set("base",str(score)) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
393 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
394 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
395 wnd = outline_panel(parent,self,abil_grid,"Abilities") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
396 wnd.title = "Abilities (edit)" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
397 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
398 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
399 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
400 html_str = """<table border='1' width=100%><tr BGCOLOR=#E9E9E9 ><th width='50%'>Ability</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
401 <th>Base</th><th>Modifier</th></tr>""" |
135 | 402 node_list = self.xml.findall('stat') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
403 for n in node_list: |
135 | 404 name = n.get('name') |
405 abbr = n.get('abbr') | |
406 base = n.get('base') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
407 mod = str(self.get_mod(abbr)) |
152 | 408 if mod >= 0: mod1 = "+" |
409 else: mod1 = "" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
410 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+base+'</td><td>%s%s</td></tr>' % (mod1, mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
411 html_str = html_str + "</table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
412 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
413 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
414 class SWd20saves(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
415 """ Node Handler for saves. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
416 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
417 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
418 def __init__(self, xml_dom, tree_node, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
419 SWd20_char_child.__init__(self, xml_dom, tree_node, parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
420 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
421 icons = self.tree.icons |
135 | 422 node_list = self.xml.findall('save') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
423 self.saves={} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
424 for n in node_list: |
135 | 425 name = n.get('name') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
426 self.saves[name] = n |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
427 new_tree_node = tree.AppendItem(self.mytree_node,name,icons['gear'],icons['gear']) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
428 tree.SetPyData(new_tree_node,self) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
429 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
430 def get_mod(self,name): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
431 save = self.saves[name] |
135 | 432 stat = save.get('stat') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
433 stat_mod = self.char_hander.child_handlers['abilities'].get_mod(stat) |
135 | 434 base = int(save.get('base')) |
435 miscmod = int(save.get('miscmod')) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
436 total = stat_mod + base + miscmod |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
437 return total |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
438 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
439 def on_rclick(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
440 item = self.tree.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
441 name = self.tree.GetItemText(item) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
442 if item == self.mytree_node: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
443 SWd20_char_child.on_ldclick(self,evt) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
444 #wnd = save_grid(self.frame.note,self) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
445 #wnd.title = "Saves" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
446 #self.frame.add_panel(wnd) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
447 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
448 mod = self.get_mod(name) |
152 | 449 if mod >= 0: mod1 = "+" |
450 else: mod1 = "" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
451 chat = self.chat |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
452 txt = '%s save: [1d20%s%s]' % (name, mod1, mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
453 chat.ParsePost( txt, True, True ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
454 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
455 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
456 wnd = outline_panel(parent,self,save_grid,"Saves") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
457 wnd.title = "Saves" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
458 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
459 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
460 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
461 html_str = """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 ><th width='30%'>Save</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
462 <th>Key</th><th>Base</th><th>Abil</th><th>Magic</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
463 <th>Misc</th><th>Total</th></tr>""" |
135 | 464 node_list = self.xml.findall('save') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
465 for n in node_list: |
135 | 466 name = n.get('name') |
467 stat = n.get('stat') | |
468 base = n.get('base') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
469 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+base+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
470 stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) |
135 | 471 mag = n.get('magmod') |
472 misc = n.get('miscmod') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
473 mod = str(self.get_mod(name)) |
152 | 474 if mod >= 0: mod1 = "+" |
475 else: mod1 = "" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
476 html_str = html_str + "<td>"+stat_mod+"</td><td>"+mag+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
477 html_str = html_str + '<td>'+misc+'</td><td>%s%s</td></tr>' % (mod1, mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
478 html_str = html_str + "</table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
479 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
480 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
481 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
482 class SWd20general(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
483 """ Node Handler for general information. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
484 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
485 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
486 def __init__(self, xml_dom, tree_node, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
487 SWd20_char_child.__init__(self, xml_dom, tree_node, parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
488 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
489 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
490 wnd = outline_panel(parent,self,gen_grid,"General Information") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
491 wnd.title = "General Info" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
492 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
493 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
494 def tohtml(self): |
135 | 495 n_list = self.xml.getchildren() |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
496 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>General Information</th></tr><tr><td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
497 for n in n_list: |
135 | 498 html_str += "<B>"+n.tag.capitalize() +":</B> " |
499 html_str += n.text + ", " | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
500 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
501 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
502 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
503 def on_name_change(self,name): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
504 self.char_hander.rename(name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
505 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
506 def get_char_name( self ): |
135 | 507 node = self.xml.findall( 'name' )[0] |
508 return node.text | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
509 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
510 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
511 class SWd20classes(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
512 """ Node Handler for classes. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
513 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
514 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
515 def __init__(self, xml_dom, tree_node, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
516 SWd20_char_child.__init__(self, xml_dom, tree_node, parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
517 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
518 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
519 wnd = outline_panel(parent,self,class_panel,"Classes") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
520 wnd.title = "Classes" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
521 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
522 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
523 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
524 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Classes</th></tr><tr><td>" |
135 | 525 n_list = self.xml.getchildren() |
152 | 526 for n in n_list: html_str += n.get('name') + " ("+n.get('level')+"), " |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
527 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
528 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
529 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
530 def get_char_lvl( self, attr ): |
135 | 531 node_list = self.xml.findall('class') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
532 for n in node_list: |
135 | 533 lvl = n.get('level') |
534 type = n.get('name') | |
152 | 535 if attr == "level": return lvl |
536 elif attr == "class": return type | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
537 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
538 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
539 class SWd20feats(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
540 """ Node Handler for classes. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
541 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
542 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
543 def __init__(self, xml_dom, tree_node, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
544 SWd20_char_child.__init__(self, xml_dom, tree_node, parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
545 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
546 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
547 wnd = outline_panel(parent,self,feat_panel,"Feats") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
548 wnd.title = "Feats" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
549 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
550 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
551 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
552 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Feats</th></tr><tr><td>" |
135 | 553 n_list = self.xml.getchildren() |
152 | 554 for n in n_list: html_str += n.get('name')+ ", " |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
555 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
556 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
557 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
558 class SWd20howto(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
559 """ Node Handler for hit points. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
560 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
561 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
562 def __init__(self, xml_dom, tree_node, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
563 SWd20_char_child.__init__(self, xml_dom, tree_node, parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
564 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
565 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
566 wnd = outline_panel(parent,self,howto_panel,"How To") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
567 wnd.title = "How To" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
568 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
569 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
570 class SWd20inventory(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
571 """ Node Handler for general information. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
572 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
573 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
574 def __init__(self, xml_dom, tree_node, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
575 SWd20_char_child.__init__(self, xml_dom, tree_node, parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
576 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
577 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
578 wnd = outline_panel(parent,self,inventory_grid,"Inventory") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
579 wnd.title = "General Info" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
580 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
581 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
582 def tohtml(self): |
135 | 583 n_list = self.xml.getchildren() |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
584 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>General Information</th></tr><tr><td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
585 for n in n_list: |
135 | 586 html_str += "<B>"+n.tag.capitalize() +":</B> " |
587 html_str += n.text + "<br />" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
588 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
589 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
590 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
591 def on_name_change(self,name): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
592 self.char_hander.rename(name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
593 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
594 def get_char_name( self ): |
135 | 595 node = self.xml.findall( 'name' )[0] |
596 return node.text | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
597 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
598 class SWd20hp(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
599 """ Node Handler for hit points. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
600 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
601 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
602 def __init__(self,xml_dom,tree_node,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
603 SWd20_char_child.__init__(self,xml_dom,tree_node,parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
604 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
605 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
606 wnd = outline_panel(parent,self,hp_panel,"Wound Points") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
607 wnd.title = "Wound Points" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
608 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
609 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
610 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
611 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th colspan=4>Wound Points</th></tr>" |
135 | 612 html_str += "<tr><th>Max:</th><td>"+self.xml.get('max')+"</td>" |
613 html_str += "<th>Current:</th><td>"+self.xml.get('current')+"</td>" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
614 html_str += "</tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
615 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
616 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
617 def get_max_hp( self ): |
152 | 618 try: return eval( self.xml.get( 'max' ) ) |
619 except: return 0 | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
620 def get_current_hp( self ): |
152 | 621 try: return eval( self.xml.get( 'current' ) ) |
622 except: return 0 | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
623 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
624 class SWd20vp(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
625 """ Node Handler for hit points. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
626 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
627 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
628 def __init__(self,xml_dom,tree_node,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
629 SWd20_char_child.__init__(self,xml_dom,tree_node,parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
630 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
631 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
632 wnd = outline_panel(parent,self,vp_panel,"Vitality Points") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
633 wnd.title = "Vitality Points" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
634 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
635 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
636 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
637 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th colspan=4>Vitality Points</th></tr>" |
135 | 638 html_str += "<tr><th>Max:</th><td>"+self.xml.get('max')+"</td>" |
639 html_str += "<th>Current:</th><td>"+self.xml.get('current')+"</td>" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
640 html_str += "</tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
641 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
642 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
643 def get_max_vp( self ): |
152 | 644 try: return eval( self.xml.get( 'max' ) ) |
645 except: return 0 | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
646 def get_current_vp( self ): |
152 | 647 try: return eval( self.xml.get( 'current' ) ) |
648 except: return 0 | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
649 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
650 class SWd20attacks(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
651 """ Node Handler for attacks. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
652 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
653 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
654 def __init__(self,xml_dom,tree_node,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
655 SWd20_char_child.__init__(self,xml_dom,tree_node,parent) |
135 | 656 node_list = self.xml.findall('melee') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
657 self.melee = node_list[0] |
135 | 658 node_list = self.xml.findall('ranged') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
659 self.ranged = node_list[0] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
660 self.refresh_weapons() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
661 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
662 def refresh_weapons(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
663 self.weapons = {} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
664 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
665 icons = self.tree.icons |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
666 tree.CollapseAndReset(self.mytree_node) |
135 | 667 node_list = self.xml.findall('weapon') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
668 for n in node_list: |
135 | 669 name = n.get('name') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
670 new_tree_node = tree.AppendItem(self.mytree_node,name,icons['sword'],icons['sword']) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
671 tree.SetPyData(new_tree_node,self) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
672 self.weapons[name]=n |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
673 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
674 def get_mod(self,type='m'): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
675 (base, base2, base3, base4, base5, base6, stat_mod, misc) = self.get_attack_data(type) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
676 return base + misc + stat_mod |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
677 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
678 def get_attack_data(self,type='m'): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
679 if type=='m' or type=='0': |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
680 stat_mod = self.char_hander.child_handlers['abilities'].get_mod('Str') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
681 temp = self.melee |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
682 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
683 stat_mod = self.char_hander.child_handlers['abilities'].get_mod('Dex') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
684 temp = self.ranged |
135 | 685 base = int(temp.get('base')) |
686 base2 = int(temp.get('second')) | |
687 base3 = int(temp.get('third')) | |
688 base4 = int(temp.get('forth')) | |
689 base5 = int(temp.get('fifth')) | |
690 base6 = int(temp.get('sixth')) | |
691 misc = int(temp.get('misc')) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
692 return (base, base2, base3, base4, base5, base6, stat_mod ,misc) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
693 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
694 def on_rclick(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
695 #removed the DnD specific code |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
696 item = self.tree.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
697 name = self.tree.GetItemText(item) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
698 if item == self.mytree_node: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
699 SWd20_char_child.on_ldclick(self,evt) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
700 #self.frame.add_panel(self.get_design_panel(self.frame.note)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
701 else: |
135 | 702 mod = int(self.weapons[name].get('mod')) |
703 if self.weapons[name].get('range') == '0': | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
704 mod = mod + self.get_mod('m') |
152 | 705 if mod >= 0: mod1 = "+" |
706 else: mod1 = "" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
707 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
708 mod = mod + self.get_mod('r') |
152 | 709 if mod >= 0: mod1 = "+" |
710 else: mod1 = "" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
711 chat = self.chat |
135 | 712 dmg = self.weapons[name].get('damage') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
713 lvl = self.get_char_lvl('level') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
714 cname = self.char_hander.get_char_name() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
715 txt = '%s %s Attack Roll: [1d20%s%s] ===> DMG: [%s%s%s]' % (cname, name, mod1, mod, dmg, mod1, mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
716 chat.ParsePost( txt, True, False ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
717 temp = self.melee |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
718 stat_mod = self.char_hander.child_handlers['abilities'].get_mod('Str') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
719 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
720 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
721 wnd = outline_panel(parent,self,attack_panel,"Attacks") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
722 wnd.title = "Attacks" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
723 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
724 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
725 def get_char_lvl( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
726 return self.char_hander.get_char_lvl(attr) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
727 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
728 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
729 melee = self.get_attack_data('m') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
730 ranged = self.get_attack_data('r') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
731 html_str = """<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Attack</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
732 <th>Total</th><th >Base</th><th>Abil</th><th>Misc</th></tr>""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
733 html_str += "<tr ALIGN='center' ><th >Melee:</th>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
734 html_str += "<td>"+str(melee[0]+melee[1]+melee[2])+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
735 html_str += "<td>"+str(melee[0])+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
736 html_str += "<td>"+str(melee[1])+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
737 html_str += "<td>"+str(melee[2])+"</td></tr>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
738 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
739 html_str += "<tr ALIGN='center' ><th >Ranged:</th>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
740 html_str += "<td>"+str(ranged[0]+ranged[1]+ranged[2])+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
741 html_str += "<td>"+str(ranged[0])+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
742 html_str += "<td>"+str(ranged[1])+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
743 html_str += "<td>"+str(ranged[2])+"</td></tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
744 |
135 | 745 n_list = self.xml.findall('weapon') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
746 for n in n_list: |
135 | 747 mod = n.get('mod') |
152 | 748 if mod >= 0: mod1 = "+" |
749 else: mod1 = "" | |
135 | 750 ran = n.get('range') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
751 total = str(int(mod) + self.get_mod(ran)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
752 html_str += """<P><table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th colspan=2>Weapon</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
753 <th>Attack</th><th >Damage</th><th>Critical</th></tr>""" |
135 | 754 html_str += "<tr ALIGN='center' ><td colspan=2>"+n.get('name')+"</td><td>"+total+"</td>" |
755 html_str += "<td>"+n.get('damage')+"</td><td>"+n.get('critical')+"</td></tr>" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
756 html_str += """<tr BGCOLOR=#E9E9E9 ><th>Range</th><th>Weight</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
757 <th>Type</th><th>Size</th><th>Misc Mod</th></tr>""" |
135 | 758 html_str += "<tr ALIGN='center'><td>"+ran+"</td><td>"+n.get('weight')+"</td>" |
759 html_str += "<td>"+n.get('type')+"</td><td>"+n.get('size')+"</td>" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
760 html_str += '<td>%s%s</td></tr></table>' % (mod1, mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
761 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
762 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
763 class SWd20armor(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
764 """ Node Handler for ac. This handler will be |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
765 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
766 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
767 def __init__(self,xml_dom,tree_node,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
768 SWd20_char_child.__init__(self,xml_dom,tree_node,parent) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
769 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
770 def get_total_weight(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
771 return self.get_total('weight') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
772 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
773 def get_check_pen(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
774 return self.get_total('checkpenalty') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
775 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
776 def get_armor_class(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
777 ac_total = 10 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
778 ac_total += self.get_total('bonus') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
779 dex_mod = self.char_hander.child_handlers['abilities'].get_mod('Dex') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
780 max_dex = self.get_max_dex() |
152 | 781 if dex_mod < max_dex: ac_total += dex_mod |
782 else: ac_total += max_dex | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
783 return ac_total |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
784 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
785 def get_max_dex(self): |
135 | 786 armor_list = self.xml.findall('armor') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
787 dex = 10 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
788 for a in armor_list: |
135 | 789 temp = int(a.get("maxdex")) |
152 | 790 if temp < dex: dex = temp |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
791 return dex |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
792 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
793 def get_total(self,attr): |
135 | 794 armor_list = self.xml.findall('armor') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
795 total = 0 |
152 | 796 for a in armor_list: total += int(a.get(attr)) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
797 return total |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
798 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
799 def get_design_panel(self,parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
800 wnd = outline_panel(parent,self,ac_panel,"Armor") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
801 wnd.title = "Armor" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
802 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
803 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
804 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
805 html_str = """<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>AC</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
806 <th>Check Penalty</th><th >Spell Failure</th><th>Max Dex</th><th>Total Weight</th></tr>""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
807 html_str += "<tr ALIGN='center' ><td>"+str(self.get_armor_class())+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
808 html_str += "<td>"+str(self.get_check_pen())+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
809 html_str += "<td>"+str(self.get_spell_failure())+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
810 html_str += "<td>"+str(self.get_max_dex())+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
811 html_str += "<td>"+str(self.get_total_weight())+"</td></tr></table>" |
135 | 812 n_list = self.xml.getchildren() |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
813 for n in n_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
814 html_str += """<P><table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th colspan=3>Armor</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
815 <th>Type</th><th >Bonus</th></tr>""" |
135 | 816 html_str += "<tr ALIGN='center' ><td colspan=3>"+n.get('name')+"</td>" |
817 html_str += "<td>"+n.get('type')+"</td>" | |
818 html_str += "<td>"+n.get('bonus')+"</td></tr>" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
819 html_str += """<tr BGCOLOR=#E9E9E9 ><th>Check Penalty</th><th>Spell Failure</th> |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
820 <th>Max Dex</th><th>Speed</th><th>Weight</th></tr>""" |
135 | 821 html_str += "<tr ALIGN='center'><td>"+n.get('checkpenalty')+"</td>" |
822 html_str += "<td>"+n.get('maxdex')+"</td>" | |
823 html_str += "<td>"+n.get('speed')+"</td>" | |
824 html_str += "<td>"+n.get('weight')+"</td></tr></table>" | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
825 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
826 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
827 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
828 ######################## |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
829 ## d20 char windows |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
830 ######################## |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
831 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
832 class base_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
833 def __init__(self, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
834 wx.Panel.__init__(self, parent, -1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
835 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
836 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
837 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
838 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
839 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
840 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
841 class outline_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
842 def __init__(self, parent, handler, wnd, txt,): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
843 wx.Panel.__init__(self, parent, -1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
844 self.panel = wnd(self,handler) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
845 self.outline = wx.StaticBox(self,-1,txt) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
846 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
847 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
848 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
849 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
850 self.panel.SetDimensions(20,20,s[0]-40,s[1]-40) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
851 self.outline.SetDimensions(5,5,s[0]-10,s[1]-10) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
852 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
853 class char_panel(wx.ScrolledWindow): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
854 def __init__(self, parent, handler): |
135 | 855 pname = handler.xml.set("name", 'TWO') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
856 wx.ScrolledWindow.__init__(self, parent, -1,style=wx.VSCROLL | wx.SUNKEN_BORDER ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
857 self.height = 1200 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
858 self.SetScrollbars(10, 10,80, self.height/10) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
859 self.main_sizer = wx.BoxSizer(wx.HORIZONTAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
860 self.panels = {} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
861 keys = handler.child_handlers.keys() |
152 | 862 for k in keys: self.panels[k] = handler.child_handlers[k].get_design_panel(self, [k]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
863 self.sub_sizer = wx.BoxSizer(wx.VERTICAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
864 self.sub_sizer2 = wx.BoxSizer(wx.VERTICAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
865 self.sub_sizer.Add(self.panels['general'], 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
866 self.sub_sizer.Add(self.panels['abilities'], 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
867 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
868 self.sub_sizer.Add(self.panels['attacks'], 2, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
869 self.sub_sizer.Add(self.panels['ac'], 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
870 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
871 self.sub_sizer2.Add(self.panels['classes'], 2, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
872 self.sub_sizer2.Add(self.panels['wp'], 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
873 self.sub_sizer2.Add(self.panels['vp'], 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
874 self.sub_sizer2.Add(self.panels['saves'], 2, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
875 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
876 self.sub_sizer2.Add(self.panels['feats'], 2, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
877 self.sub_sizer2.Add(self.panels['skills'], 3, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
878 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
879 self.main_sizer.Add(self.sub_sizer, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
880 self.main_sizer.Add(self.sub_sizer2, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
881 self.panels['abilities'].panel.char_wnd = self |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
882 self.SetSizer(self.main_sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
883 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
884 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
885 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
886 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
887 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
888 self.SetScrollbars(10, 10,s[0]/10, self.height/10) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
889 dc = wx.ClientDC(self) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
890 x = dc.DeviceToLogicalX(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
891 y = dc.DeviceToLogicalY(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
892 self.main_sizer.SetDimension(x,y,s[0],self.height) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
893 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
894 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
895 def refresh_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
896 self.panels['saves'].panel.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
897 self.panels['skills'].panel.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
898 self.panels['attacks'].panel.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
899 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
900 HOWTO_MAX = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
901 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
902 class howto_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
903 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
904 wx.Panel.__init__(self, parent, -1) |
135 | 905 pname = handler.xml.set("name", 'How To') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
906 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap |
135 | 907 self.xml = handler.xml |
908 n_list = self.xml.getchildren() | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
909 for n in n_list: |
135 | 910 self.sizer.AddMany([ (wx.StaticText(self, -1, n.text), 0, wx.ALIGN_CENTER_VERTICAL), |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
911 ]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
912 self.sizer.AddGrowableCol(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
913 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
914 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
915 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
916 WP_CUR = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
917 WP_MAX = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
918 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
919 class hp_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
920 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
921 wx.Panel.__init__(self, parent, -1) |
135 | 922 pname = handler.xml.set("name", 'WoundPoints') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
923 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap |
135 | 924 self.xml = handler.xml |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
925 self.sizer.AddMany([ (wx.StaticText(self, -1, "WP Current:"), 0, wx.ALIGN_CENTER_VERTICAL), |
135 | 926 (wx.TextCtrl(self, WP_CUR, self.xml.get('current')), 0, wx.EXPAND), |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
927 (wx.StaticText(self, -1, "WP Max:"), 0, wx.ALIGN_CENTER_VERTICAL), |
135 | 928 (wx.TextCtrl(self, WP_MAX, self.xml.get('max')), 0, wx.EXPAND), |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
929 ]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
930 self.sizer.AddGrowableCol(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
931 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
932 self.Bind(wx.EVT_TEXT, self.on_text, id=WP_MAX) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
933 self.Bind(wx.EVT_TEXT, self.on_text, id=WP_CUR) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
934 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
935 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
936 def on_text(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
937 id = evt.GetId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
938 if id == WP_CUR: |
135 | 939 self.xml.set('current',evt.GetString()) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
940 elif id == WP_MAX: |
135 | 941 self.xml.set('max',evt.GetString()) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
942 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
943 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
944 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
945 self.sizer.SetDimension(0,0,s[0],s[1]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
946 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
947 VP_CUR = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
948 VP_MAX = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
949 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
950 class vp_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
951 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
952 wx.Panel.__init__(self, parent, -1) |
135 | 953 pname = handler.xml.set("name", 'VitalityPoints') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
954 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap |
135 | 955 self.xml = handler.xml |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
956 self.sizer.AddMany([ (wx.StaticText(self, -1, "VP Current:"), 0, wx.ALIGN_CENTER_VERTICAL), |
135 | 957 (wx.TextCtrl(self, VP_CUR, self.xml.get('current')), 0, wx.EXPAND), |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
958 (wx.StaticText(self, -1, "VP Max:"), 0, wx.ALIGN_CENTER_VERTICAL), |
135 | 959 (wx.TextCtrl(self, VP_MAX, self.xml.get('max')), 0, wx.EXPAND), |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
960 ]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
961 self.sizer.AddGrowableCol(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
962 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
963 self.Bind(wx.EVT_TEXT, self.on_text, id=VP_MAX) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
964 self.Bind(wx.EVT_TEXT, self.on_text, id=VP_CUR) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
965 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
966 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
967 def on_text(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
968 id = evt.GetId() |
152 | 969 if id == VP_CUR: self.xml.set('current',evt.GetString()) |
970 elif id == VP_MAX: self.xml.set('max',evt.GetString()) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
971 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
972 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
973 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
974 self.sizer.SetDimension(0,0,s[0],s[1]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
975 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
976 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
977 class gen_grid(wx.grid.Grid): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
978 """grid for gen info""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
979 def __init__(self, parent, handler): |
135 | 980 pname = handler.xml.set("name", 'General') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
981 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
982 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
983 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
984 self.handler = handler |
135 | 985 n_list = handler.xml.getchildren() |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
986 self.CreateGrid(len(n_list),2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
987 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
988 self.SetColLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
989 self.n_list = n_list |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
990 i = 0 |
152 | 991 for i in range(len(n_list)): self.refresh_row(i) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
992 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
993 def on_cell_change(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
994 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
995 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
996 value = self.GetCellValue(row,col) |
135 | 997 self.n_list[row].text = value |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
998 if row==0: self.handler.on_name_change(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
999 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1000 def refresh_row(self,rowi): |
135 | 1001 self.SetCellValue(rowi,0,self.n_list[rowi].tag) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1002 self.SetReadOnly(rowi,0) |
135 | 1003 self.SetCellValue(rowi,1,self.n_list[rowi].text) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1004 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1005 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1006 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1007 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1008 col_w = w/(cols) |
152 | 1009 for i in range(0,cols): self.SetColSize(i,col_w) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1010 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1011 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1012 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1013 class inventory_grid(wx.grid.Grid): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1014 """grid for gen info""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1015 def __init__(self, parent, handler): |
135 | 1016 pname = handler.xml.set("name", 'Money and Inventory') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1017 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1018 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1019 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1020 self.handler = handler |
135 | 1021 n_list = handler.xml.getchildren() |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1022 self.CreateGrid(len(n_list),2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1023 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1024 self.SetColLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1025 self.n_list = n_list |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1026 i = 0 |
152 | 1027 for i in range(len(n_list)): self.refresh_row(i) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1028 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1029 def on_cell_change(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1030 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1031 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1032 value = self.GetCellValue(row,col) |
135 | 1033 self.n_list[row].text = value |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1034 if row==0: self.handler.on_name_change(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1035 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1036 def refresh_row(self,rowi): |
135 | 1037 self.SetCellValue(rowi,0, self.n_list[rowi].tag) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1038 self.SetReadOnly(rowi,0) |
135 | 1039 self.SetCellValue(rowi,1,self.n_list[rowi].text) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1040 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1041 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1042 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1043 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1044 col_w = w/(cols) |
152 | 1045 for i in range(0,cols): self.SetColSize(i,col_w) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1046 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1047 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1048 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1049 class abil_grid(wx.grid.Grid): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1050 """grid for abilities""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1051 def __init__(self, parent, handler): |
135 | 1052 pname = handler.xml.set("name", 'Stats') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1053 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1054 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1055 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1056 self.handler = handler |
135 | 1057 stats = handler.xml.findall('stat') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1058 self.CreateGrid(len(stats),3) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1059 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1060 col_names = ['Ability','Score','Modifier'] |
152 | 1061 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1062 self.stats = stats |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1063 i = 0 |
152 | 1064 for i in range(len(stats)): self.refresh_row(i) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1065 self.char_wnd = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1066 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1067 def on_cell_change(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1068 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1069 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1070 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1071 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1072 int(value) |
135 | 1073 self.stats[row].set('base',value) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1074 self.refresh_row(row) |
152 | 1075 except: self.SetCellValue(row,col,"0") |
1076 if self.char_wnd: self.char_wnd.refresh_data() | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1077 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1078 def refresh_row(self,rowi): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1079 s = self.stats[rowi] |
135 | 1080 name = s.get('name') |
1081 abbr = s.get('abbr') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1082 self.SetCellValue(rowi,0,name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1083 self.SetReadOnly(rowi,0) |
135 | 1084 self.SetCellValue(rowi,1,s.get('base')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1085 self.SetCellValue(rowi,2,str(self.handler.get_mod(abbr))) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1086 self.SetReadOnly(rowi,2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1087 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1088 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1089 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1090 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1091 col_w = w/(cols+2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1092 self.SetColSize(0,col_w*3) |
152 | 1093 for i in range(1,cols): self.SetColSize(i,col_w) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1094 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1095 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1096 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1097 def refresh_data(self): |
152 | 1098 for r in range(self.GetNumberRows()-1): self.refresh_row(r) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1099 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1100 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1101 class save_grid(wx.grid.Grid): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1102 """grid for saves""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1103 def __init__(self, parent, handler): |
135 | 1104 pname = handler.xml.set("name", 'Saves') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1105 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1106 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1107 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1108 self.handler = handler |
135 | 1109 saves = handler.xml.findall('save') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1110 self.stats = handler.char_hander.child_handlers['abilities'] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1111 self.CreateGrid(len(saves),7) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1112 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1113 col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] |
152 | 1114 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1115 self.saves = saves |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1116 i = 0 |
152 | 1117 for i in range(len(saves)):self.refresh_row(i) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1118 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1119 def on_cell_change(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1120 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1121 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1122 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1123 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1124 int(value) |
152 | 1125 if col == 2: self.saves[row].set('base',value) |
1126 elif col == 4:self.saves[row].set('magmod',value) | |
1127 elif col == 4: self.saves[row].set('miscmod',value) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1128 self.refresh_row(row) |
152 | 1129 except: self.SetCellValue(row,col,"0") |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1130 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1131 def refresh_row(self,rowi): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1132 s = self.saves[rowi] |
135 | 1133 name = s.get('name') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1134 self.SetCellValue(rowi,0,name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1135 self.SetReadOnly(rowi,0) |
135 | 1136 stat = s.get('stat') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1137 self.SetCellValue(rowi,1,stat) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1138 self.SetReadOnly(rowi,1) |
135 | 1139 self.SetCellValue(rowi,2,s.get('base')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1140 self.SetCellValue(rowi,3,str(self.stats.get_mod(stat))) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1141 self.SetReadOnly(rowi,3) |
135 | 1142 self.SetCellValue(rowi,4,s.get('magmod')) |
1143 self.SetCellValue(rowi,5,s.get('miscmod')) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1144 mod = str(self.handler.get_mod(name)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1145 self.SetCellValue(rowi,6,mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1146 self.SetReadOnly(rowi,6) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1147 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1148 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1149 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1150 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1151 col_w = w/(cols+2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1152 self.SetColSize(0,col_w*3) |
152 | 1153 for i in range(1,cols): self.SetColSize(i,col_w) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1154 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1155 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1156 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1157 def refresh_data(self): |
152 | 1158 for r in range(self.GetNumberRows()): self.refresh_row(r) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1159 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1160 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1161 class skill_grid(wx.grid.Grid): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1162 """ panel for skills """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1163 def __init__(self, parent, handler): |
135 | 1164 pname = handler.xml.set("name", 'Skills') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1165 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1166 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1167 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1168 self.handler = handler |
135 | 1169 skills = handler.xml.findall('skill') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1170 self.stats = handler.char_hander.child_handlers['abilities'] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1171 self.CreateGrid(len(skills),7) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1172 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1173 col_names = ['Skill','Key','Rank','Abil','Misc','Total'] |
152 | 1174 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1175 rowi = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1176 self.skills = skills |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1177 for i in range(len(skills)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1178 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1179 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1180 def on_cell_change(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1181 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1182 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1183 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1184 #print value |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1185 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1186 int(value) |
152 | 1187 if col == 3: self.skills[row].set('rank',value) |
1188 elif col == 5: self.skills[row].set('misc',value) | |
1189 elif col == 1: self.skills[row].set('untrained',value) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1190 self.refresh_row(row) |
152 | 1191 except: self.SetCellValue(row,col,"0") |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1192 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1193 def refresh_row(self,rowi): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1194 s = self.skills[rowi] |
135 | 1195 name = s.get('name') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1196 self.SetCellValue(rowi,0,name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1197 self.SetReadOnly(rowi,0) |
135 | 1198 self.SetCellValue(rowi,1,s.get('untrained')) |
1199 stat = s.get('stat') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1200 self.SetCellValue(rowi,2,stat) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1201 self.SetReadOnly(rowi,2) |
135 | 1202 self.SetCellValue(rowi,3,s.get('rank')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1203 self.SetCellValue(rowi,4,str(self.stats.get_mod(stat))) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1204 self.SetReadOnly(rowi,4) |
135 | 1205 self.SetCellValue(rowi,5,s.get('misc')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1206 mod = str(self.handler.get_mod(name)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1207 self.SetCellValue(rowi,6,mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1208 self.SetReadOnly(rowi,6) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1209 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1210 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1211 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1212 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1213 col_w = w/(cols+2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1214 self.SetColSize(0,col_w*3) |
152 | 1215 for i in range(1,cols): self.SetColSize(i,col_w) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1216 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1217 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1218 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1219 def refresh_data(self): |
152 | 1220 for r in range(self.GetNumberRows()): self.refresh_row(r) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1221 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1222 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1223 class feat_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1224 def __init__(self, parent, handler): |
135 | 1225 pname = handler.xml.set("name", 'Feats') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1226 wx.Panel.__init__(self, parent, -1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1227 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1228 sizer = wx.BoxSizer(wx.HORIZONTAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1229 remove_btn = wx.Button(self, wx.ID_ANY, "Remove Feat") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1230 add_btn = wx.Button(self, wx.ID_ANY, "Add Feat") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1231 sizer.Add(remove_btn, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1232 sizer.Add(wx.Size(10,10)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1233 sizer.Add(add_btn, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1234 self.sizer = sizer |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1235 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1236 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1237 self.Bind(wx.EVT_BUTTON, self.on_remove, remove_btn) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1238 self.Bind(wx.EVT_BUTTON, self.on_add, add_btn) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1239 |
135 | 1240 n_list = handler.xml.getchildren() |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1241 self.n_list = n_list |
135 | 1242 self.xml = handler.xml |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1243 self.grid.CreateGrid(len(n_list),2,1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1244 self.grid.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1245 self.grid.SetColLabelValue(0,"Feat") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1246 self.grid.SetColLabelValue(1,"Type") |
152 | 1247 for i in range(len(n_list)): self.refresh_row(i) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1248 self.temp_dom = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1249 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1250 def refresh_row(self,i): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1251 feat = self.n_list[i] |
135 | 1252 name = feat.get('name') |
1253 type = feat.get('type') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1254 self.grid.SetCellValue(i,0,name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1255 self.grid.SetReadOnly(i,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1256 self.grid.SetCellValue(i,1,type) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1257 self.grid.SetReadOnly(i,1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1258 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1259 def on_remove(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1260 rows = self.grid.GetNumberRows() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1261 for i in range(rows): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1262 if self.grid.IsInSelection(i,0): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1263 self.grid.DeleteRows(i) |
135 | 1264 self.xml.remove(self.n_list[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1265 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1266 def on_add(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1267 if not self.temp_dom: |
135 | 1268 tree = parse(dir_struct["SWd20"]+"d20feats.xml") |
1269 self.temp_dom = tree.getroot() | |
1270 f_list = self.temp_dom.findall('feat') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1271 opts = [] |
152 | 1272 for f in f_list: opts.append(f.get('name')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1273 dlg = wx.SingleChoiceDialog(self,'Choose Feat','Feats',opts) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1274 if dlg.ShowModal() == wx.ID_OK: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1275 i = dlg.GetSelection() |
135 | 1276 new_node = self.xml.append(f_list[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1277 self.grid.AppendRows(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1278 self.refresh_row(self.grid.GetNumberRows()-1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1279 dlg.Destroy() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1280 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1281 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1282 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1283 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1284 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1285 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1286 (w,h) = self.grid.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1287 cols = self.grid.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1288 col_w = w/(cols) |
152 | 1289 for i in range(0,cols): self.grid.SetColSize(i,col_w) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1290 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1291 class attack_grid(wx.grid.Grid): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1292 """grid for attacks""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1293 def __init__(self, parent, handler): |
135 | 1294 pname = handler.xml.set("name", 'Melee') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1295 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1296 self.parent = parent |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1297 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1298 self.rows = (self.handler.melee,self.handler.ranged) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1299 self.CreateGrid(2,10) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1300 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1301 col_names = ['Type','base','base 2','base 3','base 4','base 5','base 6','abil','misc','Total'] |
152 | 1302 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1303 self.SetCellValue(0,0,"Melee") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1304 self.SetCellValue(1,0,"Ranged") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1305 self.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1306 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1307 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1308 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1309 def on_cell_change(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1310 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1311 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1312 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1313 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1314 int(value) |
152 | 1315 if col== 1: self.rows[row].set('base',value) |
1316 elif col== 2: self.rows[row].set('second',value) | |
1317 elif col== 3: self.rows[row].set('third',value) | |
1318 elif col== 4: self.rows[row].set('forth',value) | |
1319 elif col== 5: self.rows[row].set('fifth',value) | |
1320 elif col== 6: self.rows[row].set('sixth',value) | |
1321 elif col== 8: self.rows[row].set('misc',value) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1322 self.parent.refresh_data() |
152 | 1323 except: self.SetCellValue(row,col,"0") |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1324 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1325 def refresh_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1326 melee = self.handler.get_attack_data('m') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1327 ranged = self.handler.get_attack_data('r') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1328 for i in range(0,7): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1329 self.SetCellValue(0,i+1,str(melee[i])) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1330 self.SetCellValue(1,i+1,str(ranged[i])) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1331 self.SetCellValue(0,9,str(melee[0]+melee[6]+melee[7])) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1332 self.SetCellValue(1,9,str(ranged[0]+ranged[6]+ranged[7])) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1333 self.SetReadOnly(0,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1334 self.SetReadOnly(1,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1335 self.SetReadOnly(0,7) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1336 self.SetReadOnly(1,7) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1337 self.SetReadOnly(0,9) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1338 self.SetReadOnly(1,9) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1339 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1340 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1341 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1342 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1343 col_w = w/(cols+1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1344 self.SetColSize(0,col_w*2) |
152 | 1345 for i in range(1,cols): self.SetColSize(i,col_w) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1346 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1347 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1348 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1349 class weapon_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1350 def __init__(self, parent, handler): |
135 | 1351 pname = handler.xml.set("name", 'Weapons') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1352 wx.Panel.__init__(self, parent, -1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1353 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1354 sizer = wx.BoxSizer(wx.HORIZONTAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1355 remove_btn = wx.Button(self, 10, "Remove Weapon") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1356 add_btn = wx.Button(self, 20, "Add Weapon") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1357 sizer.Add(remove_btn, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1358 sizer.Add(wx.Size(10,10)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1359 sizer.Add(add_btn, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1360 self.sizer = sizer |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1361 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1362 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1363 self.Bind(wx.EVT_BUTTON, self.on_remove, remove_btn) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1364 self.Bind(wx.EVT_BUTTON, self.on_add, add_btn) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1365 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
135 | 1366 n_list = handler.xml.findall('weapon') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1367 self.n_list = n_list |
135 | 1368 self.xml = handler.xml |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1369 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1370 self.grid.CreateGrid(len(n_list),9,1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1371 self.grid.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1372 col_names = ['Name','damage','mod','critical','type','weight','range','size','Total'] |
152 | 1373 for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1374 self.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1375 self.temp_dom = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1376 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1377 def on_cell_change(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1378 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1379 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1380 value = self.grid.GetCellValue(row,col) |
152 | 1381 if col == 0: self.n_list[row].set('name',value) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1382 elif col == 2: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1383 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1384 int(value) |
135 | 1385 self.n_list[row].set('mod',value) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1386 self.refresh_row(row) |
152 | 1387 except: self.grid.SetCellValue(row,col,"1") |
1388 else: self.n_list[row].set(self.grid.GetColLabelValue(col),value) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1389 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1390 def refresh_row(self,i): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1391 n = self.n_list[i] |
135 | 1392 name = n.get('name') |
1393 mod = n.get('mod') | |
1394 ran = n.get('range') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1395 total = str(int(mod) + self.handler.get_mod(ran)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1396 self.grid.SetCellValue(i,0,name) |
135 | 1397 self.grid.SetCellValue(i,1,n.get('damage')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1398 self.grid.SetCellValue(i,2,mod) |
135 | 1399 self.grid.SetCellValue(i,3,n.get('critical')) |
1400 self.grid.SetCellValue(i,4,n.get('type')) | |
1401 self.grid.SetCellValue(i,5,n.get('weight')) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1402 self.grid.SetCellValue(i,6,ran) |
135 | 1403 self.grid.SetCellValue(i,7,n.get('size') ) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1404 self.grid.SetCellValue(i,8,total) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1405 self.grid.SetReadOnly(i,8) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1406 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1407 def on_remove(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1408 rows = self.grid.GetNumberRows() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1409 for i in range(rows): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1410 if self.grid.IsInSelection(i,0): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1411 self.grid.DeleteRows(i) |
135 | 1412 self.xml.remove(self.n_list[i]) |
1413 self.n_list = self.xml.findall('weapon') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1414 self.handler.refresh_weapons() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1415 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1416 def on_add(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1417 if not self.temp_dom: |
135 | 1418 tree = parse(dir_struct["SWd20"]+"d20weapons.xml") |
1419 self.temp_dom = tree.getroot() | |
1420 f_list = self.temp_dom.findall('weapon') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1421 opts = [] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1422 for f in f_list: |
135 | 1423 opts.append(f.get('name')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1424 dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1425 if dlg.ShowModal() == wx.ID_OK: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1426 i = dlg.GetSelection() |
135 | 1427 new_node = self.xml.append(f_list[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1428 self.grid.AppendRows(1) |
135 | 1429 self.n_list = self.xml.findall('weapon') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1430 self.refresh_row(self.grid.GetNumberRows()-1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1431 self.handler.refresh_weapons() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1432 dlg.Destroy() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1433 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1434 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1435 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1436 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1437 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1438 (w,h) = self.grid.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1439 cols = self.grid.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1440 col_w = w/(cols+1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1441 self.grid.SetColSize(0,col_w*2) |
152 | 1442 for i in range(1,cols): self.grid.SetColSize(i,col_w) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1443 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1444 def refresh_data(self): |
152 | 1445 for i in range(len(self.n_list)): self.refresh_row(i) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1446 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1447 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1448 class attack_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1449 def __init__(self, parent, handler): |
135 | 1450 pname = handler.xml.set("name", 'Melee') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1451 wx.Panel.__init__(self, parent, -1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1452 self.a_grid = attack_grid(self, handler) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1453 self.w_panel = weapon_panel(self, handler) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1454 self.sizer = wx.BoxSizer(wx.VERTICAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1455 self.sizer.Add(self.a_grid, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1456 self.sizer.Add(self.w_panel, 2, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1457 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1458 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1459 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1460 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1461 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1462 self.sizer.SetDimension(0,0,s[0],s[1]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1463 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1464 def refresh_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1465 self.w_panel.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1466 self.a_grid.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1467 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1468 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1469 class ac_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1470 def __init__(self, parent, handler): |
135 | 1471 pname = handler.xml.set("name", 'Armor') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1472 wx.Panel.__init__(self, parent, -1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1473 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1474 sizer = wx.BoxSizer(wx.HORIZONTAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1475 remove_btn = wx.Button(self, 10, "Remove Armor") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1476 add_btn = wx.Button(self, 20, "Add Armor") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1477 sizer.Add(remove_btn, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1478 sizer.Add(wx.Size(10,10)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1479 sizer.Add(add_btn, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1480 self.sizer = sizer |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1481 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1482 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1483 self.Bind(wx.EVT_BUTTON, self.on_remove, remove_btn) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1484 self.Bind(wx.EVT_BUTTON, self.on_add, add_btn) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1485 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
135 | 1486 self.xml = handler.xml |
1487 n_list = handler.xml.getchildren() | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1488 self.n_list = n_list |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1489 col_names = ['Armor','DR','Max Dex','Check Penalty','Weight','Speed (10)','Speed (6)','type'] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1490 self.grid.CreateGrid(len(n_list),len(col_names),1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1491 self.grid.SetRowLabelSize(0) |
152 | 1492 for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1493 self.atts =['name','bonus','maxdex','checkpenalty','weight','speed','speed6','type'] |
152 | 1494 for i in range(len(n_list)): self.refresh_row(i) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1495 self.temp_dom = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1496 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1497 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1498 def on_cell_change(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1499 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1500 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1501 value = self.grid.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1502 if col >= 1 and col <= 5: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1503 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1504 int(value) |
135 | 1505 self.n_list[row].set(self.atts[col],value) |
152 | 1506 except: self.grid.SetCellValue(row,col,"0") |
1507 else: self.n_list[row].set(self.atts[col],value) | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1508 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1509 def refresh_row(self,i): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1510 n = self.n_list[i] |
152 | 1511 for y in range(len(self.atts)): self.grid.SetCellValue(i,y,n.get(self.atts[y])) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1512 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1513 def on_remove(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1514 rows = self.grid.GetNumberRows() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1515 for i in range(rows): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1516 if self.grid.IsInSelection(i,0): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1517 self.grid.DeleteRows(i) |
135 | 1518 self.xml.remove(self.n_list[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1519 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1520 def on_add(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1521 if not self.temp_dom: |
135 | 1522 tree = parse(dir_struct["SWd20"]+"d20armor.xml") |
1523 self.temp_dom = tree.getroot() | |
1524 f_list = self.temp_dom.findall('armor') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1525 opts = [] |
152 | 1526 for f in f_list: opts.append(f.get('name')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1527 dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1528 if dlg.ShowModal() == wx.ID_OK: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1529 i = dlg.GetSelection() |
135 | 1530 new_node = self.xml.append(f_list[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1531 self.grid.AppendRows(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1532 self.refresh_row(self.grid.GetNumberRows()-1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1533 dlg.Destroy() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1534 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1535 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1536 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1537 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1538 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1539 (w,h) = self.grid.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1540 cols = self.grid.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1541 col_w = w/(cols+2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1542 self.grid.SetColSize(0,col_w*3) |
152 | 1543 for i in range(1,cols): self.grid.SetColSize(i,col_w) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1544 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1545 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1546 class class_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1547 def __init__(self, parent, handler): |
135 | 1548 pname = handler.xml.set("name", 'Class') |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1549 wx.Panel.__init__(self, parent, -1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1550 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1551 sizer = wx.BoxSizer(wx.HORIZONTAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1552 remove_btn = wx.Button(self, wx.ID_ANY, "Remove Class") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1553 add_btn = wx.Button(self, wx.ID_ANY, "Add Class") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1554 sizer.Add(remove_btn, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1555 sizer.Add(wx.Size(10,10)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1556 sizer.Add(add_btn, 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1557 self.sizer = sizer |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1558 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1559 self.Bind(wx.EVT_SIZE, self.on_size) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1560 self.Bind(wx.EVT_BUTTON, self.on_remove, remove_btn) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1561 self.Bind(wx.EVT_BUTTON, self.on_add, add_btn) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1562 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1563 |
135 | 1564 n_list = handler.xml.getchildren() |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1565 self.n_list = n_list |
135 | 1566 self.xml = handler.xml |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1567 self.grid.CreateGrid(len(n_list),2,1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1568 self.grid.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1569 self.grid.SetColLabelValue(0,"Class") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1570 self.grid.SetColLabelValue(1,"Level") |
152 | 1571 for i in range(len(n_list)): self.refresh_row(i) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1572 self.temp_dom = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1573 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1574 def on_cell_change(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1575 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1576 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1577 value = self.grid.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1578 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1579 int(value) |
135 | 1580 self.n_list[row].set('level',value) |
152 | 1581 except: self.grid.SetCellValue(row,col,"1") |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1582 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1583 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1584 def refresh_row(self,i): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1585 n = self.n_list[i] |
135 | 1586 name = n.get('name') |
1587 level = n.get('level') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1588 self.grid.SetCellValue(i,0,name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1589 self.grid.SetReadOnly(i,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1590 self.grid.SetCellValue(i,1,level) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1591 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1592 def on_remove(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1593 rows = self.grid.GetNumberRows() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1594 for i in range(rows): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1595 if self.grid.IsInSelection(i,0): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1596 self.grid.DeleteRows(i) |
135 | 1597 self.xml.remove(self.n_list[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1598 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1599 def on_add(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1600 if not self.temp_dom: |
135 | 1601 tree = parse(dir_struct["SWd20"]+"SWd20classes.xml") |
1602 self.temp_dom = tree.getroot() | |
1603 f_list = self.temp_dom.findall('class') | |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1604 opts = [] |
152 | 1605 for f in f_list: opts.append(f.get('name')) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1606 dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1607 if dlg.ShowModal() == wx.ID_OK: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1608 i = dlg.GetSelection() |
135 | 1609 new_node = self.xml.append(f_list[i]) |
60
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1610 self.grid.AppendRows(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1611 self.refresh_row(self.grid.GetNumberRows()-1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1612 dlg.Destroy() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1613 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1614 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1615 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1616 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1617 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1618 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1619 (w,h) = self.grid.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1620 cols = self.grid.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1621 col_w = w/(cols) |
152 | 1622 for i in range(0,cols): self.grid.SetColSize(i,col_w) |
1623 |