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
36namespace MM {
37namespace MM1 {
38
39class MM1Engine : public MMEngine, public Events {
40private:
41 // Engine APIs
42 Common::Error run() override;
43
44 void setupNormal();
45 bool setupEnhanced();
46protected:
50 bool shouldQuit() const override {
51 return MMEngine::shouldQuit();
52 }
53
54public:
55 Globals _globals;
56 Sound *_sound = nullptr;
57public:
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
108 Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
109};
110
111extern MM1Engine *g_engine;
112
113} // namespace MM1
114} // namespace MM
115
116#endif
Definition: error.h:81
uint getRandomNumber(uint max)
Definition: stream.h:745
Definition: serializer.h:80
Definition: str.h:59
Definition: ustr.h:57
Definition: stream.h:77
static bool shouldQuit()
const Common::String _targetName
Definition: engine.h:186
Definition: events.h:268
Definition: globals.h:44
Definition: mm1.h:39
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
int getRandomNumber(int minNumber, int maxNumber)
Definition: mm1.h:66
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
void syncSoundSettings() override
bool shouldQuit() const override
Definition: mm1.h:50
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error synchronizeSave(Common::Serializer &s)
Definition: sound.h:37
Definition: mm.h:37
Definition: system.h:166
Definition: detection.h:27
Definition: detection.h:43