From cb02f26732dd7e5ef2e29496a9ca35e2c31a5776 Mon Sep 17 00:00:00 2001 From: James Brown Date: Thu, 21 Aug 2003 06:51:02 +0000 Subject: [PATCH] Implement '.' sentence skipping, and other shutUpActor use --- actor.cpp | 7 +++++++ actor.h | 1 + lua.cpp | 10 ++++++++-- mixer.cpp | 12 ++++++++++++ mixer.h | 1 + 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/actor.cpp b/actor.cpp index 8f1c3ac6bda..7198004c065 100644 --- a/actor.cpp +++ b/actor.cpp @@ -91,6 +91,13 @@ bool Actor::talking() { return true; } +void Actor::shutUp() { + if (talkSound_) { + Mixer::instance()->stopVoice(talkSound_); + talkSound_ = NULL; + } +} + void Actor::pushCostume(const char *name) { Costume *newCost = ResourceLoader::instance()-> loadCostume(name, currentCostume()); diff --git a/actor.h b/actor.h index 12f4ae979d2..1ba23684006 100644 --- a/actor.h +++ b/actor.h @@ -60,6 +60,7 @@ public: void turn(int dir); void sayLine(const char *msg); + void shutUp(); bool talking(); void pushCostume(const char *name); diff --git a/lua.cpp b/lua.cpp index b24a99b3fe5..d62e9b1bf81 100644 --- a/lua.cpp +++ b/lua.cpp @@ -467,6 +467,12 @@ static void IsMessageGoing() { } } +static void ShutUpActor() { + Actor *act = check_actor(1); + if (act) + act->shutUp(); +} + // Sector functions static void GetActorSector(void) { Actor *act = check_actor(1); @@ -854,7 +860,6 @@ static char *stubFuncs[] = { "GetPointSector", "IsPointInSector", "SetActorFrustrumCull", - "ShutUpActor", "SetActorFollowBoxes", "SetActorHead", "GetCameraActor", @@ -1122,7 +1127,8 @@ struct luaL_reg builtins[] = { { "InputDialog", InputDialog }, { "ChangeTextObject", ChangeTextObject }, { "GetTextObjectDimensions", GetTextObjectDimensions }, - { "MakeTextObject", MakeTextObject } + { "MakeTextObject", MakeTextObject }, + { "ShutUpActor", ShutUpActor } }; void register_lua() { diff --git a/mixer.cpp b/mixer.cpp index 5b02810782b..d874979bebd 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -312,6 +312,18 @@ void Mixer::stopSfx(Sound *s) { } } +void Mixer::stopVoice(Sound *s) { + AudioLock l; + + for (sound_list::iterator i = voiceSounds_.begin(); + i != voiceSounds_.end(); ) { + if (*i == s) + i = voiceSounds_.erase(i); + else + i++; + } +} + static int compareStates(const void *p1, const void *p2) { const imuseTableEntry *e1 = static_cast(p1); const imuseTableEntry *e2 = static_cast(p2); diff --git a/mixer.h b/mixer.h index fa852d31b7c..9669b2a81e5 100644 --- a/mixer.h +++ b/mixer.h @@ -33,6 +33,7 @@ public: void playVoice(Sound *s); void playSfx(Sound *s); void stopSfx(Sound *s); + void stopVoice(Sound *s); void setImuseState(int state); void setImuseSeq(int seq);