comparison orpg/gametree/nodehandlers/containers.py @ 130:d54e1328dbb1 alpha

Traipse Alpha 'OpenRPG' {091003-02} 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, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! Dead Node Children, not that's a O O -v-v- Happy Halloween!
author sirebral
date Tue, 03 Nov 2009 21:06:03 -0600
parents 217fb049bd00
children 90d19eb43830
comparison
equal deleted inserted replaced
129:43ad912b7c17 130:d54e1328dbb1
26 # Description: The file contains code for the container nodehandlers 26 # Description: The file contains code for the container nodehandlers
27 # 27 #
28 28
29 29
30 from core import * 30 from core import *
31 from wx.lib.splitter import MultiSplitterWindow 31 import wx.lib.splitter
32 32
33 33
34 ########################## 34 ##########################
35 ## base contiainer 35 ## base contiainer
36 ########################## 36 ##########################
37 37
38 class container_handler(node_handler): 38 class container_handler(node_handler):
39 """ should not be used! only a base class! 39 """ should not be used! only a base class!
40 <nodehandler name='?' module='core' class='container_handler' /> 40 <nodehandler name='?' module='core' class='container_handler' />
41 """ 41 """
42 def __init__(self, xml, tree_node): 42 def __init__(self,xml,tree_node):
43 node_handler.__init__(self, xml, tree_node) 43 node_handler.__init__(self,xml,tree_node)
44 self.load_children() 44 self.load_children()
45 45
46 def load_children(self): 46 def load_children(self):
47 for child_xml in self.xml: 47 for child_xml in self.xml:
48 self.tree.load_xml(child_xml,self.mytree_node) 48 self.tree.load_xml(child_xml,self.mytree_node)
51 node = self.tree.GetPyData(treenode) 51 node = self.tree.GetPyData(treenode)
52 if hasattr(node,"map_aware") and node.map_aware(): 52 if hasattr(node,"map_aware") and node.map_aware():
53 node.on_send_to_map(evt) 53 node.on_send_to_map(evt)
54 54
55 def on_send_to_map(self, evt): 55 def on_send_to_map(self, evt):
56 self.tree.traverse(self.mytree_node, self.check_map_aware, evt) 56 self.tree.traverse(self.mytree_node, self.check_map_aware, evt)
57 57
58 def checkChildToMap(self, treenode, evt): 58 def checkChildToMap(self, treenode, evt):
59 node = self.tree.GetPyData(treenode) 59 node = self.tree.GetPyData(treenode)
60 if hasattr(node,"map_aware") and node.map_aware(): 60 if hasattr(node,"map_aware") and node.map_aware():
61 self.mapcheck = True 61 self.mapcheck = True
79 node_handler.on_drop(self,evt) 79 node_handler.on_drop(self,evt)
80 80
81 def gen_html(self, treenode, evt): 81 def gen_html(self, treenode, evt):
82 node = self.tree.GetPyData(treenode) 82 node = self.tree.GetPyData(treenode)
83 self.html_str += "<p>" + node.tohtml() 83 self.html_str += "<p>" + node.tohtml()
84 84
85 def tohtml(self): 85 def tohtml(self):
86 self.html_str = "<table border=\"1\" ><tr><td>" 86 self.html_str = "<table border=\"1\" ><tr><td>"
87 self.html_str += "<b>"+self.xml.get("name") + "</b>" 87 self.html_str += "<b>"+self.xml.get("name") + "</b>"
88 self.html_str += "</td></tr>\n" 88 self.html_str += "</td></tr>\n"
89 self.html_str += "<tr><td>" 89 self.html_str += "<tr><td>"
95 95
96 def get_size_constraint(self): 96 def get_size_constraint(self):
97 return 2 97 return 2
98 98
99 99
100
101
100 ########################## 102 ##########################
101 ## group node handler 103 ## group node handler
102 ########################## 104 ##########################
103 class group_handler(container_handler): 105 class group_handler(container_handler):
104 """ group nodehandler to be used as a placeholder for other nodehandlers. 106 """ group nodehandler to be used as a placeholder for other nodehandlers.
105 This handler will continue parsing child xml data. 107 This handler will continue parsing child xml data.
106 <nodehandler name='?' module='core' class='group_handler' /> 108 <nodehandler name='?' module='core' class='group_handler' />
107 """ 109 """
108 def __init__(self, xml, tree_node): 110 def __init__(self,xml,tree_node):
109 container_handler.__init__(self, xml, tree_node) 111 container_handler.__init__(self,xml,tree_node)
110 112
111 def load_children(self): 113 def load_children(self):
112 self.atts = None 114 self.atts = None
113 for child_xml in self.xml: 115 for child_xml in self.xml:
114 if child_xml.tag == "group_atts": 116 if child_xml.tag == "group_atts":
115 self.atts = child_xml 117 self.atts = child_xml
116 else: 118 else:
117 self.tree.load_xml(child_xml,self.mytree_node) 119 self.tree.load_xml(child_xml,self.mytree_node)
118 if not self.atts: 120 if not self.atts:
119 self.atts = Element('group_atts') 121 self.atts = ET.Element('group_atts')
120 self.atts.set("cols","1") 122 self.atts.set("cols","1")
121 self.atts.set("border","1") 123 self.atts.set("border","1")
122 self.xml.append(self.atts) 124 self.xml.append(self.atts)
123 125
124 def get_design_panel(self,parent): 126 def get_design_panel(self,parent):
140 cols = self.atts.get("cols") 142 cols = self.atts.get("cols")
141 border = self.atts.get("border") 143 border = self.atts.get("border")
142 self.html_str = "<table border=\""+border+"\" ><tr><td colspan=\""+cols+"\">" 144 self.html_str = "<table border=\""+border+"\" ><tr><td colspan=\""+cols+"\">"
143 self.html_str += "<font size=4>"+self.xml.get("name") + "</font>" 145 self.html_str += "<font size=4>"+self.xml.get("name") + "</font>"
144 self.html_str += "</td></tr>\n<tr>" 146 self.html_str += "</td></tr>\n<tr>"
147
145 self.cols = int(cols) 148 self.cols = int(cols)
146 self.i = 0 149 self.i = 0
147 self.tdatas = {} 150 self.tdatas = {}
151
148 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False) 152 self.tree.traverse(self.mytree_node, self.gen_html, recurse=False)
153
149 for td in self.tdatas: 154 for td in self.tdatas:
150 self.html_str += "<td valign=\"top\" >" + self.tdatas[td] + "</td>\n"; 155 self.html_str += "<td valign=\"top\" >" + self.tdatas[td] + "</td>\n";
151 self.html_str += "</tr></table>" 156 self.html_str += "</tr></table>"
152 return self.html_str 157 return self.html_str
153 158
211 ## tabber node handler 216 ## tabber node handler
212 ########################## 217 ##########################
213 class tabber_handler(container_handler): 218 class tabber_handler(container_handler):
214 """ <nodehandler name='?' module='containers' class='tabber_handler' />""" 219 """ <nodehandler name='?' module='containers' class='tabber_handler' />"""
215 220
216 def __init__(self, xml, tree_node): 221 def __init__(self,xml,tree_node):
217 container_handler.__init__(self, xml, tree_node) 222 container_handler.__init__(self,xml,tree_node)
218 223
219 def get_design_panel(self,parent): 224 def get_design_panel(self,parent):
220 return tabbed_panel(parent,self,1) 225 return tabbed_panel(parent,self,1)
221 226
222 def get_use_panel(self,parent): 227 def get_use_panel(self,parent):
232 237
233 parent.SetSize(self.GetBestSize()) 238 parent.SetSize(self.GetBestSize())
234 239
235 def pick_panel(self, treenode, mode): 240 def pick_panel(self, treenode, mode):
236 node = self.handler.tree.GetPyData(treenode) 241 node = self.handler.tree.GetPyData(treenode)
237 if mode == 1: panel = node.get_design_panel(self) 242 if mode == 1:
238 else: panel = node.get_use_panel(self) 243 panel = node.get_design_panel(self)
244 else:
245 panel = node.get_use_panel(self)
246
239 name = node.xml.get("name") 247 name = node.xml.get("name")
240 if panel: self.AddPage(panel, name, False) 248
249 if panel:
250 self.AddPage(panel, name, False)
241 251
242 ################################# 252 #################################
243 ## Splitter container 253 ## Splitter container
244 ################################# 254 #################################
245 255
250 container_handler.__init__(self,xml,tree_node) 260 container_handler.__init__(self,xml,tree_node)
251 261
252 def load_children(self): 262 def load_children(self):
253 self.atts = None 263 self.atts = None
254 for child_xml in self.xml: 264 for child_xml in self.xml:
255 if child_xml.tag == "splitter_atts": self.atts = child_xml 265 if child_xml.tag == "splitter_atts":
256 else: self.tree.load_xml(child_xml,self.mytree_node) 266 self.atts = child_xml
267 else:
268 self.tree.load_xml(child_xml,self.mytree_node)
257 if not self.atts: 269 if not self.atts:
258 self.atts = Element('splitter_atts') 270 self.atts = ET.Element('splitter_atts')
259 self.atts.set("horizontal","0") 271 self.atts.set("horizontal","0")
260 self.xml.append(self.atts) 272 self.xml.append(self.atts)
261 273
262 def get_design_panel(self,parent): 274 def get_design_panel(self,parent):
263 return self.build_splitter_wnd(parent, 1) 275 return self.build_splitter_wnd(parent, 1)
272 def build_splitter_wnd(self, parent, mode): 284 def build_splitter_wnd(self, parent, mode):
273 self.split = self.atts.get("horizontal") 285 self.split = self.atts.get("horizontal")
274 286
275 self.pane = splitter_panel(parent, self) 287 self.pane = splitter_panel(parent, self)
276 288
277 self.splitter = MultiSplitterWindow(self.pane, -1, style=wx.SP_LIVE_UPDATE|wx.SP_3DSASH|wx.SP_NO_XP_THEME) 289 self.splitter = wx.lib.splitter.MultiSplitterWindow(self.pane, -1, style=wx.SP_LIVE_UPDATE|wx.SP_3DSASH|wx.SP_NO_XP_THEME)
278 290
279 if self.split == '1': 291 if self.split == '1':
280 self.splitter.SetOrientation(wx.VERTICAL) 292 self.splitter.SetOrientation(wx.VERTICAL)
281 else: 293 else:
282 self.splitter.SetOrientation(wx.HORIZONTAL) 294 self.splitter.SetOrientation(wx.HORIZONTAL)
283 295
284 self.bestSizex = -1 296 self.bestSizex = -1
285 self.bestSizey = -1 297 self.bestSizey = -1
286 298
287 self.tree.traverse(self.mytree_node, self.doSplit, mode, False) 299 self.tree.traverse(self.mytree_node, self.doSplit, mode, False)
288 300
289 self.pane.sizer.Add(self.splitter, 1, wx.EXPAND) 301 self.pane.sizer.Add(self.splitter, 1, wx.EXPAND)
290 302
291 303
292 if mode != 1: 304 if mode != 1:
297 parent.SetSize(self.pane.GetSize()) 309 parent.SetSize(self.pane.GetSize())
298 return self.pane 310 return self.pane
299 311
300 def doSplit(self, treenode, mode): 312 def doSplit(self, treenode, mode):
301 node = self.tree.GetPyData(treenode) 313 node = self.tree.GetPyData(treenode)
302 if mode == 1: tmp = node.get_design_panel(self.splitter) 314 if mode == 1:
303 else: tmp = node.get_use_panel(self.splitter) 315 tmp = node.get_design_panel(self.splitter)
316 else:
317 tmp = node.get_use_panel(self.splitter)
304 318
305 if self.split == '1': 319 if self.split == '1':
306 sash = tmp.GetBestSize()[1]+1 320 sash = tmp.GetBestSize()[1]+1
307 self.bestSizey += sash+11 321 self.bestSizey += sash+11
308 if self.bestSizex < tmp.GetBestSize()[0]: 322 if self.bestSizex < tmp.GetBestSize()[0]: