mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Do not attempt to resize text box to zero-width
This commit is contained in:
@@ -376,6 +376,7 @@ void CTextBox::setText(const std::string & text)
|
||||
{
|
||||
// decrease width again if slider still used
|
||||
label->pos.w = pos.w - 32;
|
||||
assert(label->pos.w > 0);
|
||||
label->setText(text);
|
||||
slider->setAmount(label->textSize.y);
|
||||
}
|
||||
@@ -383,6 +384,7 @@ void CTextBox::setText(const std::string & text)
|
||||
{
|
||||
// create slider and update widget
|
||||
label->pos.w = pos.w - 32;
|
||||
assert(label->pos.w > 0);
|
||||
label->setText(text);
|
||||
|
||||
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||
|
@@ -120,6 +120,10 @@ SDL_Surface * CMessage::drawDialogBox(int w, int h, PlayerColor playerColor)
|
||||
|
||||
std::vector<std::string> CMessage::breakText( std::string text, size_t maxLineWidth, EFonts font )
|
||||
{
|
||||
assert(maxLineWidth != 0);
|
||||
if (maxLineWidth == 0)
|
||||
return { text };
|
||||
|
||||
std::vector<std::string> ret;
|
||||
|
||||
boost::algorithm::trim_right_if(text,boost::algorithm::is_any_of(std::string(" ")));
|
||||
|
@@ -150,7 +150,9 @@ CInfoWindow::CInfoWindow(std::string Text, PlayerColor player, const TCompsInfo
|
||||
text = std::make_shared<CTextBox>(Text, Rect(0, 0, 250, 100), 0, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
|
||||
if(!text->slider)
|
||||
{
|
||||
text->resize(text->label->textSize);
|
||||
int finalWidth = std::min(250, text->label->textSize.x + 32);
|
||||
int finalHeight = text->label->textSize.y;
|
||||
text->resize(Point(finalWidth, finalHeight));
|
||||
}
|
||||
|
||||
if(buttons.size() == 1)
|
||||
|
Reference in New Issue
Block a user