]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
some more tweaks, remaining issues: why does it project the names also behind the...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 4e3201e0d2ed9ab3601a45dd99b2598b97af29a1..29a3af193852c675251c11147b1a7b8a8af9ebee 100644 (file)
@@ -89,11 +89,12 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the
 
 vector HUD_Get_Num_Color (float x, float maxvalue)
 {
+       float blinkingamt;
        vector color;
-       if(x > maxvalue) {
-               color_x = 0;
+       if(x >= maxvalue) {
+               color_x = sin(2*M_PI*time);
                color_y = 1;
-               color_z = 0;
+               color_z = sin(2*M_PI*time);
        }
        else if(x > maxvalue * 0.75) {
                color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
@@ -120,6 +121,14 @@ vector HUD_Get_Num_Color (float x, float maxvalue)
                color_y = 0;
                color_z = 0;
        }
+
+       blinkingamt = (1 - x/maxvalue/0.25);
+       if(blinkingamt > 0)
+       {
+               color_x = color_x - color_x * blinkingamt * sin(2*M_PI*time);
+               color_y = color_y - color_y * blinkingamt * sin(2*M_PI*time);
+               color_z = color_z - color_z * blinkingamt * sin(2*M_PI*time);
+       }
        return color;
 }
 
@@ -395,9 +404,9 @@ string MakeRaceString(float cp, float mytime, float histime, float lapdelta, str
        if(histime < 0)
                return strcat(col, cpname);
        else if(hisname == "")
-               return strcat(col, sprintf(_("%s (%s)")), cpname, timestr);
+               return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
        else
-               return strcat(col, sprintf(_("%s (%s %s)")), cpname, timestr, strcat(hisname, col, lapstr));
+               return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
 }
 
 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
@@ -444,7 +453,7 @@ void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, flo
        if(vertical) {
                pic = strcat(hud_skin_path, "/", pic, "_vertical");
                if(precache_pic(pic) == "") {
-                       pic = "gfx/hud/default/statusbar_vertical";
+                       pic = "gfx/hud/default/progressbar_vertical";
                }
 
         if (baralign == 1) // bottom align
@@ -486,7 +495,7 @@ void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, flo
        } else {
                pic = strcat(hud_skin_path, "/", pic);
                if(precache_pic(pic) == "") {
-                       pic = "gfx/hud/default/statusbar";
+                       pic = "gfx/hud/default/progressbar";
                }
 
                if (baralign == 1) // right align
@@ -699,16 +708,9 @@ void HUD_Weapons(void)
        }
 
        float i, weapid, wpnalpha, weapon_cnt;
-       weapon_cnt = 0;
-       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-       {
-               self = get_weaponinfo(i);
-               if(self.impulse >= 0)
-                       ++weapon_cnt;
-       }
 
        // TODO make this configurable
-       if(weaponorder_bypriority != autocvar_cl_weaponpriority)
+       if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
        {
                if(weaponorder_bypriority)
                        strunzone(weaponorder_bypriority);
@@ -729,6 +731,8 @@ void HUD_Weapons(void)
                                ++weapon_cnt;
                        }
                }
+               for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
+                       weaponorder[i] = NULL;
                heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
 
                weaponorder_cmp_str = string_null;
@@ -803,11 +807,13 @@ void HUD_Weapons(void)
 
        float weapons_st = getstati(STAT_WEAPONS);
 
-       for(i = 0; i < weapon_cnt; ++i)
+       for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
        {
+               self = weaponorder[i];
+               if (!self || self.impulse < 0)
+                       continue;
                wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
 
-               self = weaponorder[i];
                weapid = self.impulse;
 
                // draw background behind currently selected weapon
@@ -837,7 +843,7 @@ void HUD_Weapons(void)
                }
 
                // draw the weapon icon
-               if((weapid >= 0) && (weapons_st & self.weapons))
+               if(weapons_st & self.weapons)
                {
                        drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
 
@@ -902,7 +908,7 @@ void HUD_Weapons(void)
 
                        string s;
                        if(complain_weapon_type == 0) {
-                               s = "Out of ammo";
+                               s = _("Out of ammo");
                                color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
                        }
                        else if(complain_weapon_type == 1) {
@@ -1407,7 +1413,7 @@ void HUD_HealthArmor(void)
                if(fuel)
                {
                        HUD_Panel_GetProgressBarColor(fuel);
-                       HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "statusbar", fuel/100, 0, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                }
        }
        else
@@ -1456,8 +1462,9 @@ void HUD_HealthArmor(void)
                        if(autocvar_hud_panel_healtharmor_progressbar)
                        {
                                HUD_Panel_GetProgressBarColor(health);
-                               float p_health;
+                               float p_health, pain_health_alpha;
                                p_health = health;
+                               pain_health_alpha = 1;
                                if (autocvar_hud_panel_healtharmor_progressbar_gfx)
                                {
                                        if (saved_health == -1)
@@ -1486,8 +1493,16 @@ void HUD_HealthArmor(void)
                                                        saved_health = -1; //damage effect ended
                                        }
                                        prev_health = health;
+
+                                       if (health <= 40 && saved_health != -2)
+                                       {
+                                               float BLINK_FACTOR = 0.15;
+                                               float BLINK_BASE = 0.85;
+                                               float BLINK_FREQ = 9; 
+                                               pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
+                                       }
                                }
-                               HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * pain_health_alpha, DRAWFLAG_NORMAL);
                        }
                        if(autocvar_hud_panel_healtharmor_text)
                                DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
@@ -1546,7 +1561,7 @@ void HUD_HealthArmor(void)
                        else if (panel_ar < 1/4)
                                mySize_y *= 2; //restore full panel size
                        HUD_Panel_GetProgressBarColor(fuel);
-                       HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                }
        }
 }
@@ -1678,7 +1693,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                        }
                }
                else if(type == KILL_FIRST_BLOOD)
-                       print(sprintf("^1%s^1 drew first blood\n", s1));
+                       print(sprintf(_("^1%s^1 drew first blood\n"), s1));
                else if (type == DEATH_TELEFRAG) {
                        HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
                        if(gentle)
@@ -1838,7 +1853,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                } else if (type == DEATH_SLIME) {
                        HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
                        if(alsoprint)
-                               print (sprintf("^1%s^1 was slimed\n", s1));
+                               print (sprintf(_("^1%s^1 was slimed\n"), s1));
                } else if (type == DEATH_LAVA) {
                        HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
                        if(alsoprint)
@@ -1929,7 +1944,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                        print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
                } else if(type == INFO_CAPTUREFLAG) {
                        HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
-                       print(sprintf(_("%1^7 captured the %s%s\n"), s1, s2, s3));
+                       print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
                }
        } else if(msg == MSG_RACE) {
                if(type == RACE_SERVER_RECORD) {
@@ -2073,7 +2088,8 @@ void HUD_Notify (void)
        height = mySize_y/entries;
        
        vector fontsize;
-       fontsize = '0.5 0.5 0' * height;
+       float fontheight = height * autocvar_hud_panel_notify_fontsize;
+       fontsize = '0.5 0.5 0' * fontheight;
 
        float a;
        float when;
@@ -2247,7 +2263,7 @@ void HUD_Notify (void)
                        }
                        
                        attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                       pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
+                       pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
                        weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
 
                        if(s != "")
@@ -2333,8 +2349,8 @@ void HUD_Notify (void)
                        victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
 :hud_config_notifyprint
                        width_attacker = stringwidth(attacker, TRUE, fontsize);
-                       pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
-                       pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
+                       pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
+                       pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
                        weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
 
                        if(s != "")
@@ -2639,7 +2655,7 @@ void HUD_Score(void)
                                        }
                                        else
                                        {
-                                               s = strcat("Player", ftos(i+1));
+                                               s = sprintf(_("Player %d"), ftos(i+1));
                                                score -= 3;
                                        }
 
@@ -2966,10 +2982,10 @@ void HUD_VoteWindow(void)
                {
                        vote_yescount = 0;
                        vote_nocount = 0;
-                       print("^1You have to answer before entering hud configure mode\n");
+                       print(_("^1You must answer before entering hud configure mode\n"));
                        cvar_set("_hud_configure", "0");
                }
-               vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player\" ^7in stats"));
+               vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats"));
                uid2name_dialog = 1;
        }
 
@@ -3060,9 +3076,9 @@ void HUD_VoteWindow(void)
        drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
 
        // print the yes/no counts
-    s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), ftos(vote_yescount));
+    s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
        drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
-    s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), ftos(vote_nocount));
+    s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
        drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
 
        // draw the progress bar backgrounds
@@ -3499,9 +3515,9 @@ void HUD_Mod_NexBall(vector pos, vector mySize)
                //Draw the filling
                HUD_Panel_GetProgressBarColor(nexball);
                if(mySize_x > mySize_y)
-                       HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                else
-                       HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
 
        if (stat_items & IT_KEY1)
@@ -4147,7 +4163,7 @@ void HUD_InfoMessages(void)
                }
                else if(warmup_stage && !intermission && !spectatee_status)
                {
-                       s = strcat("^2Press ^3%s^2 to end warmup", getcommandkey("ready", "ready"));
+                       s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
                        drawInfoMessage(s)
                }
 
@@ -4173,7 +4189,7 @@ void HUD_InfoMessages(void)
                                        if (tm)
                                        if (tm.team != COLOR_SPECTATOR)
                                        if (tm.team_size == ts_max)
-                                               s = strcat(s, sprintf(" Press ^3%s%s to adjust", getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
+                                               s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
                                        drawInfoMessage(s)
                                }
                        }
@@ -4196,7 +4212,6 @@ void HUD_InfoMessages(void)
 //
 vector acc_prevspeed;
 float acc_prevtime, acc_avg, top_speed, top_speed_time;
-
 void HUD_Physics(void)
 {
        if(!autocvar__hud_configure)
@@ -4314,7 +4329,7 @@ void HUD_Physics(void)
        if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
        {
                HUD_Panel_GetProgressBarColor(speed);
-               HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "statusbar", speed/max_speed, 0, speed_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "progressbar", speed/max_speed, 0, speed_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
        vector tmp_offset, tmp_size;
        if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
@@ -4412,7 +4427,7 @@ void HUD_Physics(void)
                        HUD_Panel_GetProgressBarColor(acceleration_neg);
                else
                        HUD_Panel_GetProgressBarColor(acceleration);
-               HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "statusbar", acceleration/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "accelbar", acceleration/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
        if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
                drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -4580,7 +4595,7 @@ void HUD_Main (void)
                        }
                }
                if (warning)
-                       print("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
+                       print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
 
                cvar_set("_hud_panelorder", s);
                if(hud_panelorder_prev)