]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Better alignment of quickmenu entries with checkboxes
authorterencehill <piuntn@gmail.com>
Thu, 4 Jun 2015 17:11:46 +0000 (19:11 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 4 Jun 2015 17:11:46 +0000 (19:11 +0200)
qcsrc/client/quickmenu.qc

index 5c4e4dad00d59020811649c7e1482ee6728eec37..d769902b042aa246fde757455feeaf7c990b53eb 100644 (file)
@@ -541,7 +541,18 @@ void HUD_Quickmenu_DrawEntry(vector pos, string desc, string option, vector font
        entry = textShortenToWidth(desc, desc_width, fontsize, stringwidth_colors);
        if (autocvar_hud_panel_quickmenu_align > 0)
        {
-               offset = (desc_width - stringwidth_colors(entry, fontsize)) * min(autocvar_hud_panel_quickmenu_align, 1);
+               float real_desc_width = stringwidth_colors(entry, fontsize);
+               offset = (desc_width - real_desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
+
+               if(option)
+               {
+                       // when there's enough room align description regardless the checkbox
+                       float extra_offset = (panel_size.x - desc_width) * min(autocvar_hud_panel_quickmenu_align, 1);
+                       if(offset + real_desc_width + extra_offset < desc_width)
+                               offset += extra_offset;
+                       else
+                               offset = max(0, desc_width - real_desc_width);
+               }
                drawcolorcodedstring(pos + eX * offset, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
        }
        else