From 60c67bc327c24205afff66afe17d7ffafed32760 Mon Sep 17 00:00:00 2001 From: Allofich Date: Fri, 21 Apr 2017 03:55:28 +0900 Subject: [PATCH] Run scripts for voiced dialogue (Fixes #3787) --- apps/openmw/mwbase/dialoguemanager.hpp | 2 +- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 23 +++++++++++-------- apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 6 ++--- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp index 1fe63e633..18f249e56 100644 --- a/apps/openmw/mwbase/dialoguemanager.hpp +++ b/apps/openmw/mwbase/dialoguemanager.hpp @@ -50,7 +50,7 @@ namespace MWBase virtual void goodbye() = 0; - virtual void say(const MWWorld::Ptr &actor, const std::string &topic) const = 0; + virtual void say(const MWWorld::Ptr &actor, const std::string &topic) = 0; //calbacks for the GUI virtual void keywordSelected (const std::string& keyword) = 0; diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 254bc7d47..489d726e6 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -171,7 +171,7 @@ namespace MWDialogue MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext)); - executeScript (info->mResultScript); + executeScript (info->mResultScript, mActor); mLastTopic = Misc::StringUtils::lowerCase(it->mId); // update topics again to accommodate changes resulting from executeScript @@ -190,7 +190,7 @@ namespace MWDialogue MWBase::Environment::get().getWindowManager()->showCompanionWindow(mActor); } - bool DialogueManager::compile (const std::string& cmd,std::vector& code) + bool DialogueManager::compile (const std::string& cmd, std::vector& code, const MWWorld::Ptr& actor) { bool success = true; @@ -206,7 +206,7 @@ namespace MWDialogue Compiler::Locals locals; - std::string actorScript = mActor.getClass().getScript (mActor); + std::string actorScript = actor.getClass().getScript (actor); if (!actorScript.empty()) { @@ -246,14 +246,14 @@ namespace MWDialogue return success; } - void DialogueManager::executeScript (const std::string& script) + void DialogueManager::executeScript (const std::string& script, const MWWorld::Ptr& actor) { std::vector code; - if(compile(script,code)) + if(compile(script, code, actor)) { try { - MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); + MWScript::InterpreterContext interpreterContext(&actor.getRefData().getLocals(), actor); Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter); interpreter.run (&code[0], code.size(), interpreterContext); @@ -317,7 +317,7 @@ namespace MWDialogue } } - executeScript (info->mResultScript); + executeScript (info->mResultScript, mActor); mLastTopic = topic; } @@ -500,7 +500,7 @@ namespace MWDialogue } } - executeScript (info->mResultScript); + executeScript (info->mResultScript, mActor); } else { @@ -618,13 +618,13 @@ namespace MWDialogue win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext), gmsts.find ("sServiceRefusal")->getString()); - executeScript (info->mResultScript); + executeScript (info->mResultScript, mActor); return true; } return false; } - void DialogueManager::say(const MWWorld::Ptr &actor, const std::string &topic) const + void DialogueManager::say(const MWWorld::Ptr &actor, const std::string &topic) { MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); if(!sndMgr->sayDone(actor)) @@ -647,6 +647,9 @@ namespace MWDialogue if (!info->mSound.empty()) sndMgr->say(actor, info->mSound); } + + if (!info->mResultScript.empty()) + executeScript(info->mResultScript, actor); } int DialogueManager::countSavedGameRecords() const diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index bbe42975c..40a24a1f8 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -51,8 +51,8 @@ namespace MWDialogue void updateTopics(); void updateGlobals(); - bool compile (const std::string& cmd,std::vector& code); - void executeScript (const std::string& script); + bool compile (const std::string& cmd, std::vector& code, const MWWorld::Ptr& actor); + void executeScript (const std::string& script, const MWWorld::Ptr& actor); void executeTopic (const std::string& topic); @@ -74,7 +74,7 @@ namespace MWDialogue virtual bool checkServiceRefused (); - virtual void say(const MWWorld::Ptr &actor, const std::string &topic) const; + virtual void say(const MWWorld::Ptr &actor, const std::string &topic); //calbacks for the GUI virtual void keywordSelected (const std::string& keyword);