Mercurial > traipse_dev
comparison orpg/gametree/nodehandlers/core.py @ 71:449a8900f9ac ornery-dev
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
author | sirebral |
---|---|
date | Thu, 20 Aug 2009 03:00:39 -0500 |
parents | c54768cffbd4 |
children | 0c936d98f9eb dcf4fbe09b70 |
comparison
equal
deleted
inserted
replaced
70:52a5fa913008 | 71:449a8900f9ac |
---|---|
30 | 30 |
31 from nodehandler_version import NODEHANDLER_VERSION | 31 from nodehandler_version import NODEHANDLER_VERSION |
32 try: | 32 try: |
33 from orpg.orpg_windows import * | 33 from orpg.orpg_windows import * |
34 from orpg.dirpath import dir_struct | 34 from orpg.dirpath import dir_struct |
35 from orpg.orpg_xml import * | |
36 from orpg.orpgCore import component | 35 from orpg.orpgCore import component |
37 import webbrowser | 36 import webbrowser |
38 from orpg.mapper import map | 37 from orpg.mapper import map |
39 import os | 38 import os |
40 except: | 39 except: |
41 import wx | 40 import wx |
42 | |
43 | |
44 | 41 |
45 | 42 |
46 #html defaults | 43 #html defaults |
47 TH_BG = "#E9E9E9" | 44 TH_BG = "#E9E9E9" |
48 ########################## | 45 ########################## |
54 self.master_dom = xml_dom | 51 self.master_dom = xml_dom |
55 self.mytree_node = tree_node | 52 self.mytree_node = tree_node |
56 self.tree = component.get('tree') | 53 self.tree = component.get('tree') |
57 self.frame = component.get('frame') | 54 self.frame = component.get('frame') |
58 self.chat = component.get('chat') | 55 self.chat = component.get('chat') |
59 self.xml = component.get('xml') | 56 self.xml = component.get('xml') #Not used? |
60 self.drag = True | 57 self.drag = True |
61 self.myeditor = None # designing | 58 self.myeditor = None # designing |
62 self.myviewer = None # prett print | 59 self.myviewer = None # pretty print |
63 self.mywindow = None # using | 60 self.mywindow = None # using |
64 # call version hook | 61 # call version hook |
65 self.on_version(self.master_dom.getAttribute("version")) | 62 self.on_version(self.master_dom.getAttribute("version")) |
66 # set to current version | 63 # set to current version |
67 self.master_dom.setAttribute("version",NODEHANDLER_VERSION) | 64 self.master_dom.setAttribute("version",NODEHANDLER_VERSION) |
112 except: | 109 except: |
113 del self.myeditor | 110 del self.myeditor |
114 if self.create_designframe(): | 111 if self.create_designframe(): |
115 self.myeditor.Show() | 112 self.myeditor.Show() |
116 self.myeditor.Raise() | 113 self.myeditor.Raise() |
117 else: | 114 else: return |
118 return | |
119 wx.CallAfter(self.myeditor.Layout) | 115 wx.CallAfter(self.myeditor.Layout) |
120 | 116 |
121 | 117 |
122 def create_designframe(self): | 118 def create_designframe(self): |
123 title = self.master_dom.getAttribute('name') + " Editor" | 119 title = self.master_dom.getAttribute('name') + " Editor" |
124 self.myeditor = wx.Frame(None, -1, title) | 120 self.myeditor = wx.Frame(None, -1, title) |
125 self.myeditor.Freeze() | 121 self.myeditor.Freeze() |
126 if wx.Platform == '__WXMSW__': | 122 if wx.Platform == '__WXMSW__': |
127 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO) | 123 icon = wx.Icon(dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO) |
128 self.myeditor.SetIcon(icon) | 124 self.myeditor.SetIcon(icon) |
129 del icon | 125 del icon |
130 | 126 |
131 self.myeditor.panel = self.get_design_panel(self.myeditor) | 127 self.myeditor.panel = self.get_design_panel(self.myeditor) |
132 if self.myeditor.panel == None: | 128 if self.myeditor.panel == None: |
161 self.mywindow.Raise() | 157 self.mywindow.Raise() |
162 else: | 158 else: |
163 return | 159 return |
164 wx.CallAfter(self.mywindow.Layout) | 160 wx.CallAfter(self.mywindow.Layout) |
165 | 161 |
166 | |
167 def create_useframe(self): | 162 def create_useframe(self): |
168 caption = self.master_dom.getAttribute('name') | 163 caption = self.master_dom.getAttribute('name') |
169 self.mywindow = wx.Frame(None, -1, caption) | 164 self.mywindow = wx.Frame(None, -1, caption) |
170 self.mywindow.Freeze() | 165 self.mywindow.Freeze() |
171 | 166 |
172 if wx.Platform == '__WXMSW__': | 167 if wx.Platform == '__WXMSW__': |
173 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'note.ico', wx.BITMAP_TYPE_ICO) | 168 icon = wx.Icon(dir_struct["icon"] + 'note.ico', wx.BITMAP_TYPE_ICO) |
174 self.mywindow.SetIcon(icon) | 169 self.mywindow.SetIcon(icon) |
175 del icon | 170 del icon |
176 self.mywindow.panel = self.get_use_panel(self.mywindow) | 171 self.mywindow.panel = self.get_use_panel(self.mywindow) |
177 if self.mywindow.panel == None: | 172 if self.mywindow.panel == None: |
178 self.mywindow.Destroy() | 173 self.mywindow.Destroy() |
201 self.myviewer.Raise() | 196 self.myviewer.Raise() |
202 except: | 197 except: |
203 caption = self.master_dom.getAttribute('name') | 198 caption = self.master_dom.getAttribute('name') |
204 self.myviewer = wx.Frame(None, -1, caption) | 199 self.myviewer = wx.Frame(None, -1, caption) |
205 if wx.Platform == '__WXMSW__': | 200 if wx.Platform == '__WXMSW__': |
206 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO) | 201 icon = wx.Icon(dir_struct["icon"] + 'grid.ico', wx.BITMAP_TYPE_ICO) |
207 self.myviewer.SetIcon(icon) | 202 self.myviewer.SetIcon(icon) |
208 del icon | 203 del icon |
209 self.myviewer.panel = self.get_html_panel(self.myviewer) | 204 self.myviewer.panel = self.get_html_panel(self.myviewer) |
210 self.myviewer.Show() | 205 self.myviewer.Show() |
211 | 206 |
244 if not prev_sib.IsOk(): | 239 if not prev_sib.IsOk(): |
245 prev_sib = parent_node | 240 prev_sib = parent_node |
246 self.tree.load_xml(xml_dom, parent_node, prev_sib) | 241 self.tree.load_xml(xml_dom, parent_node, prev_sib) |
247 | 242 |
248 def toxml(self,pretty=0): | 243 def toxml(self,pretty=0): |
249 return toxml(self.master_dom,pretty) | 244 return component.get('xml').toxml(self.master_dom,pretty) |
250 | 245 |
251 def tohtml(self): | 246 def tohtml(self): |
252 return self.master_dom.getAttribute("name") | 247 return self.master_dom.getAttribute("name") |
253 | 248 |
254 def delete(self): | 249 def delete(self): |
268 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon]) | 263 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon]) |
269 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon], wx.TreeItemIcon_Selected) | 264 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon], wx.TreeItemIcon_Selected) |
270 self.tree.Refresh() | 265 self.tree.Refresh() |
271 | 266 |
272 def on_save(self,evt): | 267 def on_save(self,evt): |
273 f = wx.FileDialog(self.tree,"Select a file", orpg.dirpath.dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE) | 268 f = wx.FileDialog(self.tree,"Select a file", dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE) |
274 if f.ShowModal() == wx.ID_OK: | 269 if f.ShowModal() == wx.ID_OK: |
275 type = f.GetFilterIndex() | 270 type = f.GetFilterIndex() |
276 if f.GetPath()[:len(f.GetPath())-4] != '.xml': file = open(f.GetPath()+'.xml',"w") | 271 if f.GetPath()[:len(f.GetPath())-4] != '.xml': file = open(f.GetPath()+'.xml',"w") |
277 else: file = open(f.GetPath(),"w") | 272 else: file = open(f.GetPath(),"w") |
278 file.write(self.toxml(1)) | 273 file.write(self.toxml(1)) |
394 self.file_node = self.master_dom._get_firstChild() | 389 self.file_node = self.master_dom._get_firstChild() |
395 self.frame = component.get('frame') | 390 self.frame = component.get('frame') |
396 | 391 |
397 def on_ldclick(self,evt): | 392 def on_ldclick(self,evt): |
398 file_name = self.file_node.getAttribute("name") | 393 file_name = self.file_node.getAttribute("name") |
399 self.tree.insert_xml(open(orpg.dirpath.dir_struct["nodes"] + file_name,"r").read()) | 394 self.tree.insert_xml(open(dir_struct["nodes"] + file_name,"r").read()) |
400 return 1 | 395 return 1 |
401 | 396 |
402 def on_design(self,evt): | 397 def on_design(self,evt): |
403 tlist = ['Title','File Name'] | 398 tlist = ['Title','File Name'] |
404 vlist = [self.master_dom.getAttribute("name"), | 399 vlist = [self.master_dom.getAttribute("name"), |