Mercurial > parpg-source
comparison gamemap.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 |
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 | 15 |
16 from fife import fife | 16 from fife import fife |
17 | |
18 from fife.extensions.loaders import loadMapFile | 17 from fife.extensions.loaders import loadMapFile |
19 | 18 |
20 class GameMap(fife.MapChangeListener): | 19 class GameMap(fife.MapChangeListener): |
21 """Map class used to flag changes in the map""" | 20 """Map class used to flag changes in the map""" |
22 def __init__(self, engine, model): | 21 def __init__(self, engine, model): |
23 # init mapchange listener | 22 # init mapchange listener |
24 fife.MapChangeListener.__init__(self) | 23 fife.MapChangeListener.__init__(self) |
25 self.map = None | 24 self.map = None |
26 self.engine = engine | 25 self.engine = engine |
27 self.model = model | 26 self.model = model |
27 self.settings = self.model.settings | |
28 | 28 |
29 # init map attributes | 29 # init map attributes |
30 self.my_cam_id = None | 30 self.my_cam_id = None |
31 self.cameras = {} | 31 self.cameras = {} |
32 self.agent_layer = None | 32 self.agent_layer = None |
44 @return: None""" | 44 @return: None""" |
45 # We have to delete the map in Fife. | 45 # We have to delete the map in Fife. |
46 if self.map: | 46 if self.map: |
47 self.model.deleteObjects() | 47 self.model.deleteObjects() |
48 self.model.deleteMap(self.map) | 48 self.model.deleteMap(self.map) |
49 | |
49 self.transitions = [] | 50 self.transitions = [] |
50 self.map = None | 51 self.map = None |
51 self.agent_layer = None | 52 self.agent_layer = None |
52 self.top_layer = None | 53 self.top_layer = None |
53 # We have to clear the cameras in the view as well, or we can't reuse | 54 # We have to clear the cameras in the view as well, or we can't reuse |
69 """Load a map given the filename. | 70 """Load a map given the filename. |
70 @type filename: String | 71 @type filename: String |
71 @param filename: Name of map to load | 72 @param filename: Name of map to load |
72 @return: None""" | 73 @return: None""" |
73 self.reset() | 74 self.reset() |
75 | |
74 self.map = loadMapFile(filename, self.engine) | 76 self.map = loadMapFile(filename, self.engine) |
77 | |
75 self.agent_layer = self.map.getLayer('ObjectLayer') | 78 self.agent_layer = self.map.getLayer('ObjectLayer') |
76 self.top_layer = self.map.getLayer('TopLayer') | 79 self.top_layer = self.map.getLayer('TopLayer') |
77 | 80 |
78 # it's possible there's no transition layer | 81 # it's possible there's no transition layer |
79 size = len('TransitionLayer') | 82 size = len('TransitionLayer') |
86 Note that if we have more than one camera in a map file | 89 Note that if we have more than one camera in a map file |
87 we will have to rework how self.my_cam_id works. To make sure | 90 we will have to rework how self.my_cam_id works. To make sure |
88 the proper camera is set as the 'main' camera. | 91 the proper camera is set as the 'main' camera. |
89 At this point we also set the viewport to the current resolution.""" | 92 At this point we also set the viewport to the current resolution.""" |
90 for cam in self.map.getCameras(): | 93 for cam in self.map.getCameras(): |
91 width = self.model.settings.fife.ScreenWidth | 94 width = self.settings.fife.ScreenWidth |
92 height = self.model.settings.fife.ScreenHeight | 95 height = self.settings.fife.ScreenHeight |
93 viewport = fife.Rect(0, 0, width, height) | 96 viewport = fife.Rect(0, 0, width, height) |
94 cam.setViewPort(viewport) | 97 cam.setViewPort(viewport) |
95 self.my_cam_id = cam.getId() | 98 self.my_cam_id = cam.getId() |
96 self.cameras[self.my_cam_id] = cam | 99 self.cameras[self.my_cam_id] = cam |
97 cam.resetRenderers() | 100 cam.resetRenderers() |
106 | 109 |
107 # set the render text | 110 # set the render text |
108 rend = fife.FloatingTextRenderer.getInstance(self.cameras[ | 111 rend = fife.FloatingTextRenderer.getInstance(self.cameras[ |
109 self.my_cam_id | 112 self.my_cam_id |
110 ]) | 113 ]) |
111 text = self.engine.getGuiManager().\ | 114 text = self.engine.getGuiManager().createFont('fonts/rpgfont.png', |
112 createFont('fonts/rpgfont.png', 0, \ | 115 0, |
113 self.model.settings.fife.FontGlyphs) | 116 self.settings.fife.FontGlyphs) |
117 | |
114 rend.changeDefaultFont(text) | 118 rend.changeDefaultFont(text) |
115 rend.activateAllLayers(self.map) | 119 rend.activateAllLayers(self.map) |
116 rend.setEnabled(True) | 120 rend.setEnabled(True) |
117 | 121 |
118 # Activate the grid renderer on all layers | 122 # Activate the grid renderer on all layers |