From d04bab4354506854ecc0c425b7540e32bbc35825 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 9 Jun 2012 19:09:07 +0200 Subject: [PATCH] New cvar hud_panel_itemstime_size_dinamic, if enabled reduces panel size by removing spacing beetwen items --- _hud_descriptions.cfg | 1 + hud_luminos.cfg | 1 + hud_luminos_minimal.cfg | 1 + hud_luminos_minimal_xhair.cfg | 1 + hud_luminos_old.cfg | 1 + hud_nexuiz.cfg | 1 + qcsrc/client/autocvars.qh | 1 + qcsrc/client/hud.qc | 48 +++++++++++++++---- qcsrc/client/hud_config.qc | 1 + .../menu/xonotic/dialog_hudpanel_itemstime.c | 2 + 10 files changed, 48 insertions(+), 10 deletions(-) diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index 499f2d508..c1d4422d4 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -306,4 +306,5 @@ seta hud_panel_itemstime_progressbar_reduced "" "progressbar is displayed only i seta hud_panel_itemstime_showspawned "0" "show icons of already spawned items" seta hud_panel_itemstime_text "" "show text" seta hud_panel_itemstime_ratio "" "ratio between space reserved for text and icon width of each item entry (min value is 2)" +seta hud_panel_itemstime_size_dinamic "" "reduce panel size by removing spacing beetwen items" diff --git a/hud_luminos.cfg b/hud_luminos.cfg index 92d245acc..ebf063602 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -304,5 +304,6 @@ seta hud_panel_itemstime_progressbar_reduced "0" seta hud_panel_itemstime_showspawned "0" seta hud_panel_itemstime_text "1" seta hud_panel_itemstime_ratio "2" +seta hud_panel_itemstime_size_dinamic "1" menu_sync diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index 16a1a3924..c9d8efa9c 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -304,5 +304,6 @@ seta hud_panel_itemstime_progressbar_reduced "0" seta hud_panel_itemstime_showspawned "0" seta hud_panel_itemstime_text "1" seta hud_panel_itemstime_ratio "2" +seta hud_panel_itemstime_size_dinamic "1" menu_sync diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index 9c2d6e382..e78551116 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -304,5 +304,6 @@ seta hud_panel_itemstime_progressbar_reduced "0" seta hud_panel_itemstime_showspawned "0" seta hud_panel_itemstime_text "1" seta hud_panel_itemstime_ratio "2" +seta hud_panel_itemstime_size_dinamic "1" menu_sync diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index feb939361..c766eeeca 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -304,5 +304,6 @@ seta hud_panel_itemstime_progressbar_reduced "1" seta hud_panel_itemstime_showspawned "0" seta hud_panel_itemstime_text "1" seta hud_panel_itemstime_ratio "3.5" +seta hud_panel_itemstime_size_dinamic "1" menu_sync diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index 4a9692596..98e6f0b86 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -304,5 +304,6 @@ seta hud_panel_itemstime_progressbar_reduced "0" seta hud_panel_itemstime_showspawned "0" seta hud_panel_itemstime_text "1" seta hud_panel_itemstime_ratio "2" +seta hud_panel_itemstime_size_dinamic "1" menu_sync diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index e5ea0bb00..d7055f25f 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -246,6 +246,7 @@ float autocvar_hud_panel_healtharmor_text; float autocvar_hud_panel_infomessages; float autocvar_hud_panel_infomessages_flip; float autocvar_hud_panel_itemstime; +float autocvar_hud_panel_itemstime_size_dinamic; float autocvar_hud_panel_itemstime_ratio; float autocvar_hud_panel_itemstime_iconalign; float autocvar_hud_panel_itemstime_progressbar; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 377480443..306753950 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -5052,7 +5052,6 @@ void HUD_ItemsTime(void) pos = panel_pos; mySize = panel_size; - HUD_Panel_DrawBg(1); if(panel_bg_padding) { pos += '1 1 0' * panel_bg_padding; @@ -5071,21 +5070,50 @@ void HUD_ItemsTime(void) local noref vector offset; // fteqcc sucks float newSize; - if(itemstime_size_x/itemstime_size_y > ar) + if(autocvar_hud_panel_itemstime_size_dinamic) { - newSize = ar * itemstime_size_y; - offset_x = itemstime_size_x - newSize; - pos_x += offset_x/2; - itemstime_size_x = newSize; + if(autocvar__hud_configure) + if(menu_enabled != 2) + HUD_Panel_DrawBg(1); // also draw the bg of the entire panel + + // reduce panel to avoid spacing items + if(itemstime_size_x / itemstime_size_y < ar) + { + newSize = rows * itemstime_size_x / ar; + pos_y += (mySize_y - newSize) / 2; + mySize_y = newSize; + itemstime_size_y = mySize_y / rows; + } + else + { + newSize = columns * itemstime_size_y * ar; + pos_x += (mySize_x - newSize) / 2; + mySize_x = newSize; + itemstime_size_x = mySize_x / columns; + } + panel_pos = pos - '1 1 0' * panel_bg_padding; + panel_size = mySize + '2 2 0' * panel_bg_padding; } else { - newSize = 1/ar * itemstime_size_x; - offset_y = itemstime_size_y - newSize; - pos_y += offset_y/2; - itemstime_size_y = newSize; + if(itemstime_size_x/itemstime_size_y > ar) + { + newSize = ar * itemstime_size_y; + offset_x = itemstime_size_x - newSize; + pos_x += offset_x/2; + itemstime_size_x = newSize; + } + else + { + newSize = 1/ar * itemstime_size_x; + offset_y = itemstime_size_y - newSize; + pos_y += offset_y/2; + itemstime_size_y = newSize; + } } + HUD_Panel_DrawBg(1); + for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) { if (ItemsTime_time[i] == -1) continue; diff --git a/qcsrc/client/hud_config.qc b/qcsrc/client/hud_config.qc index 5406cc9c0..dae288355 100644 --- a/qcsrc/client/hud_config.qc +++ b/qcsrc/client/hud_config.qc @@ -189,6 +189,7 @@ void HUD_Panel_ExportCfg(string cfgname) HUD_Write_PanelCvar_q("_showspawned"); HUD_Write_PanelCvar_q("_text"); HUD_Write_PanelCvar_q("_ratio"); + HUD_Write_PanelCvar_q("_size_dinamic"); break; } HUD_Write("\n"); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_itemstime.c b/qcsrc/menu/xonotic/dialog_hudpanel_itemstime.c index 53134f2e9..349be0a8a 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_itemstime.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_itemstime.c @@ -38,5 +38,7 @@ void XonoticHUDItemsTimeDialog_fill(entity me) me.TD(me, 1, 2.6, e = makeXonoticSlider(2, 8, 0.5, "hud_panel_itemstime_ratio")); me.TR(me); me.TD(me, 1, 4, e = makeXonoticCheckBox(0, "hud_panel_itemstime_showspawned", _("Show spawned items"))); + me.TR(me); + me.TD(me, 1, 4, e = makeXonoticCheckBox(0, "hud_panel_itemstime_size_dinamic", _("Dinamic size"))); } #endif -- 2.39.2