Mercurial > traipse_dev
comparison orpg/gametree/nodehandlers/d20.py @ 152:6081bdc2b8d5 beta
Traipse Beta 'OpenRPG' {091125-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go.
Traipse also makes it easy for developers to work on code without fear of
sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the
code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the
productivity of the user.
Update Summary (Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
Pretty important update that can help remove thousands of dead children from your
gametree.
Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height
/>, etc... are all tags now. Check your gametree and look for dead children!!
New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops
return error instead of freezing the software!
New Syntax added for custom PC sheets
Tip of the Day added, from Core and community
Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to
prevent non updated clients from ruining the fix.
author | sirebral |
---|---|
date | Wed, 25 Nov 2009 06:16:35 -0600 |
parents | dcf4fbe09b70 |
children | 3b6888bb53b5 |
comparison
equal
deleted
inserted
replaced
150:6c5f46a5924b | 152:6081bdc2b8d5 |
---|---|
27 # | 27 # |
28 | 28 |
29 __version__ = "$Id: d20.py,v 1.30 2007/05/22 00:50:57 digitalxero Exp $" | 29 __version__ = "$Id: d20.py,v 1.30 2007/05/22 00:50:57 digitalxero Exp $" |
30 | 30 |
31 from core import * | 31 from core import * |
32 from containers import * | |
32 import re | 33 import re |
33 from xml.etree.ElementTree import ElementTree, Element, iselement | 34 from xml.etree.ElementTree import ElementTree, Element, iselement |
34 from xml.etree.ElementTree import fromstring, tostring, parse, XML | 35 from xml.etree.ElementTree import fromstring, tostring, parse, XML |
35 from orpg.tools.orpg_log import debug | 36 from orpg.tools.orpg_log import debug |
36 | 37 |
52 def load_children(self): | 53 def load_children(self): |
53 children = self.xml.getchildren() | 54 children = self.xml.getchildren() |
54 for c in children: | 55 for c in children: |
55 self.tree.load_xml(c,self.mytree_node) | 56 self.tree.load_xml(c,self.mytree_node) |
56 | 57 |
57 | |
58 def on_drop(self,evt): | 58 def on_drop(self,evt): |
59 drag_obj = self.tree.drag_obj | 59 drag_obj = self.tree.drag_obj |
60 #if self.is_my_child(self.mytree_node,drag_obj.mytree_node): | 60 if drag_obj == self: return |
61 # return | |
62 if drag_obj == self: | |
63 return | |
64 opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL) | 61 opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL) |
65 if opt == wx.YES: | 62 if opt == wx.YES: |
66 xml = self.tree.drag_obj.delete() | 63 xml = self.tree.drag_obj.delete() |
67 xml = self.xml.append(xml,None) | 64 xml = self.xml.append(xml,None) |
68 self.tree.load_xml(xml, self.mytree_node) | 65 self.tree.load_xml(xml, self.mytree_node) |
69 self.tree.Expand(self.mytree_node) | 66 self.tree.Expand(self.mytree_node) |
70 elif opt == wx.NO: | 67 elif opt == wx.NO: node_handler.on_drop(self,evt) |
71 node_handler.on_drop(self,evt) | |
72 | 68 |
73 def tohtml(self): | 69 def tohtml(self): |
74 cookie = 0 | 70 cookie = 0 |
75 html_str = "<table border=\"1\" ><tr><td>" | 71 html_str = "<table border=\"1\" ><tr><td>" |
76 html_str += "<b>"+self.xml.get("name") + "</b>" | 72 html_str += "<b>"+self.xml.get("name") + "</b>" |
77 html_str += "</td></tr>\n" | 73 html_str += "</td></tr>\n" |
78 html_str += "<tr><td>" | 74 html_str += "<tr><td>" |
79 | |
80 max = tree.GetChildrenCount(handler.mytree_node,0) | 75 max = tree.GetChildrenCount(handler.mytree_node,0) |
81 try: | 76 try: (child,cookie)=self.tree.GetFirstChild(self.mytree_node,cookie) |
82 (child,cookie)=self.tree.GetFirstChild(self.mytree_node,cookie) | 77 # If this happens we probably have a newer version of wxPython |
83 except: # If this happens we probably have a newer version of wxPython | 78 except: (child,cookie)=self.tree.GetFirstChild(self.mytree_node) |
84 (child,cookie)=self.tree.GetFirstChild(self.mytree_node) | |
85 obj = self.tree.GetPyData(child) | 79 obj = self.tree.GetPyData(child) |
86 for m in range(max): | 80 for m in range(max): |
87 html_str += "<p>" + obj.tohtml() | 81 html_str += "<p>" + obj.tohtml() |
88 if m < max-1: | 82 if m < max-1: |
89 child = self.tree.GetNextSibling(child) | 83 child = self.tree.GetNextSibling(child) |
90 if child.IsOk(): | 84 if child.IsOk(): obj = self.tree.GetPyData(child) |
91 obj = self.tree.GetPyData(child) | |
92 html_str += "</td></tr></table>" | 85 html_str += "</td></tr></table>" |
93 return html_str | 86 return html_str |
94 | 87 |
95 def get_size_constraint(self): | 88 def get_size_constraint(self): |
96 return 1 | 89 return 1 |
104 def get_char_pp( self, attr ): | 97 def get_char_pp( self, attr ): |
105 return self.child_handlers['pp'].get_char_pp(attr) | 98 return self.child_handlers['pp'].get_char_pp(attr) |
106 | 99 |
107 def get_char_lvl( self, attr ): | 100 def get_char_lvl( self, attr ): |
108 return self.child_handlers['classes'].get_char_lvl(attr) | 101 return self.child_handlers['classes'].get_char_lvl(attr) |
109 | |
110 | 102 |
111 | 103 |
112 class d20char_handler(node_handler): | 104 class d20char_handler(node_handler): |
113 """ Node handler for a d20 charactor | 105 """ Node handler for a d20 charactor |
114 <nodehandler name='?' module='d20' class='d20char_handler2' /> | 106 <nodehandler name='?' module='d20' class='d20char_handler2' /> |
130 self.new_child_handler('powers','Powers',d20powers,'questionhead') | 122 self.new_child_handler('powers','Powers',d20powers,'questionhead') |
131 self.new_child_handler('hp','Hit Points',d20hp,'gear') | 123 self.new_child_handler('hp','Hit Points',d20hp,'gear') |
132 self.new_child_handler('pp','Power Points',d20pp,'gear') | 124 self.new_child_handler('pp','Power Points',d20pp,'gear') |
133 self.new_child_handler('attacks','Attacks',d20attacks,'spears') | 125 self.new_child_handler('attacks','Attacks',d20attacks,'spears') |
134 self.new_child_handler('ac','Armor',d20armor,'spears') | 126 self.new_child_handler('ac','Armor',d20armor,'spears') |
135 #wxMenuItem(self.tree.std_menu, D20_EXPORT, "Export...", "Export") | |
136 self.myeditor = None | 127 self.myeditor = None |
137 | |
138 | 128 |
139 def on_version(self,old_version): | 129 def on_version(self,old_version): |
140 node_handler.on_version(self,old_version) | 130 node_handler.on_version(self,old_version) |
141 if old_version == "": | 131 if old_version == "": |
142 data = parse(orpg.dirpath.dir_struct["nodes"]+"d20character.xml").getroot() | 132 data = parse(orpg.dirpath.dir_struct["nodes"]+"d20character.xml").getroot() |
157 range_attack.set("fifth","0") | 147 range_attack.set("fifth","0") |
158 range_attack.set("sixth","0") | 148 range_attack.set("sixth","0") |
159 | 149 |
160 gen_list = self.xml.find('general') | 150 gen_list = self.xml.find('general') |
161 | 151 |
162 for tag in ("currentxp","xptolevel"): | 152 for tag in ("currentxp","xptolevel"): gen_list.append(data.find(tag)) |
163 gen_list.append(data.find(tag)) | |
164 ## temp fix | |
165 #parent = self.xml._get_parentNode() | |
166 #old_dom = parent.replaceChild(xml,self.xml) | |
167 #self.xml = xml | |
168 print old_version | 153 print old_version |
169 | 154 |
170 | 155 |
171 def get_char_name( self ): | 156 def get_char_name( self ): |
172 return self.child_handlers['general'].get_char_name() | 157 return self.child_handlers['general'].get_char_name() |
177 def get_char_pp( self, attr ): | 162 def get_char_pp( self, attr ): |
178 return self.child_handlers['pp'].get_char_pp(attr) | 163 return self.child_handlers['pp'].get_char_pp(attr) |
179 | 164 |
180 def get_char_lvl( self, attr ): | 165 def get_char_lvl( self, attr ): |
181 return self.child_handlers['classes'].get_char_lvl(attr) | 166 return self.child_handlers['classes'].get_char_lvl(attr) |
182 | |
183 | 167 |
184 def new_child_handler(self,tag,text,handler_class,icon='gear'): | 168 def new_child_handler(self,tag,text,handler_class,icon='gear'): |
185 tree = self.tree | 169 tree = self.tree |
186 i = self.tree.icons[icon] | 170 i = self.tree.icons[icon] |
187 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i) | 171 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i) |
190 self.child_handlers[tag] = handler | 174 self.child_handlers[tag] = handler |
191 | 175 |
192 def get_design_panel(self,parent): | 176 def get_design_panel(self,parent): |
193 return tabbed_panel(parent,self,1) | 177 return tabbed_panel(parent,self,1) |
194 | 178 |
195 | |
196 def get_use_panel(self,parent): | 179 def get_use_panel(self,parent): |
197 return tabbed_panel(parent,self,2) | 180 return tabbed_panel(parent,self,2) |
198 | |
199 | 181 |
200 def tohtml(self): | 182 def tohtml(self): |
201 html_str = "<table><tr><td colspan=2 >"+self.child_handlers['general'].tohtml()+"</td></tr>" | 183 html_str = "<table><tr><td colspan=2 >"+self.child_handlers['general'].tohtml()+"</td></tr>" |
202 html_str += "<tr><td width='50%' valign=top >"+self.child_handlers['abilities'].tohtml() | 184 html_str += "<tr><td width='50%' valign=top >"+self.child_handlers['abilities'].tohtml() |
203 html_str += "<P>" + self.child_handlers['saves'].tohtml() | 185 html_str += "<P>" + self.child_handlers['saves'].tohtml() |
214 html_str += "<P>" + self.child_handlers['skills'].tohtml() +"</td>" | 196 html_str += "<P>" + self.child_handlers['skills'].tohtml() +"</td>" |
215 html_str += "</tr></table>" | 197 html_str += "</tr></table>" |
216 return html_str | 198 return html_str |
217 | 199 |
218 def about(self): | 200 def about(self): |
219 html_str = "<img src='" + orpg.dirpath.dir_struct["icon"]+'d20_logo.gif' "><br /><b>d20 Character Tool v0.7 beta</b>" | 201 """html_str = "<img src='" + orpg.dirpath.dir_struct["icon"]+'d20_logo.gif' "><br /><b>d20 Character Tool v0.7 beta</b>" |
220 html_str += "<br />by Chris Davis<br />chris@rpgarchive.com" | 202 html_str += "<br />by Chris Davis<br />chris@rpgarchive.com" |
221 return html_str | 203 return html_str""" |
204 text = 'd20 Character Tool 0.7 beta\n' | |
205 text += 'by Chris Davis chris@rpgarchive.com' | |
206 return text | |
222 | 207 |
223 def get_char_name( self ): | 208 def get_char_name( self ): |
224 return self.child_handlers['general'].get_char_name() | 209 return self.child_handlers['general'].get_char_name() |
225 def get_armor_class( self ): | 210 def get_armor_class( self ): |
226 return self.child_handlers['ac'].get_armor_class() | 211 return self.child_handlers['ac'].get_armor_class() |
236 return self.child_handlers['pp'].get_char_pp(attr) | 221 return self.child_handlers['pp'].get_char_pp(attr) |
237 | 222 |
238 def get_char_lvl( self, attr ): | 223 def get_char_lvl( self, attr ): |
239 return self.child_handlers['classes'].get_char_lvl(attr) | 224 return self.child_handlers['classes'].get_char_lvl(attr) |
240 | 225 |
226 """ Removed to use the supplied Tabbed Panel | |
241 class tabbed_panel(wx.Notebook): | 227 class tabbed_panel(wx.Notebook): |
242 def __init__(self, parent, handler, mode): | 228 def __init__(self, parent, handler, mode): |
243 wx.Notebook.__init__(self, parent, -1, size=(1200,800)) | 229 wx.Notebook.__init__(self, parent, -1, size=(1200,800)) |
244 self.handler = handler | 230 self.handler = handler |
245 self.parent = parent | 231 self.parent = parent |
246 tree = self.handler.tree | 232 tree = self.handler.tree |
247 max = tree.GetChildrenCount(handler.mytree_node) | 233 max = tree.GetChildrenCount(handler.mytree_node) |
248 | |
249 cookie = 0 | 234 cookie = 0 |
250 | 235 |
251 try: | 236 try: (child,cookie)=tree.GetFirstChild(handler.mytree_node,cookie) |
252 (child,cookie)=tree.GetFirstChild(handler.mytree_node,cookie) | 237 # If this happens we probably have a newer version of wxPython |
253 except: # If this happens we probably have a newer version of wxPython | 238 except: (child,cookie)=tree.GetFirstChild(handler.mytree_node) |
254 (child,cookie)=tree.GetFirstChild(handler.mytree_node) | 239 if not child.IsOk(): return |
255 if not child.IsOk(): | |
256 return | |
257 obj = tree.GetPyData(child) | 240 obj = tree.GetPyData(child) |
258 for m in range(max): | 241 for m in range(max): |
259 if mode == 1: | 242 if mode == 1: panel = obj.get_design_panel(self) |
260 panel = obj.get_design_panel(self) | 243 else: panel = obj.get_use_panel(self) |
261 else: | |
262 panel = obj.get_use_panel(self) | |
263 name = obj.xml.get("name") | 244 name = obj.xml.get("name") |
264 | 245 if panel: self.AddPage(panel,name) |
265 if panel: | |
266 self.AddPage(panel,name) | |
267 if m < max-1: | 246 if m < max-1: |
268 child = tree.GetNextSibling(child) | 247 child = tree.GetNextSibling(child) |
269 if child.IsOk(): | 248 if child.IsOk(): obj = tree.GetPyData(child) |
270 obj = tree.GetPyData(child) | 249 else: break |
271 else: | |
272 break | |
273 | |
274 | 250 |
275 def about(self): | 251 def about(self): |
276 html_str = "<img src='" + orpg.dirpath.dir_struct["icon"]+'d20_logo.gif' "><br /><b>d20 Character Tool v0.7 beta</b>" | 252 html_str = "<img src='" + orpg.dirpath.dir_struct["icon"]+'d20_logo.gif' "><br /><b>d20 Character Tool v0.7 beta</b>" |
277 html_str += "<br />by Chris Davis<br />chris@rpgarchive.com" | 253 html_str += "<br />by Chris Davis<br />chris@rpgarchive.com" |
278 return html_str | 254 return html_str |
286 def get_char_pp( self, attr ): | 262 def get_char_pp( self, attr ): |
287 return self.child_handlers['pp'].get_char_pp(attr) | 263 return self.child_handlers['pp'].get_char_pp(attr) |
288 | 264 |
289 def get_char_lvl( self, attr ): | 265 def get_char_lvl( self, attr ): |
290 return self.child_handlers['classes'].get_char_lvl(attr) | 266 return self.child_handlers['classes'].get_char_lvl(attr) |
291 | 267 """ |
292 class d20_char_child(node_handler): | 268 class d20_char_child(node_handler): |
293 """ Node Handler for skill. This handler will be | 269 """ Node Handler for skill. This handler will be |
294 created by d20char_handler. | 270 created by d20char_handler. |
295 """ | 271 """ |
296 def __init__(self,xml,tree_node,parent): | 272 def __init__(self,xml,tree_node,parent): |
367 return total | 343 return total |
368 | 344 |
369 def on_rclick(self,evt): | 345 def on_rclick(self,evt): |
370 item = self.tree.GetSelection() | 346 item = self.tree.GetSelection() |
371 name = self.tree.GetItemText(item) | 347 name = self.tree.GetItemText(item) |
372 if item == self.mytree_node: | 348 if item == self.mytree_node: d20_char_child.on_ldclick(self,evt) |
373 d20_char_child.on_ldclick(self,evt) | |
374 #wnd = skill_grid(self.frame.note,self) | |
375 #wnd.title = "Skills | |
376 #self.frame.add_panel(wnd) | |
377 else: | 349 else: |
378 skill = self.skills[name]; | 350 skill = self.skills[name]; |
379 untrained = skill.get('untrained'); | 351 untrained = skill.get('untrained'); |
380 rank = skill.get('rank'); | 352 rank = skill.get('rank'); |
381 if untrained == "0" and rank == "0": | 353 if untrained == "0" and rank == "0": txt = '%s Skill Check: Untrained' % (name) |
382 txt = '%s Skill Check: Untrained' % (name) | |
383 else: | 354 else: |
384 mod = self.get_mod(name) | 355 mod = self.get_mod(name) |
385 if mod >= 0: | 356 if mod >= 0: mod1 = "+" |
386 mod1 = "+" | 357 else: mod1 = "" |
387 else: | |
388 mod1 = "" | |
389 txt = '%s Skill Check: [1d20%s%s]' % (name, mod1, mod) | 358 txt = '%s Skill Check: [1d20%s%s]' % (name, mod1, mod) |
390 chat = self.chat | 359 chat = self.chat |
391 chat.ParsePost(txt,True,True) | 360 chat.ParsePost(txt,True,True) |
392 | 361 |
393 def get_design_panel(self,parent): | 362 def get_design_panel(self,parent): |
404 rank = n.get('rank') | 373 rank = n.get('rank') |
405 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+rank+"</td>" | 374 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+rank+"</td>" |
406 stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) | 375 stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) |
407 misc = n.get('misc') | 376 misc = n.get('misc') |
408 mod = str(self.get_mod(name)) | 377 mod = str(self.get_mod(name)) |
409 if mod >= 0: | 378 if mod >= 0: mod1 = "+" |
410 mod1 = "+" | 379 else: mod1 = "" |
411 else: | |
412 mod1 = "" | |
413 html_str = html_str + "<td>"+stat_mod+"</td><td>"+misc+'</td><td>%s%s</td></tr>' % (mod1, mod) | 380 html_str = html_str + "<td>"+stat_mod+"</td><td>"+misc+'</td><td>%s%s</td></tr>' % (mod1, mod) |
414 html_str = html_str + "</table>" | 381 html_str = html_str + "</table>" |
415 return html_str | 382 return html_str |
416 | 383 |
417 | 384 |
435 name = self.tree.GetItemText( item ) | 402 name = self.tree.GetItemText( item ) |
436 if item == self.mytree_node: | 403 if item == self.mytree_node: |
437 d20_char_child.on_ldclick( self, evt ) | 404 d20_char_child.on_ldclick( self, evt ) |
438 else: | 405 else: |
439 mod = self.get_mod( name ) | 406 mod = self.get_mod( name ) |
440 if mod >= 0: | 407 if mod >= 0: mod1 = "+" |
441 mod1 = "+" | 408 else: mod1 = "" |
442 else: | |
443 mod1 = "" | |
444 chat = self.chat | 409 chat = self.chat |
445 txt = '%s check: [1d20%s%s]' % ( name, mod1, mod ) | 410 txt = '%s check: [1d20%s%s]' % ( name, mod1, mod ) |
446 chat.ParsePost( txt, True, True ) | 411 chat.ParsePost( txt, True, True ) |
447 | 412 |
448 def get_mod(self,abbr): | 413 def get_mod(self,abbr): |
465 for n in self.xml.findall('stat'): | 430 for n in self.xml.findall('stat'): |
466 name = n.get('name') | 431 name = n.get('name') |
467 abbr = n.get('abbr') | 432 abbr = n.get('abbr') |
468 base = n.get('base') | 433 base = n.get('base') |
469 mod = str(self.get_mod(abbr)) | 434 mod = str(self.get_mod(abbr)) |
470 if mod >= 0: | 435 if mod >= 0: mod1 = "+" |
471 mod1 = "+" | 436 else: mod1 = "" |
472 else: | |
473 mod1 = "" | |
474 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+base+'</td><td>%s%s</td></tr>' % (mod1, mod) | 437 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+base+'</td><td>%s%s</td></tr>' % (mod1, mod) |
475 html_str = html_str + "</table>" | 438 html_str = html_str + "</table>" |
476 return html_str | 439 return html_str |
477 | 440 |
478 | 441 |
504 def on_rclick(self,evt): | 467 def on_rclick(self,evt): |
505 item = self.tree.GetSelection() | 468 item = self.tree.GetSelection() |
506 name = self.tree.GetItemText(item) | 469 name = self.tree.GetItemText(item) |
507 if item == self.mytree_node: | 470 if item == self.mytree_node: |
508 d20_char_child.on_ldclick(self,evt) | 471 d20_char_child.on_ldclick(self,evt) |
509 #wnd = save_grid(self.frame.note,self) | 472 |
510 #wnd.title = "Saves" | |
511 #self.frame.add_panel(wnd) | |
512 else: | 473 else: |
513 mod = self.get_mod(name) | 474 mod = self.get_mod(name) |
514 if mod >= 0: | 475 if mod >= 0: mod1 = "+" |
515 mod1 = "+" | 476 else: mod1 = "" |
516 else: | |
517 mod1 = "" | |
518 chat = self.chat | 477 chat = self.chat |
519 txt = '%s save: [1d20%s%s]' % (name, mod1, mod) | 478 txt = '%s save: [1d20%s%s]' % (name, mod1, mod) |
520 chat.ParsePost( txt, True, True ) | 479 chat.ParsePost( txt, True, True ) |
521 | 480 |
522 def get_design_panel(self,parent): | 481 def get_design_panel(self,parent): |
535 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+base+"</td>" | 494 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+base+"</td>" |
536 stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) | 495 stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) |
537 mag = n.get('magmod') | 496 mag = n.get('magmod') |
538 misc = n.get('miscmod') | 497 misc = n.get('miscmod') |
539 mod = str(self.get_mod(name)) | 498 mod = str(self.get_mod(name)) |
540 if mod >= 0: | 499 if mod >= 0: mod1 = "+" |
541 mod1 = "+" | 500 else: mod1 = "" |
542 else: | |
543 mod1 = "" | |
544 html_str = html_str + "<td>"+stat_mod+"</td><td>"+mag+"</td>" | 501 html_str = html_str + "<td>"+stat_mod+"</td><td>"+mag+"</td>" |
545 html_str = html_str + '<td>'+misc+'</td><td>%s%s</td></tr>' % (mod1, mod) | 502 html_str = html_str + '<td>'+misc+'</td><td>%s%s</td></tr>' % (mod1, mod) |
546 html_str = html_str + "</table>" | 503 html_str = html_str + "</table>" |
547 return html_str | 504 return html_str |
548 | 505 |
586 wnd.title = "Classes" | 543 wnd.title = "Classes" |
587 return wnd | 544 return wnd |
588 | 545 |
589 def tohtml(self): | 546 def tohtml(self): |
590 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Classes</th></tr><tr><td>" | 547 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Classes</th></tr><tr><td>" |
591 for n in self.xml: | 548 for n in self.xml: html_str += n.get('name') + " ("+n.get('level')+"), " |
592 html_str += n.get('name') + " ("+n.get('level')+"), " | |
593 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" | 549 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
594 return html_str | 550 return html_str |
595 | 551 |
596 def get_char_lvl( self, attr ): | 552 def get_char_lvl( self, attr ): |
597 for n in self.xml.findall('class'): | 553 for n in self.xml.findall('class'): |
598 lvl = n.get('level') | 554 lvl = n.get('level') |
599 type = n.get('name') | 555 type = n.get('name') |
600 if attr == "level": | 556 if attr == "level": return lvl |
601 return lvl | 557 elif attr == "class": return type |
602 elif attr == "class": | |
603 return type | |
604 | 558 |
605 | 559 |
606 class d20feats(d20_char_child): | 560 class d20feats(d20_char_child): |
607 """ Node Handler for classes. This handler will be | 561 """ Node Handler for classes. This handler will be |
608 created by d20char_handler. | 562 created by d20char_handler. |
615 wnd.title = "Feats" | 569 wnd.title = "Feats" |
616 return wnd | 570 return wnd |
617 | 571 |
618 def tohtml(self): | 572 def tohtml(self): |
619 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Feats</th></tr><tr><td>" | 573 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Feats</th></tr><tr><td>" |
620 for n in self.xml: | 574 for n in self.xml: html_str += n.get('name')+ ", " |
621 html_str += n.get('name')+ ", " | |
622 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" | 575 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
623 return html_str | 576 return html_str |
624 | 577 |
625 | 578 |
626 class d20spells(d20_char_child): | 579 class d20spells(d20_char_child): |
656 self.chat.ParsePost( txt, True, False ) | 609 self.chat.ParsePost( txt, True, False ) |
657 else: | 610 else: |
658 txt = '%s casts %s ( level %s, "%s" )' % ( cname, name, level, descr ) | 611 txt = '%s casts %s ( level %s, "%s" )' % ( cname, name, level, descr ) |
659 self.chat.ParsePost( txt, True, False ) | 612 self.chat.ParsePost( txt, True, False ) |
660 s = '' | 613 s = '' |
661 if left != 1: | 614 if left != 1: s = 's' |
662 s = 's' | |
663 txt = '%s can cast %s %d more time%s' % ( cname, name, left, s ) | 615 txt = '%s can cast %s %d more time%s' % ( cname, name, left, s ) |
664 self.chat.ParsePost( txt, False, False ) | 616 self.chat.ParsePost( txt, False, False ) |
665 self.spells[ name ].set( 'used', `eval( use )` ) | 617 self.spells[ name ].set( 'used', `eval( use )` ) |
666 | 618 |
667 def refresh_spells(self): | 619 def refresh_spells(self): |
680 wnd.title = "Spells" | 632 wnd.title = "Spells" |
681 return wnd | 633 return wnd |
682 | 634 |
683 def tohtml(self): | 635 def tohtml(self): |
684 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Arcane Spells</th></tr><tr><td><br />" | 636 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Arcane Spells</th></tr><tr><td><br />" |
685 for n in self.xml: | 637 for n in self.xml: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " |
686 html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " | |
687 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" | 638 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
688 return html_str | 639 return html_str |
689 | 640 |
690 def get_char_lvl( self, attr ): | 641 def get_char_lvl( self, attr ): |
691 return self.char_hander.get_char_lvl(attr) | 642 return self.char_hander.get_char_lvl(attr) |
723 self.chat.ParsePost( txt, True, False ) | 674 self.chat.ParsePost( txt, True, False ) |
724 else: | 675 else: |
725 txt = '%s casts %s ( level %s, "%s" )' % ( cname, name, level, descr ) | 676 txt = '%s casts %s ( level %s, "%s" )' % ( cname, name, level, descr ) |
726 self.chat.ParsePost( txt, True, False ) | 677 self.chat.ParsePost( txt, True, False ) |
727 s = '' | 678 s = '' |
728 if left != 1: | 679 if left != 1: s = 's' |
729 s = 's' | |
730 txt = '%s can cast %s %d more time%s' % ( cname, name, left, s ) | 680 txt = '%s can cast %s %d more time%s' % ( cname, name, left, s ) |
731 self.chat.ParsePost( txt, False, False ) | 681 self.chat.ParsePost( txt, False, False ) |
732 self.spells[ name ].set( 'used', `eval( use )` ) | 682 self.spells[ name ].set( 'used', `eval( use )` ) |
733 | 683 |
734 def refresh_spells(self): | 684 def refresh_spells(self): |
747 wnd.title = "Spells" | 697 wnd.title = "Spells" |
748 return wnd | 698 return wnd |
749 | 699 |
750 def tohtml(self): | 700 def tohtml(self): |
751 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Divine Spells</th></tr><tr><td><br />" | 701 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Divine Spells</th></tr><tr><td><br />" |
752 for n in self.xml: | 702 for n in self.xml: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " |
753 html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " | |
754 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" | 703 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
755 return html_str | 704 return html_str |
756 | 705 |
757 def get_char_lvl( self, attr ): | 706 def get_char_lvl( self, attr ): |
758 return self.char_hander.get_char_lvl(attr) | 707 return self.char_hander.get_char_lvl(attr) |
794 self.chat.ParsePost( txt, True, False ) | 743 self.chat.ParsePost( txt, True, False ) |
795 else: | 744 else: |
796 txt = '%s uses %s as a Free Talent ( level %s, "%s" )' % ( cname, name, level, descr ) | 745 txt = '%s uses %s as a Free Talent ( level %s, "%s" )' % ( cname, name, level, descr ) |
797 self.chat.ParsePost( txt, True, False ) | 746 self.chat.ParsePost( txt, True, False ) |
798 s = '' | 747 s = '' |
799 if left != 1: | 748 if left != 1: s = 's' |
800 s = 's' | |
801 txt = '%s can use %s %d more time%s' % ( cname, name, numcast, s ) | 749 txt = '%s can use %s %d more time%s' % ( cname, name, numcast, s ) |
802 self.chat.ParsePost( txt, False, False ) | 750 self.chat.ParsePost( txt, False, False ) |
803 self.char_hander.set_char_pp('free', left) | 751 self.char_hander.set_char_pp('free', left) |
804 else: | 752 else: |
805 left = eval('%s - ( %s )' % ( cpp, points )) | 753 left = eval('%s - ( %s )' % ( cpp, points )) |
809 self.chat.ParsePost( txt, True, False ) | 757 self.chat.ParsePost( txt, True, False ) |
810 else: | 758 else: |
811 txt = '%s uses %s ( level %s, "%s" )' % ( cname, name, level, descr ) | 759 txt = '%s uses %s ( level %s, "%s" )' % ( cname, name, level, descr ) |
812 self.chat.ParsePost( txt, True, False ) | 760 self.chat.ParsePost( txt, True, False ) |
813 s = '' | 761 s = '' |
814 if left != 1: | 762 if left != 1: s = 's' |
815 s = 's' | |
816 txt = '%s can use %s %d more time%s' % ( cname, name, numcast, s ) | 763 txt = '%s can use %s %d more time%s' % ( cname, name, numcast, s ) |
817 txt += ' - And has %d more Powerpoints left' % (left) | 764 txt += ' - And has %d more Powerpoints left' % (left) |
818 self.chat.ParsePost( txt, False, False ) | 765 self.chat.ParsePost( txt, False, False ) |
819 self.char_hander.set_char_pp('current1', left) | 766 self.char_hander.set_char_pp('current1', left) |
820 | 767 |
834 wnd.title = "Powers" | 781 wnd.title = "Powers" |
835 return wnd | 782 return wnd |
836 | 783 |
837 def tohtml(self): | 784 def tohtml(self): |
838 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Powers</th></tr><tr><td><br />" | 785 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Powers</th></tr><tr><td><br />" |
839 for n in self.xml: | 786 for n in self.xml: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " |
840 html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " | |
841 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" | 787 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
842 return html_str | 788 return html_str |
843 | 789 |
844 def get_char_lvl( self, attr ): | 790 def get_char_lvl( self, attr ): |
845 return self.char_hander.get_char_lvl(attr) | 791 return self.char_hander.get_char_lvl(attr) |
907 html_str += "<th>Current:</th><td>"+self.xml.get('current')+"</td>" | 853 html_str += "<th>Current:</th><td>"+self.xml.get('current')+"</td>" |
908 html_str += "</tr></table>" | 854 html_str += "</tr></table>" |
909 return html_str | 855 return html_str |
910 | 856 |
911 def get_max_hp( self ): | 857 def get_max_hp( self ): |
912 try: | 858 try: return eval( self.xml.get( 'max' ) ) |
913 return eval( self.xml.get( 'max' ) ) | 859 except: return 0 |
914 except: | |
915 return 0 | |
916 def get_current_hp( self ): | 860 def get_current_hp( self ): |
917 try: | 861 try: return eval( self.xml.get( 'current' ) ) |
918 return eval( self.xml.get( 'current' ) ) | 862 except: return 0 |
919 except: | |
920 return 0 | |
921 | 863 |
922 class d20pp(d20_char_child): | 864 class d20pp(d20_char_child): |
923 """ Node Handler for power points. This handler will be | 865 """ Node Handler for power points. This handler will be |
924 created by d20char_handler. | 866 created by d20char_handler. |
925 """ | 867 """ |
1021 (attack_mod_str, damage_mods) = self.process_mod_codes( attack_mod_str, damage_mods ) | 963 (attack_mod_str, damage_mods) = self.process_mod_codes( attack_mod_str, damage_mods ) |
1022 | 964 |
1023 # Base attack bonuses for up to six attacks. | 965 # Base attack bonuses for up to six attacks. |
1024 bab_attributes = ['base', 'second', 'third', 'forth', 'fifth', 'sixth'] | 966 bab_attributes = ['base', 'second', 'third', 'forth', 'fifth', 'sixth'] |
1025 bab = [] | 967 bab = [] |
1026 for b in bab_attributes: | 968 for b in bab_attributes: bab.append( int(self.melee.get( b )) ) |
1027 bab.append( int(self.melee.get( b )) ) | |
1028 | 969 |
1029 # Misc. attack modifier to be applied to *all* attacks. | 970 # Misc. attack modifier to be applied to *all* attacks. |
1030 misc_mod = int(self.melee.get( 'misc' )); | 971 misc_mod = int(self.melee.get( 'misc' )); |
1031 | 972 |
1032 # Attack modifier (except BAB) | 973 # Attack modifier (except BAB) |
1033 attack_mod = misc_mod + eval( attack_mod_str ) | 974 attack_mod = misc_mod + eval( attack_mod_str ) |
1034 | 975 |
1035 # Total damage mod (except extra dice) | 976 # Total damage mod (except extra dice) |
1036 if damage_mods != '': | 977 if damage_mods != '': damage_mod = eval( damage_mods ) |
1037 damage_mod = eval( damage_mods ) | 978 else: damage_mod = 0 |
1038 else: | |
1039 damage_mod = 0 | |
1040 | 979 |
1041 # Determine critical hit range and multiplier. | 980 # Determine critical hit range and multiplier. |
1042 critical_str = self.weapons[name].get( 'critical' ) | 981 critical_str = self.weapons[name].get( 'critical' ) |
1043 m = re.match( r"(((?P<min>\d+)-)?\d+/)?x(?P<mult>\d+)", critical_str ) | 982 m = re.match( r"(((?P<min>\d+)-)?\d+/)?x(?P<mult>\d+)", critical_str ) |
1044 crit_min = m.group( 'min' ) | 983 crit_min = m.group( 'min' ) |
1045 crit_mult = m.group( 'mult' ) | 984 crit_mult = m.group( 'mult' ) |
1046 if crit_min == None: | 985 if crit_min == None: crit_min = 20 |
1047 crit_min = 20 | 986 else: crit_min = int( crit_min ) |
1048 else: | 987 if crit_mult == None: crit_mult = 2 |
1049 crit_min = int( crit_min ) | 988 else: crit_mult = int( crit_mult ) |
1050 if crit_mult == None: | |
1051 crit_mult = 2 | |
1052 else: | |
1053 crit_mult = int( crit_mult ) | |
1054 | 989 |
1055 # Simple matter to output all the attack/damage lines to the chat buffer. | 990 # Simple matter to output all the attack/damage lines to the chat buffer. |
1056 for i in range( 0, len( bab ) ): | 991 for i in range( 0, len( bab ) ): |
1057 if bab[i] > 0 or i == 0: | 992 if bab[i] > 0 or i == 0: |
1058 attack_roll_str = '[1d20%+d]' % (bab[i] + attack_mod) | 993 attack_roll_str = '[1d20%+d]' % (bab[i] + attack_mod) |
1065 | 1000 |
1066 # Check for a critical hit | 1001 # Check for a critical hit |
1067 d20_roll = int(re.match( r".*\[(\d+),.*", attack_roll_parsed ).group(1)); | 1002 d20_roll = int(re.match( r".*\[(\d+),.*", attack_roll_parsed ).group(1)); |
1068 dmg = damage_str | 1003 dmg = damage_str |
1069 if d20_roll >= crit_min: | 1004 if d20_roll >= crit_min: |
1070 for j in range(1,crit_mult): | 1005 for j in range(1,crit_mult): dmg += '+%s' % damage_str |
1071 dmg += '+%s' % damage_str | |
1072 txt = 'Critical hit? [1d20%+d] ===> Damage: [%dd%d%+d%s]' \ | 1006 txt = 'Critical hit? [1d20%+d] ===> Damage: [%dd%d%+d%s]' \ |
1073 % (bab[i] + attack_mod, crit_mult*num_damage_dice, \ | 1007 % (bab[i] + attack_mod, crit_mult*num_damage_dice, \ |
1074 damage_die, crit_mult*damage_mod, extra_damage) | 1008 damage_die, crit_mult*damage_mod, extra_damage) |
1075 self.chat.ParsePost( txt, True, True ) | 1009 self.chat.ParsePost( txt, True, True ) |
1076 | 1010 |
1085 def tohtml(self): | 1019 def tohtml(self): |
1086 babs = self.get_attack_data() | 1020 babs = self.get_attack_data() |
1087 html_str = "<table width=100% border=1 ><tr ALIGN='center'><th BGCOLOR=#E9E9E9>Base Attack Bonus</th>" | 1021 html_str = "<table width=100% border=1 ><tr ALIGN='center'><th BGCOLOR=#E9E9E9>Base Attack Bonus</th>" |
1088 html_str += '<td>%+d' % babs[0] | 1022 html_str += '<td>%+d' % babs[0] |
1089 for i in range(1,6): | 1023 for i in range(1,6): |
1090 if babs[i] > 0: | 1024 if babs[i] > 0: html_str += '/%+d' % babs[i] |
1091 html_str += '/%+d' % babs[i] | |
1092 html_str += "</td></tr><tr ALIGN='center' ><th BGCOLOR=#E9E9E9>Misc. Attack Bonus</th>" | 1025 html_str += "</td></tr><tr ALIGN='center' ><th BGCOLOR=#E9E9E9>Misc. Attack Bonus</th>" |
1093 html_str += '<td>%+d</td></tr></table>' % babs[6] | 1026 html_str += '<td>%+d</td></tr></table>' % babs[6] |
1094 | 1027 |
1095 n_list = self.xml.findall('weapon') | 1028 n_list = self.xml.findall('weapon') |
1096 for n in n_list: | 1029 for n in n_list: |
1131 def get_armor_class(self): | 1064 def get_armor_class(self): |
1132 ac_total = 10 | 1065 ac_total = 10 |
1133 ac_total += self.get_total('bonus') | 1066 ac_total += self.get_total('bonus') |
1134 dex_mod = self.char_hander.child_handlers['abilities'].get_mod('Dex') | 1067 dex_mod = self.char_hander.child_handlers['abilities'].get_mod('Dex') |
1135 max_dex = self.get_max_dex() | 1068 max_dex = self.get_max_dex() |
1136 if dex_mod < max_dex: | 1069 if dex_mod < max_dex: ac_total += dex_mod |
1137 ac_total += dex_mod | 1070 else: ac_total += max_dex |
1138 else: | |
1139 ac_total += max_dex | |
1140 return ac_total | 1071 return ac_total |
1141 | 1072 |
1142 def get_max_dex(self): | 1073 def get_max_dex(self): |
1143 armor_list = self.xml.findall('armor') | 1074 armor_list = self.xml.findall('armor') |
1144 dex = 10 | 1075 dex = 10 |
1145 for a in armor_list: | 1076 for a in armor_list: |
1146 temp = int(a.get("maxdex")) | 1077 temp = int(a.get("maxdex")) |
1147 if temp < dex: | 1078 if temp < dex: dex = temp |
1148 dex = temp | |
1149 return dex | 1079 return dex |
1150 | 1080 |
1151 def get_total(self,attr): | 1081 def get_total(self,attr): |
1152 armor_list = self.xml.findall('armor') | 1082 armor_list = self.xml.findall('armor') |
1153 total = 0 | 1083 total = 0 |
1154 for a in armor_list: | 1084 for a in armor_list: total += int(a.get(attr)) |
1155 total += int(a.get(attr)) | |
1156 return total | 1085 return total |
1157 | 1086 |
1158 def get_design_panel(self,parent): | 1087 def get_design_panel(self,parent): |
1159 wnd = outline_panel(parent,self,ac_panel,"Armor") | 1088 wnd = outline_panel(parent,self,ac_panel,"Armor") |
1160 wnd.title = "Armor" | 1089 wnd.title = "Armor" |
1218 self.height = 1200 | 1147 self.height = 1200 |
1219 self.SetScrollbars(10, 10,80, self.height/10) | 1148 self.SetScrollbars(10, 10,80, self.height/10) |
1220 self.main_sizer = wx.BoxSizer(wx.HORIZONTAL) | 1149 self.main_sizer = wx.BoxSizer(wx.HORIZONTAL) |
1221 self.panels = {} | 1150 self.panels = {} |
1222 keys = handler.child_handlers.keys() | 1151 keys = handler.child_handlers.keys() |
1223 for k in keys: | 1152 for k in keys: self.panels[k] = handler.child_handlers[k].get_design_panel(self, [k]) |
1224 self.panels[k] = handler.child_handlers[k].get_design_panel(self, [k]) | |
1225 self.sub_sizer = wx.BoxSizer(wx.VERTICAL) | 1153 self.sub_sizer = wx.BoxSizer(wx.VERTICAL) |
1226 self.sub_sizer2 = wx.BoxSizer(wx.VERTICAL) | 1154 self.sub_sizer2 = wx.BoxSizer(wx.VERTICAL) |
1227 self.sub_sizer.Add(self.panels['general'], 1, wx.EXPAND) | 1155 self.sub_sizer.Add(self.panels['general'], 1, wx.EXPAND) |
1228 self.sub_sizer.Add(self.panels['abilities'], 1, wx.EXPAND) | 1156 self.sub_sizer.Add(self.panels['abilities'], 1, wx.EXPAND) |
1229 | 1157 |
1298 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_MAX) | 1226 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_MAX) |
1299 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_CUR) | 1227 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_CUR) |
1300 | 1228 |
1301 def on_text(self,evt): | 1229 def on_text(self,evt): |
1302 id = evt.GetId() | 1230 id = evt.GetId() |
1303 if id == HP_CUR: | 1231 if id == HP_CUR: self.xml.set('current',evt.GetString()) |
1304 self.xml.set('current',evt.GetString()) | 1232 elif id == HP_MAX: self.xml.set('max',evt.GetString()) |
1305 elif id == HP_MAX: | |
1306 self.xml.set('max',evt.GetString()) | |
1307 | 1233 |
1308 def on_size(self,evt): | 1234 def on_size(self,evt): |
1309 s = self.GetClientSizeTuple() | 1235 s = self.GetClientSizeTuple() |
1310 self.sizer.SetDimension(0,0,s[0],s[1]) | 1236 self.sizer.SetDimension(0,0,s[0],s[1]) |
1311 | 1237 |
1338 self.Bind(wx.EVT_TEXT, self.on_text, id=PP_FRE) | 1264 self.Bind(wx.EVT_TEXT, self.on_text, id=PP_FRE) |
1339 self.Bind(wx.EVT_TEXT, self.on_text, id=PP_MFRE) | 1265 self.Bind(wx.EVT_TEXT, self.on_text, id=PP_MFRE) |
1340 | 1266 |
1341 def on_text(self,evt): | 1267 def on_text(self,evt): |
1342 id = evt.GetId() | 1268 id = evt.GetId() |
1343 if id == PP_CUR: | 1269 if id == PP_CUR: self.xml.set('current1',evt.GetString()) |
1344 self.xml.set('current1',evt.GetString()) | 1270 elif id == PP_MAX: self.xml.set('max1',evt.GetString()) |
1345 elif id == PP_MAX: | 1271 elif id == PP_FRE: self.xml.set('free',evt.GetString()) |
1346 self.xml.set('max1',evt.GetString()) | 1272 elif id == PP_MFRE: self.xml.set('maxfree',evt.GetString()) |
1347 elif id == PP_FRE: | |
1348 self.xml.set('free',evt.GetString()) | |
1349 elif id == PP_MFRE: | |
1350 self.xml.set('maxfree',evt.GetString()) | |
1351 | 1273 |
1352 def on_size(self,evt): | 1274 def on_size(self,evt): |
1353 s = self.GetClientSizeTuple() | 1275 s = self.GetClientSizeTuple() |
1354 self.sizer.SetDimension(0,0,s[0],s[1]) | 1276 self.sizer.SetDimension(0,0,s[0],s[1]) |
1355 | 1277 |
1366 self.CreateGrid(len(n_list),2) | 1288 self.CreateGrid(len(n_list),2) |
1367 self.SetRowLabelSize(0) | 1289 self.SetRowLabelSize(0) |
1368 self.SetColLabelSize(0) | 1290 self.SetColLabelSize(0) |
1369 self.n_list = n_list | 1291 self.n_list = n_list |
1370 i = 0 | 1292 i = 0 |
1371 for i in range(len(n_list)): | 1293 for i in range(len(n_list)): self.refresh_row(i) |
1372 self.refresh_row(i) | |
1373 | 1294 |
1374 def on_cell_change(self,evt): | 1295 def on_cell_change(self,evt): |
1375 row = evt.GetRow() | 1296 row = evt.GetRow() |
1376 col = evt.GetCol() | 1297 col = evt.GetCol() |
1377 value = self.GetCellValue(row,col) | 1298 value = self.GetCellValue(row,col) |
1385 | 1306 |
1386 def on_size(self,evt): | 1307 def on_size(self,evt): |
1387 (w,h) = self.GetClientSizeTuple() | 1308 (w,h) = self.GetClientSizeTuple() |
1388 cols = self.GetNumberCols() | 1309 cols = self.GetNumberCols() |
1389 col_w = w/(cols) | 1310 col_w = w/(cols) |
1390 for i in range(0,cols): | 1311 for i in range(0,cols): self.SetColSize(i,col_w) |
1391 self.SetColSize(i,col_w) | |
1392 evt.Skip() | 1312 evt.Skip() |
1393 self.Refresh() | 1313 self.Refresh() |
1394 | 1314 |
1395 class inventory_grid(wx.grid.Grid): | 1315 class inventory_grid(wx.grid.Grid): |
1396 """grid for gen info""" | 1316 """grid for gen info""" |
1404 self.CreateGrid(len(n_list),2) | 1324 self.CreateGrid(len(n_list),2) |
1405 self.SetRowLabelSize(0) | 1325 self.SetRowLabelSize(0) |
1406 self.SetColLabelSize(0) | 1326 self.SetColLabelSize(0) |
1407 self.n_list = n_list | 1327 self.n_list = n_list |
1408 i = 0 | 1328 i = 0 |
1409 for i in range(len(n_list)): | 1329 for i in range(len(n_list)): self.refresh_row(i) |
1410 self.refresh_row(i) | |
1411 | 1330 |
1412 def on_cell_change(self,evt): | 1331 def on_cell_change(self,evt): |
1413 row = evt.GetRow() | 1332 row = evt.GetRow() |
1414 col = evt.GetCol() | 1333 col = evt.GetCol() |
1415 value = self.GetCellValue(row,col) | 1334 value = self.GetCellValue(row,col) |
1423 | 1342 |
1424 def on_size(self,evt): | 1343 def on_size(self,evt): |
1425 (w,h) = self.GetClientSizeTuple() | 1344 (w,h) = self.GetClientSizeTuple() |
1426 cols = self.GetNumberCols() | 1345 cols = self.GetNumberCols() |
1427 col_w = w/(cols) | 1346 col_w = w/(cols) |
1428 for i in range(0,cols): | 1347 for i in range(0,cols): self.SetColSize(i,col_w) |
1429 self.SetColSize(i,col_w) | |
1430 evt.Skip() | 1348 evt.Skip() |
1431 self.Refresh() | 1349 self.Refresh() |
1432 | 1350 |
1433 class abil_grid(wx.grid.Grid): | 1351 class abil_grid(wx.grid.Grid): |
1434 """grid for abilities""" | 1352 """grid for abilities""" |
1440 self.handler = handler | 1358 self.handler = handler |
1441 stats = handler.xml.findall('stat') | 1359 stats = handler.xml.findall('stat') |
1442 self.CreateGrid(len(stats),3) | 1360 self.CreateGrid(len(stats),3) |
1443 self.SetRowLabelSize(0) | 1361 self.SetRowLabelSize(0) |
1444 col_names = ['Ability','Score','Modifier'] | 1362 col_names = ['Ability','Score','Modifier'] |
1445 for i in range(len(col_names)): | 1363 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
1446 self.SetColLabelValue(i,col_names[i]) | |
1447 self.stats = stats | 1364 self.stats = stats |
1448 i = 0 | 1365 i = 0 |
1449 for i in range(len(stats)): | 1366 for i in range(len(stats)): self.refresh_row(i) |
1450 self.refresh_row(i) | |
1451 self.char_wnd = None | 1367 self.char_wnd = None |
1452 | 1368 |
1453 def on_cell_change(self,evt): | 1369 def on_cell_change(self,evt): |
1454 row = evt.GetRow() | 1370 row = evt.GetRow() |
1455 col = evt.GetCol() | 1371 col = evt.GetCol() |
1456 value = self.GetCellValue(row,col) | 1372 value = self.GetCellValue(row,col) |
1457 try: | 1373 try: |
1458 int(value) | 1374 int(value) |
1459 self.stats[row].set('base',value) | 1375 self.stats[row].set('base',value) |
1460 self.refresh_row(row) | 1376 self.refresh_row(row) |
1461 except: | 1377 except: self.SetCellValue(row,col,"0") |
1462 self.SetCellValue(row,col,"0") | 1378 if self.char_wnd: self.char_wnd.refresh_data() |
1463 if self.char_wnd: | |
1464 self.char_wnd.refresh_data() | |
1465 | 1379 |
1466 def refresh_row(self,rowi): | 1380 def refresh_row(self,rowi): |
1467 s = self.stats[rowi] | 1381 s = self.stats[rowi] |
1468 name = s.get('name') | 1382 name = s.get('name') |
1469 abbr = s.get('abbr') | 1383 abbr = s.get('abbr') |
1476 def on_size(self,evt): | 1390 def on_size(self,evt): |
1477 (w,h) = self.GetClientSizeTuple() | 1391 (w,h) = self.GetClientSizeTuple() |
1478 cols = self.GetNumberCols() | 1392 cols = self.GetNumberCols() |
1479 col_w = w/(cols+2) | 1393 col_w = w/(cols+2) |
1480 self.SetColSize(0,col_w*3) | 1394 self.SetColSize(0,col_w*3) |
1481 for i in range(1,cols): | 1395 for i in range(1,cols): self.SetColSize(i,col_w) |
1482 self.SetColSize(i,col_w) | |
1483 evt.Skip() | 1396 evt.Skip() |
1484 self.Refresh() | 1397 self.Refresh() |
1485 | 1398 |
1486 def refresh_data(self): | 1399 def refresh_data(self): |
1487 for r in range(self.GetNumberRows()-1): | 1400 for r in range(self.GetNumberRows()-1): self.refresh_row(r) |
1488 self.refresh_row(r) | |
1489 | 1401 |
1490 | 1402 |
1491 class save_grid(wx.grid.Grid): | 1403 class save_grid(wx.grid.Grid): |
1492 """grid for saves""" | 1404 """grid for saves""" |
1493 def __init__(self, parent, handler): | 1405 def __init__(self, parent, handler): |
1499 saves = handler.xml.findall('save') | 1411 saves = handler.xml.findall('save') |
1500 self.stats = handler.char_hander.child_handlers['abilities'] | 1412 self.stats = handler.char_hander.child_handlers['abilities'] |
1501 self.CreateGrid(len(saves),7) | 1413 self.CreateGrid(len(saves),7) |
1502 self.SetRowLabelSize(0) | 1414 self.SetRowLabelSize(0) |
1503 col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] | 1415 col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] |
1504 for i in range(len(col_names)): | 1416 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
1505 self.SetColLabelValue(i,col_names[i]) | |
1506 self.saves = saves | 1417 self.saves = saves |
1507 i = 0 | 1418 i = 0 |
1508 for i in range(len(saves)): | 1419 for i in range(len(saves)): self.refresh_row(i) |
1509 self.refresh_row(i) | |
1510 | 1420 |
1511 def on_cell_change(self,evt): | 1421 def on_cell_change(self,evt): |
1512 row = evt.GetRow() | 1422 row = evt.GetRow() |
1513 col = evt.GetCol() | 1423 col = evt.GetCol() |
1514 value = self.GetCellValue(row,col) | 1424 value = self.GetCellValue(row,col) |
1515 try: | 1425 try: |
1516 int(value) | 1426 int(value) |
1517 if col == 2: | 1427 if col == 2: self.saves[row].set('base',value) |
1518 self.saves[row].set('base',value) | 1428 elif col == 4: self.saves[row].set('magmod',value) |
1519 elif col ==4: | 1429 elif col == 4: self.saves[row].set('miscmod',value) |
1520 self.saves[row].set('magmod',value) | |
1521 elif col ==4: | |
1522 self.saves[row].set('miscmod',value) | |
1523 self.refresh_row(row) | 1430 self.refresh_row(row) |
1524 except: | 1431 except: self.SetCellValue(row,col,"0") |
1525 self.SetCellValue(row,col,"0") | |
1526 | 1432 |
1527 def refresh_row(self,rowi): | 1433 def refresh_row(self,rowi): |
1528 s = self.saves[rowi] | 1434 s = self.saves[rowi] |
1529 name = s.get('name') | 1435 name = s.get('name') |
1530 self.SetCellValue(rowi,0,name) | 1436 self.SetCellValue(rowi,0,name) |
1544 def on_size(self,evt): | 1450 def on_size(self,evt): |
1545 (w,h) = self.GetClientSizeTuple() | 1451 (w,h) = self.GetClientSizeTuple() |
1546 cols = self.GetNumberCols() | 1452 cols = self.GetNumberCols() |
1547 col_w = w/(cols+2) | 1453 col_w = w/(cols+2) |
1548 self.SetColSize(0,col_w*3) | 1454 self.SetColSize(0,col_w*3) |
1549 for i in range(1,cols): | 1455 for i in range(1,cols): self.SetColSize(i,col_w) |
1550 self.SetColSize(i,col_w) | |
1551 evt.Skip() | 1456 evt.Skip() |
1552 self.Refresh() | 1457 self.Refresh() |
1553 | 1458 |
1554 def refresh_data(self): | 1459 def refresh_data(self): |
1555 for r in range(self.GetNumberRows()): | 1460 for r in range(self.GetNumberRows()): self.refresh_row(r) |
1556 self.refresh_row(r) | |
1557 | 1461 |
1558 | 1462 |
1559 class skill_grid(wx.grid.Grid): | 1463 class skill_grid(wx.grid.Grid): |
1560 """ panel for skills """ | 1464 """ panel for skills """ |
1561 def __init__(self, parent, handler): | 1465 def __init__(self, parent, handler): |
1567 skills = handler.xml.findall('skill') | 1471 skills = handler.xml.findall('skill') |
1568 self.stats = handler.char_hander.child_handlers['abilities'] | 1472 self.stats = handler.char_hander.child_handlers['abilities'] |
1569 self.CreateGrid(len(skills),6) | 1473 self.CreateGrid(len(skills),6) |
1570 self.SetRowLabelSize(0) | 1474 self.SetRowLabelSize(0) |
1571 col_names = ['Skill','Key','Rank','Abil','Misc','Total'] | 1475 col_names = ['Skill','Key','Rank','Abil','Misc','Total'] |
1572 for i in range(len(col_names)): | 1476 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
1573 self.SetColLabelValue(i,col_names[i]) | |
1574 rowi = 0 | 1477 rowi = 0 |
1575 self.skills = skills | 1478 self.skills = skills |
1576 for i in range(len(skills)): | 1479 for i in range(len(skills)): self.refresh_row(i) |
1577 self.refresh_row(i) | |
1578 | 1480 |
1579 def on_cell_change(self,evt): | 1481 def on_cell_change(self,evt): |
1580 row = evt.GetRow() | 1482 row = evt.GetRow() |
1581 col = evt.GetCol() | 1483 col = evt.GetCol() |
1582 value = self.GetCellValue(row,col) | 1484 value = self.GetCellValue(row,col) |
1583 try: | 1485 try: |
1584 int(value) | 1486 int(value) |
1585 if col == 2: | 1487 if col == 2: self.skills[row].set('rank',value) |
1586 self.skills[row].set('rank',value) | 1488 elif col == 4: self.skills[row].set('misc',value) |
1587 elif col ==4: | |
1588 self.skills[row].set('misc',value) | |
1589 self.refresh_row(row) | 1489 self.refresh_row(row) |
1590 except: | 1490 except: self.SetCellValue(row,col,"0") |
1591 self.SetCellValue(row,col,"0") | |
1592 | 1491 |
1593 def refresh_row(self,rowi): | 1492 def refresh_row(self,rowi): |
1594 s = self.skills[rowi] | 1493 s = self.skills[rowi] |
1595 name = s.get('name') | 1494 name = s.get('name') |
1596 self.SetCellValue(rowi,0,name) | 1495 self.SetCellValue(rowi,0,name) |
1609 def on_size(self,evt): | 1508 def on_size(self,evt): |
1610 (w,h) = self.GetClientSizeTuple() | 1509 (w,h) = self.GetClientSizeTuple() |
1611 cols = self.GetNumberCols() | 1510 cols = self.GetNumberCols() |
1612 col_w = w/(cols+2) | 1511 col_w = w/(cols+2) |
1613 self.SetColSize(0,col_w*3) | 1512 self.SetColSize(0,col_w*3) |
1614 for i in range(1,cols): | 1513 for i in range(1,cols): self.SetColSize(i,col_w) |
1615 self.SetColSize(i,col_w) | |
1616 evt.Skip() | 1514 evt.Skip() |
1617 self.Refresh() | 1515 self.Refresh() |
1618 | 1516 |
1619 def refresh_data(self): | 1517 def refresh_data(self): |
1620 for r in range(self.GetNumberRows()): | 1518 for r in range(self.GetNumberRows()): self.refresh_row(r) |
1621 self.refresh_row(r) | |
1622 | |
1623 | 1519 |
1624 | 1520 |
1625 class feat_panel(wx.Panel): | 1521 class feat_panel(wx.Panel): |
1626 def __init__(self, parent, handler): | 1522 def __init__(self, parent, handler): |
1627 pname = handler.xml.set("name", 'Feats') | 1523 pname = handler.xml.set("name", 'Feats') |
1641 self.xml = handler.xml | 1537 self.xml = handler.xml |
1642 self.grid.CreateGrid(len(n_list),2,1) | 1538 self.grid.CreateGrid(len(n_list),2,1) |
1643 self.grid.SetRowLabelSize(0) | 1539 self.grid.SetRowLabelSize(0) |
1644 self.grid.SetColLabelValue(0,"Feat") | 1540 self.grid.SetColLabelValue(0,"Feat") |
1645 self.grid.SetColLabelValue(1,"Type") | 1541 self.grid.SetColLabelValue(1,"Type") |
1646 for i in range(len(n_list)): | 1542 for i in range(len(n_list)): self.refresh_row(i) |
1647 self.refresh_row(i) | |
1648 self.temp_dom = None | 1543 self.temp_dom = None |
1649 self.SetSizer(self.sizer) | 1544 self.SetSizer(self.sizer) |
1650 | 1545 |
1651 def refresh_row(self,i): | 1546 def refresh_row(self,i): |
1652 feat = self.n_list[i] | 1547 feat = self.n_list[i] |
1668 if not self.temp_dom: | 1563 if not self.temp_dom: |
1669 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20feats.xml") | 1564 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20feats.xml") |
1670 self.temp_dom = tree.getroot() | 1565 self.temp_dom = tree.getroot() |
1671 f_list = self.temp_dom.findall('feat') | 1566 f_list = self.temp_dom.findall('feat') |
1672 opts = [] | 1567 opts = [] |
1673 for f in f_list: | 1568 for f in f_list: opts.append(f.get('name')) |
1674 opts.append(f.get('name')) | |
1675 dlg = wx.SingleChoiceDialog(self,'Choose Feat','Feats',opts) | 1569 dlg = wx.SingleChoiceDialog(self,'Choose Feat','Feats',opts) |
1676 if dlg.ShowModal() == wx.ID_OK: | 1570 if dlg.ShowModal() == wx.ID_OK: |
1677 i = dlg.GetSelection() | 1571 i = dlg.GetSelection() |
1678 new_node = self.xml.append(XML(tostring(f_list[i]))) | 1572 new_node = self.xml.append(XML(tostring(f_list[i]))) |
1679 self.grid.AppendRows(1) | 1573 self.grid.AppendRows(1) |
1686 self.grid.SetDimensions(0,0,s[0],s[1]-25) | 1580 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
1687 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 1581 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
1688 (w,h) = self.grid.GetClientSizeTuple() | 1582 (w,h) = self.grid.GetClientSizeTuple() |
1689 cols = self.grid.GetNumberCols() | 1583 cols = self.grid.GetNumberCols() |
1690 col_w = w/(cols) | 1584 col_w = w/(cols) |
1691 for i in range(0,cols): | 1585 for i in range(0,cols): self.grid.SetColSize(i,col_w) |
1692 self.grid.SetColSize(i,col_w) | |
1693 | 1586 |
1694 class spell_panel(wx.Panel): | 1587 class spell_panel(wx.Panel): |
1695 def __init__(self, parent, handler): | 1588 def __init__(self, parent, handler): |
1696 pname = handler.xml.set("name", 'Arcane Spells') | 1589 pname = handler.xml.set("name", 'Arcane Spells') |
1697 wx.Panel.__init__(self, parent, -1) | 1590 wx.Panel.__init__(self, parent, -1) |
1717 self.grid.SetRowLabelSize(0) | 1610 self.grid.SetRowLabelSize(0) |
1718 self.grid.SetColLabelValue(0,"No.") | 1611 self.grid.SetColLabelValue(0,"No.") |
1719 self.grid.SetColLabelValue(1,"Lvl") | 1612 self.grid.SetColLabelValue(1,"Lvl") |
1720 self.grid.SetColLabelValue(2,"Spell") | 1613 self.grid.SetColLabelValue(2,"Spell") |
1721 self.grid.SetColLabelValue(3,"Desc") | 1614 self.grid.SetColLabelValue(3,"Desc") |
1722 for i in range(len(n_list)): | 1615 for i in range(len(n_list)): self.refresh_row(i) |
1723 self.refresh_row(i) | |
1724 self.temp_dom = None | 1616 self.temp_dom = None |
1725 | 1617 |
1726 def on_cell_change(self,evt): | 1618 def on_cell_change(self,evt): |
1727 row = evt.GetRow() | 1619 row = evt.GetRow() |
1728 col = evt.GetCol() | 1620 col = evt.GetCol() |
1729 value = self.grid.GetCellValue(row,col) | 1621 value = self.grid.GetCellValue(row,col) |
1730 if col == 0: | 1622 if col == 0: self.n_list[row].set('memrz',value) |
1731 self.n_list[row].set('memrz',value) | |
1732 | 1623 |
1733 def refresh_row(self,i): | 1624 def refresh_row(self,i): |
1734 spell = self.n_list[i] | 1625 spell = self.n_list[i] |
1735 memrz = spell.get('memrz') | 1626 memrz = spell.get('memrz') |
1736 name = spell.get('name') | 1627 name = spell.get('name') |
1756 if not self.temp_dom: | 1647 if not self.temp_dom: |
1757 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20spells.xml") | 1648 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20spells.xml") |
1758 self.temp_dom = tree.getroot() | 1649 self.temp_dom = tree.getroot() |
1759 f_list = self.temp_dom.findall('spell') | 1650 f_list = self.temp_dom.findall('spell') |
1760 opts = [] | 1651 opts = [] |
1761 # lvl = int(self.handler.get_char_lvl('level')) | 1652 for f in f_list: opts.append("(" + f.get('level') + ")" + f.get('name')) |
1762 # castlvl = lvl / 2 | |
1763 for f in f_list: | |
1764 opts.append("(" + f.get('level') + ")" + f.get('name')) | |
1765 # spelllvl = f.get('level') | |
1766 # if spelllvl <= "1": | |
1767 # opts.append("(" + f.get('level') + ")" + f.get('name')) | |
1768 # else: | |
1769 # if eval('%d >= %s' %(castlvl, spelllvl)): | |
1770 # opts.append("(" + f.get('level') + ")" + f.get('name')) | |
1771 dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts) | 1653 dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts) |
1772 if dlg.ShowModal() == wx.ID_OK: | 1654 if dlg.ShowModal() == wx.ID_OK: |
1773 i = dlg.GetSelection() | 1655 i = dlg.GetSelection() |
1774 new_node = self.xml.append(XML(tostring(f_list[i]))) | 1656 new_node = self.xml.append(XML(tostring(f_list[i]))) |
1775 self.grid.AppendRows(1) | 1657 self.grid.AppendRows(1) |
1778 self.handler.refresh_spells() | 1660 self.handler.refresh_spells() |
1779 dlg.Destroy() | 1661 dlg.Destroy() |
1780 | 1662 |
1781 def on_refresh_spells( self, evt ): | 1663 def on_refresh_spells( self, evt ): |
1782 f_list = self.xml.findall('spell') | 1664 f_list = self.xml.findall('spell') |
1783 for spell in f_list: | 1665 for spell in f_list: spell.set( 'used', '0' ) |
1784 spell.set( 'used', '0' ) | |
1785 | 1666 |
1786 def on_size(self,event): | 1667 def on_size(self,event): |
1787 s = self.GetClientSizeTuple() | 1668 s = self.GetClientSizeTuple() |
1788 self.grid.SetDimensions(0,0,s[0],s[1]-25) | 1669 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
1789 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 1670 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
1790 (w,h) = self.grid.GetClientSizeTuple() | 1671 (w,h) = self.grid.GetClientSizeTuple() |
1791 cols = self.grid.GetNumberCols() | 1672 cols = self.grid.GetNumberCols() |
1792 col_w = w/(cols) | 1673 col_w = w/(cols) |
1793 for i in range(0,cols): | 1674 for i in range(0,cols): self.grid.SetColSize(i,col_w) |
1794 self.grid.SetColSize(i,col_w) | |
1795 self.grid.SetColSize(0,w * 0.10) | 1675 self.grid.SetColSize(0,w * 0.10) |
1796 self.grid.SetColSize(1,w * 0.10) | 1676 self.grid.SetColSize(1,w * 0.10) |
1797 self.grid.SetColSize(2,w * 0.30) | 1677 self.grid.SetColSize(2,w * 0.30) |
1798 self.grid.SetColSize(3,w * 0.50) | 1678 self.grid.SetColSize(3,w * 0.50) |
1799 | 1679 |
1800 def refresh_data(self): | 1680 def refresh_data(self): |
1801 for i in range(len(self.n_list)): | 1681 for i in range(len(self.n_list)): self.refresh_row(i) |
1802 self.refresh_row(i) | |
1803 | 1682 |
1804 class divine_panel(wx.Panel): | 1683 class divine_panel(wx.Panel): |
1805 def __init__(self, parent, handler): | 1684 def __init__(self, parent, handler): |
1806 pname = handler.xml.set("name", 'Divine Spells') | 1685 pname = handler.xml.set("name", 'Divine Spells') |
1807 wx.Panel.__init__(self, parent, -1) | 1686 wx.Panel.__init__(self, parent, -1) |
1827 self.grid.SetRowLabelSize(0) | 1706 self.grid.SetRowLabelSize(0) |
1828 self.grid.SetColLabelValue(0,"No.") | 1707 self.grid.SetColLabelValue(0,"No.") |
1829 self.grid.SetColLabelValue(1,"Lvl") | 1708 self.grid.SetColLabelValue(1,"Lvl") |
1830 self.grid.SetColLabelValue(2,"Spell") | 1709 self.grid.SetColLabelValue(2,"Spell") |
1831 self.grid.SetColLabelValue(3,"Desc") | 1710 self.grid.SetColLabelValue(3,"Desc") |
1832 for i in range(len(n_list)): | 1711 for i in range(len(n_list)): self.refresh_row(i) |
1833 self.refresh_row(i) | |
1834 self.temp_dom = None | 1712 self.temp_dom = None |
1835 | 1713 |
1836 def on_cell_change(self,evt): | 1714 def on_cell_change(self,evt): |
1837 row = evt.GetRow() | 1715 row = evt.GetRow() |
1838 col = evt.GetCol() | 1716 col = evt.GetCol() |
1839 value = self.grid.GetCellValue(row,col) | 1717 value = self.grid.GetCellValue(row,col) |
1840 if col == 0: | 1718 if col == 0: self.n_list[row].set('memrz',value) |
1841 self.n_list[row].set('memrz',value) | |
1842 | 1719 |
1843 | 1720 |
1844 def refresh_row(self,i): | 1721 def refresh_row(self,i): |
1845 spell = self.n_list[i] | 1722 spell = self.n_list[i] |
1846 memrz = spell.get('memrz') | 1723 memrz = spell.get('memrz') |
1867 if not self.temp_dom: | 1744 if not self.temp_dom: |
1868 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20divine.xml") | 1745 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20divine.xml") |
1869 self.temp_dom = tree.getroot() | 1746 self.temp_dom = tree.getroot() |
1870 f_list = self.temp_dom.findall('gift') | 1747 f_list = self.temp_dom.findall('gift') |
1871 opts = [] | 1748 opts = [] |
1872 # lvl = int(self.handler.get_char_lvl('level')) | 1749 for f in f_list: opts.append("(" + f.get('level') + ")" + f.get('name')) |
1873 # castlvl = lvl / 2 | |
1874 for f in f_list: | |
1875 opts.append("(" + f.get('level') + ")" + f.get('name')) | |
1876 # spelllvl = f.get('level') | |
1877 # if spelllvl <= "1": | |
1878 # opts.append("(" + f.get('level') + ")" + f.get('name')) | |
1879 # else: | |
1880 # if eval('%d >= %s' %(castlvl, spelllvl)): | |
1881 # opts.append("(" + f.get('level') + ")" + f.get('name')) | |
1882 dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts) | 1750 dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts) |
1883 if dlg.ShowModal() == wx.ID_OK: | 1751 if dlg.ShowModal() == wx.ID_OK: |
1884 i = dlg.GetSelection() | 1752 i = dlg.GetSelection() |
1885 new_node = self.xml.append(XML(tostring(f_list[i]))) | 1753 new_node = self.xml.append(XML(tostring(f_list[i]))) |
1886 self.grid.AppendRows(1) | 1754 self.grid.AppendRows(1) |
1889 self.handler.refresh_spells() | 1757 self.handler.refresh_spells() |
1890 dlg.Destroy() | 1758 dlg.Destroy() |
1891 | 1759 |
1892 def on_refresh_spells( self, evt ): | 1760 def on_refresh_spells( self, evt ): |
1893 f_list = self.xml.findall('gift') | 1761 f_list = self.xml.findall('gift') |
1894 for spell in f_list: | 1762 for spell in f_list: spell.set( 'used', '0' ) |
1895 spell.set( 'used', '0' ) | |
1896 | 1763 |
1897 def on_size(self,event): | 1764 def on_size(self,event): |
1898 s = self.GetClientSizeTuple() | 1765 s = self.GetClientSizeTuple() |
1899 self.grid.SetDimensions(0,0,s[0],s[1]-25) | 1766 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
1900 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 1767 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
1901 (w,h) = self.grid.GetClientSizeTuple() | 1768 (w,h) = self.grid.GetClientSizeTuple() |
1902 cols = self.grid.GetNumberCols() | 1769 cols = self.grid.GetNumberCols() |
1903 col_w = w/(cols) | 1770 col_w = w/(cols) |
1904 for i in range(0,cols): | 1771 for i in range(0,cols): self.grid.SetColSize(i,col_w) |
1905 self.grid.SetColSize(i,col_w) | |
1906 self.grid.SetColSize(0,w * 0.10) | 1772 self.grid.SetColSize(0,w * 0.10) |
1907 self.grid.SetColSize(1,w * 0.10) | 1773 self.grid.SetColSize(1,w * 0.10) |
1908 self.grid.SetColSize(2,w * 0.30) | 1774 self.grid.SetColSize(2,w * 0.30) |
1909 self.grid.SetColSize(3,w * 0.50) | 1775 self.grid.SetColSize(3,w * 0.50) |
1910 | 1776 |
1911 def refresh_data(self): | 1777 def refresh_data(self): |
1912 for i in range(len(self.n_list)): | 1778 for i in range(len(self.n_list)): self.refresh_row(i) |
1913 self.refresh_row(i) | |
1914 | 1779 |
1915 | 1780 |
1916 class power_panel(wx.Panel): | 1781 class power_panel(wx.Panel): |
1917 def __init__(self, parent, handler): | 1782 def __init__(self, parent, handler): |
1918 pname = handler.xml.set("name", 'Pionic Powers') | 1783 pname = handler.xml.set("name", 'Pionic Powers') |
1939 self.grid.SetColLabelValue(0,"PP") | 1804 self.grid.SetColLabelValue(0,"PP") |
1940 self.grid.SetColLabelValue(1,"Lvl") | 1805 self.grid.SetColLabelValue(1,"Lvl") |
1941 self.grid.SetColLabelValue(2,"Power") | 1806 self.grid.SetColLabelValue(2,"Power") |
1942 self.grid.SetColLabelValue(3,"Desc") | 1807 self.grid.SetColLabelValue(3,"Desc") |
1943 self.grid.SetColLabelValue(4,"Type") | 1808 self.grid.SetColLabelValue(4,"Type") |
1944 for i in range(len(n_list)): | 1809 for i in range(len(n_list)): self.refresh_row(i) |
1945 self.refresh_row(i) | |
1946 self.refresh_data() | 1810 self.refresh_data() |
1947 self.temp_dom = None | 1811 self.temp_dom = None |
1948 self.SetSizer(self.sizer) | 1812 self.SetSizer(self.sizer) |
1949 | 1813 |
1950 def on_cell_change(self,evt): | 1814 def on_cell_change(self,evt): |
1951 row = evt.GetRow() | 1815 row = evt.GetRow() |
1952 col = evt.GetCol() | 1816 col = evt.GetCol() |
1953 value = self.grid.GetCellValue(row,col) | 1817 value = self.grid.GetCellValue(row,col) |
1954 """if col == 0: | |
1955 self.n_list[row].set('memrz',value)""" | |
1956 | |
1957 | 1818 |
1958 def refresh_row(self,i): | 1819 def refresh_row(self,i): |
1959 power = self.n_list[i] | 1820 power = self.n_list[i] |
1960 point = power.get('point') | 1821 point = power.get('point') |
1961 name = power.get('name') | 1822 name = power.get('name') |
1985 if not self.temp_dom: | 1846 if not self.temp_dom: |
1986 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20powers.xml") | 1847 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20powers.xml") |
1987 self.temp_dom = tree.getroot() | 1848 self.temp_dom = tree.getroot() |
1988 f_list = self.temp_dom.findall('power') | 1849 f_list = self.temp_dom.findall('power') |
1989 opts = [] | 1850 opts = [] |
1990 # lvl = int(self.handler.get_char_lvl('level')) | 1851 for f in f_list: opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) |
1991 # castlvl = lvl / 2 | |
1992 for f in f_list: | |
1993 opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) | |
1994 # spelllvl = f.get('level') | |
1995 # if spelllvl <= "1": | |
1996 # opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) | |
1997 # else: | |
1998 # if eval('%d >= %s' %(castlvl, spelllvl)): | |
1999 # opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) | |
2000 dlg = wx.SingleChoiceDialog(self,'Choose Power','Powers',opts) | 1852 dlg = wx.SingleChoiceDialog(self,'Choose Power','Powers',opts) |
2001 if dlg.ShowModal() == wx.ID_OK: | 1853 if dlg.ShowModal() == wx.ID_OK: |
2002 i = dlg.GetSelection() | 1854 i = dlg.GetSelection() |
2003 new_node = self.xml.append(XML(tostring(f_list[i]))) | 1855 new_node = self.xml.append(XML(tostring(f_list[i]))) |
2004 self.grid.AppendRows(1) | 1856 self.grid.AppendRows(1) |
2014 self.grid.DeleteRows(i) | 1866 self.grid.DeleteRows(i) |
2015 self.xml.remove(self.n_list[i]) | 1867 self.xml.remove(self.n_list[i]) |
2016 self.n_list = self.xml.findall('weapon') | 1868 self.n_list = self.xml.findall('weapon') |
2017 self.handler.refresh_weapons() | 1869 self.handler.refresh_weapons() |
2018 | 1870 |
2019 | |
2020 def on_refresh_powers( self, evt ): | 1871 def on_refresh_powers( self, evt ): |
2021 mfre = self.handler.get_char_pp('maxfree') | 1872 mfre = self.handler.get_char_pp('maxfree') |
2022 mpp = self.handler.get_char_pp('max1') | 1873 mpp = self.handler.get_char_pp('max1') |
2023 self.handler.set_char_pp( 'free', mfre ) | 1874 self.handler.set_char_pp( 'free', mfre ) |
2024 self.handler.set_char_pp( 'current1', mpp ) | 1875 self.handler.set_char_pp( 'current1', mpp ) |
2028 self.grid.SetDimensions(0,0,s[0],s[1]-25) | 1879 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
2029 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 1880 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
2030 (w,h) = self.grid.GetClientSizeTuple() | 1881 (w,h) = self.grid.GetClientSizeTuple() |
2031 cols = self.grid.GetNumberCols() | 1882 cols = self.grid.GetNumberCols() |
2032 col_w = w/(cols) | 1883 col_w = w/(cols) |
2033 for i in range(0,cols): | 1884 for i in range(0,cols): self.grid.SetColSize(i,col_w) |
2034 self.grid.SetColSize(i,col_w) | |
2035 self.grid.SetColSize(0,w * 0.05) | 1885 self.grid.SetColSize(0,w * 0.05) |
2036 self.grid.SetColSize(1,w * 0.05) | 1886 self.grid.SetColSize(1,w * 0.05) |
2037 self.grid.SetColSize(2,w * 0.30) | 1887 self.grid.SetColSize(2,w * 0.30) |
2038 self.grid.SetColSize(3,w * 0.30) | 1888 self.grid.SetColSize(3,w * 0.30) |
2039 self.grid.SetColSize(4,w * 0.30) | 1889 self.grid.SetColSize(4,w * 0.30) |
2040 | 1890 |
2041 def refresh_data(self): | 1891 def refresh_data(self): |
2042 for i in range(len(self.n_list)): | 1892 for i in range(len(self.n_list)): self.refresh_row(i) |
2043 self.refresh_row(i) | |
2044 | 1893 |
2045 class attack_grid(wx.grid.Grid): | 1894 class attack_grid(wx.grid.Grid): |
2046 """grid for attacks""" | 1895 """grid for attacks""" |
2047 def __init__(self, parent, handler): | 1896 def __init__(self, parent, handler): |
2048 pname = handler.xml.set("name", 'Melee') | 1897 pname = handler.xml.set("name", 'Melee') |
2051 self.handler = handler | 1900 self.handler = handler |
2052 self.babs = self.handler.melee | 1901 self.babs = self.handler.melee |
2053 self.CreateGrid(1,7) | 1902 self.CreateGrid(1,7) |
2054 self.SetRowLabelSize(0) | 1903 self.SetRowLabelSize(0) |
2055 col_names = ['base','base 2','base 3','base 4','base 5','base 6','misc'] | 1904 col_names = ['base','base 2','base 3','base 4','base 5','base 6','misc'] |
2056 for i in range(len(col_names)): | 1905 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
2057 self.SetColLabelValue(i,col_names[i]) | |
2058 self.refresh_data() | 1906 self.refresh_data() |
2059 self.Bind(wx.EVT_SIZE, self.on_size) | 1907 self.Bind(wx.EVT_SIZE, self.on_size) |
2060 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) | 1908 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
2061 | 1909 |
2062 def on_cell_change(self,evt): | 1910 def on_cell_change(self,evt): |
2063 row = evt.GetRow() | 1911 row = evt.GetRow() |
2064 col = evt.GetCol() | 1912 col = evt.GetCol() |
2065 value = self.GetCellValue(row,col) | 1913 value = self.GetCellValue(row,col) |
2066 try: | 1914 try: int(value) |
2067 int(value) | |
2068 except: | 1915 except: |
2069 value = "0" | 1916 value = "0" |
2070 self.SetCellValue( row, col, value ) | 1917 self.SetCellValue( row, col, value ) |
2071 attribs = ['base','second','third','forth','fifth','sixth','misc'] | 1918 attribs = ['base','second','third','forth','fifth','sixth','misc'] |
2072 self.babs.set( attribs[col], value ) | 1919 self.babs.set( attribs[col], value ) |
2073 self.parent.refresh_data() | 1920 self.parent.refresh_data() |
2074 | 1921 |
2075 def refresh_data(self): | 1922 def refresh_data(self): |
2076 attack_mods = self.handler.get_attack_data() | 1923 attack_mods = self.handler.get_attack_data() |
2077 for i in range(0,7): | 1924 for i in range(0,7): self.SetCellValue( 0, i, str(attack_mods[i]) ) |
2078 self.SetCellValue( 0, i, str(attack_mods[i]) ) | |
2079 | 1925 |
2080 def on_size(self,evt): | 1926 def on_size(self,evt): |
2081 (w,h) = self.GetClientSizeTuple() | 1927 (w,h) = self.GetClientSizeTuple() |
2082 cols = self.GetNumberCols() | 1928 cols = self.GetNumberCols() |
2083 col_w = w/cols | 1929 col_w = w/cols |
2084 for i in range(0,cols): | 1930 for i in range(0,cols): self.SetColSize(i,col_w) |
2085 self.SetColSize(i,col_w) | |
2086 evt.Skip() | 1931 evt.Skip() |
2087 self.Refresh() | 1932 self.Refresh() |
2088 | 1933 |
2089 class weapon_panel(wx.Panel): | 1934 class weapon_panel(wx.Panel): |
2090 def __init__(self, parent, handler): | 1935 def __init__(self, parent, handler): |
2105 self.xml = handler.xml | 1950 self.xml = handler.xml |
2106 self.handler = handler | 1951 self.handler = handler |
2107 self.grid.CreateGrid(len(n_list),8,1) | 1952 self.grid.CreateGrid(len(n_list),8,1) |
2108 self.grid.SetRowLabelSize(0) | 1953 self.grid.SetRowLabelSize(0) |
2109 col_names = ['Name','damage','mod','critical','type','weight','range','size'] | 1954 col_names = ['Name','damage','mod','critical','type','weight','range','size'] |
2110 for i in range(len(col_names)): | 1955 for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) |
2111 self.grid.SetColLabelValue(i,col_names[i]) | |
2112 self.refresh_data() | 1956 self.refresh_data() |
2113 self.temp_dom = None | 1957 self.temp_dom = None |
2114 self.SetSizer(self.sizer) | 1958 self.SetSizer(self.sizer) |
2115 | 1959 |
2116 def on_cell_change(self,evt): | 1960 def on_cell_change(self,evt): |
2118 col = evt.GetCol() | 1962 col = evt.GetCol() |
2119 value = self.grid.GetCellValue(row,col) | 1963 value = self.grid.GetCellValue(row,col) |
2120 if col == 0: | 1964 if col == 0: |
2121 self.n_list[row].set('name',value) | 1965 self.n_list[row].set('name',value) |
2122 self.handler.refresh_weapons(); | 1966 self.handler.refresh_weapons(); |
2123 else: | 1967 else: self.n_list[row].set(self.grid.GetColLabelValue(col),value) |
2124 self.n_list[row].set(self.grid.GetColLabelValue(col),value) | |
2125 | 1968 |
2126 def refresh_row(self,i): | 1969 def refresh_row(self,i): |
2127 n = self.n_list[i] | 1970 n = self.n_list[i] |
2128 name = n.get('name') | 1971 name = n.get('name') |
2129 mod = n.get('mod') | 1972 mod = n.get('mod') |
2150 if not self.temp_dom: | 1993 if not self.temp_dom: |
2151 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20weapons.xml") | 1994 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20weapons.xml") |
2152 self.temp_dom = tree.getroot() | 1995 self.temp_dom = tree.getroot() |
2153 f_list = self.temp_dom.findall('weapon') | 1996 f_list = self.temp_dom.findall('weapon') |
2154 opts = [] | 1997 opts = [] |
2155 for f in f_list: | 1998 for f in f_list: opts.append(f.get('name')) |
2156 opts.append(f.get('name')) | |
2157 dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts) | 1999 dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts) |
2158 if dlg.ShowModal() == wx.ID_OK: | 2000 if dlg.ShowModal() == wx.ID_OK: |
2159 i = dlg.GetSelection() | 2001 i = dlg.GetSelection() |
2160 new_node = self.xml.append(XML(tostring(f_list[i]))) | 2002 new_node = self.xml.append(XML(tostring(f_list[i]))) |
2161 self.grid.AppendRows(1) | 2003 self.grid.AppendRows(1) |
2170 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 2012 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
2171 (w,h) = self.grid.GetClientSizeTuple() | 2013 (w,h) = self.grid.GetClientSizeTuple() |
2172 cols = self.grid.GetNumberCols() | 2014 cols = self.grid.GetNumberCols() |
2173 col_w = w/(cols+1) | 2015 col_w = w/(cols+1) |
2174 self.grid.SetColSize(0,col_w*2) | 2016 self.grid.SetColSize(0,col_w*2) |
2175 for i in range(1,cols): | 2017 for i in range(1,cols): self.grid.SetColSize(i,col_w) |
2176 self.grid.SetColSize(i,col_w) | |
2177 | 2018 |
2178 def refresh_data(self): | 2019 def refresh_data(self): |
2179 for i in range(len(self.n_list)): | 2020 for i in range(len(self.n_list)): self.refresh_row(i) |
2180 self.refresh_row(i) | |
2181 | 2021 |
2182 | 2022 |
2183 class attack_panel(wx.Panel): | 2023 class attack_panel(wx.Panel): |
2184 def __init__(self, parent, handler): | 2024 def __init__(self, parent, handler): |
2185 pname = handler.xml.set("name", 'Melee') | 2025 pname = handler.xml.set("name", 'Melee') |
2220 n_list = handler.xml[:] | 2060 n_list = handler.xml[:] |
2221 self.n_list = n_list | 2061 self.n_list = n_list |
2222 col_names = ['Armor','bonus','maxdex','cp','sf','weight','speed','type'] | 2062 col_names = ['Armor','bonus','maxdex','cp','sf','weight','speed','type'] |
2223 self.grid.CreateGrid(len(n_list),len(col_names),1) | 2063 self.grid.CreateGrid(len(n_list),len(col_names),1) |
2224 self.grid.SetRowLabelSize(0) | 2064 self.grid.SetRowLabelSize(0) |
2225 for i in range(len(col_names)): | 2065 for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) |
2226 self.grid.SetColLabelValue(i,col_names[i]) | |
2227 self.atts =['name','bonus','maxdex','checkpenalty','spellfailure','weight','speed','type'] | 2066 self.atts =['name','bonus','maxdex','checkpenalty','spellfailure','weight','speed','type'] |
2228 for i in range(len(n_list)): | 2067 for i in range(len(n_list)): self.refresh_row(i) |
2229 self.refresh_row(i) | |
2230 self.temp_dom = None | 2068 self.temp_dom = None |
2231 self.SetSizer(self.sizer) | 2069 self.SetSizer(self.sizer) |
2232 | 2070 |
2233 def on_cell_change(self,evt): | 2071 def on_cell_change(self,evt): |
2234 row = evt.GetRow() | 2072 row = evt.GetRow() |
2236 value = self.grid.GetCellValue(row,col) | 2074 value = self.grid.GetCellValue(row,col) |
2237 if col >= 1 and col <= 5: | 2075 if col >= 1 and col <= 5: |
2238 try: | 2076 try: |
2239 int(value) | 2077 int(value) |
2240 self.n_list[row].set(self.atts[col],value) | 2078 self.n_list[row].set(self.atts[col],value) |
2241 except: | 2079 except: self.grid.SetCellValue(row,col,"0") |
2242 self.grid.SetCellValue(row,col,"0") | 2080 else: self.n_list[row].set(self.atts[col],value) |
2243 else: | |
2244 self.n_list[row].set(self.atts[col],value) | |
2245 | 2081 |
2246 def refresh_row(self,i): | 2082 def refresh_row(self,i): |
2247 n = self.n_list[i] | 2083 n = self.n_list[i] |
2248 for y in range(len(self.atts)): | 2084 for y in range(len(self.atts)): |
2249 self.grid.SetCellValue(i,y,n.get(self.atts[y])) | 2085 self.grid.SetCellValue(i,y,n.get(self.atts[y])) |
2259 if not self.temp_dom: | 2095 if not self.temp_dom: |
2260 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20armor.xml") | 2096 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20armor.xml") |
2261 self.temp_dom = tree.getroot() | 2097 self.temp_dom = tree.getroot() |
2262 f_list = self.temp_dom.findall('armor') | 2098 f_list = self.temp_dom.findall('armor') |
2263 opts = [] | 2099 opts = [] |
2264 for f in f_list: | 2100 for f in f_list: opts.append(f.get('name')) |
2265 opts.append(f.get('name')) | |
2266 dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts) | 2101 dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts) |
2267 if dlg.ShowModal() == wx.ID_OK: | 2102 if dlg.ShowModal() == wx.ID_OK: |
2268 i = dlg.GetSelection() | 2103 i = dlg.GetSelection() |
2269 new_node = self.xml.append(XML(tostring(f_list[i]))) | 2104 new_node = self.xml.append(XML(tostring(f_list[i]))) |
2270 self.grid.AppendRows(1) | 2105 self.grid.AppendRows(1) |
2271 self.n_list = self.xml.findall('armor') | 2106 self.n_list = self.xml.findall('armor') |
2272 self.refresh_row(self.grid.GetNumberRows()-1) | 2107 self.refresh_row(self.grid.GetNumberRows()-1) |
2273 dlg.Destroy() | 2108 dlg.Destroy() |
2274 | 2109 |
2275 | |
2276 def on_size(self,event): | 2110 def on_size(self,event): |
2277 s = self.GetClientSizeTuple() | 2111 s = self.GetClientSizeTuple() |
2278 self.grid.SetDimensions(0,0,s[0],s[1]-25) | 2112 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
2279 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 2113 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
2280 (w,h) = self.grid.GetClientSizeTuple() | 2114 (w,h) = self.grid.GetClientSizeTuple() |
2281 cols = self.grid.GetNumberCols() | 2115 cols = self.grid.GetNumberCols() |
2282 col_w = w/(cols+2) | 2116 col_w = w/(cols+2) |
2283 self.grid.SetColSize(0,col_w*3) | 2117 self.grid.SetColSize(0,col_w*3) |
2284 for i in range(1,cols): | 2118 for i in range(1,cols): self.grid.SetColSize(i,col_w) |
2285 self.grid.SetColSize(i,col_w) | |
2286 | 2119 |
2287 | 2120 |
2288 class class_panel(wx.Panel): | 2121 class class_panel(wx.Panel): |
2289 def __init__(self, parent, handler): | 2122 def __init__(self, parent, handler): |
2290 pname = handler.xml.set("name", 'Class') | 2123 pname = handler.xml.set("name", 'Class') |
2306 self.xml = handler.xml | 2139 self.xml = handler.xml |
2307 self.grid.CreateGrid(len(n_list),2,1) | 2140 self.grid.CreateGrid(len(n_list),2,1) |
2308 self.grid.SetRowLabelSize(0) | 2141 self.grid.SetRowLabelSize(0) |
2309 self.grid.SetColLabelValue(0,"Class") | 2142 self.grid.SetColLabelValue(0,"Class") |
2310 self.grid.SetColLabelValue(1,"Level") | 2143 self.grid.SetColLabelValue(1,"Level") |
2311 for i in range(len(n_list)): | 2144 for i in range(len(n_list)): self.refresh_row(i) |
2312 self.refresh_row(i) | |
2313 self.temp_dom = None | 2145 self.temp_dom = None |
2314 | 2146 |
2315 def on_cell_change(self,evt): | 2147 def on_cell_change(self,evt): |
2316 row = evt.GetRow() | 2148 row = evt.GetRow() |
2317 col = evt.GetCol() | 2149 col = evt.GetCol() |
2318 value = self.grid.GetCellValue(row,col) | 2150 value = self.grid.GetCellValue(row,col) |
2319 try: | 2151 try: |
2320 int(value) | 2152 int(value) |
2321 self.n_list[row].set('level',value) | 2153 self.n_list[row].set('level',value) |
2322 except: | 2154 except: self.grid.SetCellValue(row,col,"1") |
2323 self.grid.SetCellValue(row,col,"1") | |
2324 | 2155 |
2325 def refresh_row(self,i): | 2156 def refresh_row(self,i): |
2326 n = self.n_list[i] | 2157 n = self.n_list[i] |
2327 name = n.get('name') | 2158 name = n.get('name') |
2328 level = n.get('level') | 2159 level = n.get('level') |
2329 self.grid.SetCellValue(i,0,name) | 2160 self.grid.SetCellValue(i,0,name) |
2330 self.grid.SetReadOnly(i,0) | 2161 self.grid.SetReadOnly(i,0) |
2331 self.grid.SetCellValue(i,1,level) | 2162 self.grid.SetCellValue(i,1,level) |
2332 #self.grid.SetReadOnly(i,1) | |
2333 | 2163 |
2334 def on_remove(self,evt): | 2164 def on_remove(self,evt): |
2335 rows = self.grid.GetNumberRows() | 2165 rows = self.grid.GetNumberRows() |
2336 for i in range(rows): | 2166 for i in range(rows): |
2337 if self.grid.IsInSelection(i,0): | 2167 if self.grid.IsInSelection(i,0): |
2342 if not self.temp_dom: | 2172 if not self.temp_dom: |
2343 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20classes.xml") | 2173 tree = parse(orpg.dirpath.dir_struct["d20"]+"d20classes.xml") |
2344 self.temp_dom = tree.getroot() | 2174 self.temp_dom = tree.getroot() |
2345 f_list = self.temp_dom.findall('class') | 2175 f_list = self.temp_dom.findall('class') |
2346 opts = [] | 2176 opts = [] |
2347 for f in f_list: | 2177 for f in f_list: opts.append(f.get('name')) |
2348 opts.append(f.get('name')) | |
2349 dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts) | 2178 dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts) |
2350 if dlg.ShowModal() == wx.ID_OK: | 2179 if dlg.ShowModal() == wx.ID_OK: |
2351 i = dlg.GetSelection() | 2180 i = dlg.GetSelection() |
2352 new_node = self.xml.append(XML(tostring(f_list[i]))) | 2181 new_node = self.xml.append(XML(tostring(f_list[i]))) |
2353 self.grid.AppendRows(1) | 2182 self.grid.AppendRows(1) |
2360 self.grid.SetDimensions(0,0,s[0],s[1]-25) | 2189 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
2361 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 2190 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
2362 (w,h) = self.grid.GetClientSizeTuple() | 2191 (w,h) = self.grid.GetClientSizeTuple() |
2363 cols = self.grid.GetNumberCols() | 2192 cols = self.grid.GetNumberCols() |
2364 col_w = w/(cols) | 2193 col_w = w/(cols) |
2365 for i in range(0,cols): | 2194 for i in range(0,cols): self.grid.SetColSize(i,col_w) |
2366 self.grid.SetColSize(i,col_w) |