1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-05-13 22:06:58 +02:00

Merge pull request #658 from ShubusCorporation/shc_test_centered

Fix: Issue #3151 - text centralization
This commit is contained in:
Alexander Shishkin 2020-10-16 08:33:37 +03:00 committed by GitHub
commit ff7fd2077a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -367,8 +367,10 @@ CGStatusBar::CGStatusBar(int x, int y, std::string name, int maxw)
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
background = std::make_shared<CPicture>(name);
pos = background->pos;
if(maxw < pos.w)
if((unsigned)maxw < (unsigned)pos.w) //(insigned)-1 > than any correct value of pos.w
{
//execution of this block when maxw is incorrect breaks text centralization (issue #3151)
vstd::amin(pos.w, maxw);
background->srcRect = new Rect(0, 0, maxw, pos.h);
}