diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 81a89761af..7950a78881 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -560,16 +560,14 @@ namespace MWDialogue if(pos==0) { knownTopics[*it] = true; - win->addKeyword(*it); } else if(text.substr(pos -1,1) == " ") { knownTopics[*it] = true; - win->addKeyword(*it); } } - } + updateTopics(); } void DialogueManager::startDialogue (const MWWorld::Ptr& actor) @@ -692,6 +690,8 @@ namespace MWDialogue void DialogueManager::updateTopics() { + std::list keywordList; + actorKnownTopics.clear(); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; @@ -709,12 +709,14 @@ namespace MWDialogue //does the player know the topic? if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { - win->addKeyword(it->first); + keywordList.push_back(it->first); + break; } } } } } + win->setKeywords(keywordList); } void DialogueManager::keywordSelected(std::string keyword) @@ -765,41 +767,27 @@ namespace MWDialogue { mChoice = mChoiceMap[answere]; - //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - bool found = false; - //ESMS::RecListT::MapType::iterator it; std::vector::const_iterator iter; - //for(it = dialogueList.begin(); it!=dialogueList.end();it++) if(mDialogueMap.find(mLastTopic) != mDialogueMap.end()) { ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; if(ndialogue.type == ESM::Dialogue::Topic) { - for (iter = ndialogue.mInfo.begin(); + for (std::vector::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) { - if(iter->id == mLastDialogue.id) found = true; - if(found) break; - } - } - if(found) - { - for (std::vector::const_iterator iter2 = iter; - iter2!=ndialogue.mInfo.begin();) - { - --iter2; - if (isMatching (mActor, *iter2) && functionFilter(mActor,*iter2,true)) + if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { mChoiceMap.clear(); mChoice = -1; mIsInChoice = false; MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - std::string text = iter2->response; + std::string text = iter->response; parseText(text); win->addText(text); - executeScript(iter2->resultScript); + executeScript(iter->resultScript); mLastTopic = mLastTopic; - mLastDialogue = *iter2; + mLastDialogue = *iter; break; } } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 549022e704..5ab8604431 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -113,12 +113,12 @@ void DialogueWindow::startDialogue(std::string npcName) setText("NpcName", npcName); } -void DialogueWindow::addKeyword(std::string keyWord) +void DialogueWindow::setKeywords(std::list keyWords) { - if(topicsList->findItemIndexWith(keyWord) == MyGUI::ITEM_NONE) + topicsList->removeAllItems(); + for(std::list::iterator it = keyWords.begin(); it != keyWords.end(); it++) { - topicsList->addItem(keyWord); - pTopicsText[keyWord] = " "; + topicsList->addItem(*it); } } diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 4520d4586e..7dfd7bb7f4 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -42,7 +42,7 @@ namespace MWGui void startDialogue(std::string npcName); void stopDialogue(); - void addKeyword(std::string keyWord); + void setKeywords(std::list keyWord); void removeKeyword(std::string keyWord); void addText(std::string text); void addTitle(std::string text);