ScummVM API documentation
mm1.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 MM1_MM1_H
23 #define MM1_MM1_H
24 
25 #include "common/random.h"
26 #include "common/serializer.h"
27 #include "mm/detection.h"
28 #include "mm/mm.h"
29 #include "mm/mm1/events.h"
30 #include "mm/mm1/globals.h"
31 #include "mm/mm1/sound.h"
32 
36 namespace MM {
37 namespace MM1 {
38 
39 class MM1Engine : public MMEngine, public Events {
40 private:
41  // Engine APIs
42  Common::Error run() override;
43 
44  void setupNormal();
45  bool setupEnhanced();
46 protected:
50  bool shouldQuit() const override {
51  return MMEngine::shouldQuit();
52  }
53 
54 public:
55  Globals _globals;
56  Sound *_sound = nullptr;
57 public:
58  MM1Engine(OSystem *syst, const MightAndMagicGameDescription *gameDesc);
59  ~MM1Engine() override;
60 
61  bool isEnhanced() const;
62 
66  int getRandomNumber(int minNumber, int maxNumber) {
67  return _randomSource.getRandomNumber(maxNumber - minNumber + 1) + minNumber;
68  }
69  int getRandomNumber(int maxNumber) {
70  if (maxNumber < 2)
71  maxNumber = 2;
72 
73  return getRandomNumber(1, maxNumber - 1);
74  }
75 
76  Common::String getTargetName() const {
77  return _targetName;
78  }
79 
83  void syncSoundSettings() override;
84 
88  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
89 
93  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
94 
99 
104  Common::Serializer s(stream, nullptr);
105  return synchronizeSave(s);
106  }
107 
111  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
112  Common::Serializer s(nullptr, stream);
113  return synchronizeSave(s);
114  }
115 };
116 
117 extern MM1Engine *g_engine;
118 
119 } // namespace MM1
120 } // namespace MM
121 
122 #endif
Definition: str.h:59
Definition: stream.h:77
Definition: error.h:84
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: mm.h:37
uint getRandomNumber(uint max)
Definition: stream.h:745
Definition: serializer.h:79
bool shouldQuit() const override
Definition: mm1.h:50
int getRandomNumber(int minNumber, int maxNumber)
Definition: mm1.h:66
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: mm1.h:103
Definition: ustr.h:57
Definition: globals.h:43
static bool shouldQuit()
Definition: sound.h:35
Definition: events.h:261
Definition: detection.h:27
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
Definition: mm1.h:111
Definition: detection.h:43
const Common::String _targetName
Definition: engine.h:181
Definition: mm1.h:39
Common::Error synchronizeSave(Common::Serializer &s)
Definition: system.h:161
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
void syncSoundSettings() override