From: Samual Lenks Date: Sun, 12 May 2013 00:49:05 +0000 (-0400) Subject: Update how crosshair color selection is handled, create a switch for it X-Git-Tag: xonotic-v0.7.0~53^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9ecb13ee6bbad614b17f95ef89b2f7ec3a3750dc;p=xonotic%2Fxonotic-data.pk3dir.git Update how crosshair color selection is handled, create a switch for it --- diff --git a/crosshairs.cfg b/crosshairs.cfg index 655e90a21..7f0db53e4 100644 --- a/crosshairs.cfg +++ b/crosshairs.cfg @@ -37,13 +37,9 @@ seta crosshair_hittest_blur 1 "blur the crosshair if the shot is obstructed" seta crosshair_hittest_showimpact 0 "move the crosshair to the actual impact location if obstructed" // change color based on special case -seta crosshair_color_by_health 0 "if enabled, crosshair color will depend on current health" -seta crosshair_color_per_weapon 1 "when 1, each gun will display the crosshair with a different color" - -// change color randomly on a timer -seta crosshair_rainbow 0 -seta crosshair_rainbow_delay 0.1 -seta crosshair_rainbow_brightness 2 "color brightness of the random crosshair colors" +seta crosshair_color_special 1 "special color handling for crosshair... 1 = per-weapon crosshair color (see crosshair_per_weapon), 2 = crosshair changes color based on health, 3 = rainbow/random color selection" +seta crosshair_color_special_rainbow_delay 0.1 +seta crosshair_color_special_rainbow_brightness 2 "color brightness of the random crosshair colors" // =============================== diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index e6d2f925e..b2e9c03e0 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -381,8 +381,8 @@ vector damage_blurpostprocess, content_blurpostprocess; float checkfail[16]; -float last_flicker; -vector previous_color; +float rainbow_last_flicker; +vector rainbow_prev_color; #define BUTTON_3 4 #define BUTTON_4 8 @@ -1138,7 +1138,8 @@ void CSQC_UpdateView(float w, float h) string wcross_wep = "", wcross_name; float wcross_scale, wcross_blur; - if (autocvar_crosshair_per_weapon || autocvar_crosshair_color_per_weapon) { + if (autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1)) + { e = get_weaponinfo(switchingweapon); if (e && e.netname != "") { @@ -1158,56 +1159,82 @@ void CSQC_UpdateView(float w, float h) } } } - if(wcross_wep != "" && autocvar_crosshair_color_per_weapon) - wcross_color = stov(cvar_string(strcat("crosshair_", wcross_wep, "_color"))); - else if(autocvar_crosshair_color_by_health) - { - float x = getstati(STAT_HEALTH); - - //x = red - //y = green - //z = blue - wcross_color_z = 0; + //print(sprintf("crosshair style: %s\n", wcross_style)); + wcross_name = strcat("gfx/crosshair", wcross_style); - if(x > 200) - { - wcross_color_x = 0; - wcross_color_y = 1; - } - else if(x > 150) - { - wcross_color_x = 0.4 - (x-150)*0.02 * 0.4; - wcross_color_y = 0.9 + (x-150)*0.02 * 0.1; - } - else if(x > 100) - { - wcross_color_x = 1 - (x-100)*0.02 * 0.6; - wcross_color_y = 1 - (x-100)*0.02 * 0.1; - wcross_color_z = 1 - (x-100)*0.02; - } - else if(x > 50) + // MAIN CROSSHAIR COLOR DECISION + switch(autocvar_crosshair_color_special) + { + case 1: // crosshair_color_per_weapon { - wcross_color_x = 1; - wcross_color_y = 1; - wcross_color_z = 0.2 + (x-50)*0.02 * 0.8; + if(wcross_wep != "") + { + wcross_color = stov(cvar_string(sprintf("crosshair_%s_color", wcross_wep))); + break; + } + else { goto normalcolor; } } - else if(x > 20) + + case 2: // crosshair_color_by_health { - wcross_color_x = 1; - wcross_color_y = (x-20)*90/27/100; - wcross_color_z = (x-20)*90/27/100 * 0.2; + float x = getstati(STAT_HEALTH); + + //x = red + //y = green + //z = blue + + wcross_color_z = 0; + + if(x > 200) + { + wcross_color_x = 0; + wcross_color_y = 1; + } + else if(x > 150) + { + wcross_color_x = 0.4 - (x-150)*0.02 * 0.4; + wcross_color_y = 0.9 + (x-150)*0.02 * 0.1; + } + else if(x > 100) + { + wcross_color_x = 1 - (x-100)*0.02 * 0.6; + wcross_color_y = 1 - (x-100)*0.02 * 0.1; + wcross_color_z = 1 - (x-100)*0.02; + } + else if(x > 50) + { + wcross_color_x = 1; + wcross_color_y = 1; + wcross_color_z = 0.2 + (x-50)*0.02 * 0.8; + } + else if(x > 20) + { + wcross_color_x = 1; + wcross_color_y = (x-20)*90/27/100; + wcross_color_z = (x-20)*90/27/100 * 0.2; + } + else + { + wcross_color_x = 1; + wcross_color_y = 0; + } + break; } - else + + case 3: // crosshair_color_rainbow { - wcross_color_x = 1; - wcross_color_y = 0; + if(time >= rainbow_last_flicker) + { + rainbow_prev_color = randomvec() * autocvar_crosshair_color_special_rainbow_brightness; + rainbow_last_flicker = time + autocvar_crosshair_color_special_rainbow_delay; + } + wcross_color = rainbow_prev_color; + break; } + :normalcolor + default: { wcross_color = stov(autocvar_crosshair_color); break; } } - else - wcross_color = stov(autocvar_crosshair_color); - - wcross_name = strcat("gfx/crosshair", wcross_style); if(autocvar_crosshair_effect_scalefade) { @@ -1241,7 +1268,7 @@ void CSQC_UpdateView(float w, float h) if(autocvar_crosshair_hitindication) { - vector hitindication_color = ((autocvar_crosshair_color_per_weapon) ? stov(autocvar_crosshair_hitindication_per_weapon_color) : stov(autocvar_crosshair_hitindication_color)); + vector hitindication_color = ((autocvar_crosshair_color_special == 1) ? stov(autocvar_crosshair_hitindication_per_weapon_color) : stov(autocvar_crosshair_hitindication_color)); if(hitindication_crosshair_time < hit_time) { @@ -1406,16 +1433,6 @@ void CSQC_UpdateView(float w, float h) if (ring_value) DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, ring_image, ring_value, ring_rgb, wcross_alpha * ring_alpha, DRAWFLAG_ADDITIVE); } - - if(autocvar_crosshair_rainbow) - { - if(time >= last_flicker) - { - previous_color = randomvec() * autocvar_crosshair_rainbow_brightness; - last_flicker = time + autocvar_crosshair_rainbow_delay; - } - wcross_color = previous_color; - } #define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \ do \ diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 4bc11f4e3..f8343221d 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -92,7 +92,9 @@ float autocvar_con_notifysize; string autocvar_crosshair; float autocvar_crosshair_alpha; string autocvar_crosshair_color; -float autocvar_crosshair_color_per_weapon; +float autocvar_crosshair_color_special; +var float autocvar_crosshair_color_special_rainbow_brightness = 2; +var float autocvar_crosshair_color_special_rainbow_delay = 0.1; float autocvar_crosshair_dot; float autocvar_crosshair_dot_alpha; string autocvar_crosshair_dot_color; @@ -130,9 +132,6 @@ float autocvar_crosshair_ring_reload; float autocvar_crosshair_ring_reload_alpha; float autocvar_crosshair_ring_reload_size; float autocvar_crosshair_size; -float autocvar_crosshair_rainbow; -var float autocvar_crosshair_rainbow_brightness = 2; -var float autocvar_crosshair_rainbow_delay = 0.1; float autocvar_ekg; float autocvar_fov; float autocvar_g_balance_damagepush_speedfactor; @@ -166,7 +165,6 @@ float autocvar_g_waypointsprite_spam; float autocvar_g_waypointsprite_timealphaexponent; var float autocvar_g_waypointsprite_turrets = TRUE; var float autocvar_g_waypointsprite_turrets_maxdist = 5000; - var float autocvar_hud_cursormode = TRUE; float autocvar_hud_colorflash_alpha; float autocvar_hud_configure_checkcollisions; @@ -393,7 +391,6 @@ float autocvar_vid_conheight; float autocvar_vid_conwidth; float autocvar_vid_pixelheight; float autocvar_viewsize; -float autocvar_crosshair_color_by_health; float autocvar_cl_hitsound; float autocvar_cl_hitsound_antispam_time; var float autocvar_cl_eventchase_death = 1; diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c b/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c index 21beeca6f..482a60510 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c @@ -127,16 +127,16 @@ void XonoticPlayerSettingsTab_fill(entity me) me.TR(me); me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Crosshair color:"))); setDependent(e, "crosshair_enabled", 1, 2); - me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_per_weapon", string_null, _("Per weapon"))); + me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_special", "1", _("Per weapon"))); setDependent(e, "crosshair_enabled", 1, 2); - me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_by_health", string_null, _("By health"))); + me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_special", "2", _("By health"))); setDependent(e, "crosshair_enabled", 1, 2); me.TR(me); me.TDempty(me, 0.1); - me.TD(me, 1, 0.9, e = makeXonoticRadioButton(5, string_null, string_null, _("Custom"))); + me.TD(me, 1, 0.9, e = makeXonoticRadioButton(5, "crosshair_color_special", "0", _("Custom"))); setDependent(e, "crosshair_enabled", 1, 2); me.TD(me, 2, 2, e = makeXonoticColorpickerString("crosshair_color", "crosshair_color")); - setDependentAND3(e, "crosshair_color_per_weapon", 0, 0, "crosshair_color_by_health", 0, 0, "crosshair_enabled", 1, 2); + setDependentAND(e, "crosshair_color_special", 0, 0, "crosshair_enabled", 1, 2); me.TR(me); me.TR(me); me.TR(me);