From 8e857587d76d73fe5eff5be98c0572637efa2281 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 28 Nov 2012 02:36:33 +0100 Subject: [PATCH] fix a text coloring bug --- apps/openmw/mwgui/dialogue.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 827da1085..258e9174c 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -316,6 +316,22 @@ 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) { + // do not add color if this portion of text is already colored. + { + MyGUI::TextIterator iterator (str); + MyGUI::UString colour; + while(iterator.moveNext()) + { + size_t iteratorPos = iterator.getPosition(); + iterator.getTagColour(colour); + if (iteratorPos == pos) + break; + } + + if (colour == color1) + return; + } + str.insert(pos,color1); pos += color1.length(); pos += keyword.length();