Merge branch 'master' into terencehill/hud_code_cleanup
authorterencehill <piuntn@gmail.com>
Mon, 6 Jan 2014 00:53:05 +0000 (01:53 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 6 Jan 2014 00:53:05 +0000 (01:53 +0100)
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/client/hud_config.qc
qcsrc/client/miscfunctions.qc
qcsrc/client/scoreboard.qc
qcsrc/common/items.qh

index 3206e92..8fb6e51 100644 (file)
@@ -933,6 +933,7 @@ void Ent_ScoresInfo()
        float i;
        self.classname = "ent_client_scores_info";
        gametype = ReadInt24_t();
+       HUD_ModIcons_SetFunc();
        for(i = 0; i < MAX_SCORE; ++i)
        {
                scores_label[i] = strzone(ReadString());
index 41cec30..85dfe54 100644 (file)
@@ -1660,32 +1660,16 @@ void CSQC_common_hud(void)
        if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS))
                Accuracy_LoadLevels();
 
-    HUD_Main(); // always run these functions for alpha checks
-    HUD_DrawScoreboard();
+       HUD_Main(); // always run these functions for alpha checks
+       HUD_DrawScoreboard();
 
-    if (scoreboard_active) // scoreboard/accuracy
-        HUD_Reset();
-    else if (intermission == 2) // map voting screen
-    {
-        HUD_FinaleOverlay();
-        HUD_Reset();
-    }
-       /*
-       switch(hud)
+       if (scoreboard_active) // scoreboard/accuracy
+               HUD_Reset();
+       else if (intermission == 2) // map voting screen
        {
-               case HUD_SPIDERBOT:
-                       CSQC_SPIDER_HUD();
-                       break;
-
-               case HUD_WAKIZASHI:
-                       CSQC_WAKIZASHI_HUD();
-                       break;
-
-        case HUD_BUMBLEBEE:
-            CSQC_BUMBLE_HUD();
-            break;
+               MapVote_Draw();
+               HUD_Reset();
        }
-       */
 }
 
 
index 43aab6a..5ba321a 100644 (file)
@@ -341,7 +341,17 @@ float autocvar_hud_panel_weapons_timeout_fadebgmin;
 float autocvar_hud_panel_weapons_timeout_fadefgmin;
 var float autocvar_hud_panel_weapons_timeout_speed_in = 0.25;
 var float autocvar_hud_panel_weapons_timeout_speed_out = 0.75;
+vector autocvar_hud_progressbar_acceleration_color;
+vector autocvar_hud_progressbar_acceleration_neg_color;
 float autocvar_hud_progressbar_alpha;
+vector autocvar_hud_progressbar_armor_color;
+vector autocvar_hud_progressbar_fuel_color;
+vector autocvar_hud_progressbar_health_color;
+vector autocvar_hud_progressbar_nexball_color;
+vector autocvar_hud_progressbar_shield_color;
+vector autocvar_hud_progressbar_speed_color;
+vector autocvar_hud_progressbar_strength_color;
+vector autocvar_hud_progressbar_superweapons_color;
 float autocvar_hud_showbinds;
 float autocvar_hud_showbinds_limit;
 float autocvar__hud_showbinds_reload;
index 6f008fb..120b665 100644 (file)
@@ -218,16 +218,11 @@ void CSQCPlayer_ModelAppearance_Apply(float islocalplayer)
                // own team's color is never forced
                float forcecolor_friend = 0;
                float forcecolor_enemy = 0;
-               float teams_count = 0;
                entity tm;
 
-               for(tm = teams.sort_next; tm; tm = tm.sort_next)
-                       if(tm.team != NUM_SPECTATOR)
-                               ++teams_count;
-
                if(autocvar_cl_forcemyplayercolors)
                        forcecolor_friend = 1024 + autocvar_cl_forcemyplayercolors;
-               if(autocvar_cl_forceplayercolors && teams_count == 2)
+               if(autocvar_cl_forceplayercolors && team_count == 2)
                        forcecolor_enemy = 1024 + autocvar__cl_color;
 
                if(forcecolor_enemy && !forcecolor_friend)
index 2521425..d5f74f2 100644 (file)
@@ -264,8 +264,8 @@ HUD panels
 
 // draw the background/borders
 #define HUD_Panel_DrawBg(theAlpha)\
-if(panel_bg != "0" && panel_bg != "")\
-       draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, 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))
+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))
 
 //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, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
@@ -489,7 +489,6 @@ void HUD_Weapons(void)
 
        // update generic hud functions
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        draw_beginBoldFont();
 
@@ -941,7 +940,7 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s
 
 void HUD_Ammo(void)
 {
-    if(hud != HUD_NORMAL) return;
+       if(hud != HUD_NORMAL) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_ammo) return;
@@ -949,7 +948,6 @@ void HUD_Ammo(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        draw_beginBoldFont();
 
@@ -964,6 +962,7 @@ void HUD_Ammo(void)
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
+       const float AMMO_COUNT = 4;
        float rows = 0, columns, row, column;
        vector ammo_size;
        if (autocvar_hud_panel_ammo_onlycurrent)
@@ -1155,7 +1154,6 @@ void HUD_Powerups(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        draw_beginBoldFont();
 
@@ -1277,10 +1275,7 @@ void HUD_Powerups(void)
                const float maxshield = 30;
                float shield = ceil(shield_time);
                if(autocvar_hud_panel_powerups_progressbar)
-               {
-                       HUD_Panel_GetProgressBarColor(shield);
-                       HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-               }
+                       HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, autocvar_hud_progressbar_shield_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                if(autocvar_hud_panel_powerups_text)
                {
                        if(shield > 1)
@@ -1295,10 +1290,7 @@ void HUD_Powerups(void)
                const float maxstrength = 30;
                float strength = ceil(strength_time);
                if(autocvar_hud_panel_powerups_progressbar)
-               {
-                       HUD_Panel_GetProgressBarColor(strength);
-                       HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-               }
+                       HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, autocvar_hud_progressbar_strength_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                if(autocvar_hud_panel_powerups_text)
                {
                        if(strength > 1)
@@ -1313,10 +1305,7 @@ void HUD_Powerups(void)
                const float maxsuperweapons = 30;
                float superweapons = ceil(superweapons_time);
                if(autocvar_hud_panel_powerups_progressbar)
-               {
-                       HUD_Panel_GetProgressBarColor(superweapons);
-                       HUD_Panel_DrawProgressBar(pos + superweapons_offset, mySize, autocvar_hud_panel_powerups_progressbar_superweapons, superweapons/maxsuperweapons, is_vertical, superweapons_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-               }
+                       HUD_Panel_DrawProgressBar(pos + superweapons_offset, mySize, autocvar_hud_panel_powerups_progressbar_superweapons, superweapons/maxsuperweapons, is_vertical, superweapons_baralign, autocvar_hud_progressbar_superweapons_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                if(autocvar_hud_panel_powerups_text)
                {
                        if(superweapons > 1)
@@ -1396,7 +1385,6 @@ void HUD_HealthArmor(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -1427,10 +1415,7 @@ void HUD_HealthArmor(void)
                {
                        biggercount = "health";
                        if(autocvar_hud_panel_healtharmor_progressbar)
-                       {
-                               HUD_Panel_GetProgressBarColor(health);
-                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                       }
+                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        if(armor)
             if(autocvar_hud_panel_healtharmor_text)
                                drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
@@ -1439,10 +1424,7 @@ void HUD_HealthArmor(void)
                {
                        biggercount = "armor";
                        if(autocvar_hud_panel_healtharmor_progressbar)
-                       {
-                               HUD_Panel_GetProgressBarColor(armor);
-                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                       }
+                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        if(health)
             if(autocvar_hud_panel_healtharmor_text)
                                drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -1451,10 +1433,7 @@ void HUD_HealthArmor(void)
                        DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
 
                if(fuel)
-               {
-                       HUD_Panel_GetProgressBarColor(fuel);
-                       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);
-               }
+                       HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
        }
        else
        {
@@ -1501,7 +1480,6 @@ void HUD_HealthArmor(void)
                {
                        if(autocvar_hud_panel_healtharmor_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(health);
                                float p_health, pain_health_alpha;
                                p_health = health;
                                pain_health_alpha = 1;
@@ -1534,7 +1512,7 @@ void HUD_HealthArmor(void)
                                                if (time - health_damagetime < 1)
                                                {
                                                        float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
-                                                       HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL);
+                                                       HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL);
                                                }
                                        }
                                        prev_health = health;
@@ -1547,7 +1525,7 @@ void HUD_HealthArmor(void)
                                                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 * pain_health_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, autocvar_hud_progressbar_health_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);
@@ -1557,7 +1535,6 @@ void HUD_HealthArmor(void)
                {
                        if(autocvar_hud_panel_healtharmor_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(armor);
                                float p_armor;
                                p_armor = armor;
                                if (autocvar_hud_panel_healtharmor_progressbar_gfx)
@@ -1589,12 +1566,12 @@ void HUD_HealthArmor(void)
                                                if (time - armor_damagetime < 1)
                                                {
                                                        float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
-                                                       HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL);
+                                                       HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL);
                                                }
                                        }
                                        prev_armor = armor;
                                }
-                               HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        if(autocvar_hud_panel_healtharmor_text)
                                DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
@@ -1610,8 +1587,7 @@ void HUD_HealthArmor(void)
                                mySize_x *= 2; //restore full panel size
                        else if (panel_ar < 1/4)
                                mySize_y *= 2; //restore full panel size
-                       HUD_Panel_GetProgressBarColor(fuel);
-                       HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", 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, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                }
        }
 }
@@ -1649,7 +1625,6 @@ void HUD_Notify(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -1786,7 +1761,6 @@ void HUD_Timer(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        draw_beginBoldFont();
 
@@ -1854,7 +1828,6 @@ void HUD_Radar(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        float f = 0;
 
@@ -1866,8 +1839,13 @@ void HUD_Radar(void)
                panel_pos_x = (vid_conwidth - panel_size_x) / 2;
                panel_pos_y = (vid_conheight - panel_size_y) / 2;
 
+               string panel_bg;
                panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
-               if(precache_pic(panel_bg) == "") { panel_bg = "gfx/hud/default/border_default"; } // fallback
+               if(precache_pic(panel_bg) == "")
+                       panel_bg = "gfx/hud/default/border_default"; // fallback
+               if(panel.current_panel_bg)
+                       strunzone(panel.current_panel_bg);
+               panel.current_panel_bg = strzone(panel_bg);
 
                switch(hud_panel_radar_maximized_zoommode)
                {
@@ -2016,7 +1994,7 @@ void HUD_Radar(void)
 // Score (#7)
 //
 void HUD_UpdatePlayerTeams();
-void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
+void HUD_Score_Rankings(vector pos, vector mySize, entity me)
 {
        float score;
        entity tm = world, pl;
@@ -2146,7 +2124,6 @@ void HUD_Score(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -2207,7 +2184,7 @@ void HUD_Score(void)
        } else if (!teamplay) { // non-teamgames
                if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
                {
-                       HUD_Score_Rankings(pos, mySize, me, 0);
+                       HUD_Score_Rankings(pos, mySize, me);
                        return;
                }
                // me vector := [team/connected frags id]
@@ -2248,23 +2225,21 @@ void HUD_Score(void)
                drawstring_aspect(pos + eX * 0.75 * mySize_x, distribution_str, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
                draw_endBoldFont();
        } else { // teamgames
-               float scores_count = 0, row, column, rows = 0, columns = 0;
+               float row, column, rows = 0, columns = 0;
                local noref vector offset = '0 0 0';
                vector score_pos, score_size; //for scores other than myteam
-               if (spectatee_status == -1 || autocvar_hud_panel_score_rankings)
+               if(autocvar_hud_panel_score_rankings)
+               {
+                       HUD_Score_Rankings(pos, mySize, me);
+                       return;
+               }
+               if(spectatee_status == -1)
                {
-                       for(tm = teams.sort_next; tm, tm.team != NUM_SPECTATOR; tm = tm.sort_next)
-                               ++scores_count;
-                       if (autocvar_hud_panel_score_rankings)
-                       {
-                               HUD_Score_Rankings(pos, mySize, me, scores_count);
-                               return;
-                       }
                        rows = mySize_y/mySize_x;
-                       rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
+                       rows = bound(1, floor((sqrt(4 * (3/1) * rows * team_count + rows * rows) + rows + 0.5) / 2), team_count);
                        //                               ^^^ ammo item aspect goes here
 
-                       columns = ceil(scores_count/rows);
+                       columns = ceil(team_count/rows);
 
                        score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
 
@@ -2341,7 +2316,6 @@ void HUD_RaceTimer (void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        draw_beginBoldFont();
 
@@ -2542,7 +2516,6 @@ void HUD_Vote(void)
                return;
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        if(uid2name_dialog)
        {
@@ -2693,11 +2666,6 @@ void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, float layout, f
 void HUD_Mod_CA(vector myPos, vector mySize)
 {
        mod_active = 1; // required in each mod function that always shows something
-       entity tm;
-       float teams_count = 0;
-       for(tm = teams.sort_next; tm; tm = tm.sort_next)
-               if(tm.team != NUM_SPECTATOR)
-                       ++teams_count;
 
        float layout;
        if(gametype == MAPINFO_TYPE_CA)
@@ -2707,14 +2675,14 @@ void HUD_Mod_CA(vector myPos, vector mySize)
        float rows, columns, aspect_ratio;
        rows = mySize_y/mySize_x;
        aspect_ratio = (layout) ? 2 : 1;
-       rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
-       columns = ceil(teams_count/rows);
+       rows = bound(1, floor((sqrt((4 * aspect_ratio * team_count + rows) * rows) + rows + 0.5) / 2), team_count);
+       columns = ceil(team_count/rows);
 
        int i;
        float row = 0, column = 0;
        vector pos, itemSize;
        itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
-       for(i=0; i<teams_count; ++i)
+       for(i=0; i<team_count; ++i)
        {
                pos = myPos + eX * column * itemSize_x + eY * row * itemSize_y;
 
@@ -3093,12 +3061,7 @@ void HUD_Mod_NexBall(vector pos, vector mySize)
                if (p > 1)
                        p = 2 - p;
 
-               //Draw the filling
-               HUD_Panel_GetProgressBarColor(nexball);
-               if(mySize_x > mySize_y)
-                       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, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, (mySize_x <= mySize_y), 0, autocvar_hud_progressbar_nexball_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
 
        if (stat_items & IT_KEY1)
@@ -3324,24 +3287,19 @@ void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout,
 void HUD_Mod_Dom(vector myPos, vector mySize)
 {
        mod_active = 1; // required in each mod function that always shows something
-       entity tm;
-       float teams_count = 0;
-       for(tm = teams.sort_next; tm; tm = tm.sort_next)
-               if(tm.team != NUM_SPECTATOR)
-                       ++teams_count;
 
        float layout = autocvar_hud_panel_modicons_dom_layout;
        float rows, columns, aspect_ratio;
        rows = mySize_y/mySize_x;
        aspect_ratio = (layout) ? 3 : 1;
-       rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
-       columns = ceil(teams_count/rows);
+       rows = bound(1, floor((sqrt((4 * aspect_ratio * team_count + rows) * rows) + rows + 0.5) / 2), team_count);
+       columns = ceil(team_count/rows);
 
        int i;
        float row = 0, column = 0;
        vector pos, itemSize;
        itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
-       for(i=0; i<teams_count; ++i)
+       for(i=0; i<team_count; ++i)
        {
                pos = myPos + eX * column * itemSize_x + eY * row * itemSize_y;
 
@@ -3356,6 +3314,22 @@ void HUD_Mod_Dom(vector myPos, vector mySize)
        }
 }
 
+void HUD_ModIcons_SetFunc()
+{
+       switch(gametype)
+       {
+               case MAPINFO_TYPE_KEYHUNT:              HUD_ModIcons_GameType = HUD_Mod_KH; break;
+               case MAPINFO_TYPE_CTF:                  HUD_ModIcons_GameType = HUD_Mod_CTF; break;
+               case MAPINFO_TYPE_NEXBALL:              HUD_ModIcons_GameType = HUD_Mod_NexBall; break;
+               case MAPINFO_TYPE_CTS:
+               case MAPINFO_TYPE_RACE:         HUD_ModIcons_GameType = HUD_Mod_Race; break;
+               case MAPINFO_TYPE_CA:
+               case MAPINFO_TYPE_FREEZETAG:    HUD_ModIcons_GameType = HUD_Mod_CA; break;
+               case MAPINFO_TYPE_DOMINATION:   HUD_ModIcons_GameType = HUD_Mod_Dom; break;
+               case MAPINFO_TYPE_KEEPAWAY:     HUD_ModIcons_GameType = HUD_Mod_Keepaway; break;
+       }
+}
+
 float mod_prev; // previous state of mod_active to check for a change
 float mod_alpha;
 float mod_change; // "time" when mod_active changed
@@ -3365,18 +3339,13 @@ void HUD_ModIcons(void)
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_modicons) return;
-               if (gametype != MAPINFO_TYPE_CTF && gametype != MAPINFO_TYPE_KEYHUNT && gametype != MAPINFO_TYPE_NEXBALL && gametype != MAPINFO_TYPE_CTS && gametype != MAPINFO_TYPE_RACE && gametype != MAPINFO_TYPE_CA && gametype != MAPINFO_TYPE_FREEZETAG && gametype != MAPINFO_TYPE_KEEPAWAY && gametype != MAPINFO_TYPE_DOMINATION) return;
+               if(!HUD_ModIcons_GameType) return;
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        draw_beginBoldFont();
 
-       vector pos, mySize;
-       pos = panel_pos;
-       mySize = panel_size;
-
        if(mod_active != mod_prev) {
                mod_change = time;
                mod_prev = mod_active;
@@ -3392,25 +3361,14 @@ void HUD_ModIcons(void)
 
        if(panel_bg_padding)
        {
-               pos += '1 1 0' * panel_bg_padding;
-               mySize -= '2 2 0' * panel_bg_padding;
+               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_size -= '2 2 0' * panel_bg_padding;
        }
 
-       // these MUST be ran in order to update mod_active
-       if(gametype == MAPINFO_TYPE_KEYHUNT)
-               HUD_Mod_KH(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_CTF || autocvar__hud_configure)
-               HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
-       else if(gametype == MAPINFO_TYPE_NEXBALL)
-               HUD_Mod_NexBall(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE)
-               HUD_Mod_Race(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_CA || gametype == MAPINFO_TYPE_FREEZETAG)
-               HUD_Mod_CA(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_DOMINATION)
-               HUD_Mod_Dom(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_KEEPAWAY)
-               HUD_Mod_Keepaway(pos, mySize);
+       if(autocvar__hud_configure)
+               HUD_Mod_CTF(panel_pos, panel_size);
+       else
+               HUD_ModIcons_GameType(panel_pos, panel_size);
 
        draw_endBoldFont();
 }
@@ -3426,7 +3384,6 @@ void HUD_PressedKeys(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -3498,20 +3455,20 @@ void HUD_Chat(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
        {
                panel_pos_y = panel_bg_border;
                panel_size_y = vid_conheight - panel_bg_border * 2;
-               if(panel_bg == "0") // force a border when maximized
+               if(panel.current_panel_bg == "0") // force a border when maximized
                {
-                       if(precache_pic(panel_bg) == "") {
-                               panel_bg = strcat(hud_skin_path, "/border_default");
-                               if(precache_pic(panel_bg) == "") {
-                                       panel_bg = "gfx/hud/default/border_default";
-                               }
-                       }
+                       string panel_bg;
+                       panel_bg = strcat(hud_skin_path, "/border_default");
+                       if(precache_pic(panel_bg) == "")
+                               panel_bg = "gfx/hud/default/border_default";
+                       if(panel.current_panel_bg)
+                               strunzone(panel.current_panel_bg);
+                       panel.current_panel_bg = strzone(panel_bg);
                }
                panel_bg_alpha = max(0.75, panel_bg_alpha); // force an theAlpha of at least 0.75
        }
@@ -3572,7 +3529,6 @@ void HUD_EngineInfo(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -3633,7 +3589,6 @@ void HUD_InfoMessages(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -3820,7 +3775,6 @@ void HUD_Physics(void)
        }
 
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
 
        draw_beginBoldFont();
 
@@ -3942,10 +3896,7 @@ void HUD_Physics(void)
        //draw speed
        if(speed)
        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, "progressbar", 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, autocvar_hud_progressbar_speed_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        vector tmp_offset = '0 0 0', tmp_size = '0 0 0';
        if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
        {
@@ -4012,18 +3963,15 @@ void HUD_Physics(void)
                                        peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
                 else // if (speed_baralign == 2)
                     peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
-                               //if speed is not 0 the speed progressbar already fetched the color
-                               if (speed == 0)
-                                       HUD_Panel_GetProgressBarColor(speed);
                                peak_size_x = floor(panel_size_x * 0.01 + 1.5);
                 peak_size_y = panel_size_y;
                 if (speed_baralign == 2) // draw two peaks, on both sides
                 {
-                    drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x + peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                    drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x - peak_offset_x + peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                    drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x + peak_offset_x - peak_size_x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                    drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x - peak_offset_x + peak_size_x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                 }
                 else
-                    drawfill(panel_pos + speed_offset + eX * (peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                    drawfill(panel_pos + speed_offset + eX * (peak_offset_x - peak_size_x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
 
                        //top speed
@@ -4041,10 +3989,11 @@ void HUD_Physics(void)
        if(acceleration)
        if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
        {
-               if (acceleration < 0)
-                       HUD_Panel_GetProgressBarColor(acceleration_neg);
+               vector progressbar_color;
+               if(acceleration < 0)
+                       progressbar_color = autocvar_hud_progressbar_acceleration_neg_color;
                else
-                       HUD_Panel_GetProgressBarColor(acceleration);
+                       progressbar_color = autocvar_hud_progressbar_acceleration_color;
 
                f = acceleration/autocvar_hud_panel_physics_acceleration_max;
                if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear)
@@ -4215,14 +4164,19 @@ void HUD_CenterPrint (void)
                }
        }
 
+       // this panel fades only when the menu does
+       float hud_fade_alpha_save = 0;
+       if(scoreboard_fade_alpha)
+       {
+               hud_fade_alpha_save = hud_fade_alpha;
+               hud_fade_alpha = 1 - autocvar__menu_alpha;
+       }
        HUD_Panel_UpdateCvars();
 
-       // this panel doesn't fade when showing the scoreboard
-       if(autocvar__menu_alpha)
-               HUD_Panel_ApplyFadeAlpha();
-
        if(scoreboard_fade_alpha)
        {
+               hud_fade_alpha = hud_fade_alpha_save;
+
                // move the panel below the scoreboard
                if (scoreboard_bottom >= 0.96 * vid_conheight)
                        return;
@@ -4420,21 +4374,13 @@ void HUD_Main (void)
        if(scoreboard_fade_alpha)
                hud_fade_alpha = (1 - scoreboard_fade_alpha);
 
-       if(autocvar__hud_configure)
-               if(isdemo())
-                       HUD_Configure_Exit_Force();
+       HUD_Configure_Frame();
 
        if(intermission == 2) // no hud during mapvote
-       {
-               if (autocvar__hud_configure)
-                       HUD_Configure_Exit_Force();
                hud_fade_alpha = 0;
-       }
-       else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
-               hud_fade_alpha = 1;
 
        // panels that we want to be active together with the scoreboard
-       // they must call HUD_Panel_ApplyFadeAlpha(); only when showing the menu
+       // they must fade only when the menu does
        if(scoreboard_fade_alpha == 1)
        {
                (panel = HUD_PANEL(CENTERPRINT)).panel_draw();
@@ -4455,24 +4401,6 @@ void HUD_Main (void)
                hud_skin_prev = strzone(autocvar_hud_skin);
        }
 
-       // HUD configure visible grid
-       if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
-       {
-               hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
-               hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
-               hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
-               hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
-               vector s;
-               // x-axis
-               s = eX + eY * vid_conheight;
-               for(i = 1; i < 1/hud_configure_gridSize_x; ++i)
-                       drawfill(eX * i * hud_configure_realGridSize_x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
-               // y-axis
-               s = eY + eX * vid_conwidth;
-               for(i = 1; i < 1/hud_configure_gridSize_y; ++i)
-                       drawfill(eY * i * hud_configure_realGridSize_y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
-       }
-
 #ifdef COMPAT_XON050_ENGINE
     current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
 #else
@@ -4573,34 +4501,7 @@ void HUD_Main (void)
        if(autocvar__con_chat_maximized)
                (panel = HUD_PANEL(CHAT)).panel_draw();
 
-       if(autocvar__hud_configure)
-       {
-               if(tab_panel)
-               {
-                       panel = tab_panel;
-                       HUD_Panel_UpdatePosSize()
-                       drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
-               }
-               if(highlightedPanel)
-               {
-                       panel = highlightedPanel;
-                       HUD_Panel_UpdatePosSize()
-                       HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
-               }
-               if(!hud_configure_prev || hud_configure_prev == -1)
-               {
-                       if(autocvar_hud_cursormode) { setcursormode(1); }
-                       hudShiftState = 0;
-                       for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
-                               hud_panel[panel_order[i]].update_time = time;
-               }
-       }
-       else if(hud_configure_prev && hud_configure_prev != -1 && autocvar_hud_cursormode)
-               setcursormode(0);
+       HUD_Configure_PostDraw();
 
        hud_configure_prev = autocvar__hud_configure;
-
-       if (!autocvar__hud_configure) // hud config mode disabled, enable normal theAlpha stuff again
-               if (menu_enabled)
-                       menu_enabled = 0;
 }
index c2432b9..840e802 100644 (file)
@@ -47,7 +47,6 @@ const float S_CTRL = 2;
 const float S_ALT = 4;
 
 float menu_enabled; // 1 showing the entire HUD, 2 showing only the clicked panel
-float menu_enabled_time;
 
 float hud_fade_alpha;
 
@@ -56,8 +55,6 @@ string hud_skin_prev;
 
 vector myteamcolors;
 
-var vector progressbar_color;
-
 entity highlightedPanel_backup;
 var vector panel_pos_backup;
 var vector panel_size_backup;
@@ -80,7 +77,6 @@ entity panel;
 var float panel_enabled;
 var vector panel_pos;
 var vector panel_size;
-var string panel_bg;
 var string panel_bg_str; // "_str" vars contain the raw value of the cvar, non-"_str" contains what hud.qc code should use
 var vector panel_bg_color;
 var string panel_bg_color_str;
@@ -146,24 +142,10 @@ HUD_PANELS
 // ----------------------
 // Little help for the poor people who have to make sense of this: Start from the bottom ;)
 
-#define HUD_Panel_GetProgressBarColor(item) \
-               progressbar_color = stov(cvar_string("hud_progressbar_" #item "_color"))
-#define HUD_Panel_GetProgressBarColorForString(item) \
-switch(item) {\
-       case "health": HUD_Panel_GetProgressBarColor(health); break;\
-       case "armor": HUD_Panel_GetProgressBarColor(armor); break;\
-       case "strength": HUD_Panel_GetProgressBarColor(strength); break;\
-       case "shield": HUD_Panel_GetProgressBarColor(shield); break;\
-       case "fuel": HUD_Panel_GetProgressBarColor(fuel); break;\
-       case "nexball": HUD_Panel_GetProgressBarColor(nexball); break;\
-       case "speed": HUD_Panel_GetProgressBarColor(speed); break;\
-       case "acceleration": HUD_Panel_GetProgressBarColor(acceleration); break;\
-       case "acceleration_neg": HUD_Panel_GetProgressBarColor(acceleration_neg); break;\
-} ENDS_WITH_CURLY_BRACE
-
-// Get value for panel_bg: if "" fetch default, else use panel_bg_str
+// Get value for panel.current_panel_bg: if "" fetch default, else use panel_bg_str
 // comment on last line of macro: // we probably want to see a background in config mode at all times...
 #define HUD_Panel_GetBg()\
+string panel_bg;\
 if(!autocvar__hud_configure && panel_bg_str == "0") {\
        panel_bg = "0";\
 } else {\
@@ -183,7 +165,10 @@ if(!autocvar__hud_configure && panel_bg_str == "0") {\
                        }\
                }\
        }\
-}
+}\
+if(panel.current_panel_bg)\
+       strunzone(panel.current_panel_bg);\
+panel.current_panel_bg = strzone(panel_bg);
 
 // Get value for panel_bg_color: if "" fetch default, else use panel_bg_color. Convert pants, shirt or teamcolor into a vector.
 #define HUD_Panel_GetColor()\
@@ -216,14 +201,6 @@ if(panel_bg_color_team_str == "") {\
        panel_bg_color_team = stof(panel_bg_color_team_str);\
 }
 
-// the check doesn't allow to fade this panel when showing the panel-specific menu dialog
-#define HUD_Panel_ApplyFadeAlpha()\
-if(!(menu_enabled == 2 && panel == highlightedPanel))\
-{\
-       panel_bg_alpha *= hud_fade_alpha;\
-       panel_fg_alpha *= hud_fade_alpha;\
-} ENDS_WITH_CURLY_BRACE
-
 // Get value for panel_bg_alpha: if "" fetch default, else use panel_bg_alpha. Also do various menu dialog fadeout/in checks, and minalpha checks
 // comment on line 3 of macro: // do not set a minalpha cap when showing the config dialog for this panel
 #define HUD_Panel_GetBgAlpha()\
@@ -255,13 +232,6 @@ if(panel_bg_border_str == "") {\
        panel_bg_border = stof(panel_bg_border_str);\
 } ENDS_WITH_CURLY_BRACE
 
-// Scale the pos and size vectors to absolute coordinates
-#define HUD_Panel_GetScaledVectors()\
-panel_pos_x *= vid_conwidth;\
-panel_pos_y *= vid_conheight;\
-panel_size_x *= vid_conwidth;\
-panel_size_y *= vid_conheight;
-
 // Get padding. See comments above, it's similar.
 // last line is a port of the old function, basically always make sure the panel contents are at least 5 pixels tall/wide, to disallow extreme padding values
 #define HUD_Panel_GetPadding()\
@@ -272,36 +242,12 @@ if(panel_bg_padding_str == "") {\
 }\
 panel_bg_padding = min(min(panel_size_x, panel_size_y)/2 - 5, panel_bg_padding);
 
-// Point to the macros above (stupid max macro length)
-#define HUD_Panel_GetStringVars()\
-HUD_Panel_GetBg()\
-if (panel_bg != "0") {\
-       HUD_Panel_GetColorTeam()\
-       HUD_Panel_GetColor()\
-       HUD_Panel_GetBgAlpha()\
-       HUD_Panel_GetBorder()\
-}\
-HUD_Panel_GetFgAlpha()\
-HUD_Panel_GetScaledVectors()\
-HUD_Panel_GetPadding()
-
-// return smoothly faded pos of given panel when a dialog is active
-var vector menu_enable_panelpos;
-#define HUD_Panel_GetMenuPos() \
-if(panel_size_x > panel_size_y)\
-       menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * panel_size_x + eY * 0.82 * vid_conheight;\
-else\
-       menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * panel_size_y + eX * 0.7 * vid_conwidth;\
-panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * menu_enable_panelpos;
-
-// return smoothly faded size of given panel when a dialog is active
-//var vector menu_enable_maxsize;
-var float menu_enable_maxsize_x;
-var float menu_enable_maxsize_y;
-var vector menu_enable_size;
-#define HUD_Panel_GetMenuSize()\
-menu_enable_maxsize_x = 0.3 * vid_conwidth;\
-menu_enable_maxsize_y = 0.18 * vid_conheight;\
+// return smoothly faded pos and size of given panel when a dialog is active
+#define HUD_Panel_UpdatePosSize_ForMenu()\
+vector menu_enable_pos;\
+vector menu_enable_size = '0 0 0';\
+float menu_enable_maxsize_x = 0.3 * vid_conwidth;\
+float menu_enable_maxsize_y = 0.18 * vid_conheight;\
 if(panel_size_x > panel_size_y)\
 {\
        if(panel_size_y > menu_enable_maxsize_y)\
@@ -310,6 +256,7 @@ if(panel_size_x > panel_size_y)\
                menu_enable_size_x = panel_size_x * (menu_enable_maxsize_y/panel_size_y);\
                panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\
        }\
+       menu_enable_pos = eX * 0.5 * vid_conwidth - eX * 0.5 * panel_size_x + eY * (vid_conheight - menu_enable_maxsize_y);\
 }\
 else\
 {\
@@ -319,7 +266,14 @@ else\
                menu_enable_size_y = panel_size_y * (menu_enable_maxsize_x/panel_size_x);\
                panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\
        }\
-}
+       menu_enable_pos = eY * 0.5 * vid_conheight - eY * 0.5 * panel_size_y + eX * (vid_conwidth - menu_enable_maxsize_x);\
+}\
+panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * menu_enable_pos;
+
+// Scale the pos and size vectors to absolute coordinates
+#define HUD_Panel_ScalePosSize()\
+panel_pos_x *= vid_conwidth; panel_pos_y *= vid_conheight;\
+panel_size_x *= vid_conwidth; panel_size_y *= vid_conheight;
 
 // NOTE: in hud_configure mode cvars must be reloaded every frame
 #define HUD_Panel_UpdateCvars() \
@@ -327,59 +281,55 @@ if(panel.update_time <= time) { \
        if(autocvar__hud_configure) panel_enabled = cvar(strcat("hud_panel_", panel.panel_name)); \
        panel_pos = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_pos"))); \
        panel_size = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_size"))); \
+       HUD_Panel_ScalePosSize() \
        panel_bg_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg")); \
        panel_bg_color_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color")); \
        panel_bg_color_team_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color_team")); \
        panel_bg_alpha_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_alpha")); \
        panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); \
        panel_bg_padding_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_padding")); \
-       HUD_Panel_GetStringVars()\
+       HUD_Panel_GetBg()\
+       if (panel.current_panel_bg != "0") {\
+               HUD_Panel_GetColorTeam()\
+               HUD_Panel_GetColor()\
+               HUD_Panel_GetBgAlpha()\
+               HUD_Panel_GetBorder()\
+       }\
+       HUD_Panel_GetFgAlpha()\
+       HUD_Panel_GetPadding()\
+       panel.current_panel_bg_alpha = panel_bg_alpha; \
+       panel.current_panel_fg_alpha = panel_fg_alpha; \
        if(menu_enabled == 2 && panel == highlightedPanel) {\
-               HUD_Panel_GetMenuSize()\
-               HUD_Panel_GetMenuPos()\
-       } \
+               HUD_Panel_UpdatePosSize_ForMenu()\
+       } else {\
+               panel_bg_alpha *= hud_fade_alpha;\
+               panel_fg_alpha *= hud_fade_alpha;\
+       }\
        panel.current_panel_pos = panel_pos; \
        panel.current_panel_size = panel_size; \
-       if(panel.current_panel_bg) \
-               strunzone(panel.current_panel_bg); \
-       if(panel_bg == "")\
-       {\
-               /*printf("^xf08 %s panel: panel_bg is empty\n", panel.panel_name);*/\
-               panel_bg = "0";\
-       }\
-       panel.current_panel_bg = strzone(panel_bg); \
-       panel.current_panel_bg_alpha = panel_bg_alpha; \
        panel.current_panel_bg_border = panel_bg_border; \
        panel.current_panel_bg_color = panel_bg_color; \
        panel.current_panel_bg_color_team = panel_bg_color_team; \
        panel.current_panel_bg_padding = panel_bg_padding; \
-       panel.current_panel_fg_alpha = panel_fg_alpha; \
        panel.update_time = (autocvar__hud_configure) ? time : time + autocvar_hud_panel_update_interval; \
 } else { \
        panel_pos = panel.current_panel_pos; \
        panel_size = panel.current_panel_size; \
-       panel_bg = panel.current_panel_bg; \
-       if(panel.current_panel_bg == "")\
-       {\
-               /*printf("^xf08 %s panel: panel.current_panel_bg is empty\n", panel.panel_name);*/\
-               panel_bg = "0";\
-       }\
-       panel_bg_alpha = panel.current_panel_bg_alpha; \
+       panel_bg_alpha = panel.current_panel_bg_alpha * hud_fade_alpha; \
        panel_bg_border = panel.current_panel_bg_border; \
        panel_bg_color = panel.current_panel_bg_color; \
        panel_bg_color_team = panel.current_panel_bg_color_team; \
        panel_bg_padding = panel.current_panel_bg_padding; \
-       panel_fg_alpha = panel.current_panel_fg_alpha; \
+       panel_fg_alpha = panel.current_panel_fg_alpha * hud_fade_alpha; \
 } ENDS_WITH_CURLY_BRACE
 
 #define HUD_Panel_UpdatePosSize() {\
 panel_enabled = cvar(strcat("hud_panel_", panel.panel_name)); \
 panel_pos = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_pos"))); \
 panel_size = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_size"))); \
-HUD_Panel_GetScaledVectors()\
+HUD_Panel_ScalePosSize()\
 if(menu_enabled == 2 && panel == highlightedPanel) {\
-       HUD_Panel_GetMenuSize()\
-       HUD_Panel_GetMenuPos()\
+       HUD_Panel_UpdatePosSize_ForMenu()\
 }\
 panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); \
 HUD_Panel_GetBorder() \
@@ -394,3 +344,6 @@ string notify_icon[KN_MAX_ENTRIES];
 string notify_attackers[KN_MAX_ENTRIES];
 string notify_victims[KN_MAX_ENTRIES];
 void HUD_Notify_Push(string icon, string attacker, string victim);
+
+var void HUD_ModIcons_GameType(vector pos, vector size);
+void HUD_ModIcons_SetFunc();
index d361454..810da2d 100644 (file)
@@ -721,7 +721,6 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                if (bInputType == 1)
                        return true;
                menu_enabled = 1;
-               menu_enabled_time = time;
                localcmd("menu_showhudexit\n");
        }
        else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
@@ -1068,22 +1067,11 @@ void HUD_Panel_Highlight(float allow_move)
 void HUD_Panel_EnableMenu()
 {
        menu_enabled = 2;
-       menu_enabled_time = time;
        localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
 }
 float mouse_over_panel;
 void HUD_Panel_Mouse()
 {
-       // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled
-       if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
-               menu_enabled = 0;
-
-       /*
-       print("menu_enabled: ", ftos(menu_enabled), "\n");
-       print("Highlighted: ", ftos(highlightedPanel), "\n");
-       print("Menu theAlpha: ", ftos(autocvar__menu_alpha), "\n");
-       */
-
        if(autocvar__menu_alpha == 1)
                return;
 
@@ -1197,6 +1185,66 @@ void HUD_Panel_Mouse()
 
        prevMouseClicked = mouseClicked;
 }
+void HUD_Configure_DrawGrid()
+{
+       float i;
+       if(autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
+       {
+               hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
+               hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
+               hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
+               hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
+               vector s;
+               // x-axis
+               s = eX + eY * vid_conheight;
+               for(i = 1; i < 1/hud_configure_gridSize_x; ++i)
+                       drawfill(eX * i * hud_configure_realGridSize_x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
+               // y-axis
+               s = eY + eX * vid_conwidth;
+               for(i = 1; i < 1/hud_configure_gridSize_y; ++i)
+                       drawfill(eY * i * hud_configure_realGridSize_y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
+       }
+}
+
+float _menu_alpha_prev;
+void HUD_Configure_Frame()
+{
+       float i;
+       if(autocvar__hud_configure)
+       {
+               if(isdemo() || intermission == 2)
+               {
+                       HUD_Configure_Exit_Force();
+                       return;
+               }
+
+               if(!hud_configure_prev || hud_configure_prev == -1)
+               {
+                       if(autocvar_hud_cursormode)
+                               setcursormode(1);
+                       hudShiftState = 0;
+                       for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
+                               hud_panel[panel_order[i]].update_time = time;
+               }
+
+               // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
+               if(autocvar__menu_alpha != _menu_alpha_prev)
+               {
+                       if(autocvar__menu_alpha == 0)
+                               menu_enabled = 0;
+                       _menu_alpha_prev = autocvar__menu_alpha;
+               }
+
+               HUD_Configure_DrawGrid();
+       }
+       else if(hud_configure_prev)
+       {
+               if(menu_enabled)
+                       menu_enabled = 0;
+               if(autocvar_hud_cursormode)
+                       setcursormode(0);
+       }
+}
 
 const float hlBorderSize = 4;
 const string hlBorder = "gfx/hud/default/border_highlighted";
@@ -1209,3 +1257,22 @@ void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha)
        drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize, hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL);
        drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize + eX * (panel_size_x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL);
 }
+
+void HUD_Configure_PostDraw()
+{
+       if(autocvar__hud_configure)
+       {
+               if(tab_panel)
+               {
+                       panel = tab_panel;
+                       HUD_Panel_UpdatePosSize()
+                       drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
+               }
+               if(highlightedPanel)
+               {
+                       panel = highlightedPanel;
+                       HUD_Panel_UpdatePosSize()
+                       HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
+               }
+       }
+}
index 61e527c..fbdbc45 100644 (file)
@@ -1,5 +1,6 @@
 entity players;
 entity teams;
+var float team_count; // real teams
 
 void AuditLists()
 {
@@ -81,6 +82,8 @@ float RegisterTeam(entity Team)
        if(teams.sort_next)
                teams.sort_next.sort_prev = Team;
        teams.sort_next = Team;
+       if(Team.team && Team.team != NUM_SPECTATOR)
+               ++team_count;
        AuditLists();
        return true;
 }
@@ -101,6 +104,8 @@ void RemoveTeam(entity Team)
        parent.sort_next = Team.sort_next;
        if(Team.sort_next)
                Team.sort_next.sort_prev = parent;
+       if(Team.team && Team.team != NUM_SPECTATOR)
+               --team_count;
        AuditLists();
 }
 
index 8a7d3fd..4389b8a 100644 (file)
@@ -54,20 +54,6 @@ string TranslateScoresLabel(string l)
        }
 }
 
-void MapVote_Draw();
-void HUD_FinaleOverlay()
-{
-       /*vector pos;
-       pos_x = (vid_conwidth - 1)/2;
-       pos_y = 16;
-       pos_z = 0;*/
-
-       //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
-
-       //drawstring(pos, "END", hud_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
-       MapVote_Draw();
-}
-
 void Cmd_HUD_SetFields(float argc);
 void HUD_InitScores()
 {
index 35cc002..264c9ca 100644 (file)
@@ -51,8 +51,6 @@ const float   IT_AMMO                      = 3968; // IT_SHELLS | IT_NAILS | IT_
 const float   IT_PICKUPMASK                = 51; // IT_FUEL_REGEN | IT_JETPACK | IT_UNLIMITED_AMMO; // strength and invincible are handled separately
 const float   IT_UNLIMITED_AMMO            = 3; // IT_UNLIMITED_SUPERWEAPONS | IT_UNLIMITED_WEAPON_AMMO;
 
-const float AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
-
 // variables:
 string weaponorder_byid;