1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Merge pull request #3291 from Laserlicht/audio_mute_setting

audio mute on focus lost setting
This commit is contained in:
Ivan Savenko
2023-12-10 22:48:52 +02:00
committed by GitHub
6 changed files with 44 additions and 4 deletions

View File

@@ -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.",

View File

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

View File

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

View File

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

View File

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

View File

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