ScummVM API documentation
project_item.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 TITANIC_PROJECT_ITEM_H
23 #define TITANIC_PROJECT_ITEM_H
24 
25 #include "common/scummsys.h"
26 #include "common/str.h"
27 #include "engines/savestate.h"
28 #include "graphics/surface.h"
29 #include "titanic/support/simple_file.h"
30 #include "titanic/core/dont_save_file_item.h"
31 #include "titanic/core/file_item.h"
32 #include "titanic/core/list.h"
33 #include "titanic/core/room_item.h"
34 
35 namespace Titanic {
36 
38  uint8 _version;
39  CString _saveName;
40  Graphics::Surface *_thumbnail;
41  int _year, _month, _day;
42  int _hour, _minute;
43  int _totalFrames;
44 
46 
50  void clear();
51 };
52 
53 
54 class CGameManager;
55 class CPetControl;
56 class CViewItem;
57 
61 class CFileListItem : public ListItem {
62 public:
63  CString _name;
64 public:
65  CLASSDEF;
66 
70  void save(SimpleFile *file, int indent) override;
71 
75  void load(SimpleFile *file) override;
76 };
77 
81 class CFileList: public List<CFileListItem> {
82 };
83 
84 class CProjectItem : public CFileItem {
85  DECLARE_MESSAGE_MAP;
86 private:
87  CString _filename;
88  CFileList _files;
89  int _nextRoomNumber;
90  int _nextMessageNumber;
91  int _nextObjectNumber;
92  CGameManager *_gameManager;
93 
97  void buildFilesList();
98 
102  void preLoad();
103 
107  void postLoad();
108 
112  void preSave();
113 
117  void postSave();
118 
122  CTreeItem *findChildInstance(ClassDef *classDef) const;
123 
127  CTreeItem *findSiblingChildInstanceOf(ClassDef *classDef, CTreeItem *startItem) const;
128 private:
132  CProjectItem *loadData(SimpleFile *file);
133 
137  void saveData(SimpleFile *file, CTreeItem *item) const;
138 
143 public:
147  static SaveStateList getSavegameList(const MetaEngine *metaEngine, const Common::String &target);
148 
152  static void writeSavegameHeader(SimpleFile *file, TitanicSavegameHeader &header);
153 
157  WARN_UNUSED_RESULT static bool readSavegameHeader(SimpleFile *file, TitanicSavegameHeader &header, bool skipThumbnail = true);
158 public:
159  CLASSDEF;
160  CProjectItem();
161  ~CProjectItem() override { destroyChildren(); }
162 
166  void save(SimpleFile *file, int indent) override;
167 
171  void load(SimpleFile *file) override;
172 
176  CGameManager *getGameManager() const override;
177 
181  void setGameManager(CGameManager *gameManager);
182 
186  CPetControl *getPetControl() const;
187 
191  void resetGameManager();
192 
196  void loadGame(int slotId);
197 
201  void saveGame(int slotId, const CString &desc);
202 
206  void clear();
207 
211  void setFilename(const CString &name) { _filename = name; }
212 
216  CRoomItem *findFirstRoom() const;
217 
221  CRoomItem *findNextRoom(CRoomItem *priorRoom) const;
222 
226  CDontSaveFileItem *getDontSaveFileItem() const;
227 
231  CRoomItem *findHiddenRoom();
232 
236  CViewItem *findView(int roomNumber, int nodeNumber, int viewNumber);
237 
242  CViewItem *parseView(const CString &viewString);
243 
247  bool changeView(const CString &viewName, const CString &clipName);
248 
252  bool changeView(const CString &viewName);
253 };
254 
255 } // End of namespace Titanic
256 
257 #endif /* TITANIC_PROJECT_ITEM_H */
Definition: metaengine.h:196
Definition: project_item.h:37
Definition: str.h:59
Definition: file_item.h:31
Definition: surface.h:67
Definition: dont_save_file_item.h:29
Definition: list.h:35
Definition: simple_file.h:49
Definition: saveable_object.h:35
Definition: room_item.h:33
Definition: project_item.h:61
Definition: project_item.h:81
Definition: tree_item.h:37
Definition: game_manager.h:48
bool createThumbnail(Graphics::Surface &thumb)
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: list.h:71
Definition: arm.h:30
Definition: string.h:40
Definition: project_item.h:84
void setFilename(const CString &name)
Definition: project_item.h:211
Definition: pet_control.h:45
Definition: view_item.h:32