Explorar o código

CComponent: do not always assume 80 for text

Konstantin %!s(int64=2) %!d(string=hai) anos
pai
achega
da8840c499
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  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());