Prevent displaying "Volume: 0%" when not exactly 0
authorWuzzy <Wuzzy2@mail.ru>
Tue, 05 Feb 2019 04:55:40 +0100
changeset 14687 204fb862d0e4
parent 14686 bd43e703608b
child 14688 932ff7683653
Prevent displaying "Volume: 0%" when not exactly 0
hedgewars/uSound.pas
--- a/hedgewars/uSound.pas	Tue Feb 05 03:39:03 2019 +0100
+++ b/hedgewars/uSound.pas	Tue Feb 05 04:55:40 2019 +0100
@@ -116,7 +116,7 @@
 // Modifies the sound volume of the game by voldelta and returns the new volume level.
 function  ChangeVolume(voldelta: LongInt): LongInt;
 
-// Returns the current volume in percent
+// Returns the current volume in percent. Intended for display on UI.
 function  GetVolumePercent(): LongInt;
 
 // Returns a pointer to the voicepack with the given name.
@@ -867,6 +867,12 @@
 function GetVolumePercent(): LongInt;
 begin
     GetVolumePercent:= Volume * 100 div MIX_MAX_VOLUME;
+    // 0 and 100 will only be displayed when at min/max values
+    // to avoid confusion.
+    if ((GetVolumePercent = 0) and (Volume > 0)) then
+        GetVolumePercent:= 1
+    else if ((GetVolumePercent = 100) and (Volume < MIX_MAX_VOLUME)) then
+        GetVolumePercent:= 99;
 end;
 
 function ChangeVolume(voldelta: LongInt): LongInt;