ScummVM API documentation
ultima0.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 ULTIMA0_H
23#define ULTIMA0_H
24
25#include "common/random.h"
26#include "common/serializer.h"
27#include "graphics/palette.h"
28#include "engines/engine.h"
29#include "ultima/detection.h"
30#include "ultima/ultima0/data/data.h"
31#include "ultima/ultima0/events.h"
32#include "ultima/ultima0/music.h"
33
34namespace Ultima {
35namespace Ultima0 {
36
37class Ultima0Engine : public Engine, public Events {
38private:
39 Common::RandomSource _randomSource;
40 //const UltimaGameDescription *_gameDescription;
41
42 void syncSavegame(Common::Serializer &s);
43
44protected:
45 // Engine APIs
46 Common::Error run() override;
47
48public:
49 Graphics::Palette _palette;
50 PlayerInfo _player;
51 WorldMapInfo _worldMap;
52 DungeonMapInfo _dungeon;
53 bool _showMinimap = false;
54 MusicPlayer *_music = nullptr;
55
57 ~Ultima0Engine() override;
58
62 bool shouldQuit() const override {
63 return Engine::shouldQuit();
64 }
65
69 bool hasFeature(EngineFeature f) const override;
70
74 void setRandomSeed(uint seed) {
75 _randomSource.setSeed(seed);
76 }
77
81 uint getRandomNumber(uint maxVal = RND_MAX) { return _randomSource.getRandomNumber(maxVal); }
82 uint getRandomNumber(uint minVal, uint maxVal) {
83 return _randomSource.getRandomNumber(maxVal - minVal) + minVal;
84 }
85
89 bool isEnhanced() const {
90 return true;
91 }
92
96 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
97 return true;
98 }
99
103 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
104
111
118 Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
119
123 bool savegamesExist() const;
124
125 void playMidi(const char *name);
126 void stopMidi();
127 bool isMidiPlaying() const {
128 return _music != nullptr;
129 }
130};
131
132extern Ultima0Engine *g_engine;
133
134} // End of namespace Ultima4
135} // End of namespace Ultima
136
137#endif
Definition: error.h:81
Definition: random.h:44
void setSeed(uint32 seed)
uint getRandomNumber(uint max)
Definition: stream.h:745
Definition: serializer.h:80
Definition: ustr.h:57
Definition: stream.h:77
Definition: engine.h:149
static bool shouldQuit()
EngineFeature
Definition: engine.h:282
Simple class for handling a palette data.
Definition: palette.h:61
Definition: system.h:166
Definition: events.h:281
Definition: music.h:32
Definition: ultima0.h:37
Common::Error run() override
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
bool isEnhanced() const
Definition: ultima0.h:89
void setRandomSeed(uint seed)
Definition: ultima0.h:74
uint getRandomNumber(uint maxVal=RND_MAX)
Definition: ultima0.h:81
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: ultima0.h:96
bool hasFeature(EngineFeature f) const override
bool shouldQuit() const override
Definition: ultima0.h:62
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Engine * g_engine
Definition: data.h:69
Definition: data.h:92
Definition: data.h:135
Definition: detection.h:65