Sfoglia il codice sorgente

audio mute on focus lost setting

Laserlicht 1 anno fa
parent
commit
df2a5f05d8

+ 3 - 1
Mods/vcmi/config/vcmi/english.json

@@ -114,6 +114,8 @@
 	"vcmi.systemOptions.enableUiEnhancementsButton.help"   : "{Interface Enhancements}\n\nToggle various quality of life interface improvements. Such as a backpack button etc. Disable to have a more classic experience.",
 	"vcmi.systemOptions.enableLargeSpellbookButton.hover"  : "Large Spell Book",
 	"vcmi.systemOptions.enableLargeSpellbookButton.help"   : "{Large Spell Book}\n\nEnables larger spell book that fits more spells per page. Spell book page change animation does not work with this setting enabled.",
+	"vcmi.systemOptions.audioMuteFocus.hover"  : "Mute on inactivity",
+	"vcmi.systemOptions.audioMuteFocus.help"   : "{Mute on inactivity}\n\nMute audio on inactive window focus. Exceptions are ingame messages and new turn sound.",
 
 	"vcmi.adventureOptions.infoBarPick.hover" : "Show Messages in Info Panel",
 	"vcmi.adventureOptions.infoBarPick.help" : "{Show Messages in Info Panel}\n\nWhenever possible, game messages from visiting map objects will be shown in the info panel, instead of popping up in a separate window.",
@@ -258,7 +260,7 @@
 	"vcmi.optionsTab.simturnsMin.help" : "Play simultaneously for specified number of days. Contacts between players during this period are blocked",
 	"vcmi.optionsTab.simturnsMax.help" : "Play simultaneously for specified number of days or until contact with another player",
 	"vcmi.optionsTab.simturnsAI.help" : "{Simultaneous AI Turns}\nExperimental option. Allows AI players to act at the same time as human player when simultaneous turns are enabled.",
-	
+
 	"vcmi.optionsTab.turnTime.select"     : "Select turn timer preset",
 	"vcmi.optionsTab.turnTime.unlimited"  : "Unlimited turn time",
 	"vcmi.optionsTab.turnTime.classic.1"  : "Classic timer: 1 minute",

+ 2 - 0
Mods/vcmi/config/vcmi/german.json

@@ -114,6 +114,8 @@
 	"vcmi.systemOptions.enableUiEnhancementsButton.help"   : "{Interface Verbesserungen}\n\nSchaltet verschiedene Interface Verbesserungen um. Wie z.B. ein Rucksack-Button, etc. Deaktivieren, um ein klassischeres Erlebnis zu haben.",
 	"vcmi.systemOptions.enableLargeSpellbookButton.hover"  : "Großes Zauberbuch",
 	"vcmi.systemOptions.enableLargeSpellbookButton.help"   : "{Großes Zauberbuch}\n\nErmöglicht ein größeres Zauberbuch, in das mehr Zaubersprüche pro Seite passen. Die Animation des Seitenwechsels im Zauberbuch funktioniert nicht, wenn diese Einstellung aktiviert ist.",
+	"vcmi.systemOptions.audioMuteFocus.hover"  : "Stumm bei Inaktivität",
+	"vcmi.systemOptions.audioMuteFocus.help"   : "{Stumm bei Inaktivität}\n\nSchaltet Audio bei inaktiven Fenster-Fokus stumm. Ausnahmen sind Ingame-Nachrichten und der Neuer-Zug-Sound.",
 
 	"vcmi.adventureOptions.infoBarPick.hover" : "Meldungen im Infobereich anzeigen",
 	"vcmi.adventureOptions.infoBarPick.help" : "{Meldungen im Infobereich anzeigen}\n\nWann immer möglich, werden Spielnachrichten von besuchten Kartenobjekten in der Infoleiste angezeigt, anstatt als Popup-Fenster zu erscheinen",

+ 2 - 2
client/eventsSDL/InputHandler.cpp

@@ -170,7 +170,7 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
 		case SDL_WINDOWEVENT_FOCUS_GAINED:
 			{
 				boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex);
-				if(settings["general"]["enableUiEnhancements"].Bool()) {
+				if(settings["general"]["audioMuteFocus"].Bool()) {
 					CCS->musich->setVolume(settings["general"]["music"].Integer());
 					CCS->soundh->setVolume(settings["general"]["sound"].Integer());
 				}
@@ -179,7 +179,7 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
 		case SDL_WINDOWEVENT_FOCUS_LOST:
 			{
 				boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex);
-				if(settings["general"]["enableUiEnhancements"].Bool()) {
+				if(settings["general"]["audioMuteFocus"].Bool()) {
 					CCS->musich->setVolume(0);
 					CCS->soundh->setVolume(0);
 				}

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

@@ -167,6 +167,11 @@ GeneralOptionsTab::GeneralOptionsTab()
 		setBoolSetting("gameTweaks", "enableLargeSpellbook", value);
 	});
 
+	addCallback("audioMuteFocusChanged", [](bool value)
+	{
+		setBoolSetting("general", "audioMuteFocus", value);
+	});
+
 	//moved from "other" tab that is disabled for now to avoid excessible tabs with barely any content
 	addCallback("availableCreaturesAsDwellingChanged", [=](int value)
 	{
@@ -215,6 +220,10 @@ GeneralOptionsTab::GeneralOptionsTab()
 	if (enableLargeSpellbookCheckbox)
 		enableLargeSpellbookCheckbox->setSelected(settings["gameTweaks"]["enableLargeSpellbook"].Bool());
 
+	std::shared_ptr<CToggleButton> audioMuteFocusCheckbox = widget<CToggleButton>("audioMuteFocusCheckbox");
+	if (audioMuteFocusCheckbox)
+		audioMuteFocusCheckbox->setSelected(settings["general"]["audioMuteFocus"].Bool());
+
 	std::shared_ptr<CSlider> musicSlider = widget<CSlider>("musicSlider");
 	musicSlider->scrollTo(CCS->musich->getVolume());
 

+ 6 - 1
config/schemas/settings.json

@@ -39,7 +39,8 @@
 				"useSavePrefix",
 				"savePrefix",
 				"startTurnAutosave",
-				"enableUiEnhancements"
+				"enableUiEnhancements",
+				"audioMuteFocus"
 			],
 			"properties" : {
 				"playerName" : {
@@ -131,6 +132,10 @@
 				"enableUiEnhancements" : {
 					"type": "boolean",
 					"default": true
+				},
+				"audioMuteFocus" : {
+					"type": "boolean",
+					"default": false
 				}
 			}
 		},

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

@@ -180,6 +180,28 @@
 			"type": "labelCentered",
 			"position": {"x": 565, "y": 158}
 		},
+		{
+			"type" : "verticalLayout",
+			"customType" : "labelDescription",
+			"position" : {"x": 415, "y": 202},
+			"items" : [
+				{
+					"text": "vcmi.systemOptions.audioMuteFocus.hover"
+				}
+			]
+		},
+		{
+			"type" : "verticalLayout",
+			"customType" : "checkbox",
+			"position" : {"x": 380, "y": 200},
+			"items" : [
+				{
+					"name": "audioMuteFocusCheckbox",
+					"help": "vcmi.systemOptions.audioMuteFocus",
+					"callback": "audioMuteFocusChanged"
+				}
+			]
+		},
 /////////////////////////////////////// Bottom section - Towns Settings
 		{
 			"type" : "verticalLayout",