MADS: Implement V2 DynamicHotspots::add()

This commit is contained in:
Filippos Karapetis 2019-08-04 14:03:47 +03:00
parent 8940601413
commit 913229f9db
3 changed files with 41 additions and 6 deletions

View File

@ -31,7 +31,9 @@ DynamicHotspot::DynamicHotspot() {
_facing = FACING_NONE;
_descId = 0;
_verbId = 0;
_valid = false; // V2
_articleNumber = 0;
_syntax = 0; // V2
_cursor = CURSOR_NONE;
_active = false;
}
@ -53,9 +55,36 @@ DynamicHotspots::DynamicHotspots(MADSEngine *vm) : _vm(vm) {
_count = 0;
}
int DynamicHotspots::add(int descId, int verbId, int syntax, int seqIndex, const Common::Rect &bounds) {
warning("TODO: DynamicHotspots::add(5 params))");
return add(descId, verbId, seqIndex, bounds);
int DynamicHotspots::add(int descId, int verbId, byte syntax, int seqIndex, const Common::Rect &bounds) {
// Find a free slot
uint idx = 0;
while ((idx < _entries.size()) && _entries[idx]._active)
++idx;
if (idx == _entries.size())
error("DynamicHotspots overflow");
_entries[idx]._active = true;
_entries[idx]._descId = descId;
_entries[idx]._seqIndex = seqIndex;
_entries[idx]._bounds = bounds;
_entries[idx]._feetPos = Common::Point(-3, 0);
_entries[idx]._facing = FACING_NONE;
_entries[idx]._verbId = verbId;
_entries[idx]._articleNumber = PREP_IN;
_entries[idx]._syntax = syntax;
_entries[idx]._cursor = CURSOR_NONE;
_entries[idx]._valid = true;
_entries[idx]._animIndex = -1;
++_count;
_changed = true;
if (seqIndex >= 0) {
_vm->_game->_scene._sequences[seqIndex]._dynamicHotspotIndex = idx;
_entries[idx]._valid = false;
}
return idx;
}
int DynamicHotspots::add(int descId, int verbId, int seqIndex, const Common::Rect &bounds) {
@ -138,11 +167,13 @@ void DynamicHotspots::refresh() {
ScreenObjects &scrObjects = _vm->_game->_screenObjects;
scrObjects.resize(scrObjects._uiCount);
bool isV2 = (_vm->getGameID() != GType_RexNebular);
// Loop through adding hotspots
for (uint i = 0; i < _entries.size(); ++i) {
DynamicHotspot &dh = (*this)[i];
if ((*this)[i]._active) {
if ((*this)[i]._active && (!isV2 || (*this)[i]._valid)) {
switch (scrObjects._inputMode) {
case kInputBuildingSentences:
case kInputLimitedSentences:
@ -203,7 +234,7 @@ Hotspot::Hotspot(Common::SeekableReadStream &f, bool isV2) {
_cursor = (CursorType)f.readByte();
if (isV2) {
f.skip(1); // cursor
f.skip(1); // syntax
_syntax = f.readByte();
}
_vocabId = f.readUint16LE();
_verbId = f.readUint16LE();

View File

@ -41,7 +41,9 @@ public:
Facing _facing;
int _descId;
int _verbId;
bool _valid; // V2
int _articleNumber;
byte _syntax; // V2
CursorType _cursor;
/**
@ -79,7 +81,7 @@ public:
Common::Array<MADS::DynamicHotspot>::size_type size() const { return _entries.size(); }
DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
int add(int descId, int verbId, int syntax, int seqIndex, const Common::Rect &bounds);
int add(int descId, int verbId, byte syntax, int seqIndex, const Common::Rect &bounds); // V2
int add(int descId, int verbId, int seqIndex, const Common::Rect &bounds);
int setPosition(int index, const Common::Point &pos, Facing facing);
int setCursor(int index, CursorType cursor);
@ -107,6 +109,7 @@ public:
Facing _facing;
int _articleNumber;
bool _active;
byte _syntax; // V2
CursorType _cursor;
int _vocabId;
int _verbId;

View File

@ -271,6 +271,7 @@ void Scene101::step() {
_talkCounter = 0;
}
// Monsieur Brie beckons Raul
if (_game._trigger == 50) {
_vm->_gameConv->run(0);
_callingStatus = 1;