comparison orpg/gametree/nodehandlers/containers.py @ 138:1ed2feab0db9 alpha

Traipse Alpha 'OpenRPG' {091021-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, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! New Gametree Recursion method, mapping, and context sensitivity. !!Alpha Still- Watch out for infinite loops!! 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. Appended tr_ to ID's to prevent non updated clients from ruining the fix.
author sirebral
date Sat, 21 Nov 2009 03:19:34 -0600
parents 90d19eb43830
children 06f10429eedc
comparison
equal deleted inserted replaced
137:54446a995007 138:1ed2feab0db9
159 159
160 class group_edit_panel(wx.Panel): 160 class group_edit_panel(wx.Panel):
161 def __init__(self, parent, handler): 161 def __init__(self, parent, handler):
162 wx.Panel.__init__(self, parent, -1) 162 wx.Panel.__init__(self, parent, -1)
163 self.handler = handler 163 self.handler = handler
164 self.outline = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Group"), wx.VERTICAL)
165
164 sizer = wx.BoxSizer(wx.VERTICAL) 166 sizer = wx.BoxSizer(wx.VERTICAL)
165 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')) 167 self.text = {P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')) }
166 }
167 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) 168 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
168 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) 169 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
169 sizer.Add(wx.Size(10,10)) 170 sizer.Add(wx.Size(10,10))
170 171
171 radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"]) 172 radio_c = wx.RadioBox(self, GROUP_COLS, "Columns", choices=["1","2","3","4"])
180 181
181 sizer.Add(radio_c, 0, wx.EXPAND) 182 sizer.Add(radio_c, 0, wx.EXPAND)
182 sizer.Add(wx.Size(10,10)) 183 sizer.Add(wx.Size(10,10))
183 sizer.Add(radio_b, 0, wx.EXPAND) 184 sizer.Add(radio_b, 0, wx.EXPAND)
184 185
185 self.sizer = sizer 186 self.outline.Add(sizer, 0)
186 self.outline = wx.StaticBox(self,-1,"Group") 187 self.sizer = self.outline
187 self.SetSizer(self.sizer) 188 self.SetSizer(self.sizer)
188 self.SetAutoLayout(True) 189 self.SetAutoLayout(True)
189 self.Fit() 190 self.Fit()
190 parent.SetSize(self.GetBestSize()) 191 parent.SetSize(self.GetBestSize())
191 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE) 192 self.Bind(wx.EVT_TEXT, self.on_text, id=P_TITLE)
218 219
219 def __init__(self, xml, tree_node): 220 def __init__(self, xml, tree_node):
220 container_handler.__init__(self, xml, tree_node) 221 container_handler.__init__(self, xml, tree_node)
221 222
222 def get_design_panel(self,parent): 223 def get_design_panel(self,parent):
223 return tabbed_panel(parent,self,1) 224 return tabbed_edit_panel(parent, self)
224 225
225 def get_use_panel(self,parent): 226 def get_use_panel(self,parent):
226 return tabbed_panel(parent,self,2) 227 return tabbed_panel(parent, self, 1)
227 228
228 229
229 class tabbed_panel(orpgTabberWnd): 230 class tabbed_panel(orpgTabberWnd):
230 def __init__(self, parent, handler, mode): 231 def __init__(self, parent, handler, mode):
231 orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON) 232 orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON)
232 self.handler = handler 233 self.handler = handler
233 self.parent = parent 234 self.parent = parent
234 handler.tree.traverse(handler.mytree_node, self.pick_panel, mode, False) 235 handler.tree.traverse(handler.mytree_node, self.pick_panel, mode, False)
235
236 parent.SetSize(self.GetBestSize()) 236 parent.SetSize(self.GetBestSize())
237 237
238 def pick_panel(self, treenode, mode): 238 def pick_panel(self, treenode, mode):
239 node = self.handler.tree.GetPyData(treenode) 239 node = self.handler.tree.GetPyData(treenode)
240 if mode == 1: panel = node.get_design_panel(self) 240 if mode == 1: panel = node.get_design_panel(self)
241 else: panel = node.get_use_panel(self) 241 else: panel = node.get_use_panel(self)
242 name = node.xml.get("name") 242 name = node.xml.get("name")
243 if panel: self.AddPage(panel, name, False) 243 if panel: self.AddPage(panel, name, False)
244 244
245 class tabbed_edit_panel(orpgTabberWnd):
246 def __init__(self, parent, handler):
247 orpgTabberWnd.__init__(self, parent, style=FNB.FNB_NO_X_BUTTON)
248 self.handler = handler
249 self.parent = parent
250 main_sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Tabber"), wx.VERTICAL)
251 self.title = wx.TextCtrl(self, 1, handler.xml.get('name'))
252 main_sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
253 main_sizer.Add(self.title, 0, wx.EXPAND)
254 self.SetSizer(main_sizer)
255 self.SetAutoLayout(True)
256 self.Fit()
257 self.Bind(wx.EVT_TEXT, self.on_text, id=1)
258
259 def on_text(self,evt):
260 txt = self.title.GetValue()
261 if txt != "":
262 self.handler.xml.set('name',txt)
263 self.handler.rename(txt)
264
265
245 ################################# 266 #################################
246 ## Splitter container 267 ## Splitter container
247 ################################# 268 #################################
248 269
249 class splitter_handler(container_handler): 270 class splitter_handler(container_handler):
256 self.atts = None 277 self.atts = None
257 for child_xml in self.xml: 278 for child_xml in self.xml:
258 if child_xml.tag == "splitter_atts": self.xml.remove(child_xml) #Same here! 279 if child_xml.tag == "splitter_atts": self.xml.remove(child_xml) #Same here!
259 elif child_xml: self.tree.load_xml(child_xml,self.mytree_node) 280 elif child_xml: self.tree.load_xml(child_xml,self.mytree_node)
260 if not self.xml.get('horizontal'): self.xml.set('horizontal', '0') 281 if not self.xml.get('horizontal'): self.xml.set('horizontal', '0')
261 """if not self.atts:
262 self.atts = Element('splitter_atts')
263 self.atts.set("horizontal","0")
264 self.xml.append(self.atts)"""
265 282
266 def get_design_panel(self,parent): 283 def get_design_panel(self,parent):
267 return self.build_splitter_wnd(parent, 1) 284 return self.build_splitter_wnd(parent, 1)
268 285
269 def get_use_panel(self,parent): 286 def get_use_panel(self,parent):
273 drag_obj = self.tree.drag_obj 290 drag_obj = self.tree.drag_obj
274 container_handler.on_drop(self,evt) 291 container_handler.on_drop(self,evt)
275 292
276 def build_splitter_wnd(self, parent, mode): 293 def build_splitter_wnd(self, parent, mode):
277 self.split = self.xml.get("horizontal") 294 self.split = self.xml.get("horizontal")
278
279 self.pane = splitter_panel(parent, self) 295 self.pane = splitter_panel(parent, self)
280 296 self.splitter = MultiSplitterWindow(self.pane, -1,
281 self.splitter = MultiSplitterWindow(self.pane, -1, style=wx.SP_LIVE_UPDATE|wx.SP_3DSASH|wx.SP_NO_XP_THEME) 297 style=wx.SP_LIVE_UPDATE|wx.SP_3DSASH|wx.SP_NO_XP_THEME)
282 298 if self.split == '1': self.splitter.SetOrientation(wx.VERTICAL)
283 if self.split == '1': 299 else: self.splitter.SetOrientation(wx.HORIZONTAL)
284 self.splitter.SetOrientation(wx.VERTICAL)
285 else:
286 self.splitter.SetOrientation(wx.HORIZONTAL)
287
288 self.bestSizex = -1 300 self.bestSizex = -1
289 self.bestSizey = -1 301 self.bestSizey = -1
290
291 self.tree.traverse(self.mytree_node, self.doSplit, mode, False) 302 self.tree.traverse(self.mytree_node, self.doSplit, mode, False)
292
293 self.pane.sizer.Add(self.splitter, 1, wx.EXPAND) 303 self.pane.sizer.Add(self.splitter, 1, wx.EXPAND)
294 304 if mode != 1: self.pane.hozCheck.Hide()
295
296 if mode != 1:
297 self.pane.hozCheck.Hide()
298
299 self.pane.SetSize((self.bestSizex, self.bestSizey)) 305 self.pane.SetSize((self.bestSizex, self.bestSizey))
300 self.pane.Layout() 306 self.pane.Layout()
301 parent.SetSize(self.pane.GetSize()) 307 parent.SetSize(self.pane.GetSize())
302 return self.pane 308 return self.pane
303 309
304 def doSplit(self, treenode, mode): 310 def doSplit(self, treenode, mode):
305 node = self.tree.GetPyData(treenode) 311 node = self.tree.GetPyData(treenode)
306 if mode == 1: tmp = node.get_design_panel(self.splitter) 312 if mode == 1: tmp = node.get_design_panel(self.splitter)
307 else: tmp = node.get_use_panel(self.splitter) 313 else: tmp = node.get_use_panel(self.splitter)
308
309 if self.split == '1': 314 if self.split == '1':
310 sash = tmp.GetBestSize()[1]+1 315 sash = tmp.GetBestSize()[1]+1
311 self.bestSizey += sash+11 316 self.bestSizey += sash+11
312 if self.bestSizex < tmp.GetBestSize()[0]: 317 if self.bestSizex < tmp.GetBestSize()[0]:
313 self.bestSizex = tmp.GetBestSize()[0]+10 318 self.bestSizex = tmp.GetBestSize()[0]+10
314 else: 319 else:
315 sash = tmp.GetBestSize()[0]+1 320 sash = tmp.GetBestSize()[0]+1
316 self.bestSizex += sash 321 self.bestSizex += sash
317 if self.bestSizey < tmp.GetBestSize()[1]: 322 if self.bestSizey < tmp.GetBestSize()[1]:
318 self.bestSizey = tmp.GetBestSize()[1]+31 323 self.bestSizey = tmp.GetBestSize()[1]+31
319
320 self.splitter.AppendWindow(tmp, sash) 324 self.splitter.AppendWindow(tmp, sash)
321
322 def get_size_constraint(self): 325 def get_size_constraint(self):
323 return 1 326 return 1
324 327
325 class splitter_panel(wx.Panel): 328 class splitter_panel(wx.Panel):
326 def __init__(self, parent, handler): 329 def __init__(self, parent, handler):
327 wx.Panel.__init__(self, parent, -1) 330 wx.Panel.__init__(self, parent, -1)
328 self.handler = handler 331 self.handler = handler
329 sizer = wx.BoxSizer(wx.VERTICAL) 332 sizer = wx.BoxSizer(wx.VERTICAL)
333 self.title = wx.TextCtrl(self, 1, handler.xml.get('name'))
330 334
331 self.hozCheck = wx.CheckBox(self, -1, "Horizontal Split") 335 self.hozCheck = wx.CheckBox(self, -1, "Horizontal Split")
332 hoz = self.handler.xml.get("horizontal") 336 hoz = self.handler.xml.get("horizontal")
333 337
334 if hoz == '1': 338 if hoz == '1': self.hozCheck.SetValue(True)
335 self.hozCheck.SetValue(True) 339 else: self.hozCheck.SetValue(False)
336 #self.splitsize = wx.BoxSizer(wx.HORIZONTAL) 340
337 else: 341 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
338 self.hozCheck.SetValue(False) 342 sizer.Add(self.title, 0)
339 #self.splitsize = wx.BoxSizer(wx.VERTICAL)
340
341 sizer.Add(self.hozCheck, 0, wx.EXPAND) 343 sizer.Add(self.hozCheck, 0, wx.EXPAND)
342 sizer.Add(wx.Size(10,0)) 344 sizer.Add(wx.Size(10,0))
343 #sizer.Add(self.splitsize, 1, wx.EXPAND) 345 #sizer.Add(self.splitsize, 1, wx.EXPAND)
344 346
345 self.sizer = sizer 347 self.sizer = sizer
346 self.SetSizer(self.sizer) 348 self.SetSizer(self.sizer)
347 self.SetAutoLayout(True) 349 self.SetAutoLayout(True)
348 350 self.Bind(wx.EVT_TEXT, self.on_text, id=1)
349 self.Bind(wx.EVT_CHECKBOX, self.on_check_box, id=self.hozCheck.GetId()) 351 self.Bind(wx.EVT_CHECKBOX, self.on_check_box, id=self.hozCheck.GetId())
350 352
351 def on_check_box(self,evt): 353 def on_check_box(self,evt):
352 state = self.hozCheck.GetValue() 354 state = self.hozCheck.GetValue()
353 if state: 355 if state: self.handler.xml.set("horizontal", "1")
354 self.handler.xml.set("horizontal", "1") 356 else: self.handler.xml.set("horizontal", "0")
355 else: 357
356 self.handler.xml.set("horizontal", "0") 358 def on_text(self,evt):
359 txt = self.title.GetValue()
360 if txt != "":
361 self.handler.xml.set('name',txt)
362 self.handler.rename(txt)
363