22#ifndef QDENGINE_MINIGAMES_ADV_RUNTIME_H
23#define QDENGINE_MINIGAMES_ADV_RUNTIME_H
25#include "common/hashmap.h"
27#include "qdengine/minigames/adv/common.h"
30class SeekableReadStream;
31class SeekableWriteStream;
36class qdEngineInterface;
37class qdMinigameSceneInterface;
39class MinigameInterface;
73 static int version() {
77 return _empty && _game._sequenceIndex < 0;
95 friend class TempValue;
116 bool mouseLeftPressed()
const;
117 bool mouseRightPressed()
const;
118 bool keyPressed(
int vKey,
bool once =
false)
const;
123 float getTime()
const {
127 GameInfo *getCurrentGameInfo()
const {
return _currentGameInfo; };
128 const MinigameData *getScore(
int level,
int game)
const;
130 bool debugMode()
const {
134 TextManager &textManager()
const {
135 return *_textManager;
138 void signal(SystemEvent
id);
139 void event(
int eventID,
const mgVect2f& pos,
int factor = 1);
140 void event(
int eventID,
const mgVect2i& pos,
int factor = 1) {
141 event(eventID, mgVect2f(pos.x, pos.y), factor);
145 void setCompleteHelpVariant(
int idx);
147 void setGameHelpVariant(
int idx);
150 const char *parameter(
const char *name,
bool required =
true)
const;
151 const char *parameter(
const char *name,
const char *def)
const;
154 mgVect3f game2world(
const mgVect3i &coord)
const;
155 mgVect3f game2world(
const mgVect3f &coord)
const;
156 mgVect3f game2world(
const mgVect2i &coord,
int depth = 0)
const;
157 mgVect3f game2world(
const mgVect2f &coord,
int depth = 0)
const;
159 mgVect2f world2game(
const mgVect3f& pos)
const;
160 mgVect3f world2game(qdMinigameObjectInterface *obj)
const;
162 mgVect2f getSize(qdMinigameObjectInterface *obj)
const;
165 void setDepth(qdMinigameObjectInterface *obj,
int depth)
const;
167 float getDepth(qdMinigameObjectInterface *obj)
const;
169 float getDepth(
const mgVect3f& pos)
const;
172 QDObject getObject(
const char *name)
const;
174 bool testObject(
const char *name)
const;
176 void release(QDObject& obj);
179 void setText(
const char *name,
const char *text)
const;
180 void setText(
const char *name,
int toText,
const char *format =
"%d")
const;
183 void hide(qdMinigameObjectInterface *obj)
const;
186 float rnd(
float min,
float max)
const;
187 int rnd(
int min,
int max)
const;
192 const char *gameListFileName()
const {
193 return "resource/minigames.lst";
196 int getParameter(
const char* name,
const int& defValue);
197 bool getParameter(
const char* name,
int& out,
bool obligatory);
198 float getParameter(
const char* name,
const float &defValue);
199 bool getParameter(
const char* name,
float &out,
bool obligatory);
200 mgVect2f getParameter(
const char* name,
const mgVect2f& defValue);
201 bool getParameter(
const char* name, mgVect2f& out,
bool obligatory);
202 mgVect2i getParameter(
const char* name,
const mgVect2i& defValue);
203 bool getParameter(
const char* name, mgVect2i& out,
bool obligatory);
206 MinigameInterface *_game;
209 TextManager *_textManager;
211 TimeManager *_timeManager;
213 EventManager *_eventManager;
215 EffectManager *_effectManager;
220 mutable bool _lastKeyChecked[256];
222 mgVect2i _screenSize;
226 mgVect2f _mouseAdjast;
229 qdMinigameObjectInterface *_state_flag;
231 qdMinigameObjectInterface *_pause_flag;
233 QDObject _complete_help;
234 QDObject _complete_help_miniature;
239 QDObject _game_help_trigger;
240 bool _game_help_enabled;
245 const qdEngineInterface *_engine;
247 qdMinigameSceneInterface *_scene;
255 bool _invertMouseButtons;
261 Counters _completeCounters;
263 struct GameInfoIndex {
264 GameInfoIndex(
int idx,
int level) : _gameNum(idx), _gameLevel(level) {}
271 bool operator< (
const GameInfoIndex& rs)
const {
272 return _gameLevel == rs._gameLevel ? _gameNum < rs._gameNum : _gameLevel < rs._gameLevel;
276 struct GameInfoIndex_Hash {
277 uint operator()(
const GameInfoIndex& x)
const {
278 return (x._gameNum << 16) + x._gameLevel;
282 struct GameInfoIndex_EqualTo {
283 uint operator()(
const GameInfoIndex& x,
const GameInfoIndex& y)
const {
284 return x._gameNum == y._gameNum && x._gameLevel == y._gameLevel;
290 GameInfoMap _gameInfos;
292 GameInfoIndex _currentGameIndex;
293 GameInfo *_currentGameInfo;
296 bool testAllGamesWin();
304 bool loadState(
bool current =
true);
306 void saveState(
bool force =
false);
309 QDCounter getCounter(
const char *name);
311 void release(QDCounter& counter);
313 MinigameConsCallback _callback =
nullptr;
Definition: MinigameInterface.h:27
bool init(const qdEngineInterface *engine_interface)
Инициализация игры.
bool quant(float dt)
Обсчёт логики игры, параметр - время, которое должно пройти в игре (в секундах).
bool new_game(const qdEngineInterface *engine)
Инициализация миниигры, вызывается при старте и перезапуске игры.
int save_game(const qdEngineInterface *engine, const qdMinigameSceneInterface *scene, char *buffer, int buffer_size)
Сохранение данных, вызывается при сохранении сцены, на которую повешена миниигра.
int load_game(const qdEngineInterface *engine, const qdMinigameSceneInterface *scene, const char *buffer, int buffer_size)
Загрузка данных, вызывается при загрузке сцены, на которую повешена миниигра.
bool finit()
Деинициализация игры.
Definition: qd_minigame_interface.h:365
Definition: qd_minigame_interface.h:78
Интерфейс к сцене.
Definition: qd_minigame_interface.h:315
Definition: algorithm.h:29
Базовый класс для игровых ресурсов.
Definition: console.h:28