# HG changeset patch # User Wuzzy # Date 1519145542 -3600 # Node ID aed4b25ff242a5ffd51f42001ba85d7c2bee48f2 # Parent 356995c8c48b1fc357777314d5b5acbcd10a8136 Fix volume caption not being shown when hitting mute key diff -r 356995c8c48b -r aed4b25ff242 ChangeLog.txt --- a/ChangeLog.txt Tue Feb 20 15:37:36 2018 +0100 +++ b/ChangeLog.txt Tue Feb 20 17:52:22 2018 +0100 @@ -12,6 +12,7 @@ + Hedgehog tag translucency is now changed with [Switch] + [Change hedgehog tags] * Fix time box being usable in Sudden Death with 0 health decrease * Fix chat input key being sometimes registered twice + * Fix not displaying current volume status after pressing mute key Frontend: + Schemes are now stored in separate files under Schemes diff -r 356995c8c48b -r aed4b25ff242 hedgewars/uCommandHandlers.pas --- a/hedgewars/uCommandHandlers.pas Tue Feb 20 15:37:36 2018 +0100 +++ b/hedgewars/uCommandHandlers.pas Tue Feb 20 17:52:22 2018 +0100 @@ -569,6 +569,12 @@ dec(cVolumeDelta, 3) end; +procedure chMute(var s: shortstring); +begin +s:= s; // avoid compiler hint +cMuteToggle:= true; +end; + procedure chFindhh(var s: shortstring); begin s:= s; // avoid compiler hint @@ -901,6 +907,7 @@ RegisterVariable('-volup' , @chVol_m , true ); RegisterVariable('+voldown', @chVol_m , true ); RegisterVariable('-voldown', @chVol_p , true ); + RegisterVariable('mute' , @chMute , true ); RegisterVariable('findhh' , @chFindhh , true ); RegisterVariable('pause' , @chPause , true ); RegisterVariable('+cur_u' , @chCurU_p , true ); diff -r 356995c8c48b -r aed4b25ff242 hedgewars/uGame.pas --- a/hedgewars/uGame.pas Tue Feb 20 15:37:36 2018 +0100 +++ b/hedgewars/uGame.pas Tue Feb 20 17:52:22 2018 +0100 @@ -93,6 +93,18 @@ s:= ansistring(inttostr(i)); AddCaption(FormatA(trmsg[sidVolume], s), cWhiteColor, capgrpVolume) end + end + else if cMuteToggle then + begin + MuteAudio; + if isAudioMuted then + AddCaption(trmsg[sidMute], cWhiteColor, capgrpVolume) + else + begin + s:= ansistring(inttostr(GetVolumePercent())); + AddCaption(FormatA(trmsg[sidVolume], s), cWhiteColor, capgrpVolume); + end; + cMuteToggle:= false; end; end; PlayNextVoice; diff -r 356995c8c48b -r aed4b25ff242 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Tue Feb 20 15:37:36 2018 +0100 +++ b/hedgewars/uSound.pas Tue Feb 20 17:52:22 2018 +0100 @@ -101,6 +101,9 @@ // 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 +function GetVolumePercent(): LongInt; + // Returns a pointer to the voicepack with the given name. function AskForVoicepack(name: shortstring): Pointer; @@ -672,6 +675,11 @@ cInitVolume:= vol; end; +function GetVolumePercent(): LongInt; +begin + GetVolumePercent:= Volume * 100 div MIX_MAX_VOLUME; +end; + function ChangeVolume(voldelta: LongInt): LongInt; begin ChangeVolume:= 0; @@ -687,7 +695,7 @@ Volume:= Mix_Volume(-1, -1); if isMusicEnabled then Mix_VolumeMusic(Volume * 4 div 8); - ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME; + ChangeVolume:= GetVolumePercent(); if (isMusicEnabled) then if (Volume = 0) then @@ -793,12 +801,6 @@ CurrentTeam^.voicepack:= AskForVoicepack(s) end; -procedure chMute(var s: shortstring); -begin - s:= s; // avoid compiler hint - MuteAudio; -end; - procedure preInitModule; begin isMusicEnabled:= true; @@ -811,7 +813,6 @@ i: TSound; begin RegisterVariable('voicepack', @chVoicepack, false); - RegisterVariable('mute' , @chMute , true ); MusicFN:=''; SDMusicFN:= 'sdmusic.ogg'; diff -r 356995c8c48b -r aed4b25ff242 hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Tue Feb 20 15:37:36 2018 +0100 +++ b/hedgewars/uVariables.pas Tue Feb 20 17:52:22 2018 +0100 @@ -166,6 +166,7 @@ cScriptParam : shortstring; cSeed : shortstring; cVolumeDelta : LongInt; + cMuteToggle : boolean; // Mute toggle requested cHasFocus : boolean; cInactDelay : Longword; @@ -2837,6 +2838,7 @@ autoCameraOn := true; cSeed := ''; cVolumeDelta := 0; + cMuteToggle := false; cHasFocus := true; cInactDelay := 100; ReadyTimeLeft := 0;