ScummVM API documentation
SaveHandler.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of Penumbra Overture.
26  */
27 
28 #ifndef GAME_SAVE_HANDLER_H
29 #define GAME_SAVE_HANDLER_H
30 
31 #include "hpl1/engine/engine.h"
32 
33 using namespace hpl;
34 
35 class cInit;
36 
37 #include "hpl1/penumbra-overture/GameTypes.h"
38 #include "hpl1/penumbra-overture/SaveTypes.h"
39 
41 
42 //---------------------------------------------
43 
45  kSerializableClassInit(cMusic_GlobalSave) public : tString msName;
46  float mfVolume;
47  bool mbLoop;
48 };
49 
50 //---------------------------------------------
51 
53  kSerializableClassInit(cGameMusic_GlobalSave) public : tString msFile;
54  bool mbLoop;
55  float mfVolume;
56 };
57 
59  kSerializableClassInit(cGameMusicHandler_GlobalSave) public : int mlCurrentMaxPrio;
60  bool mbAttackPlaying;
61  bool mbEnemyClosePlaying;
62 
64 };
65 
66 //---------------------------------------------
67 
69  kSerializableClassInit(cNotebookTask_GlobalSave) public : tString msName;
70  tWString msText;
71 };
72 
74  kSerializableClassInit(cNotebookNote_GlobalSave) public : tWString msName;
75  bool mbRead;
76  tString msTextCat;
77  tString msTextEntry;
78 };
79 
81  kSerializableClassInit(cNotebook_GlobalSave) public :
82 
85 };
86 
87 //---------------------------------------------
88 
90  kSerializableClassInit(cInventorySlot_GlobalSave) public : tString msItemName;
91 };
92 
94  kSerializableClassInit(cInventoryItem_GlobalSave) public : tString msName;
95  tWString msGameName;
96  tWString msDescription;
97 
98  tString msSubType;
99 
100  eGameItemType mItemType;
101 
102  tString msEntityFile;
103  tString msGfxObjectFile;
104 
105  tString msHudModelFile;
106  tString msHudModelName;
107 
108  bool mbCanBeDropped;
109  bool mbHasCount;
110  int mlCount;
111 };
112 
114  kSerializableClassInit(cInventory_GlobalSave) public : bool mbNoteBookActive;
115 
118 
120 };
121 
122 //---------------------------------------------
123 
125  kSerializableClassInit(cSceneLoadedMap_GlobalSave) public : tString msName;
126 };
127 
128 //---------------------------------------------
129 
131  kSerializableClassInit(cMapHandlerLoadedMap_GlobalSave) public : tString msName;
132  double mfTime;
133 };
134 
136 
138  kSerializableClassInit(cMapHandlerTimer_GlobalSave) public : tString msName;
139  tString msCallback;
140 
141  bool mbGlobal;
142 
143  float mfTime;
144 
145  bool mbDeleteMe;
146  bool mbPaused;
147 };
148 
150 
152  kSerializableClassInit(cMapHandler_GlobalSave);
153 
154 public:
155  double mfGameTime;
156  tString msCurrentMap;
157 
160 };
161 
162 //---------------------------------------------
163 
165  kSerializableClassInit(cPlayer_GlobalSave_CameraPS);
166 
167 public:
168  tString msName;
169  tString msFile;
170 };
171 
173  kSerializableClassInit(cPlayer_GlobalSave);
174 
175 public:
177  // Stats
178  int mlStat_NumOfSaves;
179 
181  // Global vars
182  float mfForwardUpMul;
183  float mfForwardRightMul;
184 
185  float mfUpMul;
186  float mfRightMul;
187 
188  bool mbPickAtPoint;
189  bool mbRotateWithPlayer;
190  bool mbUseNormalMass;
191 
192  float mfGrabMassMul;
193 
195  // Private
196  bool mbActive;
197 
198  float mfHeightAdd;
199 
200  float mfSpeedMul;
201  float mfHealthSpeedMul;
202 
203  float mfHeadMoveSizeMul;
204  float mfHeadMoveSpeedMul;
205 
206  ePlayerState mState;
207 
208  ePlayerMoveState mMoveState;
209 
210  eCrossHairState mCrossHairState;
211 
212  bool mbItemFlash;
213 
214  float mfHealth;
215 
216  float mfPower;
217 
218  float mfMass;
219 
221 
223  // Lights
224  bool mbFlashlightActive;
225  bool mbFlashlightDisabled;
226  bool mbGlowstickActive;
227  bool mbFlareActive;
228  float mfFlareTime;
229 
231  // Body and Camera Specific
232  cVector3f mvPosition;
233  float mfYaw;
234  float mfPitch;
235 };
236 
237 //---------------------------------------------
238 
239 class cSavedWorld : public iSerializable {
240  kSerializableClassInit_nodestructor(cSavedWorld) public : ~cSavedWorld();
241 
242  void Reset();
243 
244  tString msName;
245  tWString msGameName;
246 
247  // Ambient color
248  cColor mAmbientColor;
249 
250  // Fog
251  bool mbFogActive;
252  float mfFogStartDist;
253  float mfFogEndDist;
254  cColor mFogColor;
255  bool mbFogCulling;
256 
257  // Skybox
258  bool mbSkyboxActive;
259  cColor mSkyboxColor;
260  tString msSkyboxFile;
261 
262  // Script variables
264 
265  // Inventory variables
266  cContainerList<cInventoryUseCallback> mlstUseCallbacks;
267  cContainerList<cInventoryPickupCallback> mlstPickupCallbacks;
268  cContainerList<cInventoryCombineCallback> mlstCombineCallbacks;
269 
270  // Player collider callbacks
272 
273  // Local Timers
274  cContainerList<cGameTimer> mlstTimers;
275 
276  // Entities
278 
279  // Engine types
284 
286 
287  bool PSExists(cParticleSystem3D *apPS);
288  bool BeamExists(cBeam *apPS);
289  bool SoundExists(cSoundEntity *apSound);
290  bool JointExists(iPhysicsJoint *apJoint);
291 };
292 
293 //----------------------------
294 
295 class cSavedGame : public iSerializable {
296  kSerializableClassInit_nodestructor(cSavedGame) public : ~cSavedGame();
297 
298  void Reset();
299  void ResetWorlds();
300  void ResetGlobalData();
301  cSavedWorld *GetSavedWorld(const tString &asName);
302 
303  // Variables:
304  eGameDifficulty mDifficulty;
305 
306  tString msOnRadioEndCallback;
307 
308  cPlayer_GlobalSave mPlayer;
309  cMapHandler_GlobalSave mMapHandler;
310  cInventory_GlobalSave mInventory;
311  cNotebook_GlobalSave mNotebook;
312  cGameMusicHandler_GlobalSave mGameMusicHandler;
313  cMusic_GlobalSave mMusic;
314 
316  cContainerList<cScriptVar> mlstScriptVars;
317 
319 };
320 
321 //----------------------------
322 
323 class cSaveHandler : public iUpdateable {
324 public:
325  cSaveHandler(cInit *apInit);
326  ~cSaveHandler();
327 
328  static cDate parseDate(const Common::String &saveFile);
329 
330  void SaveData(const tString &asName);
331  void LoadData(const tString &asName);
332 
333  void SaveGameToFile(const tWString &asFile);
334  void LoadGameFromFile(const tWString &asFile, bool drawLoadingScreen = true);
335 
336  void AutoSave(const tWString &asDir, int alMaxSaves);
337  void AutoLoad(const tWString &asDir);
338 
339  void ClearSavedMaps();
340 
341  void OnWorldLoad();
342  void OnStart();
343  void Reset();
344 
345  void OnExit();
346 
347  const tWString &GetSaveDir() { return msSaveDir; }
348 
349  void DeleteOldestIfMax(const tWString &asDir, const tWString &asMask, int alMaxFiles);
350  tWString GetLatest(const tWString &asMask);
351 
352 private:
353  cInit *mpInit;
354 
355  cSavedGame *mpSavedGame;
356  tWString msSaveDir;
357 };
358 
359 #endif // GAME_SAVE_HANDLER_H
Definition: AI.h:36
Definition: SaveHandler.h:164
Definition: SaveHandler.h:124
Definition: SaveHandler.h:44
Definition: str.h:59
Definition: SaveHandler.h:323
Definition: SystemTypes.h:154
Definition: SaveHandler.h:68
Definition: SaveHandler.h:89
Definition: SaveHandler.h:113
Definition: SerializeClass.h:230
Definition: SaveHandler.h:93
Definition: GameEntity.h:76
Definition: SaveHandler.h:130
Definition: SaveHandler.h:52
Definition: ustr.h:57
Definition: SaveHandler.h:172
Definition: SaveHandler.h:239
Definition: Container.h:219
Definition: Updateable.h:35
Definition: SaveHandler.h:73
Definition: SaveHandler.h:295
Definition: SaveHandler.h:80
Definition: ParticleSystem3D.h:90
Definition: Color.h:37
Definition: SaveHandler.h:58
Definition: SaveHandler.h:151
Definition: SoundEntity.h:86
Definition: PhysicsJoint.h:135
Definition: SaveHandler.h:137
Definition: Init.h:70
Definition: Beam.h:80