ScummVM API documentation
qd_condition.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_QDCORE_QD_CONDITION_H
23#define QDENGINE_QDCORE_QD_CONDITION_H
24
25#include "qdengine/parser/xml_fwd.h"
26#include "qdengine/qdcore/qd_named_object.h"
27#include "qdengine/qdcore/qd_condition_data.h"
28#include "qdengine/qdcore/qd_condition_object_reference.h"
29
30namespace Common {
31class WriteStream;
32}
33
34namespace QDEngine {
35
36
38
358public:
365
462 };
463
466 OBJECT_NAME = 0,
467 MOUSE_OBJECT_NAME = 1,
468 ZONE_NAME = 1,
469 DIRECTION_ANGLE = 1,
470 PERSONAGE_NAME = 0,
471 TIMER_PERIOD = 0,
472 TIMER_RND = 1,
473 MINIGAME_NAME = 0,
474 MINIGAME_STATE_NAME = 1,
475 OBJECT_STATE_NAME = 1,
476 CLICK_ZONE_NAME = 0,
477 OBJECT2_NAME = 1,
478 OBJECTS_DISTANCE = 2,
479 ANIMATION_PHASE = 2,
480 STATE_TIME = 2
481 };
482
483 qdCondition();
485 qdCondition(const qdCondition &cnd);
486 ~qdCondition();
487
488 qdCondition &operator = (const qdCondition &cnd);
489
490 ConditionType type() const {
491 return _type;
492 }
493 void set_type(ConditionType tp);
494
495 static const char *type2str(uint type);
496
497 bool put_value(int idx, const char *str);
498
499 bool is_click_condition() const {
500 return (_type == CONDITION_MOUSE_CLICK || _type == CONDITION_MOUSE_DIALOG_CLICK || _type == CONDITION_MOUSE_ZONE_CLICK);
501 }
502 bool is_object_click_condition() const {
504 }
505
506 // val_index - индекс, по которому пропишется значение
507 // в qdConditionDataInt::_data или qdConditionDataFloat::_data
508 bool put_value(int idx, int val, int val_index = 0);
509 bool put_value(int idx, float val, int val_index = 0);
510
511 bool get_value(int idx, const char *&str) const;
512 bool get_value(int idx, int &val, int val_index = 0) const;
513 bool get_value(int idx, float &val, int val_index = 0) const;
514
515 bool put_object(int idx, qdNamedObject *obj);
516 const qdNamedObject *get_object(int idx) ;
517
518 const qdNamedObject *owner() const {
519 return _owner;
520 }
521 void set_owner(const qdNamedObject *p) {
522 _owner = p;
523 }
524
525 bool load_script(const xml::tag *p);
526 bool save_script(Common::WriteStream &fh, int indent = 0) const;
527
528 void quant(float dt);
529
531 bool load_data(Common::SeekableReadStream &fh, int save_version);
534
536 bool init();
537
538 bool is_inversed() const {
539 return _is_inversed;
540 }
541 void inverse(bool inverse_mode = true) {
542 _is_inversed = inverse_mode;
543 }
544
545 bool check();
546
547 bool is_in_group() const {
548 return _is_in_group;
549 }
550 void add_group_reference() {
551 _is_in_group = true;
552 }
553 void remove_group_reference() {
554 _is_in_group = false;
555 }
556
557 static bool successful_click() {
558 return _successful_click;
559 }
560 static bool successful_object_click() {
561 return _successful_object_click;
562 }
563 static void clear_successful_clicks() {
564 _successful_click = _successful_object_click = false;
565 }
566
567private:
568
569 ConditionType _type;
570 const qdNamedObject *_owner = nullptr;
571
572 typedef Std::vector<qdConditionData> data_container_t;
573 data_container_t _data;
574
575 typedef Std::vector<qdConditionObjectReference> objects_container_t;
576 objects_container_t _objects;
577
578 bool _is_inversed;
579
580 bool _is_in_group;
581
582 static bool _successful_click;
583 static bool _successful_object_click;
584
585 bool init_data(int data_index, qdConditionData::data_t data_type, int data_size = 0) {
586 assert(data_index >= 0 && data_index < (int)_data.size());
587
588 _data[data_index].set_type(data_type);
589 if (data_size)
590 _data[data_index].alloc_data(data_size);
591
592 return true;
593 }
594};
595
596} // namespace QDEngine
597
598#endif // QDENGINE_QDCORE_QD_CONDITION_H
Definition: stream.h:745
Definition: stream.h:77
Условие.
Definition: qd_condition.h:357
ConditionType
Типы условий.
Definition: qd_condition.h:360
@ CONDITION_COUNTER_IN_INTERVAL
значние счетчика в интервале
Definition: qd_condition.h:417
@ CONDITION_ANIMATED_OBJECTS_INTERSECTIONAL_BOUNDS
баунды двух объектов пересекаются
Definition: qd_condition.h:461
@ CONDITION_MOUSE_STATE_PHRASE_CLICK
клик по фразе определённого состояния
Definition: qd_condition.h:455
@ CONDITION_MOUSE_ZONE_CLICK
клик мышью по зоне на сетке сцены
Definition: qd_condition.h:385
@ CONDITION_FALSE
всегда false
Definition: qd_condition.h:364
@ CONDITION_MOUSE_RIGHT_OBJECT_ZONE_CLICK
правый клик объектом по зоне на сетке сцены
Definition: qd_condition.h:431
@ CONDITION_MOUSE_OBJECT_HOVER
мышь наведена на объект, на мыши объект
Definition: qd_condition.h:437
@ CONDITION_MOUSE_CLICK_FAILED
неудачный клик мыши
Definition: qd_condition.h:443
@ CONDITION_PERSONAGE_WALK_DIRECTION
персонаж движется в определенном направлении
Definition: qd_condition.h:373
@ CONDITION_MOUSE_RIGHT_ZONE_CLICK
правый клик мышью по зоне на сетке сцены
Definition: qd_condition.h:429
@ CONDITION_COUNTER_LESS_THAN_VALUE
значние счетчика меньше числа
Definition: qd_condition.h:413
@ CONDITION_MOUSE_RIGHT_CLICK
правый клик мыши по объекту
Definition: qd_condition.h:425
@ CONDITION_COUNTER_GREATER_THAN_VALUE
значние счетчика больше числа
Definition: qd_condition.h:411
@ CONDITION_MOUSE_OBJECT_CLICK_FAILED
неудачный клик объектом на мыши
Definition: qd_condition.h:445
@ CONDITION_OBJECT_IN_ZONE
персонаж или объект в определенном месте сетки
Definition: qd_condition.h:371
@ CONDITION_ANY_PERSONAGE_IN_ZONE
в зоне хотя бы один персонаж
Definition: qd_condition.h:423
@ CONDITION_OBJECT_NOT_IN_STATE
объект не находится в определенном состоянии
Definition: qd_condition.h:393
@ CONDITION_TRUE
всегда true
Definition: qd_condition.h:362
@ CONDITION_MOUSE_RIGHT_CLICK_EVENT
был клик правой кнопкой мыши
Definition: qd_condition.h:451
@ CONDITION_STATE_TIME_IN_INTERVAL
время работы состояния в интервале
Definition: qd_condition.h:409
@ CONDITION_OBJECT_STATE_WAITING
состояние объекта ждет активации
Definition: qd_condition.h:399
@ CONDITION_STATE_TIME_GREATER_THAN_STATE_TIME
время работы одного состояния больше времени работы другого
Definition: qd_condition.h:407
@ CONDITION_MOUSE_DIALOG_CLICK
клик мышью по фразе в диалоге
Definition: qd_condition.h:379
@ CONDITION_MOUSE_OBJECT_CLICK_EVENT
был клик объектом на мыши
Definition: qd_condition.h:449
@ CONDITION_ANIMATED_OBJECT_IDLE_GREATER_THAN_VALUE
время простоя больше заданного порога
Definition: qd_condition.h:459
@ CONDITION_OBJECT_HIDDEN
объект скрыт
Definition: qd_condition.h:433
@ CONDITION_MOUSE_CLICK_EVENT
был клик мыши
Definition: qd_condition.h:447
@ CONDITION_OBJECT_STATE_WAS_NOT_ACTIVATED
состояние объекта не активировалось
Definition: qd_condition.h:391
@ CONDITION_COUNTER_GREATER_THAN_COUNTER
значние счетчика больше значения другого счетчика
Definition: qd_condition.h:415
@ CONDITION_OBJECTS_DISTANCE
расстояние по сетке между двумя объектами меньше заданного
Definition: qd_condition.h:395
@ CONDITION_MOUSE_RIGHT_OBJECT_CLICK
правый клик объектом на мыши по объекту
Definition: qd_condition.h:427
@ CONDITION_MOUSE_HOVER
мышь наведена на объект
Definition: qd_condition.h:435
@ CONDITION_MINIGAME_STATE
мини-игра находится в определенном состоянии
Definition: qd_condition.h:381
@ CONDITION_PERSONAGE_STATIC_DIRECTION
персонаж стоит и ориентирован в определенном направлении
Definition: qd_condition.h:375
@ CONDITION_OBJECT_PREV_STATE
предыдущее состояние объекта
Definition: qd_condition.h:403
@ CONDITION_OBJECT_STATE
объект находится в определенном состоянии
Definition: qd_condition.h:383
@ CONDITION_MOUSE_OBJECT_ZONE_CLICK
клик объектом по зоне на сетке сцены
Definition: qd_condition.h:387
@ CONDITION_MOUSE_RIGHT_OBJECT_CLICK_EVENT
был клик правой кнопкой объектом на мыши
Definition: qd_condition.h:453
@ CONDITION_MOUSE_CLICK
клик мышью по объекту
Definition: qd_condition.h:367
@ CONDITION_PERSONAGE_ACTIVE
персонаж активен
Definition: qd_condition.h:397
@ CONDITION_STATE_TIME_GREATER_THAN_VALUE
время работы состояния больше значения
Definition: qd_condition.h:405
@ CONDITION_MOUSE_OBJECT_HOVER_ZONE
мышь наведена на зону, на мыши объект
Definition: qd_condition.h:441
@ CONDITION_MOUSE_HOVER_ZONE
мышь наведена на зону
Definition: qd_condition.h:439
@ CONDITION_OBJECT_STATE_ANIMATION_PHASE
состояние в определенной фазе анимации
Definition: qd_condition.h:401
@ CONDITION_OBJECT_IS_CLOSER
расстояние до одного объекта меньше чем до другого
Definition: qd_condition.h:457
@ CONDITION_MOUSE_OBJECT_CLICK
клик объектом на мыши по объекту
Definition: qd_condition.h:369
@ CONDITION_TIMER
условие выпоняется с некоторой периодичностью
Definition: qd_condition.h:377
@ CONDITION_OBJECT_STATE_WAS_ACTIVATED
состояние объекта активировалось
Definition: qd_condition.h:389
@ CONDITION_KEYPRESS
кнопка нажата
Definition: qd_condition.h:421
@ CONDITION_OBJECT_ON_PERSONAGE_WAY
объект на пути персонажа
Definition: qd_condition.h:419
ConditionDataIndex
Индексы для обращения к данным в условиях.
Definition: qd_condition.h:465
bool load_data(Common::SeekableReadStream &fh, int save_version)
Загрузка данных из сэйва.
bool init()
Инициализация условия, вызывается при старте и перезапуске игры.
bool save_data(Common::WriteStream &fh) const
Запись данных в сэйв.
Definition: algorithm.h:29
Базовый класс для игровых ресурсов.
Definition: console.h:28