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