]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
add Samual's beloved sv_fragmessages
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 45cc5150a5f5599254cbfe42d4a6b212379b7683..6d6d3193adfec279401176685ac6fae243df0389 100644 (file)
@@ -2490,7 +2490,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
 
 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
 
-void HUD_Centerprint(string s1, float type, float msg)
+void HUD_Centerprint(string s1, string s2, float type, float msg)
 {
        if(msg == MSG_SUICIDE) {
                if (type == DEATH_TEAMCHANGE) {
@@ -2544,29 +2544,29 @@ void HUD_Centerprint(string s1, float type, float msg)
                        } else {
                                centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1First victim"));
                        }
-               } else if (type == KILL_TYPEFRAG) {
+               } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
                        if(cvar("cl_gentle")) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^7 who was typing!"));
+                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You scored against ^7", s1, "^7 who was typing!", s2));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1));
+                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You typefragged ^7", s1, s2));
                        }
                } else if (type == KILL_TYPEFRAGGED) {
                        if(cvar("cl_gentle")) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^7 while you were typing!"));
+                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were scored against by ^7", s1, "^7 while you were typing!", s2));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1));
+                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were typefragged by ^7", s1, s2));
                        }
                } else if (type == KILL_FRAG) {
                        if(cvar("cl_gentle")) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1));
+                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You scored against ^7", s1, s2));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1));
+                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You fragged ^7", s1, s2));
                        }
                } else if (type == KILL_FRAGGED) {
                        if(cvar("cl_gentle")) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were scored against by ^7", s1));
+                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were scored against by ^7", s1, s2));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were fragged by ^7", s1));
+                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^4You were fragged by ^7", s1, s2));
                        }
                }
        } else if(msg == MSG_KILL_ACTION) {
@@ -2594,6 +2594,7 @@ void HUD_Notify (void)
        float entries, height;
        entries = bound(1, floor(12 * mySize_y/mySize_x), 10);
        height = mySize_y/entries;
+       entries -= 2; // top/bottom two lines reserved for info messaged, such as spec instructions
        
        vector fontsize;
        fontsize = '0.5 0.5 0' * height;
@@ -2618,6 +2619,8 @@ void HUD_Notify (void)
                        i = j;
                else // rather nasty hack for ordering items from the bottom up
                        i = entries - j - 1;
+               if(cvar("hud_notify_info_top"))
+                       i += 2; // top/bottom two lines reserved for info messaged, such as spec instructions
 
                if(fadetime)
                {
@@ -2721,35 +2724,47 @@ void HUD_Notify (void)
                        }
                }
        }
-       /* This will come later.
-       string s;
+
+       // Info messages
+       //
        entity tm;
+       vector o;
+       o = pos;
+       if(cvar("hud_notify_info_top"))
+               o = pos + eY;
+       else
+               o = pos + eY * mySize_y - eY * 2 * height;
+       
        if(spectatee_status && !intermission)
        {
-               drawfont = hud_bigfont;
+               //drawfont = hud_bigfont;
                if(spectatee_status == -1)
                        s = "^1Observing";
                else
                        s = GetPlayerName(spectatee_status - 1);
-               // spectated player name between HUD and chat area, aligned to the left
-               pos_x = 0;
-               pos_y = - 50 - hud_fontsize_spec_y;
-               s = textShortenToWidth(s, vid_conwidth/2.5, hud_fontsize_spec, stringwidth_colors);
-               drawcolorcodedstring(pos, s, hud_fontsize_spec, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
-               drawfont = hud_font;
+
+               //s = textShortenToWidth(s, mySize_y, 0.5 * height, stringwidth_colors);
+               //drawcolorcodedstring(pos + eY * 0.25 * height, s, 0.5 * height, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               //drawfont = hud_font;
 
                // spectator text in the upper right corner
                if(spectatee_status == -1)
                        s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
                else
                        s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
+               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               o += eY * fontsize_y;
 
                if(spectatee_status == -1)
                        s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
                else
                        s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
+               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               o += eY * fontsize_y;
 
                s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
+               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               o += eY * fontsize_y;
 
                if(gametype == GAME_ARENA)
                        s = "^1Wait for your turn to join";
@@ -2766,6 +2781,8 @@ void HUD_Notify (void)
                }
                else
                        s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
+               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               o += eY * fontsize_y;
 
                //show restart countdown:
                if (time < getstatf(STAT_GAMESTARTTIME)) {
@@ -2773,15 +2790,17 @@ void HUD_Notify (void)
                        //we need to ceil, otherwise the countdown would be off by .5 when using round()
                        countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
                        s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
+                       drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+                       o += eY * fontsize_y;
                }
        }
        if(warmup_stage && !intermission)
        {
                s = "^2Currently in ^1warmup^2 stage!";
+               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               o += eY * fontsize_y;
        }
 
-       // move more important stuff more to the middle so its more visible
-
        string blinkcolor;
        if(mod(time, 1) >= 0.5)
                blinkcolor = "^1";
@@ -2804,10 +2823,14 @@ void HUD_Notify (void)
                        else
                                s = strcat("^2Waiting for others to ready up...");
                }
+               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               o += eY * fontsize_y;
        }
        else if(warmup_stage && !intermission && !spectatee_status)
        {
                s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
+               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               o += eY * fontsize_y;
        }
 
        if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
@@ -2834,10 +2857,20 @@ void HUD_Notify (void)
                                if (tm.team_size == ts_max)
                                        s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
 
+                               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+                               o += eY * fontsize_y;
                        }
                }
        }
-       */
+       if(hud_configure)
+       {
+               s = "^7Press ^3ESC ^7to show HUD options.";
+               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               o += eY * fontsize_y;
+               s = "^3Doubleclick a panel for panel-specific options.";
+               drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+               o += eY * fontsize_y;
+       }
 }
 
 // Timer (#5)
@@ -3947,6 +3980,10 @@ void HUD_Chat(void)
 float prevfps;
 float prevfps_time;
 float framecounter;
+
+float frametimeavg;
+float frametimeavg1; // 1 frame ago
+float frametimeavg2; // 2 frames ago
 void HUD_EngineInfo(void)
 {
        float id = HUD_PANEL_ENGINEINFO;
@@ -3965,13 +4002,17 @@ void HUD_EngineInfo(void)
 
        if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
        {
+               frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
+               frametimeavg2 = frametimeavg1;
+               frametimeavg1 = frametimeavg;
+               
                float weight;
                weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
                if(frametime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
                {
-                       if(fabs(prevfps - (1/frametime)) > prevfps * cvar("hud_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
+                       if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
                                prevfps = (1/frametime);
-                       prevfps = (1 - weight) * prevfps + weight * (1/frametime);
+                       prevfps = (1 - weight) * prevfps + weight * (1/frametimeavg); // framecounter just used so there's no need for a new variable, think of it as "frametime average"
                }
        }
        else
@@ -3987,7 +4028,7 @@ void HUD_EngineInfo(void)
 
        vector color;
        color = HUD_Get_Num_Color (prevfps, 100);
-       drawstring(pos, strcat("FPS: ", ftos_decimals(prevfps, 2)), '1 1 0' * 0.5 * mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+       drawstring(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), '1 1 0' * 0.5 * mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
 }
 /*
 ==================