# HG changeset patch # User sirebral # Date 1259151349 21600 # Node ID 06f10429eedc46d0584fb898ca4d33260ed2461a # Parent c2caca988a11492acf5f26dcb2254d627098d0ac Traipse Alpha '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 (Cleaning up for 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, , , , , , , 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. diff -r c2caca988a11 -r 06f10429eedc orpg/chat/chatwnd.py --- a/orpg/chat/chatwnd.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/chat/chatwnd.py Wed Nov 25 06:15:49 2009 -0600 @@ -1993,7 +1993,8 @@ path = s.split('::') depth = len(path) self.gametree = component.get('tree') - node = self.gametree.tree_map[path[0]]['node'] + try: node = self.gametree.tree_map[path[0]]['node'] + except: return self.data if node.get('class') in ('dnd35char_handler', "SWd20char_handler", "d20char_handler", "dnd3echar_handler"): self.resolve_cust_loop(node, path, 1, depth) elif node.get('class') == 'rpg_grid_handler': self.resolve_grid(node, path, 1, depth) else: self.resolve_loop(node, path, 1, depth) diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/gametree.py --- a/orpg/gametree/gametree.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/gametree.py Wed Nov 25 06:15:49 2009 -0600 @@ -35,10 +35,7 @@ from orpg.orpgCore import component from orpg.dirpath import dir_struct from nodehandlers import core -import string -import urllib -import time -import os +import string, urllib, time, os from orpg.orpg_xml import xml from orpg.tools.validate import validate @@ -87,9 +84,6 @@ def __init__(self, parent, id): wx.TreeCtrl.__init__(self,parent,id, wx.DefaultPosition, wx.DefaultSize,style=wx.TR_EDIT_LABELS | wx.TR_HAS_BUTTONS) - #self.xml = component.get('xml') # - self.settings = component.get('settings') - self.session = component.get('session') self.chat = component.get('chat') self.mainframe = component.get('frame') self.build_img_list() @@ -127,8 +121,7 @@ else: logger.debug("Nodehandler for " + nodehandler + " already exists!") def remove_nodehandler(self, nodehandler): - if self.nodehandlers.has_key(nodehandler): - del self.nodehandlers[nodehandler] + if self.nodehandlers.has_key(nodehandler): del self.nodehandlers[nodehandler] else: logger.debug("No nodehandler for " + nodehandler + " exists!") def init_nodehandlers(self): @@ -154,9 +147,6 @@ self.add_nodehandler('node_loader', core.node_loader) self.add_nodehandler('url_loader', core.url_loader) self.add_nodehandler('min_map', core.min_map) - - # event = wxKeyEvent - # set to be called by wxWindows by EVT_CHAR macro in __init__ def on_key_up(self, evt): key_code = evt.GetKeyCode() @@ -189,7 +179,7 @@ if curSelection: nextSelect = self.GetItemParent(curSelection) self.on_del(evt) - try: + try: if self.GetItemText(nextSelect) != "": self.SelectItem(nextSelect) except: pass elif key_code == wx.WXK_F2: @@ -218,8 +208,7 @@ def load_tree(self, filename=dir_struct["user"]+'tree.xml', error=0): - self.settings.change("gametree", filename) - #check file exists + settings.change("gametree", filename) if not os.path.exists(filename): emsg = "Gametree Missing!\n"+filename+" cannot be found.\n\n"\ "Would you like to locate it?\n"\ @@ -227,13 +216,10 @@ self.locate_valid_tree("Gametree Error", emsg) return try: - f = open(filename, "rb") - tree = parse(f) + tree = parse(filename) self.xml_root = tree.getroot() except: - f.close() self.xml_root = None - ### Alpha ### Doing some work on Gametree to add Element Tree, slowly at first. if not self.xml_root: os.rename(filename,filename+".corrupt") @@ -348,14 +334,12 @@ self.Bind(wx.EVT_MENU, self.on_tree_prop, id=TOP_TREE_PROP) self.Bind(wx.EVT_MENU, self.on_insert_features, id=TOP_FEATURES) - def do_std_menu(self, evt, obj): try: self.std_menu.Enable(STD_MENU_MAP, obj.checkToMapMenu()) except: self.std_menu.Enable(STD_MENU_MAP, obj.map_aware()) self.std_menu.Enable(STD_MENU_CLONE, obj.can_clone()) self.PopupMenu(self.std_menu) - def strip_html(self, player): ret_string = "" x = 0 @@ -369,7 +353,6 @@ logger.debug(ret_string) return ret_string - def on_receive_data(self, data): self.insert_xml(data) @@ -396,11 +379,9 @@ if len(selections) == len(opts): self.chat.ParsePost(obj.tohtml(),True,True) else: player_ids = [] - for s in selections: - player_ids.append(players[s][2]) + for s in selections: player_ids.append(players[s][2]) self.chat.whisper_to_players(obj.tohtml(),player_ids) - def on_export_html(self, evt): f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","HTML (*.html)|*.html",wx.SAVE) if f.ShowModal() == wx.ID_OK: @@ -410,36 +391,30 @@ with open(f.GetPath(),"w") as f: data = ""+obj.xml.get("name")+"" data += ""+obj.tohtml()+"" - for tag in ("","","","","",""): - data = data.replace(tag,tag+"\n") + for tag in ("","","","","",""): data = data.replace(tag,tag+"\n") f.write(data) self.last_save_dir, throwaway = os.path.split( f.GetPath() ) f.Destroy() os.chdir(dir_struct["home"]) - def indifferent(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.usefulness("indifferent") - def useful(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.usefulness("useful") - def useless(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.usefulness("useless") - def on_email(self,evt): pass - def on_send_to(self, evt): players = self.session.get_players() opts = [] @@ -461,7 +436,6 @@ for s in selections: self.session.send(xmldata,players[s][2]) dlg.Destroy() - def on_icon(self, evt): icons = self.icons.keys() icons.sort() @@ -473,7 +447,6 @@ obj.change_icon(key) dlg.Destroy() - def on_wizard(self, evt): item = self.GetSelection() obj = self.GetPyData(item) @@ -485,7 +458,6 @@ self.insert_xml(xml_data) logger.debug(xml_data) - def on_clone(self, evt): item = self.GetSelection() obj = self.GetPyData(item) @@ -497,12 +469,31 @@ if parent_node == self.root: parent_xml = self.GetPyData(parent_node) else: parent_xml = self.GetPyData(parent_node).xml for i in range(len(parent_xml)): - if parent_xml[i] is obj.xml: + if parent_xml[i] is obj.xml: + name = self.clone_renaming(parent_xml, parent_xml[i].get('name')) + clone_xml.set('name', name) parent_xml.insert(i, clone_xml) break - self.load_xml(clone_xml, parent_node, prev_sib) + self.load_xml(clone_xml, parent_node, prev_sib) + + def clone_renaming(self, node, name): + node_list = node.getchildren() + parent = node + append = name.split('_') + try: append_d = int(append[len(append)-1]); del append[len(append)-1] + except: append_d = False + if append_d: + append_d += 1; name = '' + for a in append: name += a+'_' + name = name+str(append_d) + if not append_d: + append_d = 1; name = '' + for a in append: name += a+'_' + name = name+str(append_d) + for n in node_list: + if n.get('name') == name: name = self.clone_renaming(parent, name) + return name - def on_save(self, evt): """save node to a xml file""" item = self.GetSelection() @@ -510,7 +501,6 @@ obj.on_save(evt) os.chdir(dir_struct["home"]) - def on_save_tree_as(self, evt): f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.SAVE) if f.ShowModal() == wx.ID_OK: @@ -519,18 +509,15 @@ f.Destroy() os.chdir(dir_struct["home"]) - def on_save_tree(self, evt=None): - filename = self.settings.get_setting("gametree") + filename = settings.get_setting("gametree") self.save_tree(filename) - def save_tree(self, filename=dir_struct["user"]+'tree.xml'): self.xml_root.set("version", GAMETREE_VERSION) settings.change("gametree", filename) ElementTree(self.xml_root).write(filename) - def on_load_new_tree(self, evt): f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.OPEN) if f.ShowModal() == wx.ID_OK: @@ -539,7 +526,6 @@ f.Destroy() os.chdir(dir_struct["home"]) - def on_insert_file(self, evt): """loads xml file into the tree""" if self.last_save_dir == ".": @@ -551,7 +537,6 @@ f.Destroy() os.chdir(dir_struct["home"]) - def on_insert_url(self, evt): """loads xml url into the tree""" dlg = wx.TextEntryDialog(self,"URL?","Insert URL", "http://") @@ -561,35 +546,29 @@ self.insert_xml(file.read()) dlg.Destroy() - def on_insert_features(self, evt): self.insert_xml(open(dir_struct["template"]+"feature.xml","r").read()) - def on_tree_prop(self, evt): - dlg = gametree_prop_dlg(self, self.settings) + dlg = gametree_prop_dlg(self, settings) if dlg.ShowModal() == wx.ID_OK: pass dlg.Destroy() - def on_node_design(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.on_design(evt) - def on_node_use(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.on_use(evt) - def on_node_pp(self, evt): item = self.GetSelection() obj = self.GetPyData(item) obj.on_html_view(evt) - def on_del(self, evt): status_value = "none" try: @@ -604,31 +583,28 @@ parent_handler = self.GetPyData(parent_item) status_value = parent_handler.get('status') name = parent_handler.get('name') - if status_value == "useless": - break - elif status_value == "useful": - break - except: - status_value = "none" + if status_value == "useless": break + elif status_value == "useful": break + except: status_value = "none" parent_item = self.GetItemParent(parent_item) if status_value == "useful": dlg = wx.MessageDialog(self, `name` + " And everything beneath it are considered useful. \n\nAre you sure you want to delete this item?",'Important Item',wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: handler.delete() else: handler.delete() except: - if self.GetSelection() == self.GetRootItem(): - msg = wx.MessageDialog(None,"You can't delete the root item.","Delete Error",wx.OK) + if self.GetSelection() == self.GetRootItem(): msg = wx.MessageDialog(None,"You can't delete the root item.","Delete Error",wx.OK) else: msg = wx.MessageDialog(None,"Unknown error deleting node.","Delete Error",wx.OK) msg.ShowModal() msg.Destroy() - def on_about(self, evt): item = self.GetSelection() - obj = self.GetPyData(item) - about = MyAboutBox(self,obj.about()) - about.ShowModal() - about.Destroy() + obj = self.GetPyData(item) + text = str(obj.about()) + #about = MyAboutBox(self, obj.about()) + wx.MessageBox(text, 'About')#.ShowModal() + #about.ShowModal() + #about.Destroy() def on_send_to_map(self, evt): item = self.GetSelection() @@ -648,18 +624,13 @@ wx.MessageBox("Error Importing Node or Tree") logger.general("Error Importing Node or Tree") return - if new_xml.tag == "gametree": - for xml_child in new_xml: - self.load_xml(xml_child, self.root) + for xml_child in new_xml: self.load_xml(xml_child, self.root) return - if new_xml.tag == "tree": self.xml_root.append(new_xml.find('nodehandler')) - for xml_child in new_xml: - self.load_xml(xml_child, self.root) + for xml_child in new_xml: self.load_xml(xml_child, self.root) return - self.xml_root.append(new_xml) self.load_xml(new_xml, self.root, self.root) @@ -695,8 +666,7 @@ family_tree = self.get_tree_map(parent_node) family_tree.reverse() map_str = '' #'!@' - for member in family_tree: - map_str += member +'::' + for member in family_tree: map_str += member +'::' map_str = map_str[:len(map_str)-2] #+'@!' xml_element.set('map', map_str) @@ -717,8 +687,7 @@ try: py_class = xml_element.get("class") logger.debug("nodehandler class: " + py_class) - if not self.nodehandlers.has_key(py_class): - raise Exception("Unknown Nodehandler for " + py_class) + if not self.nodehandlers.has_key(py_class): raise Exception("Unknown Nodehandler for " + py_class) self.nodes[self.id] = self.nodehandlers[py_class](xml_element, new_tree_node) self.SetPyData(new_tree_node, self.nodes[self.id]) logger.debug("Node Data set") @@ -769,7 +738,7 @@ self.SelectItem(item) if(isinstance(obj,core.node_handler)): if not obj.on_ldclick(evt): - action = self.settings.get_setting("treedclick") + action = settings.get_setting("treedclick") if action == "use": obj.on_use(evt) elif action == "design": obj.on_design(evt) elif action == "print": obj.on_html_view(evt) @@ -806,8 +775,7 @@ child, cookie = self.GetFirstChild(root) while child.IsOk(): function(child, data) - if recurse: - self.traverse(child, function, data) + if recurse: self.traverse(child, function, data) child, cookie = self.GetNextChild(root, cookie) def on_label_change(self, evt): @@ -825,8 +793,7 @@ else: self.was_labeling = 1 item = evt.GetItem() - if item == self.GetRootItem(): - evt.Veto() + if item == self.GetRootItem(): evt.Veto() def on_drag(self, evt): self.rename_flag = 0 @@ -861,7 +828,6 @@ def __init__(self, parent, settings): wx.Dialog.__init__(self, parent, wx.ID_ANY, "Game Tree Properties") - self.settings = settings #sizers sizers = {} @@ -919,10 +885,10 @@ def on_ok(self,evt): - self.settings.change("gametree",self.ctrls[CTRL_TREE_FILE].GetValue()) - self.settings.change("SaveGameTreeOnExit",str(self.ctrls[CTRL_YES].GetValue())) - if self.ctrls[CTRL_USE].GetValue(): self.settings.change("treedclick","use") - elif self.ctrls[CTRL_DESIGN].GetValue(): self.settings.change("treedclick","design") - elif self.ctrls[CTRL_PRINT].GetValue(): self.settings.change("treedclick","print") - elif self.ctrls[CTRL_CHAT].GetValue(): self.settings.change("treedclick","chat") + settings.change("gametree",self.ctrls[CTRL_TREE_FILE].GetValue()) + settings.change("SaveGameTreeOnExit",str(self.ctrls[CTRL_YES].GetValue())) + if self.ctrls[CTRL_USE].GetValue(): settings.change("treedclick","use") + elif self.ctrls[CTRL_DESIGN].GetValue(): settings.change("treedclick","design") + elif self.ctrls[CTRL_PRINT].GetValue(): settings.change("treedclick","print") + elif self.ctrls[CTRL_CHAT].GetValue(): settings.change("treedclick","chat") self.EndModal(wx.ID_OK) diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/StarWarsd20.py --- a/orpg/gametree/nodehandlers/StarWarsd20.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/StarWarsd20.py Wed Nov 25 06:15:49 2009 -0600 @@ -29,6 +29,7 @@ __version__ = "$Id: StarWarsd20.py,v 1.18 2006/11/15 12:11:23 digitalxero Exp $" from core import * +from containers import * from orpg.tools.orpg_log import debug from xml.etree.ElementTree import parse @@ -50,7 +51,6 @@ for c in children: self.tree.load_xml(c,self.mytree_node) - def on_drop(self,evt): drag_obj = self.tree.drag_obj #if self.is_my_child(self.mytree_node,drag_obj.mytree_node): @@ -73,10 +73,8 @@ html_str += "\n" html_str += "" max = tree.GetChildrenCount(handler.mytree_node) - try: - (child,cookie)=self.tree.GetFirstChild(self.mytree_node,cookie) - except: # If this happens we probably have a newer version of wxPython - (child,cookie)=self.tree.GetFirstChild(self.mytree_node) + try: (child,cookie)=self.tree.GetFirstChild(self.mytree_node,cookie) + except: (child,cookie)=self.tree.GetFirstChild(self.mytree_node) obj = self.tree.GetPyData(child) for m in xrange(max): html_str += "

" + obj.tohtml() @@ -92,17 +90,10 @@ def get_char_name( self ): return self.child_handlers['general'].get_char_name() -## def set_char_pp(self,attr,evl): -## return self.child_handlers['pp'].set_char_pp(attr,evl) -## -## def get_char_pp( self, attr ): -## return self.child_handlers['pp'].get_char_pp(attr) -## def get_char_lvl( self, attr ): return self.child_handlers['classes'].get_char_lvl(attr) - class SWd20char_handler(node_handler): """ Node handler for a SWd20 charactor @@ -149,28 +140,17 @@ range_attack.set("forth","0") range_attack.set("fifth","0") range_attack.set("sixth","0") - gen_list = self.xml.findall('general')[0] for tag in ("currentxp","xptolevel"): node_list = xml_dom.findall(tag) gen_list.append(node_list[0]) - ## temp fix - #parent = self.xml._get_parentNode() - #old_dom = parent.replaceChild(xml_dom,self.xml) - #self.xml = xml_dom print old_version def get_char_name( self ): return self.child_handlers['general'].get_char_name() -## def set_char_pp(self,attr,evl): -## return self.child_handlers['pp'].set_char_pp(attr,evl) -## -## def get_char_pp( self, attr ): -## return self.child_handlers['pp'].get_char_pp(attr) - def get_char_lvl( self, attr ): return self.child_handlers['classes'].get_char_lvl(attr) @@ -191,7 +171,6 @@ def get_use_panel(self,parent): return tabbed_panel(parent,self,2) - def tohtml(self): html_str = "" html_str += "" html_str += "" html_str += "
"+self.child_handlers['general'].tohtml()+"
"+self.child_handlers['abilities'].tohtml() @@ -199,22 +178,21 @@ html_str += "

" + self.child_handlers['attacks'].tohtml() html_str += "

" + self.child_handlers['ac'].tohtml() html_str += "

" + self.child_handlers['feats'].tohtml() - #html_str += "

" + self.child_handlers['spells'].tohtml() - #html_str += "

" + self.child_handlers['divine'].tohtml() - #html_str += "

" + self.child_handlers['powers'].tohtml() html_str += "

" + self.child_handlers['inventory'].tohtml() +"

"+self.child_handlers['classes'].tohtml() html_str += "

" + self.child_handlers['wp'].tohtml() html_str += "

" + self.child_handlers['vp'].tohtml() - #html_str += "

" + self.child_handlers['pp'].tohtml() html_str += "

" + self.child_handlers['skills'].tohtml() +"

" return html_str def about(self): - html_str = "
d20 Character Tool v0.7 beta" + """html_str = "
d20 Character Tool v0.7 beta" html_str += "
by Chris Davis
chris@rpgarchive.com" - return html_str + return html_str""" + text = 'd20 Character Tool 0.7 beta\n' + text += 'by Chris Davis chris@rpgarchive.com' + return text def get_char_name( self ): return self.child_handlers['general'].get_char_name() @@ -228,16 +206,10 @@ return self.child_handlers['vp'].get_max_vp() def get_current_vp( self ): return self.child_handlers['vp'].get_current_vp() - -## def set_char_pp(self,attr,evl): -## return self.child_handlers['pp'].set_char_pp(attr,evl) -## -## def get_char_pp( self, attr ): -## return self.child_handlers['pp'].get_char_pp(attr) - def get_char_lvl( self, attr ): return self.child_handlers['classes'].get_char_lvl(attr) +""" Removed to use the supplied Tabbed Panel class tabbed_panel(wx.Notebook): def __init__(self, parent, handler, mode): wx.Notebook.__init__(self, parent, -1, size=(1200,800)) @@ -253,19 +225,14 @@ obj = tree.GetPyData(child) for m in xrange(max): - if mode == 1: - panel = obj.get_design_panel(self) - else: - panel = obj.get_use_panel(self) + if mode == 1: panel = obj.get_design_panel(self) + else: panel = obj.get_use_panel(self) name = obj.xml.get("name") - - if panel: - self.AddPage(panel,name) + if panel: self.AddPage(panel,name) if m < max-1: child = tree.GetNextSibling(child) obj = tree.GetPyData(child) - def about(self): html_str = "
d20 Character Tool v0.7 beta" html_str += "
by Chris Davis
chris@rpgarchive.com" @@ -274,14 +241,9 @@ def get_char_name( self ): return self.child_handlers['general'].get_char_name() -## def set_char_pp(self,attr,evl): -## return self.child_handlers['pp'].set_char_pp(attr,evl) -## -## def get_char_pp( self, attr ): -## return self.child_handlers['pp'].get_char_pp(attr) - def get_char_lvl( self, attr ): return self.child_handlers['classes'].get_char_lvl(attr) +""" class SWd20_char_child(node_handler): """ Node Handler for skill. This handler will be @@ -294,7 +256,6 @@ self.frame = component.get('frame') self.myeditor = None - def on_drop(self, evt): pass @@ -360,14 +321,11 @@ if item == self.mytree_node: SWd20_char_child.on_ldclick(self,evt) else: - if rank == 0 and untrained == 0: - chat.Post('Can\'t use untrained!',True,True) + if rank == 0 and untrained == 0: chat.Post("Can't use untrained!",True,True) else: mod = self.get_mod(name) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" txt = '%s Skill Check: [1d20%s%s]' % (name, mod1, mod) chat.ParsePost(txt,True,True) @@ -388,10 +346,8 @@ stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) misc = n.get('misc') mod = str(self.get_mod(name)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str = html_str + ""+stat_mod+""+misc+'%s%s' % (mod1, mod) html_str = html_str + "" return html_str @@ -420,10 +376,8 @@ SWd20_char_child.on_ldclick( self, evt ) else: mod = self.get_mod( name ) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" chat = self.chat txt = '%s check: [1d20%s%s]' % ( name, mod1, mod ) chat.ParsePost( txt, True, True ) @@ -451,10 +405,8 @@ abbr = n.get('abbr') base = n.get('base') mod = str(self.get_mod(abbr)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str = html_str + ""+name+""+base+'%s%s' % (mod1, mod) html_str = html_str + "" return html_str @@ -481,8 +433,6 @@ stat_mod = self.char_hander.child_handlers['abilities'].get_mod(stat) base = int(save.get('base')) miscmod = int(save.get('miscmod')) -# magmod = int(save.get('magmod')) -# total = stat_mod + base + miscmod + magmod total = stat_mod + base + miscmod return total @@ -496,10 +446,8 @@ #self.frame.add_panel(wnd) else: mod = self.get_mod(name) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" chat = self.chat txt = '%s save: [1d20%s%s]' % (name, mod1, mod) chat.ParsePost( txt, True, True ) @@ -523,10 +471,8 @@ mag = n.get('magmod') misc = n.get('miscmod') mod = str(self.get_mod(name)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str = html_str + ""+stat_mod+""+mag+"" html_str = html_str + ''+misc+'%s%s' % (mod1, mod) html_str = html_str + "" @@ -577,8 +523,7 @@ def tohtml(self): html_str = "
Classes
" n_list = self.xml.getchildren() - for n in n_list: - html_str += n.get('name') + " ("+n.get('level')+"), " + for n in n_list: html_str += n.get('name') + " ("+n.get('level')+"), " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -587,10 +532,8 @@ for n in node_list: lvl = n.get('level') type = n.get('name') - if attr == "level": - return lvl - elif attr == "class": - return type + if attr == "level": return lvl + elif attr == "class": return type class SWd20feats(SWd20_char_child): @@ -608,8 +551,7 @@ def tohtml(self): html_str = "
Feats
" n_list = self.xml.getchildren() - for n in n_list: - html_str += n.get('name')+ ", " + for n in n_list: html_str += n.get('name')+ ", " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -673,15 +615,11 @@ return html_str def get_max_hp( self ): - try: - return eval( self.xml.get( 'max' ) ) - except: - return 0 + try: return eval( self.xml.get( 'max' ) ) + except: return 0 def get_current_hp( self ): - try: - return eval( self.xml.get( 'current' ) ) - except: - return 0 + try: return eval( self.xml.get( 'current' ) ) + except: return 0 class SWd20vp(SWd20_char_child): """ Node Handler for hit points. This handler will be @@ -703,15 +641,11 @@ return html_str def get_max_vp( self ): - try: - return eval( self.xml.get( 'max' ) ) - except: - return 0 + try: return eval( self.xml.get( 'max' ) ) + except: return 0 def get_current_vp( self ): - try: - return eval( self.xml.get( 'current' ) ) - except: - return 0 + try: return eval( self.xml.get( 'current' ) ) + except: return 0 class SWd20attacks(SWd20_char_child): """ Node Handler for attacks. This handler will be @@ -768,16 +702,12 @@ mod = int(self.weapons[name].get('mod')) if self.weapons[name].get('range') == '0': mod = mod + self.get_mod('m') - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" else: mod = mod + self.get_mod('r') - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" chat = self.chat dmg = self.weapons[name].get('damage') lvl = self.get_char_lvl('level') @@ -815,10 +745,8 @@ n_list = self.xml.findall('weapon') for n in n_list: mod = n.get('mod') - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" ran = n.get('range') total = str(int(mod) + self.get_mod(ran)) html_str += """

@@ -850,10 +778,8 @@ ac_total += self.get_total('bonus') dex_mod = self.char_hander.child_handlers['abilities'].get_mod('Dex') max_dex = self.get_max_dex() - if dex_mod < max_dex: - ac_total += dex_mod - else: - ac_total += max_dex + if dex_mod < max_dex: ac_total += dex_mod + else: ac_total += max_dex return ac_total def get_max_dex(self): @@ -861,15 +787,13 @@ dex = 10 for a in armor_list: temp = int(a.get("maxdex")) - if temp < dex: - dex = temp + if temp < dex: dex = temp return dex def get_total(self,attr): armor_list = self.xml.findall('armor') total = 0 - for a in armor_list: - total += int(a.get(attr)) + for a in armor_list: total += int(a.get(attr)) return total def get_design_panel(self,parent): @@ -909,12 +833,10 @@ def __init__(self, parent): wx.Panel.__init__(self, parent, -1) - #self.build_ctrls() self.Bind(wx.EVT_SIZE, self.on_size) def on_size(self,event): s = self.GetClientSizeTuple() - #self.splitter.SetDimensions(0,0,s[0],s[1]) class outline_panel(wx.Panel): def __init__(self, parent, handler, wnd, txt,): @@ -937,8 +859,7 @@ self.main_sizer = wx.BoxSizer(wx.HORIZONTAL) self.panels = {} keys = handler.child_handlers.keys() - for k in keys: - self.panels[k] = handler.child_handlers[k].get_design_panel(self, [k]) + for k in keys: self.panels[k] = handler.child_handlers[k].get_design_panel(self, [k]) self.sub_sizer = wx.BoxSizer(wx.VERTICAL) self.sub_sizer2 = wx.BoxSizer(wx.VERTICAL) self.sub_sizer.Add(self.panels['general'], 1, wx.EXPAND) @@ -946,16 +867,13 @@ self.sub_sizer.Add(self.panels['attacks'], 2, wx.EXPAND) self.sub_sizer.Add(self.panels['ac'], 1, wx.EXPAND) - #self.sub_sizer.Add(self.panels['spells'], 1, wx.EXPAND) self.sub_sizer2.Add(self.panels['classes'], 2, wx.EXPAND) self.sub_sizer2.Add(self.panels['wp'], 1, wx.EXPAND) self.sub_sizer2.Add(self.panels['vp'], 1, wx.EXPAND) - #self.sub_sizer2.Add(self.panels['pp'], 1, wx.EXPAND) self.sub_sizer2.Add(self.panels['saves'], 2, wx.EXPAND) self.sub_sizer2.Add(self.panels['feats'], 2, wx.EXPAND) - #self.sub_sizer2.Add(self.panels['powers'], 2, wx.EXPAND) self.sub_sizer2.Add(self.panels['skills'], 3, wx.EXPAND) self.main_sizer.Add(self.sub_sizer, 1, wx.EXPAND) @@ -978,8 +896,6 @@ self.panels['saves'].panel.refresh_data() self.panels['skills'].panel.refresh_data() self.panels['attacks'].panel.refresh_data() -# self.panels['powers'].panel.refresh_data() -# self.panels['spells'].panel.refresh_data() HOWTO_MAX = wx.NewId() @@ -1050,58 +966,13 @@ def on_text(self,evt): id = evt.GetId() - if id == VP_CUR: - self.xml.set('current',evt.GetString()) - elif id == VP_MAX: - self.xml.set('max',evt.GetString()) + if id == VP_CUR: self.xml.set('current',evt.GetString()) + elif id == VP_MAX: self.xml.set('max',evt.GetString()) def on_size(self,evt): s = self.GetClientSizeTuple() self.sizer.SetDimension(0,0,s[0],s[1]) -#PP_CUR = wx.NewId() -#PP_MAX = wx.NewId() -#PP_FRE = wx.NewId() -#PP_MFRE = wx.NewId() - -#class pp_panel(wx.Panel): -# def __init__(self, parent, handler): -# wx.Panel.__init__(self, parent, -1) -# pname = handler.xml.set("name", 'PowerPoints') -# self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap -# self.xml = handler.xml -# -# self.sizer.AddMany([ (wx.StaticText(self, -1, "PP Current:"), 0, wx.ALIGN_CENTER_VERTICAL), -# (wx.TextCtrl(self, PP_CUR, self.xml.get('current1')), 0, wx.EXPAND), -# (wx.StaticText(self, -1, "PP Max:"), 0, wx.ALIGN_CENTER_VERTICAL), -# (wx.TextCtrl(self, PP_MAX, self.xml.get('max1')), 0, wx.EXPAND), -# (wx.StaticText(self, -1, "Current Free Talants per day:"), 0, wx.ALIGN_CENTER_VERTICAL), -# (wx.TextCtrl(self, PP_FRE, self.xml.get('free')), 0, wx.EXPAND), -# (wx.StaticText(self, -1, "Max Free Talants per day:"), 0, wx.ALIGN_CENTER_VERTICAL), -# (wx.TextCtrl(self, PP_MFRE, self.xml.get('maxfree')), 0, wx.EXPAND), -# ]) -# self.sizer.AddGrowableCol(1) -# self.Bind(wx.EVT_SIZE, self.on_size) -# self.Bind(wx.EVT_TEXT, self.on_text, id=PP_MAX) -# self.Bind(wx.EVT_TEXT, self.on_text, id=PP_CUR) -# self.Bind(wx.EVT_TEXT, self.on_text, id=PP_FRE) -# self.Bind(wx.EVT_TEXT, self.on_text, id=PP_MFRE) -# -# def on_text(self,evt): -# id = evt.GetId() -# if id == PP_CUR: -# self.xml.set('current1',evt.GetString()) -# elif id == PP_MAX: -# self.xml.set('max1',evt.GetString()) -# elif id == PP_FRE: -# self.xml.set('free',evt.GetString()) -# elif id == PP_MFRE: -# self.xml.set('maxfree',evt.GetString()) -# -# def on_size(self,evt): -# s = self.GetClientSizeTuple() -# self.sizer.SetDimension(0,0,s[0],s[1]) - class gen_grid(wx.grid.Grid): """grid for gen info""" @@ -1117,8 +988,7 @@ self.SetColLabelSize(0) self.n_list = n_list i = 0 - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() @@ -1136,8 +1006,7 @@ (w,h) = self.GetClientSizeTuple() cols = self.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.SetColSize(i,col_w) + for i in range(0,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() @@ -1155,8 +1024,7 @@ self.SetColLabelSize(0) self.n_list = n_list i = 0 - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() @@ -1174,8 +1042,7 @@ (w,h) = self.GetClientSizeTuple() cols = self.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.SetColSize(i,col_w) + for i in range(0,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() @@ -1191,12 +1058,10 @@ self.CreateGrid(len(stats),3) self.SetRowLabelSize(0) col_names = ['Ability','Score','Modifier'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.stats = stats i = 0 - for i in range(len(stats)): - self.refresh_row(i) + for i in range(len(stats)): self.refresh_row(i) self.char_wnd = None def on_cell_change(self,evt): @@ -1207,10 +1072,8 @@ int(value) self.stats[row].set('base',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") - if self.char_wnd: - self.char_wnd.refresh_data() + except: self.SetCellValue(row,col,"0") + if self.char_wnd: self.char_wnd.refresh_data() def refresh_row(self,rowi): s = self.stats[rowi] @@ -1227,14 +1090,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()-1): - self.refresh_row(r) + for r in range(self.GetNumberRows()-1): self.refresh_row(r) class save_grid(wx.grid.Grid): @@ -1250,12 +1111,10 @@ self.CreateGrid(len(saves),7) self.SetRowLabelSize(0) col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.saves = saves i = 0 - for i in range(len(saves)): - self.refresh_row(i) + for i in range(len(saves)):self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() @@ -1263,15 +1122,11 @@ value = self.GetCellValue(row,col) try: int(value) - if col == 2: - self.saves[row].set('base',value) - elif col ==4: - self.saves[row].set('magmod',value) - elif col ==4: - self.saves[row].set('miscmod',value) + if col == 2: self.saves[row].set('base',value) + elif col == 4:self.saves[row].set('magmod',value) + elif col == 4: self.saves[row].set('miscmod',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") + except: self.SetCellValue(row,col,"0") def refresh_row(self,rowi): s = self.saves[rowi] @@ -1295,14 +1150,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()): - self.refresh_row(r) + for r in range(self.GetNumberRows()): self.refresh_row(r) class skill_grid(wx.grid.Grid): @@ -1318,8 +1171,7 @@ self.CreateGrid(len(skills),7) self.SetRowLabelSize(0) col_names = ['Skill','Key','Rank','Abil','Misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) rowi = 0 self.skills = skills for i in range(len(skills)): @@ -1332,15 +1184,11 @@ #print value try: int(value) - if col == 3: - self.skills[row].set('rank',value) - elif col ==5: - self.skills[row].set('misc',value) - elif col == 1: - self.skills[row].set('untrained',value) + if col == 3: self.skills[row].set('rank',value) + elif col == 5: self.skills[row].set('misc',value) + elif col == 1: self.skills[row].set('untrained',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") + except: self.SetCellValue(row,col,"0") def refresh_row(self,rowi): s = self.skills[rowi] @@ -1364,15 +1212,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()): - self.refresh_row(r) - + for r in range(self.GetNumberRows()): self.refresh_row(r) class feat_panel(wx.Panel): @@ -1399,8 +1244,7 @@ self.grid.SetRowLabelSize(0) self.grid.SetColLabelValue(0,"Feat") self.grid.SetColLabelValue(1,"Type") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def refresh_row(self,i): @@ -1425,8 +1269,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('feat') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Feat','Feats',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -1443,8 +1286,7 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) class attack_grid(wx.grid.Grid): """grid for attacks""" @@ -1457,8 +1299,7 @@ self.CreateGrid(2,10) self.SetRowLabelSize(0) col_names = ['Type','base','base 2','base 3','base 4','base 5','base 6','abil','misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.SetCellValue(0,0,"Melee") self.SetCellValue(1,0,"Ranged") self.refresh_data() @@ -1471,23 +1312,15 @@ value = self.GetCellValue(row,col) try: int(value) - if col==1: - self.rows[row].set('base',value) - elif col==2: - self.rows[row].set('second',value) - elif col==3: - self.rows[row].set('third',value) - elif col==4: - self.rows[row].set('forth',value) - elif col==5: - self.rows[row].set('fifth',value) - elif col==6: - self.rows[row].set('sixth',value) - elif col==8: - self.rows[row].set('misc',value) + if col== 1: self.rows[row].set('base',value) + elif col== 2: self.rows[row].set('second',value) + elif col== 3: self.rows[row].set('third',value) + elif col== 4: self.rows[row].set('forth',value) + elif col== 5: self.rows[row].set('fifth',value) + elif col== 6: self.rows[row].set('sixth',value) + elif col== 8: self.rows[row].set('misc',value) self.parent.refresh_data() - except: - self.SetCellValue(row,col,"0") + except: self.SetCellValue(row,col,"0") def refresh_data(self): melee = self.handler.get_attack_data('m') @@ -1504,14 +1337,12 @@ self.SetReadOnly(0,9) self.SetReadOnly(1,9) - def on_size(self,evt): (w,h) = self.GetClientSizeTuple() cols = self.GetNumberCols() col_w = w/(cols+1) self.SetColSize(0,col_w*2) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() @@ -1539,8 +1370,7 @@ self.grid.CreateGrid(len(n_list),9,1) self.grid.SetRowLabelSize(0) col_names = ['Name','damage','mod','critical','type','weight','range','size','Total'] - for i in range(len(col_names)): - self.grid.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) self.refresh_data() self.temp_dom = None @@ -1548,17 +1378,14 @@ row = evt.GetRow() col = evt.GetCol() value = self.grid.GetCellValue(row,col) - if col == 0: - self.n_list[row].set('name',value) + if col == 0: self.n_list[row].set('name',value) elif col == 2: try: int(value) self.n_list[row].set('mod',value) self.refresh_row(row) - except: - self.grid.SetCellValue(row,col,"1") - else: - self.n_list[row].set(self.grid.GetColLabelValue(col),value) + except: self.grid.SetCellValue(row,col,"1") + else: self.n_list[row].set(self.grid.GetColLabelValue(col),value) def refresh_row(self,i): n = self.n_list[i] @@ -1612,19 +1439,16 @@ cols = self.grid.GetNumberCols() col_w = w/(cols+1) self.grid.SetColSize(0,col_w*2) - for i in range(1,cols): - self.grid.SetColSize(i,col_w) + for i in range(1,cols): self.grid.SetColSize(i,col_w) def refresh_data(self): - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class attack_panel(wx.Panel): def __init__(self, parent, handler): pname = handler.xml.set("name", 'Melee') wx.Panel.__init__(self, parent, -1) - self.a_grid = attack_grid(self, handler) self.w_panel = weapon_panel(self, handler) self.sizer = wx.BoxSizer(wx.VERTICAL) @@ -1665,11 +1489,9 @@ col_names = ['Armor','DR','Max Dex','Check Penalty','Weight','Speed (10)','Speed (6)','type'] self.grid.CreateGrid(len(n_list),len(col_names),1) self.grid.SetRowLabelSize(0) - for i in range(len(col_names)): - self.grid.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) self.atts =['name','bonus','maxdex','checkpenalty','weight','speed','speed6','type'] - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None @@ -1681,15 +1503,12 @@ try: int(value) self.n_list[row].set(self.atts[col],value) - except: - self.grid.SetCellValue(row,col,"0") - else: - self.n_list[row].set(self.atts[col],value) + except: self.grid.SetCellValue(row,col,"0") + else: self.n_list[row].set(self.atts[col],value) def refresh_row(self,i): n = self.n_list[i] - for y in range(len(self.atts)): - self.grid.SetCellValue(i,y,n.get(self.atts[y])) + for y in range(len(self.atts)): self.grid.SetCellValue(i,y,n.get(self.atts[y])) def on_remove(self,evt): rows = self.grid.GetNumberRows() @@ -1704,8 +1523,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('armor') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -1722,8 +1540,7 @@ cols = self.grid.GetNumberCols() col_w = w/(cols+2) self.grid.SetColSize(0,col_w*3) - for i in range(1,cols): - self.grid.SetColSize(i,col_w) + for i in range(1,cols): self.grid.SetColSize(i,col_w) class class_panel(wx.Panel): @@ -1751,8 +1568,7 @@ self.grid.SetRowLabelSize(0) self.grid.SetColLabelValue(0,"Class") self.grid.SetColLabelValue(1,"Level") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def on_cell_change(self,evt): @@ -1762,8 +1578,7 @@ try: int(value) self.n_list[row].set('level',value) - except: - self.grid.SetCellValue(row,col,"1") + except: self.grid.SetCellValue(row,col,"1") def refresh_row(self,i): @@ -1773,7 +1588,6 @@ self.grid.SetCellValue(i,0,name) self.grid.SetReadOnly(i,0) self.grid.SetCellValue(i,1,level) - #self.grid.SetReadOnly(i,1) def on_remove(self,evt): rows = self.grid.GetNumberRows() @@ -1788,8 +1602,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('class') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -1806,5 +1619,5 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) + diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/chatmacro.py --- a/orpg/gametree/nodehandlers/chatmacro.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/chatmacro.py Wed Nov 25 06:15:49 2009 -0600 @@ -80,9 +80,6 @@ self.text = {} self.text[P_TITLE] = wx.TextCtrl(self, P_TITLE, handler.master_dom.getAttribute('name')) self.text[P_BODY] = wx.TextCtrl(self, P_BODY, handler.text._get_nodeValue(), style=wx.TE_MULTILINE) - - #P_BODY : wx.TextCtrl(self, P_BODY,handler.text._get_nodeValue(), style=wx.TE_MULTILINE) - sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND) @@ -98,10 +95,8 @@ def on_text(self,evt): id = evt.GetId() txt = self.text[id].GetValue() - if txt == "": - return + if txt == "": return if id == P_TITLE: self.handler.master_dom.setAttribute('name',txt) self.handler.rename(txt) - elif id == P_BODY: - self.handler.set_text(txt) + elif id == P_BODY: self.handler.set_text(txt) diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/containers.py --- a/orpg/gametree/nodehandlers/containers.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/containers.py Wed Nov 25 06:15:49 2009 -0600 @@ -28,11 +28,12 @@ from core import * -from wx.lib.splitter import MultiSplitterWindow - +from wx.lib.splitter import MultiSplitterWindow +from orpg.tools.orpg_log import logger +from orpg.orpgCore import component ########################## -## base contiainer +## base container ########################## class container_handler(node_handler): @@ -44,21 +45,18 @@ self.load_children() def load_children(self): - for child_xml in self.xml: - self.tree.load_xml(child_xml,self.mytree_node) + for child_xml in self.xml: self.tree.load_xml(child_xml,self.mytree_node) def check_map_aware(self, treenode, evt): node = self.tree.GetPyData(treenode) - if hasattr(node,"map_aware") and node.map_aware(): - node.on_send_to_map(evt) + if hasattr(node,"map_aware") and node.map_aware(): node.on_send_to_map(evt) def on_send_to_map(self, evt): self.tree.traverse(self.mytree_node, self.check_map_aware, evt) def checkChildToMap(self, treenode, evt): node = self.tree.GetPyData(treenode) - if hasattr(node,"map_aware") and node.map_aware(): - self.mapcheck = True + if hasattr(node,"map_aware") and node.map_aware(): self.mapcheck = True def checkToMapMenu(self): self.mapcheck = False @@ -67,29 +65,25 @@ def on_drop(self,evt): drag_obj = self.tree.drag_obj - if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node): - return + if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node): return opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL) if opt == wx.YES: drop_xml = self.tree.drag_obj.delete() self.xml.insert(0, drop_xml) self.tree.load_xml(drop_xml, self.mytree_node) self.tree.Expand(self.mytree_node) - elif opt == wx.NO: - node_handler.on_drop(self,evt) + elif opt == wx.NO: node_handler.on_drop(self,evt) def gen_html(self, treenode, evt): node = self.tree.GetPyData(treenode) self.html_str += "

" + node.tohtml() def tohtml(self): - self.html_str = "

Weapon
' % (mod1, mod) html_str = html_str + "
" + self.html_str = "\n" self.html_str += "
" self.html_str += ""+self.xml.get("name") + "" self.html_str += "
" - self.tree.traverse(self.mytree_node, self.gen_html, recurse=False) - self.html_str += "
" return self.html_str @@ -113,16 +107,9 @@ for child_xml in self.xml: if child_xml.get == "group_atts": #having the group attributes as a child is bad! self.xml.remove(child_xml) - elif child_xml: - self.tree.load_xml(child_xml, self.mytree_node) + elif child_xml: self.tree.load_xml(child_xml, self.mytree_node) if not self.xml.get('cols'): self.xml.set('cols', '1') if not self.xml.get('border'): self.xml.set('border', '1') - """ - if not self.atts: - self.atts = Element('group_atts') - self.atts.set("cols","1") - self.atts.set("border","1") - self.xml.append(self.atts)""" def get_design_panel(self,parent): return group_edit_panel(parent,self) @@ -132,25 +119,22 @@ def gen_html(self, treenode, evt): node = self.tree.GetPyData(treenode) - if self.i not in self.tdatas: - self.tdatas[self.i] = '' + if self.i not in self.tdatas: self.tdatas[self.i] = '' self.tdatas[self.i] += "

" + node.tohtml() self.i += 1 - if self.i >= self.cols: - self.i = 0 + if self.i >= self.cols: self.i = 0 def tohtml(self): cols = self.xml.get("cols") border = self.xml.get("border") - self.html_str = "\n" html_str += "
" + self.html_str = "\n" self.cols = int(cols) self.i = 0 self.tdatas = {} self.tree.traverse(self.mytree_node, self.gen_html, recurse=False) - for td in self.tdatas: - self.html_str += "\n"; + for td in self.tdatas: self.html_str += "\n"; self.html_str += "
" self.html_str += ""+self.xml.get("name") + "" self.html_str += "
" + self.tdatas[td] + "" + self.tdatas[td] + "
" return self.html_str @@ -171,13 +155,11 @@ radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"]) cols = handler.xml.get("cols") - if cols != "": - radio_c.SetSelection(int(cols)-1) + if cols != "": radio_c.SetSelection(int(cols)-1) radio_b = wx.RadioBox(self, GROUP_BOR, "Border", choices=["no","yes"]) border = handler.xml.get("border") - if border != "": - radio_b.SetSelection(int(border)) + if border != "": radio_b.SetSelection(int(border)) sizer.Add(radio_c, 0, wx.EXPAND) sizer.Add(wx.Size(10,10)) @@ -196,10 +178,8 @@ def on_radio_box(self,evt): id = evt.GetId() index = evt.GetInt() - if id == GROUP_COLS: - self.handler.xml.set("cols",str(index+1)) - elif id == GROUP_BOR: - self.handler.xml.set("border",str(index)) + if id == GROUP_COLS: self.handler.xml.set("cols",str(index+1)) + elif id == GROUP_BOR: self.handler.xml.set("border",str(index)) def on_text(self,evt): id = evt.GetId() @@ -239,7 +219,13 @@ node = self.handler.tree.GetPyData(treenode) if mode == 1: panel = node.get_design_panel(self) else: panel = node.get_use_panel(self) - name = node.xml.get("name") + name = node.xml.get("name") + if name == None: ## Fixes broken 3e Inventory child + if node.xml.tag == 'inventory': + node.xml.set('name', 'Inventory') + name = "Inventory" + logger.info('A corrective action was take to a 3e PC Sheet', True) + component.get('frame').TraipseSuiteWarn('item') if panel: self.AddPage(panel, name, False) class tabbed_edit_panel(orpgTabberWnd): @@ -314,13 +300,11 @@ if self.split == '1': sash = tmp.GetBestSize()[1]+1 self.bestSizey += sash+11 - if self.bestSizex < tmp.GetBestSize()[0]: - self.bestSizex = tmp.GetBestSize()[0]+10 + if self.bestSizex < tmp.GetBestSize()[0]: self.bestSizex = tmp.GetBestSize()[0]+10 else: sash = tmp.GetBestSize()[0]+1 self.bestSizex += sash - if self.bestSizey < tmp.GetBestSize()[1]: - self.bestSizey = tmp.GetBestSize()[1]+31 + if self.bestSizey < tmp.GetBestSize()[1]: self.bestSizey = tmp.GetBestSize()[1]+31 self.splitter.AppendWindow(tmp, sash) def get_size_constraint(self): return 1 @@ -342,7 +326,6 @@ sizer.Add(self.title, 0) sizer.Add(self.hozCheck, 0, wx.EXPAND) sizer.Add(wx.Size(10,0)) - #sizer.Add(self.splitsize, 1, wx.EXPAND) self.sizer = sizer self.SetSizer(self.sizer) diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/core.py --- a/orpg/gametree/nodehandlers/core.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/core.py Wed Nov 25 06:15:49 2009 -0600 @@ -34,9 +34,8 @@ from orpg.orpg_windows import * from orpg.dirpath import dir_struct from orpg.orpgCore import component - import webbrowser + import webbrowser, os from orpg.mapper import map - import os from wx import DisplaySize except: import wx @@ -74,10 +73,8 @@ (sx,sy,px,py) = [int(value) for value in frame.split(',')] self.frame_size = (sx, sy) (maxx, maxy) = DisplaySize() - if px < maxx-80 and py < maxy-50:#if it's off screen ignore the saved pos - self.frame_pos = (px, py) - except: - pass + if px < maxx-80 and py < maxy-50: self.frame_pos = (px, py) #if it's off screen ignore the saved pos + except: pass def on_version(self,old_version): ## added version control code here or implement a new on_version in your derived class. @@ -91,12 +88,9 @@ return 0 def usefulness(self,text): - if text=="useful": - self.xml.set('status',"useful") - elif text=="useless": - self.xml.set('status',"useless") - elif text=="indifferent": - self.xml.set('status',"indifferent") + if text=="useful": self.xml.set('status',"useful") + elif text=="useless": self.xml.set('status',"useless") + elif text=="indifferent": self.xml.set('status',"indifferent") def on_design(self,evt): try: @@ -146,19 +140,16 @@ del self.mywindow if self.create_useframe(): self.mywindow.SetSize(self.frame_size) - if self.frame_pos: - self.mywindow.SetPosition(self.frame_pos) + if self.frame_pos: self.mywindow.SetPosition(self.frame_pos) self.mywindow.Show() self.mywindow.Raise() - else: - return + else: return wx.CallAfter(self.mywindow.Layout) def create_useframe(self): caption = self.xml.get('name', '') self.mywindow = wx.Frame(None, -1, caption) self.mywindow.Freeze() - if wx.Platform == '__WXMSW__': icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'note.ico', wx.BITMAP_TYPE_ICO) self.mywindow.SetIcon(icon) @@ -259,10 +250,8 @@ def delete(self): """ removes the tree_node and xml_node, and returns the removed xml_node """ parent_node = self.tree.GetItemParent(self.mytree_node) - if parent_node == self.tree.root: - parent_xml = self.tree.GetPyData(parent_node) - else: - parent_xml = self.tree.GetPyData(parent_node).xml + if parent_node == self.tree.root: parent_xml = self.tree.GetPyData(parent_node) + else: parent_xml = self.tree.GetPyData(parent_node).xml parent_xml.remove(self.xml) self.tree.Delete(self.mytree_node) return self.xml @@ -280,8 +269,7 @@ def on_save(self,evt): f = wx.FileDialog(self.tree,"Select a file", orpg.dirpath.dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE) - if f.ShowModal() == wx.ID_OK: - ElementTree(self.xml).write(f.GetPath()) + if f.ShowModal() == wx.ID_OK: ElementTree(self.xml).write(f.GetPath()) f.Destroy() def get_design_panel(self,parent): @@ -301,16 +289,19 @@ return 0 def about(self): - html_str = ""+ self.xml.get('class') + """html_str = ""+ self.xml.get('class') html_str += " Applet
by Chris Davis
chris@rpgarchive.com" - return html_str + return html_str""" + text = self.xml.get('class') + ' Applet\n' + text += 'by Chris Davis chris@rpgarchive.com' + return text def get_value(self): return None +P_TITLE = 10 +P_BODY = 20 -P_TITLE = 10 -P_BODY = 20 class text_edit_panel(wx.Panel): def __init__(self, parent, handler): wx.Panel.__init__(self, parent, -1) @@ -335,10 +326,8 @@ u_txt = "" bad_txt_found = 0 for c in txt: - if ord(c) < 128: - u_txt += c - else: - bad_txt_found = 1 + if ord(c) < 128: u_txt += c + else: bad_txt_found = 1 if bad_txt_found: wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!") txt = u_txt @@ -350,11 +339,8 @@ u_txt = "" bad_txt_found = 0 for c in txt: - if ord(c) < 128: - u_txt += c - else: - bad_txt_found = 1 - + if ord(c) < 128: u_txt += c + else: bad_txt_found = 1 if bad_txt_found: wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!") txt = u_txt @@ -381,8 +367,6 @@ self.tree.root_xml.insert(0, new_xml) tree_node = self.tree.load_xml(new_xml,self.tree.root,self.tree.root) return 1 - #obj = self.tree.GetPyData(tree_node) - #obj.on_design(None) ########################## ## file loader diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/core.py~ --- a/orpg/gametree/nodehandlers/core.py~ Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/core.py~ Wed Nov 25 06:15:49 2009 -0600 @@ -29,19 +29,19 @@ __version__ = "$Id: core.py,v 1.49 2007/12/07 20:39:48 digitalxero Exp $" from nodehandler_version import NODEHANDLER_VERSION + try: from orpg.orpg_windows import * - import orpg.dirpath - from orpg.orpg_xml import * - from orpg.orpgCore import open_rpg - import webbrowser + from orpg.dirpath import dir_struct + from orpg.orpgCore import component + import webbrowser, os from orpg.mapper import map - import os + from wx import DisplaySize except: import wx - - +from xml.etree.ElementTree import ElementTree, Element, tostring, XML +from orpg.tools.orpg_log import debug #html defaults TH_BG = "#E9E9E9" @@ -50,22 +50,31 @@ ########################## class node_handler: """ Base nodehandler with virtual functions and standard implmentations """ - def __init__(self,xml_dom,tree_node): - self.master_dom = xml_dom + def __init__(self,xml,tree_node): + self.xml = xml self.mytree_node = tree_node self.tree = open_rpg.get_component('tree') self.frame = open_rpg.get_component('frame') self.chat = open_rpg.get_component('chat') - self.xml = open_rpg.get_component('xml') self.drag = True self.myeditor = None # designing self.myviewer = None # prett print self.mywindow = None # using # call version hook - self.on_version(self.master_dom.getAttribute("version")) + self.on_version(self.xml.get("version")) # set to current version - self.master_dom.setAttribute("version",NODEHANDLER_VERSION) + self.xml.set("version",NODEHANDLER_VERSION) # null events + self.frame_size = None + self.frame_pos = None + try: + frame = self.xml.get("frame") + if len(frame): + (sx,sy,px,py) = [int(value) for value in frame.split(',')] + self.frame_size = (sx, sy) + (maxx, maxy) = DisplaySize() + if px < maxx-80 and py < maxy-50: self.frame_pos = (px, py) #if it's off screen ignore the saved pos + except: pass def on_version(self,old_version): ## added version control code here or implement a new on_version in your derived class. @@ -78,32 +87,10 @@ def on_ldclick(self,evt): return 0 - def traverse(self, traverseroot, function, cookie=0, event=None, recursive=True): - """ walk tree control """ - if traverseroot.IsOk(): - # step in subtree if there are items or ... - if self.tree.ItemHasChildren(traverseroot) and recursive: - firstchild, cookie = self.tree.GetFirstChild(traverseroot) - obj = self.tree.GetPyData(firstchild) - function(obj, event) - self.traverse(firstchild, function, cookie, event, recursive) - - # ... loop siblings - obj = self.tree.GetPyData(traverseroot) - function(obj, event) - - child = self.tree.GetNextSibling(traverseroot) - if child.IsOk(): - self.traverse(child, function, cookie, event, recursive) - - def usefulness(self,text): - if text=="useful": - self.master_dom.setAttribute('status',"useful") - elif text=="useless": - self.master_dom.setAttribute('status',"useless") - elif text=="indifferent": - self.master_dom.setAttribute('status',"indifferent") + if text=="useful": self.xml.set('status',"useful") + elif text=="useless": self.xml.set('status',"useless") + elif text=="indifferent": self.xml.set('status',"indifferent") def on_design(self,evt): try: @@ -114,13 +101,11 @@ if self.create_designframe(): self.myeditor.Show() self.myeditor.Raise() - else: - return + else: return wx.CallAfter(self.myeditor.Layout) - def create_designframe(self): - title = self.master_dom.getAttribute('name') + " Editor" + title = self.xml.get('name') + " Editor" self.myeditor = wx.Frame(None, -1, title) self.myeditor.Freeze() if wx.Platform == '__WXMSW__': @@ -139,15 +124,12 @@ self.myeditor.SetAutoLayout(True) (x, y) = self.myeditor.GetSize() - if x < 400: - x = 400 - if y < 400: - y = 400 + if x < 400: x = 400 + if y < 400: y = 400 self.myeditor.SetSize((x, y)) self.myeditor.Layout() self.myeditor.Thaw() - return True def on_use(self,evt): @@ -157,18 +139,17 @@ except: del self.mywindow if self.create_useframe(): + self.mywindow.SetSize(self.frame_size) + if self.frame_pos: self.mywindow.SetPosition(self.frame_pos) self.mywindow.Show() self.mywindow.Raise() - else: - return + else: return wx.CallAfter(self.mywindow.Layout) - def create_useframe(self): - caption = self.master_dom.getAttribute('name') + caption = self.xml.get('name', '') self.mywindow = wx.Frame(None, -1, caption) self.mywindow.Freeze() - if wx.Platform == '__WXMSW__': icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'note.ico', wx.BITMAP_TYPE_ICO) self.mywindow.SetIcon(icon) @@ -183,24 +164,28 @@ self.mywindow.SetSizer(sizer) self.mywindow.SetAutoLayout(True) - (x, y) = self.mywindow.GetSize() - if x < 400: - x = 400 - if y < 400: - y = 400 + if self.frame_size is None: + self.frame_size = self.mywindow.GetSize() + if self.frame_size.x < 400: self.frame_size.x = 400 + if self.frame_size.y < 400: self.frame_size.y = 400 - self.mywindow.SetSize((x, y)) self.mywindow.Layout() self.mywindow.Thaw() + self.mywindow.Bind(wx.EVT_CLOSE, self.close_useframe) + return True - return True + def close_useframe(self, evt): + self.frame_size = self.mywindow.GetSize() + self.frame_pos = self.mywindow.GetPosition() + frame_values = str(self.frame_size.x)+','+str(self.frame_size.y)+','+str(self.frame_pos.x)+','+str(self.frame_pos.y) + self.xml.set("frame", frame_values) + self.mywindow.Destroy() def on_html_view(self,evt): - try: - self.myviewer.Raise() + try: self.myviewer.Raise() except: - caption = self.master_dom.getAttribute('name') + caption = self.xml.get('name') self.myviewer = wx.Frame(None, -1, caption) if wx.Platform == '__WXMSW__': icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO) @@ -218,7 +203,7 @@ def on_del(self,evt): print "on del" - def on_new_data(self,xml_dom): + def on_new_data(self,xml): pass def get_scaled_bitmap(self,x,y): @@ -230,52 +215,61 @@ def on_send_to_chat(self,evt): self.chat.ParsePost(self.tohtml(),True,True) - def on_drop(self,evt): - drag_obj = self.tree.drag_obj - if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node): + def on_drop(self, evt): + drag_obj = self.tree.drag_obj + if drag_obj == self or self.tree.is_parent_node(self.mytree_node, drag_obj.mytree_node): return - #if self.is_my_child(self.mytree_node,drag_obj.mytree_node): - # return - xml_dom = self.tree.drag_obj.delete() - parent = self.master_dom._get_parentNode() - xml_dom = parent.insertBefore(xml_dom,self.master_dom) + drop_xml = self.tree.drag_obj.delete() parent_node = self.tree.GetItemParent(self.mytree_node) prev_sib = self.tree.GetPrevSibling(self.mytree_node) + if parent_node == self.tree.root: parent_xml = self.tree.GetPyData(parent_node) + else: parent_xml = self.tree.GetPyData(parent_node).xml + for i in range(len(parent_xml)): + if parent_xml[i] is self.xml: + parent_xml.insert(i, drop_xml) + break if not prev_sib.IsOk(): prev_sib = parent_node - self.tree.load_xml(xml_dom, parent_node, prev_sib) + self.tree.load_xml(drop_xml, parent_node, prev_sib) + + def get_tree(self): + family = [] + test = treenode + while test != self.tree.root: + test = self.tree.GetItemParent(test) + parent = self.tree.GetItemText(test) + family.append(parent) + return family def toxml(self,pretty=0): - return toxml(self.master_dom,pretty) + return tostring(self.xml) #toxml(self.master_dom,pretty) def tohtml(self): - return self.master_dom.getAttribute("name") + return self.xml.get("name") def delete(self): """ removes the tree_node and xml_node, and returns the removed xml_node """ - + parent_node = self.tree.GetItemParent(self.mytree_node) + if parent_node == self.tree.root: parent_xml = self.tree.GetPyData(parent_node) + else: parent_xml = self.tree.GetPyData(parent_node).xml + parent_xml.remove(self.xml) self.tree.Delete(self.mytree_node) - parent = self.master_dom._get_parentNode() - return parent.removeChild(self.master_dom) + return self.xml def rename(self,name): if len(name): self.tree.SetItemText(self.mytree_node,name) - self.master_dom.setAttribute('name', name) + self.xml.set('name', name) def change_icon(self,icon): - self.master_dom.setAttribute("icon",icon) + self.xml.set("icon",icon) self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon]) self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon], wx.TreeItemIcon_Selected) self.tree.Refresh() def on_save(self,evt): f = wx.FileDialog(self.tree,"Select a file", orpg.dirpath.dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE) - if f.ShowModal() == wx.ID_OK: - type = f.GetFilterIndex() - file = open(f.GetPath(),"w") - file.write(self.toxml(1)) - file.close() + if f.ShowModal() == wx.ID_OK: ElementTree(self.xml).write(f.GetPath()) f.Destroy() def get_design_panel(self,parent): @@ -286,31 +280,36 @@ def get_html_panel(self,parent): html_str = ""+self.tohtml()+"" - wnd = wx.HTMLpanel(parent,-1) + wnd = wx.html.HtmlWindow(parent,-1) html_str = self.chat.ParseDice(html_str) - wnd.load_text(html_str) + wnd.SetPage(html_str) return wnd def get_size_constraint(self): return 0 def about(self): - html_str = ""+ self.master_dom.getAttribute('class') + """html_str = ""+ self.xml.get('class') html_str += " Applet
by Chris Davis
chris@rpgarchive.com" - return html_str + return html_str""" + text = self.xml.get('class') + 'Applet\n' + text += 'by Chris Davis chris@rpgarchive.com' + return text + + def get_value(self): + return None P_TITLE = 10 -P_BODY = 20 +P_BODY = 20 + class text_edit_panel(wx.Panel): def __init__(self, parent, handler): wx.Panel.__init__(self, parent, -1) self.handler = handler sizer = wx.BoxSizer(wx.VERTICAL) - self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.master_dom.getAttribute('name')), - P_BODY : html_text_edit(self,P_BODY,handler.text._get_nodeValue(),self.on_text) + self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')), + P_BODY : html_text_edit(self,P_BODY,handler.text,self.on_text) } - #P_BODY : wx.TextCtrl(self, P_BODY,handler.text._get_nodeValue(), style=wx.TE_MULTILINE) - sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND) @@ -327,26 +326,21 @@ u_txt = "" bad_txt_found = 0 for c in txt: - if ord(c) < 128: - u_txt += c - else: - bad_txt_found = 1 + if ord(c) < 128: u_txt += c + else: bad_txt_found = 1 if bad_txt_found: wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!") txt = u_txt if txt != "": - self.handler.master_dom.setAttribute('name',txt) + self.handler.xml.set('name',txt) self.handler.rename(txt) elif id == P_BODY: txt = self.text[id].get_text() u_txt = "" bad_txt_found = 0 for c in txt: - if ord(c) < 128: - u_txt += c - else: - bad_txt_found = 1 - + if ord(c) < 128: u_txt += c + else: bad_txt_found = 1 if bad_txt_found: wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!") txt = u_txt @@ -361,22 +355,18 @@ """ clones childe node and insert it at top of tree """ - def __init__(self,xml_dom,tree_node): - node_handler.__init__(self,xml_dom,tree_node) + def __init__(self,xml,tree_node): + node_handler.__init__(self,xml,tree_node) def on_rclick(self,evt): pass def on_ldclick(self,evt): - title = self.master_dom.getAttribute('name') - new_node = self.master_dom._get_firstChild() - new_node = new_node.cloneNode(True) - child = self.tree.master_dom._get_firstChild() - new_node = self.tree.master_dom.insertBefore(new_node,child) - tree_node = self.tree.load_xml(new_node,self.tree.root,self.tree.root) - obj = self.tree.GetPyData(tree_node) + title = self.xml.get('name') + new_xml = XML(tostring(self.xml[0])) + self.tree.root_xml.insert(0, new_xml) + tree_node = self.tree.load_xml(new_xml,self.tree.root,self.tree.root) return 1 - #obj.on_design(None) ########################## ## file loader @@ -388,25 +378,25 @@ """ - def __init__(self,xml_dom,tree_node): - node_handler.__init__(self,xml_dom,tree_node) - self.file_node = self.master_dom._get_firstChild() + def __init__(self,xml,tree_node): + node_handler.__init__(self,xml,tree_node) + self.file_node = self.xml[0] self.frame = open_rpg.get_component('frame') def on_ldclick(self,evt): - file_name = self.file_node.getAttribute("name") + file_name = self.file_node.get("name") self.tree.insert_xml(open(orpg.dirpath.dir_struct["nodes"] + file_name,"r").read()) return 1 def on_design(self,evt): tlist = ['Title','File Name'] - vlist = [self.master_dom.getAttribute("name"), - self.file_node.getAttribute("name")] + vlist = [self.xml.get("name"), + self.file_node.get("name")] dlg = orpgMultiTextEntry(self.tree.GetParent(),tlist,vlist,"File Loader Edit") if dlg.ShowModal() == wx.ID_OK: vlist = dlg.get_values() - self.file_node.setAttribute('name', vlist[1]) - self.master_dom.setAttribute('name', vlist[0]) + self.file_node.set('name', vlist[1]) + self.xml.set('name', vlist[0]) self.tree.SetItemText(self.mytree_node,vlist[0]) dlg.Destroy() @@ -420,27 +410,27 @@ """ - def __init__(self,xml_dom,tree_node): - node_handler.__init__(self,xml_dom,tree_node) - self.file_node = self.master_dom._get_firstChild() + def __init__(self,xml,tree_node): + node_handler.__init__(self,xml,tree_node) + self.file_node = self.xml[0] self.frame = open_rpg.get_component('frame') def on_ldclick(self,evt): - file_name = self.file_node.getAttribute("url") + file_name = self.file_node.get("url") file = urllib.urlopen(file_name) self.tree.insert_xml(file.read()) return 1 def on_design(self,evt): tlist = ['Title','URL'] - print "design filename",self.master_dom.getAttribute('name') - vlist = [self.master_dom.getAttribute("name"), - self.file_node.getAttribute("url")] + print "design filename",self.xml.get('name') + vlist = [self.xml.get("name"), + self.file_node.get("url")] dlg = orpgMultiTextEntry(self.tree.GetParent(),tlist,vlist,"File Loader Edit") if dlg.ShowModal() == wx.ID_OK: vlist = dlg.get_values() - self.file_node.setAttribute('url', vlist[1]) - self.master_dom.setAttribute('name', vlist[0]) + self.file_node.set('url', vlist[1]) + self.xml.set('name', vlist[0]) self.tree.SetItemText(self.mytree_node,vlist[0]) dlg.Destroy() @@ -452,11 +442,11 @@ """ clones childe node and insert it at top of tree """ - def __init__(self,xml_dom,tree_node): - node_handler.__init__(self,xml_dom,tree_node) + def __init__(self,xml,tree_node): + node_handler.__init__(self,xml,tree_node) self.map = open_rpg.get_component('map') - self.mapdata = self.master_dom._get_firstChild() + self.mapdata = self.xml[0] def on_ldclick(self,evt): - self.map.new_data(toxml(self.mapdata)) + self.map.new_data(tostring(self.mapdata)) return 1 diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/d20.py --- a/orpg/gametree/nodehandlers/d20.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/d20.py Wed Nov 25 06:15:49 2009 -0600 @@ -28,7 +28,8 @@ __version__ = "$Id: d20.py,v 1.30 2007/05/22 00:50:57 digitalxero Exp $" -from core import * +from core import * +from containers import * import re from xml.etree.ElementTree import ElementTree, Element, iselement from xml.etree.ElementTree import fromstring, tostring, parse, XML @@ -54,21 +55,16 @@ for c in children: self.tree.load_xml(c,self.mytree_node) - def on_drop(self,evt): drag_obj = self.tree.drag_obj - #if self.is_my_child(self.mytree_node,drag_obj.mytree_node): - # return - if drag_obj == self: - return + if drag_obj == self: return opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL) if opt == wx.YES: xml = self.tree.drag_obj.delete() xml = self.xml.append(xml,None) self.tree.load_xml(xml, self.mytree_node) self.tree.Expand(self.mytree_node) - elif opt == wx.NO: - node_handler.on_drop(self,evt) + elif opt == wx.NO: node_handler.on_drop(self,evt) def tohtml(self): cookie = 0 @@ -76,19 +72,16 @@ html_str += ""+self.xml.get("name") + "" html_str += "
" - max = tree.GetChildrenCount(handler.mytree_node,0) - try: - (child,cookie)=self.tree.GetFirstChild(self.mytree_node,cookie) - except: # If this happens we probably have a newer version of wxPython - (child,cookie)=self.tree.GetFirstChild(self.mytree_node) + try: (child,cookie)=self.tree.GetFirstChild(self.mytree_node,cookie) + # If this happens we probably have a newer version of wxPython + except: (child,cookie)=self.tree.GetFirstChild(self.mytree_node) obj = self.tree.GetPyData(child) for m in range(max): html_str += "

" + obj.tohtml() if m < max-1: child = self.tree.GetNextSibling(child) - if child.IsOk(): - obj = self.tree.GetPyData(child) + if child.IsOk(): obj = self.tree.GetPyData(child) html_str += "

" return html_str @@ -108,7 +101,6 @@ return self.child_handlers['classes'].get_char_lvl(attr) - class d20char_handler(node_handler): """ Node handler for a d20 charactor @@ -132,10 +124,8 @@ self.new_child_handler('pp','Power Points',d20pp,'gear') self.new_child_handler('attacks','Attacks',d20attacks,'spears') self.new_child_handler('ac','Armor',d20armor,'spears') - #wxMenuItem(self.tree.std_menu, D20_EXPORT, "Export...", "Export") self.myeditor = None - def on_version(self,old_version): node_handler.on_version(self,old_version) if old_version == "": @@ -159,12 +149,7 @@ gen_list = self.xml.find('general') - for tag in ("currentxp","xptolevel"): - gen_list.append(data.find(tag)) - ## temp fix - #parent = self.xml._get_parentNode() - #old_dom = parent.replaceChild(xml,self.xml) - #self.xml = xml + for tag in ("currentxp","xptolevel"): gen_list.append(data.find(tag)) print old_version @@ -180,7 +165,6 @@ def get_char_lvl( self, attr ): return self.child_handlers['classes'].get_char_lvl(attr) - def new_child_handler(self,tag,text,handler_class,icon='gear'): tree = self.tree i = self.tree.icons[icon] @@ -192,11 +176,9 @@ def get_design_panel(self,parent): return tabbed_panel(parent,self,1) - def get_use_panel(self,parent): return tabbed_panel(parent,self,2) - def tohtml(self): html_str = "" html_str += "' % (mod1, mod) html_str = html_str + "
"+self.child_handlers['general'].tohtml()+"
"+self.child_handlers['abilities'].tohtml() @@ -216,9 +198,12 @@ return html_str def about(self): - html_str = "
d20 Character Tool v0.7 beta" + """html_str = "
d20 Character Tool v0.7 beta" html_str += "
by Chris Davis
chris@rpgarchive.com" - return html_str + return html_str""" + text = 'd20 Character Tool 0.7 beta\n' + text += 'by Chris Davis chris@rpgarchive.com' + return text def get_char_name( self ): return self.child_handlers['general'].get_char_name() @@ -238,6 +223,7 @@ def get_char_lvl( self, attr ): return self.child_handlers['classes'].get_char_lvl(attr) +""" Removed to use the supplied Tabbed Panel class tabbed_panel(wx.Notebook): def __init__(self, parent, handler, mode): wx.Notebook.__init__(self, parent, -1, size=(1200,800)) @@ -245,32 +231,22 @@ self.parent = parent tree = self.handler.tree max = tree.GetChildrenCount(handler.mytree_node) - cookie = 0 - try: - (child,cookie)=tree.GetFirstChild(handler.mytree_node,cookie) - except: # If this happens we probably have a newer version of wxPython - (child,cookie)=tree.GetFirstChild(handler.mytree_node) - if not child.IsOk(): - return + try: (child,cookie)=tree.GetFirstChild(handler.mytree_node,cookie) + # If this happens we probably have a newer version of wxPython + except: (child,cookie)=tree.GetFirstChild(handler.mytree_node) + if not child.IsOk(): return obj = tree.GetPyData(child) for m in range(max): - if mode == 1: - panel = obj.get_design_panel(self) - else: - panel = obj.get_use_panel(self) + if mode == 1: panel = obj.get_design_panel(self) + else: panel = obj.get_use_panel(self) name = obj.xml.get("name") - - if panel: - self.AddPage(panel,name) + if panel: self.AddPage(panel,name) if m < max-1: child = tree.GetNextSibling(child) - if child.IsOk(): - obj = tree.GetPyData(child) - else: - break - + if child.IsOk(): obj = tree.GetPyData(child) + else: break def about(self): html_str = "
d20 Character Tool v0.7 beta" @@ -288,7 +264,7 @@ def get_char_lvl( self, attr ): return self.child_handlers['classes'].get_char_lvl(attr) - +""" class d20_char_child(node_handler): """ Node Handler for skill. This handler will be created by d20char_handler. @@ -369,23 +345,16 @@ def on_rclick(self,evt): item = self.tree.GetSelection() name = self.tree.GetItemText(item) - if item == self.mytree_node: - d20_char_child.on_ldclick(self,evt) - #wnd = skill_grid(self.frame.note,self) - #wnd.title = "Skills - #self.frame.add_panel(wnd) + if item == self.mytree_node: d20_char_child.on_ldclick(self,evt) else: skill = self.skills[name]; untrained = skill.get('untrained'); rank = skill.get('rank'); - if untrained == "0" and rank == "0": - txt = '%s Skill Check: Untrained' % (name) + if untrained == "0" and rank == "0": txt = '%s Skill Check: Untrained' % (name) else: mod = self.get_mod(name) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" txt = '%s Skill Check: [1d20%s%s]' % (name, mod1, mod) chat = self.chat chat.ParsePost(txt,True,True) @@ -406,10 +375,8 @@ stat_mod = str(self.char_hander.child_handlers['abilities'].get_mod(stat)) misc = n.get('misc') mod = str(self.get_mod(name)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str = html_str + "
"+stat_mod+""+misc+'%s%s
" return html_str @@ -437,10 +404,8 @@ d20_char_child.on_ldclick( self, evt ) else: mod = self.get_mod( name ) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" chat = self.chat txt = '%s check: [1d20%s%s]' % ( name, mod1, mod ) chat.ParsePost( txt, True, True ) @@ -467,10 +432,8 @@ abbr = n.get('abbr') base = n.get('base') mod = str(self.get_mod(abbr)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str = html_str + "

"+name+""+base+'%s%s
" return html_str @@ -506,15 +469,11 @@ name = self.tree.GetItemText(item) if item == self.mytree_node: d20_char_child.on_ldclick(self,evt) - #wnd = save_grid(self.frame.note,self) - #wnd.title = "Saves" - #self.frame.add_panel(wnd) + else: mod = self.get_mod(name) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" chat = self.chat txt = '%s save: [1d20%s%s]' % (name, mod1, mod) chat.ParsePost( txt, True, True ) @@ -537,10 +496,8 @@ mag = n.get('magmod') misc = n.get('miscmod') mod = str(self.get_mod(name)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str = html_str + ""+stat_mod+""+mag+"" html_str = html_str + ''+misc+'%s%s' % (mod1, mod) html_str = html_str + "" @@ -588,8 +545,7 @@ def tohtml(self): html_str = "
Classes
" - for n in self.xml: - html_str += n.get('name') + " ("+n.get('level')+"), " + for n in self.xml: html_str += n.get('name') + " ("+n.get('level')+"), " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -597,10 +553,8 @@ for n in self.xml.findall('class'): lvl = n.get('level') type = n.get('name') - if attr == "level": - return lvl - elif attr == "class": - return type + if attr == "level": return lvl + elif attr == "class": return type class d20feats(d20_char_child): @@ -617,8 +571,7 @@ def tohtml(self): html_str = "
Feats
" - for n in self.xml: - html_str += n.get('name')+ ", " + for n in self.xml: html_str += n.get('name')+ ", " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -658,8 +611,7 @@ txt = '%s casts %s ( level %s, "%s" )' % ( cname, name, level, descr ) self.chat.ParsePost( txt, True, False ) s = '' - if left != 1: - s = 's' + if left != 1: s = 's' txt = '%s can cast %s %d more time%s' % ( cname, name, left, s ) self.chat.ParsePost( txt, False, False ) self.spells[ name ].set( 'used', `eval( use )` ) @@ -682,8 +634,7 @@ def tohtml(self): html_str = "
Arcane Spells

" - for n in self.xml: - html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " + for n in self.xml: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -725,8 +676,7 @@ txt = '%s casts %s ( level %s, "%s" )' % ( cname, name, level, descr ) self.chat.ParsePost( txt, True, False ) s = '' - if left != 1: - s = 's' + if left != 1: s = 's' txt = '%s can cast %s %d more time%s' % ( cname, name, left, s ) self.chat.ParsePost( txt, False, False ) self.spells[ name ].set( 'used', `eval( use )` ) @@ -749,8 +699,7 @@ def tohtml(self): html_str = "
Divine Spells

" - for n in self.xml: - html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " + for n in self.xml: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -796,8 +745,7 @@ txt = '%s uses %s as a Free Talent ( level %s, "%s" )' % ( cname, name, level, descr ) self.chat.ParsePost( txt, True, False ) s = '' - if left != 1: - s = 's' + if left != 1: s = 's' txt = '%s can use %s %d more time%s' % ( cname, name, numcast, s ) self.chat.ParsePost( txt, False, False ) self.char_hander.set_char_pp('free', left) @@ -811,8 +759,7 @@ txt = '%s uses %s ( level %s, "%s" )' % ( cname, name, level, descr ) self.chat.ParsePost( txt, True, False ) s = '' - if left != 1: - s = 's' + if left != 1: s = 's' txt = '%s can use %s %d more time%s' % ( cname, name, numcast, s ) txt += ' - And has %d more Powerpoints left' % (left) self.chat.ParsePost( txt, False, False ) @@ -836,8 +783,7 @@ def tohtml(self): html_str = "
Powers

" - for n in self.xml: - html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " + for n in self.xml: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -909,15 +855,11 @@ return html_str def get_max_hp( self ): - try: - return eval( self.xml.get( 'max' ) ) - except: - return 0 + try: return eval( self.xml.get( 'max' ) ) + except: return 0 def get_current_hp( self ): - try: - return eval( self.xml.get( 'current' ) ) - except: - return 0 + try: return eval( self.xml.get( 'current' ) ) + except: return 0 class d20pp(d20_char_child): """ Node Handler for power points. This handler will be @@ -1023,8 +965,7 @@ # Base attack bonuses for up to six attacks. bab_attributes = ['base', 'second', 'third', 'forth', 'fifth', 'sixth'] bab = [] - for b in bab_attributes: - bab.append( int(self.melee.get( b )) ) + for b in bab_attributes: bab.append( int(self.melee.get( b )) ) # Misc. attack modifier to be applied to *all* attacks. misc_mod = int(self.melee.get( 'misc' )); @@ -1033,24 +974,18 @@ attack_mod = misc_mod + eval( attack_mod_str ) # Total damage mod (except extra dice) - if damage_mods != '': - damage_mod = eval( damage_mods ) - else: - damage_mod = 0 + if damage_mods != '': damage_mod = eval( damage_mods ) + else: damage_mod = 0 # Determine critical hit range and multiplier. critical_str = self.weapons[name].get( 'critical' ) m = re.match( r"(((?P\d+)-)?\d+/)?x(?P\d+)", critical_str ) crit_min = m.group( 'min' ) crit_mult = m.group( 'mult' ) - if crit_min == None: - crit_min = 20 - else: - crit_min = int( crit_min ) - if crit_mult == None: - crit_mult = 2 - else: - crit_mult = int( crit_mult ) + if crit_min == None: crit_min = 20 + else: crit_min = int( crit_min ) + if crit_mult == None: crit_mult = 2 + else: crit_mult = int( crit_mult ) # Simple matter to output all the attack/damage lines to the chat buffer. for i in range( 0, len( bab ) ): @@ -1067,8 +1002,7 @@ d20_roll = int(re.match( r".*\[(\d+),.*", attack_roll_parsed ).group(1)); dmg = damage_str if d20_roll >= crit_min: - for j in range(1,crit_mult): - dmg += '+%s' % damage_str + for j in range(1,crit_mult): dmg += '+%s' % damage_str txt = 'Critical hit? [1d20%+d] ===> Damage: [%dd%d%+d%s]' \ % (bab[i] + attack_mod, crit_mult*num_damage_dice, \ damage_die, crit_mult*damage_mod, extra_damage) @@ -1087,8 +1021,7 @@ html_str = "" html_str += '" html_str += '
Base Attack Bonus%+d' % babs[0] for i in range(1,6): - if babs[i] > 0: - html_str += '/%+d' % babs[i] + if babs[i] > 0: html_str += '/%+d' % babs[i] html_str += "
Misc. Attack Bonus%+d
' % babs[6] @@ -1133,10 +1066,8 @@ ac_total += self.get_total('bonus') dex_mod = self.char_hander.child_handlers['abilities'].get_mod('Dex') max_dex = self.get_max_dex() - if dex_mod < max_dex: - ac_total += dex_mod - else: - ac_total += max_dex + if dex_mod < max_dex: ac_total += dex_mod + else: ac_total += max_dex return ac_total def get_max_dex(self): @@ -1144,15 +1075,13 @@ dex = 10 for a in armor_list: temp = int(a.get("maxdex")) - if temp < dex: - dex = temp + if temp < dex: dex = temp return dex def get_total(self,attr): armor_list = self.xml.findall('armor') total = 0 - for a in armor_list: - total += int(a.get(attr)) + for a in armor_list: total += int(a.get(attr)) return total def get_design_panel(self,parent): @@ -1220,8 +1149,7 @@ self.main_sizer = wx.BoxSizer(wx.HORIZONTAL) self.panels = {} keys = handler.child_handlers.keys() - for k in keys: - self.panels[k] = handler.child_handlers[k].get_design_panel(self, [k]) + for k in keys: self.panels[k] = handler.child_handlers[k].get_design_panel(self, [k]) self.sub_sizer = wx.BoxSizer(wx.VERTICAL) self.sub_sizer2 = wx.BoxSizer(wx.VERTICAL) self.sub_sizer.Add(self.panels['general'], 1, wx.EXPAND) @@ -1300,10 +1228,8 @@ def on_text(self,evt): id = evt.GetId() - if id == HP_CUR: - self.xml.set('current',evt.GetString()) - elif id == HP_MAX: - self.xml.set('max',evt.GetString()) + if id == HP_CUR: self.xml.set('current',evt.GetString()) + elif id == HP_MAX: self.xml.set('max',evt.GetString()) def on_size(self,evt): s = self.GetClientSizeTuple() @@ -1340,14 +1266,10 @@ def on_text(self,evt): id = evt.GetId() - if id == PP_CUR: - self.xml.set('current1',evt.GetString()) - elif id == PP_MAX: - self.xml.set('max1',evt.GetString()) - elif id == PP_FRE: - self.xml.set('free',evt.GetString()) - elif id == PP_MFRE: - self.xml.set('maxfree',evt.GetString()) + if id == PP_CUR: self.xml.set('current1',evt.GetString()) + elif id == PP_MAX: self.xml.set('max1',evt.GetString()) + elif id == PP_FRE: self.xml.set('free',evt.GetString()) + elif id == PP_MFRE: self.xml.set('maxfree',evt.GetString()) def on_size(self,evt): s = self.GetClientSizeTuple() @@ -1368,8 +1290,7 @@ self.SetColLabelSize(0) self.n_list = n_list i = 0 - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() @@ -1387,8 +1308,7 @@ (w,h) = self.GetClientSizeTuple() cols = self.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.SetColSize(i,col_w) + for i in range(0,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() @@ -1406,8 +1326,7 @@ self.SetColLabelSize(0) self.n_list = n_list i = 0 - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() @@ -1425,8 +1344,7 @@ (w,h) = self.GetClientSizeTuple() cols = self.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.SetColSize(i,col_w) + for i in range(0,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() @@ -1442,12 +1360,10 @@ self.CreateGrid(len(stats),3) self.SetRowLabelSize(0) col_names = ['Ability','Score','Modifier'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.stats = stats i = 0 - for i in range(len(stats)): - self.refresh_row(i) + for i in range(len(stats)): self.refresh_row(i) self.char_wnd = None def on_cell_change(self,evt): @@ -1458,10 +1374,8 @@ int(value) self.stats[row].set('base',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") - if self.char_wnd: - self.char_wnd.refresh_data() + except: self.SetCellValue(row,col,"0") + if self.char_wnd: self.char_wnd.refresh_data() def refresh_row(self,rowi): s = self.stats[rowi] @@ -1478,14 +1392,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()-1): - self.refresh_row(r) + for r in range(self.GetNumberRows()-1): self.refresh_row(r) class save_grid(wx.grid.Grid): @@ -1501,12 +1413,10 @@ self.CreateGrid(len(saves),7) self.SetRowLabelSize(0) col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.saves = saves i = 0 - for i in range(len(saves)): - self.refresh_row(i) + for i in range(len(saves)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() @@ -1514,15 +1424,11 @@ value = self.GetCellValue(row,col) try: int(value) - if col == 2: - self.saves[row].set('base',value) - elif col ==4: - self.saves[row].set('magmod',value) - elif col ==4: - self.saves[row].set('miscmod',value) + if col == 2: self.saves[row].set('base',value) + elif col == 4: self.saves[row].set('magmod',value) + elif col == 4: self.saves[row].set('miscmod',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") + except: self.SetCellValue(row,col,"0") def refresh_row(self,rowi): s = self.saves[rowi] @@ -1546,14 +1452,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()): - self.refresh_row(r) + for r in range(self.GetNumberRows()): self.refresh_row(r) class skill_grid(wx.grid.Grid): @@ -1569,12 +1473,10 @@ self.CreateGrid(len(skills),6) self.SetRowLabelSize(0) col_names = ['Skill','Key','Rank','Abil','Misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) rowi = 0 self.skills = skills - for i in range(len(skills)): - self.refresh_row(i) + for i in range(len(skills)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() @@ -1582,13 +1484,10 @@ value = self.GetCellValue(row,col) try: int(value) - if col == 2: - self.skills[row].set('rank',value) - elif col ==4: - self.skills[row].set('misc',value) + if col == 2: self.skills[row].set('rank',value) + elif col == 4: self.skills[row].set('misc',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") + except: self.SetCellValue(row,col,"0") def refresh_row(self,rowi): s = self.skills[rowi] @@ -1611,15 +1510,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()): - self.refresh_row(r) - + for r in range(self.GetNumberRows()): self.refresh_row(r) class feat_panel(wx.Panel): @@ -1643,8 +1539,7 @@ self.grid.SetRowLabelSize(0) self.grid.SetColLabelValue(0,"Feat") self.grid.SetColLabelValue(1,"Type") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None self.SetSizer(self.sizer) @@ -1670,8 +1565,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('feat') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Feat','Feats',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -1688,8 +1582,7 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) class spell_panel(wx.Panel): def __init__(self, parent, handler): @@ -1719,16 +1612,14 @@ self.grid.SetColLabelValue(1,"Lvl") self.grid.SetColLabelValue(2,"Spell") self.grid.SetColLabelValue(3,"Desc") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() value = self.grid.GetCellValue(row,col) - if col == 0: - self.n_list[row].set('memrz',value) + if col == 0: self.n_list[row].set('memrz',value) def refresh_row(self,i): spell = self.n_list[i] @@ -1758,16 +1649,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('spell') opts = [] - # lvl = int(self.handler.get_char_lvl('level')) - # castlvl = lvl / 2 - for f in f_list: - opts.append("(" + f.get('level') + ")" + f.get('name')) - # spelllvl = f.get('level') - # if spelllvl <= "1": - # opts.append("(" + f.get('level') + ")" + f.get('name')) - # else: - # if eval('%d >= %s' %(castlvl, spelllvl)): - # opts.append("(" + f.get('level') + ")" + f.get('name')) + for f in f_list: opts.append("(" + f.get('level') + ")" + f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -1780,8 +1662,7 @@ def on_refresh_spells( self, evt ): f_list = self.xml.findall('spell') - for spell in f_list: - spell.set( 'used', '0' ) + for spell in f_list: spell.set( 'used', '0' ) def on_size(self,event): s = self.GetClientSizeTuple() @@ -1790,16 +1671,14 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) self.grid.SetColSize(0,w * 0.10) self.grid.SetColSize(1,w * 0.10) self.grid.SetColSize(2,w * 0.30) self.grid.SetColSize(3,w * 0.50) def refresh_data(self): - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class divine_panel(wx.Panel): def __init__(self, parent, handler): @@ -1829,16 +1708,14 @@ self.grid.SetColLabelValue(1,"Lvl") self.grid.SetColLabelValue(2,"Spell") self.grid.SetColLabelValue(3,"Desc") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() value = self.grid.GetCellValue(row,col) - if col == 0: - self.n_list[row].set('memrz',value) + if col == 0: self.n_list[row].set('memrz',value) def refresh_row(self,i): @@ -1869,16 +1746,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('gift') opts = [] - # lvl = int(self.handler.get_char_lvl('level')) - # castlvl = lvl / 2 - for f in f_list: - opts.append("(" + f.get('level') + ")" + f.get('name')) - # spelllvl = f.get('level') - # if spelllvl <= "1": - # opts.append("(" + f.get('level') + ")" + f.get('name')) - # else: - # if eval('%d >= %s' %(castlvl, spelllvl)): - # opts.append("(" + f.get('level') + ")" + f.get('name')) + for f in f_list: opts.append("(" + f.get('level') + ")" + f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -1891,8 +1759,7 @@ def on_refresh_spells( self, evt ): f_list = self.xml.findall('gift') - for spell in f_list: - spell.set( 'used', '0' ) + for spell in f_list: spell.set( 'used', '0' ) def on_size(self,event): s = self.GetClientSizeTuple() @@ -1901,16 +1768,14 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) self.grid.SetColSize(0,w * 0.10) self.grid.SetColSize(1,w * 0.10) self.grid.SetColSize(2,w * 0.30) self.grid.SetColSize(3,w * 0.50) def refresh_data(self): - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class power_panel(wx.Panel): @@ -1941,8 +1806,7 @@ self.grid.SetColLabelValue(2,"Power") self.grid.SetColLabelValue(3,"Desc") self.grid.SetColLabelValue(4,"Type") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.refresh_data() self.temp_dom = None self.SetSizer(self.sizer) @@ -1951,9 +1815,6 @@ row = evt.GetRow() col = evt.GetCol() value = self.grid.GetCellValue(row,col) - """if col == 0: - self.n_list[row].set('memrz',value)""" - def refresh_row(self,i): power = self.n_list[i] @@ -1987,16 +1848,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('power') opts = [] - # lvl = int(self.handler.get_char_lvl('level')) - # castlvl = lvl / 2 - for f in f_list: - opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) - # spelllvl = f.get('level') - # if spelllvl <= "1": - # opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) - # else: - # if eval('%d >= %s' %(castlvl, spelllvl)): - # opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) + for f in f_list: opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) dlg = wx.SingleChoiceDialog(self,'Choose Power','Powers',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -2016,7 +1868,6 @@ self.n_list = self.xml.findall('weapon') self.handler.refresh_weapons() - def on_refresh_powers( self, evt ): mfre = self.handler.get_char_pp('maxfree') mpp = self.handler.get_char_pp('max1') @@ -2030,8 +1881,7 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) self.grid.SetColSize(0,w * 0.05) self.grid.SetColSize(1,w * 0.05) self.grid.SetColSize(2,w * 0.30) @@ -2039,8 +1889,7 @@ self.grid.SetColSize(4,w * 0.30) def refresh_data(self): - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class attack_grid(wx.grid.Grid): """grid for attacks""" @@ -2053,8 +1902,7 @@ self.CreateGrid(1,7) self.SetRowLabelSize(0) col_names = ['base','base 2','base 3','base 4','base 5','base 6','misc'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.refresh_data() self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) @@ -2063,8 +1911,7 @@ row = evt.GetRow() col = evt.GetCol() value = self.GetCellValue(row,col) - try: - int(value) + try: int(value) except: value = "0" self.SetCellValue( row, col, value ) @@ -2074,15 +1921,13 @@ def refresh_data(self): attack_mods = self.handler.get_attack_data() - for i in range(0,7): - self.SetCellValue( 0, i, str(attack_mods[i]) ) + for i in range(0,7): self.SetCellValue( 0, i, str(attack_mods[i]) ) def on_size(self,evt): (w,h) = self.GetClientSizeTuple() cols = self.GetNumberCols() col_w = w/cols - for i in range(0,cols): - self.SetColSize(i,col_w) + for i in range(0,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() @@ -2107,8 +1952,7 @@ self.grid.CreateGrid(len(n_list),8,1) self.grid.SetRowLabelSize(0) col_names = ['Name','damage','mod','critical','type','weight','range','size'] - for i in range(len(col_names)): - self.grid.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) self.refresh_data() self.temp_dom = None self.SetSizer(self.sizer) @@ -2120,8 +1964,7 @@ if col == 0: self.n_list[row].set('name',value) self.handler.refresh_weapons(); - else: - self.n_list[row].set(self.grid.GetColLabelValue(col),value) + else: self.n_list[row].set(self.grid.GetColLabelValue(col),value) def refresh_row(self,i): n = self.n_list[i] @@ -2152,8 +1995,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('weapon') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -2172,12 +2014,10 @@ cols = self.grid.GetNumberCols() col_w = w/(cols+1) self.grid.SetColSize(0,col_w*2) - for i in range(1,cols): - self.grid.SetColSize(i,col_w) + for i in range(1,cols): self.grid.SetColSize(i,col_w) def refresh_data(self): - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class attack_panel(wx.Panel): @@ -2222,11 +2062,9 @@ col_names = ['Armor','bonus','maxdex','cp','sf','weight','speed','type'] self.grid.CreateGrid(len(n_list),len(col_names),1) self.grid.SetRowLabelSize(0) - for i in range(len(col_names)): - self.grid.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) self.atts =['name','bonus','maxdex','checkpenalty','spellfailure','weight','speed','type'] - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None self.SetSizer(self.sizer) @@ -2238,10 +2076,8 @@ try: int(value) self.n_list[row].set(self.atts[col],value) - except: - self.grid.SetCellValue(row,col,"0") - else: - self.n_list[row].set(self.atts[col],value) + except: self.grid.SetCellValue(row,col,"0") + else: self.n_list[row].set(self.atts[col],value) def refresh_row(self,i): n = self.n_list[i] @@ -2261,8 +2097,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('armor') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -2272,7 +2107,6 @@ self.refresh_row(self.grid.GetNumberRows()-1) dlg.Destroy() - def on_size(self,event): s = self.GetClientSizeTuple() self.grid.SetDimensions(0,0,s[0],s[1]-25) @@ -2281,8 +2115,7 @@ cols = self.grid.GetNumberCols() col_w = w/(cols+2) self.grid.SetColSize(0,col_w*3) - for i in range(1,cols): - self.grid.SetColSize(i,col_w) + for i in range(1,cols): self.grid.SetColSize(i,col_w) class class_panel(wx.Panel): @@ -2308,8 +2141,7 @@ self.grid.SetRowLabelSize(0) self.grid.SetColLabelValue(0,"Class") self.grid.SetColLabelValue(1,"Level") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def on_cell_change(self,evt): @@ -2319,8 +2151,7 @@ try: int(value) self.n_list[row].set('level',value) - except: - self.grid.SetCellValue(row,col,"1") + except: self.grid.SetCellValue(row,col,"1") def refresh_row(self,i): n = self.n_list[i] @@ -2329,7 +2160,6 @@ self.grid.SetCellValue(i,0,name) self.grid.SetReadOnly(i,0) self.grid.SetCellValue(i,1,level) - #self.grid.SetReadOnly(i,1) def on_remove(self,evt): rows = self.grid.GetNumberRows() @@ -2344,8 +2174,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('class') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -2362,5 +2191,4 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/dnd35.py --- a/orpg/gametree/nodehandlers/dnd35.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/dnd35.py Wed Nov 25 06:15:49 2009 -0600 @@ -1,5 +1,3 @@ -#from orpg.tools.orpg_settings import settings #Settings used? -#import orpg.minidom from core import * from containers import * from string import * #a 1.6003 @@ -25,11 +23,7 @@ def safeGetAttr(node, label, defRetV=None): cna=node.attrib for key in cna: - if key == label: - return cna[key] - #retV=node.get(lable) # get does not distingish between - # the attribute not being present vs it having a value of "" - # This is bad for this routine, thus not used. + if key == label: return cna[key] return defRetV #a 1.6... safeGetAttr end. @@ -42,11 +36,8 @@ def __init__(self,xml_dom,tree_node): node_handler.__init__(self,xml_dom,tree_node) self.Version = "v1.000" #a 1.6000 general documentation, usage. - print "dnd35char_handler - version:",self.Version #m 1.6000 - self.hparent = None #a 1.5002 allow ability to run up tree, this is the - self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('general','GeneralInformation',dnd35general,'gear') @@ -54,10 +45,8 @@ self.new_child_handler('character','ClassesAndStats',dnd35classnstats,'knight') self.new_child_handler('snf','SkillsAndFeats',dnd35skillsnfeats,'book') self.new_child_handler('combat','Combat',dnd35combat,'spears') - self.myeditor = None - def new_child_handler(self,tag,text,handler_class,icon='gear'): node_list = self.xml.findall(tag) tree = self.tree @@ -70,7 +59,6 @@ def get_design_panel(self,parent): return tabbed_panel(parent,self,1) - def get_use_panel(self,parent): return tabbed_panel(parent,self,2) @@ -86,17 +74,18 @@ html_str += ""+self.classes.tohtml() html_str += "

" + self.hp.tohtml() html_str += "

" + self.skills.tohtml() +"" - #a block for 1.6009 end - html_str += "" return html_str def about(self): - html_str = "" #m 1.6000 was hard coded. html_str += "
by Dj Gilcrease
digitalxero@gmail.com" - return html_str + return html_str""" + text = 'dnd35 Character Tool' + self.Version +'\n' + text += 'by Dj Gilcrease digitalxero@gmail.com' + return text ########Core Handlers are done now############ ########Onto the Sub Nodes######## @@ -125,7 +114,6 @@ self.frame = component.get('frame') self.myeditor = None - def on_drop(self,evt): pass @@ -181,7 +169,6 @@ #o 1.5002 self.char_hander = parent in this case. self.charName = name #a 1.5002 make getting name easier. - def get_char_name( self ): node = self.xml.findall( 'name' )[0] return node.text @@ -192,10 +179,7 @@ pname = handler.xml.set("name", 'General') self.hparent = handler #a 1.5002 allow ability to run up tree, needed # a 1.5002 parent is functional parent, not invoking parent. - - wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) self.handler = handler n_list = handler.xml.getchildren() @@ -204,8 +188,7 @@ self.SetColLabelSize(0) self.n_list = n_list i = 0 - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() @@ -213,10 +196,8 @@ value = self.GetCellValue(row,col) t_node = self.n_list[row] t_node.text = value - if row==0: - self.handler.on_name_change(value) - #self.AutoSizeColumn(1) - + if row==0: self.handler.on_name_change(value) + def refresh_row(self, rowi): self.SetCellValue(rowi, 0, self.n_list[rowi].tag) self.SetReadOnly(rowi, 0) @@ -250,57 +231,40 @@ class inventory_pane(wx.Panel): def __init__(self, parent, handler): wx.Panel.__init__(self, parent, wx.ID_ANY) - self.n_list = handler.xml.getchildren() self.autosize = False - - self.sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Inventroy"), wx.VERTICAL) - + self.sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Inventory"), wx.VERTICAL) self.lang = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Languages") self.gear = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Gear") self.magic = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Magic") self.grid = wx.grid.Grid(self, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) - self.grid.CreateGrid(len(self.n_list)-3,2) self.grid.SetRowLabelSize(0) self.grid.SetColLabelSize(0) - - for i in xrange(len(self.n_list)): - self.refresh_row(i) - + for i in xrange(len(self.n_list)): self.refresh_row(i) sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(self.grid, 1, wx.EXPAND) sizer1.Add(self.lang, 1, wx.EXPAND) - self.sizer.Add(sizer1, 0, wx.EXPAND) - sizer2 = wx.BoxSizer(wx.HORIZONTAL) sizer2.Add(self.gear, 1, wx.EXPAND) sizer2.Add(self.magic, 1, wx.EXPAND) - self.sizer.Add(sizer2, 1, wx.EXPAND) - self.SetSizer(self.sizer) self.SetAutoLayout(True) self.Fit() - self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.lang) self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.gear) self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.magic) self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.on_cell_change, self.grid) - def fillTextNode(self, name, value): - if name == 'Languages': - self.lang.SetValue(value) - elif name == 'Gear': - self.gear.SetValue(value) - elif name == 'Magic': - self.magic.SetValue(value) + if name == 'Languages': self.lang.SetValue(value) + elif name == 'Gear': self.gear.SetValue(value) + elif name == 'Magic': self.magic.SetValue(value) def onTextNodeChange(self, event): id = event.GetId() - if id == self.gear.GetId(): nodeName = 'Gear' value = self.gear.GetValue() @@ -310,10 +274,8 @@ elif id == self.lang.GetId(): nodeName = 'Languages' value = self.lang.GetValue() - for node in self.n_list: - if node._get_tagName() == nodeName: - node.text = value + if node._get_tagName() == nodeName: node.text = value def saveMoney(self, row, col): value = self.grid.GetCellValue(row, col) @@ -325,17 +287,12 @@ self.grid.AutoSizeColumn(col) wx.CallAfter(self.saveMoney, row, col) - - def refresh_row(self, row): tagname = self.n_list[row].tag value = self.n_list[row].text - if tagname == 'Gear': - self.fillTextNode(tagname, value) - elif tagname == 'Magic': - self.fillTextNode(tagname, value) - elif tagname == 'Languages': - self.fillTextNode(tagname, value) + if tagname == 'Gear': self.fillTextNode(tagname, value) + elif tagname == 'Magic': self.fillTextNode(tagname, value) + elif tagname == 'Languages': self.fillTextNode(tagname, value) else: self.grid.SetCellValue(row, 0, tagname) self.grid.SetReadOnly(row, 0) @@ -358,7 +315,6 @@ self.new_child_handler('saves','Saves',dnd35saves,'skull') self.myeditor = None - def new_child_handler(self,tag,text,handler_class,icon='gear'): node_list = self.xml.findall(tag) tree = self.tree @@ -371,7 +327,6 @@ def get_design_panel(self,parent): return tabbed_panel(parent,self,1) - def get_use_panel(self,parent): return tabbed_panel(parent,self,2) @@ -431,20 +386,14 @@ self.abilities[name] = n new_tree_node = tree.AppendItem( self.mytree_node, name, icons['gear'], icons['gear'] ) tree.SetPyData( new_tree_node, self ) - #print "dnd35ability - init self.abilities",self.abilities #a (debug) 1.5002 def on_rclick( self, evt ): item = self.tree.GetSelection() name = self.tree.GetItemText( item ) - #if item == self.mytree_node: #d 1.6016 - # dnd35_char_child.on_ldclick( self, evt ) #d 1.6016 if not item == self.mytree_node: #a 1.6016 - #else: #d 1.6016 mod = self.get_mod( name ) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" chat = self.chat txt = '%s check: [1d20%s%s]' % ( name, mod1, mod ) chat.ParsePost( txt, True, True ) @@ -456,8 +405,7 @@ return mod def set_score(self,abbr,score): - if score >= 0: - self.abilities[abbr].set("base",str(score)) + if score >= 0: self.abilities[abbr].set("base",str(score)) def get_design_panel(self,parent): wnd = outline_panel(parent,self,abil_grid,"Abilities") @@ -473,10 +421,8 @@ abbr = n.get('abbr') base = n.get('base') mod = str(self.get_mod(abbr)) - if int(mod) >= 0: #m 1.6013 added "int(" and ")" - mod1 = "+" - else: - mod1 = "" + if int(mod) >= 0: mod1 = "+" + else: mod1 = "" html_str = (html_str + ""+ name+""+base+'%s%s' % (mod1, mod)) html_str = html_str + "" @@ -488,8 +434,6 @@ pname = handler.xml.set("name", 'Stats') self.hparent = handler #a 1.5002 allow ability to run up tree. self.root = getRoot(self) - #a 1.5002 in this case, we need the functional parent, not the invoking parent. - wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) @@ -498,33 +442,26 @@ self.CreateGrid(len(stats),3) self.SetRowLabelSize(0) col_names = ['Ability','Score','Modifier'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.stats = stats i = 0 - for i in range(len(stats)): - self.refresh_row(i) + for i in range(len(stats)): self.refresh_row(i) self.char_wnd = None def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() value = self.GetCellValue(row,col) - #print value try: int(value) self.stats[row].set('base',value) self.refresh_row(row) except: self.SetCellValue(row,col,"0") - if self.char_wnd: - self.char_wnd.refresh_data() - - #mark5 + if self.char_wnd: self.char_wnd.refresh_data() def refresh_row(self,rowi): s = self.stats[rowi] - name = s.get('name') abbr = s.get('abbr') self.SetCellValue(rowi,0,name) @@ -532,10 +469,6 @@ self.SetCellValue(rowi,1,s.get('base')) self.SetCellValue(rowi,2,str(self.handler.get_mod(abbr))) self.SetReadOnly(rowi,2) - #if self.root.saves.saveGrid: #a 1.6018 d 1.9002 whole if clause - #print getmembers(self.root.saves.saveGrid) - #self.root.saves.saveGrid.refresh_data() #a 1.6018 - #print "skipping saving throw update, put back in later" self.root.saves.refresh_data() #a 1.9002 self.root.attacks.refreshMRdata() #a 1.9001 ` @@ -544,14 +477,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()-1): - self.refresh_row(r) + for r in range(self.GetNumberRows()-1): self.refresh_row(r) class dnd35classes(class_char_child): """ Node Handler for classes. This handler will be @@ -562,7 +493,6 @@ self.hparent = parent #a 1.5002 allow ability to run up tree. self.root = getRoot(self) self.root.classes = self - #a 1.5002 in this case, we need the functional parent, not the invoking parent. def get_design_panel(self,parent): wnd = outline_panel(parent,self,class_panel,"Classes") @@ -572,41 +502,31 @@ def tohtml(self): html_str = "
Classes
" n_list = self.xml.getchildren() - for n in n_list: - html_str += n.get('name') + " ("+n.get('level')+"), " + for n in n_list: html_str += n.get('name') + " ("+n.get('level')+"), " html_str = html_str[:len(html_str)-2] + "
" return html_str def get_char_lvl( self, attr ): node_list = self.xml.findall('class') - # print "eclasses - get_char_lvl node_list",node_list tot = 0 #a 1.5009 actually, slipping in a quick enhancement ;-) for n in node_list: - lvl = n.get('level') #o 1.5009 not sure of the value of this - tot += int(lvl) #a 1.5009 - type = n.get('name') #o 1.5009 not sure of the value of this - #print type,lvl #a (debug) 1.5009 - if attr == "level": - return lvl #o 1.5009 this returns the level of someone's first class. ??? - elif attr == "class": - return type #o 1.5009 this returns one of the char's classes. ??? - if attr == "lvl": #a 1.5009 this has value, adding this. - return tot #a 1.5009 return character's "overall" level. + lvl = n.get('level') + tot += int(lvl) + type = n.get('name') + if attr == "level": return lvl + elif attr == "class": return type + if attr == "lvl": return tot - def get_class_lvl( self, classN ): #a 1.5009 need to be able to get monk lvl - #a 1.5009 this function is new. + def get_class_lvl( self, classN ): node_list = self.xml.findall('class') - #print "eclasses - get_class_lvl node_list",node_list for n in node_list: lvl = n.get('level') type = n.get('name') - if classN == type: - return lvl + if classN == type: return lvl class class_panel(wx.Panel): def __init__(self, parent, handler): pname = handler.xml.set("name", 'Class') - wx.Panel.__init__(self, parent, -1) self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) sizer = wx.BoxSizer(wx.VERTICAL) @@ -635,8 +555,7 @@ self.grid.SetColLabelValue(0,"Class") self.grid.SetColLabelValue(1,"Level") self.grid.SetColLabelValue(2,"Refrence") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def on_cell_change(self,evt): @@ -646,13 +565,11 @@ try: int(value) self.n_list[row].set('level',value) - except: - self.grid.SetCellValue(row,col,"1") + except: self.grid.SetCellValue(row,col,"1") def refresh_row(self,i): n = self.n_list[i] - name = n.get('name') level = n.get('level') book = n.get('book') @@ -679,8 +596,7 @@ self.temp_dom = xml_dom f_list = self.temp_dom.findall('class') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -689,7 +605,6 @@ self.refresh_row(self.grid.GetNumberRows()-1) dlg.Destroy() - def on_size(self,event): s = self.GetClientSizeTuple() self.grid.SetDimensions(0,0,s[0],s[1]-25) @@ -697,8 +612,7 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) class dnd35saves(class_char_child): @@ -708,7 +622,6 @@ def __init__(self,xml_dom,tree_node,parent): class_char_child.__init__(self,xml_dom,tree_node,parent) self.hparent = parent #a 1.5002 allow ability to run up tree. - #self.saveGrid = None #a 1.6018 d 1.9002 self.saveGridFrame = [] #a 1.9002 handle list, check frame for close. tree = self.tree @@ -730,17 +643,13 @@ # count backwards, maintains context despite "removes" for i in range(len(self.saveGridFrame)-1,-1,-1): x = self.saveGridFrame[i] - if x == None: - x.refresh_data() - else: - self.saveGridFrame.remove(x) + if x == None: x.refresh_data() + else: self.saveGridFrame.remove(x) def get_mod(self,name): save = self.saves[name] stat = save.get('stat') - #print "dnd35saves, get_mod: self,root",self,self.root #a (debug) 1.5002 - #print "and abilities",self.root.abilities #a (debug) 1.5002 - stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 + stat_mod = self.root.abilities.get_mod(stat) base = int(save.get('base')) miscmod = int(save.get('miscmod')) magmod = int(save.get('magmod')) @@ -754,17 +663,10 @@ if item == self.mytree_node: pass #a 1.5003 syntatic place holder return #a 1.5003 - #print "failure mode!" - #dnd35_char_child.on_ldclick(self,evt) #d 1.5003 this busted - #wnd = save_grid(self.frame.note,self) - #wnd.title = "Saves" - #self.frame.add_panel(wnd) else: mod = self.get_mod(name) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" chat = self.chat txt = '%s save: [1d20%s%s]' % (name, mod1, mod) chat.ParsePost( txt, True, True ) @@ -785,17 +687,12 @@ stat = n.get('stat') base = n.get('base') html_str = html_str + ""+name+""+stat+""+base+"" - #stat_mod = str(dnd_globals["stats"][stat]) #d 1.5002 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 - mag = n.get('magmod') misc = n.get('miscmod') mod = str(self.get_mod(name)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" - #m 1.5009 next line. added str() around stat_mod + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str = html_str + ""+str(stat_mod)+""+mag+"" html_str = html_str + ''+misc+'%s%s' % (mod1, mod) html_str = html_str + "" @@ -809,10 +706,6 @@ self.hparent = handler #a 1.5002 allow ability to run up tree. #a 1.5002 in this case, we need the functional parent, not the invoking parent. self.root = getRoot(self) - - #self.hparent.saveGrid = self #a 1.6018 d 1.9001 - - wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) @@ -821,15 +714,10 @@ self.CreateGrid(len(saves),7) self.SetRowLabelSize(0) col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.saves = saves i = 0 - for i in range(len(saves)): - self.refresh_row(i) - - - #a 1.9002 remainder of code in this method. + for i in range(len(saves)): self.refresh_row(i) climber = parent nameNode = climber.GetClassName() while nameNode != 'wxFrame': @@ -837,8 +725,6 @@ nameNode = climber.GetClassName() masterFrame=climber masterFrame.refresh_data=self.refresh_data - #print getmembers(masterFrame) - handler.saveGridFrame.append(masterFrame) def on_cell_change(self,evt): @@ -847,19 +733,14 @@ value = self.GetCellValue(row,col) try: int(value) - if col == 2: - self.saves[row].set('base',value) - elif col ==4: - self.saves[row].set('magmod',value) - elif col ==5: # 1.5001 - self.saves[row].set('miscmod',value) + if col == 2: self.saves[row].set('base',value) + elif col == 4: self.saves[row].set('magmod',value) + elif col == 5: self.saves[row].set('miscmod',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") + except: self.SetCellValue(row,col,"0") def refresh_row(self,rowi): s = self.saves[rowi] - name = s.get('name') self.SetCellValue(rowi,0,name) self.SetReadOnly(rowi,0) @@ -880,14 +761,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()): - self.refresh_row(r) + for r in range(self.GetNumberRows()): self.refresh_row(r) class dnd35skillsnfeats(dnd35_char_child): """ Node handler for a dnd35 charactor @@ -896,7 +775,6 @@ def __init__(self,xml_dom,tree_node,parent): self.hparent = parent #a 1.5002 allow ability to run up tree. self.root = getRoot(self) #a 1.6009 - node_handler.__init__(self,xml_dom,tree_node) dnd35_char_child.__init__(self,xml_dom,tree_node,parent) self.frame = component.get('frame') @@ -905,7 +783,6 @@ self.new_child_handler('feats','Feats',dnd35feats,'book') self.myeditor = None - def new_child_handler(self,tag,text,handler_class,icon='gear'): node_list = self.xml.findall(tag) tree = self.tree @@ -918,7 +795,6 @@ def get_design_panel(self,parent): return tabbed_panel(parent,self,1) - def get_use_panel(self,parent): return tabbed_panel(parent,self,2) @@ -933,8 +809,6 @@ self.frame = component.get('frame') self.myeditor = None - - def on_drop(self,evt): pass @@ -983,17 +857,12 @@ skill_check = self.skills[name] ranks = int(skill_check.get('rank')) trained = int(skill_check.get('untrained')) - if ranks > 0 or trained == 1: new_tree_node = tree.AppendItem(self.mytree_node,name, icons['gear'],icons['gear']) - else: - continue - + else: continue tree.SetPyData(new_tree_node,self) - - def refresh_skills(self): #Adding this so when you update the grid the tree will reflect #The change. -mgt @@ -1009,19 +878,15 @@ skill_check = self.skills[name] ranks = int(skill_check.get('rank')) trained = int(skill_check.get('untrained')) - if ranks > 0 or trained == 1: new_tree_node = tree.AppendItem(self.mytree_node,name, icons['gear'],icons['gear']) - else: - continue - + else: continue tree.SetPyData(new_tree_node,self) def get_mod(self,name): skill = self.skills[name] stat = skill.get('stat') - #stat_mod = int(dnd_globals["stats"][stat]) #d 1.5002 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 rank = int(skill.get('rank')) misc = int(skill.get('misc')) @@ -1031,18 +896,9 @@ def on_rclick(self,evt): item = self.tree.GetSelection() name = self.tree.GetItemText(item) - #print "skill rc self",self #a 1.6004 - #print "skill rc tree",self.mytree_node #a 1.6004 - #print "skill rc item",item #a 1.6004 - if item == self.mytree_node: - return - # following line fails, - #dnd35_char_child.on_ldclick(self,evt) #d 1.6014 - # it's what it used to try to do. + if item == self.mytree_node: return ac = self.root.ac.get_check_pen() #a 1.5002 for 1.5004 verify fix. - skill = self.skills[name] - untr = skill.get('untrained') #a 1.6004 rank = skill.get('rank') #a 1.6004 if eval('%s == 0' % (untr)): #a 1.6004 @@ -1052,26 +908,19 @@ chat = self.chat #a 1.6004 chat.Post(txt,True,True) #a 1.6004 return #a 1.6004 - armor = '' acCp = '' if ac < 0: #acCp >= 1 #m 1.5004 this is stored as negatives. armorCheck = int(skill.get('armorcheck')) - #print "ac,armorCheck",ac,armorCheck if armorCheck == 1: acCp=ac armor = '(includes Armor Penalty of %s)' % (acCp) if item == self.mytree_node: dnd35_char_child.on_ldclick(self,evt) - #wnd = skill_grid(self.frame.note,self) - #wnd.title = "Skills" - #self.frame.add_panel(wnd) else: mod = self.get_mod(name) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" chat = self.chat txt = '%s Skill Check: [1d20%s%s%s] %s' % ( name, mod1, mod, acCp, armor) @@ -1097,7 +946,6 @@ if eval('%s > 0' % (rank)) or eval('%s == 1' % (untr)): if eval('%s >=1' % (rank)): html_str += "" #a 1.6004 - #html_str += "" #d 1.6004 html_str += name+""+stat+""+rank+"" elif eval('%s == 1' % (untr)): #a 1.6004 html_str += "" #a 1.6004 @@ -1105,16 +953,12 @@ else: html_str += ""+name+"" html_str += stat+""+rank+"" - else: - continue + else: continue stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 - #stat_mod = str(dnd_globals["stats"][stat]) #d 1.5002 misc = n.get('misc') mod = str(self.get_mod(name)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str += ""+str(stat_mod)+""+misc #m 1.6009 str() html_str += '%s%s' % (mod1, mod) html_str = html_str + "" @@ -1133,34 +977,24 @@ self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) self.handler = handler skills = handler.xml.findall('skill') - #xelf.stats = dnd_globals["stats"] #d 1.5002 - self.CreateGrid(len(skills),6) self.SetRowLabelSize(0) col_names = ['Skill','Key','Rank','Abil','Misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) rowi = 0 self.skills = skills - for i in range(len(skills)): - self.refresh_row(i) + for i in range(len(skills)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() value = self.GetCellValue(row,col) - #print value try: int(value) - if col == 2: - self.skills[row].set('rank',value) - elif col ==4: - self.skills[row].set('misc',value) + if col == 2: self.skills[row].set('rank',value) + elif col == 4: self.skills[row].set('misc',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") - - #call refresh_skills + except: self.SetCellValue(row,col,"0") self.handler.refresh_skills() def refresh_row(self,rowi): @@ -1173,11 +1007,9 @@ self.SetReadOnly(rowi,1) self.SetCellValue(rowi,2,s.get('rank')) #self.SetCellValue(rowi,3,str(dnd_globals["stats"][stat])) #d 1.5002 - if self.root.abilities: #a 1.5002 sanity check. - stat_mod=self.root.abilities.get_mod(stat) #a 1.5002 - else: #a 1.5002 + if self.root.abilities: stat_mod=self.root.abilities.get_mod(stat) #a 1.5002 + else: stat_mod = -6 #a 1.5002 this can happen if code is changed so - #a 1.5002 that abilities are not defined prior invokation of init. print "Please advise dnd35 maintainer alert 1.5002 raised" self.SetCellValue(rowi,3,str(stat_mod)) #a 1.5002 @@ -1192,17 +1024,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - - for r in range(self.GetNumberRows()): - self.refresh_row(r) - - + for r in range(self.GetNumberRows()): self.refresh_row(r) class dnd35feats(skills_char_child): @@ -1219,16 +1046,13 @@ def get_design_panel(self,parent): setTitle="Feats - " + self.root.general.charName #a 1.5010 wnd = outline_panel(parent,self,feat_panel,setTitle) #a 1.5010 - #wnd = outline_panel(parent,self,feat_panel,"Feats") #d 1.5010 wnd.title = "Feats" #d 1.5010 - #wnd.title = "Feats - " + self.charName return wnd def tohtml(self): html_str = "
Feats
" n_list = self.xml.getchildren() - for n in n_list: - html_str += n.get('name')+ ", " + for n in n_list: html_str += n.get('name')+ ", " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -1236,12 +1060,9 @@ def __init__(self, parent, handler): self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 in this case, we need the functional parent, not the invoking parent. + self.root = getRoot(self) #a 1.5002 - #tempTitle= 'Feats - ' + self.root.general.charName #a 1.5010 - #pname = handler.xml.set("name", tempTitle) #a 1.5010 pname = handler.xml.set("name", 'Feats') #d 1.5010 - wx.Panel.__init__(self, parent, -1) self.grid = wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) sizer = wx.BoxSizer(wx.VERTICAL) @@ -1259,7 +1080,6 @@ self.SetAutoLayout(True) self.Fit() - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) self.Bind(wx.EVT_BUTTON, self.on_add, id=20) @@ -1275,13 +1095,11 @@ attr = wx.grid.GridCellAttr() attr.SetRenderer(wrap) self.grid.SetColAttr(2, attr) - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def refresh_row(self,i): feat = self.n_list[i] - name = feat.get('name') type = feat.get('type') desc = feat.get('desc') #m 1.6 correct typo @@ -1331,8 +1149,7 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) class dnd35combat(dnd35_char_child): """ Node handler for a dnd35 charactor @@ -1341,12 +1158,8 @@ def __init__(self,xml_dom,tree_node,parent): node_handler.__init__(self,xml_dom,tree_node) - self.hparent = parent #a 1.5002 allow ability to run up tree. self.root = getRoot(self) #a 1.5012 - - - #mark3 dnd35_char_child.__init__(self,xml_dom,tree_node,parent) self.frame = component.get('frame') @@ -1354,11 +1167,8 @@ self.new_child_handler('hp','Hit Points',dnd35hp,'gear') self.new_child_handler('attacks','Attacks',dnd35attacks,'spears') self.new_child_handler('ac','Armor',dnd35armor,'spears') - #print "combat",self.child_handlers #a (debug) 1.5002 - #wxMenuItem(self.tree.std_menu, dnd35_EXPORT, "Export...", "Export") self.myeditor = None - def new_child_handler(self,tag,text,handler_class,icon='gear'): node_list = self.xml.findall(tag) tree = self.tree @@ -1386,7 +1196,6 @@ self.frame = component.get('frame') self.myeditor = None - def on_drop(self,evt): pass @@ -1446,9 +1255,7 @@ class hp_panel(wx.Panel): def __init__(self, parent, handler): wx.Panel.__init__(self, parent, -1) - self.hparent = handler #a 1.5002 allow ability to run up tree. In this - #a 1.5002 case, we need the functional parent, not the invoking parent. - + self.hparent = handler pname = handler.xml.set("name", 'HitPoints') self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap self.xml = handler.xml @@ -1465,16 +1272,13 @@ self.SetAutoLayout(True) self.Fit() - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_TEXT, self.on_text, id=HP_MAX) self.Bind(wx.EVT_TEXT, self.on_text, id=HP_CUR) def on_text(self,evt): id = evt.GetId() - if id == HP_CUR: - self.xml.set('current',evt.GetString()) - elif id == HP_MAX: - self.xml.set('max',evt.GetString()) + if id == HP_CUR: self.xml.set('current',evt.GetString()) + elif id == HP_MAX: self.xml.set('max',evt.GetString()) def on_size(self,evt): s = self.GetClientSizeTuple() @@ -1490,9 +1294,6 @@ self.root = getRoot(self) #a 1.5002 self.root.attacks = self #a 1.6009 so others can find me. self.mrFrame = [] #a 1.9001 - - #a 1.5012 start a1b - self.updateFootNotes = False self.updateFootNotes = False self.html_str = "" @@ -1512,41 +1313,31 @@ """\n""") self.temp_dom={} - #a 1.5012 end a1b - node_list = self.xml.findall('melee') self.melee = node_list[0] node_list = self.xml.findall('ranged') self.ranged = node_list[0] - self.refresh_weapons() # this causes self.weapons to be loaded. - - #a 1.5012 this whole if clause. + self.refresh_weapons() if self.updateFootNotes == True: self.updateFootNotes = False name = self.root.general.charName self.html_str += "
Weapon NameAdded Footnote
" self.html_str += " " masterFrame = self.root.frame - title = name+"'s weapons' update to have footnotes" fnFrame = wx.Frame(masterFrame, -1, title) fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1) fnFrame.panel.SetPage(self.html_str) fnFrame.Show() - #weaponsH = self.xml.findall('attacks') - #mark7 - #a 1.9001 this whole method def refreshMRdata(self): # refresh the data in the melee/ranged section # of the attack chart. # count backwards, maintains context despite "removes" for i in range(len(self.mrFrame)-1,-1,-1): #a 1.9001 x = self.mrFrame[i] - if x == None: - x.refreshMRdata() #a 1.9001 - else: - self.mrFrame.remove(x) + if x == None: x.refreshMRdata() #a 1.9001 + else: self.mrFrame.remove(x) def refresh_weapons(self): self.weapons = {} @@ -1558,8 +1349,6 @@ for n in node_list: name = n.get('name') fn = safeGetAttr(n,'fn') #a 1.5012 can be removed when - #a 1.5012 confident all characters in the world have footnotes. - #if self.updateFootNotes: if fn == None:#a 1.5012 self.updateFootNotes=True self.updateFootN(n) #a 1.5012 @@ -1581,7 +1370,6 @@ fnN = safeGetAttr(n,'fn') if fnN == None or fnN == 'None': fnW = w.get('fn') - #print "weapon",nameF,"footnotes are updated to",fnW self.html_str += (""+nameF+""+ ""+fnW+"\n") n.set('fn',fnW) @@ -1608,7 +1396,6 @@ temp = self.ranged stat_mod = -7 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 - #print "Big test - stat_mod",stat_mod #a (debug) 1.6000 base = int(temp.get('base')) base2 = int(temp.get('second')) base3 = int(temp.get('third')) @@ -1620,15 +1407,9 @@ def on_rclick(self,evt): item = self.tree.GetSelection() - name = self.tree.GetItemText(item) - if item == self.mytree_node: - #print "bail due to FUD" - return #a 1.6015 - #dnd35_char_child.on_ldclick(self,evt)#d 1.6015 - #self.frame.add_panel(self.get_design_panel(self.frame.note)) + if item == self.mytree_node: return else: - #print "entering attack phase" mod = int(self.weapons[name].get('mod')) wepMod = mod #a 1.5008 footNotes = safeGetAttr(self.weapons[name],'fn','') @@ -1642,13 +1423,9 @@ tres="Melee" else: tres=result[1] - #print "print FootNotes,tres",footNotes,tres - if tres == 'Melee': #a 1.6001 #m 1.6022 use of tres here and... - #if self.weapons[name].get('range') == '0':#d 1.6001 - rangeOrMelee = 'm' #a 1.5008 code demote for next comment block - elif tres == 'Ranged': #m 1.6001 (was just else) #m 1.6022 here - rangeOrMelee = 'r' #a 1.5008 - else:#a 1.6001 add this whole else clause. + if tres == 'Melee': rangeOrMelee = 'm' + elif tres == 'Ranged': rangeOrMelee = 'r' + else: print "warning: 1.6001 unable to interpret weapon category" print "treating weapon as Melee, please correct xml" print "weapon name:",name @@ -1660,15 +1437,7 @@ #a 1.6003 start code fix instance a result = split(dmg,"/",2) dmg = result[0] - #print "1.6003 check:dmg",dmg,";result",result - #o currently, only picking out dmg; rest are simply ignored. - #o May be usefull - #o later for two weapon attack correction. - #a 1.6003 end code fix instance a - monkLvl = self.root.classes.get_class_lvl('Monk') # a 1.5002 - #print "monkLvl",monkLvl #a (debug) 1.5002 - # monkLvl = dnd_globals["class"]["lvl"] #d 1.5002 if find(dmg, "Monk Med") > -1: if monkLvl == None: #a 1.5009 txt = 'Attempting to use monk attack, but has no monk ' @@ -1677,18 +1446,12 @@ return #a 1.5009 else: #a 1.5009 lvl=int(monkLvl) - if lvl <= 3: #m 1.6022 reversed the order of checks. - dmg = dmg.replace("Monk Med", "1d6") - elif lvl <= 7: - dmg = dmg.replace("Monk Med", "1d8") - elif lvl <= 11: - dmg = dmg.replace("Monk Med", "1d10") - elif lvl <= 15: - dmg = dmg.replace("Monk Med", "2d6") - elif lvl <= 19: - dmg = dmg.replace("Monk Med", "2d8") - elif lvl <= 20: - dmg = dmg.replace("Monk Med", "2d10") + if lvl <= 3: dmg = dmg.replace("Monk Med", "1d6") + elif lvl <= 7: dmg = dmg.replace("Monk Med", "1d8") + elif lvl <= 11: dmg = dmg.replace("Monk Med", "1d10") + elif lvl <= 15: dmg = dmg.replace("Monk Med", "2d6") + elif lvl <= 19: dmg = dmg.replace("Monk Med", "2d8") + elif lvl <= 20: dmg = dmg.replace("Monk Med", "2d10") if find(dmg, "Monk Small") > -1: if monkLvl == None: #a 1.5009 txt = 'Attempting to use monk attack, but has no monk ' @@ -1697,18 +1460,12 @@ return #a 1.5009 else: #a 1.5009 lvl=int(monkLvl) - if lvl <= 3: #m 1.6022 reversed the order of the checks - dmg = dmg.replace("Monk Small", "1d4") - elif lvl <= 7: - dmg = dmg.replace("Monk Small", "1d6") - elif lvl <= 11: - dmg = dmg.replace("Monk Small", "1d8") - elif lvl <= 15: - dmg = dmg.replace("Monk Small", "1d10") - elif lvl <= 19: - dmg = dmg.replace("Monk Small", "2d6") - elif lvl <= 20: - dmg = dmg.replace("Monk Small", "2d8") + if lvl <= 3: dmg = dmg.replace("Monk Small", "1d4") + elif lvl <= 7: dmg = dmg.replace("Monk Small", "1d6") + elif lvl <= 11: dmg = dmg.replace("Monk Small", "1d8") + elif lvl <= 15: dmg = dmg.replace("Monk Small", "1d10") + elif lvl <= 19: dmg = dmg.replace("Monk Small", "2d6") + elif lvl <= 20: dmg = dmg.replace("Monk Small", "2d8") if find(dmg, "Monk Large") > -1: if monkLvl == None: #a 1.5009 txt = 'Attempting to use monk attack, but has no monk ' @@ -1717,45 +1474,24 @@ return #a 1.5009 else: #a 1.5009 lvl=int(monkLvl) - if lvl <= 3: #m 1.6022 reversed the order of the checks - dmg = dmg.replace("Monk Large", "1d8") - elif lvl <= 7: - dmg = dmg.replace("Monk Large", "2d6") - elif lvl <= 11: - dmg = dmg.replace("Monk Large", "2d8") - elif lvl <= 15: - dmg = dmg.replace("Monk Large", "3d6") - elif lvl <= 19: - dmg = dmg.replace("Monk Large", "3d8") - elif lvl <= 20: - dmg = dmg.replace("Monk Large", "4d8") + if lvl <= 3: dmg = dmg.replace("Monk Large", "1d8") + elif lvl <= 7: dmg = dmg.replace("Monk Large", "2d6") + elif lvl <= 11: dmg = dmg.replace("Monk Large", "2d8") + elif lvl <= 15: dmg = dmg.replace("Monk Large", "3d6") + elif lvl <= 19: dmg = dmg.replace("Monk Large", "3d8") + elif lvl <= 20: dmg = dmg.replace("Monk Large", "4d8") flurry = False - #print "adjusted weapon damage is:",dmg - #o 1.5007 str bow - #o 1.5011 start looking about here str dam bonus missed for thrown? - #o 1.5012 start looking about here str penalty missed for bow/sling? - #o 1.5013 off-hand attacks.? dam and all affects? str_mod = self.root.abilities.get_mod('Str') #a 1.5007,11,12,13 if rangeOrMelee == 'r': #a 1.5008 #if off_hand == True then stat_mod = stat_mod/2 #o 1.5013 #c 1.5007 ranged weapons normally get no str mod if find(footNotes,'b') > -1:#a 1.5012 if it's a bow - if str_mod >= 0: #a 1.5012 never a str bonus - str_mod = 0 #a 1.5012 penalty, - else: #a 1.5012 if appropriate - str_mod = 0 - # c 1.5007 (must adjust for str bows later and thown weapons) - #o 1.5007 include + for str bows - #o 1.5012 include any str penalty for bows/slings. - mod2 = "" #a 1.5007,11-13 - if str_mod >= 0: #1.6 tidy up code. - mod2 = "+" #1.6 tidy up code. + if str_mod >= 0: str_mod = 0 + else: str_mod = 0 + mod2 = "" + if str_mod >= 0: mod2 = "+" #1.6 tidy up code. aStrengthMod = mod2 + str(str_mod) #a 1.5008 applicable strength mod - - #if name == "Flurry of Blows(Monk Med)": #d 1.6012 - if find(name ,"Flurry of Blows") > -1: #a 1.6012 - flurry = True - + if find(name ,"Flurry of Blows") > -1: flurry = True (base, base2, base3, base4, base5, base6, stat_mod, misc) = self.get_attack_data(rangeOrMelee) #a 1.5008 name = name.replace('(Monk Med)', '') name = name.replace('(Monk Small)', '') @@ -1798,23 +1534,18 @@ self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) - if atks: - self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) + if atks: self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) self.sendRoll(base2, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) self.sendRoll(base3, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) self.sendRoll(base4, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) self.sendRoll(base5, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) self.sendRoll(base6, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) - - def sendRoll(self, base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=False): if base != 0 or rollAnyWay: base = base + int(stat_mod) + misc + wepMod #m 1.5008 - if base >= 0: - mod1 = "+" - else: - mod1 = "" + if base >= 0: mod1 = "+" + else: mod1 = "" txt = ' %s Attack Roll: [1d20%s%s%s]' % (name, mod1, base, flu) txt += ' ===> Damage: [%s%s]' % (dmg, aStrengthMod) self.chat.ParsePost( txt, True, True ) @@ -1845,10 +1576,8 @@ n_list = self.xml.findall('weapon') for n in n_list: mod = n.get('mod') - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" ran = n.get('range') total = str(int(mod) + self.get_mod(ran)) html_str += """

@@ -1865,7 +1594,6 @@ html_str += "" html_str += '' % (mod1, mod) - #a 1.5012 add next two lines to pretty print footnotes. html_str += """""" html_str += "" html_str += '
"+n.get('type')+"" html_str += n.get('size')+"%s%s
Footnotes:"+safeGetAttr(n,'fn','')+"
' @@ -1875,11 +1603,8 @@ """grid for attacks""" def __init__(self, parent, handler): pname = handler.xml.set("name", 'Melee') - self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 we need the functional parent, not the invoking parent. - + self.hparent = handler wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) - self.root = getRoot(self) #a 1.9001 self.parent = parent self.handler = handler @@ -1888,16 +1613,12 @@ self.SetRowLabelSize(0) col_names = ['Type','base','base 2','base 3','base 4','base 5', 'base 6','abil','misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.SetCellValue(0,0,"Melee") self.SetCellValue(1,0,"Ranged") self.refresh_data() self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) - #print "looking for containing frame" - - #a 1.9001 remainder of code in this method. climber = parent nameNode = climber.GetClassName() while nameNode != 'wxFrame': @@ -1915,23 +1636,15 @@ value = self.GetCellValue(row,col) try: int(value) - if col==1: - self.rows[row].set('base',value) - elif col==2: - self.rows[row].set('second',value) - elif col==3: - self.rows[row].set('third',value) - elif col==4: - self.rows[row].set('forth',value) - elif col==5: - self.rows[row].set('fifth',value) - elif col==6: - self.rows[row].set('sixth',value) - elif col==8: - self.rows[row].set('misc',value) + if col==1: self.rows[row].set('base',value) + elif col== 2: self.rows[row].set('second',value) + elif col== 3: self.rows[row].set('third',value) + elif col== 4: self.rows[row].set('forth',value) + elif col== 5: self.rows[row].set('fifth',value) + elif col== 6: self.rows[row].set('sixth',value) + elif col== 8: self.rows[row].set('misc',value) self.parent.refresh_data() - except: - self.SetCellValue(row,col,"0") + except: self.SetCellValue(row,col,"0") def refresh_data(self): @@ -1951,14 +1664,12 @@ self.SetReadOnly(0,9) self.SetReadOnly(1,9) - def on_size(self,evt): (w,h) = self.GetClientSizeTuple() cols = self.GetNumberCols() col_w = w/(cols+1) self.SetColSize(0,col_w*2) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() @@ -1996,18 +1707,15 @@ self.n_list = n_list self.xml = handler.xml self.handler = handler - #trash=input("weapon panel init colnames") self.colAttr = ['name','damage','mod','critical','type','weight', 'range','size','Total','fn', 'comment'] #a 1.5012 col_names = ['Name','Damage','To hit\nmod','Critical','Type','Weight', 'Range','Size','Total','Foot\nnotes','Comment'] #a 1.5012 gridColCount=len(col_names)#a 1.5012 self.grid.CreateGrid(len(n_list),gridColCount,1) #a 1.5012 - #self.grid.CreateGrid(len(n_list),9,1) #d 1.5012 self.grid.SetRowLabelSize(0) - for i in range(gridColCount): #a 1.5012 - self.grid.SetColLabelValue(i,col_names[i]) + for i in range(gridColCount): self.grid.SetColLabelValue(i,col_names[i]) self.refresh_data() self.temp_dom = None @@ -2015,21 +1723,15 @@ #mark4 #a 1.5012 add entire method. def on_gridRclick(self,evt): - #print "weapon_panel, on_rclick: self,evt",self,evt row = evt.GetRow() col = evt.GetCol() value = self.grid.GetCellValue(row,col) - #print "wp, on rclick,grid row,col,value",row,col,value + if col == 9 and value != 'None': n = self.n_list[row] name = n.get('name') - #print "we want a panel!" handler = self.hparent - #print "handler:",handler - # A handler is a node, and nodes have a reference to - # the master frame masterFrame = handler.frame - #print "masterFrame:",masterFrame title = name+"'s Special Weapon Characteristics" fnFrame = wx.Frame(masterFrame, -1, title) fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1) @@ -2037,14 +1739,12 @@ tree = parse(dir_struct["dnd35"]+ "dnd35weapons.xml") self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('f') # the footnotes - #print "weapon_panel - on_rclick f_list",f_list#a 1.6 n = self.n_list[row] name = n.get('name') footnotes = n.get('fn') html_str = "" html_str += """\n""" - #print "rclick,name,fn",name,footnotes if footnotes == "": html_str += "" html_str += " " @@ -2063,15 +1763,12 @@ html_str += "
NoteDescription
This weapon has no footnotes
" html_str += " " - - #print html_str fnFrame.panel.SetPage(html_str) fnFrame.Show() return pass - def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() @@ -2088,7 +1785,6 @@ def refresh_row(self,i): n = self.n_list[i] fn = n.get('fn') - #print "fn=",fn name = n.get('name') mod = n.get('mod') ran = n.get('range') @@ -2104,15 +1800,10 @@ self.grid.SetCellValue(i,8,total) self.grid.SetCellValue(i,9,safeGetAttr(n,'fn','None')) #a 1.5012 self.grid.SetCellValue(i,10,safeGetAttr(n,'comment','')) #a 1.5012 - #fn=safeGetAttr(n,'fn','None') #a (debug) 1.5012 - #print "fn ",fn,"<" #a (debug) 1.5012 - #o 1.5012 original damage vs what someone has changed it to. - self.grid.SetReadOnly(i,8) def on_remove(self,evt): #o 1.6011 correcting wrongful deletion rows = self.grid.GetNumberRows() - #for i in range(rows): #d 1.6011 do it backwards, for i in range(rows-1,-1,-1): #a 1.6011 or you lose context if self.grid.IsInSelection(i,0): self.grid.DeleteRows(i) @@ -2126,18 +1817,13 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('weapon') opts = [] - #print "weapon_panel - on_add f_list",f_list#a 1.6 - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() - #print f_list[i] # DOM Element: weapon. new_node = self.xml.append(f_list[i]) - #print self.grid.AppendRows # a bound method of wxGrid self.grid.AppendRows(1) self.n_list = self.xml.findall('weapon') - #print "self.n_list",self.n_list # list of DOM weapons self.refresh_row(self.grid.GetNumberRows()-1) self.handler.refresh_weapons() dlg.Destroy() @@ -2151,22 +1837,17 @@ cols = self.grid.GetNumberCols() col_w = w/(cols+1) self.grid.SetColSize(0,col_w*2) - for i in range(1,cols): - self.grid.SetColSize(i,col_w) + for i in range(1,cols): self.grid.SetColSize(i,col_w) def refresh_data(self): - - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class attack_panel(wx.Panel): def __init__(self, parent, handler): pname = handler.xml.set("name", 'Melee') self.parent = parent #a 1.9001 - wx.Panel.__init__(self, parent, -1) - self.a_grid = attack_grid(self, handler) self.w_panel = weapon_panel(self, handler) self.sizer = wx.BoxSizer(wx.VERTICAL) @@ -2174,13 +1855,11 @@ self.sizer.Add(self.w_panel, 2, wx.EXPAND) self.Bind(wx.EVT_SIZE, self.on_size) - def on_size(self,event): s = self.GetClientSizeTuple() self.sizer.SetDimension(0,0,s[0],s[1]) def refresh_data(self): - self.w_panel.refresh_data() self.a_grid.refresh_data() @@ -2211,10 +1890,8 @@ #m 1.5009 change to hardcode dex, was incorrect gv "stat" dex_mod = self.root.abilities.get_mod('Dex')#m 1.5009 hardcode dex max_dex = self.get_max_dex() - if dex_mod < max_dex: - ac_total += dex_mod - else: - ac_total += max_dex + if dex_mod < max_dex: ac_total += dex_mod + else: ac_total += max_dex return ac_total def get_max_dex(self): @@ -2222,15 +1899,13 @@ dex = 10 for a in armor_list: temp = int(a.get("maxdex")) - if temp < dex: - dex = temp + if temp < dex: dex = temp return dex def get_total(self,attr): armor_list = self.xml.findall('armor') total = 0 - for a in armor_list: - total += int(a.get(attr)) + for a in armor_list: total += int(a.get(attr)) return total def get_design_panel(self,parent): @@ -2278,9 +1953,7 @@ class ac_panel(wx.Panel): def __init__(self, parent, handler): pname = handler.xml.set("name", 'Armor') - self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 we need the functional parent, not the invoking parent. - + self.hparent = handler wx.Panel.__init__(self, parent, -1) self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) sizer = wx.BoxSizer(wx.VERTICAL) @@ -2298,7 +1971,6 @@ self.SetAutoLayout(True) self.Fit() - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) self.Bind(wx.EVT_BUTTON, self.on_add, id=20) self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) @@ -2308,12 +1980,10 @@ col_names = ['Armor','bonus','maxdex','cp','sf','weight','speed','type'] self.grid.CreateGrid(len(n_list),len(col_names),1) self.grid.SetRowLabelSize(0) - for i in range(len(col_names)): - self.grid.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) self.atts =['name','bonus','maxdex','checkpenalty', 'spellfailure','weight','speed','type'] - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None @@ -2325,16 +1995,12 @@ try: int(value) self.n_list[row].set(self.atts[col],value) - except: - self.grid.SetCellValue(row,col,"0") - else: - self.n_list[row].set(self.atts[col],value) + except: self.grid.SetCellValue(row,col,"0") + else: self.n_list[row].set(self.atts[col],value) def refresh_row(self,i): n = self.n_list[i] - - for y in range(len(self.atts)): - self.grid.SetCellValue(i,y,n.get(self.atts[y])) + for y in range(len(self.atts)): self.grid.SetCellValue(i,y,n.get(self.atts[y])) def on_remove(self,evt): rows = self.grid.GetNumberRows() @@ -2349,8 +2015,7 @@ self.temp_dom = tree.getroot() f_list = self.temp_dom.findall('armor') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -2367,5 +2032,4 @@ cols = self.grid.GetNumberCols() col_w = w/(cols+2) self.grid.SetColSize(0,col_w*3) - for i in range(1,cols): - self.grid.SetColSize(i,col_w) + for i in range(1,cols): self.grid.SetColSize(i,col_w) diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/dnd3e.py --- a/orpg/gametree/nodehandlers/dnd3e.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/dnd3e.py Wed Nov 25 06:15:49 2009 -0600 @@ -25,127 +25,7 @@ # # Description: The file contains code for the dnd3e nodehanlers # -# qpatch by lead.b. All modified lines denoted by # 1.500x[or] as below -# 1.5001r fix for unable to update misc modifier for saves -# 1.5002r fix for dnd_globals not scoping 1 character's data from another -or -# causing abends or other problems due to lack of intialization from -# char abilities. getCharacterProp function added. -# This includes fix for "total on saves", making "rclick" on skill -# work to send roll to window,"total on skill rolls", -# 1.5004r getting ac mod for -# those skill which have armour class adjustments was broken. -# 1.5005r perhaps no lines marked. Under dnd3eattacks, the misc. value for -# both Melee and Ranged do not get re-displayed if the panel is closed -# and re-opened, tho the adjustment still seems to be in total... perhap -# total just isn't getting recalculated? -# 1.5006r on rclick on a weapon, on first attack roll is generated, additional -# crash,terminating the sequence. -# 1.5008r extended bonuses for "extra" attacks don't include all items. -# 1.5009r while 1.5008 is "resolved", not sure it is correct for special monk -# attacks. I'm pretty sure I fixed this. -# 1.5014r powerpoints are broken. -# 1.5017r if you bring up the entire character in edit mode (dlclick on -# top node of character), and click -# "Money and Inventory" tab, then change the amount of "plat" a -# character has, the name on the tree will be updated to match -# the "plat" entry. -# 1.5019r if str bonus was 0, forgot + for aStrengthMod. -# ---v 1.6 cut. above corrected by 1.6. -# -- items marked 1.5xxx were found prior 1.6 but not added (enhancements) -# or corrected (bugs, default if not stated) at that cut point -# 1.5003r this is currently just a "this is busted" flag, this is an rclick on -# on the saves node (above the fort/wil/ref saves) itself. It throws an -# error message into the python window, then nothing... Not even sure what -# it is -supposed- to do. set to do nothing, which I think is fine. -# 1.5011r enhancement. Damage for thrown weapon should get str adder. -# Don't think this is accounted for. Remember, JUST damage, not to-hit. -# included into 1.6002, marking resolved to simplify list. -# 1.5012r enhancement. str penalty to dam for bow/slings should be applied. -# but it's not. Remember, this is just for damage, not to-hit. -# 1.5015r if you bring up the entire character in edit mode (dlclick on -# top node of character), and click -# "Spells and Powers" tab, then "Psionic Powers", push the "Refresh -# Powers" button, the powers are refreshed but if you select the -# "PowerPoints" tab, the update is not reflected there. Must close -# and reopen edit session for refresh. (Already corrected misspelling of -# "Pionic" -> "Psionic") -# 1.6000r eliminate misc debug items, include things like getCharacterProp which -# never got used. Documenting for completeness. Minor changes for clarity -# 1.6001r bug, melee weapons, such as dagger, which have a range are currently -# being treated simply as ranged weapons... this mean dex bonuses -# are being applied for to-hit Vs strength. Melee thrown are treated -# different than ranged. -# 1.6003r bug, if double weapon handle damage specified as 1d8/1d6 as 1d8 -# for single weapon usage. The correct usage for double weapon will -# for short term at least remove requirement to have to update -# memorized list. - med priority -# 1.6008r C:\Program Files\openrpg1\orpg\templates\nodes\dnd3e.xml minor -# typos corrected, added comment on psionics. Remember to replace! -# 1.6009r tohtml fails, thus send to chat fails and pretty print fails. -# 1.6010r tohtml for power points needs some clean up. -# 1.6011r if multiple weapons are chosen for deletion from character inventory, -# at least one wrong weapons will be deleted. -# 1.6012r flurry attack negative only applied to med monk, applies to all. -# 1.6013r penalties on stats on tohtml showed +-3, instead of just -3. -# 1.6014r rclick on "Skills" node above actual skills throws an error msg to -# python window. -# 1.6015r rclick on "Attacks" or "Abilities Score" node throws an error msg to -# python window. -# 1.6016r enhancement add comment to rclick footnotes to get footnote details. -# 1.6018r resolve saves not updating on panel if open when ability scores change -# change -# 1.6021r didn't roll extra monk attacks if base to it bonus was 0. -# 1.6022r monks always got d20 damage, reversed order of checks to fix. -# v1.8 cut. -# -- items marked 1.6xxx were found prior 1.8 but not added (enhancements) -# or corrected (bugs, default if not stated) at that cut point -# 1.5007o enhancement. str bows not accounted for correctly. -# thoughts: use new element tag to indicate strBow(3). -# 1.5010r proposed enhancement. Adding character name to frames around stuff. -# - marking resolved... determined to not do. -# 1.5013o enhancement. this is for all "off-hand" attacks stuff. Eg: str bonus -# only 1/2 for "off-hand" for both to-hit and damage (unless penalty! ;-) -# Probably other things, as I see nothing in here to account for them. -# 1.5016o enhancement. swim check does not reflect weight check. -# 1.5018o enhancement. actual psionic abilities list. -# 1.6002o enhancement. modify code to take advanage of new footnote field for -# indicating which weapons are Thrown, as opposed to improvised thrown -# weapons; which are treated differently. Allow for throwing of melee -# weapons (with 1.6001 all melee are unthrowable) recast of 1.5011, -# which I'm marking resolved. -# 1.6004o feature request from 541659 Ability to remove skills, at least those -# that can't be used untrained. This would also require ability to re-add -# skills later. Short term solution may be to ability to clearly mark -# skill which can't be used yet. - low priority. -# 1.6005o feature request from 541659 Custom feats, without the need to edit -# data/dnd3e/dnd3efeats.xml Note, while standard feats may be affecting -# how tool will generate rolls, etc; it is unlikely that custom feats will -# will be able to do this; but should be able to be include from a -# complete "character sheet" perspective. - low priority (since -# dnd3efeats can be edited to add feats) -# 1.6006o feature request from 541659 Do sorcerer and bard spells right; -# for short term at least remove requirement to have to update -# memorized list. - med priority -# 1.6007o feature request from 541659 Make tabs optional to be able to remove -# tabs which are unused by a particular character. Would need ability -# to add them back in, since character might later add a class which -# would need them. - very low priority -# 1.6017o enhancement when editing footnotes for weapons, -# provide full table of footnotes in companion window to help. -# 1.6019o enhancement Forum request to add "flatfooted" to ac matrix -# 1.6020o enh add column to skills to allow tracking of skill points allocated. -# 1.9000r clean up of excess comments from 1.6 and earlier. -# 1.9001r if str or dex changes, Melee/Ranged combat ability does not update -# until refreshed by a change. -# 1.9002r depending on what subwindows were open, changing stat scores could -# crash out entire orpg environment. -# -# r- resolved -# o- open -# -#import orpg.tools.orpg_settings #Not used?? -#import orpg.minidom from core import * from containers import * from string import * #a 1.6003 @@ -172,7 +52,7 @@ root = target target = target.hparent return root -#o 1.5002 (this whole comment block) + # if a method runs getRoot for its instance and assigns the # value returned to self.root, you can get to instances X via Y # instance handle via invocation @@ -206,21 +86,12 @@ # # replace {instance handle} with your designation # # replace {whatever you need} with the attribute/method u want. -#d 1.6000 not used. -#def getCharacterProp(forgetIt): -# return None - -#a 1.6 convinience function added safeGetAttr def safeGetAttr(node, label, defRetV=None): cna=node.attrib for key in cna: - if key == label: - return cna[key] - #retV=node.get(lable) # get does not distingish between - # the attribute not being present vs it having a value of "" - # This is bad for this routine, thus not used. + if key == label: return cna[key] return defRetV -#a 1.6... safeGetAttr end. + ########End of My global Stuff######## ########Start of Main Node Handlers####### @@ -234,10 +105,7 @@ print "dnd3echar_handler - version:", self.Version #m 1.6000 - self.hparent = None #a 1.5002 allow ability to run up tree, this is the - #a 1.5002 top of the handler tree, this is used to flag where to stop - #a 1.5002 on the way up. Changing this will break getRoot(self) - + self.hparent = None self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('howtouse','HowTo use this tool',dnd3ehowto,'note') @@ -247,12 +115,8 @@ self.new_child_handler('snf','SkillsAndFeats',dnd3eskillsnfeats,'book') self.new_child_handler('combat','Combat',dnd3ecombat,'spears') self.new_child_handler('snp','SpellsAndPowers',dnd3esnp,'flask') - #wxMenuItem(self.tree.std_menu, dnd3e_EXPORT, "Export...", "Export") - #print "dnd3echar_handler init - "+\ - # "self.child_handlers:",self.child_handlers # a (debug) 1.5002 self.myeditor = None - def new_child_handler(self,tag,text,handler_class,icon='gear'): node_list = self.xml.findall(tag) tree = self.tree @@ -265,31 +129,11 @@ def get_design_panel(self,parent): return tabbed_panel(parent,self,1) - def get_use_panel(self,parent): return tabbed_panel(parent,self,2) def tohtml(self): html_str = "" - #html_str += "" - #html_str += "" - #d block for 1.6009 end - #a block for 1.6009 start html_str += self.general.tohtml()+"" html_str += "" - #a block for 1.6009 end html_str += "
" - #d block for 1.6009 start - #html_str += self.child_handlers['general'].tohtml()+"
- # "+self.child_handlers['abilities'].tohtml() - #html_str += "

" + self.child_handlers['saves'].tohtml() - #html_str += "

" + self.child_handlers['attacks'].tohtml() - #html_str += "

" + self.child_handlers['ac'].tohtml() - #html_str += "

" + self.child_handlers['feats'].tohtml() - #html_str += "

" + self.child_handlers['spells'].tohtml() - #html_str += "

" + self.child_handlers['divine'].tohtml() - #html_str += "

" + self.child_handlers['powers'].tohtml() - #html_str += "

" + self.child_handlers['inventory'].tohtml() +"

- # "+self.child_handlers['classes'].tohtml() - #html_str += "

" + self.child_handlers['hp'].tohtml() - #html_str += "

" + self.child_handlers['pp'].tohtml() - #html_str += "

" + self.child_handlers['skills'].tohtml() +"

"+self.abilities.tohtml() html_str += "

" + self.saves.tohtml() @@ -304,16 +148,18 @@ html_str += "

" + self.hp.tohtml() html_str += "

" + self.pp.tohtml() html_str += "

" + self.skills.tohtml() +"

" return html_str def about(self): - html_str = "" #m 1.6000 was hard coded. + html_str += self.Version+"" html_str += "
by Dj Gilcrease
digitalxero@gmail.com" - return html_str + return html_str""" + text = 'dnd3e Character Tool' + self.Version +'\n' + text += 'by Dj Gilcrease digitalxero@gmail.com' + return text ########Core Handlers are done now############ ########Onto the Sub Nodes######## @@ -342,7 +188,6 @@ self.frame = component.get('frame') self.myeditor = None - def on_drop(self,evt): pass @@ -375,7 +220,7 @@ """ def __init__(self,xml_dom,tree_node,parent): dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. + self.hparent = parent def get_design_panel(self,parent): wnd = howto_panel(parent, self) @@ -402,10 +247,10 @@ """ def __init__(self,xml_dom,tree_node,parent): dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. - self.root = getRoot(self) #a 1.5002 - self.root.general = self #a 1.5002 - self.charName = self.get_char_name() # a 1.5002 make getting name easier. + self.hparent = parent + self.root = getRoot(self) + self.root.general = self + self.charName = self.get_char_name() def get_design_panel(self,parent): wnd = outline_panel(parent,self,gen_grid,"General Information") @@ -424,9 +269,7 @@ def on_name_change(self,name): self.char_hander.rename(name) - #o 1.5002 self.char_hander = parent in this case. - self.charName = name #a 1.5002 make getting name easier. - + self.charName = name def get_char_name( self ): node = self.xml.findall( 'name' )[0] @@ -436,12 +279,9 @@ """grid for gen info""" def __init__(self, parent, handler): pname = handler.xml.set("name", 'General') - self.hparent = handler #a 1.5002 allow ability to run up tree, needed - # a 1.5002 parent is functional parent, not invoking parent. - + self.hparent = handler wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) self.handler = handler n_list = handler.xml.getchildren() @@ -450,17 +290,14 @@ self.SetColLabelSize(0) self.n_list = n_list i = 0 - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() value = self.GetCellValue(row,col) self.n_list[row].text = value - if row==0: - self.handler.on_name_change(value) - #self.AutoSizeColumn(1) + if row==0: self.handler.on_name_change(value) def refresh_row(self,rowi): self.SetCellValue(rowi,0,self.n_list[rowi].tag) @@ -474,21 +311,20 @@ """ def __init__(self,xml_dom,tree_node,parent): dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. - self.root = getRoot(self) #a 1.6009 - self.root.inventory = self #a 1.6009 + self.hparent = parent + self.root = getRoot(self) + self.root.inventory = self def get_design_panel(self,parent): wnd = inventory_pane(parent, self) #outline_panel(parent,self,inventory_grid,"Inventory") - wnd.title = "General Info" + wnd.title = "Inventory" return wnd def tohtml(self): n_list = self.xml.getchildren() html_str = "
General Information
" for n in n_list: - debug((n)) - html_str += ""+n.tag.capitalize() +": " + html_str += ""+n.tag.capitalize()+": " html_str += n.text + "
" html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -498,7 +334,7 @@ wx.Panel.__init__(self, parent, wx.ID_ANY) self.n_list = handler.xml.getchildren() self.autosize = False - self.sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Inventroy"), wx.VERTICAL) + self.sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Inventory"), wx.VERTICAL) self.lang = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Languages") self.gear = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Gear") self.magic = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Magic") @@ -506,8 +342,7 @@ self.grid.CreateGrid(len(self.n_list)-3,2) self.grid.SetRowLabelSize(0) self.grid.SetColLabelSize(0) - for i in xrange(len(self.n_list)): - self.refresh_row(i) + for i in xrange(len(self.n_list)): self.refresh_row(i) sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(self.grid, 1, wx.EXPAND) sizer1.Add(self.lang, 1, wx.EXPAND) @@ -575,7 +410,7 @@ """ def __init__(self,xml_dom,tree_node,parent): node_handler.__init__(self,xml_dom,tree_node) - self.hparent = parent #a 1.5002 allow ability to run up tree. + self.hparent = parent dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) self.frame = component.get('frame') self.child_handlers = {} @@ -584,7 +419,6 @@ self.new_child_handler('saves','Saves',dnd3esaves,'skull') self.myeditor = None - def new_child_handler(self,tag,text,handler_class,icon='gear'): node_list = self.xml.findall(tag) tree = self.tree @@ -597,8 +431,8 @@ def get_design_panel(self,parent): return tabbed_panel(parent,self,1) - - def get_use_panel(self,parent): + def get_use_panel(self,parent): + print 'here' return tabbed_panel(parent,self,2) class class_char_child(node_handler): @@ -643,9 +477,9 @@ """ def __init__(self,xml_dom,tree_node,parent): class_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. - self.root = getRoot(self) #a 1.5002 get top of our local function tree. - self.root.abilities = self #a 1.5002 let other classes find me. + self.hparent = parent + self.root = getRoot(self) + self.root.abilities = self self.abilities = {} node_list = self.xml.findall('stat') tree = self.tree @@ -655,20 +489,14 @@ self.abilities[name] = n new_tree_node = tree.AppendItem( self.mytree_node, name, icons['gear'], icons['gear'] ) tree.SetPyData( new_tree_node, self ) - #print "dnd3eability - init self.abilities",self.abilities #a (debug) 1.5002 def on_rclick( self, evt ): item = self.tree.GetSelection() name = self.tree.GetItemText( item ) - #if item == self.mytree_node: #d 1.6016 - # dnd3e_char_child.on_ldclick( self, evt ) #d 1.6016 - if not item == self.mytree_node: #a 1.6016 - #else: #d 1.6016 + if not item == self.mytree_node: mod = self.get_mod( name ) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" chat = self.chat txt = '%s check: [1d20%s%s]' % ( name, mod1, mod ) chat.ParsePost( txt, True, True ) @@ -697,10 +525,8 @@ abbr = n.get('abbr') base = n.get('base') mod = str(self.get_mod(abbr)) - if int(mod) >= 0: #m 1.6013 added "int(" and ")" - mod1 = "+" - else: - mod1 = "" + if int(mod) >= 0: mod1 = "+" + else: mod1 = "" html_str = (html_str + ""+ name+""+base+'%s%s' % (mod1, mod)) html_str = html_str + "" @@ -710,9 +536,8 @@ """grid for abilities""" def __init__(self, parent, handler): pname = handler.xml.set("name", 'Stats') - self.hparent = handler #a 1.5002 allow ability to run up tree. + self.hparent = handler self.root = getRoot(self) - #a 1.5002 in this case, we need the functional parent, not the invoking parent. wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) self.Bind(wx.EVT_SIZE, self.on_size) @@ -722,31 +547,26 @@ self.CreateGrid(len(stats),3) self.SetRowLabelSize(0) col_names = ['Ability','Score','Modifier'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.stats = stats i = 0 - for i in range(len(stats)): - self.refresh_row(i) + for i in range(len(stats)): self.refresh_row(i) self.char_wnd = None def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() value = self.GetCellValue(row,col) - #print value try: int(value) self.stats[row].set('base',value) self.refresh_row(row) except: self.SetCellValue(row,col,"0") - if self.char_wnd: - self.char_wnd.refresh_data() + if self.char_wnd: self.char_wnd.refresh_data() def refresh_row(self,rowi): s = self.stats[rowi] - name = s.get('name') abbr = s.get('abbr') self.SetCellValue(rowi,0,name) @@ -754,26 +574,20 @@ self.SetCellValue(rowi,1,s.get('base')) self.SetCellValue(rowi,2,str(self.handler.get_mod(abbr))) self.SetReadOnly(rowi,2) - #if self.root.saves.saveGrid: #a 1.6018 d 1.9002 whole if clause - #print getmembers(self.root.saves.saveGrid) - #self.root.saves.saveGrid.refresh_data() #a 1.6018 - #print "skipping saving throw update, put back in later" - self.root.saves.refresh_data() #a 1.9002 - self.root.attacks.refreshMRdata() #a 1.9001 ` + self.root.saves.refresh_data() + self.root.attacks.refreshMRdata() def on_size(self,evt): (w,h) = self.GetClientSizeTuple() cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()-1): - self.refresh_row(r) + for r in range(self.GetNumberRows()-1): self.refresh_row(r) class dnd3eclasses(class_char_child): """ Node Handler for classes. This handler will be @@ -781,10 +595,9 @@ """ def __init__(self,xml_dom,tree_node,parent): class_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. + self.hparent = parent self.root = getRoot(self) self.root.classes = self - #a 1.5002 in this case, we need the functional parent, not the invoking parent. def get_design_panel(self,parent): wnd = outline_panel(parent,self,class_panel,"Classes") @@ -794,36 +607,27 @@ def tohtml(self): html_str = "
Classes
" n_list = self.xml.getchildren() - for n in n_list: - html_str += n.get('name') + " ("+n.get('level')+"), " + for n in n_list: html_str += n.get('name') + " ("+n.get('level')+"), " html_str = html_str[:len(html_str)-2] + "
" return html_str def get_char_lvl( self, attr ): node_list = self.xml.findall('class') - # print "eclasses - get_char_lvl node_list",node_list - tot = 0 #a 1.5009 actually, slipping in a quick enhancement ;-) + tot = 0 for n in node_list: - lvl = n.get('level') #o 1.5009 not sure of the value of this - tot += int(lvl) #a 1.5009 - type = n.get('name') #o 1.5009 not sure of the value of this - #print type,lvl #a (debug) 1.5009 - if attr == "level": - return lvl #o 1.5009 this returns the level of someone's first class. ??? - elif attr == "class": - return type #o 1.5009 this returns one of the char's classes. ??? - if attr == "lvl": #a 1.5009 this has value, adding this. - return tot #a 1.5009 return character's "overall" level. + lvl = n.get('level') + tot += int(lvl) + type = n.get('name') + if attr == "level": return lvl + elif attr == "class": return type + if attr == "lvl": return tot - def get_class_lvl( self, classN ): #a 1.5009 need to be able to get monk lvl - #a 1.5009 this function is new. + def get_class_lvl( self, classN ): node_list = self.xml.findall('class') - #print "eclasses - get_class_lvl node_list",node_list for n in node_list: lvl = n.get('level') type = n.get('name') - if classN == type: - return lvl + if classN == type: return lvl class class_panel(wx.Panel): def __init__(self, parent, handler): @@ -845,7 +649,6 @@ self.SetAutoLayout(True) self.Fit() - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) self.Bind(wx.EVT_BUTTON, self.on_add, id=20) self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) @@ -857,8 +660,7 @@ self.grid.SetRowLabelSize(0) self.grid.SetColLabelValue(0,"Class") self.grid.SetColLabelValue(1,"Level") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def on_cell_change(self,evt): @@ -877,7 +679,6 @@ self.grid.SetCellValue(i,0,name) self.grid.SetReadOnly(i,0) self.grid.SetCellValue(i,1,level) - #self.grid.SetReadOnly(i,1) def on_remove(self,evt): rows = self.grid.GetNumberRows() @@ -893,8 +694,7 @@ self.temp_dom = xml_dom f_list = self.temp_dom.findall('class') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -910,8 +710,7 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) class dnd3esaves(class_char_child): @@ -920,15 +719,14 @@ """ def __init__(self,xml_dom,tree_node,parent): class_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. - #self.saveGrid = None #a 1.6018 d 1.9002 - self.saveGridFrame = [] #a 1.9002 handle list, check frame for close. + self.hparent = parent + self.saveGridFrame = [] tree = self.tree icons = self.tree.icons - self.root = getRoot(self) #a 1.5002 - self.root.saves = self #a 1.6009 + self.root = getRoot(self) + self.root.saves = self node_list = self.xml.findall('save') self.saves={} for n in node_list: @@ -937,23 +735,19 @@ new_tree_node = tree.AppendItem(self.mytree_node,name,icons['gear'],icons['gear']) tree.SetPyData(new_tree_node,self) - #a 1.9002 this whole method - def refresh_data(self): # refresh the data in the melee/ranged section + + def refresh_data(self): # of the attack chart. # count backwards, maintains context despite "removes" for i in range(len(self.saveGridFrame)-1,-1,-1): x = self.saveGridFrame[i] - if x == None: - x.refresh_data() - else: - self.saveGridFrame.remove(x) + if x == None: x.refresh_data() + else: self.saveGridFrame.remove(x) def get_mod(self,name): save = self.saves[name] stat = save.get('stat') - #print "dnd3esaves, get_mod: self,root",self,self.root #a (debug) 1.5002 - #print "and abilities",self.root.abilities #a (debug) 1.5002 - stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 + stat_mod = self.root.abilities.get_mod(stat) base = int(save.get('base')) miscmod = int(save.get('miscmod')) magmod = int(save.get('magmod')) @@ -964,13 +758,8 @@ item = self.tree.GetSelection() name = self.tree.GetItemText(item) if item == self.mytree_node: - pass #a 1.5003 syntatic place holder - return #a 1.5003 - #print "failure mode!" - #dnd3e_char_child.on_ldclick(self,evt) #d 1.5003 this busted - #wnd = save_grid(self.frame.note,self) - #wnd.title = "Saves" - #self.frame.add_panel(wnd) + pass + return else: mod = self.get_mod(name) if mod >= 0: mod1 = "+" @@ -995,17 +784,13 @@ stat = n.get('stat') base = n.get('base') html_str = html_str + ""+name+""+stat+""+base+"" - #stat_mod = str(dnd_globals["stats"][stat]) #d 1.5002 - stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 + stat_mod = self.root.abilities.get_mod(stat) mag = n.get('magmod') misc = n.get('miscmod') mod = str(self.get_mod(name)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" - #m 1.5009 next line. added str() around stat_mod + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str = html_str + ""+str(stat_mod)+""+mag+"" html_str = html_str + ''+misc+'%s%s' % (mod1, mod) html_str = html_str + "" @@ -1016,10 +801,8 @@ """grid for saves""" def __init__(self, parent, handler): pname = handler.xml.set("name", 'Saves') - self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 in this case, we need the functional parent, not the invoking parent. + self.hparent = handler self.root = getRoot(self) - #self.hparent.saveGrid = self #a 1.6018 d 1.9001 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) @@ -1028,12 +811,10 @@ self.CreateGrid(len(saves),7) self.SetRowLabelSize(0) col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.saves = saves i = 0 for i in range(len(saves)): self.refresh_row(i) - #a 1.9002 remainder of code in this method. climber = parent nameNode = climber.GetClassName() while nameNode != 'wxFrame': @@ -1041,7 +822,6 @@ nameNode = climber.GetClassName() masterFrame=climber masterFrame.refresh_data=self.refresh_data - #print getmembers(masterFrame) handler.saveGridFrame.append(masterFrame) def on_cell_change(self,evt): @@ -1050,15 +830,11 @@ value = self.GetCellValue(row,col) try: int(value) - if col == 2: - self.saves[row].set('base',value) - elif col ==4: - self.saves[row].set('magmod',value) - elif col ==5: # 1.5001 - self.saves[row].set('miscmod',value) + if col == 2: self.saves[row].set('base',value) + elif col == 4: self.saves[row].set('magmod',value) + elif col == 5: self.saves[row].set('miscmod',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") + except: self.SetCellValue(row,col,"0") def refresh_row(self,rowi): s = self.saves[rowi] @@ -1082,34 +858,26 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - for r in range(self.GetNumberRows()): - self.refresh_row(r) + for r in range(self.GetNumberRows()): self.refresh_row(r) class dnd3eskillsnfeats(dnd3e_char_child): """ Node handler for a dnd3e charactor """ def __init__(self,xml_dom,tree_node,parent): - self.hparent = parent #a 1.5002 allow ability to run up tree. - self.root = getRoot(self) #a 1.6009 - - #print "dnd3eskillsnfeats - init, self ",self #a (debug) 1.5002 - #print "dnd3eskillsnfeats - init, parent ",self.hparent #a (debug) 1.5002 - #print "dnd3eskillsnfeats - init, parent ",parent.dnd3eclassnstats #a (debug) 1.5002 - + self.hparent = parent + self.root = getRoot(self) node_handler.__init__(self,xml_dom,tree_node) dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('skills','Skills',dnd3eskill,'book') self.new_child_handler('feats','Feats',dnd3efeats,'book') - #wxMenuItem(self.tree.std_menu, dnd3e_EXPORT, "Export...", "Export") self.myeditor = None def new_child_handler(self,tag,text,handler_class,icon='gear'): @@ -1168,10 +936,9 @@ created by dnd3echar_handler. """ def __init__(self,xml_dom,tree_node,parent): - self.hparent = parent #a 1.5002 allow ability to run up tree. - #a 1.5002 Need the functional parent, not the invoking parent. - self.root = getRoot(self) #a 1.5002 - self.root.skills = self #a 1.6009 + self.hparent = parent + self.root = getRoot(self) + self.root.skills = self skills_char_child.__init__(self,xml_dom,tree_node,parent) tree = self.tree @@ -1179,14 +946,12 @@ node_list = self.xml.findall('skill') self.skills={} - #Adding code to not display skills you can not use -mgt for n in node_list: name = n.get('name') self.skills[name] = n skill_check = self.skills[name] ranks = int(skill_check.get('rank')) trained = int(skill_check.get('untrained')) - if ranks > 0 or trained == 1: new_tree_node = tree.AppendItem(self.mytree_node,name, icons['gear'],icons['gear']) @@ -1201,7 +966,6 @@ icons = self.tree.icons tree.CollapseAndReset(self.mytree_node) node_list = self.xml.findall('skill') - self.skills={} for n in node_list: name = n.get('name') @@ -1209,7 +973,6 @@ skill_check = self.skills[name] ranks = int(skill_check.get('rank')) trained = int(skill_check.get('untrained')) - if ranks > 0 or trained == 1: new_tree_node = tree.AppendItem(self.mytree_node,name, icons['gear'],icons['gear']) @@ -1219,8 +982,7 @@ def get_mod(self,name): skill = self.skills[name] stat = skill.get('stat') - #stat_mod = int(dnd_globals["stats"][stat]) #d 1.5002 - stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 + stat_mod = self.root.abilities.get_mod(stat) rank = int(skill.get('rank')) misc = int(skill.get('misc')) total = stat_mod + rank + misc @@ -1229,39 +991,27 @@ def on_rclick(self,evt): item = self.tree.GetSelection() name = self.tree.GetItemText(item) - #print "skill rc self",self #a 1.6004 - #print "skill rc tree",self.mytree_node #a 1.6004 - #print "skill rc item",item #a 1.6004 - if item == self.mytree_node: - return - # following line fails, - #dnd3e_char_child.on_ldclick(self,evt) #d 1.6014 - # it's what it used to try to do. - ac = self.root.ac.get_check_pen() #a 1.5002 for 1.5004 verify fix. + if item == self.mytree_node: return + ac = self.root.ac.get_check_pen() skill = self.skills[name] - untr = skill.get('untrained') #a 1.6004 - rank = skill.get('rank') #a 1.6004 - if eval('%s == 0' % (untr)): #a 1.6004 - if eval('%s == 0' % (rank)): #a 1.6004 - res = 'You fumble around, accomplishing nothing' #a 1.6004 - txt = '%s Skill Check: %s' % (name, res) #a 1.6004 - chat = self.chat #a 1.6004 - chat.Post(txt,True,True) #a 1.6004 - return #a 1.6004 - + untr = skill.get('untrained') + rank = skill.get('rank') + if eval('%s == 0' % (untr)): + if eval('%s == 0' % (rank)): + res = 'You fumble around, accomplishing nothing' + txt = '%s Skill Check: %s' % (name, res) + chat = self.chat + chat.Post(txt,True,True) + return armor = '' acCp = '' - if ac < 0: #acCp >= 1 #m 1.5004 this is stored as negatives. + if ac < 0: armorCheck = int(skill.get('armorcheck')) - #print "ac,armorCheck",ac,armorCheck if armorCheck == 1: acCp=ac armor = '(includes Armor Penalty of %s)' % (acCp) if item == self.mytree_node: dnd3e_char_child.on_ldclick(self,evt) - #wnd = skill_grid(self.frame.note,self) - #wnd.title = "Skills" - #self.frame.add_panel(wnd) else: mod = self.get_mod(name) if mod >= 0: mod1 = "+" @@ -1286,29 +1036,24 @@ name = n.get('name') stat = n.get('stat') rank = n.get('rank') - untr = n.get('untrained') #a 1.6004 + untr = n.get('untrained') #Filter unsuable skills out of pretty print -mgt if eval('%s > 0' % (rank)) or eval('%s == 1' % (untr)): if eval('%s >=1' % (rank)): - html_str += "" #a 1.6004 - #html_str += "" #d 1.6004 + html_str += "" html_str += name+""+stat+""+rank+"" - elif eval('%s == 1' % (untr)): #a 1.6004 - html_str += "" #a 1.6004 - html_str += name+""+stat+""+rank+"" #a 1.6004 + elif eval('%s == 1' % (untr)): + html_str += "" + html_str += name+""+stat+""+rank+"" else: html_str += ""+name+"" html_str += stat+""+rank+"" - else: - continue - stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 - #stat_mod = str(dnd_globals["stats"][stat]) #d 1.5002 + else: continue + stat_mod = self.root.abilities.get_mod(stat) misc = n.get('misc') mod = str(self.get_mod(name)) - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" html_str += ""+str(stat_mod)+""+misc #m 1.6009 str() html_str += '%s%s' % (mod1, mod) html_str = html_str + "" @@ -1318,8 +1063,8 @@ class skill_grid(wx.grid.Grid): """ panel for skills """ def __init__(self, parent, handler): - self.hparent = handler #a 1.5002 need function parent, not invoker - self.root = getRoot(self) #a 1.5002 + self.hparent = handler + self.root = getRoot(self) pname = handler.xml.set("name", 'Skills') wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) @@ -1327,7 +1072,6 @@ self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) self.handler = handler skills = handler.xml.findall('skill') - #xelf.stats = dnd_globals["stats"] #d 1.5002 self.CreateGrid(len(skills),6) self.SetRowLabelSize(0) @@ -1336,25 +1080,18 @@ self.SetColLabelValue(i,col_names[i]) rowi = 0 self.skills = skills - for i in range(len(skills)): - self.refresh_row(i) + for i in range(len(skills)): self.refresh_row(i) def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() value = self.GetCellValue(row,col) - #print value try: int(value) - if col == 2: - self.skills[row].set('rank',value) - elif col ==4: - self.skills[row].set('misc',value) + if col == 2: self.skills[row].set('rank',value) + elif col ==4: self.skills[row].set('misc',value) self.refresh_row(row) - except: - self.SetCellValue(row,col,"0") - - #call refresh_skills + except: self.SetCellValue(row,col,"0") self.handler.refresh_skills() def refresh_row(self,rowi): @@ -1366,15 +1103,12 @@ self.SetCellValue(rowi,1,stat) self.SetReadOnly(rowi,1) self.SetCellValue(rowi,2,s.get('rank')) - #self.SetCellValue(rowi,3,str(dnd_globals["stats"][stat])) #d 1.5002 - if self.root.abilities: #a 1.5002 sanity check. - stat_mod=self.root.abilities.get_mod(stat) #a 1.5002 - else: #a 1.5002 - stat_mod = -6 #a 1.5002 this can happen if code is changed so - #a 1.5002 that abilities are not defined prior invokation of init. + if self.root.abilities: stat_mod=self.root.abilities.get_mod(stat) + else: + stat_mod = -6 print "Please advise dnd3e maintainer alert 1.5002 raised" - self.SetCellValue(rowi,3,str(stat_mod)) #a 1.5002 + self.SetCellValue(rowi,3,str(stat_mod)) self.SetReadOnly(rowi,3) self.SetCellValue(rowi,4,s.get('misc')) mod = str(self.handler.get_mod(name)) @@ -1386,17 +1120,12 @@ cols = self.GetNumberCols() col_w = w/(cols+2) self.SetColSize(0,col_w*3) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() def refresh_data(self): - - for r in range(self.GetNumberRows()): - self.refresh_row(r) - - + for r in range(self.GetNumberRows()): self.refresh_row(r) class dnd3efeats(skills_char_child): @@ -1405,17 +1134,14 @@ """ def __init__(self,xml_dom,tree_node,parent): skills_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. - self.root = getRoot(self) #a 1.5002 - self.root.feats = self #a 1.6009 - + self.hparent = parent + self.root = getRoot(self) + self.root.feats = self def get_design_panel(self,parent): - setTitle="Feats - " + self.root.general.charName #a 1.5010 - wnd = outline_panel(parent,self,feat_panel,setTitle) #a 1.5010 - #wnd = outline_panel(parent,self,feat_panel,"Feats") #d 1.5010 - wnd.title = "Feats" #d 1.5010 - #wnd.title = "Feats - " + self.charName + setTitle="Feats - " + self.root.general.charName + wnd = outline_panel(parent,self,feat_panel,setTitle) + wnd.title = "Feats" return wnd def tohtml(self): @@ -1429,34 +1155,24 @@ class feat_panel(wx.Panel): def __init__(self, parent, handler): - self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 in this case, we need the functional parent, not the invoking parent. - self.root = getRoot(self) #a 1.5002 - #tempTitle= 'Feats - ' + self.root.general.charName #a 1.5010 - #pname = handler.xml.set("name", tempTitle) #a 1.5010 - pname = handler.xml.set("name", 'Feats') #d 1.5010 - + self.hparent = handler + self.root = getRoot(self) + pname = handler.xml.set("name", 'Feats') wx.Panel.__init__(self, parent, -1) self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.grid, 1, wx.EXPAND) - sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(wx.Button(self, 10, "Remove Feat"), 0, wx.EXPAND) sizer1.Add(wx.Size(10,10)) sizer1.Add(wx.Button(self, 20, "Add Feat"), 0, wx.EXPAND) - sizer.Add(sizer1, 0, wx.EXPAND) self.sizer = sizer - self.SetSizer(self.sizer) self.SetAutoLayout(True) self.Fit() - - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) self.Bind(wx.EVT_BUTTON, self.on_add, id=20) - n_list = handler.xml.getchildren() self.n_list = n_list self.xml = handler.xml @@ -1464,22 +1180,20 @@ self.grid.SetRowLabelSize(0) self.grid.SetColLabelValue(0,"Feat") self.grid.SetColLabelValue(1,"Type") - self.grid.SetColLabelValue(2,"Reference") #m 1.6 typo correction. - for i in range(len(n_list)): - self.refresh_row(i) + self.grid.SetColLabelValue(2,"Reference") + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def refresh_row(self,i): feat = self.n_list[i] - name = feat.get('name') type = feat.get('type') - desc = feat.get('desc') #m 1.6 correct typo + desc = feat.get('desc') self.grid.SetCellValue(i,0,name) self.grid.SetReadOnly(i,0) self.grid.SetCellValue(i,1,type) self.grid.SetReadOnly(i,1) - self.grid.SetCellValue(i,2,desc) #m 1.6 correct typo + self.grid.SetCellValue(i,2,desc) self.grid.SetReadOnly(i,2) def on_remove(self,evt): @@ -1526,23 +1240,16 @@ node_handler.__init__(self,xml_dom,tree_node) - self.hparent = parent #a 1.5002 allow ability to run up tree. - self.root = getRoot(self) #a 1.5012 - - - - #mark3 + self.hparent = parent + self.root = getRoot(self) dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('hp','Hit Points',dnd3ehp,'gear') self.new_child_handler('attacks','Attacks',dnd3eattacks,'spears') self.new_child_handler('ac','Armor',dnd3earmor,'spears') - #print "combat",self.child_handlers #a (debug) 1.5002 - #wxMenuItem(self.tree.std_menu, dnd3e_EXPORT, "Export...", "Export") self.myeditor = None - def new_child_handler(self,tag,text,handler_class,icon='gear'): node_list = self.xml.findall(tag) tree = self.tree @@ -1570,7 +1277,6 @@ self.frame = component.get('frame') self.myeditor = None - def on_drop(self,evt): pass @@ -1602,9 +1308,9 @@ """ def __init__(self,xml_dom,tree_node,parent): combat_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. - self.root = getRoot(self) #a 1.6009 - self.root.hp = self #a 1.6009 + self.hparent = parent + self.root = getRoot(self) + self.root.hp = self def get_design_panel(self,parent): wnd = outline_panel(parent,self,hp_panel,"Hit Points") @@ -1630,9 +1336,7 @@ class hp_panel(wx.Panel): def __init__(self, parent, handler): wx.Panel.__init__(self, parent, -1) - self.hparent = handler #a 1.5002 allow ability to run up tree. In this - #a 1.5002 case, we need the functional parent, not the invoking parent. - + self.hparent = handler pname = handler.xml.set("name", 'HitPoints') self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap self.xml = handler.xml @@ -1648,17 +1352,13 @@ self.SetSizer(self.sizer) self.SetAutoLayout(True) self.Fit() - - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_TEXT, self.on_text, id=HP_MAX) self.Bind(wx.EVT_TEXT, self.on_text, id=HP_CUR) def on_text(self,evt): id = evt.GetId() - if id == HP_CUR: - self.xml.set('current',evt.GetString()) - elif id == HP_MAX: - self.xml.set('max',evt.GetString()) + if id == HP_CUR: self.xml.set('current',evt.GetString()) + elif id == HP_MAX: self.xml.set('max',evt.GetString()) def on_size(self,evt): s = self.GetClientSizeTuple() @@ -1670,13 +1370,10 @@ """ def __init__(self,xml_dom,tree_node,parent): combat_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. - self.root = getRoot(self) #a 1.5002 - self.root.attacks = self #a 1.6009 so others can find me. - self.mrFrame = [] #a 1.9001 - - #a 1.5012 start a1b - + self.hparent = parent + self.root = getRoot(self) + self.root.attacks = self + self.mrFrame = [] self.updateFootNotes = False self.updateFootNotes = False self.html_str = "" @@ -1696,41 +1393,32 @@ """\n""") self.temp_dom={} - #a 1.5012 end a1b - node_list = self.xml.findall('melee') self.melee = node_list[0] node_list = self.xml.findall('ranged') self.ranged = node_list[0] - self.refresh_weapons() # this causes self.weapons to be loaded. - - #a 1.5012 this whole if clause. + self.refresh_weapons() if self.updateFootNotes == True: self.updateFootNotes = False name = self.root.general.charName self.html_str += "
Weapon NameAdded Footnote
" self.html_str += " " masterFrame = self.root.frame - title = name+"'s weapons' update to have footnotes" fnFrame = wx.Frame(masterFrame, -1, title) fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1) fnFrame.panel.SetPage(self.html_str) fnFrame.Show() - #weaponsH = self.xml.findall('attacks') - #mark7 + - #a 1.9001 this whole method - def refreshMRdata(self): # refresh the data in the melee/ranged section + def refreshMRdata(self): # of the attack chart. # count backwards, maintains context despite "removes" - for i in range(len(self.mrFrame)-1,-1,-1): #a 1.9001 + for i in range(len(self.mrFrame)-1,-1,-1): x = self.mrFrame[i] - if x == None: - x.refreshMRdata() #a 1.9001 - else: - self.mrFrame.remove(x) + if x == None: x.refreshMRdata() #a 1.9001 + else: self.mrFrame.remove(x) def refresh_weapons(self): self.weapons = {} @@ -1741,18 +1429,16 @@ node_list = self.xml.findall('weapon') for n in node_list: name = n.get('name') - fn = safeGetAttr(n,'fn') #a 1.5012 can be removed when - #a 1.5012 confident all characters in the world have footnotes. - #if self.updateFootNotes: - if fn == None:#a 1.5012 + fn = safeGetAttr(n,'fn') + if fn == None: self.updateFootNotes=True - self.updateFootN(n) #a 1.5012 + self.updateFootN(n) new_tree_node = tree.AppendItem( self.mytree_node,name,icons['sword'],icons['sword']) tree.SetPyData(new_tree_node,self) self.weapons[name]=n - def updateFootN(self,n):#a 1.5012 this whole function + def updateFootN(self,n): if not self.temp_dom: tree = parse(dir_struct["dnd3e"]+"dnd3eweapons.xml") self.temp_dom = tree.getroot() @@ -1765,7 +1451,6 @@ fnN = safeGetAttr(n,'fn') if fnN == None or fnN == 'None': fnW = w.get('fn') - #print "weapon",nameF,"footnotes are updated to",fnW self.html_str += (""+nameF+""+ ""+fnW+"\n") n.set('fn',fnW) @@ -1777,7 +1462,6 @@ ""+'X'+"\n") n.set('fn','X') - def get_mod(self,type='m'): (base, base2, base3, base4, base5, base6, stat_mod, misc) \ = self.get_attack_data(type) @@ -1785,14 +1469,13 @@ def get_attack_data(self,type='m'): if type=='m' or type=='0': - stat = 'Str' #m was dnd_globals["stats"]['Str'] 1.5002 + stat = 'Str' temp = self.melee else: - stat = 'Dex' #m was dnd_globals["stats"]['Dex'] 1.5002 + stat = 'Dex' temp = self.ranged stat_mod = -7 - stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 - #print "Big test - stat_mod",stat_mod #a (debug) 1.6000 + stat_mod = self.root.abilities.get_mod(stat) base = int(temp.get('base')) base2 = int(temp.get('second')) base3 = int(temp.get('third')) @@ -1807,12 +1490,9 @@ name = self.tree.GetItemText(item) if item == self.mytree_node: - #print "bail due to FUD" - return #a 1.6015 - #dnd3e_char_child.on_ldclick(self,evt)#d 1.6015 - #self.frame.add_panel(self.get_design_panel(self.frame.note)) + return else: - #print "entering attack phase" + mod = int(self.weapons[name].get('mod')) wepMod = mod #a 1.5008 footNotes = safeGetAttr(self.weapons[name],'fn','') @@ -1826,9 +1506,7 @@ tres="Melee" else: tres=result[1] - #print "print FootNotes,tres",footNotes,tres if tres == 'Melee': #a 1.6001 #m 1.6022 use of tres here and... - #if self.weapons[name].get('range') == '0':#d 1.6001 rangeOrMelee = 'm' #a 1.5008 code demote for next comment block elif tres == 'Ranged': #m 1.6001 (was just else) #m 1.6022 here rangeOrMelee = 'r' #a 1.5008 @@ -1844,15 +1522,7 @@ #a 1.6003 start code fix instance a result = split(dmg,"/",2) dmg = result[0] - #print "1.6003 check:dmg",dmg,";result",result - #o currently, only picking out dmg; rest are simply ignored. - #o May be usefull - #o later for two weapon attack correction. - #a 1.6003 end code fix instance a - monkLvl = self.root.classes.get_class_lvl('Monk') # a 1.5002 - #print "monkLvl",monkLvl #a (debug) 1.5002 - # monkLvl = dnd_globals["class"]["lvl"] #d 1.5002 if dmg == "Monk Med": if monkLvl == None: #a 1.5009 txt = 'Attempting to use monk attack, but has no monk ' @@ -1861,63 +1531,37 @@ return #a 1.5009 else: #a 1.5009 lvl=int(monkLvl) - if lvl <= 3: #m 1.6022 reversed the order of checks. - dmg = "1d6" - elif lvl <= 7: - dmg = "1d8" - elif lvl <= 11: - dmg = "1d10" - elif lvl <= 15: - dmg = "2d6" - elif lvl <= 19: - dmg = "2d8" - elif lvl <= 20: - dmg = "2d10" + if lvl <= 3: dmg = "1d6" + elif lvl <= 7: dmg = "1d8" + elif lvl <= 11: dmg = "1d10" + elif lvl <= 15: dmg = "2d6" + elif lvl <= 19: dmg = "2d8" + elif lvl <= 20: dmg = "2d10" if dmg == "Monk Small": - if monkLvl == None: #a 1.5009 + if monkLvl == None: txt = 'Attempting to use monk attack, but has no monk ' txt += 'levels, please choose a different attack.' - chat.ParsePost( txt, True, True ) #a 1.5009 - return #a 1.5009 - else: #a 1.5009 + chat.ParsePost( txt, True, True ) + return + else: lvl=int(monkLvl) - if lvl <= 3: #m 1.6022 reversed the order of the checks - dmg = "1d4" - elif lvl <= 7: - dmg = "1d6" - elif lvl <= 11: - dmg = "1d8" - elif lvl <= 15: - dmg = "1d10" - elif lvl <= 20: - dmg = "2d6" + if lvl <= 3: dmg = "1d4" + elif lvl <= 7: dmg = "1d6" + elif lvl <= 11: dmg = "1d8" + elif lvl <= 15: dmg = "1d10" + elif lvl <= 20: dmg = "2d6" flu = '' - #print "adjusted weapon damage is:",dmg - #o 1.5007 str bow - #o 1.5011 start looking about here str dam bonus missed for thrown? - #o 1.5012 start looking about here str penalty missed for bow/sling? - #o 1.5013 off-hand attacks.? dam and all affects? str_mod = self.root.abilities.get_mod('Str') #a 1.5007,11,12,13 if rangeOrMelee == 'r': #a 1.5008 - #if off_hand == True then stat_mod = stat_mod/2 #o 1.5013 - #c 1.5007 ranged weapons normally get no str mod - if find(footNotes,'b') > -1:#a 1.5012 if it's a bow - if str_mod >= 0: #a 1.5012 never a str bonus - str_mod = 0 #a 1.5012 penalty, - else: #a 1.5012 if appropriate - str_mod = 0 - # c 1.5007 (must adjust for str bows later and thown weapons) - #o 1.5007 include + for str bows - #o 1.5012 include any str penalty for bows/slings. - mod2 = "" #a 1.5007,11-13 - if str_mod >= 0: #1.6 tidy up code. - mod2 = "+" #1.6 tidy up code. + + if find(footNotes,'b') > -1: + if str_mod >= 0: str_mod = 0 + else: str_mod = 0 + mod2 = "" + if str_mod >= 0: mod2 = "+" aStrengthMod = mod2 + str(str_mod) #a 1.5008 applicable strength mod - - #if name == "Flurry of Blows(Monk Med)": #d 1.6012 if find(name ,"Flurry of Blows") > -1: #a 1.6012 flu = '-2' - (base, base2, base3, base4, base5, base6, stat_mod, misc)\ = self.get_attack_data(rangeOrMelee) #a 1.5008 self.sendRoll(base ,stat_mod,misc,wepMod,name,flu,dmg, @@ -1937,10 +1581,8 @@ spacer="",pname=False,rollAnyWay=False): if base != 0 or rollAnyWay: base = base + int(stat_mod) + misc + wepMod #m 1.5008 - if base >= 0: - mod1 = "+" - else: - mod1 = "" + if base >= 0: mod1 = "+" + else: mod1 = "" txt = '%s ' % (spacer) txt += '%s Attack Roll: [1d20%s%s%s]' % (name, mod1, base, flu) txt += ' ===> Damage: [%s%s]' % (dmg, aStrengthMod) @@ -1972,10 +1614,8 @@ n_list = self.xml.findall('weapon') for n in n_list: mod = n.get('mod') - if mod >= 0: - mod1 = "+" - else: - mod1 = "" + if mod >= 0: mod1 = "+" + else: mod1 = "" ran = n.get('range') total = str(int(mod) + self.get_mod(ran)) html_str += """

@@ -1992,7 +1632,6 @@ html_str += "" html_str += '' % (mod1, mod) - #a 1.5012 add next two lines to pretty print footnotes. html_str += """""" html_str += "" html_str += '
"+n.get('type')+"" html_str += n.get('size')+"%s%s
Footnotes:"+safeGetAttr(n,'fn','')+"
' @@ -2002,9 +1641,7 @@ """grid for attacks""" def __init__(self, parent, handler): pname = handler.xml.set("name", 'Melee') - self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 we need the functional parent, not the invoking parent. - + self.hparent = handler wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) self.root = getRoot(self) #a 1.9001 @@ -2015,16 +1652,12 @@ self.SetRowLabelSize(0) col_names = ['Type','base','base 2','base 3','base 4','base 5', 'base 6','abil','misc','Total'] - for i in range(len(col_names)): - self.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) self.SetCellValue(0,0,"Melee") self.SetCellValue(1,0,"Ranged") self.refresh_data() self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) - #print "looking for containing frame" - - #a 1.9001 remainder of code in this method. climber = parent nameNode = climber.GetClassName() while nameNode != 'wxFrame': @@ -2032,26 +1665,8 @@ nameNode = climber.GetClassName() masterFrame=climber masterFrame.refreshMRdata=self.refresh_data - #print getmembers(masterFrame) - handler.mrFrame.append(masterFrame) - #print "masterFrame=",masterFrame - #print "mr.Show=",masterFrame.Show() - #print "mf.GetName",masterFrame.GetName() - #print "mf.GetClassName",masterFrame.GetClassName() - #print "mf.GetId",masterFrame.GetId() - #print "mf.GetLabel",masterFrame.GetLabel() - #print "mf.GetHandle",masterFrame.GetHandle() - #print "mf.GetParent",masterFrame.GetParent() - # here, GetParent consistent returns the master frame of the app. - #print "mf.GetGParent",masterFrame.GetGrandParent() #here, always None - #print "mf.GetTitle",masterFrame.GetTitle() - #print "mf.IsEnabled",masterFrame.IsEnabled() - #print "mf.IsShown",masterFrame.IsShown() - #print "mf.IsTopLevel",masterFrame.IsTopLevel() - #print "self.frame=",self.frame - def on_cell_change(self,evt): row = evt.GetRow() @@ -2059,32 +1674,21 @@ value = self.GetCellValue(row,col) try: int(value) - if col==1: - self.rows[row].set('base',value) - elif col==2: - self.rows[row].set('second',value) - elif col==3: - self.rows[row].set('third',value) - elif col==4: - self.rows[row].set('forth',value) - elif col==5: - self.rows[row].set('fifth',value) - elif col==6: - self.rows[row].set('sixth',value) - elif col==8: - self.rows[row].set('misc',value) - #print "row:",row,"value",value,self.rows[row] + if col==1: self.rows[row].set('base',value) + elif col==2: self.rows[row].set('second',value) + elif col==3: self.rows[row].set('third',value) + elif col==4: self.rows[row].set('forth',value) + elif col==5: self.rows[row].set('fifth',value) + elif col==6: self.rows[row].set('sixth',value) + elif col==8: self.rows[row].set('misc',value) self.parent.refresh_data() - except: - self.SetCellValue(row,col,"0") + except: self.SetCellValue(row,col,"0") def refresh_data(self): - melee = self.handler.get_attack_data('m') ranged = self.handler.get_attack_data('r') tmelee = int(melee[0]) + int(melee[6]) + int(melee[7]) tranged = int(ranged[0]) + int(ranged[6]) + int(ranged[7]) - # for i in range(0,7): #d 1.5005 for i in range(0,8): #a 1.5005 self.SetCellValue(0,i+1,str(melee[i])) self.SetCellValue(1,i+1,str(ranged[i])) @@ -2097,43 +1701,35 @@ self.SetReadOnly(0,9) self.SetReadOnly(1,9) - def on_size(self,evt): (w,h) = self.GetClientSizeTuple() cols = self.GetNumberCols() col_w = w/(cols+1) self.SetColSize(0,col_w*2) - for i in range(1,cols): - self.SetColSize(i,col_w) + for i in range(1,cols): self.SetColSize(i,col_w) evt.Skip() self.Refresh() class weapon_panel(wx.Panel): def __init__(self, parent, handler): - self.hparent = handler #a 1.5012 + self.hparent = handler self.root = getRoot(self) - pname = handler.xml.set("name", 'Weapons') - wx.Panel.__init__(self, parent, -1) self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.grid, 1, wx.EXPAND) - sizer2 = wx.BoxSizer(wx.HORIZONTAL) sizer2.Add(wx.Button(self, 10, "Remove Weapon"), 0, wx.EXPAND) sizer2.Add(wx.Size(10,10)) sizer2.Add(wx.Button(self, 20, "Add Weapon"), 0, wx.EXPAND) - sizer.Add(sizer2, 0, wx.EXPAND) sizer.Add(wx.StaticText(self, -1, "Right click a weapon's footnote to see what the footnotes mean."),0, wx.EXPAND)#a 1.5012 self.sizer = sizer self.SetSizer(self.sizer) self.SetAutoLayout(True) self.Fit() - self.sizer2 = sizer2 - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) self.Bind(wx.EVT_BUTTON, self.on_add, id=20) self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) @@ -2143,19 +1739,14 @@ self.n_list = n_list self.xml = handler.xml self.handler = handler - #trash=input("weapon panel init colnames") self.colAttr = ['name','damage','mod','critical','type','weight', - 'range','size','Total','fn', 'comment'] #a 1.5012 + 'range','size','Total','fn', 'comment'] col_names = ['Name','Damage','To hit\nmod','Critical','Type','Weight', - 'Range','Size','Total','Foot\nnotes','Comment'] #a 1.5012 - gridColCount=len(col_names)#a 1.5012 - self.grid.CreateGrid(len(n_list),gridColCount,1) #a 1.5012 - #self.grid.CreateGrid(len(n_list),9,1) #d 1.5012 + 'Range','Size','Total','Foot\nnotes','Comment'] + gridColCount=len(col_names) + self.grid.CreateGrid(len(n_list),gridColCount,1) self.grid.SetRowLabelSize(0) - #col_names = ['Name','damage','mod','critical','type','weight','range', 'size','Total'] #d 1.5012 - #for i in range(len(col_names)): #d 1.5012 - for i in range(gridColCount): #a 1.5012 - self.grid.SetColLabelValue(i,col_names[i]) + for i in range(gridColCount): self.grid.SetColLabelValue(i,col_names[i]) self.refresh_data() self.temp_dom = None @@ -2163,21 +1754,16 @@ #mark4 #a 1.5012 add entire method. def on_gridRclick(self,evt): - #print "weapon_panel, on_rclick: self,evt",self,evt row = evt.GetRow() col = evt.GetCol() value = self.grid.GetCellValue(row,col) - #print "wp, on rclick,grid row,col,value",row,col,value if col == 9 and value != 'None': n = self.n_list[row] name = n.get('name') - #print "we want a panel!" handler = self.hparent - #print "handler:",handler # A handler is a node, and nodes have a reference to # the master frame masterFrame = handler.frame - #print "masterFrame:",masterFrame title = name+"'s Special Weapon Characteristics" fnFrame = wx.Frame(masterFrame, -1, title) fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1) @@ -2186,14 +1772,12 @@ xml_dom = tree.getroot() self.temp_dom = xml_dom f_list = self.temp_dom.findall('f') # the footnotes - #print "weapon_panel - on_rclick f_list",f_list#a 1.6 n = self.n_list[row] name = n.get('name') footnotes = n.get('fn') html_str = "" html_str += """\n""" - #print "rclick,name,fn",name,footnotes if footnotes == "": html_str += "" html_str += " " @@ -2212,15 +1796,12 @@ html_str += "
NoteDescription
This weapon has no footnotes
" html_str += " " - - #print html_str fnFrame.panel.SetPage(html_str) fnFrame.Show() return pass - def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() @@ -2232,25 +1813,11 @@ self.n_list[row].get('fn') == "None" ): #a 5.012 special case for footnotes self.n_list[row].set(self.colAttr[col],value)#a 5.012 - #print "cell change",row,col,value - #if col == 0:#d 5.012 use of colAttr removed need for this. - # self.n_list[row].set('name',value) #d 5.012 - #elif col == 2: #d 5.012 - # try:#d 5.012 simplifying... remove this block. - # int(value) - # self.n_list[row].set('mod',value) - # #self.refresh_row(row) #d 5.012 did nothing. - # except: - # value = "0" - # self.n_list[row].set('mod',value) - #else: #d 5.012 demoted self.n set. - # self.n_list[row].set(self.grid.GetColLabelValue(col),value) def refresh_row(self,i): n = self.n_list[i] fn = n.get('fn') - #print "fn=",fn name = n.get('name') mod = n.get('mod') ran = n.get('range') @@ -2266,15 +1833,10 @@ self.grid.SetCellValue(i,8,total) self.grid.SetCellValue(i,9,safeGetAttr(n,'fn','None')) #a 1.5012 self.grid.SetCellValue(i,10,safeGetAttr(n,'comment','')) #a 1.5012 - #fn=safeGetAttr(n,'fn','None') #a (debug) 1.5012 - #print "fn ",fn,"<" #a (debug) 1.5012 - #o 1.5012 original damage vs what someone has changed it to. - self.grid.SetReadOnly(i,8) def on_remove(self,evt): #o 1.6011 correcting wrongful deletion rows = self.grid.GetNumberRows() - #for i in range(rows): #d 1.6011 do it backwards, for i in range(rows-1,-1,-1): #a 1.6011 or you lose context if self.grid.IsInSelection(i,0): self.grid.DeleteRows(i) @@ -2289,18 +1851,14 @@ self.temp_dom = xml_dom f_list = self.temp_dom.findall('weapon') opts = [] - #print "weapon_panel - on_add f_list",f_list#a 1.6 for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() - #print f_list[i] # DOM Element: weapon. new_node = self.xml.append(f_list[i]) - #print self.grid.AppendRows # a bound method of wxGrid self.grid.AppendRows(1) self.n_list = self.xml.findall('weapon') - #print "self.n_list",self.n_list # list of DOM weapons self.refresh_row(self.grid.GetNumberRows()-1) self.handler.refresh_weapons() dlg.Destroy() @@ -2314,22 +1872,17 @@ cols = self.grid.GetNumberCols() col_w = w/(cols+1) self.grid.SetColSize(0,col_w*2) - for i in range(1,cols): - self.grid.SetColSize(i,col_w) + for i in range(1,cols): self.grid.SetColSize(i,col_w) def refresh_data(self): - - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class attack_panel(wx.Panel): def __init__(self, parent, handler): pname = handler.xml.set("name", 'Melee') self.parent = parent #a 1.9001 - wx.Panel.__init__(self, parent, -1) - self.a_grid = attack_grid(self, handler) self.w_panel = weapon_panel(self, handler) self.sizer = wx.BoxSizer(wx.VERTICAL) @@ -2337,13 +1890,11 @@ self.sizer.Add(self.w_panel, 2, wx.EXPAND) self.Bind(wx.EVT_SIZE, self.on_size) - def on_size(self,event): s = self.GetClientSizeTuple() self.sizer.SetDimension(0,0,s[0],s[1]) def refresh_data(self): - self.w_panel.refresh_data() self.a_grid.refresh_data() @@ -2354,9 +1905,9 @@ """ def __init__(self,xml_dom,tree_node,parent): combat_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. - self.root = getRoot(self) #a 1.5002 - self.root.ac = self #a 1.6009 + self.hparent = parent + self.root = getRoot(self) + self.root.ac = self def get_spell_failure(self): return self.get_total('spellfailure') @@ -2371,13 +1922,10 @@ ac_total = 10 ac_total += self.get_total('bonus') - #m 1.5009 change to hardcode dex, was incorrect gv "stat" - dex_mod = self.root.abilities.get_mod('Dex')#m 1.5009 hardcode dex + dex_mod = self.root.abilities.get_mod('Dex') max_dex = self.get_max_dex() - if dex_mod < max_dex: - ac_total += dex_mod - else: - ac_total += max_dex + if dex_mod < max_dex: ac_total += dex_mod + else: ac_total += max_dex return ac_total def get_max_dex(self): @@ -2385,15 +1933,13 @@ dex = 10 for a in armor_list: temp = int(a.get("maxdex")) - if temp < dex: - dex = temp + if temp < dex: dex = temp return dex def get_total(self,attr): armor_list = self.xml.findall('armor') total = 0 - for a in armor_list: - total += int(a.get(attr)) + for a in armor_list: total += int(a.get(attr)) return total def get_design_panel(self,parent): @@ -2404,7 +1950,6 @@ def on_rclick( self, evt ): ac = self.get_armor_class() fac = (int(ac)-(self.root.abilities.get_mod('Dex'))) - txt = '((AC: %s Normal, %s Flatfoot))' % ( ac, fac ) #a 1.5002 self.chat.ParsePost( txt, True, True ) @@ -2441,27 +1986,20 @@ class ac_panel(wx.Panel): def __init__(self, parent, handler): pname = handler.xml.set("name", 'Armor') - self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 we need the functional parent, not the invoking parent. - + self.hparent = handler wx.Panel.__init__(self, parent, -1) self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.grid, 1, wx.EXPAND) - sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(wx.Button(self, 10, "Remove Armor"), 1, wx.EXPAND) sizer1.Add(wx.Size(10,10)) sizer1.Add(wx.Button(self, 20, "Add Armor"), 1, wx.EXPAND) - sizer.Add(sizer1, 0, wx.EXPAND) - self.sizer = sizer self.SetSizer(self.sizer) self.SetAutoLayout(True) self.Fit() - - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) self.Bind(wx.EVT_BUTTON, self.on_add, id=20) self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) @@ -2471,12 +2009,10 @@ col_names = ['Armor','bonus','maxdex','cp','sf','weight','speed','type'] self.grid.CreateGrid(len(n_list),len(col_names),1) self.grid.SetRowLabelSize(0) - for i in range(len(col_names)): - self.grid.SetColLabelValue(i,col_names[i]) + for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) self.atts =['name','bonus','maxdex','checkpenalty', 'spellfailure','weight','speed','type'] - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None @@ -2488,16 +2024,12 @@ try: int(value) self.n_list[row].set(self.atts[col],value) - except: - self.grid.SetCellValue(row,col,"0") - else: - self.n_list[row].set(self.atts[col],value) + except: self.grid.SetCellValue(row,col,"0") + else: self.n_list[row].set(self.atts[col],value) def refresh_row(self,i): n = self.n_list[i] - - for y in range(len(self.atts)): - self.grid.SetCellValue(i,y,n.get(self.atts[y])) + for y in range(len(self.atts)): self.grid.SetCellValue(i,y,n.get(self.atts[y])) def on_remove(self,evt): rows = self.grid.GetNumberRows() @@ -2513,8 +2045,7 @@ self.temp_dom = xml_dom f_list = self.temp_dom.findall('armor') opts = [] - for f in f_list: - opts.append(f.get('name')) + for f in f_list: opts.append(f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts) if dlg.ShowModal() == wx.ID_OK: i = dlg.GetSelection() @@ -2531,8 +2062,7 @@ cols = self.grid.GetNumberCols() col_w = w/(cols+2) self.grid.SetColSize(0,col_w*3) - for i in range(1,cols): - self.grid.SetColSize(i,col_w) + for i in range(1,cols): self.grid.SetColSize(i,col_w) class dnd3esnp(dnd3e_char_child): @@ -2542,9 +2072,7 @@ def __init__(self,xml_dom,tree_node,parent): node_handler.__init__(self,xml_dom,tree_node) dnd3e_char_child.__init__(self,xml_dom,tree_node,parent) - self.hparent = parent #a 1.5002 allow ability to run up tree. - - + self.hparent = parent self.frame = component.get('frame') self.child_handlers = {} self.new_child_handler('spells','Spells',dnd3espells,'book') @@ -2567,13 +2095,7 @@ def get_use_panel(self,parent): return tabbed_panel(parent,self,2) - -# def set_char_pp(self,attr,evl): #d 1.5002 doesn't seem to be used, but -# dnd_globals["pp"][attr] = evl #d 1.5002 uses dnd_globals, so tossing. - - -# def get_char_pp( self, attr ): #d 1.5002 doesn't seem to be used, but -# return dnd_globals["pp"][attr] #d 1.5002 doesn't seem to be used, but + class snp_char_child(node_handler): """ Node Handler for skill. This handler will be @@ -2586,8 +2108,6 @@ self.frame = component.get('frame') self.myeditor = None - - def on_drop(self,evt): pass @@ -2650,17 +2170,13 @@ left = eval( '%s - ( %s )' % ( memrz, use ) ) if left < 0: txt = '%s Tried to cast %s but has used all of them for today,' - #txt +='"Please rest so I can cast more."' % ( dnd_globals["gen"]["Name"], name )##d 1.5002 txt +='"Please rest so I can cast more."' % ( charNameL, name ) #a 1.5002 self.chat.ParsePost( txt, True, False ) else: - #txt = '%s casts %s ( level %s, "%s" )' % ( dnd_globals["gen"]["Name"], name, level, descr )#d 1.5002 txt = '%s casts %s ( level %s, "%s" )' % ( charNameL, name, level, descr )#a f 1.5002 self.chat.ParsePost( txt, True, False ) s = '' - if left != 1: - s = 's' - #txt = '%s can cast %s %d more time%s' % ( dnd_globals["gen"]["Name"], name, left, s )#d 1.5002 + if left != 1: s = 's' txt = '%s can cast %s %d more time%s' % ( charNameL, name, left, s ) #a 1.5002 self.chat.ParsePost( txt, False, False ) self.spells[ name ].set( 'used', `eval( use )` ) @@ -2685,8 +2201,7 @@ def tohtml(self): html_str = "
Arcane Spells

" n_list = self.xml.getchildren() - for n in n_list: - html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " + for n in n_list: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -2697,28 +2212,22 @@ def __init__(self, parent, handler): pname = handler.xml.set("name", 'Arcane Spells') self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 in this case, we need the functional parent, not the invoking parent. - wx.Panel.__init__(self, parent, -1) self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) self.handler = handler sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.grid, 1, wx.EXPAND) - sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(wx.Button(self, 10, "Remove Spell"), 1, wx.EXPAND) sizer1.Add(wx.Size(10,10)) sizer1.Add(wx.Button(self, 20, "Add Spell"), 1, wx.EXPAND) sizer1.Add(wx.Size(10,10)) sizer1.Add(wx.Button(self, 30, "Refresh Spells"), 1, wx.EXPAND) - sizer.Add(sizer1, 0, wx.EXPAND) self.sizer = sizer self.SetSizer(self.sizer) self.SetAutoLayout(True) self.Fit() - - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) self.Bind(wx.EVT_BUTTON, self.on_add, id=20) self.Bind(wx.EVT_BUTTON, self.on_refresh_spells, id=30) @@ -2732,21 +2241,17 @@ self.grid.SetColLabelValue(1,"Lvl") self.grid.SetColLabelValue(2,"Spell") self.grid.SetColLabelValue(3,"Desc") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def on_cell_change(self,evt): row = evt.GetRow() col = evt.GetCol() value = self.grid.GetCellValue(row,col) - if col == 0: - self.n_list[row].set('memrz',value) - + if col == 0: self.n_list[row].set('memrz',value) def refresh_row(self,i): spell = self.n_list[i] - memrz = spell.get('memrz') name = spell.get('name') type = spell.get('desc') @@ -2755,8 +2260,7 @@ self.grid.SetCellValue(i,2,name) self.grid.SetReadOnly(i,2) self.grid.SetCellValue(i,3,type) - self.grid.SetReadOnly(i,3) - self.grid.SetCellValue(i,1,level) + self.grid.SetReadOnly(i,3) self.grid.SetCellValue(i,1,level) self.grid.SetReadOnly(i,1) def on_remove(self,evt): @@ -2779,10 +2283,6 @@ #castlvl = eval('%s/2' % (lvl)) for f in f_list: spelllvl = f.get('level') - #if spelllvl <= "1": - # opts.append("(" + f.get('level') + ")" + f.get('name')) - #else: - # if eval('%d >= %s' %(castlvl, spelllvl)): opts.append("(" + f.get('level') + ")" + f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts) if dlg.ShowModal() == wx.ID_OK: @@ -2796,9 +2296,7 @@ def on_refresh_spells( self, evt ): f_list = self.xml.findall('spell') - - for spell in f_list: - spell.set( 'used', '0' ) + for spell in f_list: spell.set( 'used', '0' ) def on_size(self,event): s = self.GetClientSizeTuple() @@ -2807,16 +2305,14 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) self.grid.SetColSize(0,w * 0.10) self.grid.SetColSize(1,w * 0.10) self.grid.SetColSize(2,w * 0.30) self.grid.SetColSize(3,w * 0.50) def refresh_data(self): - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class dnd3edivine(snp_char_child): """ Node Handler for classes. This handler will be @@ -2827,8 +2323,6 @@ self.hparent = parent #a 1.5002 allow ability to run up tree. self.root = getRoot(self) #a 1.5002 self.root.divine = self #a 1.6009 - - node_list = self.xml.findall( 'gift' ) self.spells = {} tree = self.tree @@ -2855,16 +2349,12 @@ if left < 0: txt = '%s Tried to cast %s but has used all of them for today,' #m 1.5002 break in 2. txt += "Please rest so I can cast more."' % ( charNameL, name )' #a 1.5002 - #txt += "Please rest so I can cast more."' % ( dnd_globals["gen"]["Name"], name ) #d 1.5002 self.chat.ParsePost( txt, True, False ) else: - #txt = '%s casts %s ( level %s, "%s" )' % ( dnd_globals["gen"]["Name"], name, level, descr ) #d 1.5002 txt = '%s casts %s ( level %s, "%s" )' % ( charNameL, name, level, descr ) #a 5002 self.chat.ParsePost( txt, True, False ) s = '' - if left != 1: - s = 's' - #txt = '%s can cast %s %d more time%s' % ( dnd_globals["gen"]["Name"], name, left, s ) #d 1.5002 + if left != 1: s = 's' txt = '%s can cast %s %d more time%s' % ( charNameL, name, left, s ) #a 1.5002 self.chat.ParsePost( txt, False, False ) self.spells[ name ].set( 'used', `eval( use )` ) @@ -2874,7 +2364,6 @@ tree = self.tree icons = self.tree.icons tree.CollapseAndReset(self.mytree_node) - node_list = self.xml.findall('gift') for n in node_list: name = n.get('name') @@ -2890,8 +2379,7 @@ def tohtml(self): html_str = "
Divine Spells

" n_list = self.xml.getchildren() - for n in n_list: - html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " + for n in n_list: html_str += "(" + n.get('level') + ") " + n.get('name')+ ", " html_str = html_str[:len(html_str)-2] + "
" return html_str @@ -2901,30 +2389,24 @@ class divine_panel(wx.Panel): def __init__(self, parent, handler): pname = handler.xml.set("name", 'Divine Spells') - self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 in this case, we need the functional parent, not the invoking parent. - + self.hparent = handler wx.Panel.__init__(self, parent, -1) self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) self.handler = handler sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.grid, 1, wx.EXPAND) - sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(wx.Button(self, 10, "Remove Spell"), 1, wx.EXPAND) sizer1.Add(wx.Size(10,10)) sizer1.Add(wx.Button(self, 20, "Add Spell"), 1, wx.EXPAND) sizer1.Add(wx.Size(10,10)) sizer1.Add(wx.Button(self, 30, "Refresh Spells"), 1, wx.EXPAND) - sizer.Add(sizer1, 0, wx.EXPAND) self.sizer = sizer self.SetSizer(self.sizer) self.SetAutoLayout(True) self.Fit() - - #self.Bind(wx.EVT_SIZE, self.on_size) - self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) + self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) self.Bind(wx.EVT_BUTTON, self.on_add, id=20) self.Bind(wx.EVT_BUTTON, self.on_refresh_spells, id=30) self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) @@ -2938,22 +2420,17 @@ self.grid.SetColLabelValue(1,"Lvl") self.grid.SetColLabelValue(2,"Spell") self.grid.SetColLabelValue(3,"Desc") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.temp_dom = None def on_cell_change(self,evt): row = evt.GetRow() - col = evt.GetCol() value = self.grid.GetCellValue(row,col) - if col == 0: - self.n_list[row].set('memrz',value) - + if col == 0: self.n_list[row].set('memrz',value) def refresh_row(self,i): spell = self.n_list[i] - memrz = spell.get('memrz') name = spell.get('name') type = spell.get('desc') @@ -2980,14 +2457,8 @@ self.temp_dom = xml_dom f_list = self.temp_dom.findall('gift') opts = [] - #lvl = int(dnd3e_char_child.get_char_lvl('level')) - #castlvl = lvl / 2 for f in f_list: spelllvl = f.get('level') - #if spelllvl <= "1": - # opts.append("(" + f.get('level') + ")" + f.get('name')) - #else: - # if eval('%d >= %s' %(castlvl, spelllvl)): opts.append("(" + f.get('level') + ")" + f.get('name')) dlg = wx.SingleChoiceDialog(self,'Choose Spell','Spells',opts) if dlg.ShowModal() == wx.ID_OK: @@ -3001,8 +2472,7 @@ def on_refresh_spells( self, evt ): f_list = self.xml.findall('gift') - for spell in f_list: - spell.set( 'used', '0' ) + for spell in f_list: spell.set( 'used', '0' ) def on_size(self,event): s = self.GetClientSizeTuple() @@ -3011,17 +2481,14 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) self.grid.SetColSize(0,w * 0.10) self.grid.SetColSize(1,w * 0.10) self.grid.SetColSize(2,w * 0.30) self.grid.SetColSize(3,w * 0.50) def refresh_data(self): - - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class dnd3epowers(snp_char_child): @@ -3075,8 +2542,7 @@ % ( charNameL, name, level, descr )) #a 1.5002 self.chat.ParsePost( txt, True, False ) s = '' - if left != 1: - s = 's' + if left != 1: s = 's' txt = '%s has %d Free Talent%s left' % ( charNameL, numcast, s ) #a 1.5002 self.chat.ParsePost( txt, False, False ) self.root.pp.set_char_pp('free',left) #a 1.5002 @@ -3101,7 +2567,6 @@ def refresh_powers(self): self.powers = {} - tree = self.tree icons = self.tree.icons tree.CollapseAndReset(self.mytree_node) @@ -3130,8 +2595,7 @@ def __init__(self, parent, handler): #m 1.5015 corrected typo, was Pionic. pname = handler.xml.set("name", 'Psionic Powers') - self.hparent = handler #a 1.5002 allow ability to run up tree. In this - #a 1.5002 case, we need the functional parent, not the invoking parent. + self.hparent = handler self.root = getRoot(self) #a (debug) 1.5002,1.5014 wx.Panel.__init__(self, parent, -1) @@ -3168,8 +2632,7 @@ self.grid.SetColLabelValue(2,"Power") self.grid.SetColLabelValue(3,"Desc") self.grid.SetColLabelValue(4,"Type") - for i in range(len(n_list)): - self.refresh_row(i) + for i in range(len(n_list)): self.refresh_row(i) self.refresh_data() self.temp_dom = None @@ -3177,13 +2640,9 @@ row = evt.GetRow() col = evt.GetCol() value = self.grid.GetCellValue(row,col) - """if col == 0: - self.n_list[row].set('memrz',value)""" - def refresh_row(self,i): power = self.n_list[i] - point = power.get('point') name = power.get('name') type = power.get('desc') @@ -3216,14 +2675,8 @@ debug(self.temp) f_list = self.temp_dom.findall('power') opts = [] - #lvl = int(dnd3e_char_child.get_char_lvl('level')) - #castlvl = lvl / 2 for f in f_list: spelllvl = f.get('level') - #if spelllvl <= "1": - # opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) - #else: - # if eval('%d >= %s' %(castlvl, spelllvl)): opts.append("(" + f.get('level') + ") - " + f.get('name') + " - " + f.get('test')) dlg = wx.SingleChoiceDialog(self,'Choose Power','Powers',opts) @@ -3246,12 +2699,8 @@ self.handler.refresh_powers() def on_refresh_powers( self, evt ): - #a 1.5002,1.5014 s self.root.pp.set_char_pp('current1',self.root.pp.get_char_pp('max1')) self.root.pp.set_char_pp('free',self.root.pp.get_char_pp('maxfree')) - #a 1.5002,1.5014 e - - def on_size(self,event): s = self.GetClientSizeTuple() @@ -3260,8 +2709,7 @@ (w,h) = self.grid.GetClientSizeTuple() cols = self.grid.GetNumberCols() col_w = w/(cols) - for i in range(0,cols): - self.grid.SetColSize(i,col_w) + for i in range(0,cols): self.grid.SetColSize(i,col_w) self.grid.SetColSize(0,w * 0.05) self.grid.SetColSize(1,w * 0.05) self.grid.SetColSize(2,w * 0.30) @@ -3269,9 +2717,7 @@ self.grid.SetColSize(4,w * 0.30) def refresh_data(self): - - for i in range(len(self.n_list)): - self.refresh_row(i) + for i in range(len(self.n_list)): self.refresh_row(i) class dnd3epp(snp_char_child): """ Node Handler for power points. This handler will be @@ -3284,7 +2730,6 @@ self.root.pp = self self.ppPanel=None - def get_design_panel(self,parent): wnd = outline_panel(parent,self,pp_panel,"Power Points") wnd.title = "Power Points" @@ -3293,9 +2738,7 @@ def tohtml(self): html_str = "" - #html_str += "" #d 1.6010 html_str += "" #a 1.6010 - #m 1.6010 rearanged everything below to "return html_str" html_str += "" html_str += "" html_str += "" @@ -3311,23 +2754,16 @@ def get_char_pp( self, attr ): pp = self.xml.get(attr) - #print "dnd3epp -get_char_pp: attr,pp",attr,pp return pp def set_char_pp( self, attr, evl ): qSub = str(evl) #a 1.5014 must force it to be a string for next call. self.xml.set(attr, qSub) - #This function needs to be looked at the idea is to refresh the power panel - #But it causes a seg fault when you refresh from powers -mgt - #if self.ppPanel: #a 1.5015 - # self.ppPanel.on_refresh(attr,qSub) #a 1.5015 - class pp_panel(wx.Panel): def __init__(self, parent, handler): wx.Panel.__init__(self, parent, -1) self.hparent = handler #a 1.5002 allow ability to run up tree. - #a 1.5002 we need the functional parent, not the invoking parent. self.hparent.ppPanel=self #a 1.5xx pname = handler.xml.set("name", 'PowerPoints') @@ -3339,10 +2775,6 @@ self.xml.get('current1')) #a 1.5015 self.dyn3= wx.TextCtrl(self, PP_FRE, self.xml.get('free')) #a 1.5015 -# self.sizer.AddMany([ (wx.StaticText(self, -1, "PP Current:"), #d 1.5015 -# 0, wx.ALIGN_CENTER_VERTICAL), -# (wx.TextCtrl(self, PP_CUR, #d 1.5015 -# self.xml.get('current1')), 0, wx.EXPAND), self.sizer.AddMany([ (self.static1, 0, wx.ALIGN_CENTER_VERTICAL), (self.dyn1, 0, wx.EXPAND), (wx.StaticText(self, -1, "PP Max:"), 0, wx.ALIGN_CENTER_VERTICAL), @@ -3351,8 +2783,6 @@ (wx.StaticText(self, -1, "Current Free Talants per day:"), 0, wx.ALIGN_CENTER_VERTICAL), (self.dyn3, 0, wx.EXPAND), #a 1.5015 -# (wx.TextCtrl(self, PP_FRE, -# self.xml.get('free')), 0, wx.EXPAND),#d 1.5015 (wx.StaticText(self, -1, "Max Free Talants per day:"), 0, wx.ALIGN_CENTER_VERTICAL), (wx.TextCtrl(self, PP_MFRE, @@ -3363,8 +2793,6 @@ self.SetSizer(self.sizer) self.SetAutoLayout(True) self.Fit() - - #self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_TEXT, self.on_text, id=PP_MAX) self.Bind(wx.EVT_TEXT, self.on_text, id=PP_CUR) self.Bind(wx.EVT_TEXT, self.on_text, id=PP_FRE) @@ -3372,14 +2800,10 @@ def on_text(self,evt): id = evt.GetId() - if id == PP_CUR: - self.xml.set('current1',evt.GetString()) - elif id == PP_MAX: - self.xml.set('max1',evt.GetString()) - elif id == PP_FRE: - self.xml.set('free',evt.GetString()) - elif id == PP_MFRE: - self.xml.set('maxfree',evt.GetString()) + if id == PP_CUR: self.xml.set('current1',evt.GetString()) + elif id == PP_MAX: self.xml.set('max1',evt.GetString()) + elif id == PP_FRE: self.xml.set('free',evt.GetString()) + elif id == PP_MFRE: self.xml.set('maxfree',evt.GetString()) def on_size(self,evt): s = self.GetClientSizeTuple() @@ -3387,7 +2811,5 @@ #a 5.015 this whole function. def on_refresh(self,attr,value): - if attr == 'current1': - self.dyn1.SetValue(value) - else: - self.dyn3.SetValue(value) + if attr == 'current1': self.dyn1.SetValue(value) + else: self.dyn3.SetValue(value) diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/forms.py --- a/orpg/gametree/nodehandlers/forms.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/forms.py Wed Nov 25 06:15:49 2009 -0600 @@ -211,8 +211,7 @@ def tohtml(self): txt = self.get_value() txt = string.replace(txt,'\n',"
") - if not self.is_hide_title(): - txt = ""+self.xml.get("name")+": "+txt + if not self.is_hide_title(): txt = ""+self.xml.get("name")+": "+txt return txt def get_value(self): @@ -245,8 +244,7 @@ sizer.Add(wx.Size(5,0)) sizer.Add(self.text, 1, sizer_style) - if handler.has_send_button(): - sizer.Add(wx.Button(self, FORM_SEND_BUTTON, "Send"), 0, sizer_style) + if handler.has_send_button(): sizer.Add(wx.Button(self, FORM_SEND_BUTTON, "Send"), 0, sizer_style) self.sizer = sizer self.SetSizer(sizer) @@ -545,18 +543,14 @@ if type != L_RADIO: sizer.Add(wx.StaticText(self, -1, label+": "), 0, wx.EXPAND) sizer.Add(wx.Size(5,0)) - sizer.Add(self.list, 1, wx.EXPAND) - if handler.has_send_button(): sizer.Add(wx.Button(self, F_SEND, "Send"), 0, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.handler.on_send_to_chat, id=F_SEND) - self.sizer = sizer self.SetSizer(sizer) self.SetAutoLayout(True) self.Fit() - parent.SetSize(self.GetBestSize()) if type == L_DROP: self.Bind(wx.EVT_COMBOBOX, self.on_change, id=F_LIST) @@ -715,7 +709,7 @@ def tohtml(self): href = self.link.get("href") title = self.xml.get("name") - return ""+title+"" + return ""+title+"" class link_panel(wx.StaticText): def __init__(self,parent,handler): @@ -725,7 +719,6 @@ self.SetForegroundColour(wx.BLUE) self.Bind(wx.EVT_LEFT_DOWN, self.handler.on_use) - P_URL = wx.NewId() class link_edit_panel(wx.Panel): @@ -754,8 +747,7 @@ if id == P_TITLE: self.handler.xml.set('name',txt) self.handler.rename(txt) - elif id == P_URL: - self.handler.link.set('href',txt) + elif id == P_URL: self.handler.link.set('href',txt) ########################## ## webimg node handler @@ -775,11 +767,10 @@ def get_use_panel(self,parent): img = img_helper().load_url(self.link.get("href")) - if not img is None: - return wx.StaticBitmap(parent,-1,img,size= wx.Size(img.GetWidth(),img.GetHeight())) + if not img is None: return wx.StaticBitmap(parent,-1,img,size= wx.Size(img.GetWidth(),img.GetHeight())) return wx.EmptyBitmap(1, 1) def tohtml(self): href = self.link.get("href") title = self.xml.get("name") - return "+title+" + return "+title+" diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/map_miniature_nodehandler.py --- a/orpg/gametree/nodehandlers/map_miniature_nodehandler.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/map_miniature_nodehandler.py Wed Nov 25 06:15:49 2009 -0600 @@ -41,7 +41,6 @@ """ - def __init__(self,xml,tree_node): node_handler.__init__(self,xml,tree_node) self.mapper = component.get("map") @@ -56,11 +55,8 @@ if path: path = urllib.unquote(path) - if ImageHandler.Cache.has_key(path): - bmp = ImageHandler.Cache[path] - else: - #bmp = ImageHandler.directLoad(path, 'miniature', id) - bmp = ImageHandler.directLoad(path)# Old Code TaS. + if ImageHandler.Cache.has_key(path): bmp = ImageHandler.Cache[path] + else: bmp = ImageHandler.directLoad(path)# Old Code TaS. if bmp: img = wx.ImageFromMime(ImageHandler.Cache[path][1], ImageHandler.Cache[path][2]) @@ -111,20 +107,17 @@ width = int(self.xml.get("width")) height = int(self.xml.get("height")) pos = grid.get_snapped_to_pos(pos, align, width, height) - except: - pass + except: pass self.miniature_xml.set("posx", str(pos.x)) self.miniature_xml.set("posy", str(pos.y)) new_xml = self.get_to_map_XML() if (self.session.my_role() != self.session.ROLE_GM) and (self.session.my_role() != self.session.ROLE_PLAYER): component.get("chat").InfoPost("You must be either a player or GM to use the miniature Layer") return - if new_xml: self.mapper.new_data(new_xml) self.session.send(new_xml) - else: - print "problem converting old mini xml to new mini xml" + else: print "problem converting old mini xml to new mini xml" def about(self): return "Miniature node by Andrew Bennett" @@ -134,4 +127,4 @@ html_str += "
" html_str += "
\n" html_str += "
Power Points
Power Points
Max:"+self.xml.get('max1')+"
" + self.xml.get("name") + "
" - return html_str \ No newline at end of file + return html_str diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/minilib.py --- a/orpg/gametree/nodehandlers/minilib.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/minilib.py Wed Nov 25 06:15:49 2009 -0600 @@ -104,21 +104,16 @@ url = mini.get(ATTRIBUTE_URL) label = mini.get(ATTRIBUTE_NAME) flag = 0 - try: - flag = eval( mini.get(ATTRIBUTE_UNIQUE) ) - except: - pass + try: flag = eval( mini.get(ATTRIBUTE_UNIQUE) ) + except: pass show = 'yes' - if flag: - show = 'no' - + if flag: show = 'no' str += """ %s %s %s """ % ( label, url, url, show ) - str += "" return str @@ -129,8 +124,7 @@ def on_drop(self, evt): drag_obj = self.tree.drag_obj - if drag_obj == self or self.tree.is_parent_node( self.mytree_node, drag_obj.mytree_node ): - return + if drag_obj == self or self.tree.is_parent_node( self.mytree_node, drag_obj.mytree_node ): return elif isinstance( drag_obj, map_miniature_nodehandler.map_miniature_handler ): drop_xml = self.tree.drag_obj.xml#.delete() obj = drop_xml[0] @@ -138,21 +132,17 @@ unique = '' for attrib in obj.keys(): key = TO_MINILIB_MAP.get( attrib, attrib ) - if key != None: - dict[ key ] = obj.get( attrib ) + if key != None: dict[ key ] = obj.get( attrib ) dict[ ATTRIBUTE_UNIQUE ] = unique self.new_mini( dict ) - else: - node_handler.on_drop(self, evt) + else: node_handler.on_drop(self, evt) def new_mini( self, data={}, add=1 ): mini = Element( TAG_MINIATURE ) - for key in data.keys(): - mini.set( key, data[ key ] ) + for key in data.keys(): mini.set( key, data[ key ] ) for key in CORE_ATTRIBUTES: - if mini.get( key ) == '': - mini.set( key, '0' ) + if mini.get( key ) == '': mini.set( key, '0' ) if add: self.add_mini( mini ) self.add_leaf( mini ) @@ -169,15 +159,13 @@ def update_leaves( self ): self.mydata = [] - for n in self.xml.findall(TAG_MINIATURE): - self.add_leaf( n ) + for n in self.xml.findall(TAG_MINIATURE): self.add_leaf( n ) def on_drag( self, evt ): print 'drag event caught' def send_mini_to_map( self, mini, count=1, addName=True ): - if mini == None: - return + if mini == None: return if mini.get( ATTRIBUTE_URL ) == '' or mini.get( ATTRIBUTE_URL ) == 'http://': self.chat.ParsePost( self.chat.colorize(self.chat.syscolor, '"%s" is not a valid URL, the mini "%s" will not be added to the map' % ( mini.get( ATTRIBUTE_URL ), mini.get( ATTRIBUTE_NAME ) )) ) return @@ -202,15 +190,11 @@ # translate our attributes to map attributes key = FROM_MINILIB_MAP.get( k, k ) if key != None: - if not addName and k == 'name': - pass - else: - msg.init_prop( key, mini_xml.get( k ) ) + if not addName and k == 'name': pass + else: msg.init_prop( key, mini_xml.get( k ) ) unique = self.is_unique( mini_xml ) - if addName: - label = mini_xml.get( ATTRIBUTE_NAME ) - else: - label = '' + if addName: label = mini_xml.get( ATTRIBUTE_NAME ) + else: label = '' return msg.get_all_xml() def is_unique( self, mini ): @@ -259,9 +243,6 @@ self.map = component.get('map') names = self.buildList() - # self.keys = self.list.keys() - # self.keys.sort() - s = self.GetClientSizeTuple() @@ -298,8 +279,7 @@ """Returns a dictionary of label => game tree miniature DOM node mappings. """ self.list = [] - for mini in self.handler.xml.findall(TAG_MINIATURE): - self.list.append( mini.get( ATTRIBUTE_NAME ) ) + for mini in self.handler.xml.findall(TAG_MINIATURE): self.list.append( mini.get( ATTRIBUTE_NAME ) ) return self.list def on_close(self, evt): @@ -310,22 +290,15 @@ """ btn = self.FindWindowById(evt.GetId()) sendName = True - try: - count = eval( self.count.GetValue() ) - except: - count = 1 - + try: count = eval( self.count.GetValue() ) + except: count = 1 try: - if eval( unique ): - count = 1 + if eval( unique ): count = 1 unique = eval( unique ) - except: - pass + except: pass - if btn.GetLabel() == 'Add No Label': - sendName = False - for index in self.listbox.GetSelections(): - self.handler.send_mini_to_map( self.handler.get_mini( index ), count, sendName ) + if btn.GetLabel() == 'Add No Label': sendName = False + for index in self.listbox.GetSelections(): self.handler.send_mini_to_map( self.handler.get_mini( index ), count, sendName ) class minpedit(wx.Panel): @@ -394,12 +367,8 @@ 'How many %s\'s do you want to add?' % ( self.grid.getSelectedLabel() ), 'Batch mini add', '2' ) if dlg.ShowModal() == wx.ID_OK: - try: - value = eval( dlg.GetValue() ) - except: - value = 0 - # for loop in range( 0, value ): - # self.send_to_map() + try: value = eval( dlg.GetValue() ) + except: value = 0 print 'getting selected index for batch send' index = self.grid.GetGridCursorRow() print 'sending batch to map' @@ -415,15 +384,9 @@ wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS ) self.parent = parent self.handler = handler - #self.keys = [ ATTRIBUTE_NAME, ATTRIBUTE_URL, ATTRIBUTE_UNIQUE ] self.keys = CORE_ATTRIBUTES self.CreateGrid( 1, len( self.keys ) ) - # self.SetColLabelValue( 0, 'Name' ) - # self.SetColLabelValue( 1, 'URL' ) - # self.SetColSize( 1, 250 ) - # self.SetColLabelValue( 2, 'Unique' ) - for key in self.keys: - self.SetColLabelValue( self.keys.index( key ), key ) + for key in self.keys: self.SetColLabelValue( self.keys.index( key ), key ) self.update_all() self.selectedRow = 0 self.AutoSizeColumns() @@ -433,8 +396,7 @@ def update_cols( self ): for n in self.handler.xml.findall(TAG_MINIATURE): for k in n.keys(): - if k not in self.keys: - self.keys.append( k ) + if k not in self.keys: self.keys.append( k ) def select_cell( self, evt ): """Event handler for grid cell selection changes. It stores the @@ -492,13 +454,11 @@ count = 0 for n in list: for k in n.keys(): - if k not in self.keys: - self.keys.append( k ) + if k not in self.keys: self.keys.append( k ) count = len( self.keys ) if self.GetNumberCols() < count: self.AppendCols( count - self.GetNumberCols() ) - for k in self.keys: - self.SetColLabelValue( self.keys.index( k ), k ) + for k in self.keys: self.SetColLabelValue( self.keys.index( k ), k ) count = len( list ) rowcount = self.GetNumberRows() if ( count > rowcount ): @@ -531,13 +491,11 @@ """ list = self.getList() item = list[ row ] - for key in self.keys: - self.GetTable().SetValue( row, self.keys.index( key ), item.get( key ) ) + for key in self.keys: self.GetTable().SetValue( row, self.keys.index( key ), item.get( key ) ) def update_data_row( self, row ): """Updates the DOM nodw 'row' with grid data from 'row' """ list = self.getList() item = list[ row ] - for key in self.keys: - item.set( key, string.strip( self.GetTable().GetValue( row, self.keys.index( key ) ) ) ) + for key in self.keys: item.set( key, string.strip( self.GetTable().GetValue( row, self.keys.index( key ) ) ) ) diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/minilib.py~ --- a/orpg/gametree/nodehandlers/minilib.py~ Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/minilib.py~ Wed Nov 25 06:15:49 2009 -0600 @@ -32,11 +32,11 @@ miniatures as sending them to the map singly or in batches. """ from core import * -import orpg.dirpath +from orpg.dirpath import dir_struct import string import map_miniature_nodehandler -import orpg.mapper.map_msg -from orpg.mapper.images import ImageHandler +import orpg.mapper.map_msg +import orpg.minidom as minidom # import scriptkit # Constants @@ -68,15 +68,13 @@ </nodehandler> """ - def __init__(self, xml_dom, tree_node): + def __init__(self, xml, tree_node): """Instantiates the class, and sets all vars to their default state """ - node_handler.__init__(self, xml_dom, tree_node) - + node_handler.__init__(self, xml, tree_node) self.myeditor = None self.mywindow = None self.tree_node = tree_node - # self.xml_dom = xml_dom self.update_leaves() self.sanity_check_nodes() @@ -101,17 +99,15 @@ expecting for a given column. """ str = '' - list = self.master_dom.getElementsByTagName(TAG_MINIATURE) - str += "" - for mini in list: - url = mini.getAttribute(ATTRIBUTE_URL) - label = mini.getAttribute(ATTRIBUTE_NAME) + str += "" + for mini in self.xml.findall(TAG_MINIATURE): + url = mini.get(ATTRIBUTE_URL) + label = mini.get(ATTRIBUTE_NAME) flag = 0 try: - flag = eval( mini.getAttribute(ATTRIBUTE_UNIQUE) ) + flag = eval( mini.get(ATTRIBUTE_UNIQUE) ) except: pass - show = 'yes' if flag: show = 'no' @@ -124,7 +120,6 @@ """ % ( label, url, url, show ) str += "
LabelImageURLUnique
LabelImageURLUnique
" - print str return str def html_view( self ): @@ -136,122 +131,111 @@ drag_obj = self.tree.drag_obj if drag_obj == self or self.tree.is_parent_node( self.mytree_node, drag_obj.mytree_node ): return - if isinstance( drag_obj, minilib_handler ): - item = self.tree.GetSelection() - name = self.tree.GetItemText( item ) - if isinstance( drag_obj, map_miniature_nodehandler.map_miniature_handler ): - xml_dom = self.tree.drag_obj.master_dom#.delete() - obj = xml_dom.firstChild - print obj.getAttributeKeys() + elif isinstance( drag_obj, map_miniature_nodehandler.map_miniature_handler ): + drop_xml = self.tree.drag_obj.xml#.delete() + obj = drop_xml[0] dict = {} unique = '' - for attrib in obj.getAttributeKeys(): + for attrib in obj.keys(): key = TO_MINILIB_MAP.get( attrib, attrib ) if key != None: - dict[ key ] = obj.getAttribute( attrib ) + dict[ key ] = obj.get( attrib ) dict[ ATTRIBUTE_UNIQUE ] = unique self.new_mini( dict ) + else: + node_handler.on_drop(self, evt) def new_mini( self, data={}, add=1 ): - mini = minidom.Element( TAG_MINIATURE ) + mini = Element( TAG_MINIATURE ) for key in data.keys(): - mini.setAttribute( key, data[ key ] ) + mini.set( key, data[ key ] ) for key in CORE_ATTRIBUTES: - if mini.getAttribute( key ) == '': - mini.setAttribute( key, '0' ) + if mini.get( key ) == '': + mini.set( key, '0' ) if add: self.add_mini( mini ) self.add_leaf( mini ) return mini def add_mini( self, mini ): - self.master_dom.appendChild( mini ) + self.xml.append( mini ) def add_leaf( self, mini, icon='gear' ): tree = self.tree icons = tree.icons - key = mini.getAttribute( ATTRIBUTE_NAME ) + key = mini.get( ATTRIBUTE_NAME ) self.mydata.append( mini ) def update_leaves( self ): self.mydata = [] - nl = self.master_dom.getElementsByTagName( TAG_MINIATURE ) - for n in nl: + for n in self.xml.findall(TAG_MINIATURE): self.add_leaf( n ) - def on_drag( self, evt ): print 'drag event caught' def send_mini_to_map( self, mini, count=1, addName=True ): if mini == None: return - if mini.getAttribute( ATTRIBUTE_URL ) == '' or mini.getAttribute( ATTRIBUTE_URL ) == 'http://': - self.chat.ParsePost( self.chat.colorize(self.chat.syscolor, '"%s" is not a valid URL, the mini "%s" will not be added to the map' % ( mini.getAttribute( ATTRIBUTE_URL ), mini.getAttribute( ATTRIBUTE_NAME ) )) ) + if mini.get( ATTRIBUTE_URL ) == '' or mini.get( ATTRIBUTE_URL ) == 'http://': + self.chat.ParsePost( self.chat.colorize(self.chat.syscolor, '"%s" is not a valid URL, the mini "%s" will not be added to the map' % ( mini.get( ATTRIBUTE_URL ), mini.get( ATTRIBUTE_NAME ) )) ) return - session = open_rpg.get_component( COMPONENT_SESSION ) + session = component.get( COMPONENT_SESSION ) if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER): - open_rpg.get_component("chat").InfoPost("You must be either a player or GM to use the miniature Layer") + component.get("chat").InfoPost("You must be either a player or GM to use the miniature Layer") return - map = open_rpg.get_component(COMPONENT_MAP) + map = component.get(COMPONENT_MAP) for loop in range( count ): msg = self.get_miniature_XML( mini, addName) msg = str("" + msg + "") map.new_data( msg ) session.send( msg ) - def get_miniature_XML( self, mini, addName = True ): + def get_miniature_XML( self, mini_xml, addName = True ): msg = orpg.mapper.map_msg.mini_msg() - map = open_rpg.get_component( COMPONENT_MAP ) - session = open_rpg.get_component( COMPONENT_SESSION ) + map = component.get( COMPONENT_MAP ) + session = component.get( COMPONENT_SESSION ) msg.init_prop( ATTRIBUTE_ID, session.get_next_id() ) - for k in mini.getAttributeKeys(): + msg.init_prop('selected', '1')# this will make the mini initially selected + for k in mini_xml.keys(): # translate our attributes to map attributes key = FROM_MINILIB_MAP.get( k, k ) if key != None: if not addName and k == 'name': pass else: - msg.init_prop( key, mini.getAttribute( k ) ) - unique = self.is_unique( mini ) + msg.init_prop( key, mini_xml.get( k ) ) + unique = self.is_unique( mini_xml ) if addName: - label = mini.getAttribute( ATTRIBUTE_NAME ) + label = mini_xml.get( ATTRIBUTE_NAME ) else: label = '' return msg.get_all_xml() def is_unique( self, mini ): - unique = mini.getAttribute( ATTRIBUTE_UNIQUE ) + unique = mini.get( ATTRIBUTE_UNIQUE ) val = 0 - try: - val = eval( unique ) - except: - val = len( unique ) + try: val = eval( unique ) + except: val = len( unique ) return val def sanity_check_nodes( self ): - nl = self.master_dom.getElementsByTagName( TAG_MINIATURE ) - for node in nl: - if node.getAttribute( ATTRIBUTE_POSX ) == '': - node.setAttribute( ATTRIBUTE_POSX, '0' ) - if node.getAttribute( ATTRIBUTE_POSY ) == '': - node.setAttribute( ATTRIBUTE_POSY, '0' ) + for node in self.xml.findall(TAG_MINIATURE): + if node.get( ATTRIBUTE_POSX ) == '': node.set( ATTRIBUTE_POSX, '0' ) + if node.get( ATTRIBUTE_POSY ) == '': node.set( ATTRIBUTE_POSY, '0' ) def get_mini( self, index ): - try: - nl = self.master_dom.getElementsByTagName( TAG_MINIATURE ) - return nl[ index ] - except: - return None + try: return self.xml.findall(TAG_MINIATURE)[index] + except: return None class mini_handler( node_handler ): - def __init__( self, xml_dom, tree_node, handler ): - node_handler.__init__( self, xml_dom, tree_node) + def __init__( self, xml, tree_node, handler ): + node_handler.__init__( self, xml, tree_node) self.handler = handler def on_ldclick( self, evt ): - self.handler.send_mini_to_map( self.master_dom ) + self.handler.send_mini_to_map( self.xml ) def on_drop( self, evt ): pass @@ -273,7 +257,7 @@ self.handler = handler self.frame = frame - self.map = open_rpg.get_component('map') + self.map = component.get('map') names = self.buildList() # self.keys = self.list.keys() # self.keys.sort() @@ -283,7 +267,7 @@ self.sizer = wx.BoxSizer(wx.VERTICAL) box = wx.BoxSizer(wx.HORIZONTAL) - self.listbox = wx.BitmapButton(self, wx.ID_ANY, names, wx.LB_EXTENDED) + self.listbox = wx.ListBox(self, wx.ID_ANY, (10, 10), (s[0] - 10, s[1] - 30 ), names, wx.LB_EXTENDED) self.count = wx.TextCtrl(self, wx.ID_ANY, '1') box.Add( wx.StaticText( self, -1, 'Minis to add' ), 0, wx.EXPAND ) @@ -313,19 +297,10 @@ def buildList( self ): """Returns a dictionary of label => game tree miniature DOM node mappings. """ - list = self.handler.master_dom.getElementsByTagName(TAG_MINIATURE) self.list = [] - for mini in list: - min_path = mini.getAttribute( ATTRIBUTE_URL ) - min_img = ImageHandler.load( min_path, 'miniature', 1) - self.list.append( mini.getAttribute( min_img ) ) + for mini in self.handler.xml.findall(TAG_MINIATURE): + self.list.append( mini.get( ATTRIBUTE_NAME ) ) return self.list - # self.list = {} - # for mini in list: - # name = mini.getAttribute( ATTRIBUTE_NAME ) - # if name == '': - # name = self.map.canvas.get_label_from_url( mini.getAttribute( ATTRIBUTE_URL ) ) - # self.list[ name ] = mini def on_close(self, evt): self.frame.Close() @@ -456,9 +431,8 @@ self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.select_cell) def update_cols( self ): - nl = self.handler.master_dom.getElementsByTagName( TAG_MINIATURE ) - for n in nl: - for k in n.getAttributeKeys(): + for n in self.handler.xml.findall(TAG_MINIATURE): + for k in n.keys(): if k not in self.keys: self.keys.append( k ) @@ -477,7 +451,7 @@ """Returns the list of 'miniature' DOM elements associated with this miniature library. """ - return self.handler.master_dom.getElementsByTagName( TAG_MINIATURE ) + return self.handler.xml.findall( TAG_MINIATURE ) def add_row( self, count = 1 ): """creates a new miniature node, and then adds it to the current @@ -488,7 +462,7 @@ ATTRIBUTE_NAME :' ', ATTRIBUTE_URL :'http://'} )# minidom.Element( TAG_MINIATURE ) self.update_all() - #self.handler.master_dom.appendChild( node ) + #self.handler.xml.append( node ) def del_row( self ): """deletes the miniature associated with the currently selected @@ -497,8 +471,8 @@ """ if self.selectedRow > -1: pos = self.selectedRow - list = self.handler.master_dom.getElementsByTagName(TAG_MINIATURE) - self.handler.master_dom.removeChild( list[pos] ) + list = self.handler.xml.findall(TAG_MINIATURE) + self.handler.xml.remove( list[pos] ) self.DeleteRows( pos, 1 ) list = self.getList() del list[ pos ] @@ -517,7 +491,7 @@ list = self.getList() count = 0 for n in list: - for k in n.getAttributeKeys(): + for k in n.keys(): if k not in self.keys: self.keys.append( k ) count = len( self.keys ) @@ -557,11 +531,8 @@ """ list = self.getList() item = list[ row ] - # self.GetTable().SetValue( row, 0, item.getAttribute(ATTRIBUTE_NAME) ) - # self.GetTable().SetValue( row, 1, item.getAttribute(ATTRIBUTE_URL) ) - # self.GetTable().SetValue( row, 2, item.getAttribute(ATTRIBUTE_UNIQUE) ) for key in self.keys: - self.GetTable().SetValue( row, self.keys.index( key ), item.getAttribute( key ) ) + self.GetTable().SetValue( row, self.keys.index( key ), item.get( key ) ) def update_data_row( self, row ): """Updates the DOM nodw 'row' with grid data from 'row' @@ -569,10 +540,4 @@ list = self.getList() item = list[ row ] for key in self.keys: - item.setAttribute( key, string.strip( self.GetTable().GetValue( row, self.keys.index( key ) ) ) ) - # item.setAttribute( ATTRIBUTE_NAME, string.strip( self.GetTable().GetValue( row, 0 ) ) ) - # item.setAttribute( ATTRIBUTE_URL, string.strip( self.GetTable().GetValue( row, 1 ) ) ) - # item.setAttribute( ATTRIBUTE_UNIQUE, string.strip( self.GetTable().GetValue( row, 2 ) ) ) - # self.GetTable().SetValue( row, 0, item.getAttribute(ATTRIBUTE_NAME) ) - # self.GetTable().SetValue( row, 1, item.getAttribute(ATTRIBUTE_URL) ) - # self.GetTable().SetValue( row, 2, item.getAttribute(ATTRIBUTE_UNIQUE) ) + item.set( key, string.strip( self.GetTable().GetValue( row, self.keys.index( key ) ) ) ) diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/rpg_grid.py --- a/orpg/gametree/nodehandlers/rpg_grid.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/rpg_grid.py Wed Nov 25 06:15:49 2009 -0600 @@ -52,10 +52,8 @@ def __init__(self,xml,tree_node): node_handler.__init__(self,xml,tree_node) self.grid = self.xml.find('grid') - if self.grid.get("border") == "": - self.grid.set("border","1") - if self.grid.get("autosize") == "": - self.grid.set("autosize","1") + if self.grid.get("border") == "": self.grid.set("border","1") + if self.grid.get("autosize") == "": self.grid.set("autosize","1") self.macros = self.xml.find('macros') self.myeditor = None self.refresh_rows() @@ -71,8 +69,7 @@ for row in self.grid.findall('row'): first_cell = row.find('cell') name = first_cell.text - if name == None or name == '': - name = "Row" + if name == None or name == '': name = "Row" new_tree_node = tree.AppendItem(self.mytree_node,name,icons['gear'],icons['gear']) handler = grid_row_handler(row,new_tree_node,self) tree.SetPyData(new_tree_node,handler) @@ -87,11 +84,9 @@ cells = r.findall('cell') html_str += "" for c in cells: - #html_str += "" bug here html_str += "" text = c.text - if text == None or text == '': - text = '
' + if text == None or text == '': text = '
' html_str += text + "" html_str += "" html_str += "" @@ -131,8 +126,7 @@ for c in cells: # should loop over rows first, then cells html_str += "" text = c.text - if text == '' or text is None: - text = '
' + if text == '' or text is None: text = '
' html_str += text + "" html_str += "" html_str += "" @@ -140,10 +134,8 @@ def get_value(self): cells = self.xml.findall('cell') - if len(cells) == 2: - return getText(cells[1]) - else: - return None + if len(cells) == 2: return getText(cells[1]) + else: return None def set_value(self, new_value): cells = self.xml.findall('cell') @@ -178,7 +170,6 @@ def __init__(self): wx.grid.PyGridCellEditor.__init__(self) - def Create(self, parent, id, evtHandler): """ Called to create the control, which must derive from wxControl. @@ -187,9 +178,7 @@ self._tc = wx.TextCtrl(parent, id, "", style=wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB) self._tc.SetInsertionPoint(0) self.SetControl(self._tc) - if evtHandler: - self._tc.PushEventHandler(evtHandler) - + if evtHandler: self._tc.PushEventHandler(evtHandler) def SetSize(self, rect): """ @@ -199,15 +188,6 @@ """ self._tc.SetDimensions(rect.x+1, rect.y+1, rect.width+2, rect.height+2) - - #def Show(self, show, attr): #deprecated DeprecationWarning: Please use PyGridCellEditor.Show instead. - # """ - # Show or hide the edit control. You can use the attr (if not None) - # to set colours or fonts for the control. - # """ - # self.base_Show(show, attr) # Removed to prevent recursive error type. - - def BeginEdit(self, row, col, grid): """ Fetch the value from the table and prepare the edit control @@ -222,7 +202,6 @@ # For this example, select the text self._tc.SetSelection(0, self._tc.GetLastPosition()) - def EndEdit(self, row, col, grid): """ Complete the editing of the current cell. Returns True if the value @@ -230,7 +209,6 @@ *Must Override* """ changed = False - val = self._tc.GetValue() if val != self.startValue: changed = True @@ -240,7 +218,6 @@ self._tc.SetValue('') return changed - def Reset(self): """ Reset the value in the control back to its starting value. @@ -249,21 +226,15 @@ self._tc.SetValue(self.startValue) self._tc.SetInsertionPointEnd() - def IsAcceptedKey(self, evt): """ Return True to allow the given key to start editing: the base class version only checks that the event has no modifiers. F2 is special and will always start the editor. """ - - ## Oops, there's a bug here, we'll have to do it ourself.. - ##return self.base_IsAcceptedKey(evt) - return (not (evt.ControlDown() or evt.AltDown()) and evt.GetKeyCode() != wx.WXK_SHIFT) - def StartingKey(self, evt): """ If the editor is enabled by pressing keys on the grid, this will be @@ -274,33 +245,23 @@ if key in [wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3, wx.WXK_NUMPAD4, wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7, wx.WXK_NUMPAD8, wx.WXK_NUMPAD9]: ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0) - elif key < 256 and key >= 0 and chr(key) in string.printable: ch = chr(key) - if not evt.ShiftDown(): - ch = string.lower(ch) - - if ch is not None: - # For this example, replace the text. Normally we would append it. - self._tc.AppendText(ch) - else: - evt.Skip() - - + if not evt.ShiftDown(): ch = string.lower(ch) + if ch is not None: self._tc.AppendText(ch) + else: evt.Skip() def Destroy(self): """final cleanup""" self.base_Destroy() - def Clone(self): """ Create a new object which is the copy of this one *Must Override* """ return MyCellEditor() - - + class rpg_grid(wx.grid.Grid): """grid for attacks""" @@ -309,7 +270,6 @@ self.parent = parent self.handler = handler - # Registers a "custom" cell editor (really the example from Robin Dunn with minor mods self.RegisterDataType(wx.grid.GRID_VALUE_STRING, wx.grid.GridCellStringRenderer(),MyCellEditor()) self.rows = handler.grid.findall('row') @@ -320,8 +280,7 @@ self.SetColLabelSize(0) self.set_col_widths() - for i in range(0,len(self.rows)): - self.refresh_row(i) + for i in range(0,len(self.rows)): self.refresh_row(i) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.on_col_size) @@ -329,8 +288,7 @@ def on_leftdclick(self,evt): - if self.CanEnableCellControl(): - self.EnableCellEditControl() + if self.CanEnableCellControl(): self.EnableCellEditControl() def on_col_size(self, evt): col = evt.GetRowOrCol() @@ -345,8 +303,7 @@ value = self.GetCellValue(row,col) cells = self.rows[row].findall('cell') cells[col].text = value - if col == 0: - self.handler.refresh_rows() + if col == 0: self.handler.refresh_rows() def set_col_widths(self): cells = self.rows[0].findall('cell') @@ -354,8 +311,7 @@ try: size = int(cells[i].get('size')) self.SetColSize(i,size) - except: - continue + except: continue def refresh_row(self,rowi): cells = self.rows[rowi].findall('cell') @@ -388,8 +344,7 @@ def del_row(self,evt=None): num = self.GetNumberRows() - if num == 1: - return + if num == 1: return self.handler.grid.remove(self.handler.grid[num-1])# always remove last row -- nasty self.DeleteRows(num-1,1) self.rows = self.handler.grid.findall('row') @@ -397,8 +352,7 @@ def del_col(self,evt=None): num = self.GetNumberCols() - if num == 1: - return + if num == 1: return for r in self.rows: cells = r.findall('cell') r.remove(r[num-1]) # always remove the last column -- nasty @@ -422,7 +376,6 @@ self.Fit() parent.SetSize(self.GetBestSize()) - G_AUTO_SIZE = wx.NewId() G_ADD_ROW = wx.NewId() G_ADD_COL = wx.NewId() diff -r c2caca988a11 -r 06f10429eedc orpg/gametree/nodehandlers/voxchat.py --- a/orpg/gametree/nodehandlers/voxchat.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/gametree/nodehandlers/voxchat.py Wed Nov 25 06:15:49 2009 -0600 @@ -28,9 +28,7 @@ __version__ = "$Id: voxchat.py,v 1.37 2007/05/06 16:42:55 digitalxero Exp $" -import re -import os -import string +import re, os, string, core from orpg.orpg_windows import * import core diff -r c2caca988a11 -r 06f10429eedc orpg/main.py --- a/orpg/main.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/main.py Wed Nov 25 06:15:49 2009 -0600 @@ -851,7 +851,6 @@ elif pane.name == 'Map Tool Bar': self.mainmenu.SetMenuState('ToolsMapBar', False) else: for wndid, wname in self.mainwindows.iteritems(): - #print pane.name, wname, wndid if pane.name == wname: self.windowsmenu.Check(wndid, False); break evt.Skip() self._mgr.Update() @@ -1073,7 +1072,7 @@ ## About Dialog class ######################################## class AboutORPG(wx.Frame): - def __init__(self, parent): + def __init__(self, parent, description=''): super(AboutORPG, self).__init__(parent, -1, "About 'Traipse' OpenRPG") icon = None icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) @@ -1094,7 +1093,7 @@ self.Bind(wx.EVT_CLOSE, self.Min) self.Min(None) - description = "OpenRPG is a Virtual Game Table that allows users to connect via a network and play table " + description += "OpenRPG is a Virtual Game Table that allows users to connect via a network and play table " description += "top games with friends. 'Traipse' is an OpenRPG distro that is easy to setup and provides superb " description += "functionality. OpenRPG is originally designed by Chris Davis." diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/background.py --- a/orpg/mapper/background.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/background.py Wed Nov 25 06:15:49 2009 -0600 @@ -29,15 +29,10 @@ __version__ = "$Id: background.py,v 1.29 2007/03/09 14:11:55 digitalxero Exp $" from base import * -import thread -import urllib -import os.path -import time -import mimetypes +import thread, urllib, os.path, time, mimetypes from orpg.orpgCore import component from orpg.tools.orpg_log import logger -from orpg.tools.decorators import debugging from orpg.tools.orpg_settings import settings ##----------------------------- @@ -59,14 +54,12 @@ self.r_h = RGBHex() self.clear() - def error_loading_image(self, image): msg = "Unable to load image:" + `image` dlg = wx.MessageDialog(self.canvas,msg,'File not Found',wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() - def clear(self): self.type = BG_NONE self.bg_bmp = None @@ -77,16 +70,13 @@ self.localTime = -1 self.isUpdated = True - def get_type(self): return self.type - def get_img_path(self): if self.img_path: return self.img_path else: return "" - def get_color(self): hexcolor = "#FFFFFF" if self.bg_color: @@ -94,7 +84,6 @@ hexcolor = self.r_h.hexstring(red, green, blue) return hexcolor - def set_texture(self, path): self.isUpdated = True self.type = BG_TEXTURE @@ -107,7 +96,6 @@ except: self.error_loading_image(path) self.img_path = path - def set_image(self, path, scale): self.isUpdated = True self.type = BG_IMAGE @@ -121,7 +109,6 @@ self.img_path = path return (self.bg_bmp.GetWidth(),self.bg_bmp.GetHeight()) - def set_color(self, color): self.isUpdated = True self.type = BG_COLOR @@ -129,7 +116,6 @@ self.bg_color = cmpColour(r,g,b) self.canvas.SetBackgroundColour(self.bg_color) - def layerDraw(self, dc, scale, topleft, size): if self.bg_bmp == None or not self.bg_bmp.Ok() or ((self.type != BG_TEXTURE) and (self.type != BG_IMAGE)): return False @@ -204,7 +190,6 @@ del dc2 return True - def layerToXML(self, action="update"): xml_str = " element" diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/fog.py --- a/orpg/mapper/fog.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/fog.py Wed Nov 25 06:15:49 2009 -0600 @@ -106,8 +106,7 @@ def resize(self, size): try: - if self.width == size[0] and self.height == size[1]: - return + if self.width == size[0] and self.height == size[1]: return self.recompute_fog() except: pass @@ -139,8 +138,7 @@ del mdc def layerDraw(self, dc, topleft, size): - if self.fog_bmp == None or not self.fog_bmp.Ok() or not self.use_fog: - return + if self.fog_bmp == None or not self.fog_bmp.Ok() or not self.use_fog: return if self.last_role != self.canvas.frame.session.role: self.fill_fog() mdc = wx.MemoryDC() mdc.SelectObject(self.fog_bmp) @@ -152,17 +150,14 @@ regn = self.scanConvert(polyline) area = "" for i in polyline: - if (area != ""): - area += ";" + if (area != ""): area += ";" area += str(i.X) + "," + str(i.Y) if mode == 'new': - if self.fogregion.IsEmpty(): - self.fogregion = regn + if self.fogregion.IsEmpty(): self.fogregion = regn else: self.fogregion.UnionRegion(regn) self.add_area(area, show) else: - if not self.fogregion.IsEmpty(): - self.fogregion.SubtractRegion(regn) + if not self.fogregion.IsEmpty(): self.fogregion.SubtractRegion(regn) else: self.fogregion = wx.Region(0, 0, self.canvas.size[0], self.canvas.size[1]) self.fogregion.SubtractRegion(regn) @@ -200,8 +195,7 @@ if show == "Yes": self.canvas.frame.session.send(xml_str) def layerToXML(self, action="update"): - if not self.use_fog: - return "" + if not self.use_fog: return "" fog_string = "" ri = wx.RegionIterator(self.fogregion) if not (ri.HaveRects()): fog_string = FogArea("all", self.log).toxml("del") @@ -222,8 +216,7 @@ s += fog_string s += "" return s - else: - return "" + else: return "" def layerTakeDOM(self, xml_dom): try: diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/grid.py --- a/orpg/mapper/grid.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/grid.py Wed Nov 25 06:15:49 2009 -0600 @@ -101,7 +101,7 @@ elif self.mode == GRID_ISOMETRIC: x = (topLeft.x)-(mini_width/2) y = (topLeft.y)-(mini_height) - else:# GRID_RECTANGLE + else: # GRID_RECTANGLE x = topLeft.x + ((self.unit_size - mini_width) / 2) y = topLeft.y + ((self.unit_size_y - mini_height) /2) else: diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/grid_msg.py --- a/orpg/mapper/grid_msg.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/grid_msg.py Wed Nov 25 06:15:49 2009 -0600 @@ -35,3 +35,4 @@ def __init__(self,reentrant_lock_object = None): self.tagname = "grid" map_element_msg_base.__init__(self,reentrant_lock_object) + diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/map.py --- a/orpg/mapper/map.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/map.py Wed Nov 25 06:15:49 2009 -0600 @@ -32,11 +32,7 @@ from min_dialogs import * from map_prop_dialog import * -import random -import os -import thread -#import gc #Garbage Collecter Needed? -import traceback +import random, os, thread, traceback from miniatures_handler import * from whiteboard_handler import * @@ -811,7 +807,6 @@ def on_left_down(self, evt): self.layer_handlers[self.current_layer].on_left_down(evt) - #double click handler added by Snowdog 5/03 def on_left_dclick(self, evt): self.layer_handlers[self.current_layer].on_left_dclick(evt) diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/map_msg.py --- a/orpg/mapper/map_msg.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/map_msg.py Wed Nov 25 06:15:49 2009 -0600 @@ -92,8 +92,7 @@ self.clear() # Process all of the properties in each tag if xml_dom.getAttributeKeys(): - for k in xml_dom.getAttributeKeys(): - self.set_prop(k,xml_dom.getAttribute(k)) + for k in xml_dom.getAttributeKeys(): self.set_prop(k,xml_dom.getAttribute(k)) for c in xml_dom._get_childNodes(): name = c._get_nodeName() if not self.children.has_key(name): diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/min_dialogs.py --- a/orpg/mapper/min_dialogs.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/min_dialogs.py Wed Nov 25 06:15:49 2009 -0600 @@ -224,7 +224,6 @@ listsizer.Add(self.labelcombo,0, wx.EXPAND) self.pathcombo = wx.ComboBox(self, PATH_COMBO, "no change",style=wx.CB_DROPDOWN) self.positioncombo = wx.ComboBox(self, POS_COMB, "no change", choices=["no change"], style=wx.CB_READONLY) - #self.positioncombo.SetValue(`min_list[0].pos`) self.labelcombo.Append("no change") self.pathcombo.Append("no change") for m in min_list: @@ -267,9 +266,7 @@ ###Group together the postion radiobox and the and its selection elements ### xpos = int(min_list[0].pos[0]) - #xpos = int(`min_list[0].pos`[1:`min_list[0].pos`.index(',')]) ypos = int(min_list[0].pos[1]) - #ypos = int(`min_list[0].pos`[`min_list[0].pos`.rfind(',')+1:len(`min_list[0].pos`)-1]) self.scx = wx.SpinCtrl(self, POS_SPIN, "", (-1,-1), wx.Size(75,25)) self.scx.SetRange(0,self.grid.return_grid()[0]) self.scx.SetValue(xpos) diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/miniatures.py --- a/orpg/mapper/miniatures.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/miniatures.py Wed Nov 25 06:15:49 2009 -0600 @@ -29,11 +29,7 @@ __version__ = "$Id: miniatures.py,v 1.46 2007/12/07 20:39:50 digitalxero Exp $" from base import * -import thread -import time -import urllib -import os.path -import mimetypes +import thread, time, urllib, os.path, mimetypes import xml.dom.minidom as minidom from orpg.tools.orpg_settings import settings @@ -106,10 +102,6 @@ self.image = None def set_bmp(self, bmp): - ### Alpha ### - try: bmp = bmp.ConvertToImage() - except: pass - ### Still ironing out some kinks to FlexiRPG's map features ### self.image = bmp self.image.ConvertAlphaToMask() self.generate_bmps() @@ -149,18 +141,6 @@ def draw(self, dc, mini_layer, op=wx.COPY): if self.hide and mini_layer.canvas.frame.session.my_role() == mini_layer.canvas.frame.session.ROLE_GM: # set the width and height of the image - """ - if self.width and self.height: - tmp_image = self.bmp.ConvertToImage() - tmp_image.Rescale(int(self.width), int(self.height)) - tmp_image.ConvertAlphaToMask() - self.bmp = tmp_image.ConvertToBitmap() - mask = wx.Mask(self.bmp, wx.Colour(tmp_image.GetMaskRed(), - tmp_image.GetMaskGreen(), tmp_image.GetMaskBlue())) - self.bmp.SetMask(mask) - del tmp_image - del mask - """ self.left = 0 self.right = self.bmp.GetWidth() self.top = 0 @@ -269,14 +249,30 @@ triangle = [] # Figure out which direction to draw the marker!! tri_list = { - FACE_NORTH: [cmpPoint(x_center - x_quarter, y_center - y_half ), cmpPoint(x_center, y_center - y_3quarter ), cmpPoint(x_center + x_quarter, y_center - y_half)], - FACE_SOUTH: [cmpPoint(x_center - x_quarter, y_center + y_half ), cmpPoint(x_center, y_center + y_3quarter ), cmpPoint(x_center + x_quarter, y_center + y_half )], - FACE_NORTHEAST: [cmpPoint(x_center + x_quarter, y_center - y_half ), cmpPoint(x_center + x_3quarter, y_center - y_3quarter ), cmpPoint(x_center + x_half, y_center - y_quarter)], - FACE_EAST: [cmpPoint(x_center + x_half, y_center - y_quarter ), cmpPoint(x_center + x_3quarter, y_center ), cmpPoint(x_center + x_half, y_center + y_quarter )], - FACE_SOUTHEAST: [cmpPoint(x_center + x_half, y_center + y_quarter ), cmpPoint(x_center + x_3quarter, y_center + y_3quarter ), cmpPoint(x_center + x_quarter, y_center + y_half )], - FACE_SOUTHWEST: [cmpPoint(x_center - x_quarter, y_center + y_half ), cmpPoint(x_center - x_3quarter, y_center + y_3quarter ), cmpPoint(x_center - x_half, y_center + y_quarter )], - FACE_WEST: [cmpPoint(x_center - x_half, y_center + y_quarter ), cmpPoint(x_center - x_3quarter, y_center ), cmpPoint(x_center - x_half, y_center - y_quarter )], - FACE_NORTHWEST: [cmpPoint(x_center - x_half, y_center - y_quarter ), cmpPoint(x_center - x_3quarter, y_center - y_3quarter ), cmpPoint(x_center - x_quarter, y_center - y_half )]} + FACE_NORTH: [cmpPoint(x_center - x_quarter, y_center - y_half ), + cmpPoint(x_center, y_center - y_3quarter ), + cmpPoint(x_center + x_quarter, y_center - y_half)], + FACE_SOUTH: [cmpPoint(x_center - x_quarter, y_center + y_half ), + cmpPoint(x_center, y_center + y_3quarter ), + cmpPoint(x_center + x_quarter, y_center + y_half )], + FACE_NORTHEAST: [cmpPoint(x_center + x_quarter, y_center - y_half ), + cmpPoint(x_center + x_3quarter, y_center - y_3quarter ), + cmpPoint(x_center + x_half, y_center - y_quarter)], + FACE_EAST: [cmpPoint(x_center + x_half, y_center - y_quarter ), + cmpPoint(x_center + x_3quarter, y_center ), + cmpPoint(x_center + x_half, y_center + y_quarter )], + FACE_SOUTHEAST: [cmpPoint(x_center + x_half, y_center + y_quarter ), + cmpPoint(x_center + x_3quarter, y_center + y_3quarter ), + cmpPoint(x_center + x_quarter, y_center + y_half )], + FACE_SOUTHWEST: [cmpPoint(x_center - x_quarter, y_center + y_half ), + cmpPoint(x_center - x_3quarter, y_center + y_3quarter ), + cmpPoint(x_center - x_half, y_center + y_quarter )], + FACE_WEST: [cmpPoint(x_center - x_half, y_center + y_quarter ), + cmpPoint(x_center - x_3quarter, y_center ), + cmpPoint(x_center - x_half, y_center - y_quarter )], + FACE_NORTHWEST: [cmpPoint(x_center - x_half, y_center - y_quarter ), + cmpPoint(x_center - x_3quarter, y_center - y_3quarter ), + cmpPoint(x_center - x_quarter, y_center - y_half )]} for tri in tri_list[self.heading]: triangle.append(tri) del tri_list @@ -352,14 +348,10 @@ def takedom(self, xml_dom): self.id = xml_dom.getAttribute("id") - if xml_dom.hasAttribute("posx"): - self.pos.x = int(xml_dom.getAttribute("posx")) - if xml_dom.hasAttribute("posy"): - self.pos.y = int(xml_dom.getAttribute("posy")) - if xml_dom.hasAttribute("heading"): - self.heading = int(xml_dom.getAttribute("heading")) - if xml_dom.hasAttribute("face"): - self.face = int(xml_dom.getAttribute("face")) + if xml_dom.hasAttribute("posx"): self.pos.x = int(xml_dom.getAttribute("posx")) + if xml_dom.hasAttribute("posy"): self.pos.y = int(xml_dom.getAttribute("posy")) + if xml_dom.hasAttribute("heading"): self.heading = int(xml_dom.getAttribute("heading")) + if xml_dom.hasAttribute("face"): self.face = int(xml_dom.getAttribute("face")) if xml_dom.hasAttribute("path"): self.path = urllib.unquote(xml_dom.getAttribute("path")) self.set_bmp(ImageHandler.load(self.path, 'miniature', self.id)) @@ -369,17 +361,13 @@ if xml_dom.hasAttribute("hide"): if xml_dom.getAttribute("hide") == '1' or xml_dom.getAttribute("hide") == 'True': self.hide = True else: self.hide = False - if xml_dom.hasAttribute("label"): - self.label = xml_dom.getAttribute("label") - if xml_dom.hasAttribute("zorder"): - self.zorder = int(xml_dom.getAttribute("zorder")) + if xml_dom.hasAttribute("label"): self.label = xml_dom.getAttribute("label") + if xml_dom.hasAttribute("zorder"): self.zorder = int(xml_dom.getAttribute("zorder")) if xml_dom.hasAttribute("align"): if xml_dom.getAttribute("align") == '1' or xml_dom.getAttribute("align") == 'True': self.snap_to_align = 1 else: self.snap_to_align = 0 - if xml_dom.hasAttribute("width"): - self.width = int(xml_dom.getAttribute("width")) - if xml_dom.hasAttribute("height"): - self.height = int(xml_dom.getAttribute("height")) + if xml_dom.hasAttribute("width"): self.width = int(xml_dom.getAttribute("width")) + if xml_dom.hasAttribute("height"): self.height = int(xml_dom.getAttribute("height")) ##----------------------------- ## miniature layer @@ -448,8 +436,7 @@ def get_miniature_by_id(self, id): for mini in self.miniatures: - if str(mini.id) == str(id): - return mini + if str(mini.id) == str(id): return mini return None def del_miniature(self, min): @@ -513,9 +500,7 @@ id = c.getAttribute('id') if action == "del": mini = self.get_miniature_by_id(id) - if mini: - self.miniatures.remove(mini) - del mini + if mini: self.miniatures.remove(mini); del mini elif action == "new": pos = cmpPoint(int(c.getAttribute('posx')),int(c.getAttribute('posy'))) path = urllib.unquote(c.getAttribute('path')) @@ -546,7 +531,7 @@ postdata = urllib.urlencode({'filename':filename[1], 'imgdata':imgdata, 'imgtype':imgtype}) thread.start_new_thread(self.upload, (postdata, localPath, True)) # collapse the zorder. If the client behaved well, then nothing should change. - # Otherwise, this will ensure that there's some kind of z-order + # Otherwise, this will ensure that there's some kind of z-order self.collapse_zorder() else: mini = self.get_miniature_by_id(id) @@ -575,8 +560,7 @@ self.miniatures[len(self.miniatures)-1].localPath = filename self.miniatures[len(self.miniatures)-1].localTime = time.time() self.miniatures[len(self.miniatures)-1].path = path - else: - print xml_dom.get('msg') + else: print xml_dom.get('msg') except Exception, e: print e print recvdata diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/miniatures_handler.py --- a/orpg/mapper/miniatures_handler.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/miniatures_handler.py Wed Nov 25 06:15:49 2009 -0600 @@ -29,16 +29,11 @@ from base_handler import * from min_dialogs import * -import thread -import time -import mimetypes -import urllib +import thread, time, mimetypes, urllib, wx, os -import wx from grid import GRID_RECTANGLE from grid import GRID_HEXAGON from grid import GRID_ISOMETRIC -import os from orpg.tools.orpg_settings import settings @@ -202,7 +197,6 @@ self.canvas.send_map_data() self.canvas.Refresh(False) - def build_menu(self,label = "Miniature"): base_layer_handler.build_menu(self,label) self.main_menu.AppendSeparator() @@ -314,8 +308,7 @@ for item in self.mini_rclick_menu_extra_items.items(): self.min_menu.Append(item[1], item[0]) if len(self.background_rclick_menu_extra_items)>0: self.main_menu.AppendSeparator() - for item in self.background_rclick_menu_extra_items.items(): - self.main_menu.Append(item[1], item[0]) + for item in self.background_rclick_menu_extra_items.items(): self.main_menu.Append(item[1], item[0]) def do_min_menu(self,pos): self.canvas.PopupMenu(self.min_menu,pos) @@ -620,8 +613,7 @@ postdata = urllib.urlencode({'filename':filename, 'imgdata':imgdata, 'imgtype':imgtype}) if self.settings.get_setting('LocalorRemote') == 'Remote': thread.start_new_thread(self.canvas.layers['miniatures'].upload, (postdata, filepath), {'pos':cmpPoint(x,y)}) - else: - self.CherryPit(filepath, '') + else: self.CherryPit(filepath, '') def on_tooltip_timer(self, *args): pos = args[0] @@ -634,8 +626,7 @@ tooltip = mini_list[0].label #self.canvas.SetToolTipString(mini_list[0].label) #Once set, it never unsets, so it sucks. - else: - self.canvas.SetToolTipString('') + else: self.canvas.SetToolTipString('') def on_motion(self,evt): if evt.Dragging() and evt.LeftIsDown(): diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/miniatures_msg.py --- a/orpg/mapper/miniatures_msg.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/miniatures_msg.py Wed Nov 25 06:15:49 2009 -0600 @@ -81,8 +81,7 @@ self.p_lock.acquire() if xml_dom.tagName == self.tagname: if xml_dom.getAttributeKeys(): - for k in xml_dom.getAttributeKeys(): - self.init_prop(k,xml_dom.getAttribute(k)) + for k in xml_dom.getAttributeKeys(): self.init_prop(k,xml_dom.getAttribute(k)) for c in xml_dom._get_childNodes(): mini = mini_msg(self.p_lock) @@ -90,16 +89,13 @@ except Exception, e: print e; continue id = mini.get_prop("id") action = mini.get_prop("action") - if action == "new": self.children[id] = mini elif action == "del": if self.children.has_key(id): self.children[id] = None del self.children[id] - elif action == "update": - if self.children.has_key(id): - self.children[id].init_props(mini.get_all_props()) + if self.children.has_key(id): self.children[id].init_props(mini.get_all_props()) else: self.p_lock.release() raise Exception, "Error attempting to initialize a " + self.tagname + " from a non-<" + self.tagname + "/> element" @@ -109,12 +105,9 @@ self.p_lock.acquire() if xml_dom.tagName == self.tagname: if xml_dom.getAttributeKeys(): - for k in xml_dom.getAttributeKeys(): - self.set_prop(k,xml_dom.getAttribute(k)) - + for k in xml_dom.getAttributeKeys(): self.set_prop(k,xml_dom.getAttribute(k)) for c in xml_dom._get_childNodes(): mini = mini_msg(self.p_lock) - try: mini.set_from_dom(c) except Exception, e: print e; continue id = mini.get_prop("id") diff -r c2caca988a11 -r 06f10429eedc orpg/mapper/whiteboard.py --- a/orpg/mapper/whiteboard.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/mapper/whiteboard.py Wed Nov 25 06:15:49 2009 -0600 @@ -121,10 +121,8 @@ def takedom(self, xml_dom): self.text_string = xml_dom.getAttribute("text_string") self.id = xml_dom.getAttribute("id") - if xml_dom.hasAttribute("posy"): - self.posy = int(xml_dom.getAttribute("posy")) - if xml_dom.hasAttribute("posx"): - self.posx = int(xml_dom.getAttribute("posx")) + if xml_dom.hasAttribute("posy"): self.posy = int(xml_dom.getAttribute("posy")) + if xml_dom.hasAttribute("posx"): self.posx = int(xml_dom.getAttribute("posx")) if xml_dom.hasAttribute("weight"): self.weight = int(xml_dom.getAttribute("weight")) self.font.SetWeight(self.weight) @@ -175,11 +173,9 @@ oldicords = (int(stcords[0]),int(stcords[1])) for coordinate_string_counter in range(1, len(coords)): stcords = coords[coordinate_string_counter].split(",") - if stcords[0] == "": - return False + if stcords[0] == "": return False icords = (int(stcords[0]),int(stcords[1])) - if orpg.mapper.map_utils.proximity_test(oldicords,icords,pt,12): - return True + if orpg.mapper.map_utils.proximity_test(oldicords,icords,pt,12): return True oldicords = icords return False @@ -237,20 +233,14 @@ def takedom(self, xml_dom): self.line_string = xml_dom.getAttribute("line_string") self.id = xml_dom.getAttribute("id") - if xml_dom.hasAttribute("upperleftx"): - self.upperleft.x = int(xml_dom.getAttribute("upperleftx")) - if xml_dom.hasAttribute("upperlefty"): - self.upperleft.y = int(xml_dom.getAttribute("upperlefty")) - if xml_dom.hasAttribute("lowerrightx"): - self.lowerright.x = int(xml_dom.getAttribute("lowerrightx")) - if xml_dom.hasAttribute("lowerrighty"): - self.lowerright.y = int(xml_dom.getAttribute("lowerrighty")) + if xml_dom.hasAttribute("upperleftx"): self.upperleft.x = int(xml_dom.getAttribute("upperleftx")) + if xml_dom.hasAttribute("upperlefty"): self.upperleft.y = int(xml_dom.getAttribute("upperlefty")) + if xml_dom.hasAttribute("lowerrightx"): self.lowerright.x = int(xml_dom.getAttribute("lowerrightx")) + if xml_dom.hasAttribute("lowerrighty"): self.lowerright.y = int(xml_dom.getAttribute("lowerrighty")) if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '': self.linecolor = xml_dom.getAttribute("color") - if self.linecolor == '#0000000': - self.linecolor = '#000000' - if xml_dom.hasAttribute("width"): - self.linewidth = int(xml_dom.getAttribute("width")) + if self.linecolor == '#0000000': self.linecolor = '#000000' + if xml_dom.hasAttribute("width"): self.linewidth = int(xml_dom.getAttribute("width")) ##----------------------------- ## whiteboard layer @@ -299,14 +289,12 @@ def get_line_by_id(self, id): for line in self.lines: - if str(line.id) == str(id): - return line + if str(line.id) == str(id): return line return None def get_text_by_id(self, id): for text in self.texts: - if str(text.id) == str(id): - return text + if str(text.id) == str(id): return text return None def del_line(self, line): @@ -327,17 +315,14 @@ self.canvas.Refresh(True) def del_all_lines(self): - for i in xrange(len(self.lines)): - self.del_line(self.lines[0]) - print self.lines + for i in xrange(len(self.lines)): self.del_line(self.lines[0]) def del_text(self, text): xml_str = "" xml_str += text.toxml("del") xml_str += "" self.canvas.frame.session.send(xml_str) - if text: - self.texts.remove(text) + if text: self.texts.remove(text) self.canvas.Refresh(True) def layerDraw(self, dc): @@ -347,8 +332,7 @@ def hit_test_text(self, pos, dc): list_of_texts_matching = [] if self.canvas.layers['fog'].use_fog == 1: - if self.canvas.frame.session.role != "GM": - return list_of_texts_matching + if self.canvas.frame.session.role != "GM": return list_of_texts_matching for m in self.texts: if m.hit_test(pos,dc): list_of_texts_matching.append(m) return list_of_texts_matching @@ -356,8 +340,7 @@ def hit_test_lines(self, pos, dc): list_of_lines_matching = [] if self.canvas.layers['fog'].use_fog == 1: - if self.canvas.frame.session.role != "GM": - return list_of_lines_matching + if self.canvas.frame.session.role != "GM": return list_of_lines_matching for m in self.lines: if m.hit_test(pos): list_of_lines_matching.append(m) return list_of_lines_matching @@ -368,10 +351,8 @@ self.canvas.PrepareDC( dc ) dc.SetUserScale(scale,scale) line_list = self.hit_test_lines(pt,dc) - if line_list: - return line_list[0] - else: - return None + if line_list: return line_list[0] + else: return None def setcolor(self, color): r,g,b = color.Get() @@ -412,8 +393,7 @@ points = x.split(",") x1 = int(points[0]) y1 = int(points[1]) - if x2 != -999: - dc.DrawLine(x2,y2,x1,y1) + if x2 != -999: dc.DrawLine(x2,y2,x1,y1) x2 = x1 y2 = y1 dc.SetPen(wx.NullPen) @@ -422,9 +402,9 @@ def layerToXML(self, action="update"): """ format """ white_string = "" - if self.lines: + if self.lines: for l in self.lines: white_string += l.toxml(action) - if self.texts: + if self.texts: for l in self.texts: white_string += l.toxml(action) if len(white_string): s = "") head = data[:end+1] msg = data[end+1:] - ### Alpha ### + ### This if statement should help close invalid messages. ### if head[end:] != '/': if head[end:] != '>': head = head[:end] + '/>' - ### This if statement should help close invalid messages. Since it needs fixing, use the try except message for now. try: el = fromstring(head) except: el = fromstring(head[:end] +'/>') + ########### try: el1 = fromstring(msg) el.append(el1) except ExpatError: el.text = msg - #logger.general("Bad Message: \n" + data) id = el.get('from') or el.get('id') if el.tag in self.msg_handlers: self.msg_handlers[el.tag](id, data, el) @@ -718,10 +705,10 @@ elif self.is_valid_id(id): self.on_receive(msg, self.players[id]) def on_ping(self, id, msg, etreeEl): - #a REAL ping time implementation by Snowdog 8/03 + # A REAL ping time implementation by Snowdog 8/03 # recieves special server command # where ### is a returning time from the clients ping command - #get current time, pull old time from object and compare them + # get current time, pull old time from object and compare them # the difference is the latency between server and client * 2 ct = time.clock() ot = etreeEl.get("time") @@ -772,7 +759,6 @@ self.clear_players() self.on_mplay_event(mplay_event(MPLAY_GROUP_CHANGE, self.groups[self.group_id])) self.players[self.id] = self.get_my_info() - #(self.name,self.ip,self.id,self.text_status) self.on_player_event(mplay_event(PLAYER_NEW, self.players[self.id])) elif act == "failed": self.on_mplay_event(mplay_event(MPLAY_GROUP_CHANGE_F)) diff -r c2caca988a11 -r 06f10429eedc orpg/networking/mplay_groups.py --- a/orpg/networking/mplay_groups.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/networking/mplay_groups.py Wed Nov 25 06:15:49 2009 -0600 @@ -1,5 +1,6 @@ from orpg.mapper.map_msg import * from orpg.tools.orpg_log import debug +from xml.etree.ElementTree import parse, tostring class game_group: def __init__( self, id, name, pwd, desc="", @@ -18,16 +19,10 @@ self.moderated = 0 self.voice = {} self.persistant = persist - ### Needs to use Element Tree closer - if mapFile != None: - f = open( mapFile ) - tree = f.read() - f.close() - else: - f = open(orpg.dirpath.dir_struct["template"] + "default_map.xml") - tree = f.read() - f.close() - self.game_map.init_from_xml(fromstring(tree)) + if mapFile != None: tree = parse(mapFile) + else: tree = parse(dir_struct["template"] + "default_map.xml") + tree = tree.getroot() + self.game_map.init_from_xml(tostring(tree)) def add_player(self,id): self.players.append(id) @@ -68,9 +63,9 @@ #depreciated - see send_group_list() def toxml(self, act="new"): # Please don't add the boot_pwd to the xml, as this will give it away to players watching their console - xml_data = "" + xml_data = "" return xml_data diff -r c2caca988a11 -r 06f10429eedc orpg/networking/mplay_messaging.py --- a/orpg/networking/mplay_messaging.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/networking/mplay_messaging.py Wed Nov 25 06:15:49 2009 -0600 @@ -48,10 +48,8 @@ class messenger: def __init__(self, *args, **kwargs): - #self.xml = component.get("xml") used once, no need for the object. self.dir_struct = component.get("dir_struct") #used? self.validate = component.get("validate") #used?? - #self.settings = component.get("settings") ## used once, no need for the object. if kwargs.has_key('isServer'): self.isServer = kwargs['isServer'] else: @@ -121,7 +119,6 @@ def build_message(self, *args, **kwargs): - #print args message = '<' + args[0] #Setup the attributes of the message @@ -134,11 +131,9 @@ #Close the first part message += '>' message += escape(args[1]) - #Close the whole thing message += '' - else: - message += ' />' + else: message += ' />' return message def disconnect(self): @@ -289,14 +284,12 @@ logger.note("message handler thread running...", ORPG_NOTE) while self.alive or self.status == 'connected': data = None - try: - data = self.inbox.get(0) + try: data = self.inbox.get(0) except Queue.Empty: time.sleep(0.25) #sleep 1/4 second continue bytes = len(data) - if bytes < 5: - continue + if bytes < 5: continue try: thread.start_new_thread(self.parse_incoming_dom,(str(data),)) #data has been passed... unlink from the variable references @@ -311,7 +304,6 @@ self.inbox_event.set() def parse_incoming_dom(self, data): - #print data xml_dom = None try: xml_dom = component.get("xml").parseXml(data) @@ -342,19 +334,15 @@ # Loop as long as we have a connection while( self.get_status() == 'connected' ): - try: - readMsg = self.outbox.get( block=1 ) - + try: readMsg = self.outbox.get( block=1 ) except Exception, text: logger.exception("Exception: messenger->sendThread(): " + str(text) - # If we are here, it's because we have data to send, no doubt! if self.status == 'connected': try: # Send the entire message, properly formated/encoded sent = self.sendMsg( self.sock, readMsg ) - except: - logger.exception("Exception: messenger->sendThread():\n" + traceback.format_exc() + except: logger.exception("Exception: messenger->sendThread():\n" + traceback.format_exc() else: # If we are not connected, purge the data queue logger.note("Data queued without a connection, purging data from queue...") @@ -374,11 +362,9 @@ try: # Send the encoded length sentl = sock.send( lp ) - # Now, send the message the the length was describing sentm = sock.send( msg ) - if self.isServer: - logger.debug("('data_sent', " + str(sentl+sentm) + ")") + if self.isServer: logger.debug("('data_sent', " + str(sentl+sentm) + ")") return sentm except socket.error, e: logger.exception("Socket Error: messenger->sendMsg(): " + traceback.format_exc()) @@ -395,15 +381,11 @@ # Make sure we didn't get disconnected bytes = len( readMsg ) - if bytes == 0: - break - + if bytes == 0: break # Check the length of the message bytes = len( readMsg ) - # Make sure we are still connected - if bytes == 0: - break + if bytes == 0: break else: # Pass along the message so it can be processed self.inbox.put( readMsg ) @@ -456,14 +438,11 @@ # Now, convert to a usable form (length,) = unpack( 'i', lenData ) length = socket.ntohl( length ) - # Read exactly the remaining amount of data msgData = self.recvData( sock, length ) - if self.isServer: - logger.debug("('data_recv', " + str(length+4) + ")") - except: - logger.exception("Exception: messenger->recvMsg():\n" + traceback.format_exc()) + if self.isServer: logger.debug("('data_recv', " + str(length+4) + ")") + except: logger.exception("Exception: messenger->recvMsg():\n" + traceback.format_exc()) return msgData if __name__ == "__main__": diff -r c2caca988a11 -r 06f10429eedc orpg/networking/mplay_server.py --- a/orpg/networking/mplay_server.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/networking/mplay_server.py Wed Nov 25 06:15:49 2009 -0600 @@ -91,7 +91,6 @@ self.voice = {} self.persistant = persist self.mapFile = None - ### Needs to use Element Tree closer if mapFile != None: tree = parse(mapFile) else: tree = parse(dir_struct["template"] + "default_map.xml") tree = tree.getroot() @@ -349,7 +348,6 @@ # as needed, over-riding any default values as requested. def initServerConfig(self): - debug(log=False) self.log_msg("Processing Server Configuration File... " + self.userPath) # make sure the server_ini.xml exists! validate.config_file( "server_ini.xml", "default_server_ini.xml" ) @@ -849,7 +847,6 @@ self.log_msg("Server stopped!") def log_msg(self,msg): - debug(parents=True) if self.log_to_console: if self.log_console: self.log_console(msg) else: print str(msg) @@ -1195,6 +1192,7 @@ self.handle_role("set", props['id'], "GM", self.groups[LOBBY_ID].boot_pwd, LOBBY_ID) cmsg = "Client Connect: (" + str(props['id']) + ") " + str(props['name']) + " [" + str(props['ip']) + "]" self.log_msg(cmsg) + self.log_msg(("update_group", (self.groups[LOBBY_ID].name, LOBBY_ID, len(self.groups[LOBBY_ID].players) ) )) cmsg = ("connect", props) ################################################# self.log_msg(cmsg) @@ -1605,6 +1603,7 @@ #notify user about others in the room self.return_room_roles(from_id,group_id) self.log_msg(("join_group", (self.groups[group_id].name, group_id, from_id))) + self.log_msg(("update_group", (self.groups[group_id].name, group_id, len(self.groups[group_id].players) ))) self.handle_role("set", from_id, self.players[from_id].role, self.groups[group_id].boot_pwd, group_id) except Exception, e: self.log_msg(str(e)) @@ -1909,7 +1908,7 @@ def handle_role(self, act, player, role, given_boot_pwd, group_id): if act == "display": - msg = "" + msg = "" msg += "Displaying Roles

Role   Player
" keys = self.players.keys() for m in keys: @@ -1996,7 +1995,7 @@ self.check_group(to_id, group_id) else: #tell the clients password manager the password failed -- SD 8/03 - pm = "" + pm = "" self.players[from_id].outbox.put(pm) print "boot passwords did not match" @@ -2027,8 +2026,9 @@ time.sleep( 1 ) self.log_msg("kicking player " + str(id) + " from server.") + # Send delete player event to all - self.send_to_group("0",group_id,self.players[id].toxml("del")) + self.send_to_group("0", group_id, self.players[id].toxml("del")) # Remove the player from local data structures self.del_player(id,group_id) @@ -2080,8 +2080,7 @@ # Send a message to everyone in the victim's room, letting them know someone has been booted ban_msg = "Banning '(%s) %s' from server... %s" % ( group_id, id, self.players[id].name, str(message)) self.log_msg("ban_msg:" + ban_msg) - if (silent == 0): - self.send_to_group("0", group_id, ban_msg) + if (silent == 0): self.send_to_group("0", group_id, ban_msg) time.sleep( .1 ) self.log_msg("baning player " + str(id) + " from server.") @@ -2520,12 +2519,11 @@ keys = self.groups.keys() keys.sort(id_compare) for k in keys: - debug((self.groups, self.groups[k], self.groups[k].name)) groupstring = "" groutstring += "Group " + str(k) + ": " + self.groups[k].name + "" groupstring += " Password: " + self.groups[k].pwd + "" groupstring += " Boot: " + self.groups[k].boot_pwd + "" - pl += groupstring; debug(groupstring) + pl += groupstring ids = self.groups[k].get_player_ids() ids.sort(id_compare) for id in ids: diff -r c2caca988a11 -r 06f10429eedc orpg/networking/mplay_server_gui.py --- a/orpg/networking/mplay_server_gui.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/networking/mplay_server_gui.py Wed Nov 25 06:15:49 2009 -0600 @@ -32,30 +32,12 @@ # Constants ###################################### SERVER_RUNNING = 1 SERVER_STOPPED = 0 -MENU_START_SERVER = wx.NewId() -MENU_STOP_SERVER = wx.NewId() -MENU_EXIT = wx.NewId() -MENU_REGISTER_SERVER = wx.NewId() -MENU_UNREGISTER_SERVER = wx.NewId() -MENU_START_PING_PLAYERS = wx.NewId() -MENU_STOP_PING_PLAYERS = wx.NewId() -MENU_PING_INTERVAL = wx.NewId() + ### Alpha ### MENU_MODIFY_BANLIST = wx.NewId() ############# -# Add our menu id's for our right click popup -MENU_PLAYER_BOOT = wx.NewId() -### Alpha ### -MENU_ADMIN_BAN = wx.NewId() -MENU_BAN_LIST = wx.NewId() -MENU_ADMIN_UNBAN = wx.NewId() -PLAYER_SHOW_VERSION = wx.NewId() -############# MENU_PLAYER_CREATE_ROOM = wx.NewId() -MENU_PLAYER_SEND_MESSAGE = wx.NewId() -MENU_PLAYER_SEND_ROOM_MESSAGE = wx.NewId() -MENU_PLAYER_SEND_SERVER_MESSAGE = wx.NewId() # Our new event type that gets posted from one # thread to another @@ -97,18 +79,15 @@ # ServerConfig Object ############################ class ServerConfig: - #debug(log=False) """ This class contains configuration setting used to control the server.""" def __init__(self, owner ): """ Loads default configuration settings.""" validate.config_file("server_ini.xml", "default_server_ini.xml") - config_xml = parse(dir_struct['user'] + 'server_ini.xml') - #debug(config_xml, log=False) - configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') - port = configDom.childNodes[0].childNodes[1].getAttribute('port') - OPENRPG_PORT = 6774 if port == '' else int(port) #Pretty ugly, but I couldn't find the tag any other way. + config_xml = parse(dir_struct['user'] + 'server_ini.xml').getroot() + port = config_xml.find('service').get('port') + OPENRPG_PORT = 6774 if port == '' else int(port) self.owner = owner def load_xml(self, xml): @@ -134,7 +113,6 @@ self.bootPwd = pwd def log(self, mesg): - #debug(log=False) if type(mesg) == types.TupleType: func, msg = mesg event = MessageFunctionEvent( func, msg ) @@ -143,7 +121,6 @@ del event def run(self): - #debug(log=False) """ Start the server. """ self.server = mplay_server(self.log, self.serverName ) self.server.initServer(bootPassword=self.bootPwd, reg="No") @@ -151,7 +128,6 @@ while self.alive: time.sleep(3) def stop(self): - #debug(log=False) """ Stop the server. """ self.server.kill_server() self.alive = 0 @@ -163,22 +139,19 @@ def __init__(self, parent, main): wx.ListCtrl.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES) - self.main = main """Not completed. Creates room, delets rooms. Does not track players. Nor does gsclient, ftm.""" + validate.config_file("server_ini.xml", "default_server_ini.xml" ) + config_xml = parse(dir_struct["user"] + 'server_ini.xml').getroot() + lobbyname = config_xml.get('lobbyname') - ### Alpha ### Get Lobby Name # Moving to etree. - validate.config_file("server_ini.xml", "default_server_ini.xml" ) - configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') - lobbyname = configDom.childNodes[0].getAttribute('lobbyname') - ############# + self.main = main self.roomList = { 0 : lobbyname } - self.InsertColumn(0, 'Group ID') self.InsertColumn(1, 'Game') self.InsertColumn(2, 'Players') self.InsertColumn(3, 'Passworded') - self.AddGroup((self.roomList[0], '0', 'Need to Find', 'No')) + self.AddGroup((self.roomList[0], '0', '0', 'No')) def AddGroup(self, data): (room, room_id, players, passworded) = data @@ -191,25 +164,23 @@ i = self.FindItem(-1, str(data)) self.DeleteItem(i) - def UpdateRoom(self, data): + def UpdateGroup(self, data): (room, room_id, players) = data i = self.FindItem( -1, str(room_id)) self.SetStringItem( i, 1, room ) - if players: self.SetStringItem(i, 2, players) + if players: self.SetStringItem(i, 2, str(players)) ### Need to add room for Password Updates ### class Connections(wx.ListCtrl): def __init__( self, parent, main ): wx.ListCtrl.__init__( self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES ) - self.main = main - ### Alpha ### Get Lobby Name validate.config_file("server_ini.xml", "default_server_ini.xml" ) - configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') - lobbyname = configDom.childNodes[0].getAttribute('lobbyname') - ############# + config_xml = parse(dir_struct["user"] + 'server_ini.xml').getroot() + lobbyname = config_xml.get('lobbyname') + self.main = main self.roomList = { 0 : lobbyname } self._imageList = wx.ImageList( 16, 16, False ) img = wx.Image(dir_struct["icon"]+"player.gif", wx.BITMAP_TYPE_GIF).ConvertToBitmap() @@ -234,22 +205,22 @@ # Build our pop up menu to do cool things with the players in the list self.menu = wx.Menu() self.menu.SetTitle( "Player Menu" ) - self.menu.Append( MENU_PLAYER_BOOT, "Boot Player" ) - self.menu.Append( MENU_ADMIN_BAN, 'Ban Player' ) - self.menu.Append( PLAYER_SHOW_VERSION, "Player Version" ) + self.menu.Append( 1, "Boot Player" ) + self.menu.Append( 2, 'Ban Player' ) + self.menu.Append( 3, "Player Version" ) self.menu.AppendSeparator() - self.menu.Append( MENU_PLAYER_SEND_MESSAGE, "Send Player Message" ) - self.menu.Append( MENU_PLAYER_SEND_ROOM_MESSAGE, "Send Room Message" ) - self.menu.Append( MENU_PLAYER_SEND_SERVER_MESSAGE, "Broadcast Server Message" ) + self.menu.Append( 4, "Send Player Message" ) + self.menu.Append( 5, "Send Room Message" ) + self.menu.Append( 6, "Broadcast Server Message" ) # Associate our events self.Bind(wx.EVT_RIGHT_DOWN, self.OnPopupMenu) - self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_BOOT) - self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_ADMIN_BAN) - self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_MESSAGE) - self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_ROOM_MESSAGE) - self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=MENU_PLAYER_SEND_SERVER_MESSAGE) - self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=PLAYER_SHOW_VERSION) + self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=1) + self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=2) + self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=4) + self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=5) + self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=6) + self.Bind(wx.EVT_MENU, self.OnPopupMenuItem, id=3) def add(self, player): i = self.InsertImageStringItem( 0, player["id"], 0 ) @@ -293,8 +264,7 @@ if player['group_id'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) except KeyError: # Needed because group_id turns into group somewhere. if player['group'] != "0": item.SetTextColour(settings.get_setting(role + "RoleColor")) - except: - item.SetTextColour('BLUE') + except: item.SetTextColour('BLUE') self.SetItem(item) def update(self, player): @@ -351,13 +321,9 @@ for r in self.roomList: if room == self.roomList[r]: groupID = r else: groupID = 0 - if menuItem == MENU_PLAYER_BOOT: - print "booting player: ", playerID - self.main.server.server.del_player( playerID, groupID ) - self.main.server.server.check_group( playerID, groupID ) - self.remove( playerID ) - ### Alpha ### - elif menuItem == MENU_ADMIN_BAN: + if menuItem == 1: + self.main.server.server.admin_kick( playerID ) + elif menuItem == 2: message = 'Banishment' BanMsg = wx.TextEntryDialog( self, "Enter A Message To Send:", "Ban Message", message, wx.OK|wx.CANCEL|wx.CENTRE ) @@ -369,22 +335,17 @@ else: silent = 0 self.main.server.server.admin_ban(playerID, message, silent) self.remove( playerID ) - ############### - elif menuItem == MENU_PLAYER_SEND_MESSAGE: - print "send a message..." + elif menuItem == 4: msg = self.GetMessageInput( "Send a message to player" ) if len(msg): self.main.server.server.send( msg, playerID, str(groupID) ) #Leave this in for now. - elif menuItem == MENU_PLAYER_SEND_ROOM_MESSAGE: - print "Send message to room..." + elif menuItem == 5: msg = self.GetMessageInput( "Send message to room of this player") if len(msg): self.main.server.server.send_to_group('0', str(groupID), msg ) - elif menuItem == MENU_PLAYER_SEND_SERVER_MESSAGE: - print "broadcast a message..." + elif menuItem == 6: msg = self.GetMessageInput( "Broadcast Server Message" ) - # If we got a message back, send it if len(msg): self.main.server.server.broadcast( msg ) - elif menuItem == PLAYER_SHOW_VERSION: + elif menuItem == 3: version_string = self.main.server.server.obtain_by_id(playerID, 'client_string') if version_string: wx.MessageBox("Running client version " + version_string,"Version") else: wx.MessageBox("No client version available for this player", "Version") @@ -405,6 +366,7 @@ self.SetIcon(icon) self.serverName = "Server Name" self.bootPwd = "" + self.do_log = True # Register our events to process -- notice the custom event handler self.Bind(wx.EVT_CLOSE, self.OnExit) @@ -415,16 +377,12 @@ self.build_menu() self.build_body() self.build_status() - - ### Alpha ### - # Ban List Dialog self.BanListDialog = BanListDialog(self) - ############# # Server Callbacks cb = {} cb["log"] = self.Log - cb["connect"] = self.OnConnect ##Fixed!! + cb["connect"] = self.OnConnect cb["disconnect"] = self.OnDisconnect cb["update"] = self.OnUpdatePlayer cb["data_recv"] = self.OnDataRecv @@ -444,65 +402,75 @@ self.total_data_sent = 0 """ Build GUI """ - def build_menu(self): """ Build the GUI menu. """ self.mainMenu = wx.MenuBar() # File Menu menu = wx.Menu() - menu.Append( MENU_START_SERVER, 'Start', 'Start server.') - self.Bind(wx.EVT_MENU, self.OnStart, id=MENU_START_SERVER) - menu.Append( MENU_STOP_SERVER, 'Stop', 'Shutdown server.') - self.Bind(wx.EVT_MENU, self.OnStop, id=MENU_STOP_SERVER) + menu.Append( 1, 'Start', 'Start server.') + menu.Append( 2, 'Stop', 'Shutdown server.') menu.AppendSeparator() - menu.Append( MENU_EXIT, 'E&xit', 'Exit application.') - self.Bind(wx.EVT_MENU, self.OnExit, id=MENU_EXIT) + menu.Append( 3, 'E&xit', 'Exit application.') + self.Bind(wx.EVT_MENU, self.OnStart, id=1) + self.Bind(wx.EVT_MENU, self.OnStop, id=2) + self.Bind(wx.EVT_MENU, self.OnExit, id=3) self.mainMenu.Append(menu, '&Server') # Registration Menu menu = wx.Menu() - menu.Append( MENU_REGISTER_SERVER, 'Register', 'Register with OpenRPG server directory.') - self.Bind(wx.EVT_MENU, self.OnRegister, id=MENU_REGISTER_SERVER) - menu.Append( MENU_UNREGISTER_SERVER, 'Unregister', 'Unregister from OpenRPG server directory.') - self.Bind(wx.EVT_MENU, self.OnUnregister, id=MENU_UNREGISTER_SERVER) + menu.Append( 4, 'Register', 'Register with OpenRPG server directory.') + menu.Append( 5, 'Unregister', 'Unregister from OpenRPG server directory.') + self.Bind(wx.EVT_MENU, self.OnRegister, id=4) + self.Bind(wx.EVT_MENU, self.OnUnregister, id=5) self.mainMenu.Append( menu, '&Registration' ) # Server Configuration Menu menu = wx.Menu() - menu.Append( MENU_BAN_LIST, 'Ban List', 'Modify Ban List.' ) - self.Bind(wx.EVT_MENU, self.ModifyBanList, id=MENU_BAN_LIST) - menu.Append( MENU_START_PING_PLAYERS, 'Start Ping', 'Ping players to validate remote connection.' ) - self.Bind(wx.EVT_MENU, self.PingPlayers, id=MENU_START_PING_PLAYERS) - menu.Append( MENU_STOP_PING_PLAYERS, 'Stop Ping', 'Stop validating player connections.' ) - self.Bind(wx.EVT_MENU, self.StopPingPlayers, id=MENU_STOP_PING_PLAYERS) - menu.Append( MENU_PING_INTERVAL, 'Ping Interval', 'Change the ping interval.' ) - self.Bind(wx.EVT_MENU, self.ConfigPingInterval, id=MENU_PING_INTERVAL) + menu.Append( 6, 'Ban List', 'Modify Ban List.') + menu.Append(11, 'Zombies', 'Set auto-kick time for zombie clients') + menu.Append(14, 'Send Size', 'Adjust the send size limit') + menu.AppendSeparator() + menu.Append( 7, 'Start Ping', 'Ping players to validate remote connection.' ) + menu.Append( 8, 'Stop Ping', 'Stop validating player connections.' ) + menu.Append( 9, 'Ping Interval', 'Change the ping interval.' ) + menu.AppendSeparator() + menu.AppendCheckItem( 10, 'Server Logging', 'Turn on or off the Server GUI Log').Check(self.do_log) + menu.AppendCheckItem(12, 'Room Passwords', 'Allow or Deny Room Passwords').Check(False) + menu.AppendCheckItem(13, 'Remote Admin', 'Allow or Deny Remote Admin').Check(False) + menu.AppendCheckItem(15, 'Remote Kill', 'Allow or Deny Remote Admin Server Kill').Check(False) + self.Bind(wx.EVT_MENU, self.ModifyBanList, id=6) + self.Bind(wx.EVT_MENU, self.PingPlayers, id=7) + self.Bind(wx.EVT_MENU, self.StopPingPlayers, id=8) + self.Bind(wx.EVT_MENU, self.ConfigPingInterval, id=9) + self.Bind(wx.EVT_MENU, self.LogToggle, id=10) self.mainMenu.Append( menu, '&Configuration' ) - self.SetMenuBar( self.mainMenu ) - self.mainMenu.Enable( MENU_STOP_SERVER, False ) - self.mainMenu.Enable( MENU_REGISTER_SERVER, False ) - self.mainMenu.Enable( MENU_UNREGISTER_SERVER, False ) + self.mainMenu.Enable( 2, False ) + self.mainMenu.Enable( 4, False ) + self.mainMenu.Enable( 5, False ) # Disable the ping menu items - self.mainMenu.Enable( MENU_START_PING_PLAYERS, False ) - self.mainMenu.Enable( MENU_STOP_PING_PLAYERS, False ) - self.mainMenu.Enable( MENU_PING_INTERVAL, False ) + self.mainMenu.Enable( 7, False ) + self.mainMenu.Enable( 8, False ) + self.mainMenu.Enable( 9, False ) + # Disable placeholders + self.mainMenu.Enable( 11, False ) + self.mainMenu.Enable( 14, False ) + self.mainMenu.Enable( 12, False ) + self.mainMenu.Enable( 13, False ) + self.mainMenu.Enable( 15, False ) def build_body(self): """ Create the ViewNotebook and logger. """ splitter = wx.SplitterWindow(self, -1, style=wx.NO_3D | wx.SP_3D) nb = wx.Notebook( splitter, -1 ) self.conns = Connections(nb, self) self.groups = Groups(nb, self) + self.msgWindow = HTMLMessageWindow( nb ) nb.AddPage(self.conns, "Players") nb.AddPage(self.groups, 'Rooms') - - #Not sure why this is Remarked TaS - Sirebral - #nb.AddPage( self.conns, "Rooms" ) - self.msgWindow = HTMLMessageWindow( nb ) nb.AddPage( self.msgWindow, "Messages" ) log = wx.TextCtrl(splitter, -1, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) @@ -535,6 +503,9 @@ # Event handler for out logging event + def LogToggle(self, event): + self.do_log = event.IsChecked() + def OnLogMessage( self, event ): self.Log( event.message ) @@ -544,7 +515,7 @@ ### Server Callbacks ##################################### def Log(self, log): - wx.LogMessage(str(log)) + if self.do_log: wx.LogMessage(str(log)) def OnConnect(self, player): self.conns.add(player) @@ -578,7 +549,6 @@ del self.conns.roomList[room_id] def OnJoinGroup(self, data): - #debug(data) self.conns.updateRoom(data) def OnUpdateGroup(self, data): @@ -596,10 +566,8 @@ # see if we already have name specified try: validate.config_file( "server_ini.xml", "default_server_ini.xml" ) - configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') - configDom.normalize() - configDoc = configDom.documentElement - if configDoc.hasAttribute("name"): self.serverName = configDoc.getAttribute("name") + configDoc = parse(dir_struct["user"] + 'server_ini.xml').getroot() + if configDoc.get("name"): self.serverName = configDoc.get("name") except: pass if self.serverName == '': self.serverName = 'Server Name' @@ -609,11 +577,9 @@ # see if we already have password specified try: validate.config_file( "server_ini.xml", "default_server_ini.xml" ) - configDom = minidom.parse(dir_struct["user"] + 'server_ini.xml') - configDom.normalize() - configDoc = configDom.documentElement - if configDoc.hasAttribute("admin"): self.bootPwd = configDoc.getAttribute("admin") - elif configDoc.hasAttribute("boot"): self.bootPwd = configDoc.getAttribute("boot") + configDoc = parse(dir_struct["user"] + 'server_ini.xml').getroot() + if configDoc.get("admin"): self.bootPwd = configDoc.get("admin") + elif configDoc.get("boot"): self.bootPwd = configDoc.get("boot") except: pass if self.bootPwd == '': serverPasswordEntry = wx.TextEntryDialog(self, @@ -627,9 +593,9 @@ self.STATUS = SERVER_RUNNING self.sb.SetStatusText("Running", 3) self.SetTitle(__appname__ + "- (running) - (unregistered)") - self.mainMenu.Enable( MENU_START_SERVER, False ) - self.mainMenu.Enable( MENU_STOP_SERVER, True ) - self.mainMenu.Enable( MENU_REGISTER_SERVER, True ) + self.mainMenu.Enable( 1, False ) + self.mainMenu.Enable( 2, True ) + self.mainMenu.Enable( 4, True ) wx.EndBusyCursor() else: self.show_error("Server is already running.", "Error Starting Server") @@ -641,10 +607,10 @@ self.STATUS = SERVER_STOPPED self.sb.SetStatusText("Stopped", 3) self.SetTitle(__appname__ + "- (stopped) - (unregistered)") - self.mainMenu.Enable( MENU_STOP_SERVER, False ) - self.mainMenu.Enable( MENU_START_SERVER, True ) - self.mainMenu.Enable( MENU_REGISTER_SERVER, False ) - self.mainMenu.Enable( MENU_UNREGISTER_SERVER, False ) + self.mainMenu.Enable( 1, True ) + self.mainMenu.Enable( 2, False ) + self.mainMenu.Enable( 4, False ) + self.mainMenu.Enable( 5, False ) self.conns.DeleteAllItems() def OnRegister(self, event = None): @@ -656,9 +622,9 @@ wx.BeginBusyCursor() self.server.server.register(self.serverName) self.sb.SetStatusText( ("%s" % (self.serverName)), 4 ) - self.mainMenu.Enable( MENU_REGISTER_SERVER, False ) - self.mainMenu.Enable( MENU_UNREGISTER_SERVER, True ) - self.mainMenu.Enable( MENU_STOP_SERVER, False ) + self.mainMenu.Enable( 4, False ) + self.mainMenu.Enable( 5, True ) + #self.mainMenu.Enable( 2, False ) self.SetTitle(__appname__ + "- (running) - (registered)") wx.EndBusyCursor() @@ -671,17 +637,15 @@ wx.BeginBusyCursor() self.server.server.unregister() self.sb.SetStatusText( "Unregistered", 4 ) - self.mainMenu.Enable( MENU_UNREGISTER_SERVER, False ) - self.mainMenu.Enable( MENU_REGISTER_SERVER, True ) - self.mainMenu.Enable( MENU_STOP_SERVER, True ) + self.mainMenu.Enable( 5, False ) + self.mainMenu.Enable( 4, True ) + #self.mainMenu.Enable( 2, True ) self.SetTitle(__appname__ + "- (running) - (unregistered)") wx.EndBusyCursor() - ### Alpha ### def ModifyBanList(self, event): if self.BanListDialog.IsShown() == True: self.BanListDialog.Hide() else: self.BanListDialog.Show() - ############# def PingPlayers( self, event = None ): "Ping all players that are connected at a periodic interval, detecting dropped connections." @@ -704,10 +668,9 @@ def ExitConfirmed(self, event=None): """ Quit the program. """ self.OnStop() - self.BanListDialog.Destroy() ### Alpha ### + self.BanListDialog.Destroy() wx.CallAfter(self.Destroy) -### Alpha ### class BanListDialog(wx.Frame): def __init__(self, parent): super(BanListDialog, self).__init__(parent, -1, "Ban List") @@ -726,11 +689,11 @@ # Ban List Dialog Pop Up Menu, more can be added self.menu = wx.Menu() self.menu.SetTitle( "Modify Ban List" ) - self.menu.Append( MENU_ADMIN_UNBAN, "Un-Ban Player" ) + self.menu.Append( 1, "Un-Ban Player" ) # Even Association self.BanList.Bind(wx.EVT_RIGHT_DOWN, self.BanPopupMenu) - self.Bind(wx.EVT_MENU, self.BanPopupMenuItem, id=MENU_ADMIN_UNBAN) + self.Bind(wx.EVT_MENU, self.BanPopupMenuItem, id=1) # When we right click, cause our popup menu to appear def BanPopupMenu( self, event ): @@ -744,7 +707,7 @@ menuItem = event.GetId() player = str(self.BanList.GetItemData(self.selectedItem)) playerIP = str(self.BanList.GetItem((int(player)), 1).GetText()) - if menuItem == MENU_ADMIN_UNBAN: + if menuItem == 1: server.admin_unban(playerIP) self.BanList.DeleteItem(self.BanList.GetItemData(self.selectedItem)) self.BanList.Refresh() @@ -756,11 +719,11 @@ self.BanList.InsertColumn(1, "IP") validate.config_file("ban_list.xml", "default_ban_list.xml" ) - configDom = minidom.parse(dir_struct["user"] + 'ban_list.xml') + configDom = parse(dir_struct["user"] + 'ban_list.xml').getroot() ban_dict = {} - for element in configDom.getElementsByTagName('banned'): - player = element.getAttribute('name').replace("&", "&").replace("<", "<").replace('"', """).replace(">", ">") - playerIP = element.getAttribute('ip') + for element in configDom.findall('banned'): + player = element.get('name').replace("&", "&").replace("<", "<").replace('"', """).replace(">", ">") + playerIP = element.get('ip') ban_dict[player] = playerIP for key in ban_dict: i = self.BanList.InsertImageStringItem( 0, key, 0 ) @@ -774,6 +737,7 @@ self.BanList.Refresh() def Min(self, evt): + self.BuildList() self.Hide() ############### diff -r c2caca988a11 -r 06f10429eedc orpg/networking/server_plugins.py --- a/orpg/networking/server_plugins.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/networking/server_plugins.py Wed Nov 25 06:15:49 2009 -0600 @@ -1,5 +1,4 @@ -import sys -import os +import sys, os from orpg.dirpath import dir_struct class _SingletonKey(object): diff -r c2caca988a11 -r 06f10429eedc orpg/orpg_version.py --- a/orpg/orpg_version.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/orpg_version.py Wed Nov 25 06:15:49 2009 -0600 @@ -4,7 +4,7 @@ #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed) DISTRO = "Traipse Alpha" DIS_VER = "Ornery Orc" -BUILD = "091124-00" +BUILD = "091125-00" # This version is for network capability. PROTOCOL_VERSION = "1.2" diff -r c2caca988a11 -r 06f10429eedc orpg/orpg_windows.py --- a/orpg/orpg_windows.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/orpg_windows.py Wed Nov 25 06:15:49 2009 -0600 @@ -277,7 +277,7 @@ (beg,end) = self.text.GetSelection() if beg != end: sel_txt = txt[beg:end] else: return - print txt + # TaS - sirebral. Replaces 6 lines with 4 lines. recycle_bin = {self.BOLD: "b", self.ITALIC: "i", self.UNDER: "u"} if recycle_bin.has_key(id): @@ -329,7 +329,6 @@ else: self.load_url(self.path+address) def load_url(self,path): - print path dlg = wx.ProgressDialog("HTML Document","Loading...",3,self) dlg.Update(1) try: @@ -483,7 +482,6 @@ # continue search from insertion point instead of top self.matchPosition = self.matchPositionOld = self.text.GetInsertionPoint() - # find search string in chatbuffer self.matchPosition = string.find(textValue[self.matchPositionOld:], matchValue) # cumulate position for substring matching in continuing search diff -r c2caca988a11 -r 06f10429eedc orpg/player_list.py --- a/orpg/player_list.py Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/player_list.py Wed Nov 25 06:15:49 2009 -0600 @@ -55,26 +55,15 @@ PLAYER_SHOW_VERSION = wx.NewId() WG_LIST = {} -#--------------------------------------------------------- -# [START] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- PLAYER_WG_MENU = wx.NewId() PLAYER_WG_CREATE = wx.NewId() PLAYER_WG_CLEAR_ALL = wx.NewId() WG_MENU_LIST = {} -#--------------------------------------------------------- -# [END] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- -#--------------------------------------------------------- -# [START] Snowdog Password/Room Name altering code 12/02 -#--------------------------------------------------------- PLAYER_COMMAND_MENU = wx.NewId() PLAYER_COMMAND_PASSWORD_ALTER = wx.NewId() PLAYER_COMMAND_ROOM_RENAME = wx.NewId() -#--------------------------------------------------------- -# [END] Snowdog Password/Room Name altering code 12/02 -#--------------------------------------------------------- + class player_list(wx.ListCtrl): def __init__( self, parent): @@ -96,17 +85,13 @@ self.InsertColumn( 0, "ID" ) self.InsertColumn( 1, "Player") self.InsertColumn( 2, "Status" ) -#--------------------------------------------------------- -# [START] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- + ##Main Menu self.wgMenu = wx.Menu() #Add the Base Menu items, so they are always at the bottom self.wgMenu.Append(PLAYER_WG_CREATE, "Create") self.wgMenu.Append(PLAYER_WG_CLEAR_ALL, "Delete All Groups") -#--------------------------------------------------------- -# [END] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- + # Create the role menu self.roleMenu = wx.Menu() self.roleMenu.SetTitle( "Assign Role" ) @@ -121,18 +106,14 @@ self.moderateMenu.AppendSeparator() self.moderateMenu.Append( PLAYER_MODERATE_GIVE_VOICE, "Give Voice" ) self.moderateMenu.Append( PLAYER_MODERATE_TAKE_VOICE, "Take Voice" ) -#--------------------------------------------------------- -# [START] Snowdog Password/Room Name altering code 12/02 -#--------------------------------------------------------- + # Create the room control menu self.commandMenu = wx.Menu() self.commandMenu.SetTitle( "Room Controls" ) self.commandMenu.Append( PLAYER_COMMAND_PASSWORD_ALTER, "Password" ) self.commandMenu.Append( PLAYER_COMMAND_ROOM_RENAME, "Room Name" ) self.commandMenu.AppendSeparator() -#--------------------------------------------------------- -# [END] Snowdog Password/Room Name altering code 12/02 -#--------------------------------------------------------- + # Create the pop up menu self.menu = wx.Menu() self.menu.SetTitle( "Player Menu" ) @@ -141,13 +122,7 @@ self.menu.Append( PLAYER_IGNORE, "Toggle &Ignore" ) self.menu.AppendSeparator() self.menu.Append( PLAYER_WHISPER, "Whisper" ) -#--------------------------------------------------------- -# [START] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- self.menu.AppendMenu(PLAYER_WG_MENU, "Whisper Groups", self.wgMenu) -#--------------------------------------------------------- -# [END] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- self.menu.AppendSeparator() self.menu.AppendMenu( PLAYER_MODERATE_MENU, "Moderate", self.moderateMenu ) self.menu.AppendMenu( PLAYER_COMMAND_MENU, "Room Control", self.commandMenu ) @@ -155,6 +130,7 @@ self.menu.AppendMenu( PLAYER_ROLE_MENU, "Assign Role", self.roleMenu ) self.menu.AppendSeparator() self.menu.Append( PLAYER_SHOW_VERSION, "Version" ) + # Event processing for our menu self.Bind(wx.EVT_MENU, self.on_menu_item, id=PLAYER_BOOT) self.Bind(wx.EVT_MENU, self.on_menu_item, id=PLAYER_IGNORE) @@ -167,30 +143,13 @@ self.Bind(wx.EVT_MENU, self.on_menu_role_change, id=PLAYER_ROLE_PLAYER) self.Bind(wx.EVT_MENU, self.on_menu_role_change, id=PLAYER_ROLE_GM) self.Bind(wx.EVT_MENU, self.on_menu_item, id=PLAYER_SHOW_VERSION) -#--------------------------------------------------------- -# [START] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=PLAYER_WG_CREATE) self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=PLAYER_WG_CLEAR_ALL) -#--------------------------------------------------------- -# [END] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- -#--------------------------------------------------------- -# [START] Snowdog Password/Room Name altering code 12/02 -#--------------------------------------------------------- self.Bind(wx.EVT_MENU, self.on_menu_password, id=PLAYER_COMMAND_PASSWORD_ALTER) self.Bind(wx.EVT_MENU, self.on_menu_room_rename, id=PLAYER_COMMAND_ROOM_RENAME) -#--------------------------------------------------------- -# [END] Snowdog Password/Room Name altering code 12/02 -#--------------------------------------------------------- self.Bind(wx.EVT_LEFT_DCLICK, self.on_d_lclick) self.Bind(wx.EVT_RIGHT_DOWN, self.on_menu) self.sized = 1 -#--------------------------------------------------------- -# [START] Snowdog Password/Room Name altering code 12/02 -# -# Revised 8/03 to add support for password manager -#--------------------------------------------------------- def AutoAdjust(self): self.SetColumnWidth(0, -1) @@ -251,13 +210,7 @@ new_name = b + ""e" + e oldloc = loc +1 self.session.set_room_name(new_name, boot_pwd) -#--------------------------------------------------------- -# [END] Snowdog Password/Room Name altering code 12/02 -#--------------------------------------------------------- -#--------------------------------------------------------- -# [START] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- def clean_sub_menus(self): for mid in WG_MENU_LIST: try: @@ -290,10 +243,6 @@ elif id == WG_MENU_LIST[mid]["whisper"]: self.chat.set_chat_text("/gw " + mid + "="); return return -#--------------------------------------------------------- -# [END] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- - def on_menu_moderate( self, evt ): "Change the moderated status of a room or player." id = evt.GetId() @@ -397,9 +346,6 @@ #else: self.menu.Enable(PLAYER_BOOT,1) self.menu.SetLabel(PLAYER_BOOT,"Boot") -#--------------------------------------------------------- -# [START] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- self.menu.Enable(PLAYER_WG_MENU, True) item = self.GetItem( self.selected_item ) if len(WG_MENU_LIST) > len(WG_LIST): self.clean_sub_menus() @@ -438,9 +384,6 @@ self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=WG_MENU_LIST[gid]["add"] ) self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=WG_MENU_LIST[gid]["remove"] ) self.Bind(wx.EVT_MENU, self.on_menu_whispergroup, id=WG_MENU_LIST[gid]["clear"] ) -#--------------------------------------------------------- -# [END] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- self.PopupMenu(self.menu,pos) def add_player(self,player): @@ -461,15 +404,8 @@ def del_player(self,player): i = self.FindItemData(-1,int(player[2])) self.DeleteItem(i) - -#--------------------------------------------------------- -# [START] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- for gid in WG_LIST: if WG_LIST[gid].has_key(int(player[2])): del WG_LIST[gid][int(player[2])] -#--------------------------------------------------------- -# [END] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- # play sound setobj = component.get('settings') @@ -520,13 +456,7 @@ def reset(self): self.whisperCount = 0 -#--------------------------------------------------------- -# [START] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- WG_LIST.clear() -#--------------------------------------------------------- -# [END] Digitalxero Multi Whisper Group 1/1/05 -#--------------------------------------------------------- self.DeleteAllItems() def strip_html(self,player): diff -r c2caca988a11 -r 06f10429eedc orpg/templates/nodes/dnd3e.xml --- a/orpg/templates/nodes/dnd3e.xml Tue Nov 24 17:17:42 2009 -0600 +++ b/orpg/templates/nodes/dnd3e.xml Wed Nov 25 06:15:49 2009 -0600 @@ -49,7 +49,7 @@ - + 0 0 0