comparison charactercreationcontroller.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 708a6f651c31
comparison
equal deleted inserted replaced
1:4912a6f97c52 2:06145a6ee387
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 controller that defines the behaviour of the character creation 15 """Provides the controller that defines the behaviour of the character creation
16 screen.""" 16 screen."""
17 17
18 from parpg import vfs
18 import characterstatistics as char_stats 19 import characterstatistics as char_stats
19 from serializers import XmlSerializer 20 from serializers import XmlSerializer
20 from controllerbase import ControllerBase 21 from controllerbase import ControllerBase
21 from gamescenecontroller import GameSceneController 22 from gamescenecontroller import GameSceneController
22 from gamesceneview import GameSceneView 23 from gamesceneview import GameSceneView
25 DEFAULT_STAT_VALUE = 50 26 DEFAULT_STAT_VALUE = 50
26 27
27 28
28 def getStatCost(offset): 29 def getStatCost(offset):
29 """Gets and returns the cost to increase stat based on the offset""" 30 """Gets and returns the cost to increase stat based on the offset"""
31
30 if offset < 0: 32 if offset < 0:
31 offset *= -1 33 offset *= -1
34
32 if offset < 22: 35 if offset < 22:
33 return 1 36 return 1
34 elif offset < 29: 37 elif offset < 29:
35 return 2 38 return 2
36 elif offset < 32: 39 elif offset < 32:
104 @param application: Application used to glue the various MVC 107 @param application: Application used to glue the various MVC
105 components together. 108 components together.
106 @type application: 109 @type application:
107 L{fife.extensions.basicapplication.ApplicationBase}""" 110 L{fife.extensions.basicapplication.ApplicationBase}"""
108 ControllerBase.__init__(self, engine, view, model, application) 111 ControllerBase.__init__(self, engine, view, model, application)
112 self.settings = self.model.settings
109 self.view.start_new_game_callback = self.startNewGame 113 self.view.start_new_game_callback = self.startNewGame
110 self.view.cancel_new_game_callback = self.cancelNewGame 114 self.view.cancel_new_game_callback = self.cancelNewGame
111 self.view.show() 115 self.view.show()
112 #TODO: Maybe this should not be hardcoded 116 # FIXME M. George Hansen 2011-06-06: character stats scripts aren't
113 stream = file("character_scripts/primary_stats.xml") 117 # finished, unfortunately.
114 prim_stats = XmlSerializer.deserialize(stream) 118 # primary_stats_file = \
115 stream = file("character_scripts/secondary_stats.xml") 119 # vfs.VFS.open('character_scripts/primary_stats.xml')
116 sec_stats = XmlSerializer.deserialize(stream) 120 # primary_stats = XmlSerializer.deserialize(primary_stats_file)
117 self.char_data = SimpleCharacter("", 121 # secondary_stats_file = \
118 self.GENDERS[0], 122 # vfs.VFS.open('character_scripts/secondary_stats.xml')
119 self.ORIGINS.keys()[0], 123 # secondary_stats = XmlSerializer.deserialize(secondary_stats_file)
120 20, 124 primary_stats = []
121 self.PICTURES[self.GENDERS[0]][0], 125 secondary_stats = []
122 [], 126 self.char_data = SimpleCharacter(
123 prim_stats, 127 "",
124 sec_stats, 128 self.GENDERS[0],
125 Inventory()) 129 self.ORIGINS.keys()[0],
130 20,
131 self.PICTURES[self.GENDERS[0]][0],
132 [],
133 primary_stats,
134 secondary_stats,
135 Inventory()
136 )
126 self._stat_points = 200 137 self._stat_points = 200
127 138
128 139
129 def startNewGame(self): 140 def startNewGame(self):
130 """Create the new character and start a new game. 141 """Create the new character and start a new game.
132 view = GameSceneView(self.engine, self.model) 143 view = GameSceneView(self.engine, self.model)
133 controller = GameSceneController(self.engine, view, self.model, 144 controller = GameSceneController(self.engine, view, self.model,
134 self.application) 145 self.application)
135 self.application.view = view 146 self.application.view = view
136 self.application.switchController(controller) 147 self.application.switchController(controller)
137 start_map = self.model.settings.parpg.Map 148 start_map = self.settings.parpg.Map
138 self.model.changeMap(start_map) 149 self.model.changeMap(start_map)
139 150
140 def cancelNewGame(self): 151 def cancelNewGame(self):
141 """Exit the character creation view and return the to main menu. 152 """Exit the character creation view and return the to main menu.
142 @return: None""" 153 @return: None"""