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