ScummVM API documentation
nancy.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 NANCY_H
23 #define NANCY_H
24 
25 #include "common/file.h"
26 #include "common/str.h"
27 #include "common/ptr.h"
28 
29 #include "engines/engine.h"
30 
31 #include "nancy/detection.h"
32 #include "nancy/time.h"
33 #include "nancy/commontypes.h"
34 #include "nancy/enginedata.h"
35 
36 namespace Common {
37 class RandomSource;
38 class Serializer;
39 }
40 
55 namespace Nancy {
56 
57 static const int kSavegameVersion = 4;
58 
59 struct NancyGameDescription;
60 
61 class ResourceManager;
62 class IFF;
63 class InputManager;
64 class SoundManager;
65 class GraphicsManager;
66 class CursorManager;
67 class NancyConsole;
68 class DeferredLoader;
69 
70 namespace State {
71 class State;
72 }
73 
74 class NancyEngine : public Engine {
75 public:
76  NancyEngine(OSystem *syst, const NancyGameDescription *gd);
77  ~NancyEngine();
78 
79  static NancyEngine *create(GameType type, OSystem *syst, const NancyGameDescription *gd);
80 
81  void errorString(const char *buf_input, char *buf_output, int buf_output_size) override;
82  bool hasFeature(EngineFeature f) const override;
83 
84  Common::Error loadGameState(int slot) override;
85  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
86  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
87  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
88  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
89 
90  void secondChance();
91 
92  const char *getCopyrightString() const;
93  uint32 getGameFlags() const;
94  const char *getGameId() const;
95  GameType getGameType() const;
96  Common::Language getGameLanguage() const;
97  Common::Platform getPlatform() const;
98 
99  const StaticData &getStaticData() const;
100  const EngineData *getEngineData(const Common::String &name) const;
101 
102  void setState(NancyState::NancyState state, NancyState::NancyState overridePrevious = NancyState::kNone);
103  NancyState::NancyState getState() { return _gameFlow.curState; }
104  void setToPreviousState();
105 
106  void setMouseEnabled(bool enabled);
107 
108  void addDeferredLoader(Common::SharedPtr<DeferredLoader> &loaderPtr);
109 
110  // The first few games used 1/2 for false/true in
111  // inventory, logic conditions, and event flags
112  const byte _true;
113  const byte _false;
114 
115  // Managers
116  ResourceManager *_resource;
117  GraphicsManager *_graphics;
118  CursorManager *_cursor;
119  InputManager *_input;
120  SoundManager *_sound;
121 
122  Common::RandomSource *_randomSource;
123 
124  // Used to check whether we need to show the SaveDialog
125  bool _hasJustSaved;
126 
127 protected:
128  Common::Error run() override;
129  void pauseEngineIntern(bool pause) override;
130 
131 private:
132  struct GameFlow {
133  NancyState::NancyState curState = NancyState::kNone;
134  NancyState::NancyState prevState = NancyState::kNone;
135  NancyState::NancyState nextState = NancyState::kNone;
136  bool changingState = true;
137  };
138 
139  void bootGameEngine();
140 
141  State::State *getStateObject(NancyState::NancyState state) const;
142  void destroyState(NancyState::NancyState state) const;
143 
144  void preloadCals();
145  void readDatFile();
146 
147  Common::Error synchronize(Common::Serializer &serializer);
148 
149  bool isCompressed();
150 
151  StaticData _staticData;
153 
154  const byte _datFileMajorVersion;
155  const byte _datFileMinorVersion;
156 
157  GameFlow _gameFlow;
158  OSystem *_system;
159 
160  const NancyGameDescription *_gameDescription;
161 
162  Common::Array<Common::WeakPtr<DeferredLoader>> _deferredLoaderObjects;
163 };
164 
165 extern NancyEngine *g_nancy;
166 #define GetEngineData(s) (const s*)g_nancy->getEngineData(#s);
167 
168 } // End of namespace Nancy
169 
170 #endif // NANCY_H
Definition: commontypes.h:322
Definition: nancy.h:74
Definition: str.h:59
EngineFeature
Definition: engine.h:258
Definition: stream.h:77
Definition: error.h:81
Definition: array.h:52
Definition: cursor.h:32
Definition: graphics.h:36
Definition: random.h:44
Definition: stream.h:745
Definition: serializer.h:80
Definition: detection.h:73
Definition: hashmap.h:85
Definition: ustr.h:57
Definition: input.h:70
Definition: algorithm.h:29
Definition: sound.h:44
Definition: state.h:32
Definition: graphics.h:38
Definition: resource.h:36
Definition: enginedata.h:35
Definition: system.h:165
Definition: ptr.h:159
Definition: engine.h:144
Platform
Definition: platform.h:93
Definition: actionmanager.h:32
Language
Definition: language.h:45