mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-07 00:58:39 +02:00
setting to disable subtitle
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
#include "../widgets/VideoWidget.h"
|
||||
#include "../widgets/Images.h"
|
||||
#include "../render/Canvas.h"
|
||||
#include "../lib/CConfigHandler.h"
|
||||
|
||||
CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::function<void()> callback)
|
||||
: CWindowObject(BORDERED), spe(_spe), positionCounter(0), voiceSoundHandle(-1), videoSoundHandle(-1), exitCb(callback), elapsedTimeMilliseconds(0)
|
||||
@ -56,6 +57,9 @@ CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::f
|
||||
};
|
||||
ENGINE->sound().setCallback(voiceSoundHandle, onVoiceStop);
|
||||
|
||||
if(!settings["general"]["enableSubtitle"].Bool())
|
||||
return;
|
||||
|
||||
text = std::make_shared<CMultiLineLabel>(Rect(100, 500, 600, 100), EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::METALLIC_GOLD, spe.prologText.toString());
|
||||
if(text->getLines().size() == 3)
|
||||
text->scrollTextTo(-25); // beginning of text in the vertical middle of black area
|
||||
@ -67,9 +71,9 @@ void CPrologEpilogVideo::tick(uint32_t msPassed)
|
||||
{
|
||||
elapsedTimeMilliseconds += msPassed;
|
||||
|
||||
const uint32_t speed = (voiceDurationMilliseconds == 0) ? 150 : (voiceDurationMilliseconds / (text->textSize.y));
|
||||
const uint32_t speed = (!text || voiceDurationMilliseconds == 0) ? 150 : (voiceDurationMilliseconds / (text->textSize.y));
|
||||
|
||||
if(elapsedTimeMilliseconds > speed && text->textSize.y - 50 > positionCounter)
|
||||
if(text && elapsedTimeMilliseconds > speed && text->textSize.y - 50 > positionCounter)
|
||||
{
|
||||
text->scrollTextBy(1);
|
||||
elapsedTimeMilliseconds -= speed;
|
||||
@ -84,7 +88,8 @@ void CPrologEpilogVideo::show(Canvas & to)
|
||||
to.drawColor(pos, Colors::BLACK);
|
||||
|
||||
videoPlayer->show(to);
|
||||
text->showAll(to); // blit text over video, if needed
|
||||
if(text)
|
||||
text->showAll(to); // blit text over video, if needed
|
||||
}
|
||||
|
||||
void CPrologEpilogVideo::clickPressed(const Point & cursorPosition)
|
||||
|
Reference in New Issue
Block a user