]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Update how crosshair color selection is handled, create a switch for it
authorSamual Lenks <samual@xonotic.org>
Sun, 12 May 2013 00:49:05 +0000 (20:49 -0400)
committerSamual Lenks <samual@xonotic.org>
Sun, 12 May 2013 00:49:05 +0000 (20:49 -0400)
crosshairs.cfg
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c

index 655e90a21b7f43c18e3eecf78dbc875906556bd5..7f0db53e4c68c00ab1b70085d4615e127e9ea8f0 100644 (file)
@@ -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"
 
 
 // ===============================
index e6d2f925e4a246cb67cbf5081193bd7181fa678d..b2e9c03e0ea5659da6b93b5f1c41b0592283e864 100644 (file)
@@ -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 \
index 4bc11f4e35aeb14afa6e225264ffb8f9da375bca..f8343221ded4d13dd72358c6670ccc4c162de5d6 100644 (file)
@@ -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;
index 21beeca6f48ea94472869ba69d7ac98742cad660..482a60510e88cdd2f52d6cc68c9e8d49c6f4ad63 100644 (file)
@@ -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);