Mercurial > traipse_dev
diff orpg/gametree/gametree.py @ 218:b8091ede042a alpha
Traipse Alpha 'OpenRPG' {100430-01}
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 (Patch-2)
New Features:
New Namespace method with two new syntaxes
New Namespace Internal is context sensitive, always!
New Namespace External is 'as narrow as you make it'
New Namespace FutureCheck helps ensure you don't receive an incorrect node
New PluginDB access for URL2Link plugin
New to Forms, they now show their content in Design Mode
New to Update Manager, checks Repo for updates on software start
New to Mini Lin node, change title in design mode
New to Game Tree, never lose a node, appends a number to the end of corrupted trees
New to Server GUI, Traipse Suite's Debug Console
Fixes:
Fix to Server GUI startup errors
Fix to Server GUI Rooms tab updating
Fix to Chat and Settings if non existant die roller is picked
Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated
Fix to Alias Lib's Export to Tree, Open, Save features
Fix to alias node, now works properly
Fix to Splitter node, minor GUI cleanup
Fix to Backgrounds not loading through remote loader
Fix to Node name errors
Fix to rolling dice in chat Whispers
Fix to Splitters Sizing issues
Fix to URL2Link plugin, modified regex compilation should remove memory leak
Fix to mapy.py, a roll back due to zoomed grid issues
Fix to whiteboard_handler, Circles work by you clicking the center of the circle
Fix to Servers parse_incoming_dom which was outdated and did not respect XML
Fix to a broken link in the server welcome message
Fix to InterParse and logger requiring traceback
Fix to Update Manager Status Bar
Fix to failed image and erroneous pop up
Fix to Mini Lib node that was preventing use
Fix to plugins that parce dice but did not call InterParse
Fix to nodes for name changing by double click
Fix to Game Tree, node ordering on drag and drop corrected
Fix to Game Tree, corrupted error message was not showing
author | sirebral |
---|---|
date | Fri, 30 Apr 2010 11:37:37 -0500 |
parents | 50af54dbd6a6 |
children | 24769389a7ba |
line wrap: on
line diff
--- a/orpg/gametree/gametree.py Fri Apr 30 05:36:11 2010 -0500 +++ b/orpg/gametree/gametree.py Fri Apr 30 11:37:37 2010 -0500 @@ -45,6 +45,7 @@ from orpg.dirpath import dir_struct from nodehandlers import core import string, urllib, time, os +from shutil import copytree, copystat, copy, copyfile from orpg.orpg_xml import xml from orpg.tools.validate import validate @@ -60,6 +61,12 @@ from xml.etree.ElementTree import fromstring, tostring, XML, iselement from xml.parsers.expat import ExpatError +def exists(path): + try: + os.stat(path) + return True + except: return False + STD_MENU_DELETE = wx.NewId() STD_MENU_DESIGN = wx.NewId() STD_MENU_USE = wx.NewId() @@ -206,9 +213,9 @@ self.EditLabel(curSelection) evt.Skip() - def locate_valid_tree(self, error, msg): ## --Snowdog 3/05 + def locate_valid_tree(self, error, msg, filename): ## --Snowdog 3/05 """prompts the user to locate a new tree file or create a new one""" - response = wx.MessageDialog(self, msg, error, wx.YES|wx.NO|wx.ICON_ERROR) + response = wx.MessageBox(msg, error, wx.YES|wx.NO|wx.ICON_ERROR) if response == wx.YES: file = None dlg = wx.FileDialog(self, "Locate Gametree file", dir_struct["user"], @@ -221,6 +228,7 @@ else: self.load_tree(file) return else: + copyfile(dir_struct['template']+'default_tree.xml', filename) validate.config_file("tree.xml","default_tree.xml") self.load_tree(error=1) return @@ -234,24 +242,25 @@ self.locate_valid_tree("Gametree Error", emsg) return try: + self.xml_root = False tree = parse(filename) self.xml_root = tree.getroot() - except: - self.xml_root = None - + except: self.xml_root = False if not self.xml_root: - os.rename(filename,filename+".corrupt") + count = 1 + while exists(filename[:len(filename)-4]+'-'+str(count)+'.xml'): count += 1 + corrupt_tree = filename[:len(filename)-4]+'-'+str(count)+'.xml' + copyfile(filename, corrupt_tree) emsg = "Your gametree is being regenerated.\n\n"\ "To salvage a recent version of your gametree\n"\ - "exit OpenRPG and copy the lastgood.xml file in\n"\ + "exit OpenRPG and copy the one of the tree-# files in\n"\ "your myfiles directory to "+filename+ "\n"\ "in your myfiles directory.\n\n"\ "lastgood.xml WILL BE OVERWRITTEN NEXT TIME YOU RUN OPENRPG.\n\n"\ "Would you like to select a different gametree file to use?\n"\ "(Selecting 'No' will cause a new default gametree to be generated)" - self.locate_valid_tree("Corrupt Gametree!", emsg) + self.locate_valid_tree("Corrupt Gametree!", emsg, filename) return - if self.xml_root.tag != "gametree": emsg = filename+" does not appear to be a valid gametree file.\n\n"\ "Would you like to select a different gametree file to use?\n"\ @@ -286,8 +295,22 @@ except Exception, e: logger.exception(traceback.format_exc()) - wx.MessageBox("Corrupt Tree!\nYour game tree is being regenerated. To\nsalvage a recent version of your gametree\nexit OpenRPG and copy the lastgood.xml\nfile in your myfiles directory\nto "+filename+ "\nin your myfiles directory.\nlastgood.xml WILL BE OVERWRITTEN NEXT TIME YOU RUN OPENRPG.") - os.rename(filename,filename+".corrupt") + + count = 1 + while exists(filename[:len(filename)-4]+'-'+str(count)+'.xml'): count += 1 + corrupt_tree = filename[:len(filename)-4]+'-'+str(count)+'.xml' + copyfile(filename, corrupt_tree) + wx.MessageBox("Your gametree is being regenerated.\n\n"\ + "To salvage a recent version of your gametree\n"\ + "exit OpenRPG and copy the one of the tree-# files in\n"\ + "your myfiles directory to "+filename+ "\n"\ + "in your myfiles directory.\n\n"\ + "lastgood.xml WILL BE OVERWRITTEN NEXT TIME YOU RUN OPENRPG.\n\n") + + count = 1 + while exists(filename[:len(filename)-4]+'-'+str(count)+'.xml'): count += 1 + corrupt_tree = filename[:len(filename)-4]+'-'+str(count)+'.xml' + copyfile(filename, corrupt_tree) validate.config_file("tree.xml","default_tree.xml") self.load_tree(error=1)