First step toward repairing the volume adjusters with the cutsound feature. It was...
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 26 Feb 2011 16:26:00 +0000 (18:26 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 26 Feb 2011 16:26:00 +0000 (18:26 +0200)
data/qcsrc/client/View.qc

index 41cfb57..0e4167c 100644 (file)
@@ -256,7 +256,7 @@ float pickup_crosshair_time, pickup_crosshair_size;
 float myhealth, myhealth_prev, myhealth_flash;\r
 float contentavgalpha, liquidalpha_prev;\r
 float stomachsplash_alpha, stomachsplash_remove_at_respawn;\r
-float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2, volume_modify_default_set;\r
+float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2;\r
 vector myhealth_gentlergb;\r
 vector liquidcolor_prev;\r
 vector damage_blurpostprocess, content_blurpostprocess;\r
@@ -698,48 +698,51 @@ void CSQC_UpdateView(float w, float h)
 \r
        if(cvar("cl_vore_cutvolume_sound") < 1 || cvar("cl_vore_cutvolume_music") < 1)\r
        {\r
-               if(!volume_modify_default_set)\r
+               float volume_modify_1_target, volume_modify_2_target, volume_modify_fade;\r
+               if(getstati(STAT_VORE_EATEN))\r
+               {\r
+                       volume_modify_1_target = volume_modify_default_1 * cvar("cl_vore_cutvolume_sound");\r
+                       volume_modify_2_target = volume_modify_default_2 * cvar("cl_vore_cutvolume_music");\r
+               }\r
+               else\r
+               {\r
+                       volume_modify_1_target = 1;\r
+                       volume_modify_2_target = 1;\r
+               }\r
+               volume_modify_fade = cvar("cl_vore_cutvolume_fade") * frametime;\r
+\r
+               if(spectatee_status == -1 || intermission)\r
                {\r
-                       // set the initial volume\r
+                       // no volume fading is currently taking place, so if we change the volume settings, update the initial volume\r
                        volume_modify_default_1 = cvar("volume");\r
                        volume_modify_default_2 = cvar("bgmvolume");\r
-                       volume_modify_default_set = TRUE;\r
                }\r
-               if(spectatee_status == -1 || intermission)\r
-                       volume_modify_1 = volume_modify_2 = 1;\r
-               else if (getstati(STAT_VORE_EATEN))\r
+               else if(volume_modify_1 != volume_modify_1_target || volume_modify_2 != volume_modify_2_target)\r
                {\r
-                       if (volume_modify_1 > cvar("cl_vore_cutvolume_sound"))\r
-                       {\r
-                               volume_modify_1 -= cvar("cl_vore_cutvolume_fade") * frametime;\r
-                               if(volume_modify_1 < cvar("cl_vore_cutvolume_sound"))\r
-                                       volume_modify_1 = cvar("cl_vore_cutvolume_sound");\r
-                       }\r
-                       if (volume_modify_2 > cvar("cl_vore_cutvolume_music"))\r
-                       {\r
-                               volume_modify_2 -= cvar("cl_vore_cutvolume_fade") * frametime;\r
-                               if(volume_modify_2 < cvar("cl_vore_cutvolume_music"))\r
-                                       volume_modify_2 = cvar("cl_vore_cutvolume_music");\r
-                       }\r
+                       if (volume_modify_1 > volume_modify_1_target + volume_modify_fade)\r
+                               volume_modify_1 -= volume_modify_fade;\r
+                       else if (volume_modify_1 < volume_modify_1_target - volume_modify_fade)\r
+                               volume_modify_1 += volume_modify_fade;\r
+                       else\r
+                               volume_modify_1 = volume_modify_1_target;\r
+\r
+                       if (volume_modify_2 > volume_modify_2_target + volume_modify_fade)\r
+                               volume_modify_2 -= volume_modify_fade;\r
+                       else if (volume_modify_2 < volume_modify_2_target - volume_modify_fade)\r
+                               volume_modify_2 += volume_modify_fade;\r
+                       else\r
+                               volume_modify_2 = volume_modify_1_target;\r
+\r
+                       cvar_set("volume", ftos(volume_modify_1));\r
+                       cvar_set("bgmvolume", ftos(volume_modify_2));\r
+                       // TODO: Setting the "volume" cvar is a bad way to go, and modifies the menu slider! We need a better way\r
                }\r
-               else\r
+               else if(cvar("volume") != volume_modify_default_1 || cvar("bgmvolume") != volume_modify_default_2)\r
                {\r
-                       if (volume_modify_1 < 1)\r
-                       {\r
-                               volume_modify_1 += cvar("cl_vore_cutvolume_fade") * frametime;\r
-                               if(volume_modify_1 > 1)\r
-                                       volume_modify_1 = 1;\r
-                       }\r
-                       if (volume_modify_2 < 1)\r
-                       {\r
-                               volume_modify_2 += cvar("cl_vore_cutvolume_fade") * frametime;\r
-                               if(volume_modify_2 > 1)\r
-                                       volume_modify_2 = 1;\r
-                       }\r
+                       // no volume fading is currently taking place, so if we change the volume settings, update the initial volume\r
+                       volume_modify_default_1 = cvar("volume");\r
+                       volume_modify_default_2 = cvar("bgmvolume");\r
                }\r
-               cvar_set("volume", ftos(volume_modify_default_1 * volume_modify_1));\r
-               cvar_set("bgmvolume", ftos(volume_modify_default_2 * volume_modify_2));\r
-               // TODO: Setting the "volume" cvar is a bad way to go, and modifies the menu slider! We need a better way to go\r
        }\r
 \r
        // Draw the mouse cursor\r