ScummVM API documentation
neverhood.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 NEVERHOOD_NEVERHOOD_H
23 #define NEVERHOOD_NEVERHOOD_H
24 
25 #include "common/scummsys.h"
26 #include "common/events.h"
27 #include "common/keyboard.h"
28 #include "common/random.h"
29 #include "common/savefile.h"
30 #include "common/str-array.h"
31 #include "common/system.h"
32 #include "engines/engine.h"
33 #include "gui/debugger.h"
34 #include "neverhood/console.h"
35 #include "neverhood/messages.h"
36 
37 struct ADGameDescription;
38 
39 namespace Neverhood {
40 
41 class GameModule;
42 class GameVars;
43 class ResourceMan;
44 class Screen;
45 class SoundMan;
46 class AudioResourceMan;
47 class StaticData;
48 struct NPoint;
49 
50 struct GameState {
51  int sceneNum;
52  int which;
53 };
54 
55 struct SubtitleGlyph {
56  byte bitmap[16];
57  byte outline[16];
58 };
59 
60 class NeverhoodEngine : public ::Engine {
61 protected:
62 
63  Common::Error run() override;
64  void mainLoop();
65 
66 public:
67  NeverhoodEngine(OSystem *syst, const ADGameDescription *gameDesc);
68  ~NeverhoodEngine() override;
69 
70  // Detection related functions
71  const ADGameDescription *_gameDescription;
72  const char *getGameId() const;
73  Common::Platform getPlatform() const;
74  Common::Language getLanguage() const;
75  bool hasFeature(EngineFeature f) const override;
76  bool isDemo() const;
77  bool isBigDemo() const;
78  bool applyResourceFixes() const;
79  Common::String getTargetName() { return _targetName; };
80 
82 
83  int16 _mouseX, _mouseY;
84  uint16 _buttonState;
85 
86  GameState _gameState;
87  GameVars *_gameVars;
88  Screen *_screen;
89  ResourceMan *_res;
90  GameModule *_gameModule;
91  StaticData *_staticData;
92 
93  SoundMan *_soundMan;
94  AudioResourceMan *_audioResourceMan;
95 
96 public:
97 
98  /* Save/load */
99 
100  enum kReadSaveHeaderError {
101  kRSHENoError = 0,
102  kRSHEInvalidType = 1,
103  kRSHEInvalidVersion = 2,
104  kRSHEIoError = 3
105  };
106 
107  struct SaveHeader {
108  Common::String description;
109  uint32 version;
110  byte gameID;
111  uint32 flags;
112  uint32 saveDate;
113  uint32 saveTime;
114  uint32 playTime;
115  Graphics::Surface *thumbnail;
116  };
117 
118  bool _isSaveAllowed;
119 
120  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
121  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
122 
123  Common::Error loadGameState(int slot) override;
124  Common::Error saveGameState(int slot, const Common::String &description, bool isAutosave = false) override;
125  Common::Error removeGameState(int slot);
126  bool savegame(const char *filename, const char *description);
127  bool loadgame(const char *filename);
128  Common::String getSaveStateName(int slot) const override;
129  static Common::String getSavegameFilename(const Common::String &target, int num);
130  WARN_UNUSED_RESULT static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *in, SaveHeader &header, bool skipThumbnail = true);
131 
132  GameState& gameState() { return _gameState; }
133  GameModule *gameModule() { return _gameModule; }
134  int16 getMouseX() const { return _mouseX; }
135  int16 getMouseY() const { return _mouseY; }
136  NPoint getMousePos();
137 
138  void toggleSoundUpdate(bool state) { _updateSound = state; }
139  void toggleMusic(bool state) { _enableMusic = state; }
140  bool musicIsEnabled() { return _enableMusic; }
141  bool shouldOffsetFontNhc() const { return _nhcOffsetFont; }
142 
143  const SubtitleGlyph *getSubfont() const {
144  return _haveSubtitles ? _subFont : nullptr;
145  }
146 
147 private:
148  bool _updateSound;
149  bool _enableMusic;
150  bool _nhcOffsetFont;
151 
152  SubtitleGlyph _subFont[256];
153  bool _haveSubtitles;
154 };
155 
156 } // End of namespace Neverhood
157 
158 #endif /* NEVERHOOD_NEVERHOOD_H */
Definition: background.h:30
Definition: staticdata.h:93
Definition: str.h:59
Definition: surface.h:66
EngineFeature
Definition: engine.h:250
Definition: screen.h:64
Definition: error.h:84
Definition: neverhood.h:60
Definition: advancedDetector.h:120
Definition: random.h:44
Definition: default_display_client.h:78
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: neverhood.h:120
Definition: stream.h:745
Definition: ustr.h:57
Definition: resourceman.h:107
Definition: neverhood.h:107
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: neverhood.h:55
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: neverhood.h:121
Definition: system.h:167
Definition: neverhood.h:50
Definition: gamevars.h:173
Definition: gamemodule.h:30
Definition: sound.h:265
Definition: engine.h:143
Platform
Definition: platform.h:46
Definition: sound.h:127
Definition: graphics.h:32
Language
Definition: language.h:45