diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 737d22280..80316c0f5 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -238,6 +238,44 @@ namespace MWDialogue } } + void DialogueManager::executeTopic (const std::string& topic) + { + Filter filter (mActor, mChoice, mTalkedTo); + + const MWWorld::Store &dialogues = + MWBase::Environment::get().getWorld()->getStore().get(); + + const ESM::Dialogue& dialogue = *dialogues.find (topic); + + if (const ESM::DialInfo *info = filter.search (dialogue)) + { + parseText (info->mResponse); + + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); + + if (dialogue.mType==ESM::Dialogue::Persuasion) + { + std::string modifiedTopic = "s" + topic; + + modifiedTopic.erase (std::remove (modifiedTopic.begin(), modifiedTopic.end(), ' '), modifiedTopic.end()); + + const MWWorld::Store& gmsts = + MWBase::Environment::get().getWorld()->getStore().get(); + + win->addTitle (gmsts.find (modifiedTopic)->getString()); + } + else + win->addTitle (topic); + + win->addText (info->mResponse); + + executeScript (info->mResultScript); + + mLastTopic = topic; + mLastDialogue = *info; + } + } + void DialogueManager::updateTopics() { std::list keywordList; @@ -332,24 +370,7 @@ namespace MWDialogue ESM::Dialogue ndialogue = mDialogueMap[keyword]; if (mDialogueMap[keyword].mType == ESM::Dialogue::Topic) { - Filter filter (mActor, mChoice, mTalkedTo); - - if (const ESM::DialInfo *info = filter.search (mDialogueMap[keyword])) - { - std::string text = info->mResponse; - std::string script = info->mResultScript; - - parseText (text); - - MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); - win->addTitle (keyword); - win->addText (info->mResponse); - - executeScript (script); - - mLastTopic = keyword; - mLastDialogue = *info; - } + executeTopic (keyword); } } } @@ -445,28 +466,22 @@ namespace MWDialogue else if (curDisp + mTemporaryDispositionChange > 100) mTemporaryDispositionChange = 100 - curDisp; - // add status message to dialogue window + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Speechcraft, success ? 0 : 1); + std::string text; if (type == MWBase::MechanicsManager::PT_Admire) - text = "sAdmire"; + text = "Admire"; else if (type == MWBase::MechanicsManager::PT_Taunt) - text = "sTaunt"; + text = "Taunt"; else if (type == MWBase::MechanicsManager::PT_Intimidate) - text = "sIntimidate"; + text = "Intimidate"; else{ - text = "sBribe"; + text = "Bribe"; } - MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Speechcraft, success ? 0 : 1); - - text += (success ? "Success" : "Fail"); - - MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); - win->addTitle(MyGUI::LanguageManager::getInstance().replaceTags("#{"+text+"}")); - - /// \todo text from INFO record, how to get the ID? + executeTopic (text + (success ? " Success" : " Fail")); } int DialogueManager::getTemporaryDispositionChange() const diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index 9e1971b0f..98b27f774 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -23,7 +23,7 @@ namespace MWDialogue MWScript::CompilerContext mCompilerContext; std::ostream mErrorStream; Compiler::StreamErrorHandler mErrorHandler; - + MWWorld::Ptr mActor; bool mTalkedTo; @@ -46,6 +46,8 @@ namespace MWDialogue void printError (const std::string& error); + void executeTopic (const std::string& topic); + public: DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose);