ScummVM API documentation
ultima3.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 ULTIMA3_H
23#define ULTIMA3_H
24
25#include "common/scummsys.h"
26#include "common/system.h"
27#include "common/error.h"
28#include "common/ptr.h"
29#include "common/serializer.h"
30#include "common/util.h"
31#include "audio/audiostream.h"
32#include "audio/mixer.h"
33#include "engines/engine.h"
34#include "ultima/detection.h"
35#include "ultima/shared/engine/events.h"
36#include "ultima/ultima3/data/arena.h"
37#include "ultima/ultima3/data/data.h"
38#include "ultima/ultima3/data/dungeon.h"
39#include "ultima/ultima3/data/map.h"
40#include "ultima/ultima3/data/savegame.h"
41#include "ultima/ultima3/gfx/message_log.h"
42#include "ultima/ultima3/gfx/overview.h"
43#include "ultima/ultima3/gfx/screen_effects.h"
44#include "ultima/ultima3/gfx/shapes.h"
45#include "ultima/ultima3/music.h"
46#include "ultima/ultima3/logic/combat_logic.h"
47
48namespace Audio {
49class PCSpeaker;
50}
51
52namespace Ultima {
53namespace Ultima3 {
54
55struct Ultima3GameDescription;
56
57class Ultima3Engine : public Engine, public Shared::Events {
58private:
59 const Ultima::UltimaGameDescription *_gameDescription;
60
64 bool isEnhanced() const;
65
69 void loadOptions();
70
71protected:
72 // Engine APIs
73 Common::Error run() override;
74 void applyGameSettings() override;
75
79 bool shouldQuit() const override {
80 return Engine::shouldQuit();
81 }
82
86 void returnToMainMenu() override;
87
88private:
89 Audio::PCSpeaker *_pcSpeaker = nullptr;
90 bool _pcSpeakerReady = false;
91 Audio::QueuingAudioStream *_effectStream = nullptr;
92 Audio::SoundHandle _effectHandle;
93
94public:
98 void queueEffect(const Common::Array<byte> &samples);
99
105 void queueTone(int divisor, uint32 lengthMs);
106
110 void queueSilence(uint32 lengthMs);
111
116
121 void playSoundEffect(byte effect, byte arg1 = 0, byte arg2 = 0);
122
123 Data::Savegame _savegame;
124 Data::Map _map;
125 Data::Map _worldMap;
126 Data::Dungeon _dungeon;
127 CombatLogic _combat;
128 Gfx::Shapes _shapes;
129 Gfx::MessageLog _messages;
130 Gfx::Overview _overview;
131 Gfx::ScreenEffects _effects;
132 byte _windDirection = 0;
133
134 // How many more turns time is held still for, by powder or a spell
135 byte _holdTime = 0;
136
137 // A full viewport picture shown in place of the dungeon, such as a fountain
138 byte _scene[Data::ARENA_SIZE * Data::ARENA_SIZE] = {};
139 bool _sceneShown = false;
140
141 // Set by the game options that bring in the Ultima III Upgrade's changes to
142 // the monster generation and food rates
143 bool _moreMonsters = false;
144 bool _lessHunger = false;
145 bool _moonIcons = true;
146 bool _timedSounds = false;
147
148 // Plays the Upgrade's MIDI music, if that's been turned on
149 Music _music;
150
151 // Which of the upgrade's renderers is in use
152 Data::RenderMode _renderMode = Data::RENDER_CGA;
153
154 // Toggled in the game by the Volume command
155 bool _soundEnabled = true;
156
157 // Set when a loaded game should continue in the world rather than start it
158 bool _resumeGame = false;
159
160 // Debug flag toggled by the "intangible" console command, allowing
161 // movement through normally impassable terrain
162 bool _intangible = false;
163
165 ~Ultima3Engine() override;
166
167 uint32 getFeatures() const;
168
173
174 bool hasFeature(EngineFeature f) const override {
175 return
179 };
180
181 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
182 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
183
189
190 Common::Error saveGameStream(Common::WriteStream *stream, bool = false) override {
191 Common::Serializer s(nullptr, stream);
192 return syncGame(s);
193 }
195 Common::Serializer s(stream, nullptr);
196 return syncGame(s);
197 }
198
202 bool savegamesExist() const;
203
207 const char *gameViewName() const {
208 return _savegame._location == Data::LOCATION_DUNGEON ? "DungeonMap" : "LocationMap";
209 }
210
214 Graphics::Font *createFont() const override;
215};
216
217extern Ultima3Engine *g_engine;
218#define _G(X) (Ultima3::g_engine->_##X)
219
220} // namespace Ultima3
221} // namespace Ultima
222
223#endif
Definition: pcspk.h:36
Definition: audiostream.h:370
Definition: mixer.h:49
Definition: error.h:81
Definition: stream.h:745
Definition: serializer.h:80
Definition: str.h:59
Definition: ustr.h:57
Definition: stream.h:77
Definition: engine.h:155
static bool shouldQuit()
EngineFeature
Definition: engine.h:293
@ kSupportsReturnToLauncher
Definition: engine.h:307
@ kSupportsSavingDuringRuntime
Definition: engine.h:325
@ kSupportsLoadingDuringRuntime
Definition: engine.h:316
Definition: font.h:83
Definition: system.h:166
Definition: events.h:61
Definition: combat_logic.h:59
Definition: dungeon.h:54
Definition: map.h:55
Definition: message_log.h:39
Definition: overview.h:35
Definition: shapes.h:42
Definition: music.h:57
Definition: ultima3.h:57
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: ultima3.h:194
void queueSilence(uint32 lengthMs)
void returnToMainMenu() override
Graphics::Font * createFont() const override
void queueEffect(const Common::Array< byte > &samples)
Common::String getGameId() const
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
bool hasFeature(EngineFeature f) const override
Definition: ultima3.h:174
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error saveGameStream(Common::WriteStream *stream, bool=false) override
Definition: ultima3.h:190
void applyGameSettings() override
void playSoundEffect(byte effect, byte arg1=0, byte arg2=0)
void queueTone(int divisor, uint32 lengthMs)
Common::Error syncGame(Common::Serializer &s)
const char * gameViewName() const
Definition: ultima3.h:207
Common::Error run() override
bool shouldQuit() const override
Definition: ultima3.h:79
Engine * g_engine
Definition: system.h:39
Definition: savegame.h:42
Definition: screen_effects.h:35
Definition: detection.h:65