1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

disable audio on lost focus

This commit is contained in:
Laserlicht 2023-09-18 21:28:23 +02:00 committed by GitHub
parent e630dcb7de
commit 996036bdf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@
#include "../CMT.h"
#include "../CPlayerInterface.h"
#include "../CGameInfo.h"
#include "../CMusicHandler.h"
#include "../../lib/CConfigHandler.h"
@ -153,6 +154,18 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
}
#endif
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
if(settings["general"]["enableUiEnhancements"].Bool()) {
CCS->musich->setVolume(settings["general"]["music"].Integer());
CCS->soundh->setVolume(settings["general"]["sound"].Integer());
}
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
if(settings["general"]["enableUiEnhancements"].Bool()) {
CCS->musich->setVolume(0);
CCS->soundh->setVolume(0);
}
break;
}
return;
}