mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Topic passed to keywordSelected() no longer has to be lower case
Remove redundant mDialogueMap
This commit is contained in:
parent
b7752ec52d
commit
f8ffd85146
@ -60,15 +60,6 @@ namespace MWDialogue
|
||||
mChoice = -1;
|
||||
mIsInChoice = false;
|
||||
mCompilerContext.setExtensions (&extensions);
|
||||
|
||||
const MWWorld::Store<ESM::Dialogue> &dialogs =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
|
||||
|
||||
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
|
||||
for (; it != dialogs.end(); ++it)
|
||||
{
|
||||
mDialogueMap[Misc::StringUtils::lowerCase(it->mId)] = *it;
|
||||
}
|
||||
}
|
||||
|
||||
void DialogueManager::clear()
|
||||
@ -171,7 +162,7 @@ namespace MWDialogue
|
||||
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
|
||||
win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext), "", false);
|
||||
executeScript (info->mResultScript, mActor);
|
||||
mLastTopic = Misc::StringUtils::lowerCase(it->mId);
|
||||
mLastTopic = it->mId;
|
||||
|
||||
// update topics again to accommodate changes resulting from executeScript
|
||||
updateTopics();
|
||||
@ -310,7 +301,7 @@ namespace MWDialogue
|
||||
{
|
||||
if (iter->mId == info->mId)
|
||||
{
|
||||
MWBase::Environment::get().getJournal()->addTopic (topic, info->mId, mActor);
|
||||
MWBase::Environment::get().getJournal()->addTopic (Misc::StringUtils::lowerCase(topic), info->mId, mActor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -327,6 +318,11 @@ namespace MWDialogue
|
||||
}
|
||||
}
|
||||
|
||||
const ESM::Dialogue *DialogueManager::searchDialogue(const std::string& id)
|
||||
{
|
||||
return MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().search(id);
|
||||
}
|
||||
|
||||
void DialogueManager::updateGlobals()
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->updateDialogueGlobals();
|
||||
@ -416,12 +412,10 @@ namespace MWDialogue
|
||||
{
|
||||
if(!mIsInChoice)
|
||||
{
|
||||
if(mDialogueMap.find(keyword) != mDialogueMap.end())
|
||||
const ESM::Dialogue* dialogue = searchDialogue(keyword);
|
||||
if (dialogue && dialogue->mType == ESM::Dialogue::Topic)
|
||||
{
|
||||
if (mDialogueMap[keyword].mType == ESM::Dialogue::Topic)
|
||||
{
|
||||
executeTopic (keyword);
|
||||
}
|
||||
executeTopic (keyword);
|
||||
}
|
||||
}
|
||||
|
||||
@ -456,14 +450,14 @@ namespace MWDialogue
|
||||
{
|
||||
mChoice = answer;
|
||||
|
||||
if (mDialogueMap.find(mLastTopic) != mDialogueMap.end())
|
||||
const ESM::Dialogue* dialogue = searchDialogue(mLastTopic);
|
||||
if (dialogue)
|
||||
{
|
||||
Filter filter (mActor, mChoice, mTalkedTo);
|
||||
|
||||
if (mDialogueMap[mLastTopic].mType == ESM::Dialogue::Topic
|
||||
|| mDialogueMap[mLastTopic].mType == ESM::Dialogue::Greeting)
|
||||
if (dialogue->mType == ESM::Dialogue::Topic || dialogue->mType == ESM::Dialogue::Greeting)
|
||||
{
|
||||
if (const ESM::DialInfo *info = filter.search (mDialogueMap[mLastTopic], true))
|
||||
if (const ESM::DialInfo *info = filter.search (*dialogue, true))
|
||||
{
|
||||
std::string text = info->mResponse;
|
||||
parseText (text);
|
||||
@ -477,12 +471,12 @@ namespace MWDialogue
|
||||
|
||||
// Make sure the returned DialInfo is from the Dialogue we supplied. If could also be from the Info refusal group,
|
||||
// in which case it should not be added to the journal.
|
||||
for (ESM::Dialogue::InfoContainer::const_iterator iter = mDialogueMap[mLastTopic].mInfo.begin();
|
||||
iter!=mDialogueMap[mLastTopic].mInfo.end(); ++iter)
|
||||
for (ESM::Dialogue::InfoContainer::const_iterator iter = dialogue->mInfo.begin();
|
||||
iter!=dialogue->mInfo.end(); ++iter)
|
||||
{
|
||||
if (iter->mId == info->mId)
|
||||
{
|
||||
MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId, mActor);
|
||||
MWBase::Environment::get().getJournal()->addTopic (Misc::StringUtils::lowerCase(mLastTopic), info->mId, mActor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -737,7 +731,7 @@ namespace MWDialogue
|
||||
if (actor == mActor && !mLastTopic.empty())
|
||||
{
|
||||
MWBase::Environment::get().getJournal()->removeLastAddedTopicResponse(
|
||||
mLastTopic, actor.getClass().getName(actor));
|
||||
Misc::StringUtils::lowerCase(mLastTopic), actor.getClass().getName(actor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ namespace MWDialogue
|
||||
{
|
||||
class DialogueManager : public MWBase::DialogueManager
|
||||
{
|
||||
std::map<std::string, ESM::Dialogue> mDialogueMap;
|
||||
std::set<std::string> mKnownTopics;// Those are the topics the player knows.
|
||||
|
||||
// Modified faction reactions. <Faction1, <Faction2, Difference> >
|
||||
@ -56,6 +55,8 @@ namespace MWDialogue
|
||||
|
||||
void executeTopic (const std::string& topic);
|
||||
|
||||
const ESM::Dialogue* searchDialogue(const std::string& id);
|
||||
|
||||
public:
|
||||
|
||||
DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage);
|
||||
|
@ -223,7 +223,7 @@ namespace MWGui
|
||||
{
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->playSound("Menu Click");
|
||||
MWBase::Environment::get().getDialogueManager()->keywordSelected(Misc::StringUtils::lowerCase(mTopicId));
|
||||
MWBase::Environment::get().getDialogueManager()->keywordSelected(mTopicId);
|
||||
}
|
||||
|
||||
void Goodbye::activated()
|
||||
@ -328,7 +328,7 @@ namespace MWGui
|
||||
}
|
||||
|
||||
if (id >= separatorPos)
|
||||
MWBase::Environment::get().getDialogueManager()->keywordSelected(Misc::StringUtils::lowerCase(topic));
|
||||
MWBase::Environment::get().getDialogueManager()->keywordSelected(topic);
|
||||
else
|
||||
{
|
||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||
@ -552,24 +552,7 @@ namespace MWGui
|
||||
|
||||
void DialogueWindow::addResponse(const std::string &text, const std::string &title, bool needMargin)
|
||||
{
|
||||
// This is called from the dialogue manager, so text is
|
||||
// case-smashed - thus we have to retrieve the correct case
|
||||
// of the title through the topic list.
|
||||
std::string realTitle = title;
|
||||
if (realTitle != "")
|
||||
{
|
||||
for (size_t i=0; i<mTopicsList->getItemCount(); ++i)
|
||||
{
|
||||
std::string item = mTopicsList->getItemNameAt(i);
|
||||
if (Misc::StringUtils::ciEqual(item, title))
|
||||
{
|
||||
realTitle = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mHistoryContents.push_back(new Response(text, realTitle, needMargin));
|
||||
mHistoryContents.push_back(new Response(text, title, needMargin));
|
||||
updateHistory();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user