comparison orpg/gametree/nodehandlers/core.py @ 152:6081bdc2b8d5 beta

Traipse Beta 'OpenRPG' {091125-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 (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. !Infinite Loops return error instead of freezing the software! 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. Modified ID's to prevent non updated clients from ruining the fix.
author sirebral
date Wed, 25 Nov 2009 06:16:35 -0600
parents dcf4fbe09b70
children 3b6888bb53b5
comparison
equal deleted inserted replaced
150:6c5f46a5924b 152:6081bdc2b8d5
32 32
33 try: 33 try:
34 from orpg.orpg_windows import * 34 from orpg.orpg_windows import *
35 from orpg.dirpath import dir_struct 35 from orpg.dirpath import dir_struct
36 from orpg.orpgCore import component 36 from orpg.orpgCore import component
37 import webbrowser 37 import webbrowser, os
38 from orpg.mapper import map 38 from orpg.mapper import map
39 import os
40 from wx import DisplaySize 39 from wx import DisplaySize
41 except: 40 except:
42 import wx 41 import wx
43 42
44 from xml.etree.ElementTree import ElementTree, Element, tostring, XML 43 from xml.etree.ElementTree import ElementTree, Element, tostring, XML
72 frame = self.xml.get("frame") 71 frame = self.xml.get("frame")
73 if len(frame): 72 if len(frame):
74 (sx,sy,px,py) = [int(value) for value in frame.split(',')] 73 (sx,sy,px,py) = [int(value) for value in frame.split(',')]
75 self.frame_size = (sx, sy) 74 self.frame_size = (sx, sy)
76 (maxx, maxy) = DisplaySize() 75 (maxx, maxy) = DisplaySize()
77 if px < maxx-80 and py < maxy-50:#if it's off screen ignore the saved pos 76 if px < maxx-80 and py < maxy-50: self.frame_pos = (px, py) #if it's off screen ignore the saved pos
78 self.frame_pos = (px, py) 77 except: pass
79 except:
80 pass
81 78
82 def on_version(self,old_version): 79 def on_version(self,old_version):
83 ## added version control code here or implement a new on_version in your derived class. 80 ## added version control code here or implement a new on_version in your derived class.
84 ## always call the base class on_version ! 81 ## always call the base class on_version !
85 pass 82 pass
89 86
90 def on_ldclick(self,evt): 87 def on_ldclick(self,evt):
91 return 0 88 return 0
92 89
93 def usefulness(self,text): 90 def usefulness(self,text):
94 if text=="useful": 91 if text=="useful": self.xml.set('status',"useful")
95 self.xml.set('status',"useful") 92 elif text=="useless": self.xml.set('status',"useless")
96 elif text=="useless": 93 elif text=="indifferent": self.xml.set('status',"indifferent")
97 self.xml.set('status',"useless")
98 elif text=="indifferent":
99 self.xml.set('status',"indifferent")
100 94
101 def on_design(self,evt): 95 def on_design(self,evt):
102 try: 96 try:
103 self.myeditor.Show() 97 self.myeditor.Show()
104 self.myeditor.Raise() 98 self.myeditor.Raise()
144 self.mywindow.Raise() 138 self.mywindow.Raise()
145 except: 139 except:
146 del self.mywindow 140 del self.mywindow
147 if self.create_useframe(): 141 if self.create_useframe():
148 self.mywindow.SetSize(self.frame_size) 142 self.mywindow.SetSize(self.frame_size)
149 if self.frame_pos: 143 if self.frame_pos: self.mywindow.SetPosition(self.frame_pos)
150 self.mywindow.SetPosition(self.frame_pos)
151 self.mywindow.Show() 144 self.mywindow.Show()
152 self.mywindow.Raise() 145 self.mywindow.Raise()
153 else: 146 else: return
154 return
155 wx.CallAfter(self.mywindow.Layout) 147 wx.CallAfter(self.mywindow.Layout)
156 148
157 def create_useframe(self): 149 def create_useframe(self):
158 caption = self.xml.get('name', '') 150 caption = self.xml.get('name', '')
159 self.mywindow = wx.Frame(None, -1, caption) 151 self.mywindow = wx.Frame(None, -1, caption)
160 self.mywindow.Freeze() 152 self.mywindow.Freeze()
161
162 if wx.Platform == '__WXMSW__': 153 if wx.Platform == '__WXMSW__':
163 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'note.ico', wx.BITMAP_TYPE_ICO) 154 icon = wx.Icon(orpg.dirpath.dir_struct["icon"] + 'note.ico', wx.BITMAP_TYPE_ICO)
164 self.mywindow.SetIcon(icon) 155 self.mywindow.SetIcon(icon)
165 del icon 156 del icon
166 self.mywindow.panel = self.get_use_panel(self.mywindow) 157 self.mywindow.panel = self.get_use_panel(self.mywindow)
257 return self.xml.get("name") 248 return self.xml.get("name")
258 249
259 def delete(self): 250 def delete(self):
260 """ removes the tree_node and xml_node, and returns the removed xml_node """ 251 """ removes the tree_node and xml_node, and returns the removed xml_node """
261 parent_node = self.tree.GetItemParent(self.mytree_node) 252 parent_node = self.tree.GetItemParent(self.mytree_node)
262 if parent_node == self.tree.root: 253 if parent_node == self.tree.root: parent_xml = self.tree.GetPyData(parent_node)
263 parent_xml = self.tree.GetPyData(parent_node) 254 else: parent_xml = self.tree.GetPyData(parent_node).xml
264 else:
265 parent_xml = self.tree.GetPyData(parent_node).xml
266 parent_xml.remove(self.xml) 255 parent_xml.remove(self.xml)
267 self.tree.Delete(self.mytree_node) 256 self.tree.Delete(self.mytree_node)
268 return self.xml 257 return self.xml
269 258
270 def rename(self,name): 259 def rename(self,name):
278 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon], wx.TreeItemIcon_Selected) 267 self.tree.SetItemImage(self.mytree_node, self.tree.icons[icon], wx.TreeItemIcon_Selected)
279 self.tree.Refresh() 268 self.tree.Refresh()
280 269
281 def on_save(self,evt): 270 def on_save(self,evt):
282 f = wx.FileDialog(self.tree,"Select a file", orpg.dirpath.dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE) 271 f = wx.FileDialog(self.tree,"Select a file", orpg.dirpath.dir_struct["user"],"","XML files (*.xml)|*.xml",wx.SAVE)
283 if f.ShowModal() == wx.ID_OK: 272 if f.ShowModal() == wx.ID_OK: ElementTree(self.xml).write(f.GetPath())
284 ElementTree(self.xml).write(f.GetPath())
285 f.Destroy() 273 f.Destroy()
286 274
287 def get_design_panel(self,parent): 275 def get_design_panel(self,parent):
288 return None 276 return None
289 277
299 287
300 def get_size_constraint(self): 288 def get_size_constraint(self):
301 return 0 289 return 0
302 290
303 def about(self): 291 def about(self):
304 html_str = "<b>"+ self.xml.get('class') 292 """html_str = "<b>"+ self.xml.get('class')
305 html_str += " Applet</b><br />by Chris Davis<br />chris@rpgarchive.com" 293 html_str += " Applet</b><br />by Chris Davis<br />chris@rpgarchive.com"
306 return html_str 294 return html_str"""
295 text = self.xml.get('class') + ' Applet\n'
296 text += 'by Chris Davis chris@rpgarchive.com'
297 return text
307 298
308 def get_value(self): 299 def get_value(self):
309 return None 300 return None
310 301
311
312 P_TITLE = 10 302 P_TITLE = 10
313 P_BODY = 20 303 P_BODY = 20
304
314 class text_edit_panel(wx.Panel): 305 class text_edit_panel(wx.Panel):
315 def __init__(self, parent, handler): 306 def __init__(self, parent, handler):
316 wx.Panel.__init__(self, parent, -1) 307 wx.Panel.__init__(self, parent, -1)
317 self.handler = handler 308 self.handler = handler
318 sizer = wx.BoxSizer(wx.VERTICAL) 309 sizer = wx.BoxSizer(wx.VERTICAL)
333 txt = self.text[id].GetValue() 324 txt = self.text[id].GetValue()
334 # The following block strips out 8-bit characters 325 # The following block strips out 8-bit characters
335 u_txt = "" 326 u_txt = ""
336 bad_txt_found = 0 327 bad_txt_found = 0
337 for c in txt: 328 for c in txt:
338 if ord(c) < 128: 329 if ord(c) < 128: u_txt += c
339 u_txt += c 330 else: bad_txt_found = 1
340 else:
341 bad_txt_found = 1
342 if bad_txt_found: 331 if bad_txt_found:
343 wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!") 332 wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!")
344 txt = u_txt 333 txt = u_txt
345 if txt != "": 334 if txt != "":
346 self.handler.xml.set('name',txt) 335 self.handler.xml.set('name',txt)
348 elif id == P_BODY: 337 elif id == P_BODY:
349 txt = self.text[id].get_text() 338 txt = self.text[id].get_text()
350 u_txt = "" 339 u_txt = ""
351 bad_txt_found = 0 340 bad_txt_found = 0
352 for c in txt: 341 for c in txt:
353 if ord(c) < 128: 342 if ord(c) < 128: u_txt += c
354 u_txt += c 343 else: bad_txt_found = 1
355 else:
356 bad_txt_found = 1
357
358 if bad_txt_found: 344 if bad_txt_found:
359 wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!") 345 wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!")
360 txt = u_txt 346 txt = u_txt
361 self.handler.text._set_nodeValue(txt) 347 self.handler.text._set_nodeValue(txt)
362 348
379 title = self.xml.get('name') 365 title = self.xml.get('name')
380 new_xml = XML(tostring(self.xml[0])) 366 new_xml = XML(tostring(self.xml[0]))
381 self.tree.root_xml.insert(0, new_xml) 367 self.tree.root_xml.insert(0, new_xml)
382 tree_node = self.tree.load_xml(new_xml,self.tree.root,self.tree.root) 368 tree_node = self.tree.load_xml(new_xml,self.tree.root,self.tree.root)
383 return 1 369 return 1
384 #obj = self.tree.GetPyData(tree_node)
385 #obj.on_design(None)
386 370
387 ########################## 371 ##########################
388 ## file loader 372 ## file loader
389 ########################## 373 ##########################
390 374