1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #4780 from Laserlicht/text_pos_fix

fix: campaign video scrolling for short texts
This commit is contained in:
Ivan Savenko 2024-10-15 18:01:52 +03:00 committed by GitHub
commit 52e0899d6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -60,7 +60,10 @@ CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::f
CCS->soundh->setCallback(voiceSoundHandle, onVoiceStop);
text = std::make_shared<CMultiLineLabel>(Rect(100, 500, 600, 100), EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::METALLIC_GOLD, spe.prologText.toString());
text->scrollTextTo(-50); // beginning of text in the vertical middle of black area
if(text->getLines().size() == 3)
text->scrollTextTo(-25); // beginning of text in the vertical middle of black area
else if(text->getLines().size() > 3)
text->scrollTextTo(-50); // beginning of text in the vertical middle of black area
}
void CPrologEpilogVideo::tick(uint32_t msPassed)

View File

@ -176,6 +176,11 @@ void CMultiLineLabel::setText(const std::string & Txt)
CLabel::setText(Txt);
}
std::vector<std::string> CMultiLineLabel::getLines()
{
return lines;
}
void CTextContainer::blitLine(Canvas & to, Rect destRect, std::string what)
{
const auto f = GH.renderHandler().loadFont(font);

View File

@ -96,6 +96,7 @@ public:
CMultiLineLabel(Rect position, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::TOPLEFT, const ColorRGBA & Color = Colors::WHITE, const std::string & Text = "");
void setText(const std::string & Txt) override;
std::vector<std::string> getLines();
void showAll(Canvas & to) override;
void setVisibleSize(Rect visibleSize, bool redrawElement = true);