forked from teamnwah/openmw-tes3coop
Fix for prefix/suffix stuff
This commit is contained in:
parent
bc72b2d535
commit
232e478768
3 changed files with 47 additions and 26 deletions
|
@ -404,6 +404,32 @@ namespace MWDialogue
|
|||
knownTopics[toLower(topic)] = true;
|
||||
}
|
||||
|
||||
void DialogueManager::parseText(std::string text)
|
||||
{
|
||||
std::map<std::string,std::string>::iterator it;
|
||||
for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++)
|
||||
{
|
||||
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
|
||||
size_t pos = find_str_ci(text,it->first,0);
|
||||
if(pos !=std::string::npos)
|
||||
{
|
||||
if(pos==0)
|
||||
{
|
||||
//std::cout << "fouuuuuuuuuuund";
|
||||
knownTopics[it->first] = true;
|
||||
win->addKeyword(it->first,it->second);
|
||||
}
|
||||
else if(text.substr(pos -1,1) == " ")
|
||||
{
|
||||
//std::cout << "fouuuuuuuuuuund";
|
||||
knownTopics[it->first] = true;
|
||||
win->addKeyword(it->first,it->second);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void DialogueManager::startDialogue (const MWWorld::Ptr& actor)
|
||||
{
|
||||
std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl;
|
||||
|
@ -463,18 +489,9 @@ namespace MWDialogue
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
parseText(text);
|
||||
win->addText(iter->response);
|
||||
|
||||
greetingFound = true;
|
||||
break;
|
||||
}
|
||||
|
@ -486,16 +503,7 @@ namespace MWDialogue
|
|||
void DialogueManager::keywordSelected(std::string keyword)
|
||||
{
|
||||
std::string text = actorKnownTopics[keyword];
|
||||
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)
|
||||
{
|
||||
knownTopics[it->first] = true;
|
||||
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
|
||||
win->addKeyword(it->first,it->second);
|
||||
}
|
||||
}
|
||||
parseText(text);
|
||||
}
|
||||
|
||||
void DialogueManager::goodbyeSelected()
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace MWDialogue
|
|||
|
||||
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const;
|
||||
|
||||
void parseText(std::string text);
|
||||
|
||||
std::map<std::string,bool> knownTopics;// Those are the topics the player knows.
|
||||
std::map<std::string,std::string> actorKnownTopics;
|
||||
|
||||
|
|
|
@ -154,12 +154,23 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c
|
|||
size_t pos = 0;
|
||||
while((pos = find_str_ci(str,keyword, pos)) != std::string::npos)
|
||||
{
|
||||
if(pos==0)
|
||||
{
|
||||
str.insert(pos,color1);
|
||||
pos += color1.length();
|
||||
pos += keyword.length();
|
||||
str.insert(pos,color2);
|
||||
pos+= color2.length();
|
||||
}
|
||||
else if(str.substr(pos -1,1) == " ")
|
||||
{
|
||||
str.insert(pos,color1);
|
||||
pos += color1.length();
|
||||
pos += keyword.length();
|
||||
str.insert(pos,color2);
|
||||
pos+= color2.length();
|
||||
}
|
||||
//str.replace(pos, oldStr.length(), "#686EBA"+str.get);
|
||||
str.insert(pos,color1);
|
||||
pos += color1.length();
|
||||
pos += keyword.length();
|
||||
str.insert(pos,color2);
|
||||
pos+= color2.length();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue