From c5566d7092e4719f8fb729d25cbc04055ddd1d6f Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 15 Jul 2015 15:33:59 +0200 Subject: [PATCH] Make map voting screen more compact when possible (hard size limit is now applied to the table cell rather than to the items within the cell) Signed-off-by: terencehill --- qcsrc/client/mapvoting.qc | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index 35c250882..1350b154e 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -87,13 +87,6 @@ void GameTypeVote_DrawGameTypeItem(vector pos, float maxh, float tsize, string g else alpha = 1; // Normal, full alpha - float maxheight = vid_conheight / 5; - if(maxh > maxheight) - { - pos.y += (maxh - maxheight) / 2; - maxh = maxheight; - } - // Bounding box details float rect_margin = hud_fontsize.y / 2; @@ -211,7 +204,6 @@ void MapVote_DrawMapItem(vector pos, float isize, float tsize, string map, strin float img_ar = 4/3; img_size.x = min(tsize, isize * img_ar); - img_size.x = min(img_size.x, vid_conwidth / 6); img_size.y = img_size.x / img_ar; img_size.y -= hud_fontsize.y - autocvar_scoreboard_border_thickness * 2; img_size.x = img_size.y * img_ar; @@ -391,6 +383,35 @@ void MapVote_Draw() dist.x = (xmax - xmin) / mv_columns; dist.y = (ymax - pos.y) / rows; + // reduce size of too wide items + tmp = vid_conwidth / 3; // max width + if(dist.x > tmp) + { + dist.x = tmp; + dist.y = min(dist.y, dist.x / item_aspect); + } + tmp = vid_conheight / 3; // max height + if(dist.y > tmp) + { + dist.y = tmp; + dist.x = min(dist.x, dist.y * item_aspect); + } + + // reduce size to fix aspect ratio + if(dist.x / dist.y > item_aspect) + dist.x = dist.y * item_aspect; + else + dist.y = dist.x / item_aspect; + + // adjust table pos and size according to the new size + float offset; + offset = ((xmax - pos.x) - dist.x * mv_columns) / 2; + xmin = pos.x += offset; + xmax -= offset; + offset = ((ymax - pos.y) - dist.y * rows) / 2; + ymin = pos.y += offset; + ymax -= offset; + tsize = dist.x; isize = dist.y; -- 2.39.2