From: MirceaKitsune Date: Sat, 26 Feb 2011 16:26:00 +0000 (+0200) Subject: First step toward repairing the volume adjusters with the cutsound feature. It was... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8cac9a6f0e00ad7b1a39f9b616e4da769550df3d;p=voretournament%2Fvoretournament.git First step toward repairing the volume adjusters with the cutsound feature. It was broken before, and still is broken now. --- diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index 41cfb576..0e4167c8 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -256,7 +256,7 @@ float pickup_crosshair_time, pickup_crosshair_size; float myhealth, myhealth_prev, myhealth_flash; float contentavgalpha, liquidalpha_prev; float stomachsplash_alpha, stomachsplash_remove_at_respawn; -float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2, volume_modify_default_set; +float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2; vector myhealth_gentlergb; vector liquidcolor_prev; vector damage_blurpostprocess, content_blurpostprocess; @@ -698,48 +698,51 @@ void CSQC_UpdateView(float w, float h) if(cvar("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1) { - if(!volume_modify_default_set) + float volume_modify_1_target, volume_modify_2_target, volume_modify_fade; + if(getstati(STAT_VORE_EATEN)) + { + volume_modify_1_target = volume_modify_default_1 * cvar("cl_vore_cutvolume_sound"); + volume_modify_2_target = volume_modify_default_2 * cvar("cl_vore_cutvolume_music"); + } + else + { + volume_modify_1_target = 1; + volume_modify_2_target = 1; + } + volume_modify_fade = cvar("cl_vore_cutvolume_fade") * frametime; + + if(spectatee_status == -1 || intermission) { - // set the initial volume + // no volume fading is currently taking place, so if we change the volume settings, update the initial volume volume_modify_default_1 = cvar("volume"); volume_modify_default_2 = cvar("bgmvolume"); - volume_modify_default_set = TRUE; } - if(spectatee_status == -1 || intermission) - volume_modify_1 = volume_modify_2 = 1; - else if (getstati(STAT_VORE_EATEN)) + else if(volume_modify_1 != volume_modify_1_target || volume_modify_2 != volume_modify_2_target) { - if (volume_modify_1 > cvar("cl_vore_cutvolume_sound")) - { - volume_modify_1 -= cvar("cl_vore_cutvolume_fade") * frametime; - if(volume_modify_1 < cvar("cl_vore_cutvolume_sound")) - volume_modify_1 = cvar("cl_vore_cutvolume_sound"); - } - if (volume_modify_2 > cvar("cl_vore_cutvolume_music")) - { - volume_modify_2 -= cvar("cl_vore_cutvolume_fade") * frametime; - if(volume_modify_2 < cvar("cl_vore_cutvolume_music")) - volume_modify_2 = cvar("cl_vore_cutvolume_music"); - } + if (volume_modify_1 > volume_modify_1_target + volume_modify_fade) + volume_modify_1 -= volume_modify_fade; + else if (volume_modify_1 < volume_modify_1_target - volume_modify_fade) + volume_modify_1 += volume_modify_fade; + else + volume_modify_1 = volume_modify_1_target; + + if (volume_modify_2 > volume_modify_2_target + volume_modify_fade) + volume_modify_2 -= volume_modify_fade; + else if (volume_modify_2 < volume_modify_2_target - volume_modify_fade) + volume_modify_2 += volume_modify_fade; + else + volume_modify_2 = volume_modify_1_target; + + cvar_set("volume", ftos(volume_modify_1)); + cvar_set("bgmvolume", ftos(volume_modify_2)); + // TODO: Setting the "volume" cvar is a bad way to go, and modifies the menu slider! We need a better way } - else + else if(cvar("volume") != volume_modify_default_1 || cvar("bgmvolume") != volume_modify_default_2) { - if (volume_modify_1 < 1) - { - volume_modify_1 += cvar("cl_vore_cutvolume_fade") * frametime; - if(volume_modify_1 > 1) - volume_modify_1 = 1; - } - if (volume_modify_2 < 1) - { - volume_modify_2 += cvar("cl_vore_cutvolume_fade") * frametime; - if(volume_modify_2 > 1) - volume_modify_2 = 1; - } + // no volume fading is currently taking place, so if we change the volume settings, update the initial volume + volume_modify_default_1 = cvar("volume"); + volume_modify_default_2 = cvar("bgmvolume"); } - cvar_set("volume", ftos(volume_modify_default_1 * volume_modify_1)); - cvar_set("bgmvolume", ftos(volume_modify_default_2 * volume_modify_2)); - // TODO: Setting the "volume" cvar is a bad way to go, and modifies the menu slider! We need a better way to go } // Draw the mouse cursor