Browse Source

disable audio on lost focus

Laserlicht 2 năm trước cách đây
mục cha
commit
996036bdf2
1 tập tin đã thay đổi với 13 bổ sung0 xóa
  1. 13 0
      client/eventsSDL/InputHandler.cpp

+ 13 - 0
client/eventsSDL/InputHandler.cpp

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