ScummVM API documentation
qdengine.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 QDENGINE_H
23 #define QDENGINE_H
24 
25 #include "common/error.h"
26 #include "common/random.h"
27 #include "common/serializer.h"
28 #include "engines/engine.h"
29 #include "graphics/pixelformat.h"
30 
31 #include "qdengine/qd_fwd.h"
32 #include "qdengine/parser/qdscr_parser.h"
33 #include "qdengine/qdcore/qd_screen_text.h"
34 
35 struct ADGameDescription;
36 
37 namespace Graphics {
38 class Screen;
39 }
40 
41 namespace QDEngine {
42 
43 struct QDEngineGameDescription;
44 class grDispatcher;
45 class qdGameDispatcher;
46 
47 enum QDEngineDebugChannels {
48  kDebugGraphics = 1,
49  kDebugImGui,
50  kDebugInput,
51  kDebugLoad,
52  kDebugLog,
53  kDebugSave,
54  kDebugSound,
55  kDebugTemp,
56  kDebugQuant,
57  kDebugMinigames,
58  kDebugMovement,
59  kDebugText,
60  kDebug16BppMode,
61 };
62 
63 enum {
64  GF_BROKEN_VIDEOS = 1
65 };
66 
67 class QDEngineEngine : public Engine {
68 private:
69  const ADGameDescription *_gameDescription;
70  Common::RandomSource _randomSource;
71 
72  grDispatcher *_grD = nullptr;
73  qdGameDispatcher *_gameD = nullptr;
74 
75 protected:
76  // Engine APIs
77  Common::Error run() override;
78 
79 public:
80  Graphics::Screen *_screen = nullptr;
81  Graphics::PixelFormat _pixelformat;
82  int _tagMap[QDSCR_MAX_KEYWORD_ID];
83 
84  int _screenW;
85  int _screenH;
86 
87  bool _forceFullRedraw = false;
88 
89 public:
90  QDEngineEngine(OSystem *syst, const ADGameDescription *gameDesc);
91  ~QDEngineEngine() override;
92 
93  uint32 getFeatures() const;
94  Common::Language getLanguage() const;
95 
99  Common::String getGameId() const;
100  Common::String getTargetName() const { return _targetName; }
101 
102  const char *getExeName() const;
103 
107  uint32 getRandomNumber(uint maxNum) {
108  return _randomSource.getRandomNumber(maxNum);
109  }
110 
111  void setSeed(uint32 seed) {
112  _randomSource.setSeed(seed);
113  }
114 
115  bool hasFeature(EngineFeature f) const override {
116  return
117  (f == kSupportsLoadingDuringRuntime) ||
118  (f == kSupportsSavingDuringRuntime) ||
119  (f == kSupportsReturnToLauncher);
120  };
121 
122  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
123  return true;
124  }
125  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override {
126  return true;
127  }
128 
129  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
130  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
131 
132  void syncSoundSettings() override;
133 
134  int engineMain();
135 
136  const Vect2i &screen_offset() {
137  return _screen_offset;
138  }
139  void set_screen_offset(const Vect2i &offset) {
140  _screen_offset = offset;
141  }
142 
143 public:
144  int _thumbSizeX = 0, _thumbSizeY = 0;
145  bool _debugDraw = false;
146  bool _debugDrawGrid = false;
147  bool _debugDrawPath = false;
148  int _gameVersion = 0;
149 
150  Vect2i _screen_offset = Vect2i(0, 0);
151  grScreenRegion _fps_region = grScreenRegion_EMPTY;
152  grScreenRegion _fps_region_last = grScreenRegion_EMPTY;
153  Std::vector<qdGameObject *> _visible_objects;
154 
155  // Default text format
156  qdScreenTextFormat _default_format;
157  // Global format
158  qdScreenTextFormat _global_text_format;
159  // Global format for dialog topics
160  qdScreenTextFormat _global_topic_format;
161 
162 private:
163  void init_graphics();
164 };
165 
166 extern QDEngineEngine *g_engine;
167 #define SHOULD_QUIT ::QDEngine::g_engine->shouldQuit()
168 
169 } // namespace QDEngine
170 
171 byte *transCyrillic(const Common::String &str);
172 
173 #endif // QDENGINE_H
Definition: vector.h:39
Definition: str.h:59
EngineFeature
Definition: engine.h:260
Definition: stream.h:77
Definition: error.h:81
Definition: gr_dispatcher.h:85
Definition: pixelformat.h:138
Definition: advancedDetector.h:164
Definition: random.h:44
bool hasFeature(EngineFeature f) const override
Definition: qdengine.h:115
uint getRandomNumber(uint max)
Definition: atari-screen.h:58
Definition: stream.h:745
Definition: screen.h:48
Обозначает отсутствие шрифта
Definition: qd_screen_text.h:39
Engine * g_engine
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: qdengine.h:125
Definition: ustr.h:57
Базовый класс для игровых ресурсов.
Definition: console.h:28
Definition: xmath.h:268
uint32 getRandomNumber(uint maxNum)
Definition: qdengine.h:107
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: qdengine.h:122
Definition: formatinfo.h:28
Definition: qdengine.h:67
Definition: qd_game_dispatcher.h:43
Прямоугольная область на экране.
Definition: gr_screen_region.h:31
void setSeed(uint32 seed)
Definition: system.h:163
Definition: engine.h:146
Language
Definition: language.h:45