ScummVM API documentation
gameloader.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 #ifndef NGI_GAMELOADER_H
23 #define NGI_GAMELOADER_H
24 
25 #include "common/ptr.h"
26 #include "engines/savestate.h"
27 
28 #include "ngi/objects.h"
29 #include "ngi/inventory.h"
30 #include "ngi/messages.h"
31 
32 namespace NGI {
33 
34 #define NGI_SAVEGAME_VERSION 2
35 
36 class SceneTag;
37 class MctlCompound;
38 class InputController;
39 class InteractionController;
40 class MotionController;
41 class MovGraph;
42 
43 class Sc2 : public CObject {
44  public:
45  int16 _sceneId;
46  int16 _field_2;
47  Scene *_scene;
50  Common::Array<int32> _data1; // FIXME, could be a struct
51  PicAniInfoList _defPicAniInfos;
52  PicAniInfoList _picAniInfos;
53  bool _isLoaded;
54  Common::Array<EntranceInfo> _entranceData;
55 
56  public:
57  Sc2();
58  ~Sc2() override;
59  bool load(MfcArchive &file) override;
60 };
61 
63 
64 struct PreloadItem {
65  int preloadId1;
66  int preloadId2;
67  int sceneId;
68  int param;
69 };
70 
71 bool preloadCallback(PreloadItem &pre, int flag);
72 
73 class PreloadItems : public Common::Array<PreloadItem>, public CObject {
74  public:
75  bool load(MfcArchive &file) override;
76 };
77 
79  char id[6];
80  uint8 version;
81  Common::String saveName;
82  Common::String description;
83  uint32 date;
84  uint16 time;
85  uint32 playtime;
86  Graphics::Surface *thumbnail;
87 };
88 
89 struct SaveHeader {
90  int32 version;
91  char magic[32];
92  int32 updateCounter;
93  int32 unkField;
94  int32 encSize;
95 };
96 
97 class GameLoader : public CObject {
98  public:
99  GameLoader();
100  ~GameLoader() override;
101 
102  bool load(MfcArchive &file) override;
103  bool loadScene(int sceneId);
104  bool gotoScene(int sceneId, int entranceId);
105  bool preloadScene(int sceneId, int entranceId);
106  bool unloadScene(int sceneId);
107 
108  void addPreloadItem(const PreloadItem &item);
109 
110  void updateSystems(int counterdiff);
111 
112  int getSceneTagBySceneId(int sceneId, SceneTag **st);
113  void applyPicAniInfos(Scene *sc, const PicAniInfoList &picAniInfo);
114  void saveScenePicAniInfos(int sceneId);
115  PicAniInfoList savePicAniInfos(Scene *sc, int flag1, int flag2);
116 
117  bool readSavegame(const char *fname);
118  bool writeSavegame(Scene *sc, const char *fname, const Common::String &description);
119 
120  void addVar(GameVar *var, GameVar *subvar);
121 
122  void restoreDefPicAniInfos();
123 
124  Common::ScopedPtr<GameProject> _gameProject;
125  InteractionController *_interactionController;
126  InputController *_inputController;
127  Inventory2 _inventory;
128  Sc2Array _sc2array;
129  void *_sceneSwitcher;
130  bool (*_preloadCallback)(PreloadItem &pre, int flag);
131  void (*_savegameCallback)(MfcArchive *archive, bool mode);
132  int16 _field_F8;
133  int16 _field_FA;
134  PreloadItems _preloadItems;
135  GameVar *_gameVar;
136  Common::String _gameName;
137  ExCommand _exCommand;
138  int _updateCounter;
139  int _preloadSceneId;
140  int _preloadEntranceId;
141 };
142 
143 const char *getSavegameFile(int saveGameIdx);
144 WARN_UNUSED_RESULT bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header, bool skipThumbnail = true);
145 void parseSavegameHeader(NGI::FullpipeSavegameHeader &header, SaveStateDescriptor &desc);
146 
147 Inventory2 *getGameLoaderInventory();
148 InteractionController *getGameLoaderInteractionController();
149 MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId);
150 MovGraph *getSc2MovGraphBySceneId(int16 sceneId);
151 MctlCompound *getCurrSceneSc2MotionController();
152 
153 } // End of namespace NGI
154 
155 #endif /* NGI_GAMELOADER_H */
Definition: str.h:59
Definition: surface.h:66
Definition: utils.h:39
Definition: gameloader.h:64
Definition: scene.h:97
Definition: gameloader.h:43
Definition: inventory.h:82
MotionController * _motionController
Definition: gameloader.h:49
Definition: stream.h:745
Definition: ptr.h:572
Definition: gameloader.h:78
Definition: savestate.h:56
Definition: input.h:46
Definition: gameloader.h:97
Definition: gameloader.h:73
Definition: interaction.h:63
Definition: gameloader.h:89
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: motion.h:39
Definition: objects.h:76
Definition: motion.h:94
Definition: messages.h:59
Definition: scene.h:32
Definition: anihandler.h:25
Definition: utils.h:106
Definition: motion.h:270