comparison charactercreationview.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
comparison
equal deleted inserted replaced
1:4912a6f97c52 2:06145a6ee387
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 """Provides the view for displaying the character creation screen.""" 15 """Provides the view for displaying the character creation screen."""
16 16
17 import os
18
19 from fife.extensions import pychan 17 from fife.extensions import pychan
20 18
19 from parpg import vfs
21 from viewbase import ViewBase 20 from viewbase import ViewBase
22 21
23 class CharacterCreationView(ViewBase): 22 class CharacterCreationView(ViewBase):
24 """View used to display the character creation screen. 23 """View used to display the character creation screen.
25 @ivar background: Widget displayed as the background. 24 @ivar background: Widget displayed as the background.
38 @type engine: L{fife.Engine} 37 @type engine: L{fife.Engine}
39 @param model: Model of the game state. 38 @param model: Model of the game state.
40 @type model: L{GameState}""" 39 @type model: L{GameState}"""
41 ViewBase.__init__(self, engine, model) 40 ViewBase.__init__(self, engine, model)
42 self.settings = settings 41 self.settings = settings
43 gui_path = os.path.join(self.settings.system_path, 42 xml_file = vfs.VFS.open('gui/main_menu_background.xml')
44 self.settings.parpg.GuiPath) 43 self.background = pychan.loadXML(xml_file)
45 self.background = pychan.loadXML(os.path.join(gui_path,
46 'main_menu_background.xml'))
47 screen_mode = self.engine.getRenderBackend().getCurrentScreenMode() 44 screen_mode = self.engine.getRenderBackend().getCurrentScreenMode()
48 self.background.width = screen_mode.getWidth() 45 self.background.width = screen_mode.getWidth()
49 self.background.height = screen_mode.getHeight() 46 self.background.height = screen_mode.getHeight()
50 self.start_new_game_callback = None 47 self.start_new_game_callback = None
51 self.cancel_new_game_callback = None 48 self.cancel_new_game_callback = None
52 self.character_screen = pychan.loadXML(os.path.join(gui_path, 49
53 'character_screen.xml')) 50 xml_file = vfs.VFS.open('gui/character_screen.xml')
51 self.character_screen = pychan.loadXML(xml_file)
52
54 self.character_screen.adaptLayout() 53 self.character_screen.adaptLayout()
55 character_screen_events = {} 54 character_screen_events = {}
56 character_screen_events['startButton'] = self.startNewGame 55 character_screen_events['startButton'] = self.startNewGame
57 character_screen_events['cancelButton'] = self.cancelNewGame 56 character_screen_events['cancelButton'] = self.cancelNewGame
58 self.character_screen.mapEvents(character_screen_events) 57 self.character_screen.mapEvents(character_screen_events)