From: terencehill Date: Wed, 7 Aug 2013 09:45:15 +0000 (+0200) Subject: Pause music when the screenshot viewer is opened as image browsing can make music... X-Git-Tag: xonotic-v0.8.0~139^2~1^2~155^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=aa22d4f5258f70b6aa047bfa31eea06e5920d438;p=xonotic%2Fxonotic-data.pk3dir.git Pause music when the screenshot viewer is opened as image browsing can make music lag depending on image loading time --- diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c index 4e0e908e0..146f496be 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c @@ -18,8 +18,24 @@ ENDCLASS(XonoticScreenshotViewerDialog) #endif #ifdef IMPLEMENTATION +float music_playlist_index_backup; void XonoticScreenshotViewerDialog_loadScreenshot(entity me, string scrImage) { + // disable music as it can lag depending on image loading time + if(!cvar("menu_screenshotviewer_enablemusic")) + if(cvar("music_playlist_index") != 999) // if the playlist isn't paused + { + // pause music + if(cvar("music_playlist_index") != -1) + { + music_playlist_index_backup = cvar("music_playlist_index"); + cvar_set("music_playlist_sampleposition0", "0"); + cvar_set("music_playlist_index", "999"); + } + else + localcmd("\ncd pause\n"); + } + if (me.currentScrPath == scrImage) return; if (me.currentScrPath) @@ -106,6 +122,15 @@ float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, f } void XonoticScreenshotViewerDialog_close(entity me) { + // resume music + if(!cvar("menu_screenshotviewer_enablemusic")) + if(cvar("music_playlist_index") == 999) + { + cvar_set("music_playlist_index", ftos(music_playlist_index_backup)); + } + else + localcmd("\ncd resume\n"); + me.scrList.stopSlideShow(me.scrList); me.slideShowButton.forcePressed = 0; SUPER(XonoticScreenshotViewerDialog).close(me);