1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

a little fix

This commit is contained in:
gugus 2012-02-10 22:54:17 +01:00
parent f1dc360720
commit eee5d20809

View File

@ -121,6 +121,14 @@ namespace
namespace MWDialogue namespace MWDialogue
{ {
//helper function
std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos)
{
return toLower(str).find(toLower(substr),pos);
}
bool DialogueManager::isMatching (const MWWorld::Ptr& actor, bool DialogueManager::isMatching (const MWWorld::Ptr& actor,
const ESM::DialInfo::SelectStruct& select) const const ESM::DialInfo::SelectStruct& select) const
{ {
@ -439,9 +447,9 @@ namespace MWDialogue
if (isMatching (actor, *iter)) if (isMatching (actor, *iter))
{ {
// start dialogue // start dialogue
std::cout << "found matching info record" << std::endl; //std::cout << "found matching info record" << std::endl;
std::cout << "response: " << iter->response << std::endl; //std::cout << "response: " << iter->response << std::endl;
if (!iter->sound.empty()) if (!iter->sound.empty())
{ {
@ -450,28 +458,34 @@ namespace MWDialogue
if (!iter->resultScript.empty()) if (!iter->resultScript.empty())
{ {
std::cout << "script: " << iter->resultScript << std::endl; //std::cout << "script: " << iter->resultScript << std::endl;
// TODO execute script // TODO execute script
} }
std::string text = iter->response;
std::map<std::string,std::string>::iterator it;
for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++)
{
if(find_str_ci(text,it->first,0) !=std::string::npos)
{
std::cout << "fouuuuuuuuuuund";
knownTopics[it->first] = true;
MWGui::DialogueWindow* win2 = mEnvironment.mWindowManager->getDialogueWindow();
win2->addKeyword(it->first,it->second);
}
}
win->addText(iter->response); win->addText(iter->response);
break; //break;
} }
} }
} }
//helper function
std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos)
{
return toLower(str).find(toLower(substr),pos);
}
void DialogueManager::keywordSelected(std::string keyword) void DialogueManager::keywordSelected(std::string keyword)
{ {
std::string text = actorKnownTopics[keyword]; std::string text = actorKnownTopics[keyword];
std::map<std::string,std::string>::iterator it; std::map<std::string,std::string>::iterator it;
for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++)
{ {
if(find_str_ci(text,it->second,0) !=std::string::npos) if(find_str_ci(text,it->first,0) !=std::string::npos)
{ {
knownTopics[it->first] = true; knownTopics[it->first] = true;
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();