diff src/parpg/mainmenuview.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
line wrap: on
line diff
--- a/src/parpg/mainmenuview.py	Tue May 31 02:46:20 2011 -0700
+++ b/src/parpg/mainmenuview.py	Mon Jun 06 15:56:14 2011 -1000
@@ -13,10 +13,9 @@
 #   You should have received a copy of the GNU General Public License
 #   along with PARPG.  If not, see <http://www.gnu.org/licenses/
 
-import os
-
 from fife.extensions import pychan
 
+from parpg import vfs
 from viewbase import ViewBase
 from parpg.gui.filebrowser import FileBrowser
 from parpg.gui.menus import SettingsMenu
@@ -38,9 +37,7 @@
         self.quit_callback = None
         self.main_menu = None
         self.character_screen = None
-        self.gui_path = os.path.join(self.model.settings.system_path,
-                                     self.model.settings.parpg.GuiPath)
-        
+    
     def showMenu(self):
         """"Shows the main menu"""
         self.main_menu_background.show()
@@ -54,29 +51,16 @@
     def initalizeMainMenu(self, new_game, load_game, quit_game):
         """Initialized the main menu and sets the callbacks"""
         # Set a simple background to display the main screen.
-        self.main_menu_background = pychan.loadXML(os.path.join(self.gui_path,
-                                                   'main_menu_background.xml'))
+        xml_file = vfs.VFS.open('gui/main_menu_background.xml')
+        self.main_menu_background = pychan.loadXML(xml_file)
         
         # Initialize the main menu screen.
         screen_mode = self.engine.getRenderBackend().getCurrentScreenMode()
         self.main_menu_background.width = screen_mode.getWidth()
         self.main_menu_background.height = screen_mode.getHeight()
-        self.main_menu = pychan.loadXML(os.path.join(self.gui_path,
-                                                     'main_menu.xml'))
 
-        # Setup images for variables widgets 
-        self.main_menu.background_image = os.path.join(self.gui_path,
-                                                       'notebook',
-                                                       'notebook_background.png')
-        quit_button = self.main_menu.findChild(name='quitButton')
-        quit_button.up_image = os.path.join(self.gui_path, 'notebook', 'tabs',
-                                            'tab2_bg_dark_bottom.png')
-        quit_button.hover_image = os.path.join(self.gui_path, 'notebook',
-                                               'tabs',
-                                               'tab2_bg_normal_bottom.png')
-        quit_button.down_image = os.path.join(self.gui_path, 'notebook',
-                                              'tabs',
-                                              'tab2_bg_normal_bottom.png')
+        xml_file = vfs.VFS.open('gui/main_menu.xml')
+        self.main_menu = pychan.loadXML(xml_file)
 
         self.main_menu.adaptLayout()
         self.new_game_callback = new_game
@@ -103,8 +87,7 @@
         load_browser = FileBrowser(self.engine,
                                    self.model.settings,
                                    self.load_game_callback,
-                                   gui_xml_path=os.path.join(self.gui_path,
-                                                             'loadbrowser.xml'),
+                                   gui_xml_path='gui/loadbrowser.xml',
                                    save_file=False,
                                    extensions=('.dat'))
         load_browser.showBrowser()