comparison orpg/gametree/nodehandlers/core.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 fe4dc5817d5e
comparison
equal deleted inserted replaced
117:0f18d16f3fe7 118:217fb049bd00
27 # 27 #
28 28
29 __version__ = "$Id: core.py,v 1.49 2007/12/07 20:39:48 digitalxero Exp $" 29 __version__ = "$Id: core.py,v 1.49 2007/12/07 20:39:48 digitalxero Exp $"
30 30
31 from nodehandler_version import NODEHANDLER_VERSION 31 from nodehandler_version import NODEHANDLER_VERSION
32
32 try: 33 try:
33 from orpg.orpg_windows import * 34 from orpg.orpg_windows import *
34 from orpg.dirpath import dir_struct 35 from orpg.dirpath import dir_struct
35 from orpg.orpgCore import component 36 from orpg.orpgCore import component
36 import webbrowser 37 import webbrowser
38 import os 39 import os
39 from wx import DisplaySize 40 from wx import DisplaySize
40 except: 41 except:
41 import wx 42 import wx
42 43
44 from xml.etree.ElementTree import ElementTree, Element, tostring, XML
43 45
44 #html defaults 46 #html defaults
45 TH_BG = "#E9E9E9" 47 TH_BG = "#E9E9E9"
46 ########################## 48 ##########################
47 ## base node handler 49 ## base node handler
48 ########################## 50 ##########################
49 class node_handler: 51 class node_handler:
50 """ Base nodehandler with virtual functions and standard implmentations """ 52 """ Base nodehandler with virtual functions and standard implmentations """
51 def __init__(self,xml_dom,tree_node): 53 def __init__(self,xml,tree_node):
52 self.master_dom = xml_dom 54 self.xml = xml
53 self.mytree_node = tree_node 55 self.mytree_node = tree_node
54 self.tree = component.get('tree') 56 self.tree = open_rpg.get_component('tree')
55 self.frame = component.get('frame') 57 self.frame = open_rpg.get_component('frame')
56 self.chat = component.get('chat') 58 self.chat = open_rpg.get_component('chat')
57 self.xml = component.get('xml') #Not used?
58 self.drag = True 59 self.drag = True
59 self.myeditor = None # designing 60 self.myeditor = None # designing
60 self.myviewer = None # pretty print 61 self.myviewer = None # prett print
61 self.mywindow = None # using 62 self.mywindow = None # using
62 # call version hook 63 # call version hook
63 self.on_version(self.master_dom.getAttribute("version")) 64 self.on_version(self.xml.get("version"))
64 # set to current version 65 # set to current version
65 self.master_dom.setAttribute("version",NODEHANDLER_VERSION) 66 self.xml.set("version",NODEHANDLER_VERSION)
66 # null events 67 # null events
68 self.frame_size = None
69 self.frame_pos = None
70 try:
71 frame = self.xml.get("frame")
72 if len(frame):
73 (sx,sy,px,py) = [int(value) for value in frame.split(',')]
74 self.frame_size = (sx, sy)
75 (maxx, maxy) = DisplaySize()
76 if px < maxx-80 and py < maxy-50:#if it's off screen ignore the saved pos
77 self.frame_pos = (px, py)
78 except:
79 pass
67 80
68 def on_version(self,old_version): 81 def on_version(self,old_version):
69 ## added version control code here or implement a new on_version in your derived class. 82 ## added version control code here or implement a new on_version in your derived class.
70 ## always call the base class on_version ! 83 ## always call the base class on_version !
71 pass 84 pass
74 self.tree.do_std_menu(evt,self) 87 self.tree.do_std_menu(evt,self)
75 88
76 def on_ldclick(self,evt): 89 def on_ldclick(self,evt):
77 return 0 90 return 0
78 91
79 def traverse(self, root, function, data=None, recurse=True):
80 child, cookie = self.tree.GetFirstChild(root)
81 while child.IsOk():
82 function(self.tree.GetPyData(child), data)
83 if recurse:
84 self.traverse(child, function, data)
85 child, cookie = self.tree.GetNextChild(root, cookie)
86
87
88 def usefulness(self,text): 92 def usefulness(self,text):
89 if text=="useful": 93 if text=="useful":
90 self.master_dom.setAttribute('status',"useful") 94 self.xml.set('status',"useful")
91 elif text=="useless": 95 elif text=="useless":
92 self.master_dom.setAttribute('status',"useless") 96 self.xml.set('status',"useless")
93 elif text=="indifferent": 97 elif text=="indifferent":
94 self.master_dom.setAttribute('status',"indifferent") 98 self.xml.set('status',"indifferent")
95 99
96 def on_design(self,evt): 100 def on_design(self,evt):
97 try: 101 try:
98 self.myeditor.Show() 102 self.myeditor.Show()
99 self.myeditor.Raise() 103 self.myeditor.Raise()
100 except: 104 except:
101 del self.myeditor 105 del self.myeditor
102 if self.create_designframe(): 106 if self.create_designframe():
103 self.myeditor.Show() 107 self.myeditor.Show()
104 self.myeditor.Raise() 108 self.myeditor.Raise()
105 else: return 109 else:
110 return
106 wx.CallAfter(self.myeditor.Layout) 111 wx.CallAfter(self.myeditor.Layout)
107 112
108 113
109 def create_designframe(self): 114 def create_designframe(self):
110 title = self.master_dom.getAttribute('name') + " Editor" 115 title = self.xml.get('name') + " Editor"
111 self.myeditor = wx.Frame(None, -1, title) 116 self.myeditor = wx.Frame(None, -1, title)
112 self.myeditor.Freeze() 117 self.myeditor.Freeze()
113 if wx.Platform == '__WXMSW__': 118 if wx.Platform == '__WXMSW__':
114 icon = wx.Icon(dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO) 119 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO)
115 self.myeditor.SetIcon(icon) 120 self.myeditor.SetIcon(icon)
116 del icon 121 del icon
117 122
118 self.myeditor.panel = self.get_design_panel(self.myeditor) 123 self.myeditor.panel = self.get_design_panel(self.myeditor)
119 if self.myeditor.panel == None: 124 if self.myeditor.panel == None:
142 self.mywindow.Show() 147 self.mywindow.Show()
143 self.mywindow.Raise() 148 self.mywindow.Raise()
144 except: 149 except:
145 del self.mywindow 150 del self.mywindow
146 if self.create_useframe(): 151 if self.create_useframe():
152 self.mywindow.SetSize(self.frame_size)
153 if self.frame_pos:
154 self.mywindow.SetPosition(self.frame_pos)
147 self.mywindow.Show() 155 self.mywindow.Show()
148 self.mywindow.Raise() 156 self.mywindow.Raise()
149 else: 157 else:
150 return 158 return
151 wx.CallAfter(self.mywindow.Layout) 159 wx.CallAfter(self.mywindow.Layout)
152 160
161
153 def create_useframe(self): 162 def create_useframe(self):
154 caption = self.master_dom.getAttribute('name') 163 caption = self.xml.get('name', '')
155 self.mywindow = wx.Frame(None, -1, caption) 164 self.mywindow = wx.Frame(None, -1, caption)
156 self.mywindow.Freeze() 165 self.mywindow.Freeze()
157 166
158 if wx.Platform == '__WXMSW__': 167 if wx.Platform == '__WXMSW__':
159 icon = wx.Icon(dir_struct["icon"] + 'note.ico', wx.BITMAP_TYPE_ICO) 168 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'note.ico', wx.BITMAP_TYPE_ICO)
160 self.mywindow.SetIcon(icon) 169 self.mywindow.SetIcon(icon)
161 del icon 170 del icon
162 self.mywindow.panel = self.get_use_panel(self.mywindow) 171 self.mywindow.panel = self.get_use_panel(self.mywindow)
163 if self.mywindow.panel == None: 172 if self.mywindow.panel == None:
164 self.mywindow.Destroy() 173 self.mywindow.Destroy()
167 sizer.Add(self.mywindow.panel, 2, wx.EXPAND) 176 sizer.Add(self.mywindow.panel, 2, wx.EXPAND)
168 177
169 self.mywindow.SetSizer(sizer) 178 self.mywindow.SetSizer(sizer)
170 self.mywindow.SetAutoLayout(True) 179 self.mywindow.SetAutoLayout(True)
171 180
172 (x, y) = self.mywindow.GetSize() 181 if self.frame_size is None:
173 if x < 400: 182 self.frame_size = self.mywindow.GetSize()
174 x = 400 183 if self.frame_size.x < 400:
175 if y < 400: 184 self.frame_size.x = 400
176 y = 400 185 if self.frame_size.y < 400:
177 186 self.frame_size.y = 400
178 self.mywindow.SetSize((x, y)) 187
179 self.mywindow.Layout() 188 self.mywindow.Layout()
180 self.mywindow.Thaw() 189 self.mywindow.Thaw()
181 190
191 self.mywindow.Bind(wx.EVT_CLOSE, self.close_useframe)
192
182 return True 193 return True
194
195 def close_useframe(self, evt):
196 self.frame_size = self.mywindow.GetSize()
197 self.frame_pos = self.mywindow.GetPosition()
198 frame_values = str(self.frame_size.x)+','+str(self.frame_size.y)+','+str(self.frame_pos.x)+','+str(self.frame_pos.y)
199 self.xml.set("frame", frame_values)
200 self.mywindow.Destroy()
183 201
184 202
185 def on_html_view(self,evt): 203 def on_html_view(self,evt):
186 try: 204 try:
187 self.myviewer.Raise() 205 self.myviewer.Raise()
188 except: 206 except:
189 caption = self.master_dom.getAttribute('name') 207 caption = self.xml.get('name')
190 self.myviewer = wx.Frame(None, -1, caption) 208 self.myviewer = wx.Frame(None, -1, caption)
191 if wx.Platform == '__WXMSW__': 209 if wx.Platform == '__WXMSW__':
192 icon = wx.Icon(dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO) 210 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO)
193 self.myviewer.SetIcon(icon) 211 self.myviewer.SetIcon(icon)
194 del icon 212 del icon
195 self.myviewer.panel = self.get_html_panel(self.myviewer) 213 self.myviewer.panel = self.get_html_panel(self.myviewer)
196 self.myviewer.Show() 214 self.myviewer.Show()
197 215
202 return 1; 220 return 1;
203 221
204 def on_del(self,evt): 222 def on_del(self,evt):
205 print "on del" 223 print "on del"
206 224
207 def on_new_data(self,xml_dom): 225 def on_new_data(self,xml):
208 pass 226 pass
209 227
210 def get_scaled_bitmap(self,x,y): 228 def get_scaled_bitmap(self,x,y):
211 return None 229 return None
212 230
220 drag_obj = self.tree.drag_obj 238 drag_obj = self.tree.drag_obj
221 if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node): 239 if drag_obj == self or self.tree.is_parent_node(self.mytree_node,drag_obj.mytree_node):
222 return 240 return
223 #if self.is_my_child(self.mytree_node,drag_obj.mytree_node): 241 #if self.is_my_child(self.mytree_node,drag_obj.mytree_node):
224 # return 242 # return
225 xml_dom = self.tree.drag_obj.delete() 243 drop_xml = self.tree.drag_obj.delete()
226 parent = self.master_dom._get_parentNode()
227 xml_dom = parent.insertBefore(xml_dom,self.master_dom)
228 parent_node = self.tree.GetItemParent(self.mytree_node) 244 parent_node = self.tree.GetItemParent(self.mytree_node)
229 prev_sib = self.tree.GetPrevSibling(self.mytree_node) 245 prev_sib = self.tree.GetPrevSibling(self.mytree_node)
246 if parent_node == self.tree.root:
247 parent_xml = self.tree.GetPyData(parent_node)
248 else:
249 parent_xml = self.tree.GetPyData(parent_node).xml
250 for i in range(len(parent_xml)):
251 if parent_xml[i] is self.xml:
252 parent_xml.insert(i, drop_xml)
253 break
230 if not prev_sib.IsOk(): 254 if not prev_sib.IsOk():
231 prev_sib = parent_node 255 prev_sib = parent_node
232 self.tree.load_xml(xml_dom, parent_node, prev_sib) 256 self.tree.load_xml(drop_xml, parent_node, prev_sib)
233 257
234 def toxml(self,pretty=0): 258 def toxml(self,pretty=0):
235 return component.get('xml').toxml(self.master_dom,pretty) 259 return tostring(self.xml) #toxml(self.master_dom,pretty)
236 260
237 def tohtml(self): 261 def tohtml(self):
238 return self.master_dom.getAttribute("name") 262 return self.xml.get("name")
239 263
240 def delete(self): 264 def delete(self):
241 """ removes the tree_node and xml_node, and returns the removed xml_node """ 265 """ removes the tree_node and xml_node, and returns the removed xml_node """
242 266 parent_node = self.tree.GetItemParent(self.mytree_node)
267 if parent_node == self.tree.root:
268 parent_xml = self.tree.GetPyData(parent_node)
269 else:
270 parent_xml = self.tree.GetPyData(parent_node).xml
271 parent_xml.remove(self.xml)
243 self.tree.Delete(self.mytree_node) 272 self.tree.Delete(self.mytree_node)
244 parent = self.master_dom._get_parentNode() 273 return self.xml
245 return parent.removeChild(self.master_dom)
246 274
247 def rename(self,name): 275 def rename(self,name):
248 if len(name): 276 if len(name):
249 self.tree.SetItemText(self.mytree_node,name) 277 self.tree.SetItemText(self.mytree_node,name)
250 self.master_dom.setAttribute('name', name) 278 self.xml.set('name', name)
251 279
252 def change_icon(self,icon): 280 def change_icon(self,icon):
253 self.master_dom.setAttribute("icon",icon) 281 self.xml.set("icon",icon)
254 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon]) 282 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon])
255 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon], wx.TreeItemIcon_Selected) 283 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon], wx.TreeItemIcon_Selected)
256 self.tree.Refresh() 284 self.tree.Refresh()
257 285
258 def on_save(self,evt): 286 def on_save(self,evt):
259 f = wx.FileDialog(self.tree,"Select a file", dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE) 287 f = wx.FileDialog(self.tree,"Select a file", orpg.dirpath.dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE)
260 if f.ShowModal() == wx.ID_OK: 288 if f.ShowModal() == wx.ID_OK:
261 type = f.GetFilterIndex() 289 ElementTree(self.xml).write(f.GetPath())
262 if f.GetPath()[:len(f.GetPath())-4] != '.xml': file = open(f.GetPath()+'.xml',"w")
263 else: file = open(f.GetPath(),"w")
264 file.write(self.toxml(1))
265 file.close()
266 f.Destroy() 290 f.Destroy()
267 291
268 def get_design_panel(self,parent): 292 def get_design_panel(self,parent):
269 return None 293 return None
270 294
273 297
274 def get_html_panel(self,parent): 298 def get_html_panel(self,parent):
275 html_str = "<html><body bgcolor=\"#FFFFFF\" >"+self.tohtml()+"</body></html>" 299 html_str = "<html><body bgcolor=\"#FFFFFF\" >"+self.tohtml()+"</body></html>"
276 wnd = wx.html.HtmlWindow(parent,-1) 300 wnd = wx.html.HtmlWindow(parent,-1)
277 html_str = self.chat.ParseDice(html_str) 301 html_str = self.chat.ParseDice(html_str)
278 wnd.SetPage(html_str) 302 wnd.SetPage(html_str)
279 return wnd 303 return wnd
280 304
281 def get_size_constraint(self): 305 def get_size_constraint(self):
282 return 0 306 return 0
283 307
284 def about(self): 308 def about(self):
285 html_str = "<b>"+ self.master_dom.getAttribute('class') 309 html_str = "<b>"+ self.xml.get('class')
286 html_str += " Applet</b><br />by Chris Davis<br />chris@rpgarchive.com" 310 html_str += " Applet</b><br />by Chris Davis<br />chris@rpgarchive.com"
287 return html_str 311 return html_str
312
313 def set_referenceable(self, value):
314 if value:
315 self.xml.set('referenceable', '1')
316 else:
317 self.xml.set('referenceable', '0')
318
319 def get_referenceable(self):
320 if 'referenceable' in self.xml.attrib and self.xml.get('referenceable')=="0":
321 return False
322 return True
323
324 def set_namespace(self, value):
325 if value:
326 self.xml.set('namespace', '1')
327 else:
328 self.xml.set('namespace', '0')
329
330 def get_namespace(self):
331 if 'namespace' in self.xml.attrib and self.xml.get('namespace')=="1":
332 return True
333 return False
334
335 def get_value(self):
336 return None
337
338
288 339
289 P_TITLE = 10 340 P_TITLE = 10
290 P_BODY = 20 341 P_BODY = 20
291 class text_edit_panel(wx.Panel): 342 class text_edit_panel(wx.Panel):
292 def __init__(self, parent, handler): 343 def __init__(self, parent, handler):
293 wx.Panel.__init__(self, parent, -1) 344 wx.Panel.__init__(self, parent, -1)
294 self.handler = handler 345 self.handler = handler
295 sizer = wx.BoxSizer(wx.VERTICAL) 346 sizer = wx.BoxSizer(wx.VERTICAL)
296 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.master_dom.getAttribute('name')), 347 self.text = { P_TITLE : wx.TextCtrl(self, P_TITLE, handler.xml.get('name')),
297 P_BODY : html_text_edit(self,P_BODY,handler.text._get_nodeValue(),self.on_text) 348 P_BODY : html_text_edit(self,P_BODY,handler.text,self.on_text)
298 } 349 }
299 #P_BODY : wx.TextCtrl(self, P_BODY,handler.text._get_nodeValue(), style=wx.TE_MULTILINE) 350 #P_BODY : wx.TextCtrl(self, P_BODY,handler.text, style=wx.TE_MULTILINE)
300 351
301 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) 352 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
302 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) 353 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
303 sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND) 354 sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND)
304 sizer.Add(self.text[P_BODY], 1, wx.EXPAND) 355 sizer.Add(self.text[P_BODY], 1, wx.EXPAND)
320 bad_txt_found = 1 371 bad_txt_found = 1
321 if bad_txt_found: 372 if bad_txt_found:
322 wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!") 373 wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!")
323 txt = u_txt 374 txt = u_txt
324 if txt != "": 375 if txt != "":
325 self.handler.master_dom.setAttribute('name',txt) 376 self.handler.xml.set('name',txt)
326 self.handler.rename(txt) 377 self.handler.rename(txt)
327 elif id == P_BODY: 378 elif id == P_BODY:
328 txt = self.text[id].get_text() 379 txt = self.text[id].get_text()
329 u_txt = "" 380 u_txt = ""
330 bad_txt_found = 0 381 bad_txt_found = 0
346 ########################## 397 ##########################
347 class node_loader(node_handler): 398 class node_loader(node_handler):
348 """ clones childe node and insert it at top of tree 399 """ clones childe node and insert it at top of tree
349 <nodehandler name='?' module='core' class='node_loader' /> 400 <nodehandler name='?' module='core' class='node_loader' />
350 """ 401 """
351 def __init__(self,xml_dom,tree_node): 402 def __init__(self,xml,tree_node):
352 node_handler.__init__(self,xml_dom,tree_node) 403 node_handler.__init__(self,xml,tree_node)
353 404
354 def on_rclick(self,evt): 405 def on_rclick(self,evt):
355 pass 406 pass
356 407
357 def on_ldclick(self,evt): 408 def on_ldclick(self,evt):
358 title = self.master_dom.getAttribute('name') 409 title = self.xml.get('name')
359 new_node = self.master_dom._get_firstChild() 410 new_xml = XML(tostring(self.xml[0]))
360 new_node = new_node.cloneNode(True) 411 self.tree.root_xml.insert(0, new_xml)
361 child = self.tree.master_dom._get_firstChild() 412 tree_node = self.tree.load_xml(new_xml,self.tree.root,self.tree.root)
362 new_node = self.tree.master_dom.insertBefore(new_node,child)
363 tree_node = self.tree.load_xml(new_node,self.tree.root,self.tree.root)
364 obj = self.tree.GetPyData(tree_node)
365 return 1 413 return 1
414 #obj = self.tree.GetPyData(tree_node)
366 #obj.on_design(None) 415 #obj.on_design(None)
367 416
368 ########################## 417 ##########################
369 ## file loader 418 ## file loader
370 ########################## 419 ##########################
373 """ loads file and insert into game tree 422 """ loads file and insert into game tree
374 <nodehandler name='?' module='core' class='file_loader' > 423 <nodehandler name='?' module='core' class='file_loader' >
375 <file name="file_name.xml" /> 424 <file name="file_name.xml" />
376 </nodehandler> 425 </nodehandler>
377 """ 426 """
378 def __init__(self,xml_dom,tree_node): 427 def __init__(self,xml,tree_node):
379 node_handler.__init__(self,xml_dom,tree_node) 428 node_handler.__init__(self,xml,tree_node)
380 self.file_node = self.master_dom._get_firstChild() 429 self.file_node = self.xml[0]
381 self.frame = component.get('frame') 430 self.frame = open_rpg.get_component('frame')
382 431
383 def on_ldclick(self,evt): 432 def on_ldclick(self,evt):
384 file_name = self.file_node.getAttribute("name") 433 file_name = self.file_node.get("name")
385 self.tree.insert_xml(open(dir_struct["nodes"] + file_name,"r").read()) 434 self.tree.insert_xml(open(orpg.dirpath.dir_struct["nodes"] + file_name,"r").read())
386 return 1 435 return 1
387 436
388 def on_design(self,evt): 437 def on_design(self,evt):
389 tlist = ['Title','File Name'] 438 tlist = ['Title','File Name']
390 vlist = [self.master_dom.getAttribute("name"), 439 vlist = [self.xml.get("name"),
391 self.file_node.getAttribute("name")] 440 self.file_node.get("name")]
392 dlg = orpgMultiTextEntry(self.tree.GetParent(),tlist,vlist,"File Loader Edit") 441 dlg = orpgMultiTextEntry(self.tree.GetParent(),tlist,vlist,"File Loader Edit")
393 if dlg.ShowModal() == wx.ID_OK: 442 if dlg.ShowModal() == wx.ID_OK:
394 vlist = dlg.get_values() 443 vlist = dlg.get_values()
395 self.file_node.setAttribute('name', vlist[1]) 444 self.file_node.set('name', vlist[1])
396 self.master_dom.setAttribute('name', vlist[0]) 445 self.xml.set('name', vlist[0])
397 self.tree.SetItemText(self.mytree_node,vlist[0]) 446 self.tree.SetItemText(self.mytree_node,vlist[0])
398 dlg.Destroy() 447 dlg.Destroy()
399 448
400 ########################## 449 ##########################
401 ## URL loader 450 ## URL loader
405 """ loads file from url and insert into game tree 454 """ loads file from url and insert into game tree
406 <nodehandler name='?' module='core' class='url_loader' > 455 <nodehandler name='?' module='core' class='url_loader' >
407 <file name="http://file_name.xml" /> 456 <file name="http://file_name.xml" />
408 </nodehandler> 457 </nodehandler>
409 """ 458 """
410 def __init__(self,xml_dom,tree_node): 459 def __init__(self,xml,tree_node):
411 node_handler.__init__(self,xml_dom,tree_node) 460 node_handler.__init__(self,xml,tree_node)
412 self.file_node = self.master_dom._get_firstChild() 461 self.file_node = self.xml[0]
413 self.frame = component.get('frame') 462 self.frame = open_rpg.get_component('frame')
414 463
415 def on_ldclick(self,evt): 464 def on_ldclick(self,evt):
416 file_name = self.file_node.getAttribute("url") 465 file_name = self.file_node.get("url")
417 file = urllib.urlopen(file_name) 466 file = urllib.urlopen(file_name)
418 self.tree.insert_xml(file.read()) 467 self.tree.insert_xml(file.read())
419 return 1 468 return 1
420 469
421 def on_design(self,evt): 470 def on_design(self,evt):
422 tlist = ['Title','URL'] 471 tlist = ['Title','URL']
423 print "design filename",self.master_dom.getAttribute('name') 472 print "design filename",self.xml.get('name')
424 vlist = [self.master_dom.getAttribute("name"), 473 vlist = [self.xml.get("name"),
425 self.file_node.getAttribute("url")] 474 self.file_node.get("url")]
426 dlg = orpgMultiTextEntry(self.tree.GetParent(),tlist,vlist,"File Loader Edit") 475 dlg = orpgMultiTextEntry(self.tree.GetParent(),tlist,vlist,"File Loader Edit")
427 if dlg.ShowModal() == wx.ID_OK: 476 if dlg.ShowModal() == wx.ID_OK:
428 vlist = dlg.get_values() 477 vlist = dlg.get_values()
429 self.file_node.setAttribute('url', vlist[1]) 478 self.file_node.set('url', vlist[1])
430 self.master_dom.setAttribute('name', vlist[0]) 479 self.xml.set('name', vlist[0])
431 self.tree.SetItemText(self.mytree_node,vlist[0]) 480 self.tree.SetItemText(self.mytree_node,vlist[0])
432 dlg.Destroy() 481 dlg.Destroy()
433 482
434 483
435 ########################## 484 ##########################
437 ########################## 486 ##########################
438 class min_map(node_handler): 487 class min_map(node_handler):
439 """ clones childe node and insert it at top of tree 488 """ clones childe node and insert it at top of tree
440 <nodehandler name='?' module='core' class='min_map' /> 489 <nodehandler name='?' module='core' class='min_map' />
441 """ 490 """
442 def __init__(self,xml_dom,tree_node): 491 def __init__(self,xml,tree_node):
443 node_handler.__init__(self,xml_dom,tree_node) 492 node_handler.__init__(self,xml,tree_node)
444 self.map = component.get('map') 493 self.map = open_rpg.get_component('map')
445 self.mapdata = self.master_dom._get_firstChild() 494 self.mapdata = self.xml[0]
446 495
447 def on_ldclick(self,evt): 496 def on_ldclick(self,evt):
448 self.map.new_data(toxml(self.mapdata)) 497 self.map.new_data(tostring(self.mapdata))
449 return 1 498 return 1