Merge pull request #1264 from Allofich/script

Run scripts for voiced dialogue
pull/203/head
scrawl 8 years ago committed by GitHub
commit 2c879ddbbf

@ -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;

@ -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<Interpreter::Type_Code>& code)
bool DialogueManager::compile (const std::string& cmd, std::vector<Interpreter::Type_Code>& 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<Interpreter::Type_Code> 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

@ -51,8 +51,8 @@ namespace MWDialogue
void updateTopics();
void updateGlobals();
bool compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code);
void executeScript (const std::string& script);
bool compile (const std::string& cmd, std::vector<Interpreter::Type_Code>& 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);

Loading…
Cancel
Save