]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge branch 'master' into terencehill/hud_cleanups
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 9a0f87b944a56dfe49d3ce222976c748e6efa0ca..5ead970345f2b10a4d7152c1a86c822263cd9c6f 100644 (file)
@@ -1,26 +1,19 @@
 #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.qh"
-#include "../common/constants.qh"
-#include "../common/deathtypes.qh"
+#include "../common/buffs/all.qh"
+#include "../common/deathtypes/all.qh"
 #include "../common/items/all.qc"
 #include "../common/mapinfo.qh"
-#include "../common/nades.qh"
-
-#include "../server/mutators/gamemode_ctf.qh"
-
+#include "../common/mutators/mutator/waypoints/all.qh"
+#include "../common/nades/all.qh"
 #include "../common/stats.qh"
-
-#include "../csqcmodellib/cl_player.qh"
+#include "../lib/csqcmodel/cl_player.qh"
+#include "../server/mutators/gamemode_ctf.qh"
 
 
 /*
@@ -205,12 +198,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)
 {
@@ -334,7 +321,7 @@ void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theA
 
 // Weapon icons (#0)
 //
-entity weaponorder[WEP_MAXCOUNT];
+entity weaponorder[Weapons_MAX];
 void weaponorder_swap(int i, int j, entity pass)
 {
        entity h = weaponorder[i];
@@ -379,7 +366,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)
@@ -420,7 +406,7 @@ void HUD_Weapons(void)
                                ++weapon_cnt;
                        }
                }
-               for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
+               for(i = weapon_cnt; i < Weapons_MAX; ++i)
                        weaponorder[i] = world;
                heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
 
@@ -441,7 +427,7 @@ void HUD_Weapons(void)
                if(cvar("wep_add"))
                {
                        weapons_stat = '0 0 0';
-                       float countw = 1 + floor((floor(time * cvar("wep_add"))) % WEP_COUNT);
+                       float countw = 1 + floor((floor(time * cvar("wep_add"))) % (Weapons_COUNT - 1));
                        for(i = WEP_FIRST; i <= countw; ++i)
                                weapons_stat |= WepSet_FromWeapon(i);
                }
@@ -472,7 +458,15 @@ void HUD_Weapons(void)
                vector padded_panel_size = panel_size - '2 2 0' * panel_bg_padding;
 
                // get the all-weapons layout
-               vector table_size = HUD_GetTableSize_BestItemAR(WEP_COUNT, padded_panel_size, aspect);
+               int nHidden = 0;
+               WepSet weapons_stat = WepSet_GetFromStat();
+               for (int i = WEP_FIRST; i <= WEP_LAST; ++i) {
+                       WepSet weapons_wep = WepSet_FromWeapon(i);
+                       if (weapons_stat & weapons_wep) continue;
+                       Weapon w = get_weaponinfo(i);
+                       if (w.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
+               }
+               vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, padded_panel_size, aspect);
                columns = table_size.x;
                rows = table_size.y;
                weapon_size.x = padded_panel_size.x / columns;
@@ -527,7 +521,7 @@ void HUD_Weapons(void)
                        panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
        }
        else
-               weapon_count = WEP_COUNT;
+               weapon_count = (Weapons_COUNT - 1);
 
        // animation for fading in/out the panel respectively when not in use
        if(!autocvar__hud_configure)
@@ -632,7 +626,7 @@ void HUD_Weapons(void)
 
        if(!rows) // if rows is > 0 onlyowned code has already updated these vars
        {
-               vector table_size = HUD_GetTableSize_BestItemAR(WEP_COUNT, panel_size, aspect);
+               vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1), panel_size, aspect);
                columns = table_size.x;
                rows = table_size.y;
                weapon_size.x = panel_size.x / columns;
@@ -850,8 +844,8 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan
        float bonusNades    = getstatf(STAT_NADE_BONUS);
        float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
        float bonusType     = getstati(STAT_NADE_BONUS_TYPE);
-       vector nadeColor    = NADES[bonusType].m_color;
-       string nadeIcon     = NADES[bonusType].m_icon;
+       vector nadeColor    = Nades[bonusType].m_color;
+       string nadeIcon     = Nades[bonusType].m_icon;
 
        vector iconPos, textPos;
 
@@ -957,7 +951,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)
        {
@@ -1232,8 +1225,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;
@@ -1275,7 +1266,7 @@ void HUD_Powerups()
        if(superTime)
                addPowerupItem("Superweapons", "superweapons", autocvar_hud_progressbar_superweapons_color, superTime, 30);
 
-       FOREACH(BUFFS, it.m_itemid & allBuffs, LAMBDA(
+       FOREACH(Buffs, it.m_itemid & allBuffs, LAMBDA(
                addPowerupItem(it.m_prettyName, strcat("buff_", it.m_name), it.m_color, bound(0, getstatf(STAT_BUFF_TIME) - time, 99), 60);
        ));
 
@@ -1397,7 +1388,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;
@@ -1469,7 +1459,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);
@@ -1704,7 +1694,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;
@@ -1818,7 +1807,6 @@ void HUD_Notify(void)
 
 void HUD_Timer(void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_timer) return;
@@ -2039,7 +2027,6 @@ void HUD_Radar_Mouse()
 
 void HUD_Radar(void)
 {
-       if(intermission == 2) return;
        if (!autocvar__hud_configure)
        {
                if (hud_panel_radar_maximized)
@@ -2232,8 +2219,8 @@ void HUD_Radar(void)
                                drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
                        }
                }
-
-               draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
+               entity icon = RadarIcons[tm.teamradar_icon];
+               draw_teamradar_icon(tm.origin, icon, tm, spritelookupcolor(tm, icon.netname, tm.teamradar_color), panel_fg_alpha);
        }
        for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
        {
@@ -2388,7 +2375,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;
@@ -2572,7 +2558,6 @@ void HUD_Score(void)
 //
 void HUD_RaceTimer (void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_racetimer) return;
@@ -2723,7 +2708,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;
@@ -3600,7 +3584,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;
@@ -3642,7 +3625,6 @@ void HUD_ModIcons(void)
 //
 void HUD_PressedKeys(void)
 {
-       if(intermission == 2) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_pressedkeys) return;
@@ -3806,7 +3788,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;
@@ -3868,7 +3849,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;
@@ -4050,7 +4030,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;
@@ -4442,7 +4421,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;
@@ -4456,7 +4434,7 @@ void HUD_CenterPrint (void)
                        reset_centerprint_messages();
                if (time > hud_configure_cp_generation_time)
                {
-                       if(HUD_PANEL(CENTERPRINT) == highlightedPanel)
+                       if(highlightedPanel == HUD_PANEL(CENTERPRINT))
                        {
                                float r;
                                r = random();
@@ -4686,28 +4664,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
@@ -4791,18 +4789,18 @@ void HUD_Main (void)
 
        // cache the panel order into the panel_order array
        if(autocvar__hud_panelorder != hud_panelorder_prev) {
-               for(i = 0; i < HUD_PANEL_NUM; ++i)
+               for(i = 0; i < hud_panels_COUNT; ++i)
                        panel_order[i] = -1;
                string s = "";
                int p_num;
                bool warning = false;
                int argc = tokenize_console(autocvar__hud_panelorder);
-               if (argc > HUD_PANEL_NUM)
+               if (argc > hud_panels_COUNT)
                        warning = true;
                //first detect wrong/missing panel numbers
-               for(i = 0; i < HUD_PANEL_NUM; ++i) {
+               for(i = 0; i < hud_panels_COUNT; ++i) {
                        p_num = stoi(argv(i));
-                       if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
+                       if (p_num >= 0 && p_num < hud_panels_COUNT) { //correct panel number?
                                if (panel_order[p_num] == -1) //found for the first time?
                                        s = strcat(s, ftos(p_num), " ");
                                panel_order[p_num] = 1; //mark as found
@@ -4810,7 +4808,7 @@ void HUD_Main (void)
                        else
                                warning = true;
                }
-               for(i = 0; i < HUD_PANEL_NUM; ++i) {
+               for(i = 0; i < hud_panels_COUNT; ++i) {
                        if (panel_order[i] == -1) {
                                warning = true;
                                s = strcat(s, ftos(i), " "); //add missing panel number
@@ -4826,15 +4824,17 @@ void HUD_Main (void)
 
                //now properly set panel_order
                tokenize_console(s);
-               for(i = 0; i < HUD_PANEL_NUM; ++i) {
+               for(i = 0; i < hud_panels_COUNT; ++i) {
                        panel_order[i] = stof(argv(i));
                }
        }
 
        hud_draw_maximized = 0;
        // draw panels in the order specified by panel_order array
-       for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
-               HUD_Panel_Draw(hud_panel[panel_order[i]]);
+       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
@@ -4845,6 +4845,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;