changeset 170:0296f5f74a0f

Fixed saving and loading that broke with changing of the settings module.
author Beliar <KarstenBock@gmx.net>
date Sat, 25 Feb 2012 22:05:39 +0100
parents 5b880b8cff6d
children 565ffdd98d68
files gamemodel.py gui/filebrowser.py
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gamemodel.py	Sat Feb 25 00:21:28 2012 +0100
+++ b/gamemodel.py	Sat Feb 25 22:05:39 2012 +0100
@@ -213,12 +213,12 @@
            @type filename: string
            @param filename: the name of the file (including path) to load from
            @return: None"""
-        fname = '/'.join([path, filename])
+        fname = os.path.join(path, filename)
 
         try:
             load_file = open(fname, 'r')
         except(IOError):
-            sys.stderr.write("Error: Can't find save game file\n")
+            sys.stderr.write("Error: Can't find save game file '" + fname + "'\n")
             return        
         self.deleteMaps()
         self.clearAgents()
--- a/gui/filebrowser.py	Sat Feb 25 00:21:28 2012 +0100
+++ b/gui/filebrowser.py	Sat Feb 25 22:05:39 2012 +0100
@@ -50,7 +50,9 @@
         # FIXME M. George Hansen 2011-06-06: Not sure that user_path is set
         #     correctly atm. Plus, I don't think that this should be
         #     hard-coded.
-        self.path = os.path.join(self.settings.user_path, 'saves')
+        self.path = os.path.relpath(os.path.join(self.settings.get("parpg", "DataPath"), 'saves'))
+        if not os.path.exists(self.path):
+            os.makedirs(self.path)
         self.dir_list = []
         self.file_list = []
         
@@ -115,7 +117,6 @@
                                     listDirectories(self.path))
         file_list = filter(lambda f: f.split('.')[-1] in self.extensions, \
                            self.engine.getVFS().listFiles(self.path))
-                
         self.dir_list = decodeList(dir_list)
         self.file_list = decodeList(file_list)
         self._widget.distributeInitialData({