]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
It begins
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index dbae62cbdef08c40cde94676b407e014673e5169..b1fa777a474bc78e8279170fd94dca82f1680d87 100644 (file)
@@ -1,27 +1,20 @@
 #include "hud.qh"
-#include "_all.qh"
 
 #include "hud_config.qh"
 #include "mapvoting.qh"
 #include "scoreboard.qh"
 #include "teamradar.qh"
 #include "t_items.qh"
-
-#include "../dpdefs/keycodes.qh"
-
 #include "../common/buffs/all.qh"
-#include "../common/constants.qh"
-#include "../common/deathtypes.qh"
+#include "../common/deathtypes/all.qh"
 #include "../common/items/all.qc"
 #include "../common/mapinfo.qh"
-#include "../common/nades/all.qh"
-
 #include "../common/mutators/mutator/waypoints/all.qh"
-#include "../server/mutators/gamemode_ctf.qh"
-
+#include "../common/nades/all.qh"
 #include "../common/stats.qh"
-
-#include "../csqcmodellib/cl_player.qh"
+#include "../lib/csqcmodel/cl_player.qh"
+// TODO: remove
+#include "../server/mutators/mutator/gamemode_ctf.qc"
 
 
 /*
@@ -206,12 +199,6 @@ HUD panels
 ==================
 */
 
-// draw the background/borders
-#define HUD_Panel_DrawBg(theAlpha) do {                                                                                                                                                                \
-       if(panel.current_panel_bg != "0" && panel.current_panel_bg != "")                                                                                               \
-               draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
-} while(0)
-
 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
 {
@@ -352,8 +339,9 @@ int weaponorder_cmp(int i, int j, entity pass)
        return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
 }
 
-void HUD_Weapons(void)
-{SELFPARAM();
+void HUD_Weapons()
+{
+       SELFPARAM();
        // declarations
        WepSet weapons_stat = WepSet_GetFromStat();
        int i;
@@ -380,7 +368,6 @@ void HUD_Weapons(void)
        vector color;
 
        // check to see if we want to continue
-       if(intermission == 2) return;
        if(hud != HUD_NORMAL) return;
 
        if(!autocvar__hud_configure)
@@ -966,7 +953,6 @@ int nade_prevframe;
 float nade_statuschange_time;
 void HUD_Ammo(void)
 {
-       if(intermission == 2) return;
        if(hud != HUD_NORMAL) return;
        if(!autocvar__hud_configure)
        {
@@ -1241,8 +1227,6 @@ int getPowerupItemAlign(int align, int column, int row, int columns, int rows, b
 
 void HUD_Powerups()
 {
-       if(intermission == 2) return;
-
        int allItems = getstati(STAT_ITEMS, 0, 24);
        int allBuffs = getstati(STAT_BUFFS, 0, 24);
        int strengthTime, shieldTime, superTime;
@@ -1406,7 +1390,6 @@ void HUD_Powerups()
 void HUD_HealthArmor(void)
 {
        int armor, health, fuel;
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_healtharmor) return;
@@ -1478,7 +1461,7 @@ void HUD_HealthArmor(void)
        if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
        {
                vector v;
-               v = healtharmor_maxdamage(health, armor, armorblockpercent, DEATH_WEAPON);
+               v = healtharmor_maxdamage(health, armor, armorblockpercent, DEATH_WEAPON.m_id);
 
                float x;
                x = floor(v.x + 1);
@@ -1713,7 +1696,6 @@ void HUD_Notify_Push(string icon, string attacker, string victim)
 
 void HUD_Notify(void)
 {
-       if(intermission == 2) return;
        if (!autocvar__hud_configure)
                if (!autocvar_hud_panel_notify)
                        return;
@@ -1827,7 +1809,6 @@ void HUD_Notify(void)
 
 void HUD_Timer(void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_timer) return;
@@ -2048,7 +2029,6 @@ void HUD_Radar_Mouse()
 
 void HUD_Radar(void)
 {
-       if(intermission == 2) return;
        if (!autocvar__hud_configure)
        {
                if (hud_panel_radar_maximized)
@@ -2397,7 +2377,6 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me)
 
 void HUD_Score(void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_score) return;
@@ -2581,7 +2560,6 @@ void HUD_Score(void)
 //
 void HUD_RaceTimer (void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_racetimer) return;
@@ -2732,7 +2710,6 @@ void HUD_RaceTimer (void)
 
 void HUD_Vote(void)
 {
-       if(intermission == 2) return;
        if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS)))
        {
                vote_active = 1;
@@ -3609,7 +3586,6 @@ float mod_change; // "time" when mod_active changed
 
 void HUD_ModIcons(void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_modicons) return;
@@ -3651,7 +3627,6 @@ void HUD_ModIcons(void)
 //
 void HUD_PressedKeys(void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_pressedkeys) return;
@@ -3713,6 +3688,12 @@ void HUD_PressedKeys(void)
        drawpic_aspect_skin(pos + eX * keysize.x * 2, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 }
 
+entity chatlines;
+STATIC_INIT(chatlines) { chatlines = LL_NEW(); }
+CLASS(ChatEntry, Object)
+       ATTRIB(ChatEntry, m_text, string, string_null)
+ENDCLASS(ChatEntry)
+
 // Handle chat as a panel (#12)
 //
 void HUD_Chat(void)
@@ -3786,14 +3767,26 @@ void HUD_Chat(void)
        cvar_set("con_chatwidth", ftos(mySize.x/vid_conwidth));
        cvar_set("con_chat", ftos(floor(mySize.y/autocvar_con_chatsize - 0.5)));
 
+       vector chatsize = '1 1 0' * autocvar_con_chatsize;
+
+       int n = 0;
+       int oldy = pos.y;
+       LL_EACH(chatlines, true, LAMBDA(
+               float a = 1;
+               string s = textShortenToWidth(it.m_text, mySize.x, chatsize, stringwidth_colors);
+               drawcolorcodedstring(pos, s, chatsize, a, DRAWFLAG_NORMAL);
+               pos.y += chatsize.y;
+               n = i;
+       ));
+       drawcolorcodedstring(pos, ftos(n), chatsize, 1, DRAWFLAG_NORMAL);
+       pos.y = oldy;
+
        if(autocvar__hud_configure)
        {
-               vector chatsize;
-               chatsize = '1 1 0' * autocvar_con_chatsize;
                cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over theAlpha and such
-               float i, a;
-               for(i = 0; i < autocvar_con_chat; ++i)
+               for(int i = 0; i < autocvar_con_chat; ++i)
                {
+                       float a;
                        if(i == autocvar_con_chat - 1)
                                a = panel_fg_alpha;
                        else
@@ -3815,7 +3808,6 @@ float frametimeavg1; // 1 frame ago
 float frametimeavg2; // 2 frames ago
 void HUD_EngineInfo(void)
 {
-       //if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_engineinfo) return;
@@ -3877,7 +3869,6 @@ void HUD_EngineInfo(void)
 } while(0)
 void HUD_InfoMessages(void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_infomessages) return;
@@ -4059,7 +4050,6 @@ float acc_prevtime, acc_avg, top_speed, top_speed_time;
 float physics_update_time, discrete_speed, discrete_acceleration;
 void HUD_Physics(void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_physics) return;
@@ -4451,7 +4441,6 @@ void reset_centerprint_messages(void)
 float hud_configure_cp_generation_time;
 void HUD_CenterPrint (void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_centerprint) return;
@@ -4695,28 +4684,48 @@ Main HUD system
 ==================
 */
 
+void HUD_Vehicle()
+{
+       if(autocvar__hud_configure) return;
+       if(intermission == 2) return;
+
+       if(hud == HUD_BUMBLEBEE_GUN)
+               CSQC_BUMBLE_GUN_HUD();
+       else {
+               Vehicle info = get_vehicleinfo(hud);
+               info.vr_hud(info);
+       }
+}
+
 bool HUD_Panel_CheckFlags(int showflags)
 {
        if ( HUD_Minigame_Showpanels() )
                return showflags & PANEL_SHOW_MINIGAME;
+       if(intermission == 2)
+               return showflags & PANEL_SHOW_MAPVOTE;
        return showflags & PANEL_SHOW_MAINGAME;
 }
 
 void HUD_Panel_Draw(entity panent)
 {
        panel = panent;
-       if ( HUD_Panel_CheckFlags(panel.panel_showflags) )
+       if(autocvar__hud_configure)
+       {
+               if(panel.panel_configflags & PANEL_CONFIG_MAIN)
+                       panel.panel_draw();
+       }
+       else if(HUD_Panel_CheckFlags(panel.panel_showflags))
                panel.panel_draw();
 }
 
-void HUD_Reset (void)
+void HUD_Reset(void)
 {
        // reset gametype specific icons
        if(gametype == MAPINFO_TYPE_CTF)
                HUD_Mod_CTF_Reset();
 }
 
-void HUD_Main (void)
+void HUD_Main(void)
 {
        int i;
        // global hud theAlpha fade
@@ -4845,6 +4854,8 @@ void HUD_Main (void)
        for(i = hud_panels_COUNT - 1; i >= 0; --i)
                HUD_Panel_Draw(hud_panels[panel_order[i]]);
 
+       HUD_Vehicle();
+
        hud_draw_maximized = 1; // panels that may be maximized must check this var
        // draw maximized panels on top
        if(hud_panel_radar_maximized)
@@ -4854,6 +4865,9 @@ void HUD_Main (void)
        if(hud_panel_quickmenu)
                HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
 
+       if (scoreboard_active || intermission == 2)
+               HUD_Reset();
+
        HUD_Configure_PostDraw();
 
        hud_configure_prev = autocvar__hud_configure;