]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Smooth selection change in the weapons panel, optionally with a nice lens effect
authorterencehill <piuntn@gmail.com>
Thu, 19 May 2016 17:01:36 +0000 (19:01 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 19 May 2016 17:01:36 +0000 (19:01 +0200)
_hud_descriptions.cfg
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud/panel/weapons.qc

index de46317116aec1944872f71ccf56d7626aeeed61..ee46898904a77f6d992b974f867c8fa798169aa8 100644 (file)
@@ -65,6 +65,8 @@ seta hud_panel_weapons_ammo "" "show ammo as a status bar"
 seta hud_panel_weapons_onlyowned "" "show only owned weapons"
 seta hud_panel_weapons_noncurrent_alpha "" "alpha of noncurrent weapons"
 seta hud_panel_weapons_noncurrent_scale "" "scale of noncurrent weapons, relative to the current weapon"
+seta hud_panel_weapons_selection_radius "" "number of weapons that get partially highlighted on each side of the currently selected weapon"
+seta hud_panel_weapons_selection_speed "" "weapon selection speed (0 for an instant selection)"
 
 seta hud_panel_ammo_pos "" "position of this panel"
 seta hud_panel_ammo_size "" "size of this panel"
index 2ec91efca551f9dfacc1b056768948b7f1dd02b0..2f4f31e92b7290f7f2852a69ffdc1dc8272915ff 100644 (file)
@@ -66,6 +66,8 @@ seta hud_panel_weapons_timeout_speed_out "0.75"
 seta hud_panel_weapons_onlyowned "1"
 seta hud_panel_weapons_noncurrent_alpha "0.8"
 seta hud_panel_weapons_noncurrent_scale "0.9"
+seta hud_panel_weapons_selection_radius "0"
+seta hud_panel_weapons_selection_speed "10"
 
 seta hud_panel_ammo_pos "0.315000 0.865000"
 seta hud_panel_ammo_size "0.370000 0.060000"
index 7badb25057d5d01e36f26e47bef8b1fb3556e403..3d259ebf394d7b104f848c37e8a35058c8b6aec0 100644 (file)
@@ -66,6 +66,8 @@ seta hud_panel_weapons_timeout_speed_out "0.75"
 seta hud_panel_weapons_onlyowned "1"
 seta hud_panel_weapons_noncurrent_alpha "1"
 seta hud_panel_weapons_noncurrent_scale "1"
+seta hud_panel_weapons_selection_radius "0"
+seta hud_panel_weapons_selection_speed "0"
 
 seta hud_panel_ammo_pos "0.330000 0.960000"
 seta hud_panel_ammo_size "0.350000 0.040000"
index 76edc7bc09fc766003bbb7ebf0afb90b653981b2..c1ac51b7ab854ddf345f7e11023b64713dccc810 100644 (file)
@@ -66,6 +66,8 @@ seta hud_panel_weapons_timeout_speed_out "0.75"
 seta hud_panel_weapons_onlyowned "1"
 seta hud_panel_weapons_noncurrent_alpha "1"
 seta hud_panel_weapons_noncurrent_scale "1"
+seta hud_panel_weapons_selection_radius "0"
+seta hud_panel_weapons_selection_speed "0"
 
 seta hud_panel_ammo_pos "0.650000 0.890000"
 seta hud_panel_ammo_size "0.055000 0.110000"
index f2670d8e2d7b0923e25112947641ba315ef3fd85..d6125985b8a42e180e753e91a4b3ee584bddf932 100644 (file)
@@ -66,6 +66,8 @@ seta hud_panel_weapons_timeout_speed_out "0.75"
 seta hud_panel_weapons_onlyowned "1"
 seta hud_panel_weapons_noncurrent_alpha "1"
 seta hud_panel_weapons_noncurrent_scale "1"
+seta hud_panel_weapons_selection_radius "0"
+seta hud_panel_weapons_selection_speed "0"
 
 seta hud_panel_ammo_pos "0.450000 0.630000"
 seta hud_panel_ammo_size "0.080000 0.040000"
index fc8d05ffbe5421ba67d493f989baa20fc64bd3cd..4ee8005213de354475b006596b82655b7c5408f9 100644 (file)
@@ -66,6 +66,8 @@ seta hud_panel_weapons_timeout_speed_out "0.75"
 seta hud_panel_weapons_onlyowned "1"
 seta hud_panel_weapons_noncurrent_alpha "1"
 seta hud_panel_weapons_noncurrent_scale "1"
+seta hud_panel_weapons_selection_radius "0"
+seta hud_panel_weapons_selection_speed "0"
 
 seta hud_panel_ammo_pos "0.190000 0.920000"
 seta hud_panel_ammo_size "0.120000 0.070000"
index bc1dc9bddae01228cce082efbe7a24c9b369740c..df565ef686ebf47a92f2541f74183dfa937c2aa8 100644 (file)
@@ -66,6 +66,8 @@ seta hud_panel_weapons_timeout_speed_out "0.75"
 seta hud_panel_weapons_onlyowned "0"
 seta hud_panel_weapons_noncurrent_alpha "1"
 seta hud_panel_weapons_noncurrent_scale "1"
+seta hud_panel_weapons_selection_radius "0"
+seta hud_panel_weapons_selection_speed "0"
 
 seta hud_panel_ammo_pos "0.160000 0.910000"
 seta hud_panel_ammo_size "0.190000 0.090000"
index d797cee330f4c6dbb358aab71d6c9dbf79f0114e..26834613cf1d7cc123d507c63f3eee3d77c72737 100644 (file)
@@ -327,6 +327,8 @@ float autocvar_hud_panel_weapons_label_scale = 0.5;
 bool autocvar_hud_panel_weapons_onlyowned;
 float autocvar_hud_panel_weapons_noncurrent_alpha = 1;
 float autocvar_hud_panel_weapons_noncurrent_scale = 1;
+float autocvar_hud_panel_weapons_selection_radius = 0;
+float autocvar_hud_panel_weapons_selection_speed = 10;
 float autocvar_hud_panel_weapons_timeout;
 int autocvar_hud_panel_weapons_timeout_effect;
 float autocvar_hud_panel_weapons_timeout_fadebgmin;
index cfacd59b60f831085e5216c8c86154f2c5d0cefe..712eb26c58c020140c1743a1ec5471b69b7a1e40 100644 (file)
@@ -346,10 +346,23 @@ void HUD_Weapons()
        // draw items
        row = column = 0;
        vector label_size = '1 1 0' * min(weapon_size.x, weapon_size.y) * bound(0, autocvar_hud_panel_weapons_label_scale, 1);
-       vector noncurrent_pos = '0 0 0';
        vector noncurrent_size = weapon_size * bound(0, autocvar_hud_panel_weapons_noncurrent_scale, 1);
        float noncurrent_alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_weapons_noncurrent_alpha, 1);
        bool isCurrent;
+       static vector weapon_pos_current = '-1 0 0';
+       if(weapon_pos_current.x == -1)
+               weapon_pos_current = panel_pos;
+
+       float switch_speed;
+       if(autocvar_hud_panel_weapons_selection_speed <= 0 || autocvar__hud_configure)
+               switch_speed = 999;
+       else
+               switch_speed = frametime * autocvar_hud_panel_weapons_selection_speed;
+       vector radius_size = weapon_size * (autocvar_hud_panel_weapons_selection_radius + 1);
+
+       // draw background behind currently selected weapon
+       // do it earlier to make sure bg is drawn behind every weapon icons while it's moving
+       drawpic_aspect_skin(weapon_pos_current, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
        for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
        {
@@ -374,13 +387,20 @@ void HUD_Weapons()
 
                // figure out the drawing position of weapon
                weapon_pos = (panel_pos + eX * column * weapon_size.x + eY * row * weapon_size.y);
-               noncurrent_pos.x = weapon_pos.x + (weapon_size.x - noncurrent_size.x) / 2;
-               noncurrent_pos.y = weapon_pos.y + (weapon_size.y - noncurrent_size.y) / 2;
 
-               // draw background behind currently selected weapon
+               // update position of the currently selected weapon
                isCurrent = (it == switchweapon);
                if(isCurrent)
-                       drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               {
+                       if(weapon_pos_current.y > weapon_pos.y)
+                               weapon_pos_current.y = max(weapon_pos.y, weapon_pos_current.y - switch_speed * (weapon_pos_current.y - weapon_pos.y));
+                       else if(weapon_pos_current.y < weapon_pos.y)
+                               weapon_pos_current.y = min(weapon_pos.y, weapon_pos_current.y + switch_speed * (weapon_pos.y - weapon_pos_current.y));
+                       if(weapon_pos_current.x > weapon_pos.x)
+                               weapon_pos_current.x = max(weapon_pos.x, weapon_pos_current.x - switch_speed * (weapon_pos_current.x - weapon_pos.x));
+                       else if(weapon_pos_current.x < weapon_pos.x)
+                               weapon_pos_current.x = min(weapon_pos.x, weapon_pos_current.x + switch_speed * (weapon_pos.x - weapon_pos_current.x));
+               }
 
                // draw the weapon accuracy
                if(autocvar_hud_panel_weapons_accuracy)
@@ -393,14 +413,26 @@ void HUD_Weapons()
                        }
                }
 
+               vector weapon_size_real = noncurrent_size;
+               float weapon_alpha_real = noncurrent_alpha;
+               float radius_factor_x = 1 - bound(0, fabs(weapon_pos.x - weapon_pos_current.x) / radius_size.x, 1);
+               float radius_factor_y = 1 - bound(0, fabs(weapon_pos.y - weapon_pos_current.y) / radius_size.y, 1);
+               if(radius_factor_x || radius_factor_y)
+               {
+                       weapon_size_real.x += (weapon_size.x - noncurrent_size.x) * radius_factor_x;
+                       weapon_size_real.y += (weapon_size.y - noncurrent_size.y) * radius_factor_y;
+                       weapon_alpha_real += (panel_fg_alpha - noncurrent_alpha) * min(radius_factor_x, radius_factor_y);
+               }
+
+               vector weapon_pos_real = weapon_pos;
+               weapon_pos_real.x = weapon_pos.x + (weapon_size.x - weapon_size_real.x) / 2;
+               weapon_pos_real.y = weapon_pos.y + (weapon_size.y - weapon_size_real.y) / 2;
+
                // drawing all the weapon items
                if(weapons_stat & WepSet_FromWeapon(it))
                {
                        // draw the weapon image
-                       if(isCurrent)
-                               drawpic_aspect_skin(weapon_pos, it.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                       else
-                               drawpic_aspect_skin(noncurrent_pos, it.model2, noncurrent_size, '1 1 1', noncurrent_alpha, DRAWFLAG_NORMAL);
+                       drawpic_aspect_skin(weapon_pos_real, it.model2, weapon_size_real, '1 1 1', weapon_alpha_real, DRAWFLAG_NORMAL);
 
                        // draw weapon label string
                        switch(autocvar_hud_panel_weapons_label)
@@ -462,7 +494,7 @@ void HUD_Weapons()
                }
                else // draw a "ghost weapon icon" if you don't have the weapon
                {
-                       drawpic_aspect_skin(noncurrent_pos, it.model2, noncurrent_size, '0.2 0.2 0.2', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
+                       drawpic_aspect_skin(weapon_pos_real, it.model2, weapon_size_real, '0.2 0.2 0.2', weapon_alpha_real * 0.5, DRAWFLAG_NORMAL);
                }
 
                // draw the complain message