1
0
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:
Laserlicht
2025-03-10 00:04:44 +01:00
parent ee5cddb52c
commit 7af340e301
5 changed files with 41 additions and 10 deletions

View File

@ -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,6 +88,7 @@ void CPrologEpilogVideo::show(Canvas & to)
to.drawColor(pos, Colors::BLACK);
videoPlayer->show(to);
if(text)
text->showAll(to); // blit text over video, if needed
}

View File

@ -18,6 +18,7 @@
#include "../render/Canvas.h"
#include "../render/IScreenHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/filesystem/Filesystem.h"
VideoWidgetBase::VideoWidgetBase(const Point & position, const VideoPath & video, bool playAudio)
@ -39,12 +40,15 @@ void VideoWidgetBase::playVideo(const VideoPath & fileToPlay)
{
OBJECT_CONSTRUCTION;
if(settings["general"]["enableSubtitle"].Bool())
{
JsonPath subTitlePath = fileToPlay.toType<EResType::JSON>();
JsonPath subTitlePathVideoDir = subTitlePath.addPrefix("VIDEO/");
if(CResourceHandler::get()->existsResource(subTitlePath))
subTitleData = JsonNode(subTitlePath);
else if(CResourceHandler::get()->existsResource(subTitlePathVideoDir))
subTitleData = JsonNode(subTitlePathVideoDir);
}
float preScaleFactor = 1;
VideoPath videoFile = fileToPlay;

View File

@ -185,6 +185,11 @@ GeneralOptionsTab::GeneralOptionsTab()
setBoolSetting("general", "audioMuteFocus", value);
});
addCallback("enableSubtitleChanged", [](bool value)
{
setBoolSetting("general", "enableSubtitle", value);
});
//moved from "other" tab that is disabled for now to avoid excessible tabs with barely any content
addCallback("availableCreaturesAsDwellingChanged", [=](int value)
{
@ -243,6 +248,10 @@ GeneralOptionsTab::GeneralOptionsTab()
if (audioMuteFocusCheckbox)
audioMuteFocusCheckbox->setSelected(settings["general"]["audioMuteFocus"].Bool());
std::shared_ptr<CToggleButton> enableSubtitleCheckbox = widget<CToggleButton>("enableSubtitleCheckbox");
if (enableSubtitleCheckbox)
enableSubtitleCheckbox->setSelected(settings["general"]["enableSubtitle"].Bool());
std::shared_ptr<CSlider> musicSlider = widget<CSlider>("musicSlider");
musicSlider->scrollTo(ENGINE->music().getVolume());

View File

@ -44,7 +44,8 @@
"enableUiEnhancements",
"audioMuteFocus",
"enableOverlay",
"lastKindomInterface"
"lastKindomInterface",
"enableSubtitle"
],
"properties" : {
"playerName" : {
@ -156,6 +157,10 @@
"lastKindomInterface" : {
"type" : "number",
"default" : 0
},
"enableSubtitle" : {
"type": "boolean",
"default": true
}
}
},

View File

@ -227,6 +227,9 @@
"items" : [
{
"text": "vcmi.systemOptions.audioMuteFocus.hover"
},
{
"text": "core.genrltxt.575"
}
]
},
@ -239,6 +242,11 @@
"name": "audioMuteFocusCheckbox",
"help": "vcmi.systemOptions.audioMuteFocus",
"callback": "audioMuteFocusChanged"
},
{
"name": "enableSubtitleCheckbox",
"help": "core.help.363",
"callback": "enableSubtitleChanged"
}
]
},