Mercurial > traipse_dev
annotate orpg/gametree/nodehandlers/StarWarsd20.py @ 60:3b2cfa13b610 ornery-dev
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
Fix to three broken nodes. Update Manager is no longer a top window, has an
icon and now has a place on the task bar (panel).
author | sirebral |
---|---|
date | Wed, 12 Aug 2009 20:54:46 -0500 |
parents | 4385a7d0efd1 |
children | c54768cffbd4 |
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: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
24 # $Id: StarWarsd20.py,v 1.18 2006/11/15 12:11:23 digitalxero Exp $ |
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 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
29 __version__ = "$Id: StarWarsd20.py,v 1.18 2006/11/15 12:11:23 digitalxero Exp $" |
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 * |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
32 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
33 SWD20_EXPORT = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
34 ############################ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
35 ## StarWarsd20 character node handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
36 ############################ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
37 ##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
|
38 class container_handler(node_handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
39 """ 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
|
40 <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
|
41 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
42 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
|
43 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
|
44 self.load_children() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
45 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
46 def load_children(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
47 children = self.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
48 for c in children: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
49 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
|
50 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
51 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
52 def on_drop(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
53 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
|
54 #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
|
55 # return |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
56 if drag_obj == self: |
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 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
|
59 if opt == wx.YES: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
60 xml_dom = self.tree.drag_obj.delete() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
61 xml_dom = self.master_dom.insertBefore(xml_dom,None) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
62 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
|
63 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
|
64 elif opt == wx.NO: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
65 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
|
66 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
67 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
68 cookie = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
69 html_str = "<table border=\"1\" ><tr><td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
70 html_str += "<b>"+self.master_dom.getAttribute("name") + "</b>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
71 html_str += "</td></tr>\n" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
72 html_str += "<tr><td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
73 max = tree.GetChildrenCount(handler.mytree_node) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
74 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
75 (child,cookie)=self.tree.GetFirstChild(self.mytree_node,cookie) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
76 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
|
77 (child,cookie)=self.tree.GetFirstChild(self.mytree_node) |
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 set_char_pp(self,attr,evl): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
94 ## return self.child_handlers['pp'].set_char_pp(attr,evl) |
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 ## def get_char_pp( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
97 ## return self.child_handlers['pp'].get_char_pp(attr) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
98 ## |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
99 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
|
100 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
|
101 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
102 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
103 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
104 class SWd20char_handler(node_handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
105 """ 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
|
106 <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
|
107 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
108 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
|
109 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
|
110 self.frame = open_rpg.get_component('frame') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
111 self.child_handlers = {} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 self.myeditor = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
125 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
126 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
127 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
|
128 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
|
129 if old_version == "": |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
130 tmp = open(orpg.dirpath.dir_struct["nodes"]+"StarWars_d20character.xml","r") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
131 xml_dom = parseXml_with_dlg(self.tree,tmp.read()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
132 xml_dom = xml_dom._get_firstChild() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
133 tmp.close() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
134 ## add new nodes |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
135 for tag in ("howtouse","inventory","powers","divine","pp"): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
136 node_list = xml_dom.getElementsByTagName(tag) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
137 self.master_dom.appendChild(node_list[0]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
138 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
139 ## add new atts |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
140 melee_attack = self.master_dom.getElementsByTagName('melee')[0] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
141 melee_attack.setAttribute("second","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
142 melee_attack.setAttribute("third","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
143 melee_attack.setAttribute("forth","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
144 melee_attack.setAttribute("fifth","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
145 melee_attack.setAttribute("sixth","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
146 range_attack = self.master_dom.getElementsByTagName('ranged')[0] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
147 range_attack.setAttribute("second","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
148 range_attack.setAttribute("third","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
149 range_attack.setAttribute("forth","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
150 range_attack.setAttribute("fifth","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
151 range_attack.setAttribute("sixth","0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
152 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
153 gen_list = self.master_dom.getElementsByTagName('general')[0] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
154 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
155 for tag in ("currentxp","xptolevel"): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
156 node_list = xml_dom.getElementsByTagName(tag) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
157 gen_list.appendChild(node_list[0]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
158 ## temp fix |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
159 #parent = self.master_dom._get_parentNode() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
160 #old_dom = parent.replaceChild(xml_dom,self.master_dom) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
161 #self.master_dom = xml_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
162 print old_version |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
163 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
164 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
165 def get_char_name( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
166 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
|
167 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
168 ## def set_char_pp(self,attr,evl): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
169 ## return self.child_handlers['pp'].set_char_pp(attr,evl) |
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_char_pp( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
172 ## return self.child_handlers['pp'].get_char_pp(attr) |
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 get_char_lvl( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
175 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
|
176 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
177 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
178 def new_child_handler(self,tag,text,handler_class,icon='gear'): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
179 node_list = self.master_dom.getElementsByTagName(tag) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
180 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
181 i = self.tree.icons[icon] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
182 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
|
183 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
|
184 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
|
185 self.child_handlers[tag] = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
186 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
187 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
|
188 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
|
189 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
190 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
191 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
|
192 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
|
193 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
194 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
195 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
202 #html_str += "<P>" + self.child_handlers['spells'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
203 #html_str += "<P>" + self.child_handlers['divine'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
204 #html_str += "<P>" + self.child_handlers['powers'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 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
|
209 #html_str += "<P>" + self.child_handlers['pp'].tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
210 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
|
211 html_str += "</tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
212 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
213 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
214 def about(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
215 html_str = "<img src='" + orpg.dirpath.dir_struct["icon"]+'d20_logo.gif' "><br /><b>d20 Character Tool v0.7 beta</b>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
216 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
|
217 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
218 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
219 def get_char_name( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
220 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
|
221 def get_armor_class( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
222 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
|
223 def get_max_hp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
224 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
|
225 def get_current_hp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
226 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
|
227 def get_max_vp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
228 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
|
229 def get_current_vp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
230 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
|
231 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
232 ## def set_char_pp(self,attr,evl): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
233 ## return self.child_handlers['pp'].set_char_pp(attr,evl) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
234 ## |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
235 ## def get_char_pp( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
236 ## return self.child_handlers['pp'].get_char_pp(attr) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
237 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
238 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
|
239 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
|
240 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
241 class tabbed_panel(wx.Notebook): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
242 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
|
243 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
|
244 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
245 self.parent = parent |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
246 tree = self.handler.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
247 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
|
248 cookie = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
249 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
250 (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
|
251 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
|
252 (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
|
253 obj = tree.GetPyData(child) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
254 for m in xrange(max): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
255 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
256 if mode == 1: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
257 panel = obj.get_design_panel(self) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
258 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
259 panel = obj.get_use_panel(self) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
260 name = obj.master_dom.getAttribute("name") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
261 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
262 if panel: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
263 self.AddPage(panel,name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
264 if m < max-1: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
265 child = tree.GetNextSibling(child) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
266 obj = tree.GetPyData(child) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
267 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
268 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
269 def about(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
270 html_str = "<img src='" + orpg.dirpath.dir_struct["icon"]+'d20_logo.gif' "><br /><b>d20 Character Tool v0.7 beta</b>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
271 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
|
272 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
273 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
274 def get_char_name( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
275 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
|
276 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
277 ## def set_char_pp(self,attr,evl): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
278 ## return self.child_handlers['pp'].set_char_pp(attr,evl) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
279 ## |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
280 ## def get_char_pp( self, attr ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
281 ## return self.child_handlers['pp'].get_char_pp(attr) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
282 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
283 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
|
284 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
|
285 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
286 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
|
287 """ 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
|
288 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
289 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
290 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
|
291 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
|
292 self.char_hander = parent |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
293 self.drag = False |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
294 self.frame = open_rpg.get_component('frame') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
295 self.myeditor = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
296 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
297 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
298 def on_drop(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
299 pass |
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 on_rclick(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
302 pass |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
303 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
304 def on_ldclick(self,evt): #Function needs help. Needs an OnClose I think. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
305 if self.myeditor == None or self.myeditor.destroyed: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
306 title = self.master_dom.getAttribute('name') + " Editor" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
307 # Frame created in correctly. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
308 self.myeditor = wx.Frame(self.frame,title,orpg.dirpath.dir_struct["icon"]+'grid.ico') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
309 wnd = self.get_design_panel(self.myeditor) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
310 self.myeditor.panel = wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
311 self.wnd = wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
312 self.myeditor.Show(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
313 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
314 self.myeditor.Raise() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
315 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
316 def on_html(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
317 html_str = self.tohtml() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
318 wnd = http_html_window(self.frame.note,-1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
319 wnd.title = self.master_dom.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
320 self.frame.add_panel(wnd) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
321 wnd.SetPage(html_str) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
322 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
323 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
|
324 pass |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
325 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
326 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
|
327 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
|
328 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
329 def delete(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
330 pass |
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 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
333 class SWd20skill(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
334 """ 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
|
335 created by SWd20char_handler. |
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 __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
|
338 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
|
339 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
340 icons = self.tree.icons |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
341 node_list = self.master_dom.getElementsByTagName('skill') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
342 self.skills={} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
343 for n in node_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
344 name = n.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
345 self.skills[name] = n |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
346 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
|
347 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
|
348 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
349 def get_mod(self,name): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
350 skill = self.skills[name] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
351 stat = skill.getAttribute('stat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
352 ac = int(skill.getAttribute('armorcheck')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
353 if ac: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
354 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
|
355 stat_mod = self.char_hander.child_handlers['abilities'].get_mod(stat) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
356 rank = int(skill.getAttribute('rank')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
357 misc = int(skill.getAttribute('misc')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
358 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
|
359 return total |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
360 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
361 def on_rclick(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
362 #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
|
363 item = self.tree.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
364 name = self.tree.GetItemText(item) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
365 skill = self.skills[name] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
366 rank = int(skill.getAttribute('rank')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
367 untrained = int(skill.getAttribute('untrained')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
368 chat = self.chat |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
369 if item == self.mytree_node: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
370 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
|
371 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
372 if rank == 0 and untrained == 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
373 chat.Post('Can\'t use untrained!',True,True) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
374 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
375 mod = self.get_mod(name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
376 if mod >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
377 mod1 = "+" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
378 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
379 mod1 = "" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
380 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
|
381 chat.ParsePost(txt,True,True) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
382 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
383 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
|
384 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
|
385 wnd.title = "Skills (edit)" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
386 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
387 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
388 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
389 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
|
390 <th>Rank</th><th>Abil</th><th>Misc</th><th>Total</th></tr>""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
391 node_list = self.master_dom.getElementsByTagName('skill') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
392 for n in node_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
393 name = n.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
394 stat = n.getAttribute('stat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
395 rank = n.getAttribute('rank') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
396 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
|
397 stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
398 misc = n.getAttribute('misc') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
399 mod = str(self.get_mod(name)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
400 if mod >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
401 mod1 = "+" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
402 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
403 mod1 = "" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
404 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
|
405 html_str = html_str + "</table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
406 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
407 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
408 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
409 class SWd20ability(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
410 """ 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
|
411 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
412 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
413 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
|
414 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
|
415 self.abilities = {} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
416 node_list = self.master_dom.getElementsByTagName('stat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
417 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
418 icons = tree.icons |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
419 for n in node_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
420 name = n.getAttribute('abbr') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
421 self.abilities[name] = n |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
422 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
|
423 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
|
424 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
425 def on_rclick( self, evt ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
426 item = self.tree.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
427 name = self.tree.GetItemText( item ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
428 if item == self.mytree_node: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
429 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
|
430 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
431 mod = self.get_mod( name ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
432 if mod >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
433 mod1 = "+" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
434 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
435 mod1 = "" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
436 chat = self.chat |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
437 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
|
438 chat.ParsePost( txt, True, True ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
439 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
440 def get_mod(self,abbr): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
441 score = int(self.abilities[abbr].getAttribute('base')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
442 mod = (score - 10) / 2 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
443 return mod |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
444 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
445 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
|
446 if score >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
447 self.abilities[abbr].setAttribute("base",str(score)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
448 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
449 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
|
450 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
|
451 wnd.title = "Abilities (edit)" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
452 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
453 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
454 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
455 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
|
456 <th>Base</th><th>Modifier</th></tr>""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
457 node_list = self.master_dom.getElementsByTagName('stat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
458 for n in node_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
459 name = n.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
460 abbr = n.getAttribute('abbr') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
461 base = n.getAttribute('base') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
462 mod = str(self.get_mod(abbr)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
463 if mod >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
464 mod1 = "+" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
465 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
466 mod1 = "" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
467 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
|
468 html_str = html_str + "</table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
469 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
470 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
471 class SWd20saves(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
472 """ 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
|
473 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
474 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
475 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
|
476 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
|
477 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
478 icons = self.tree.icons |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
479 node_list = self.master_dom.getElementsByTagName('save') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
480 self.saves={} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
481 for n in node_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
482 name = n.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
483 self.saves[name] = n |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
484 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
|
485 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
|
486 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
487 def get_mod(self,name): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
488 save = self.saves[name] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
489 stat = save.getAttribute('stat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
490 stat_mod = self.char_hander.child_handlers['abilities'].get_mod(stat) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
491 base = int(save.getAttribute('base')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
492 miscmod = int(save.getAttribute('miscmod')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
493 # magmod = int(save.getAttribute('magmod')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
494 # total = stat_mod + base + miscmod + magmod |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
495 total = stat_mod + base + miscmod |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
496 return total |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
497 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
498 def on_rclick(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
499 item = self.tree.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
500 name = self.tree.GetItemText(item) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
501 if item == self.mytree_node: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
502 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
|
503 #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
|
504 #wnd.title = "Saves" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
505 #self.frame.add_panel(wnd) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
506 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
507 mod = self.get_mod(name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
508 if mod >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
509 mod1 = "+" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
510 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
511 mod1 = "" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
512 chat = self.chat |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
513 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
|
514 chat.ParsePost( txt, True, True ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
515 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
516 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
|
517 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
|
518 wnd.title = "Saves" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
519 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
520 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
521 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
522 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
|
523 <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
|
524 <th>Misc</th><th>Total</th></tr>""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
525 node_list = self.master_dom.getElementsByTagName('save') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
526 for n in node_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
527 name = n.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
528 stat = n.getAttribute('stat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
529 base = n.getAttribute('base') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
530 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
|
531 stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
532 mag = n.getAttribute('magmod') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
533 misc = n.getAttribute('miscmod') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
534 mod = str(self.get_mod(name)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
535 if mod >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
536 mod1 = "+" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
537 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
538 mod1 = "" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
539 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
|
540 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
|
541 html_str = html_str + "</table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
542 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
543 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
544 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
545 class SWd20general(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
546 """ 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
|
547 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
548 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
549 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
|
550 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
|
551 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
552 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
|
553 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
|
554 wnd.title = "General Info" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
555 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
556 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
557 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
558 n_list = self.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
559 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
|
560 for n in n_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
561 t_node = safe_get_text_node(n) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
562 html_str += "<B>"+n._get_tagName().capitalize() +":</B> " |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
563 html_str += t_node._get_nodeValue() + ", " |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
564 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
|
565 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
566 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
567 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
|
568 self.char_hander.rename(name) |
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 def get_char_name( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
571 node = self.master_dom.getElementsByTagName( 'name' )[0] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
572 t_node = safe_get_text_node( node ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
573 return t_node._get_nodeValue() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
574 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
575 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
576 class SWd20classes(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
577 """ 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
|
578 created by SWd20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
579 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
580 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
|
581 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
|
582 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
583 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
|
584 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
|
585 wnd.title = "Classes" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
586 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
587 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
588 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
589 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Classes</th></tr><tr><td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
590 n_list = self.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
591 for n in n_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
592 html_str += n.getAttribute('name') + " ("+n.getAttribute('level')+"), " |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
593 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
|
594 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
595 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
596 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
|
597 node_list = self.master_dom.getElementsByTagName('class') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
598 for n in node_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
599 lvl = n.getAttribute('level') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
600 type = n.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
601 if attr == "level": |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
602 return lvl |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
603 elif attr == "class": |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
604 return type |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
605 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
606 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
607 class SWd20feats(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
608 """ 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
|
609 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
610 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
611 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
|
612 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
|
613 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
614 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
|
615 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
|
616 wnd.title = "Feats" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
617 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
618 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
619 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
620 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Feats</th></tr><tr><td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
621 n_list = self.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
622 for n in n_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
623 html_str += n.getAttribute('name')+ ", " |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
624 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
|
625 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
626 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
627 class SWd20howto(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
628 """ 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
|
629 created by d20char_handler. |
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 __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
|
632 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
|
633 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
634 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
|
635 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
|
636 wnd.title = "How To" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
637 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
638 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
639 class SWd20inventory(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
640 """ 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
|
641 created by d20char_handler. |
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 __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
|
644 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
|
645 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
646 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
|
647 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
|
648 wnd.title = "General Info" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
649 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
650 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
651 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
652 n_list = self.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
653 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
|
654 for n in n_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
655 t_node = safe_get_text_node(n) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
656 html_str += "<B>"+n._get_tagName().capitalize() +":</B> " |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
657 html_str += t_node._get_nodeValue() + "<br />" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
658 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
|
659 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
660 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
661 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
|
662 self.char_hander.rename(name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
663 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
664 def get_char_name( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
665 node = self.master_dom.getElementsByTagName( 'name' )[0] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
666 t_node = safe_get_text_node( node ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
667 return t_node._get_nodeValue() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
668 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
669 class SWd20hp(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
670 """ 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
|
671 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
672 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
673 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
|
674 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
|
675 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
676 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
|
677 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
|
678 wnd.title = "Wound Points" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
679 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
680 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
681 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
682 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th colspan=4>Wound Points</th></tr>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
683 html_str += "<tr><th>Max:</th><td>"+self.master_dom.getAttribute('max')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
684 html_str += "<th>Current:</th><td>"+self.master_dom.getAttribute('current')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
685 html_str += "</tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
686 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
687 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
688 def get_max_hp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
689 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
690 return eval( self.master_dom.getAttribute( 'max' ) ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
691 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
692 return 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
693 def get_current_hp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
694 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
695 return eval( self.master_dom.getAttribute( 'current' ) ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
696 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
697 return 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
698 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
699 class SWd20vp(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
700 """ 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
|
701 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
702 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
703 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
|
704 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
|
705 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
706 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
|
707 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
|
708 wnd.title = "Vitality Points" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
709 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
710 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
711 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
712 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th colspan=4>Vitality Points</th></tr>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
713 html_str += "<tr><th>Max:</th><td>"+self.master_dom.getAttribute('max')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
714 html_str += "<th>Current:</th><td>"+self.master_dom.getAttribute('current')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
715 html_str += "</tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
716 return html_str |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
717 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
718 def get_max_vp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
719 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
720 return eval( self.master_dom.getAttribute( 'max' ) ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
721 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
722 return 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
723 def get_current_vp( self ): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
724 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
725 return eval( self.master_dom.getAttribute( 'current' ) ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
726 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
727 return 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
728 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
729 class SWd20attacks(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
730 """ 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
|
731 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
732 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
733 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
|
734 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
|
735 node_list = self.master_dom.getElementsByTagName('melee') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
736 self.melee = node_list[0] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
737 node_list = self.master_dom.getElementsByTagName('ranged') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
738 self.ranged = node_list[0] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
739 self.refresh_weapons() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
740 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
741 def refresh_weapons(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
742 self.weapons = {} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
743 tree = self.tree |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
744 icons = self.tree.icons |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
745 tree.CollapseAndReset(self.mytree_node) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
746 node_list = self.master_dom.getElementsByTagName('weapon') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
747 for n in node_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
748 name = n.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
749 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
|
750 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
|
751 self.weapons[name]=n |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
752 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
753 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
|
754 (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
|
755 return base + misc + stat_mod |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
756 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
757 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
|
758 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
|
759 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
|
760 temp = self.melee |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
761 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
762 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
|
763 temp = self.ranged |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
764 base = int(temp.getAttribute('base')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
765 base2 = int(temp.getAttribute('second')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
766 base3 = int(temp.getAttribute('third')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
767 base4 = int(temp.getAttribute('forth')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
768 base5 = int(temp.getAttribute('fifth')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
769 base6 = int(temp.getAttribute('sixth')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
770 misc = int(temp.getAttribute('misc')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
771 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
|
772 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
773 def on_rclick(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
774 #removed the DnD specific code |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
775 item = self.tree.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
776 name = self.tree.GetItemText(item) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
777 if item == self.mytree_node: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
778 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
|
779 #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
|
780 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
781 mod = int(self.weapons[name].getAttribute('mod')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
782 if self.weapons[name].getAttribute('range') == '0': |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
783 mod = mod + self.get_mod('m') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
784 if mod >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
785 mod1 = "+" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
786 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
787 mod1 = "" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
788 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
789 mod = mod + self.get_mod('r') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
790 if mod >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
791 mod1 = "+" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
792 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
793 mod1 = "" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
794 chat = self.chat |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
795 dmg = self.weapons[name].getAttribute('damage') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
796 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
|
797 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
|
798 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
|
799 chat.ParsePost( txt, True, False ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
800 temp = self.melee |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
801 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
|
802 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
803 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
|
804 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
|
805 wnd.title = "Attacks" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
806 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
807 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
808 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
|
809 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
|
810 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
811 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
812 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
|
813 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
|
814 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
|
815 <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
|
816 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
|
817 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
|
818 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
|
819 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
|
820 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
|
821 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
822 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
|
823 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
|
824 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
|
825 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
|
826 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
|
827 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
828 n_list = self.master_dom.getElementsByTagName('weapon') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
829 for n in n_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
830 mod = n.getAttribute('mod') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
831 if mod >= 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
832 mod1 = "+" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
833 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
834 mod1 = "" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
835 ran = n.getAttribute('range') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
836 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
|
837 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
|
838 <th>Attack</th><th >Damage</th><th>Critical</th></tr>""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
839 html_str += "<tr ALIGN='center' ><td colspan=2>"+n.getAttribute('name')+"</td><td>"+total+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
840 html_str += "<td>"+n.getAttribute('damage')+"</td><td>"+n.getAttribute('critical')+"</td></tr>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
841 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
|
842 <th>Type</th><th>Size</th><th>Misc Mod</th></tr>""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
843 html_str += "<tr ALIGN='center'><td>"+ran+"</td><td>"+n.getAttribute('weight')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
844 html_str += "<td>"+n.getAttribute('type')+"</td><td>"+n.getAttribute('size')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
845 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
|
846 return html_str |
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 class SWd20armor(SWd20_char_child): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
849 """ 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
|
850 created by d20char_handler. |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
851 """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
852 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
|
853 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
|
854 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
855 def get_total_weight(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
856 return self.get_total('weight') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
857 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
858 def get_check_pen(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
859 return self.get_total('checkpenalty') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
860 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
861 def get_armor_class(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
862 ac_total = 10 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
863 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
|
864 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
|
865 max_dex = self.get_max_dex() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
866 if dex_mod < max_dex: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
867 ac_total += dex_mod |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
868 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
869 ac_total += max_dex |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
870 return ac_total |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
871 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
872 def get_max_dex(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
873 armor_list = self.master_dom.getElementsByTagName('armor') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
874 dex = 10 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
875 for a in armor_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
876 temp = int(a.getAttribute("maxdex")) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
877 if temp < dex: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
878 dex = temp |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
879 return dex |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
880 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
881 def get_total(self,attr): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
882 armor_list = self.master_dom.getElementsByTagName('armor') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
883 total = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
884 for a in armor_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
885 total += int(a.getAttribute(attr)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
886 return total |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
887 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
888 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
|
889 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
|
890 wnd.title = "Armor" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
891 return wnd |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
892 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
893 def tohtml(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
894 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
|
895 <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
|
896 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
|
897 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
|
898 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
|
899 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
|
900 html_str += "<td>"+str(self.get_total_weight())+"</td></tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
901 n_list = self.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
902 for n in n_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
903 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
|
904 <th>Type</th><th >Bonus</th></tr>""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
905 html_str += "<tr ALIGN='center' ><td colspan=3>"+n.getAttribute('name')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
906 html_str += "<td>"+n.getAttribute('type')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
907 html_str += "<td>"+n.getAttribute('bonus')+"</td></tr>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
908 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
|
909 <th>Max Dex</th><th>Speed</th><th>Weight</th></tr>""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
910 html_str += "<tr ALIGN='center'><td>"+n.getAttribute('checkpenalty')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
911 html_str += "<td>"+n.getAttribute('maxdex')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
912 html_str += "<td>"+n.getAttribute('speed')+"</td>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
913 html_str += "<td>"+n.getAttribute('weight')+"</td></tr></table>" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
914 return html_str |
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 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
917 ######################## |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
918 ## d20 char windows |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
919 ######################## |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
920 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
921 class base_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
922 def __init__(self, parent): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
923 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
|
924 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
925 #self.build_ctrls() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
926 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
|
927 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
928 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
929 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
930 #self.splitter.SetDimensions(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
|
931 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
932 class outline_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
933 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
|
934 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
|
935 self.panel = wnd(self,handler) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
936 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
|
937 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
|
938 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
939 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
940 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
941 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
|
942 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
|
943 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
944 class char_panel(wx.ScrolledWindow): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
945 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
946 pname = handler.master_dom.setAttribute("name", 'TWO') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
947 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
|
948 self.height = 1200 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
949 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
|
950 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
|
951 self.panels = {} |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
952 keys = handler.child_handlers.keys() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
953 for k in keys: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
954 self.panels[k] = handler.child_handlers[k].get_design_panel(self, [k]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
955 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
|
956 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
|
957 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
|
958 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
|
959 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
960 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
|
961 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
|
962 #self.sub_sizer.Add(self.panels['spells'], 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
963 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
964 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
|
965 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
|
966 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
|
967 #self.sub_sizer2.Add(self.panels['pp'], 1, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
968 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
|
969 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
970 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
|
971 #self.sub_sizer2.Add(self.panels['powers'], 2, wx.EXPAND) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
972 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
|
973 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
974 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
|
975 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
|
976 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
|
977 self.SetSizer(self.main_sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
978 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
|
979 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
980 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
981 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
982 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
983 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
|
984 dc = wx.ClientDC(self) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
985 x = dc.DeviceToLogicalX(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
986 y = dc.DeviceToLogicalY(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
987 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
|
988 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
989 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
990 def refresh_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
991 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
|
992 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
|
993 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
|
994 # self.panels['powers'].panel.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
995 # self.panels['spells'].panel.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
996 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
997 HOWTO_MAX = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
998 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
999 class howto_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1000 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1001 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
|
1002 pname = handler.master_dom.setAttribute("name", 'How To') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1003 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1004 self.master_dom = handler.master_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1005 n_list = self.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1006 for n in n_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1007 t_node = safe_get_text_node(n) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1008 self.sizer.AddMany([ (wx.StaticText(self, -1, t_node._get_nodeValue()), 0, wx.ALIGN_CENTER_VERTICAL), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1009 ]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1010 self.sizer.AddGrowableCol(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1011 self.SetSizer(self.sizer) |
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 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1014 WP_CUR = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1015 WP_MAX = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1016 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1017 class hp_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1018 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1019 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
|
1020 pname = handler.master_dom.setAttribute("name", 'WoundPoints') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1021 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1022 self.master_dom = handler.master_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1023 self.sizer.AddMany([ (wx.StaticText(self, -1, "WP Current:"), 0, wx.ALIGN_CENTER_VERTICAL), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1024 (wx.TextCtrl(self, WP_CUR, self.master_dom.getAttribute('current')), 0, wx.EXPAND), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1025 (wx.StaticText(self, -1, "WP Max:"), 0, wx.ALIGN_CENTER_VERTICAL), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1026 (wx.TextCtrl(self, WP_MAX, self.master_dom.getAttribute('max')), 0, wx.EXPAND), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1027 ]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1028 self.sizer.AddGrowableCol(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1029 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
|
1030 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
|
1031 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
|
1032 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1033 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1034 def on_text(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1035 id = evt.GetId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1036 if id == WP_CUR: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1037 self.master_dom.setAttribute('current',evt.GetString()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1038 elif id == WP_MAX: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1039 self.master_dom.setAttribute('max',evt.GetString()) |
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 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1043 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
|
1044 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1045 VP_CUR = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1046 VP_MAX = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1047 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1048 class vp_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1049 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1050 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
|
1051 pname = handler.master_dom.setAttribute("name", 'VitalityPoints') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1052 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1053 self.master_dom = handler.master_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1054 self.sizer.AddMany([ (wx.StaticText(self, -1, "VP Current:"), 0, wx.ALIGN_CENTER_VERTICAL), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1055 (wx.TextCtrl(self, VP_CUR, self.master_dom.getAttribute('current')), 0, wx.EXPAND), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1056 (wx.StaticText(self, -1, "VP Max:"), 0, wx.ALIGN_CENTER_VERTICAL), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1057 (wx.TextCtrl(self, VP_MAX, self.master_dom.getAttribute('max')), 0, wx.EXPAND), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1058 ]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1059 self.sizer.AddGrowableCol(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1060 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
|
1061 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
|
1062 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
|
1063 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1064 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1065 def on_text(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1066 id = evt.GetId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1067 if id == VP_CUR: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1068 self.master_dom.setAttribute('current',evt.GetString()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1069 elif id == VP_MAX: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1070 self.master_dom.setAttribute('max',evt.GetString()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1071 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1072 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1073 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1074 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
|
1075 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1076 #PP_CUR = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1077 #PP_MAX = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1078 #PP_FRE = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1079 #PP_MFRE = wx.NewId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1080 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1081 #class pp_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1082 # def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1083 # 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
|
1084 # pname = handler.master_dom.setAttribute("name", 'PowerPoints') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1085 # self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1086 # self.master_dom = handler.master_dom |
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 # self.sizer.AddMany([ (wx.StaticText(self, -1, "PP Current:"), 0, wx.ALIGN_CENTER_VERTICAL), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1089 # (wx.TextCtrl(self, PP_CUR, self.master_dom.getAttribute('current1')), 0, wx.EXPAND), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1090 # (wx.StaticText(self, -1, "PP Max:"), 0, wx.ALIGN_CENTER_VERTICAL), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1091 # (wx.TextCtrl(self, PP_MAX, self.master_dom.getAttribute('max1')), 0, wx.EXPAND), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1092 # (wx.StaticText(self, -1, "Current Free Talants per day:"), 0, wx.ALIGN_CENTER_VERTICAL), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1093 # (wx.TextCtrl(self, PP_FRE, self.master_dom.getAttribute('free')), 0, wx.EXPAND), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1094 # (wx.StaticText(self, -1, "Max Free Talants per day:"), 0, wx.ALIGN_CENTER_VERTICAL), |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1095 # (wx.TextCtrl(self, PP_MFRE, self.master_dom.getAttribute('maxfree')), 0, wx.EXPAND), |
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 # self.sizer.AddGrowableCol(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1098 # 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
|
1099 # self.Bind(wx.EVT_TEXT, self.on_text, id=PP_MAX) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1100 # self.Bind(wx.EVT_TEXT, self.on_text, id=PP_CUR) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1101 # self.Bind(wx.EVT_TEXT, self.on_text, id=PP_FRE) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1102 # self.Bind(wx.EVT_TEXT, self.on_text, id=PP_MFRE) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1103 # |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1104 # def on_text(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1105 # id = evt.GetId() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1106 # if id == PP_CUR: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1107 # self.master_dom.setAttribute('current1',evt.GetString()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1108 # elif id == PP_MAX: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1109 # self.master_dom.setAttribute('max1',evt.GetString()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1110 # elif id == PP_FRE: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1111 # self.master_dom.setAttribute('free',evt.GetString()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1112 # elif id == PP_MFRE: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1113 # self.master_dom.setAttribute('maxfree',evt.GetString()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1114 # |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1115 # def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1116 # s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1117 # 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
|
1118 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1119 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1120 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
|
1121 """grid for gen info""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1122 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1123 pname = handler.master_dom.setAttribute("name", 'General') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1124 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
|
1125 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
|
1126 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
|
1127 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1128 n_list = handler.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1129 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
|
1130 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1131 self.SetColLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1132 self.n_list = n_list |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1133 i = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1134 for i in range(len(n_list)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1135 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1136 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1137 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
|
1138 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1139 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1140 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1141 t_node = self.n_list[row]._get_firstChild() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1142 t_node._set_nodeValue(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1143 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
|
1144 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1145 def refresh_row(self,rowi): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1146 t_node = safe_get_text_node(self.n_list[rowi]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1147 self.SetCellValue(rowi,0,self.n_list[rowi]._get_tagName()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1148 self.SetReadOnly(rowi,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1149 self.SetCellValue(rowi,1,t_node._get_nodeValue()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1150 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1151 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1152 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1153 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1154 col_w = w/(cols) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1155 for i in range(0,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1156 self.SetColSize(i,col_w) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1157 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1158 self.Refresh() |
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 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
|
1161 """grid for gen info""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1162 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1163 pname = handler.master_dom.setAttribute("name", 'Money and Inventory') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1164 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
|
1165 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
|
1166 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
|
1167 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1168 n_list = handler.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1169 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
|
1170 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1171 self.SetColLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1172 self.n_list = n_list |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1173 i = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1174 for i in range(len(n_list)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1175 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1176 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1177 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
|
1178 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1179 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1180 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1181 t_node = self.n_list[row]._get_firstChild() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1182 t_node._set_nodeValue(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1183 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
|
1184 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1185 def refresh_row(self,rowi): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1186 t_node = safe_get_text_node(self.n_list[rowi]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1187 self.SetCellValue(rowi,0,self.n_list[rowi]._get_tagName()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1188 self.SetReadOnly(rowi,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1189 self.SetCellValue(rowi,1,t_node._get_nodeValue()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1190 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1191 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1192 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1193 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1194 col_w = w/(cols) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1195 for i in range(0,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1196 self.SetColSize(i,col_w) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1197 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1198 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1199 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1200 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
|
1201 """grid for abilities""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1202 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1203 pname = handler.master_dom.setAttribute("name", 'Stats') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1204 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
|
1205 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
|
1206 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
|
1207 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1208 stats = handler.master_dom.getElementsByTagName('stat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1209 self.CreateGrid(len(stats),3) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1210 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1211 col_names = ['Ability','Score','Modifier'] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1212 for i in range(len(col_names)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1213 self.SetColLabelValue(i,col_names[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1214 self.stats = stats |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1215 i = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1216 for i in range(len(stats)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1217 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1218 self.char_wnd = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1219 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1220 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
|
1221 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1222 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1223 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1224 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1225 int(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1226 self.stats[row].setAttribute('base',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1227 self.refresh_row(row) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1228 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1229 self.SetCellValue(row,col,"0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1230 if self.char_wnd: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1231 self.char_wnd.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1232 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1233 def refresh_row(self,rowi): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1234 s = self.stats[rowi] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1235 name = s.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1236 abbr = s.getAttribute('abbr') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1237 self.SetCellValue(rowi,0,name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1238 self.SetReadOnly(rowi,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1239 self.SetCellValue(rowi,1,s.getAttribute('base')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1240 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
|
1241 self.SetReadOnly(rowi,2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1242 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1243 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1244 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1245 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1246 col_w = w/(cols+2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1247 self.SetColSize(0,col_w*3) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1248 for i in range(1,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1249 self.SetColSize(i,col_w) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1250 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1251 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1252 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1253 def refresh_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1254 for r in range(self.GetNumberRows()-1): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1255 self.refresh_row(r) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1256 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1257 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1258 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
|
1259 """grid for saves""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1260 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1261 pname = handler.master_dom.setAttribute("name", 'Saves') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1262 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
|
1263 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
|
1264 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
|
1265 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1266 saves = handler.master_dom.getElementsByTagName('save') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1267 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
|
1268 self.CreateGrid(len(saves),7) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1269 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1270 col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1271 for i in range(len(col_names)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1272 self.SetColLabelValue(i,col_names[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1273 self.saves = saves |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1274 i = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1275 for i in range(len(saves)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1276 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1277 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1278 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
|
1279 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1280 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1281 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1282 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1283 int(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1284 if col == 2: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1285 self.saves[row].setAttribute('base',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1286 elif col ==4: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1287 self.saves[row].setAttribute('magmod',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1288 elif col ==4: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1289 self.saves[row].setAttribute('miscmod',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1290 self.refresh_row(row) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1291 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1292 self.SetCellValue(row,col,"0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1293 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1294 def refresh_row(self,rowi): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1295 s = self.saves[rowi] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1296 name = s.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1297 self.SetCellValue(rowi,0,name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1298 self.SetReadOnly(rowi,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1299 stat = s.getAttribute('stat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1300 self.SetCellValue(rowi,1,stat) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1301 self.SetReadOnly(rowi,1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1302 self.SetCellValue(rowi,2,s.getAttribute('base')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1303 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
|
1304 self.SetReadOnly(rowi,3) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1305 self.SetCellValue(rowi,4,s.getAttribute('magmod')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1306 self.SetCellValue(rowi,5,s.getAttribute('miscmod')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1307 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
|
1308 self.SetCellValue(rowi,6,mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1309 self.SetReadOnly(rowi,6) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1310 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1311 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1312 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1313 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1314 col_w = w/(cols+2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1315 self.SetColSize(0,col_w*3) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1316 for i in range(1,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1317 self.SetColSize(i,col_w) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1318 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1319 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1320 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1321 def refresh_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1322 for r in range(self.GetNumberRows()): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1323 self.refresh_row(r) |
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 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1326 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
|
1327 """ panel for skills """ |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1328 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1329 pname = handler.master_dom.setAttribute("name", 'Skills') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1330 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
|
1331 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
|
1332 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
|
1333 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1334 skills = handler.master_dom.getElementsByTagName('skill') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1335 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
|
1336 self.CreateGrid(len(skills),7) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1337 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1338 col_names = ['Skill','Key','Rank','Abil','Misc','Total'] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1339 for i in range(len(col_names)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1340 self.SetColLabelValue(i,col_names[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1341 rowi = 0 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1342 self.skills = skills |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1343 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
|
1344 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1345 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1346 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
|
1347 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1348 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1349 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1350 #print value |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1351 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1352 int(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1353 if col == 3: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1354 self.skills[row].setAttribute('rank',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1355 elif col ==5: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1356 self.skills[row].setAttribute('misc',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1357 elif col == 1: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1358 self.skills[row].setAttribute('untrained',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1359 self.refresh_row(row) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1360 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1361 self.SetCellValue(row,col,"0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1362 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1363 def refresh_row(self,rowi): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1364 s = self.skills[rowi] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1365 name = s.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1366 self.SetCellValue(rowi,0,name) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1367 self.SetReadOnly(rowi,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1368 self.SetCellValue(rowi,1,s.getAttribute('untrained')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1369 stat = s.getAttribute('stat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1370 self.SetCellValue(rowi,2,stat) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1371 self.SetReadOnly(rowi,2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1372 self.SetCellValue(rowi,3,s.getAttribute('rank')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1373 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
|
1374 self.SetReadOnly(rowi,4) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1375 self.SetCellValue(rowi,5,s.getAttribute('misc')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1376 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
|
1377 self.SetCellValue(rowi,6,mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1378 self.SetReadOnly(rowi,6) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1379 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1380 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1381 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1382 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1383 col_w = w/(cols+2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1384 self.SetColSize(0,col_w*3) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1385 for i in range(1,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1386 self.SetColSize(i,col_w) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1387 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1388 self.Refresh() |
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_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1391 for r in range(self.GetNumberRows()): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1392 self.refresh_row(r) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1393 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1394 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1395 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1396 class feat_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1397 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1398 pname = handler.master_dom.setAttribute("name", 'Feats') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1399 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
|
1400 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
|
1401 sizer = wx.BoxSizer(wx.HORIZONTAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1402 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
|
1403 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
|
1404 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
|
1405 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
|
1406 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
|
1407 self.sizer = sizer |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1408 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1409 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
|
1410 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
|
1411 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
|
1412 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1413 n_list = handler.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1414 self.n_list = n_list |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1415 self.master_dom = handler.master_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1416 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
|
1417 self.grid.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1418 self.grid.SetColLabelValue(0,"Feat") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1419 self.grid.SetColLabelValue(1,"Type") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1420 for i in range(len(n_list)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1421 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1422 self.temp_dom = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1423 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1424 def refresh_row(self,i): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1425 feat = self.n_list[i] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1426 name = feat.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1427 type = feat.getAttribute('type') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1428 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
|
1429 self.grid.SetReadOnly(i,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1430 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
|
1431 self.grid.SetReadOnly(i,1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1432 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1433 def on_remove(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1434 rows = self.grid.GetNumberRows() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1435 for i in range(rows): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1436 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
|
1437 self.grid.DeleteRows(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1438 self.master_dom.removeChild(self.n_list[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1439 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1440 def on_add(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1441 if not self.temp_dom: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1442 tmp = open(orpg.dirpath.dir_struct["SWd20"]+"d20feats.xml","r") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1443 xml_dom = parseXml_with_dlg(self,tmp.read()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1444 xml_dom = xml_dom._get_firstChild() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1445 tmp.close() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1446 self.temp_dom = xml_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1447 f_list = self.temp_dom.getElementsByTagName('feat') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1448 opts = [] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1449 for f in f_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1450 opts.append(f.getAttribute('name')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1451 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
|
1452 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
|
1453 i = dlg.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1454 new_node = self.master_dom.appendChild(f_list[i].cloneNode(False)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1455 self.grid.AppendRows(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1456 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
|
1457 dlg.Destroy() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1458 |
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.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
|
1463 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
|
1464 (w,h) = self.grid.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1465 cols = self.grid.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1466 col_w = w/(cols) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1467 for i in range(0,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1468 self.grid.SetColSize(i,col_w) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1469 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1470 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
|
1471 """grid for attacks""" |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1472 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1473 pname = handler.master_dom.setAttribute("name", 'Melee') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1474 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
|
1475 self.parent = parent |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1476 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1477 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
|
1478 self.CreateGrid(2,10) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1479 self.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1480 col_names = ['Type','base','base 2','base 3','base 4','base 5','base 6','abil','misc','Total'] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1481 for i in range(len(col_names)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1482 self.SetColLabelValue(i,col_names[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1483 self.SetCellValue(0,0,"Melee") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1484 self.SetCellValue(1,0,"Ranged") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1485 self.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1486 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
|
1487 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
|
1488 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1489 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
|
1490 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1491 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1492 value = self.GetCellValue(row,col) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1493 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1494 int(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1495 if col==1: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1496 self.rows[row].setAttribute('base',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1497 elif col==2: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1498 self.rows[row].setAttribute('second',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1499 elif col==3: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1500 self.rows[row].setAttribute('third',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1501 elif col==4: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1502 self.rows[row].setAttribute('forth',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1503 elif col==5: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1504 self.rows[row].setAttribute('fifth',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1505 elif col==6: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1506 self.rows[row].setAttribute('sixth',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1507 elif col==8: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1508 self.rows[row].setAttribute('misc',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1509 self.parent.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1510 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1511 self.SetCellValue(row,col,"0") |
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 refresh_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1514 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
|
1515 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
|
1516 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
|
1517 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
|
1518 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
|
1519 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
|
1520 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
|
1521 self.SetReadOnly(0,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1522 self.SetReadOnly(1,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1523 self.SetReadOnly(0,7) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1524 self.SetReadOnly(1,7) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1525 self.SetReadOnly(0,9) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1526 self.SetReadOnly(1,9) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1527 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1528 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1529 def on_size(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1530 (w,h) = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1531 cols = self.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1532 col_w = w/(cols+1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1533 self.SetColSize(0,col_w*2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1534 for i in range(1,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1535 self.SetColSize(i,col_w) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1536 evt.Skip() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1537 self.Refresh() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1538 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1539 class weapon_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1540 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1541 pname = handler.master_dom.setAttribute("name", 'Weapons') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1542 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
|
1543 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
|
1544 sizer = wx.BoxSizer(wx.HORIZONTAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1545 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
|
1546 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
|
1547 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
|
1548 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
|
1549 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
|
1550 self.sizer = sizer |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1551 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1552 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
|
1553 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
|
1554 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
|
1555 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
|
1556 n_list = handler.master_dom.getElementsByTagName('weapon') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1557 self.n_list = n_list |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1558 self.master_dom = handler.master_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1559 self.handler = handler |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1560 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
|
1561 self.grid.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1562 col_names = ['Name','damage','mod','critical','type','weight','range','size','Total'] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1563 for i in range(len(col_names)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1564 self.grid.SetColLabelValue(i,col_names[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1565 self.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1566 self.temp_dom = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1567 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1568 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
|
1569 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1570 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1571 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
|
1572 if col == 0: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1573 self.n_list[row].setAttribute('name',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1574 elif col == 2: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1575 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1576 int(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1577 self.n_list[row].setAttribute('mod',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1578 self.refresh_row(row) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1579 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1580 self.grid.SetCellValue(row,col,"1") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1581 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1582 self.n_list[row].setAttribute(self.grid.GetColLabelValue(col),value) |
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] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1586 name = n.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1587 mod = n.getAttribute('mod') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1588 ran = n.getAttribute('range') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1589 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
|
1590 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
|
1591 self.grid.SetCellValue(i,1,n.getAttribute('damage')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1592 self.grid.SetCellValue(i,2,mod) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1593 self.grid.SetCellValue(i,3,n.getAttribute('critical')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1594 self.grid.SetCellValue(i,4,n.getAttribute('type')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1595 self.grid.SetCellValue(i,5,n.getAttribute('weight')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1596 self.grid.SetCellValue(i,6,ran) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1597 self.grid.SetCellValue(i,7,n.getAttribute('size') ) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1598 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
|
1599 self.grid.SetReadOnly(i,8) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1600 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1601 def on_remove(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1602 rows = self.grid.GetNumberRows() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1603 for i in range(rows): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1604 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
|
1605 self.grid.DeleteRows(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1606 self.master_dom.removeChild(self.n_list[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1607 self.n_list = self.master_dom.getElementsByTagName('weapon') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1608 self.handler.refresh_weapons() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1609 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1610 def on_add(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1611 if not self.temp_dom: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1612 tmp = open(orpg.dirpath.dir_struct["SWd20"]+"d20weapons.xml","r") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1613 xml_dom = parseXml_with_dlg(self,tmp.read()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1614 xml_dom = xml_dom._get_firstChild() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1615 tmp.close() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1616 self.temp_dom = xml_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1617 f_list = self.temp_dom.getElementsByTagName('weapon') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1618 opts = [] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1619 for f in f_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1620 opts.append(f.getAttribute('name')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1621 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
|
1622 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
|
1623 i = dlg.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1624 new_node = self.master_dom.appendChild(f_list[i].cloneNode(False)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1625 self.grid.AppendRows(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1626 self.n_list = self.master_dom.getElementsByTagName('weapon') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1627 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
|
1628 self.handler.refresh_weapons() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1629 dlg.Destroy() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1630 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1631 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1632 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1633 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
|
1634 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
|
1635 (w,h) = self.grid.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1636 cols = self.grid.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1637 col_w = w/(cols+1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1638 self.grid.SetColSize(0,col_w*2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1639 for i in range(1,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1640 self.grid.SetColSize(i,col_w) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1641 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1642 def refresh_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1643 for i in range(len(self.n_list)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1644 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1645 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1646 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1647 class attack_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1648 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1649 pname = handler.master_dom.setAttribute("name", 'Melee') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1650 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
|
1651 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1652 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
|
1653 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
|
1654 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
|
1655 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
|
1656 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
|
1657 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1658 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
|
1659 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1660 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1661 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1662 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
|
1663 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1664 def refresh_data(self): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1665 self.w_panel.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1666 self.a_grid.refresh_data() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1667 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1668 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1669 class ac_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1670 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1671 pname = handler.master_dom.setAttribute("name", 'Armor') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1672 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
|
1673 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
|
1674 sizer = wx.BoxSizer(wx.HORIZONTAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1675 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
|
1676 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
|
1677 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
|
1678 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
|
1679 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
|
1680 self.sizer = sizer |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1681 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1682 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
|
1683 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
|
1684 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
|
1685 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
|
1686 self.master_dom = handler.master_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1687 n_list = handler.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1688 self.n_list = n_list |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1689 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
|
1690 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
|
1691 self.grid.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1692 for i in range(len(col_names)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1693 self.grid.SetColLabelValue(i,col_names[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1694 self.atts =['name','bonus','maxdex','checkpenalty','weight','speed','speed6','type'] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1695 for i in range(len(n_list)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1696 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1697 self.temp_dom = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1698 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1699 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1700 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
|
1701 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1702 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1703 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
|
1704 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
|
1705 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1706 int(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1707 self.n_list[row].setAttribute(self.atts[col],value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1708 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1709 self.grid.SetCellValue(row,col,"0") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1710 else: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1711 self.n_list[row].setAttribute(self.atts[col],value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1712 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1713 def refresh_row(self,i): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1714 n = self.n_list[i] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1715 for y in range(len(self.atts)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1716 self.grid.SetCellValue(i,y,n.getAttribute(self.atts[y])) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1717 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1718 def on_remove(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1719 rows = self.grid.GetNumberRows() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1720 for i in range(rows): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1721 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
|
1722 self.grid.DeleteRows(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1723 self.master_dom.removeChild(self.n_list[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1724 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1725 def on_add(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1726 if not self.temp_dom: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1727 tmp = open(orpg.dirpath.dir_struct["SWd20"]+"d20armor.xml","r") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1728 xml_dom = parseXml_with_dlg(self,tmp.read()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1729 xml_dom = xml_dom._get_firstChild() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1730 tmp.close() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1731 self.temp_dom = xml_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1732 f_list = self.temp_dom.getElementsByTagName('armor') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1733 opts = [] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1734 for f in f_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1735 opts.append(f.getAttribute('name')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1736 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
|
1737 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
|
1738 i = dlg.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1739 new_node = self.master_dom.appendChild(f_list[i].cloneNode(False)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1740 self.grid.AppendRows(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1741 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
|
1742 dlg.Destroy() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1743 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1744 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1745 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1746 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
|
1747 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
|
1748 (w,h) = self.grid.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1749 cols = self.grid.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1750 col_w = w/(cols+2) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1751 self.grid.SetColSize(0,col_w*3) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1752 for i in range(1,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1753 self.grid.SetColSize(i,col_w) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1754 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1755 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1756 class class_panel(wx.Panel): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1757 def __init__(self, parent, handler): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1758 pname = handler.master_dom.setAttribute("name", 'Class') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1759 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
|
1760 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
|
1761 sizer = wx.BoxSizer(wx.HORIZONTAL) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1762 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
|
1763 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
|
1764 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
|
1765 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
|
1766 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
|
1767 self.sizer = sizer |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1768 self.SetSizer(self.sizer) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1769 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
|
1770 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
|
1771 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
|
1772 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
|
1773 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1774 n_list = handler.master_dom._get_childNodes() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1775 self.n_list = n_list |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1776 self.master_dom = handler.master_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1777 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
|
1778 self.grid.SetRowLabelSize(0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1779 self.grid.SetColLabelValue(0,"Class") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1780 self.grid.SetColLabelValue(1,"Level") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1781 for i in range(len(n_list)): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1782 self.refresh_row(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1783 self.temp_dom = None |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1784 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1785 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
|
1786 row = evt.GetRow() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1787 col = evt.GetCol() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1788 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
|
1789 try: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1790 int(value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1791 self.n_list[row].setAttribute('level',value) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1792 except: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1793 self.grid.SetCellValue(row,col,"1") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1794 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1795 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1796 def refresh_row(self,i): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1797 n = self.n_list[i] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1798 name = n.getAttribute('name') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1799 level = n.getAttribute('level') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1800 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
|
1801 self.grid.SetReadOnly(i,0) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1802 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
|
1803 #self.grid.SetReadOnly(i,1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1804 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1805 def on_remove(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1806 rows = self.grid.GetNumberRows() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1807 for i in range(rows): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1808 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
|
1809 self.grid.DeleteRows(i) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1810 self.master_dom.removeChild(self.n_list[i]) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1811 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1812 def on_add(self,evt): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1813 if not self.temp_dom: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1814 tmp = open(orpg.dirpath.dir_struct["SWd20"]+"SWd20classes.xml","r") |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1815 xml_dom = parseXml_with_dlg(self,tmp.read()) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1816 xml_dom = xml_dom._get_firstChild() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1817 tmp.close() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1818 self.temp_dom = xml_dom |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1819 f_list = self.temp_dom.getElementsByTagName('class') |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1820 opts = [] |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1821 for f in f_list: |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1822 opts.append(f.getAttribute('name')) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1823 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
|
1824 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
|
1825 i = dlg.GetSelection() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1826 new_node = self.master_dom.appendChild(f_list[i].cloneNode(False)) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1827 self.grid.AppendRows(1) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1828 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
|
1829 dlg.Destroy() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1830 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1831 |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1832 def on_size(self,event): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1833 s = self.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1834 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
|
1835 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
|
1836 (w,h) = self.grid.GetClientSizeTuple() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1837 cols = self.grid.GetNumberCols() |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1838 col_w = w/(cols) |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1839 for i in range(0,cols): |
3b2cfa13b610
Fix to toolbar menus. More correct fix so docking is working on Ubuntu
sirebral
parents:
0
diff
changeset
|
1840 self.grid.SetColSize(i,col_w) |