comparison 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
comparison
equal deleted inserted replaced
11:4706e0194af3 12:d60f1dab8469
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 12
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/ 14 # along with PARPG. If not, see <http://www.gnu.org/licenses/
15 15
16 import os
17
18 from fife.extensions import pychan 16 from fife.extensions import pychan
19 17
18 from parpg import vfs
20 from viewbase import ViewBase 19 from viewbase import ViewBase
21 from parpg.gui.filebrowser import FileBrowser 20 from parpg.gui.filebrowser import FileBrowser
22 from parpg.gui.menus import SettingsMenu 21 from parpg.gui.menus import SettingsMenu
23 22
24 class MainMenuView(ViewBase): 23 class MainMenuView(ViewBase):
36 self.new_game_callback = None 35 self.new_game_callback = None
37 self.load_game_callback = None 36 self.load_game_callback = None
38 self.quit_callback = None 37 self.quit_callback = None
39 self.main_menu = None 38 self.main_menu = None
40 self.character_screen = None 39 self.character_screen = None
41 self.gui_path = os.path.join(self.model.settings.system_path, 40
42 self.model.settings.parpg.GuiPath)
43
44 def showMenu(self): 41 def showMenu(self):
45 """"Shows the main menu""" 42 """"Shows the main menu"""
46 self.main_menu_background.show() 43 self.main_menu_background.show()
47 self.main_menu.show() 44 self.main_menu.show()
48 45
52 self.main_menu_background.hide() 49 self.main_menu_background.hide()
53 50
54 def initalizeMainMenu(self, new_game, load_game, quit_game): 51 def initalizeMainMenu(self, new_game, load_game, quit_game):
55 """Initialized the main menu and sets the callbacks""" 52 """Initialized the main menu and sets the callbacks"""
56 # Set a simple background to display the main screen. 53 # Set a simple background to display the main screen.
57 self.main_menu_background = pychan.loadXML(os.path.join(self.gui_path, 54 xml_file = vfs.VFS.open('gui/main_menu_background.xml')
58 'main_menu_background.xml')) 55 self.main_menu_background = pychan.loadXML(xml_file)
59 56
60 # Initialize the main menu screen. 57 # Initialize the main menu screen.
61 screen_mode = self.engine.getRenderBackend().getCurrentScreenMode() 58 screen_mode = self.engine.getRenderBackend().getCurrentScreenMode()
62 self.main_menu_background.width = screen_mode.getWidth() 59 self.main_menu_background.width = screen_mode.getWidth()
63 self.main_menu_background.height = screen_mode.getHeight() 60 self.main_menu_background.height = screen_mode.getHeight()
64 self.main_menu = pychan.loadXML(os.path.join(self.gui_path,
65 'main_menu.xml'))
66 61
67 # Setup images for variables widgets 62 xml_file = vfs.VFS.open('gui/main_menu.xml')
68 self.main_menu.background_image = os.path.join(self.gui_path, 63 self.main_menu = pychan.loadXML(xml_file)
69 'notebook',
70 'notebook_background.png')
71 quit_button = self.main_menu.findChild(name='quitButton')
72 quit_button.up_image = os.path.join(self.gui_path, 'notebook', 'tabs',
73 'tab2_bg_dark_bottom.png')
74 quit_button.hover_image = os.path.join(self.gui_path, 'notebook',
75 'tabs',
76 'tab2_bg_normal_bottom.png')
77 quit_button.down_image = os.path.join(self.gui_path, 'notebook',
78 'tabs',
79 'tab2_bg_normal_bottom.png')
80 64
81 self.main_menu.adaptLayout() 65 self.main_menu.adaptLayout()
82 self.new_game_callback = new_game 66 self.new_game_callback = new_game
83 self.load_game_callback = load_game 67 self.load_game_callback = load_game
84 self.quit_callback = quit_game 68 self.quit_callback = quit_game
101 """ Called when the user wants to load a game. 85 """ Called when the user wants to load a game.
102 @return: None""" 86 @return: None"""
103 load_browser = FileBrowser(self.engine, 87 load_browser = FileBrowser(self.engine,
104 self.model.settings, 88 self.model.settings,
105 self.load_game_callback, 89 self.load_game_callback,
106 gui_xml_path=os.path.join(self.gui_path, 90 gui_xml_path='gui/loadbrowser.xml',
107 'loadbrowser.xml'),
108 save_file=False, 91 save_file=False,
109 extensions=('.dat')) 92 extensions=('.dat'))
110 load_browser.showBrowser() 93 load_browser.showBrowser()
111 94
112 def initializeQuitDialog(self): 95 def initializeQuitDialog(self):