comparison orpg/gametree/nodehandlers/core.py @ 180:12ba14d30baa alpha

Traipse Alpha 'OpenRPG' {100115-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 (Keeping up with Beta) New Features: Added Bookmarks 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 New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Fri, 15 Jan 2010 00:09:39 -0600
parents ff19dd30064b
children b633f4c64aae 81d0bfd5e800
comparison
equal deleted inserted replaced
179:5609ac142298 180:12ba14d30baa
52 """ Base nodehandler with virtual functions and standard implmentations """ 52 """ Base nodehandler with virtual functions and standard implmentations """
53 def __init__(self,xml,tree_node): 53 def __init__(self,xml,tree_node):
54 self.xml = xml 54 self.xml = xml
55 self.mytree_node = tree_node 55 self.mytree_node = tree_node
56 self.tree = component.get('tree') 56 self.tree = component.get('tree')
57 self.core_tree = component.get('tree_fs') 57 #self.tree = component.get('tree_fs')
58 self.frame = component.get('frame') 58 self.frame = component.get('frame')
59 self.chat = component.get('chat') 59 self.chat = component.get('chat')
60 self.drag = True 60 self.drag = True
61 self.myeditor = None # designing 61 self.myeditor = None # designing
62 self.myviewer = None # prett print 62 self.myviewer = None # prett print
81 ## added version control code here or implement a new on_version in your derived class. 81 ## added version control code here or implement a new on_version in your derived class.
82 ## always call the base class on_version ! 82 ## always call the base class on_version !
83 pass 83 pass
84 84
85 def on_rclick(self,evt): 85 def on_rclick(self,evt):
86 self.core_tree.do_std_menu(evt,self) 86 self.tree.do_std_menu(evt,self)
87 87
88 def on_ldclick(self,evt): 88 def on_ldclick(self,evt):
89 return 0 89 return 0
90 90
91 def usefulness(self,text): 91 def usefulness(self,text):
215 215
216 def on_send_to_chat(self,evt): 216 def on_send_to_chat(self,evt):
217 self.chat.ParsePost(self.tohtml(),True,True) 217 self.chat.ParsePost(self.tohtml(),True,True)
218 218
219 def on_drop(self, evt): 219 def on_drop(self, evt):
220 drag_obj = self.core_tree.drag_obj 220 drag_obj = self.tree.drag_obj
221 if drag_obj == self or self.core_tree.is_parent_node(self.mytree_node, drag_obj.mytree_node): 221 if drag_obj == self or self.tree.is_parent_node(self.mytree_node, drag_obj.mytree_node):
222 return 222 return
223 drop_xml = self.core_tree.drag_obj.delete() 223 drop_xml = self.tree.drag_obj.delete()
224 parent_node = self.core_tree.GetItemParent(self.mytree_node) 224 parent_node = self.tree.GetItemParent(self.mytree_node)
225 prev_sib = self.core_tree.GetPrevSibling(self.mytree_node) 225 prev_sib = self.tree.GetPrevSibling(self.mytree_node)
226 if parent_node == self.core_tree.root: parent_xml = self.core_tree.GetPyData(parent_node) 226 if parent_node == self.tree.root: parent_xml = self.tree.GetPyData(parent_node)
227 else: parent_xml = self.core_tree.GetPyData(parent_node).xml 227 else: parent_xml = self.tree.GetPyData(parent_node).xml
228 for i in range(len(parent_xml)): 228 for i in range(len(parent_xml)):
229 if parent_xml[i] is self.xml: 229 if parent_xml[i] is self.xml:
230 parent_xml.insert(i, drop_xml) 230 parent_xml.insert(i, drop_xml)
231 break 231 break
232 if not prev_sib.IsOk(): 232 if not prev_sib.IsOk():
233 prev_sib = parent_node 233 prev_sib = parent_node
234 self.core_tree.load_xml(drop_xml, parent_node, prev_sib) 234 self.tree.load_xml(drop_xml, parent_node, prev_sib)
235 235
236 def get_tree(self): 236 def get_tree(self):
237 family = [] 237 family = []
238 test = treenode 238 test = treenode
239 while test != self.core_tree.root: 239 while test != self.tree.root:
240 test = self.core_tree.GetItemParent(test) 240 test = self.tree.GetItemParent(test)
241 parent = self.core_tree.GetItemText(test) 241 parent = self.tree.GetItemText(test)
242 family.append(parent) 242 family.append(parent)
243 return family 243 return family
244 244
245 def toxml(self,pretty=0): 245 def toxml(self,pretty=0):
246 return tostring(self.xml) #toxml(self.master_dom,pretty) 246 return tostring(self.xml) #toxml(self.master_dom,pretty)
248 def tohtml(self): 248 def tohtml(self):
249 return self.xml.get("name") 249 return self.xml.get("name")
250 250
251 def delete(self): 251 def delete(self):
252 """ removes the tree_node and xml_node, and returns the removed xml_node """ 252 """ removes the tree_node and xml_node, and returns the removed xml_node """
253 parent_node = self.core_tree.GetItemParent(self.mytree_node) 253 parent_node = self.tree.GetItemParent(self.mytree_node)
254 if parent_node == self.core_tree.root: parent_xml = self.core_tree.GetPyData(parent_node) 254 if parent_node == self.tree.root: parent_xml = self.tree.GetPyData(parent_node)
255 else: parent_xml = self.core_tree.GetPyData(parent_node).xml 255 else: parent_xml = self.tree.GetPyData(parent_node).xml
256 parent_xml.remove(self.xml) 256 parent_xml.remove(self.xml)
257 self.core_tree.Delete(self.mytree_node) 257 self.tree.Delete(self.mytree_node)
258 return self.xml 258 return self.xml
259 259
260 def rename(self,name): 260 def rename(self,name):
261 if len(name): 261 if len(name):
262 self.core_tree.SetItemText(self.mytree_node,name) 262 self.tree.SetItemText(self.mytree_node,name)
263 self.xml.set('name', name) 263 self.xml.set('name', name)
264 264
265 def change_icon(self,icon): 265 def change_icon(self,icon):
266 self.xml.set("icon",icon) 266 self.xml.set("icon",icon)
267 self.core_tree.SetItemImage(self.mytree_node, self.core_tree.icons[icon]) 267 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon])
268 self.core_tree.SetItemImage(self.mytree_node, self.core_tree.icons[icon], wx.TreeItemIcon_Selected) 268 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon], wx.TreeItemIcon_Selected)
269 self.core_tree.Refresh() 269 self.tree.Refresh()
270 270
271 def on_save(self,evt): 271 def on_save(self,evt):
272 f = wx.FileDialog(self.core_tree,"Select a file", orpg.dirpath.dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE) 272 f = wx.FileDialog(self.tree,"Select a file", orpg.dirpath.dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE)
273 if f.ShowModal() == wx.ID_OK: ElementTree(self.xml).write(f.GetPath()) 273 if f.ShowModal() == wx.ID_OK: ElementTree(self.xml).write(f.GetPath())
274 f.Destroy() 274 f.Destroy()
275 275
276 def get_design_panel(self,parent): 276 def get_design_panel(self,parent):
277 return None 277 return None
363 pass 363 pass
364 364
365 def on_ldclick(self,evt): 365 def on_ldclick(self,evt):
366 title = self.xml.get('name') 366 title = self.xml.get('name')
367 new_xml = XML(tostring(self.xml[0])) 367 new_xml = XML(tostring(self.xml[0]))
368 self.core_tree.root_xml.insert(0, new_xml) 368 self.tree.root_xml.insert(0, new_xml)
369 tree_node = self.core_tree.load_xml(new_xml,self.core_tree.root,self.core_tree.root) 369 tree_node = self.tree.load_xml(new_xml,self.tree.root,self.tree.root)
370 return 1 370 return 1
371 371
372 ########################## 372 ##########################
373 ## file loader 373 ## file loader
374 ########################## 374 ##########################
384 self.file_node = self.xml[0] 384 self.file_node = self.xml[0]
385 self.frame = component.get('frame') 385 self.frame = component.get('frame')
386 386
387 def on_ldclick(self,evt): 387 def on_ldclick(self,evt):
388 file_name = self.file_node.get("name") 388 file_name = self.file_node.get("name")
389 self.core_tree.insert_xml(open(orpg.dirpath.dir_struct["nodes"] + file_name,"r").read()) 389 self.tree.insert_xml(open(orpg.dirpath.dir_struct["nodes"] + file_name,"r").read())
390 return 1 390 return 1
391 391
392 def on_design(self,evt): 392 def on_design(self,evt):
393 tlist = ['Title','File Name'] 393 tlist = ['Title','File Name']
394 vlist = [self.xml.get("name"), 394 vlist = [self.xml.get("name"),
395 self.file_node.get("name")] 395 self.file_node.get("name")]
396 dlg = orpgMultiTextEntry(self.core_tree.GetParent(),tlist,vlist,"File Loader Edit") 396 dlg = orpgMultiTextEntry(self.tree.GetParent(),tlist,vlist,"File Loader Edit")
397 if dlg.ShowModal() == wx.ID_OK: 397 if dlg.ShowModal() == wx.ID_OK:
398 vlist = dlg.get_values() 398 vlist = dlg.get_values()
399 self.file_node.set('name', vlist[1]) 399 self.file_node.set('name', vlist[1])
400 self.xml.set('name', vlist[0]) 400 self.xml.set('name', vlist[0])
401 self.core_tree.SetItemText(self.mytree_node,vlist[0]) 401 self.tree.SetItemText(self.mytree_node,vlist[0])
402 dlg.Destroy() 402 dlg.Destroy()
403 403
404 ########################## 404 ##########################
405 ## URL loader 405 ## URL loader
406 ########################## 406 ##########################
417 self.frame = component.get('frame') 417 self.frame = component.get('frame')
418 418
419 def on_ldclick(self,evt): 419 def on_ldclick(self,evt):
420 file_name = self.file_node.get("url") 420 file_name = self.file_node.get("url")
421 file = urllib.urlopen(file_name) 421 file = urllib.urlopen(file_name)
422 self.core_tree.insert_xml(file.read()) 422 self.tree.insert_xml(file.read())
423 return 1 423 return 1
424 424
425 def on_design(self,evt): 425 def on_design(self,evt):
426 tlist = ['Title','URL'] 426 tlist = ['Title','URL']
427 vlist = [self.xml.get("name"), 427 vlist = [self.xml.get("name"),
428 self.file_node.get("url")] 428 self.file_node.get("url")]
429 dlg = orpgMultiTextEntry(self.core_tree.GetParent(),tlist,vlist,"File Loader Edit") 429 dlg = orpgMultiTextEntry(self.tree.GetParent(),tlist,vlist,"File Loader Edit")
430 if dlg.ShowModal() == wx.ID_OK: 430 if dlg.ShowModal() == wx.ID_OK:
431 vlist = dlg.get_values() 431 vlist = dlg.get_values()
432 self.file_node.set('url', vlist[1]) 432 self.file_node.set('url', vlist[1])
433 self.xml.set('name', vlist[0]) 433 self.xml.set('name', vlist[0])
434 self.core_tree.SetItemText(self.mytree_node,vlist[0]) 434 self.tree.SetItemText(self.mytree_node,vlist[0])
435 dlg.Destroy() 435 dlg.Destroy()
436 436
437 437
438 ########################## 438 ##########################
439 ## minature map loader 439 ## minature map loader