From 45ffcb91f40f85ed1f8107d55621e4ffde994fb0 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Mon, 3 May 2021 03:19:08 +0100 Subject: [PATCH] Fix up r_showfields 3 a little, to make it easier to see which props are which. --- engine/client/sbar.c | 11 ++++++++--- engine/client/view.c | 8 +++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/engine/client/sbar.c b/engine/client/sbar.c index 558f6718..7f13db98 100644 --- a/engine/client/sbar.c +++ b/engine/client/sbar.c @@ -240,8 +240,13 @@ void Draw_FunStringWidthFont(struct font_s *font, float x, float y, const void * w = Font_Decode(w, &codeflags, &codepoint); fw += Font_CharWidth(codeflags, codepoint); } - if (rightalign == 2) - { + if (rightalign == 3) + { //center the text (ignoring width info) + px -= fw/2; + width = fw; + } + else if (rightalign == 2) + { //center the text (left align when too long) if (fw < width) { px += (width-fw)/2; @@ -249,7 +254,7 @@ void Draw_FunStringWidthFont(struct font_s *font, float x, float y, const void * } } else - { + { //right align the text if shorter than specified width.. px += width; if (fw > width) fw = width; diff --git a/engine/client/view.c b/engine/client/view.c index 901eba73..a78b8143 100644 --- a/engine/client/view.c +++ b/engine/client/view.c @@ -2051,7 +2051,7 @@ void R_DrawNameTags(void) if (body) { // Q_snprintfz(fname, sizeof(fname), ""); - str = va("^2%s^7\n%s%s\n{%s\n", fname, ruleset_allow_shaders.ival?"":CON_ERROR"WARNING: ruleset_allow_shaders disables external shaders"CON_DEFAULT"\n", surf->texinfo->texture->name, body); + str = va("^2%s^7\n%s%s\n{\n%s\n", fname, ruleset_allow_shaders.ival?"":CON_ERROR"WARNING: ruleset_allow_shaders disables external shaders"CON_DEFAULT"\n", surf->texinfo->texture->name, ((*body=='\n')?body+1:body)); Z_Free(body); } else @@ -2145,10 +2145,9 @@ void R_DrawNameTags(void) entstr = state->model->name; if (entstr) { - vec2_t scale = {8,8}; x = screenspace[0]*r_refdef.vrect.width+r_refdef.vrect.x; y = (1-screenspace[1])*r_refdef.vrect.height+r_refdef.vrect.y; - R_DrawTextField(x, y, vid.width - x, vid.height - y, entstr, CON_WHITEMASK, CPRINT_TALIGN, font_default, scale); + Draw_FunStringWidth(x, y, entstr, 0, 3, false); } } } @@ -2170,10 +2169,9 @@ void R_DrawNameTags(void) entstr = state->model->name; if (entstr) { - vec2_t scale = {8,8}; x = screenspace[0]*r_refdef.vrect.width+r_refdef.vrect.x; y = (1-screenspace[1])*r_refdef.vrect.height+r_refdef.vrect.y; - R_DrawTextField(x, y, vid.width - x, vid.height - y, entstr, CON_WHITEMASK, CPRINT_TALIGN, font_default, scale); + Draw_FunStringWidth(x, y, entstr, 0, 3, false); } } }