From: terencehill <piuntn@gmail.com>
Date: Mon, 7 May 2012 17:12:01 +0000 (+0200)
Subject: Playback again the menu track when the music player is stopped (3 seconds later)
X-Git-Tag: xonotic-v0.8.1~157^2~28
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2e664f8716f53aa6eabc63dfd7480552a9b4459b;p=xonotic%2Fxonotic-data.pk3dir.git

Playback again the menu track when the music player is stopped (3 seconds later)
---

diff --git a/qcsrc/menu/xonotic/soundlist.c b/qcsrc/menu/xonotic/soundlist.c
index fea84a7ce1..784b38c963 100644
--- a/qcsrc/menu/xonotic/soundlist.c
+++ b/qcsrc/menu/xonotic/soundlist.c
@@ -164,10 +164,14 @@ void SoundList_Filter_Change(entity box, entity me)
 
 void XonoticSoundList_stopSound(entity me)
 {
-	// STOP: list 0 is disabled by setting the index to 999
+	// STOP: list 0 is disabled by setting the index to -1
 	// we set sampleposition0 to -1 to indicate that music is stopped
-	cvar_set("music_playlist_index", "999");
-	localcmd("\nwait; music_playlist_sampleposition0 -1\n");
+	if(cvar("music_playlist_index") != -1) // == 0 doesn't work when paused
+	{
+		cvar_set("music_playlist_index", "-1");
+		localcmd("\nwait; music_playlist_sampleposition0 -1\n");
+		localcmd("\ndefer 3 \"cd play $menu_cdtrack\"\n");
+	}
 }
 
 void StopSound_Click(entity btn, entity me)