mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-30 02:56:44 +00:00 
			
		
		
		
	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; |         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) |     void DialogueManager::startDialogue (const MWWorld::Ptr& actor) | ||||||
|     { |     { | ||||||
|         std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; |         std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; | ||||||
|  | @ -463,18 +489,9 @@ namespace MWDialogue | ||||||
|                             // TODO execute script
 |                             // TODO execute script
 | ||||||
|                         } |                         } | ||||||
|                         std::string text = iter->response; |                         std::string text = iter->response; | ||||||
|                         std::map<std::string,std::string>::iterator it; |                         parseText(text); | ||||||
|                         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); | ||||||
|  |                          | ||||||
|                         greetingFound = true; |                         greetingFound = true; | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
|  | @ -486,16 +503,7 @@ namespace MWDialogue | ||||||
|     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; |         parseText(text); | ||||||
|         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); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void DialogueManager::goodbyeSelected() |     void DialogueManager::goodbyeSelected() | ||||||
|  |  | ||||||
|  | @ -21,6 +21,8 @@ namespace MWDialogue | ||||||
| 
 | 
 | ||||||
|             bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; |             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,bool> knownTopics;// Those are the topics the player knows.
 | ||||||
|             std::map<std::string,std::string> actorKnownTopics; |             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; |     size_t pos = 0; | ||||||
|     while((pos = find_str_ci(str,keyword, pos)) != std::string::npos) |     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.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