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 
34 namespace Ultima {
35 namespace Ultima0 {
36 
37 class Ultima0Engine : public Engine, public Events {
38 private:
39  Common::RandomSource _randomSource;
40  //const UltimaGameDescription *_gameDescription;
41 
42  void syncSavegame(Common::Serializer &s);
43 
44 protected:
45  // Engine APIs
46  Common::Error run() override;
47 
48 public:
49  Graphics::Palette _palette;
50  PlayerInfo _player;
51  WorldMapInfo _worldMap;
52  DungeonMapInfo _dungeon;
53  bool _showMinimap = false;
54  MusicPlayer *_music = nullptr;
55 
56  Ultima0Engine(OSystem *syst, const Ultima::UltimaGameDescription *gameDesc);
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 
132 extern Ultima0Engine *g_engine;
133 
134 } // End of namespace Ultima4
135 } // End of namespace Ultima
136 
137 #endif
EngineFeature
Definition: engine.h:258
Definition: stream.h:77
Definition: error.h:81
void setRandomSeed(uint seed)
Definition: ultima0.h:74
Definition: random.h:44
Definition: data.h:92
bool hasFeature(EngineFeature f) const override
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: data.h:69
uint getRandomNumber(uint max)
Common::Error run() override
Definition: stream.h:745
Definition: detection.h:65
Definition: events.h:281
bool shouldQuit() const override
Definition: ultima0.h:62
Engine * g_engine
Definition: serializer.h:79
Definition: detection.h:27
bool isEnhanced() const
Definition: ultima0.h:89
Definition: ustr.h:57
Definition: data.h:135
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: ultima0.h:96
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
static bool shouldQuit()
uint getRandomNumber(uint maxVal=RND_MAX)
Definition: ultima0.h:81
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
void setSeed(uint32 seed)
Definition: system.h:163
Simple class for handling a palette data.
Definition: palette.h:55
Definition: ultima0.h:37
Definition: engine.h:144
Definition: music.h:32