From ad6a83ef5f26601ecd76774df04d769e1dad9b93 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 7 Feb 2015 21:00:55 +0100 Subject: [PATCH] Ultimate improvement of the onlyowned layout: change the automatic fix of the weapon icon aspect ratio to note scale the icon up, then scale it up (when there's enough available space) with hud_panel_weapons_onlyowned_icon_maxscale without altering aspect ratio --- _hud_descriptions.cfg | 1 + hud_luma.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 | 27 +++++++++++++++++++++------ qcsrc/client/hud_config.qc | 1 + 10 files changed, 30 insertions(+), 6 deletions(-) diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index a47884ef0..06ffb8ccb 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -62,6 +62,7 @@ seta hud_panel_weapons_label_scale "" "scale of the weapon text label" seta hud_panel_weapons_accuracy "" "show accuracy color as the weapon icon background; colors can be configured with accuracy_color* cvars" seta hud_panel_weapons_ammo "" "show ammo as a status bar" seta hud_panel_weapons_onlyowned "" "show only owned weapons" +seta hud_panel_weapons_onlyowned_icon_maxscale "" "scale icons up by this factor when there's enough available space; 0 means use maximum available scale" seta hud_panel_ammo "" "enable/disable this panel" seta hud_panel_ammo_pos "" "position of this panel" diff --git a/hud_luma.cfg b/hud_luma.cfg index 4f801509e..26f82aac4 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -60,6 +60,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0.4" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_onlyowned_icon_maxscale "1.5" seta hud_panel_ammo 1 seta hud_panel_ammo_pos "0.330000 0.865000" diff --git a/hud_luminos.cfg b/hud_luminos.cfg index 34db2beb6..77c224e06 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -60,6 +60,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0.4" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_onlyowned_icon_maxscale "1.5" seta hud_panel_ammo 1 seta hud_panel_ammo_pos "0.330000 0.960000" diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index 39a6fd2ed..93424cadc 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -60,6 +60,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_onlyowned_icon_maxscale "1.5" seta hud_panel_ammo 1 seta hud_panel_ammo_pos "0.650000 0.890000" diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index 4b6b7e4a7..3947487af 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -60,6 +60,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_onlyowned_icon_maxscale "1.5" seta hud_panel_ammo 1 seta hud_panel_ammo_pos "0.450000 0.630000" diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index 20650899e..203e1bce5 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -60,6 +60,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_onlyowned_icon_maxscale "1.5" seta hud_panel_ammo 1 seta hud_panel_ammo_pos "0.190000 0.920000" diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index 2d86881f5..3ecebc5bf 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -60,6 +60,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "0" +seta hud_panel_weapons_onlyowned_icon_maxscale "1.5" seta hud_panel_ammo 1 seta hud_panel_ammo_pos "0.160000 0.910000" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index e35bf82dd..ac254df87 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -352,6 +352,7 @@ float autocvar_hud_panel_weapons_complainbubble_time; int autocvar_hud_panel_weapons_label; float autocvar_hud_panel_weapons_label_scale = 0.5; bool autocvar_hud_panel_weapons_onlyowned; +float autocvar_hud_panel_weapons_onlyowned_icon_maxscale = 1.5; float autocvar_hud_panel_weapons_timeout; int autocvar_hud_panel_weapons_timeout_effect; float autocvar_hud_panel_weapons_timeout_fadebgmin; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 81812ca20..b3cc1007a 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -539,21 +539,36 @@ void HUD_Weapons(void) weapon_size.y = padded_panel_size.y / rows; // reduce rows and columns as needed - // 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.x / padded_panel_size.y < aspect) { columns = ceil(weapon_count / 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); } else { rows = ceil(weapon_count / 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); + } + + // reduce cell size to match the desired aspect ratio + // NOTE: it doesn't reduce weapon icon size itself at all + // (assuming aspect ratio of the real weapon image == aspect) + if(weapon_size.x / weapon_size.y > aspect) + weapon_size.x = aspect * weapon_size.y; + else + weapon_size.y = weapon_size.x / aspect; + + float maxscale = autocvar_hud_panel_weapons_onlyowned_icon_maxscale; + if(maxscale == 0) + maxscale = 99; + if(maxscale > 1) + { + weapon_size.x = min(padded_panel_size.x / columns, weapon_size.x * maxscale); + weapon_size.y = min(padded_panel_size.y / rows, weapon_size.y * maxscale); + if(weapon_size.x / weapon_size.y > aspect) + weapon_size.x = aspect * weapon_size.y; + else + weapon_size.y = weapon_size.x / aspect; } // reduce size of the panel diff --git a/qcsrc/client/hud_config.qc b/qcsrc/client/hud_config.qc index 898f3eb56..fb3a42638 100644 --- a/qcsrc/client/hud_config.qc +++ b/qcsrc/client/hud_config.qc @@ -98,6 +98,7 @@ void HUD_Panel_ExportCfg(string cfgname) HUD_Write_PanelCvar_q("_timeout_speed_in"); HUD_Write_PanelCvar_q("_timeout_speed_out"); HUD_Write_PanelCvar_q("_onlyowned"); + HUD_Write_PanelCvar_q("onlyowned_icon_maxscale"); break; case HUD_PANEL_AMMO: HUD_Write_PanelCvar_q("_onlycurrent"); -- 2.39.2