/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
#ifndef DGDS_SCENE_H
#define DGDS_SCENE_H
#include "common/array.h"
#include "common/serializer.h"
#include "dgds/dialog.h"
#include "dgds/head.h"
#include "dgds/dgds_rect.h"
#include "dgds/minigames/shell_game.h"
#include "dgds/scene_condition.h"
#include "dgds/scene_op.h"
namespace Dgds {
class ResourceManager;
class Decompressor;
class DgdsFont;
class SoundRaw;
class TTMInterpreter;
class TTMEnviro;
class HotArea {
public:
DgdsRect _rect;
uint16 _num; //
uint16 _cursorNum;
// Used in Willy Beamish
uint16 _cursorNum2;
uint16 _objInteractionRectNum;
Common::Array enableConditions;
Common::Array onLookOps;
Common::Array onPickUpOps;
Common::Array onUseOps;
virtual ~HotArea() {}
virtual Common::String dump(const Common::String &indent) const;
};
class DynamicRect {
public:
DynamicRect() : _num(0) {};
uint16 _num;
DgdsRect _rect;
};
enum GameItemState {
kItemStateDragging = 1,
kItemStateWasInInv = 0x10000,
};
class GameItem : public HotArea {
public:
Common::Array onDragFinishedOps;
Common::Array onBothButtonsOps;
uint16 _altCursor;
uint16 _iconNum;
// mutable values
uint16 _inSceneNum;
uint32 _flags;
uint16 _quality;
Common::String dump(const Common::String &indent) const override;
};
class MouseCursor {
public:
MouseCursor(uint16 hotX, uint16 hotY) : _hot(hotX, hotY) {}
Common::String dump(const Common::String &indent) const;
const Common::Point getHot() const { return _hot; }
private:
Common::Point _hot;
};
// Interactions between two objects when one is dropped on the other
class ObjectInteraction {
public:
ObjectInteraction(uint16 dropped, uint16 target) : _droppedItemNum(dropped), _targetItemNum(target) {}
Common::Array opList;
bool matches(uint16 droppedItemNum, uint16 targetItemNum) const {
return (_droppedItemNum == 0xFFFF || _droppedItemNum == droppedItemNum)
&& _targetItemNum == targetItemNum;
}
Common::String dump(const Common::String &indent) const;
private:
uint16 _droppedItemNum;
uint16 _targetItemNum;
};
class SceneTrigger {
public:
SceneTrigger(uint16 num) : _num(num), _enabled(false), _timesToCheckBeforeRunning(0), _checksUntilRun(0) {}
Common::String dump(const Common::String &indent) const;
Common::Array conditionList;
Common::Array sceneOpList;
uint16 _timesToCheckBeforeRunning; // Only used in Beamish.
uint16 _checksUntilRun;
bool _enabled;
uint16 getNum() const { return _num; }
private:
uint16 _num;
};
/* A global value that only applies on a per-SDS-scene,
but stays with the GDS data as it sticks around during
the game */
class PerSceneGlobal {
public:
PerSceneGlobal(uint16 num, uint16 scene) : _num(num), _sceneNo(scene), _val(0) {}
Common::String dump(const Common::String &indent) const;
bool matches(uint16 num, uint16 scene) const { return num == _num && (_sceneNo == 0 || _sceneNo == scene); }
bool numMatches(uint16 num) const { return num == _num; }
int16 _val;
private:
// Immutable, read from the data file
uint16 _num;
uint16 _sceneNo;
};
/**
* A scene is described by an SDS file, which points to the ADS script to load
* and holds the dialog info.
*/
class Scene {
public:
Scene();
virtual ~Scene() {};
virtual bool parse(Common::SeekableReadStream *s) = 0;
bool isVersionOver(const char *version) const;
bool isVersionUnder(const char *version) const;
uint32 getMagic() const { return _magic; }
const Common::String &getVersion() const { return _version; }
bool runPreTickOps() { return runOps(_preTickOps); }
bool runPostTickOps() { return runOps(_postTickOps); }
static bool runOps(const Common::Array ops, int16 addMinutes = 0);
virtual Common::Error syncState(Common::Serializer &s) = 0;
// These are all static as they are potentially run over scene changes.
static void segmentStateOps(const Common::Array &args);
static void setItemAttrOp(const Common::Array &args);
static void setDragItemOp(const Common::Array &args);
protected:
bool readConditionList(Common::SeekableReadStream *s, Common::Array &list) const;
bool readHotArea(Common::SeekableReadStream *s, HotArea &dst) const;
bool readHotAreaList(Common::SeekableReadStream *s, Common::List &list) const;
bool readGameItemList(Common::SeekableReadStream *s, Common::Array &list) const;
bool readMouseHotspotList(Common::SeekableReadStream *s, Common::Array &list) const;
bool readObjInteractionList(Common::SeekableReadStream *s, Common::Array &list) const;
bool readOpList(Common::SeekableReadStream *s, Common::Array &list) const;
bool readDialogList(Common::SeekableReadStream *s, Common::List