hedgewars/uSound.pas
changeset 14682 204fb862d0e4
parent 14598 62dea281e4d5
child 14819 fba15e2f5e5b
equal deleted inserted replaced
14681:bd43e703608b 14682:204fb862d0e4
   114 procedure SetVolume(vol: LongInt);
   114 procedure SetVolume(vol: LongInt);
   115 
   115 
   116 // Modifies the sound volume of the game by voldelta and returns the new volume level.
   116 // Modifies the sound volume of the game by voldelta and returns the new volume level.
   117 function  ChangeVolume(voldelta: LongInt): LongInt;
   117 function  ChangeVolume(voldelta: LongInt): LongInt;
   118 
   118 
   119 // Returns the current volume in percent
   119 // Returns the current volume in percent. Intended for display on UI.
   120 function  GetVolumePercent(): LongInt;
   120 function  GetVolumePercent(): LongInt;
   121 
   121 
   122 // Returns a pointer to the voicepack with the given name.
   122 // Returns a pointer to the voicepack with the given name.
   123 function  AskForVoicepack(name: shortstring): Pointer;
   123 function  AskForVoicepack(name: shortstring): Pointer;
   124 
   124 
   865 end;
   865 end;
   866 
   866 
   867 function GetVolumePercent(): LongInt;
   867 function GetVolumePercent(): LongInt;
   868 begin
   868 begin
   869     GetVolumePercent:= Volume * 100 div MIX_MAX_VOLUME;
   869     GetVolumePercent:= Volume * 100 div MIX_MAX_VOLUME;
       
   870     // 0 and 100 will only be displayed when at min/max values
       
   871     // to avoid confusion.
       
   872     if ((GetVolumePercent = 0) and (Volume > 0)) then
       
   873         GetVolumePercent:= 1
       
   874     else if ((GetVolumePercent = 100) and (Volume < MIX_MAX_VOLUME)) then
       
   875         GetVolumePercent:= 99;
   870 end;
   876 end;
   871 
   877 
   872 function ChangeVolume(voldelta: LongInt): LongInt;
   878 function ChangeVolume(voldelta: LongInt): LongInt;
   873 begin
   879 begin
   874     ChangeVolume:= 0;
   880     ChangeVolume:= 0;