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