From ad33c9a79b11c8f1119f8928bf6f22d81bba2177 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 3 Dec 2011 00:06:26 +0100 Subject: [PATCH] Allow to change text alignment in the quick menu --- _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 | 21 ++++++++++++++----- qcsrc/client/hud_config.qc | 3 +++ .../menu/xonotic/dialog_hudpanel_quickmenu.c | 8 +++++++ 10 files changed, 34 insertions(+), 5 deletions(-) diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index c9ed70c51..08ecb6f65 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -297,3 +297,4 @@ seta hud_panel_quickmenu_bg_color_team "" "override panel color with team color seta hud_panel_quickmenu_bg_alpha "" "if set to something else than \"\" = override default panel background alpha" seta hud_panel_quickmenu_bg_border "" "if set to something else than \"\" = override default size of border around the background" seta hud_panel_quickmenu_bg_padding "" "if set to something else than \"\" = override default padding of contents from border" +seta hud_panel_quickmenu_align "text alignment: 0 left, 0.5 center, 1 right" diff --git a/hud_luminos.cfg b/hud_luminos.cfg index fc7edc5d6..a05b3bf03 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -291,5 +291,6 @@ seta hud_panel_quickmenu_bg_color_team "" seta hud_panel_quickmenu_bg_alpha "" seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" +seta hud_panel_quickmenu_align "0" menu_sync diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index cf1d8fc33..5900fdf87 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -291,5 +291,6 @@ seta hud_panel_quickmenu_bg_color_team "" seta hud_panel_quickmenu_bg_alpha "" seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" +seta hud_panel_quickmenu_align "0" menu_sync diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index 1e43ab80c..11ba6e4eb 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -291,5 +291,6 @@ seta hud_panel_quickmenu_bg_color_team "" seta hud_panel_quickmenu_bg_alpha "" seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" +seta hud_panel_quickmenu_align "0" menu_sync diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index de67dbb24..df9b804fd 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -291,5 +291,6 @@ seta hud_panel_quickmenu_bg_color_team "" seta hud_panel_quickmenu_bg_alpha "" seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" +seta hud_panel_quickmenu_align "1" menu_sync diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index 9652d43a0..88d380c87 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -291,5 +291,6 @@ seta hud_panel_quickmenu_bg_color_team "" seta hud_panel_quickmenu_bg_alpha "" seta hud_panel_quickmenu_bg_border "" seta hud_panel_quickmenu_bg_padding "" +seta hud_panel_quickmenu_align "0" menu_sync diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 1325c6324..b7f96375c 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -320,6 +320,7 @@ float autocvar_hud_panel_weapons_onlyowned; float autocvar_hud_panel_weapons_timeout; float autocvar_hud_panel_weapons_timeout_effect; float autocvar_hud_panel_quickmenu; +float autocvar_hud_panel_quickmenu_align; float autocvar_hud_progressbar_alpha; float autocvar_hud_showbinds; float autocvar_hud_showbinds_limit; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index ec2bb8257..a665ca553 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -5112,6 +5112,19 @@ void HUD_Panel_QuickMenu_Mouse() const vector cursorsize = '32 32 0'; drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', 0.8, DRAWFLAG_NORMAL); } +void HUD_QuickMenu_DrawEntry(vector pos, string s, vector fontsize) +{ + string entry; + float offset; + entry = textShortenToWidth(s, panel_size_x, fontsize, stringwidth_colors); + if (autocvar_hud_panel_quickmenu_align > 0) + { + offset = (panel_size_x - stringwidth_colors(entry, fontsize)) * min(autocvar_hud_panel_quickmenu_align, 1); + drawcolorcodedstring(pos + eX * offset, entry, fontsize, 1, DRAWFLAG_ADDITIVE); + } + else + drawcolorcodedstring(pos + eY * (panel_size_y - fontsize_y), entry, fontsize, 1, DRAWFLAG_ADDITIVE); +} void HUD_QuickMenu(void) { if(!autocvar__hud_configure) @@ -5150,14 +5163,13 @@ void HUD_QuickMenu(void) float i; vector fontsize; - string entry, color; + string color; fontsize = '1 1 0' * (panel_size_y / QUICKMENU_MAXLINES); if (!QuickMenu_IsLastPage) { color = "^5"; - entry = textShortenToWidth(sprintf("%d: %s%s", 0, color, _("Continue...")), panel_size_x, fontsize, stringwidth_colors); - drawcolorcodedstring(panel_pos + eY * (panel_size_y - fontsize_y), entry, fontsize, 1, DRAWFLAG_ADDITIVE); + HUD_QuickMenu_DrawEntry(panel_pos + eY * (panel_size_y - fontsize_y), sprintf("%d: %s%s", 0, color, _("Continue...")), fontsize); } else panel_pos_y += ((QUICKMENU_MAXLINES - QuickMenu_Entries) * fontsize_y) / 2; @@ -5169,8 +5181,7 @@ void HUD_QuickMenu(void) color = "^4"; else color = "^3"; - entry = textShortenToWidth(sprintf("%d: %s%s", i, color, QuickMenu_Description[i]), panel_size_x, fontsize, stringwidth_colors); - drawcolorcodedstring(panel_pos, entry, fontsize, 1, DRAWFLAG_ADDITIVE); + HUD_QuickMenu_DrawEntry(panel_pos, sprintf("%d: %s%s", i, color, QuickMenu_Description[i]), fontsize); panel_pos_y += fontsize_y; } } diff --git a/qcsrc/client/hud_config.qc b/qcsrc/client/hud_config.qc index 18ff119a7..6399dde2e 100644 --- a/qcsrc/client/hud_config.qc +++ b/qcsrc/client/hud_config.qc @@ -177,6 +177,9 @@ void HUD_Panel_ExportCfg(string cfgname) HUD_Write_PanelCvar_q("_fade_subsequent_minfontsize"); HUD_Write_PanelCvar_q("_fade_minfontsize"); break; + case HUD_PANEL_QUICKMENU: + HUD_Write_PanelCvar_q("_align"); + break; } HUD_Write("\n"); } diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_quickmenu.c b/qcsrc/menu/xonotic/dialog_hudpanel_quickmenu.c index f9527d423..4aed758a5 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_quickmenu.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_quickmenu.c @@ -17,5 +17,13 @@ void XonoticHUDQuickMenuDialog_fill(entity me) string panelname = "quickmenu"; DIALOG_HUDPANEL_COMMON(); + + me.TR(me); + me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("Text alignment:"))); + me.TR(me); + me.TDempty(me, 0.2); + me.TD(me, 1, 3.8/3, e = makeXonoticRadioButton(3, "hud_panel_quickmenu_align", "0", _("Left"))); + me.TD(me, 1, 3.8/3, e = makeXonoticRadioButton(3, "hud_panel_quickmenu_align", "0.5", _("Center"))); + me.TD(me, 1, 3.8/3, e = makeXonoticRadioButton(3, "hud_panel_quickmenu_align", "1", _("Right"))); } #endif -- 2.39.2