]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge branch 'master' into Mario/buff_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 8463117dfd4c7c6f58ed9c5745e343c04573b968..dfe52049b16ed8c6ed79c7140dd9ab54de9f9227 100644 (file)
@@ -592,30 +592,26 @@ void HUD_Weapons(void)
                weapon_size.x = padded_panel_size.x / columns;
                weapon_size.y = padded_panel_size.y / rows;
 
-               // reduce table trying to keep the original table proportions as much as possible
-               vertical_order = (columns >= rows);
-               if(vertical_order)
-               {
-                       rows = ceil(sqrt(weapon_count / (columns / rows)));
-                       columns = ceil(weapon_count / rows);
-               }
-               else
-               {
-                       columns = ceil(sqrt(weapon_count / (rows / columns)));
-                       rows = ceil(weapon_count / columns);
-               }
-
                // NOTE: although weapons should aways look the same even if onlyowned is enabled,
                // we enlarge them a bit when possible to better match the desired aspect ratio
-               if(padded_panel_size.y > padded_panel_size.x)
+               if(padded_panel_size.x / padded_panel_size.y < aspect)
                {
+                       // maximum number of rows that allows to display items with the desired aspect ratio
+                       float max_rows = floor(padded_panel_size.y / (weapon_size.x / aspect));
+                       columns = min(columns, ceil(weapon_count / max_rows));
+                       rows = ceil(weapon_count / columns);
                        weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect);
                        weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y);
+                       vertical_order = false;
                }
                else
                {
+                       float max_columns = floor(padded_panel_size.x / (weapon_size.y * aspect));
+                       rows = min(rows, ceil(weapon_count / max_columns));
+                       columns = ceil(weapon_count / rows);
                        weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y);
                        weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect);
+                       vertical_order = true;
                }
 
                // reduce size of the panel
@@ -758,7 +754,7 @@ void HUD_Weapons(void)
                rows = table_size.y;
                weapon_size.x = panel_size.x / columns;
                weapon_size.y = panel_size.y / rows;
-               vertical_order = (columns >= rows);
+               vertical_order = (panel_size.x / panel_size.y >= aspect);
        }
 
        // calculate position/size for visual bar displaying ammount of ammo status
@@ -4290,12 +4286,12 @@ void HUD_CenterPrint (void)
        {
                if(!autocvar_hud_panel_centerprint) return;
 
-               if (hud_configure_prev && hud_configure_prev != -1)
+               if(hud_configure_prev)
                        reset_centerprint_messages();
        }
        else
        {
-               if (!hud_configure_prev)
+               if(!hud_configure_prev)
                        reset_centerprint_messages();
                if (time > hud_configure_cp_generation_time)
                {
@@ -4526,8 +4522,7 @@ void HUD_Buffs(void)
        }
 
        HUD_Panel_UpdateCvars();
-
-       draw_beginBoldFont();
+       
 
        vector pos, mySize;
        pos = panel_pos;
@@ -4545,8 +4540,16 @@ void HUD_Buffs(void)
        //float buff_iconalign = autocvar_hud_panel_buffs_iconalign;
        vector buff_offset = '0 0 0';
 
+       draw_beginBoldFont();
+       float buff_time, buff_maxtime;
+       buff_time = bound(0, getstatf(STAT_BUFF_TIME) - time, 99);
+       buff_maxtime = 60; // TODO: stat?
        for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items)
        {
+               if(buff_time && autocvar_hud_panel_buffs_progressbar)
+                       HUD_Panel_DrawProgressBar(pos + buff_offset, mySize, autocvar_hud_panel_buffs_progressbar_name, buff_time/buff_maxtime, 0, 0, 
+                                                                         Buff_Color(e.items) * -1 + '1 1 1', (autocvar_hud_progressbar_alpha * panel_fg_alpha) * 0.4, DRAWFLAG_NORMAL);
+
                //DrawNumIcon(pos + buff_offset, mySize, shield, "shield", is_vertical, buff_iconalign, '1 1 1', 1);
                drawcolorcodedstring_aspect(pos + buff_offset, s, mySize, panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
        }