Mercurial > parpg-source
diff gui/hud.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 | 98f26f7636d8 |
line wrap: on
line diff
--- a/gui/hud.py Tue May 31 02:46:20 2011 -0700 +++ b/gui/hud.py Mon Jun 06 15:56:14 2011 -1000 @@ -19,13 +19,14 @@ from fife.extensions import pychan from fife.extensions.pychan.tools import callbackWithArguments as cbwa +from parpg import vfs from parpg.gui.filebrowser import FileBrowser from parpg.gui.menus import ContextMenu, SettingsMenu -from parpg.gui import inventorygui from parpg.gui.popups import ExaminePopup from parpg.gui.containergui import ContainerGUI from parpg.gui.dialoguegui import DialogueGUI from parpg.gui import drag_drop_data as data_drag +from parpg.gui.inventorygui import InventoryGUI from actionsbox import ActionsBox logger = logging.getLogger('hud') @@ -46,12 +47,15 @@ @return: None""" # TODO: perhaps this should not be hard-coded here + self.settings = settings pychan.registerWidget(ActionsBox) - self.hud = pychan.loadXML("gui/hud.xml") + + xml_file = vfs.VFS.open('gui/hud.xml') + self.hud = pychan.loadXML(xml_file) + self.controller = controller self.engine = controller.engine self.model = controller.model - self.settings = settings self.inventory = None self.character_screen = None @@ -152,9 +156,8 @@ def initializeInventory(self): """Initialize the inventory""" if not self.inventory: - self.inventory = inventorygui.InventoryGUI(self.controller, - None, - None) + xml_file = vfs.VFS.open('gui/inventory.xml') + self.inventory = InventoryGUI(self.controller, xml_file, None) # inv_callbacks = { # 'refreshReadyImages': self.refreshReadyImages, # 'toggleInventoryButton': self.toggleInventoryButton, @@ -173,13 +176,13 @@ """Initialize the character screen.""" # TODO Technomage 2010-12-24: if not self.character_screen: - self.character_screen = pychan.loadXML('gui/character_screen.xml') - + xml_file = vfs.VFS.open('gui/character_screen.xml') + self.character_screen = pychan.loadXML(xml_file) def initializeContextMenu(self): """Initialize the Context Menu @return: None""" - self.context_menu = ContextMenu (self.engine, [], (0, 0)) + self.context_menu = ContextMenu(self.engine, [], (0, 0)) def showContextMenu(self, data, pos): """Display the Context Menu with model at pos @@ -199,7 +202,10 @@ def initializeMainMenu(self): """Initalize the main menu. @return: None""" - self.main_menu = pychan.loadXML("gui/hud_pause_menu.xml") + + xml_file = vfs.VFS.open('gui/hud_pause_menu.xml') + self.main_menu = pychan.loadXML(xml_file) + #TODO: find more suitalbe place for onOptilonsPress implementation self.menu_events = {"resumeButton": self.hideMenu, "settingsButton": self.displaySettings, @@ -237,7 +243,10 @@ def initializeHelpMenu(self): """Initialize the help menu @return: None""" - self.help_dialog = pychan.loadXML("gui/help.xml") + + xml_file = vfs.VFS.open('gui/help.xml') + self.help_dialog = pychan.loadXML(xml_file) + help_events = {"closeButton":self.help_dialog.hide} self.help_dialog.mapEvents(help_events) main_help_text = u"Welcome to Post-Apocalyptic RPG or PARPG![br][br]"\ @@ -273,9 +282,7 @@ """ Called when the user wants to save the game. @return: None""" self.stopActions() - xml_path = os.path.join(self.settings.system_path, - self.settings.parpg.GuiPath, - 'savebrowser.xml') + xml_path = 'gui/savebrowser.xml' save_browser = FileBrowser(self.engine, self.settings, self.save_game_callback, @@ -318,9 +325,7 @@ """ Called when the user wants to load a game. @return: None""" self.stopActions() - xml_path = os.path.join(self.settings.system_path, - self.settings.parpg.GuiPath, - 'loadbrowser.xml') + xml_path = 'gui/loadbrowser.xml' load_browser = FileBrowser(self.engine, self.settings, self.load_game_callback, @@ -380,13 +385,15 @@ def toggleInventory(self, toggle_image=True): """Displays the inventory screen @return: None""" - if self.inventory == None: + if self.inventory is None: self.initializeInventory() + self.inventory.toggleInventory(toggle_image) def toggleCharacterScreen(self): - if not self.character_screen: + if self.characcter_screen is None: self.initializeCharacterScreen() + if not self.character_screen.isVisible(): self.character_screen.show() else: