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