diff charactercreationcontroller.py @ 2:06145a6ee387

Fixed resource path dependencies issue that caused PARPG to crash on start. * PARPG should now run without issue (system installation not tested). * Utilized FIFE's VFS module to remove path dependencies from most PARPG modules. * The new parpg.vfs module is a singleton with a single global variable, VFS, which is a reference to the global VFS instance. Although a singleton is not ideal it should be replaced once PARPG's core code is refactored. * The parpg.vfs singleton is initialized in the parpg.applicaiton.PARPGApplication class with the absolute path to the data directory via the parpg.settings module and corresponding configuration file. * A new DataPath entry was added to the default system configuration file template under the [parpg] section to support the new parpg.vfs module. * Updated the parpg-assets subrepo to revision 3 to fix some dialog file format issues (for details see commit message for parpg-assets). * Fixed a few bugs in the parpg.dialogueparsers.YAMLDialogueParser class related to exception handling.
author M. George Hansen <technopolitica@gmail.com>
date Mon, 06 Jun 2011 15:56:14 -1000
parents 7a89ea5404b1
children 708a6f651c31
line wrap: on
line diff
--- a/charactercreationcontroller.py	Tue May 31 02:46:20 2011 -0700
+++ b/charactercreationcontroller.py	Mon Jun 06 15:56:14 2011 -1000
@@ -15,6 +15,7 @@
 """Provides the controller that defines the behaviour of the character creation
    screen."""
 
+from parpg import vfs
 import characterstatistics as char_stats
 from serializers import XmlSerializer
 from controllerbase import ControllerBase
@@ -27,8 +28,10 @@
 
 def getStatCost(offset):
     """Gets and returns the cost to increase stat based on the offset"""
+
     if offset < 0:
         offset *= -1
+
     if offset < 22:
         return 1
     elif offset < 29:
@@ -106,23 +109,31 @@
            @type application: 
                L{fife.extensions.basicapplication.ApplicationBase}"""
         ControllerBase.__init__(self, engine, view, model, application)
+        self.settings = self.model.settings
         self.view.start_new_game_callback = self.startNewGame
         self.view.cancel_new_game_callback = self.cancelNewGame
         self.view.show()
-        #TODO: Maybe this should not be hardcoded
-        stream = file("character_scripts/primary_stats.xml")        
-        prim_stats = XmlSerializer.deserialize(stream)
-        stream = file("character_scripts/secondary_stats.xml")        
-        sec_stats = XmlSerializer.deserialize(stream)
-        self.char_data = SimpleCharacter("",
-                                              self.GENDERS[0],
-                                              self.ORIGINS.keys()[0],
-                                              20,
-                                              self.PICTURES[self.GENDERS[0]][0],
-                                              [],
-                                              prim_stats,
-                                              sec_stats,
-                                              Inventory())
+        # FIXME M. George Hansen 2011-06-06: character stats scripts aren't
+        #     finished, unfortunately.
+#        primary_stats_file = \
+#            vfs.VFS.open('character_scripts/primary_stats.xml')
+#        primary_stats = XmlSerializer.deserialize(primary_stats_file)
+#        secondary_stats_file = \
+#            vfs.VFS.open('character_scripts/secondary_stats.xml')
+#        secondary_stats = XmlSerializer.deserialize(secondary_stats_file)
+        primary_stats = []
+        secondary_stats = []
+        self.char_data = SimpleCharacter(
+            "",
+            self.GENDERS[0],
+            self.ORIGINS.keys()[0],
+            20,
+            self.PICTURES[self.GENDERS[0]][0],
+            [],
+            primary_stats,
+            secondary_stats,
+            Inventory()
+        )
         self._stat_points = 200
   
        
@@ -134,7 +145,7 @@
                                          self.application)
         self.application.view = view
         self.application.switchController(controller)
-        start_map = self.model.settings.parpg.Map
+        start_map = self.settings.parpg.Map
         self.model.changeMap(start_map)
     
     def cancelNewGame(self):