From: MirceaKitsune Date: Fri, 25 Feb 2011 20:35:40 +0000 (+0200) Subject: Colorize the screen when inside water or other fluids (code ported back from Xonotic) X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ab879337bb60c220f47d15fcfdf6f8c52fe77dea;p=voretournament%2Fvoretournament.git Colorize the screen when inside water or other fluids (code ported back from Xonotic) --- diff --git a/data/defaultVoretournament.cfg b/data/defaultVoretournament.cfg index 5a2a208d..0c88250b 100644 --- a/data/defaultVoretournament.cfg +++ b/data/defaultVoretournament.cfg @@ -1059,6 +1059,17 @@ con_chatwidth 0.6 con_notifysize 10 con_notifyalign 0 +seta hud_contents 1 "an improved version of gl_polyblend for liquids such as water/lava/slime, draw a filler when inside the liquid" +seta hud_contents_factor 1 "factor at which to multiply the current faded value." +seta hud_contents_fadeintime 0.02 "factor of time it takes for the alpha level to reach normal value when entering the liquid" +seta hud_contents_fadeouttime 0.1 "factor of time it takes for the alpha level to reach normal value when leaving the liquid" +seta hud_contents_lava_alpha 0.7 "alpha of the lava color blend when inside it" +seta hud_contents_lava_color "0.8 0.1 0" +seta hud_contents_slime_alpha 0.7 "alpha of the slime color blend when inside it" +seta hud_contents_slime_color "0 0.4 0.1" +seta hud_contents_water_alpha 0.5 "alpha of the water color blend when inside it" +seta hud_contents_water_color "0.4 0.3 0.3" + sbar_info_pos 50 seta sbar_alpha_bg 0.8 "alpha value of the HUD background" seta sbar_alpha_fg 1 "alpha value of the HUD foreground items" diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index 9ae5a03b..37090311 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -253,6 +253,8 @@ float camera_mode; float chase_active_old; float artwork_fade; float pickup_crosshair_time, pickup_crosshair_size; +float contentavgalpha, liquidalpha_prev; +vector liquidcolor_prev; string artwork_image; string intermission_song; string NextFrameCommand; @@ -451,6 +453,54 @@ void CSQC_UpdateView(float w, float h) // next R_RenderScene call drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0); + if(cvar("hud_contents")) + { + float contentalpha_temp, incontent, liquidalpha, contentfadetime; + vector liquidcolor; + + switch(pointcontents(view_origin)) + { + case CONTENT_WATER: + liquidalpha = cvar("hud_contents_water_alpha"); + liquidcolor = stov(cvar_string("hud_contents_water_color")); + incontent = 1; + break; + + case CONTENT_LAVA: + liquidalpha = cvar("hud_contents_lava_alpha"); + liquidcolor = stov(cvar_string("hud_contents_lava_color")); + incontent = 1; + break; + + case CONTENT_SLIME: + liquidalpha = cvar("hud_contents_slime_alpha"); + liquidcolor = stov(cvar_string("hud_contents_slime_color")); + incontent = 1; + break; + + default: + liquidalpha = 0; + liquidcolor = '0 0 0'; + incontent = 0; + break; + } + + if(incontent) // fade in/out at different speeds so you can do e.g. instant fade when entering water and slow when leaving it. + { // also lets delcare previous values for blending properties, this way it isn't reset until after you have entered a different content + contentfadetime = cvar("hud_contents_fadeintime"); + liquidalpha_prev = liquidalpha; + liquidcolor_prev = liquidcolor; + } + else + contentfadetime = cvar("hud_contents_fadeouttime"); + + contentalpha_temp = bound(0, drawframetime / max(0.0001, contentfadetime), 1); + contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp; + + if(contentavgalpha) + drawfill('0 0 0', '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, liquidcolor_prev, contentavgalpha * liquidalpha_prev, DRAWFLAG_NORMAL); + } + // Draw the mouse cursor // NOTE: drawpic must happen after R_RenderScene for some reason //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);