浏览代码

CComponent: do not always assume 80 for text

Konstantin 2 年之前
父节点
当前提交
da8840c499
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      client/widgets/CComponent.cpp

+ 7 - 1
client/widgets/CComponent.cpp

@@ -73,7 +73,13 @@ void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize)
 
 	pos.h += 4; //distance between text and image
 
-	std::vector<std::string> textLines = CMessage::breakText(getSubtitle(), std::max<int>(80, pos.w), font);
+	auto max = 80;
+	if (size < medium)
+		max = 40;
+	if (size < small)
+		max = 30;
+
+	std::vector<std::string> textLines = CMessage::breakText(getSubtitle(), std::max<int>(max, pos.w), font);
 	for(auto & line : textLines)
 	{
 		int height = static_cast<int>(graphics->fonts[font]->getLineHeight());