]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge remote-tracking branch 'origin/master' into samual/notification_rewrite
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 27e3665fc2b679b99c7addfa59f26182e1940852..3e3663db5a90b99e95838e61b0180a61e5867577 100644 (file)
@@ -461,13 +461,13 @@ void HUD_Weapons(void)
        // declarations
        WEPSET_DECLARE_A(weapons_stat);
        WEPSET_COPY_AS(weapons_stat);
-       float i, f, a, j, factor;
-       float screen_ar, center_x, center_y;
+       float i, f, a;
+       float screen_ar, center_x = 0, center_y;
        float weapon_count, weapon_id;
        float row, column, rows, columns;
        float aspect = autocvar_hud_panel_weapons_aspect;
 
-       float show_accuracy = false, panel_weapon_accuracy;
+       float panel_weapon_accuracy;
 
        float timeout = autocvar_hud_panel_weapons_timeout;
        float timein_effect_length = autocvar_hud_panel_weapons_timeout_speed_in; //? 0.375 : 0);
@@ -492,7 +492,8 @@ void HUD_Weapons(void)
        {
                if((!autocvar_hud_panel_weapons) || (spectatee_status == -1))
                        return;
-               else if(timeout && time >= weapontime + timeout + timeout_effect_length && ((autocvar_hud_panel_weapons_timeout_effect != 1) && !(autocvar_hud_panel_weapons_timeout_fadebgmin + autocvar_hud_panel_weapons_timeout_fadefgmin)))
+               if(timeout && time >= weapontime + timeout + timeout_effect_length)
+               if(autocvar_hud_panel_weapons_timeout_effect == 3 || (autocvar_hud_panel_weapons_timeout_effect == 1 && !(autocvar_hud_panel_weapons_timeout_fadebgmin + autocvar_hud_panel_weapons_timeout_fadefgmin)))
                {
                        weaponprevtime = time;
                        return;
@@ -622,6 +623,8 @@ void HUD_Weapons(void)
                                        else //top
                                                panel_pos_y -= f * (panel_pos_y + panel_size_y);
                                }
+                               if(f == 1)
+                                       center_x = -1; // mark the panel as off screen
                        }
                        weaponprevtime = time - (1 - f) * timein_effect_length;
                }
@@ -669,6 +672,10 @@ void HUD_Weapons(void)
 
        // draw the background, then change the virtual size of it to better fit other items inside
        HUD_Panel_DrawBg(1);
+
+       if(center_x == -1)
+               return;
+
        if(panel_bg_padding)
        {
                panel_pos += '1 1 0' * panel_bg_padding;
@@ -700,14 +707,8 @@ void HUD_Weapons(void)
                        baroffset_y = (weapon_size_y - barsize_y) / 2;
                }
        }
-
-       if(autocvar_hud_panel_weapons_accuracy && acc_levels)
-       {
-               show_accuracy = true;
-               if (acc_col[0] == '-1 0 0')
-                       for (i = 0; i < acc_levels; ++i)
-                               acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
-       }
+       if(autocvar_hud_panel_weapons_accuracy)
+               Accuracy_LoadColors();
 
        row = column = 0;
        for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
@@ -737,21 +738,12 @@ void HUD_Weapons(void)
                        drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
                // draw the weapon accuracy
-               if(show_accuracy)
+               if(autocvar_hud_panel_weapons_accuracy)
                {
                        panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
                        if(panel_weapon_accuracy >= 0)
                        {
-                               // find the max level lower than weapon_accuracy
-                               j = acc_levels-1;
-                               while ( j && panel_weapon_accuracy < acc_lev[j] )
-                                       --j;
-
-                               // inject color j+1 in color j, how much depending on how much weapon_accuracy is higher than level j
-                               factor = (panel_weapon_accuracy - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
-                               color = acc_col[j];
-                               color = color + factor * (acc_col[j+1] - color);
-
+                               color = Accuracy_GetColor(panel_weapon_accuracy);
                                drawpic_aspect_skin(weapon_pos, "weapon_accuracy", weapon_size, color, panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                }
@@ -2065,91 +2057,6 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
        }*/
 }
 
-void HUD_KillCenterprint(string s1, string s2, float type, float msg)
-{
-       float gentle;
-       gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
-       if(msg == MSG_SUICIDE) {
-               if (type == DEATH_TEAMCHANGE) {
-                       centerprint_hud(sprintf(_("You are now on: %s"), s1));
-               } else if (type == DEATH_AUTOTEAMCHANGE) {
-                       centerprint_hud(sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1));
-               } else if (type == DEATH_CAMP) {
-                       if(gentle)
-                               centerprint_hud(_("^1Reconsider your tactics, camper!"));
-                       else
-                               centerprint_hud(_("^1Die camper!"));
-               } else if (type == DEATH_NOAMMO) {
-                       if(gentle)
-                               centerprint_hud(_("^1You are reinserted into the game for running out of ammo..."));
-                       else
-                               centerprint_hud(_("^1You were killed for running out of ammo..."));
-               } else if (type == DEATH_ROT) {
-                       if(gentle)
-                               centerprint_hud(_("^1You need to preserve your health"));
-                       else
-                               centerprint_hud(_("^1You grew too old without taking your medicine"));
-               } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
-                       if(gentle)
-                               centerprint_hud(_("^1Don't go against team mates!"));
-                       else
-                               centerprint_hud(_("^1Don't shoot your team mates!"));
-               } else { // generic message
-                       if(gentle)
-                               centerprint_hud(_("^1You need to be more careful!"));
-                       else
-                               centerprint_hud(_("^1You killed your own dumb self!"));
-               }
-       } else if(msg == MSG_KILL) {
-               if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
-                       if(gentle) {
-                               centerprint_hud(sprintf(_("^1Moron! You went against ^7%s^1, a team mate!"), s1));
-                       } else {
-                               centerprint_hud(sprintf(_("^1Moron! You fragged ^7%s^1, a team mate!"), s1));
-                       }
-               } else if (type == KILL_FIRST_BLOOD) {
-                       if(gentle) {
-                               centerprint_hud(_("^1First score"));
-                       } else {
-                               centerprint_hud(_("^1First blood"));
-                       }
-               } else if (type == KILL_FIRST_VICTIM) {
-                       if(gentle) {
-                               centerprint_hud(_("^1First casualty"));
-                       } else {
-                               centerprint_hud(_("^1First victim"));
-                       }
-               } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
-                       if(gentle) {
-                               centerprint_hud(strcat(sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
-                       } else {
-                               centerprint_hud(strcat(sprintf(_("^1You typefragged ^7%s"), s1), s2));
-                       }
-               } else if (type == KILL_TYPEFRAGGED) {
-                       if(gentle) {
-                               centerprint_hud(strcat(sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
-                       } else {
-                               centerprint_hud(strcat(sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
-                       }
-               } else if (type == KILL_FRAG) {
-                       if(gentle) {
-                               centerprint_hud(strcat(sprintf(_("^4You scored against ^7%s"), s1), s2));
-                       } else {
-                               centerprint_hud(strcat(sprintf(_("^4You fragged ^7%s"), s1), s2));
-                       }
-               } else { // generic message
-                       if(gentle) {
-                               centerprint_hud(strcat(sprintf(_("^1You were scored against by ^7%s"), s1), s2));
-                       } else {
-                               centerprint_hud(strcat(sprintf(_("^1You were fragged by ^7%s"), s1), s2));
-                       }
-               }
-       } else if(msg == MSG_KILL_ACTION) {
-               // TODO: invent more centerprints here?
-               centerprint_hud(_("^1Watch your step!"));
-       }
-}
-
 void HUD_Notify(void)
 {
        if(!autocvar__hud_configure)
@@ -4908,11 +4815,14 @@ void HUD_Main (void)
                return;
 
        // Drawing stuff
-       if (hud_skin_path != autocvar_hud_skin)
+       if (hud_skin_prev != autocvar_hud_skin)
        {
                if (hud_skin_path)
                        strunzone(hud_skin_path);
                hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
+               if (hud_skin_prev)
+                       strunzone(hud_skin_prev);
+               hud_skin_prev = strzone(autocvar_hud_skin);
        }
 
        // HUD configure visible grid
@@ -5043,7 +4953,7 @@ void HUD_Main (void)
                        HUD_Panel_UpdatePosSizeForId(highlightedPanel);
                        HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
                }
-               if (!hud_configure_prev)
+               if(!hud_configure_prev || hud_configure_prev == -1)
                {
                        if(autocvar_hud_cursormode) { setcursormode(1); }
                        hudShiftState = 0;