hedgewars/uSound.pas
changeset 6472 bced12412f94
parent 6415 af2047bb4f70
child 6521 16d9ac07f504
equal deleted inserted replaced
6471:010ec2fa7d7b 6472:bced12412f94
    50 // Obvious music commands for music track specified in MusicFN.
    50 // Obvious music commands for music track specified in MusicFN.
    51 procedure PlayMusic;
    51 procedure PlayMusic;
    52 procedure PauseMusic;
    52 procedure PauseMusic;
    53 procedure ResumeMusic;
    53 procedure ResumeMusic;
    54 procedure ChangeMusic; // Replaces music track with current MusicFN and plays it.
    54 procedure ChangeMusic; // Replaces music track with current MusicFN and plays it.
       
    55 procedure StopMusic; // Stops and releases the current track
    55 
    56 
    56 
    57 
    57 // SOUNDS
    58 // SOUNDS
    58 
    59 
    59 // Plays the sound snd [from a given voicepack],
    60 // Plays the sound snd [from a given voicepack],
   456 procedure PauseMusic;
   457 procedure PauseMusic;
   457 begin
   458 begin
   458     if (MusicFN = '') or (not isMusicEnabled) then
   459     if (MusicFN = '') or (not isMusicEnabled) then
   459         exit;
   460         exit;
   460 
   461 
   461     Mix_PauseMusic(Mus);
   462     if Mus <> nil then
       
   463     	Mix_PauseMusic(Mus);
   462 end;
   464 end;
   463 
   465 
   464 procedure ResumeMusic;
   466 procedure ResumeMusic;
   465 begin
   467 begin
   466     if (MusicFN = '') or (not isMusicEnabled) then
   468     if (MusicFN = '') or (not isMusicEnabled) then
   467         exit;
   469         exit;
   468 
   470 
   469     Mix_ResumeMusic(Mus);
   471     if Mus <> nil then
       
   472     	Mix_ResumeMusic(Mus);
   470 end;
   473 end;
   471 
   474 
   472 procedure ChangeMusic;
   475 procedure ChangeMusic;
   473 begin
   476 begin
   474     if (MusicFN = '') or (not isMusicEnabled) then
   477     if (MusicFN = '') or (not isMusicEnabled) then
   475         exit;
   478         exit;
   476 
   479 
   477     // get rid of current music
   480     StopMusic;
       
   481     PlayMusic;
       
   482 end;
       
   483 
       
   484 procedure StopMusic;
       
   485 begin
       
   486     if (MusicFN = '') or (not isMusicEnabled) then
       
   487         exit;
       
   488 
   478     if Mus <> nil then
   489     if Mus <> nil then
   479         Mix_FreeMusic(Mus);
   490         Mix_FreeMusic(Mus);
   480 
       
   481     PlayMusic;
       
   482 end;
   491 end;
   483 
   492 
   484 procedure chVoicepack(var s: shortstring);
   493 procedure chVoicepack(var s: shortstring);
   485 begin
   494 begin
   486     if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/voicepack"', true);
   495     if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/voicepack"', true);