Mercurial > traipse_dev
diff orpg/gametree/nodehandlers/containers.py @ 118:217fb049bd00 alpha
Traipse Alpha 'OpenRPG' {091028-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:
Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images!
Changes made to the map for increased portability. SnowDog has changes planned in
Core, though.
Added an initial push to the BCG. Not much to see, just shows off how it is
re-writing Main code.
Fix to remote admin commands
Minor fix to texted based server, works in /System/ folder
Some Core changes to gametree to correctly disply Pretty Print, thanks David!
Fix to Splitter Nodes not being created.
Added images to Plugin Control panel for Autostart feature
Fix to massive amounts of images loading; from Core
fix to gsclient so with_statement imports
Added 'boot' command to remote admin
Prep work in Pass tool for remote admin rankings and different passwords, ei,
Server, Admin, Moderator, etc.
Remote Admin Commands more organized, more prep work.
Added Confirmation window for sent nodes.
Minor changes to allow for portability to an OpenSUSE linux OS (hopefully without
breaking)
{091028}
00:
Made changes to gametree to start working with Element Tree, mostly from Core
Minor changes to Map to start working with Element Tree, from Core
Preliminary changes to map efficiency, from FlexiRPG
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Changes to main.py to start working with Element Tree
author | sirebral |
---|---|
date | Wed, 28 Oct 2009 14:24:54 -0500 |
parents | 0c936d98f9eb |
children | d54e1328dbb1 |
line wrap: on
line diff
--- a/orpg/gametree/nodehandlers/containers.py Mon Oct 12 23:24:10 2009 -0500 +++ b/orpg/gametree/nodehandlers/containers.py Wed Oct 28 14:24:54 2009 -0500 @@ -39,32 +39,30 @@ """ should not be used! only a base class! <nodehandler name='?' module='core' class='container_handler' /> """ - 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.load_children() def load_children(self): - children = self.master_dom._get_childNodes() - for c in children: - self.tree.load_xml(c,self.mytree_node) + for child_xml in self.xml: + self.tree.load_xml(child_xml,self.mytree_node) - def check_map_aware(self, obj, evt): - if hasattr(obj,"map_aware") and obj.map_aware(): - obj.on_send_to_map(evt) - + 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) def on_send_to_map(self, evt): - self.traverse(self.mytree_node, self.check_map_aware, evt) - + self.tree.traverse(self.mytree_node, self.check_map_aware, evt) - def checkChildToMap(self, obj, evt): - if hasattr(obj,"map_aware") and obj.map_aware(): + def checkChildToMap(self, treenode, evt): + node = self.tree.GetPyData(treenode) + if hasattr(node,"map_aware") and node.map_aware(): self.mapcheck = True def checkToMapMenu(self): self.mapcheck = False - self.traverse(self.mytree_node, self.checkChildToMap) - + self.tree.traverse(self.mytree_node, self.checkChildToMap) return self.mapcheck def on_drop(self,evt): @@ -73,23 +71,24 @@ return opt = wx.MessageBox("Add node as child?","Container Node",wx.YES_NO|wx.CANCEL) if opt == wx.YES: - xml_dom = self.tree.drag_obj.delete() - xml_dom = self.master_dom.insertBefore(xml_dom,None) - self.tree.load_xml(xml_dom, self.mytree_node) + 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) - def gen_html(self, obj, evt): - self.html_str += "<p>" + obj.tohtml() - + def gen_html(self, treenode, evt): + node = self.tree.GetPyData(treenode) + self.html_str += "<p>" + node.tohtml() + def tohtml(self): self.html_str = "<table border=\"1\" ><tr><td>" - self.html_str += "<b>"+self.master_dom.getAttribute("name") + "</b>" + self.html_str += "<b>"+self.xml.get("name") + "</b>" self.html_str += "</td></tr>\n" self.html_str += "<tr><td>" - self.traverse(self.mytree_node, self.gen_html, recurse=False) + self.tree.traverse(self.mytree_node, self.gen_html, recurse=False) self.html_str += "</td></tr></table>" return self.html_str @@ -106,22 +105,21 @@ This handler will continue parsing child xml data. <nodehandler name='?' module='core' class='group_handler' /> """ - def __init__(self,xml_dom,tree_node): - container_handler.__init__(self,xml_dom,tree_node) + def __init__(self, xml, tree_node): + container_handler.__init__(self, xml, tree_node) def load_children(self): self.atts = None - children = self.master_dom._get_childNodes() - for c in children: - if c._get_tagName() == "group_atts": - self.atts = c + for child_xml in self.xml: + if child_xml.tag == "group_atts": + self.atts = child_xml else: - self.tree.load_xml(c,self.mytree_node) + self.tree.load_xml(child_xml,self.mytree_node) if not self.atts: - elem = self.xml.minidom.Element('group_atts') - elem.setAttribute("cols","1") - elem.setAttribute("border","1") - self.atts = self.master_dom.appendChild(elem) + 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) @@ -129,27 +127,25 @@ def on_use(self,evt): return - def gen_html(self, obj, evt): + def gen_html(self, treenode, evt): + node = self.tree.GetPyData(treenode) if self.i not in self.tdatas: self.tdatas[self.i] = '' - self.tdatas[self.i] += "<P>" + obj.tohtml() + self.tdatas[self.i] += "<P>" + node.tohtml() self.i += 1 if self.i >= self.cols: self.i = 0 def tohtml(self): - cols = self.atts.getAttribute("cols") - border = self.atts.getAttribute("border") + cols = self.atts.get("cols") + border = self.atts.get("border") self.html_str = "<table border=\""+border+"\" ><tr><td colspan=\""+cols+"\">" - self.html_str += "<font size=4>"+self.master_dom.getAttribute("name") + "</font>" + self.html_str += "<font size=4>"+self.xml.get("name") + "</font>" self.html_str += "</td></tr>\n<tr>" - self.cols = int(cols) self.i = 0 self.tdatas = {} - - self.traverse(self.mytree_node, self.gen_html, recurse=False) - + self.tree.traverse(self.mytree_node, self.gen_html, recurse=False) for td in self.tdatas: self.html_str += "<td valign=\"top\" >" + self.tdatas[td] + "</td>\n"; self.html_str += "</tr></table>" @@ -163,19 +159,19 @@ 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')) + self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')) } sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) sizer.Add(wx.Size(10,10)) radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"]) - cols = handler.atts.getAttribute("cols") + cols = handler.atts.get("cols") if cols != "": radio_c.SetSelection(int(cols)-1) radio_b = wx.RadioBox(self, GROUP_BOR, "Border", choices=["no","yes"]) - border = handler.atts.getAttribute("border") + border = handler.atts.get("border") if border != "": radio_b.SetSelection(int(border)) @@ -197,16 +193,16 @@ id = evt.GetId() index = evt.GetInt() if id == GROUP_COLS: - self.handler.atts.setAttribute("cols",str(index+1)) + self.handler.atts.set("cols",str(index+1)) elif id == GROUP_BOR: - self.handler.atts.setAttribute("border",str(index)) + self.handler.atts.set("border",str(index)) def on_text(self,evt): id = evt.GetId() if id == P_TITLE: txt = self.text[id].GetValue() if txt != "": - self.handler.master_dom.setAttribute('name',txt) + self.handler.xml.set('name',txt) self.handler.rename(txt) @@ -217,8 +213,8 @@ class tabber_handler(container_handler): """ <nodehandler name='?' module='containers' class='tabber_handler' />""" - def __init__(self,xml_dom,tree_node): - container_handler.__init__(self,xml_dom,tree_node) + def __init__(self, xml, tree_node): + container_handler.__init__(self, xml, tree_node) def get_design_panel(self,parent): return tabbed_panel(parent,self,1) @@ -232,20 +228,16 @@ orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON) self.handler = handler self.parent = parent - handler.traverse(handler.mytree_node, self.pick_panel, mode, False) + handler.tree.traverse(handler.mytree_node, self.pick_panel, mode, False) parent.SetSize(self.GetBestSize()) - def pick_panel(self, obj, mode): - if mode == 1: - panel = obj.get_design_panel(self) - else: - panel = obj.get_use_panel(self) - - name = obj.master_dom.getAttribute("name");print 'here '+name - - if panel: - self.AddPage(panel, name, False) + def pick_panel(self, treenode, mode): + 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") + if panel: self.AddPage(panel, name, False) ################################# ## Splitter container @@ -254,21 +246,18 @@ class splitter_handler(container_handler): """ <nodehandler name='?' module='containers' class='splitter_handler' />""" - def __init__(self,xml_dom,tree_node): - container_handler.__init__(self,xml_dom,tree_node) + def __init__(self,xml,tree_node): + container_handler.__init__(self,xml,tree_node) def load_children(self): self.atts = None - children = self.master_dom._get_childNodes() - for c in children: - if c._get_tagName() == "splitter_atts": - self.atts = c - else: - self.tree.load_xml(c,self.mytree_node) + for child_xml in self.xml: + if child_xml.tag == "splitter_atts": self.atts = child_xml + else: self.tree.load_xml(child_xml,self.mytree_node) if not self.atts: - elem = self.xml.minidom.Element('splitter_atts') - elem.setAttribute("horizontal","0") - self.atts = self.master_dom.appendChild(elem) + self.atts = Element('splitter_atts') + self.atts.set("horizontal","0") + self.xml.append(self.atts) def get_design_panel(self,parent): return self.build_splitter_wnd(parent, 1) @@ -281,7 +270,7 @@ container_handler.on_drop(self,evt) def build_splitter_wnd(self, parent, mode): - self.split = self.atts.getAttribute("horizontal") + self.split = self.atts.get("horizontal") self.pane = splitter_panel(parent, self) @@ -295,7 +284,7 @@ self.bestSizex = -1 self.bestSizey = -1 - self.traverse(self.mytree_node, self.doSplit, mode, False) + self.tree.traverse(self.mytree_node, self.doSplit, mode, False) self.pane.sizer.Add(self.splitter, 1, wx.EXPAND) @@ -308,11 +297,10 @@ parent.SetSize(self.pane.GetSize()) return self.pane - def doSplit(self, obj, mode): - if mode == 1: - tmp = obj.get_design_panel(self.splitter) - else: - tmp = obj.get_use_panel(self.splitter) + def doSplit(self, treenode, mode): + node = self.tree.GetPyData(treenode) + if mode == 1: tmp = node.get_design_panel(self.splitter) + else: tmp = node.get_use_panel(self.splitter) if self.split == '1': sash = tmp.GetBestSize()[1]+1 @@ -337,7 +325,7 @@ sizer = wx.BoxSizer(wx.VERTICAL) self.hozCheck = wx.CheckBox(self, -1, "Horizontal Split") - hoz = self.handler.atts.getAttribute("horizontal") + hoz = self.handler.atts.get("horizontal") if hoz == '1': self.hozCheck.SetValue(True) @@ -359,6 +347,6 @@ def on_check_box(self,evt): state = self.hozCheck.GetValue() if state: - self.handler.atts.setAttribute("horizontal", "1") + self.handler.atts.set("horizontal", "1") else: - self.handler.atts.setAttribute("horizontal", "0") + self.handler.atts.set("horizontal", "0")