diff src/parpg/gamescenecontroller.py @ 12:d60f1dab8469

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 1fd2201f5c36
children aa3d837024a3
line wrap: on
line diff
--- a/src/parpg/gamescenecontroller.py	Tue May 31 02:46:20 2011 -0700
+++ b/src/parpg/gamescenecontroller.py	Mon Jun 06 15:56:14 2011 -1000
@@ -94,9 +94,10 @@
 
         if model.settings.fife.EnableSound:
             if not self.view.sounds.music_init:
-                music_file = random.choice(glob.glob(os.path.join(
-                                                                  "music", 
-                                                                  "*.ogg")))
+                music_path = 'music'
+                music_file = random.choice(
+                    glob.glob('/'.join([music_path, '*.ogg']))
+                )
                 self.view.sounds.playMusic(music_file) 
         self.initHud()
                 
@@ -135,8 +136,10 @@
             # F7 saves a screenshot to screenshots directory
 
             settings = self.model.settings
+            # FIXME M. George Hansen 2011-06-06: Not sure that user_path is set
+            #     correctly atm.
             screenshot_directory = os.path.join(settings.user_path,
-                                           settings.parpg.ScreenshotsPath)
+                                                'screenshots')
             # try to create the screenshots directory
             try:
                 os.mkdir(screenshot_directory)
@@ -256,37 +259,25 @@
             if mouse_y <= pixle_edge: 
                 direction[0] += 1
                 direction[1] -= 1
-                image = os.path.join(settings.system_path,
-                                     settings.parpg.GuiPath,
-                                     settings.parpg.CursorPath,
-                                     settings.parpg.CursorUp)
+                image = '/'.join(['gui/cursors', settings.parpg.CursorUp])
                 
             #right
             if mouse_x >= screen_width - pixle_edge:
                 direction[0] += 1
                 direction[1] += 1
-                image = os.path.join(settings.system_path,
-                                     settings.parpg.GuiPath,
-                                     settings.parpg.CursorPath,
-                                     settings.parpg.CursorRight)
+                image = '/'.join(['gui/cursors', settings.parpg.CursorRight])
                 
             #down
             if mouse_y >= screen_height - pixle_edge:
                 direction[0] -= 1
                 direction[1] += 1
-                image = os.path.join(settings.system_path,
-                                     settings.parpg.GuiPath,
-                                     settings.parpg.CursorPath,
-                                     settings.parpg.CursorDown)
+                image = '/'.join(['gui/cursors', settings.parpg.CursorDown])
                 
             #left
             if mouse_x <= pixle_edge:
                 direction[0] -= 1
                 direction[1] -= 1
-                image = os.path.join(settings.system_path,
-                                     settings.parpg.GuiPath,
-                                     settings.parpg.CursorPath,
-                                     settings.parpg.CursorLeft)
+                image = '/'.join(['gui/cursors', settings.parpg.CursorLeft])
             
             if image is not None and not data_drag.dragging:
                 self.setMouseCursor(image, image)
@@ -310,9 +301,12 @@
                 player_agent = self.model.active_map.\
                                     agent_layer.getInstance("PlayerCharacter")
                 self.model.active_map.agent_layer.deleteInstance(player_agent)
+            
             self.model.loadMap(self.model.target_map_name)
+            
             self.model.setActiveMap(self.model.target_map_name)          
             self.model.readAgentsOfMap(self.model.target_map_name)
+            
             self.model.placeAgents()
             self.model.placePC()
             self.model.map_change = False