瀏覽代碼

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

Ivan Savenko 1 年之前
父節點
當前提交
85d8e093df
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      client/battle/BattleInterfaceClasses.cpp

+ 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;