From 3ce6d7020bc054d440e40dd0eccc795fa6babcb2 Mon Sep 17 00:00:00 2001 From: medsouz Date: Tue, 11 Aug 2015 00:42:18 -0400 Subject: [PATCH] Pause audio when tabbing out TODO: Figure out why title music and toilet sounds are still playing Add an option to disable this feature so that people can jam out to the carousel music while tabbed out. --- src/platform/shared.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/platform/shared.c b/src/platform/shared.c index cb5dadf239..3ccc5c0825 100644 --- a/src/platform/shared.c +++ b/src/platform/shared.c @@ -19,6 +19,7 @@ *****************************************************************************/ #include "../addresses.h" +#include "../audio/audio.h" #include "../config.h" #include "../cursors.h" #include "../drawing/drawing.h" @@ -351,6 +352,16 @@ void platform_process_messages() case SDL_WINDOWEVENT: if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) platform_resize(e.window.data1, e.window.data2); + if (e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { + if (gConfigSound.sound) { + unpause_sounds(); + } + } + if (e.window.event == SDL_WINDOWEVENT_FOCUS_LOST) { + if (gConfigSound.sound) { + pause_sounds(); + } + } break; case SDL_MOUSEMOTION: RCT2_GLOBAL(0x0142406C, int) = e.motion.x;