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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef NEVERHOOD_NEVERHOOD_H
24 #define NEVERHOOD_NEVERHOOD_H
25 
26 #include "common/scummsys.h"
27 #include "common/events.h"
28 #include "common/keyboard.h"
29 #include "common/random.h"
30 #include "common/savefile.h"
31 #include "common/str-array.h"
32 #include "common/system.h"
33 #include "engines/engine.h"
34 #include "gui/debugger.h"
35 #include "neverhood/console.h"
36 #include "neverhood/messages.h"
37 
38 struct ADGameDescription;
39 
40 namespace Neverhood {
41 
42 class GameModule;
43 class GameVars;
44 class ResourceMan;
45 class Screen;
46 class SoundMan;
47 class AudioResourceMan;
48 class StaticData;
49 struct NPoint;
50 
51 struct GameState {
52 	int sceneNum;
53 	int which;
54 };
55 
56 class NeverhoodEngine : public ::Engine {
57 protected:
58 
59 	Common::Error run() override;
60 	void mainLoop();
61 
62 public:
63 	NeverhoodEngine(OSystem *syst, const ADGameDescription *gameDesc);
64 	~NeverhoodEngine() override;
65 
66 	// Detection related functions
67 	const ADGameDescription *_gameDescription;
68 	const char *getGameId() const;
69 	Common::Platform getPlatform() const;
70 	Common::Language getLanguage() const;
71 	bool hasFeature(EngineFeature f) const override;
72 	bool isDemo() const;
73 	bool isBigDemo() const;
74 	bool applyResourceFixes() const;
getTargetName()75 	Common::String getTargetName() { return _targetName; };
76 
77 	Common::RandomSource *_rnd;
78 
79 	int16 _mouseX, _mouseY;
80 	uint16 _buttonState;
81 
82 	GameState _gameState;
83 	GameVars *_gameVars;
84 	Screen *_screen;
85 	ResourceMan *_res;
86 	GameModule *_gameModule;
87 	StaticData *_staticData;
88 
89 	SoundMan *_soundMan;
90 	AudioResourceMan *_audioResourceMan;
91 
92 public:
93 
94 	/* Save/load */
95 
96 	enum kReadSaveHeaderError {
97 		kRSHENoError = 0,
98 		kRSHEInvalidType = 1,
99 		kRSHEInvalidVersion = 2,
100 		kRSHEIoError = 3
101 	};
102 
103 	struct SaveHeader {
104 		Common::String description;
105 		uint32 version;
106 		byte gameID;
107 		uint32 flags;
108 		uint32 saveDate;
109 		uint32 saveTime;
110 		uint32 playTime;
111 		Graphics::Surface *thumbnail;
112 	};
113 
114 	bool _isSaveAllowed;
115 
canLoadGameStateCurrently()116 	bool canLoadGameStateCurrently() override { return _isSaveAllowed; }
canSaveGameStateCurrently()117 	bool canSaveGameStateCurrently() override { return _isSaveAllowed; }
118 
119 	Common::Error loadGameState(int slot) override;
120 	Common::Error saveGameState(int slot, const Common::String &description, bool isAutosave = false) override;
121 	Common::Error removeGameState(int slot);
122 	bool savegame(const char *filename, const char *description);
123 	bool loadgame(const char *filename);
124 	Common::String getSaveStateName(int slot) const override;
125 	static Common::String getSavegameFilename(const Common::String &target, int num);
126 	WARN_UNUSED_RESULT static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *in, SaveHeader &header, bool skipThumbnail = true);
127 
gameState()128 	GameState& gameState() { return _gameState; }
gameModule()129 	GameModule *gameModule() { return _gameModule; }
getMouseX()130 	int16 getMouseX() const { return _mouseX; }
getMouseY()131 	int16 getMouseY() const { return _mouseY; }
132 	NPoint getMousePos();
133 
toggleSoundUpdate(bool state)134 	void toggleSoundUpdate(bool state) { _updateSound = state; }
toggleMusic(bool state)135 	void toggleMusic(bool state) { _enableMusic = state; }
musicIsEnabled()136 	bool musicIsEnabled() { return _enableMusic; }
137 
138 private:
139 	bool _updateSound;
140 	bool _enableMusic;
141 
142 };
143 
144 } // End of namespace Neverhood
145 
146 #endif /* NEVERHOOD_NEVERHOOD_H */
147