2
0
Эх сурвалжийг харах

Battle console: attempt to re-split string if it is too long to fit into
two lines due to line break

Ivan Savenko 1 жил өмнө
parent
commit
85d8e093df

+ 7 - 0
client/battle/BattleInterfaceClasses.cpp

@@ -83,6 +83,13 @@ std::vector<std::string> BattleConsole::getVisibleText()
 
 		auto result = CMessage::breakText(text, pos.w, FONT_SMALL);
 
+		if(result.size() > 2 && text.find('\n') != std::string::npos)
+		{
+			// Text has too many lines to fit into console, but has line breaks. Try ignore them and fit text that way
+			std::string cleanText = boost::algorithm::replace_all_copy(text, "\n", " ");
+			result = CMessage::breakText(cleanText, pos.w, FONT_SMALL);
+		}
+
 		if(result.size() > 2)
 			result.resize(2);
 		return result;