Explorar o código

setting to disable subtitle

Laserlicht hai 7 meses
pai
achega
7af340e301

+ 8 - 3
client/mainmenu/CPrologEpilogVideo.cpp

@@ -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)

+ 10 - 6
client/widgets/VideoWidget.cpp

@@ -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;
 
-	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);
+	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;

+ 9 - 0
client/windows/settings/GeneralOptionsTab.cpp

@@ -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());
 

+ 6 - 1
config/schemas/settings.json

@@ -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
 				}
 			}
 		},

+ 8 - 0
config/widgets/settings/generalOptionsTab.json

@@ -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"
 				}
 			]
 		},