mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-24 03:24:50 +00:00
TWP: Fix dialog shutup in dialog (bug #15070)
This commit is contained in:
parent
804a51110e
commit
7a9946c6db
@ -206,9 +206,7 @@ void Dialog::choose(DialogSlot *slot) {
|
||||
YChoice *choice = getChoice(slot);
|
||||
if (slot->_dlg->_context.parrot) {
|
||||
slot->_dlg->_state = DialogState::Active;
|
||||
slot->_dlg->_action = Common::SharedPtr<SerialMotors>(new SerialMotors(
|
||||
{slot->_dlg->_tgt->say(slot->_dlg->_context.actor, choice->_text),
|
||||
Common::SharedPtr<SelectLabelMotor>(new SelectLabelMotor(slot->_dlg, choice->_goto->_line, choice->_goto->_name))}));
|
||||
slot->_dlg->_action = Common::SharedPtr<SelectLabelMotor>(new SelectLabelMotor(slot->_dlg, choice->_goto->_line, choice->_goto->_name));
|
||||
slot->_dlg->clearSlots();
|
||||
} else {
|
||||
slot->_dlg->selectLabel(choice->_goto->_line, choice->_goto->_name);
|
||||
@ -415,6 +413,11 @@ void Dialog::running(float dt) {
|
||||
_action->update(dt);
|
||||
return;
|
||||
} else {
|
||||
IsShutup isShutup;
|
||||
statmt->_exp->accept(isShutup);
|
||||
if (g_twp->isSomeoneTalking() && !isShutup._isShutup) {
|
||||
break;
|
||||
}
|
||||
run(statmt);
|
||||
if (_lbl && (_currentStatement == _lbl->_stmts.size()))
|
||||
gotoNextLabel();
|
||||
|
@ -131,6 +131,15 @@ public:
|
||||
bool _isChoice = false;
|
||||
};
|
||||
|
||||
class IsShutup : public YackVisitor {
|
||||
public:
|
||||
virtual ~IsShutup() override {}
|
||||
void visit(const YShutup &node) override { _isShutup = true; }
|
||||
|
||||
public:
|
||||
bool _isShutup = false;
|
||||
};
|
||||
|
||||
class ExpVisitor : public YackVisitor {
|
||||
public:
|
||||
explicit ExpVisitor(Dialog *dialog);
|
||||
|
@ -348,31 +348,9 @@ static SQInteger breakwhilerunning(HSQUIRRELVM v) {
|
||||
v, [id] { return sqthread(id) != nullptr; }, "breakwhilerunning(%d)", id);
|
||||
}
|
||||
|
||||
// Returns true if at least 1 actor is talking.
|
||||
static bool isSomeoneTalking() {
|
||||
for (auto it = g_twp->_actors.begin(); it != g_twp->_actors.end(); it++) {
|
||||
Common::SharedPtr<Object> obj = *it;
|
||||
if (obj->_room != g_twp->_room)
|
||||
continue;
|
||||
if (obj->getTalking() && obj->getTalking()->isEnabled())
|
||||
return true;
|
||||
}
|
||||
for (auto it = g_twp->_room->_layers.begin(); it != g_twp->_room->_layers.end(); it++) {
|
||||
Common::SharedPtr<Layer> layer = *it;
|
||||
for (auto it2 = layer->_objects.begin(); it2 != layer->_objects.end(); it2++) {
|
||||
Common::SharedPtr<Object> obj = *it2;
|
||||
if (obj->_room != g_twp->_room)
|
||||
continue;
|
||||
if (obj->getTalking() && obj->getTalking()->isEnabled())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct SomeoneTalking {
|
||||
bool operator()() {
|
||||
return isSomeoneTalking();
|
||||
return g_twp->isSomeoneTalking();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1769,6 +1769,29 @@ void TwpEngine::stopTalking() {
|
||||
}
|
||||
}
|
||||
|
||||
bool TwpEngine::isSomeoneTalking() const {
|
||||
if (!_room)
|
||||
return false;
|
||||
for (auto it = _actors.begin(); it != _actors.end(); it++) {
|
||||
Common::SharedPtr<Object> obj = *it;
|
||||
if (obj->_room != _room)
|
||||
continue;
|
||||
if (obj->getTalking() && obj->getTalking()->isEnabled())
|
||||
return true;
|
||||
}
|
||||
for (auto it = _room->_layers.begin(); it != _room->_layers.end(); it++) {
|
||||
Common::SharedPtr<Layer> layer = *it;
|
||||
for (auto it2 = layer->_objects.begin(); it2 != layer->_objects.end(); it2++) {
|
||||
Common::SharedPtr<Object> obj = *it2;
|
||||
if (obj->_room != _room)
|
||||
continue;
|
||||
if (obj->getTalking() && obj->getTalking()->isEnabled())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float TwpEngine::getRandom() const {
|
||||
return g_twp->getRandomSource().getRandomNumber(RAND_MAX) / (float)RAND_MAX;
|
||||
}
|
||||
|
@ -139,6 +139,7 @@ public:
|
||||
Common::SharedPtr<Object> objAt(const Math::Vector2d &pos);
|
||||
void flashSelectableActor(int flash);
|
||||
void stopTalking();
|
||||
bool isSomeoneTalking() const;
|
||||
void walkFast(bool state = true);
|
||||
|
||||
void actorEnter(Common::SharedPtr<Object> actor);
|
||||
|
Loading…
x
Reference in New Issue
Block a user