theme configurable sudden death music. untested
authornemo
Tue, 03 Jun 2014 11:09:18 -0400
changeset 10254 eb28335df088
parent 10253 ea57f2f2b98d
child 10255 fdc342ebdc31
theme configurable sudden death music. untested
hedgewars/uGears.pas
hedgewars/uLandObjects.pas
hedgewars/uSound.pas
--- a/hedgewars/uGears.pas	Sun Jun 01 16:13:47 2014 -0400
+++ b/hedgewars/uGears.pas	Tue Jun 03 11:09:18 2014 -0400
@@ -321,19 +321,19 @@
                     end;
                 AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
                 playSound(sndSuddenDeath);
-                StopMusic //No SDMusic for now
-                    //ChangeMusic(SDMusic)
-                    end
-                else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then
-                    begin
-                    i:= cSuddenDTurns - TotalRounds;
-                    s:= ansistring(inttostr(i));
-                    if i = 1 then
-                        AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState)
-                    else if (i = 2) or ((i > 0) and ((i mod 50 = 0) or ((i <= 25) and (i mod 5 = 0)))) then
-                        AddCaption(FormatA(trmsg[sidRoundsSD], s), cWhiteColor, capgrpGameState);
-                    end;
+                StopMusic;
+                if SDMusicFN <> '' then PlayMusic
+                end
+            else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then
+                begin
+                i:= cSuddenDTurns - TotalRounds;
+                s:= ansistring(inttostr(i));
+                if i = 1 then
+                    AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState)
+                else if (i = 2) or ((i > 0) and ((i mod 50 = 0) or ((i <= 25) and (i mod 5 = 0)))) then
+                    AddCaption(FormatA(trmsg[sidRoundsSD], s), cWhiteColor, capgrpGameState);
                 end;
+            end;
             if bBetweenTurns
             or isInMultiShoot
             or (TotalRounds = -1) then
--- a/hedgewars/uLandObjects.pas	Sun Jun 01 16:13:47 2014 -0400
+++ b/hedgewars/uLandObjects.pas	Tue Jun 03 11:09:18 2014 -0400
@@ -604,7 +604,9 @@
         SDWaterOpacity:= WaterOpacity
         end
     else if key = 'music' then
-        SetMusicName(Trim(s))
+        MusicFN:= Trim(s)
+    else if key = 'sd-music' then
+        SDMusicFN:= Trim(s)
     else if key = 'clouds' then
         begin
         cCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div 4096;
--- a/hedgewars/uSound.pas	Sun Jun 01 16:13:47 2014 -0400
+++ b/hedgewars/uSound.pas	Tue Jun 03 11:09:18 2014 -0400
@@ -104,6 +104,8 @@
 // Returns a pointer to the voicepack with the given name.
 function  AskForVoicepack(name: shortstring): Pointer;
 
+var MusicFN: shortstring; // music file name
+    SDMusicFN: shortstring; // SD music file name
 
 var Volume: LongInt;
     SoundTimerTicks: Longword;
@@ -117,7 +119,6 @@
     voicepacks: array[0..cMaxTeams] of TVoicepack;
     defVoicepack: PVoicepack;
     Mus: PMixMusic; // music pointer
-    MusicFN: shortstring; // music file name
     isMusicEnabled: boolean;
     isSoundEnabled: boolean;
     isSEBackup: boolean;
@@ -554,8 +555,9 @@
 begin
     if (MusicFN = '') or (not isMusicEnabled) then
         exit;
-
-    s:= '/Music/' + MusicFN;
+    if SuddenDeath and (SDMusicFN <> '') then 
+         s:= '/Music/' + SDMusicFN
+    else s:= '/Music/' + MusicFN;
     WriteToConsole(msgLoading + s + ' ');
 
     Mus:= Mix_LoadMUS_RW(rwopsOpenRead(s));