introduce HUlib_drawTextLineAt() and use it consistently for w_monsec and w_sttime (#879)

Draw to temporary position instead of changing widget coordinates back and forth.
This commit is contained in:
Fabian Greffrath 2023-01-27 09:09:47 +01:00 committed by GitHub
parent 0b65b314e9
commit c2401c33ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 38 deletions

View File

@ -139,7 +139,12 @@ boolean HUlib_delCharFromTextLine(hu_textline_t* t)
void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor)
{
int i, x = l->x, y = l->y; // killough 1/18/98 -- support multiple lines
HUlib_drawTextLineAt(l, l->x, l->y, drawcursor);
}
void HUlib_drawTextLineAt(hu_textline_t *l, int x, int y, boolean drawcursor)
{
int i; // killough 1/18/98 -- support multiple lines
unsigned char c;
char *oc = l->cr; //jff 2/17/98 remember default color

View File

@ -157,6 +157,7 @@ boolean HUlib_delCharFromTextLine(hu_textline_t *t);
// draws tline
void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor);
void HUlib_drawTextLineAt(hu_textline_t *l, int x, int y, boolean drawcursor);
// erases text line
void HUlib_eraseTextLine(hu_textline_t *l);

View File

@ -831,31 +831,6 @@ void HU_MoveHud(void)
{
static int ohud_distributed=-1;
// [FG] draw Time widget on intermission screen
if (gamestate == GS_INTERMISSION)
{
w_sttime.x = HU_TITLEX;
w_sttime.y = 0;
ohud_distributed = -1;
return;
}
// [FG] draw Time/STS widgets above status bar
if (scaledviewheight < SCREENHEIGHT || crispy_hud)
{
// adjust Time widget if set to Time only
short t_offset = (hud_timests == 1) ? 1 : 2;
w_sttime.x = HU_TITLEX;
w_sttime.y = ST_Y - t_offset*HU_GAPY;
w_monsec.x = HU_TITLEX;
w_monsec.y = ST_Y - HU_GAPY;
ohud_distributed = -1;
return;
}
//jff 3/4/98 move displays around on F5 changing hud_distributed
if (hud_distributed!=ohud_distributed)
{
@ -1260,19 +1235,27 @@ void HU_Drawer(void)
automap_off
)
{
HU_MoveHud(); // insure HUD display coords are correct
// prefer Crispy HUD over Boom HUD
if (crispy_hud)
{
// adjust Time widget if set to Time only
short y = ST_Y - HU_GAPY;
ST_Drawer (false, true);
if (hud_timests & HU_STTIME)
HUlib_drawTextLine(&w_sttime, false);
if (hud_timests & HU_STSTATS)
HUlib_drawTextLine(&w_monsec, false);
{
HUlib_drawTextLineAt(&w_monsec, HU_HUDX, y, false);
y -= HU_GAPY;
}
if (hud_timests & HU_STTIME)
{
HUlib_drawTextLineAt(&w_sttime, HU_HUDX, y, false);
}
}
else // [FG] ~440 lines below
{
HU_MoveHud(); // insure HUD display coords are correct
// do the hud ammo display
// clear the widgets internal line
HUlib_clearTextLine(&w_ammo);
@ -1713,12 +1696,19 @@ void HU_Drawer(void)
scaledviewheight < SCREENHEIGHT &&
automap_off)
{
// insure HUD display coords are correct
HU_MoveHud();
if (hud_timests & HU_STTIME)
HUlib_drawTextLine(&w_sttime, false);
// adjust Time widget if set to Time only
short y = ST_Y - HU_GAPY;
ST_Drawer (false, true);
if (hud_timests & HU_STSTATS)
HUlib_drawTextLine(&w_monsec, false);
{
HUlib_drawTextLineAt(&w_monsec, HU_HUDX, y, false);
y -= HU_GAPY;
}
if (hud_timests & HU_STTIME)
{
HUlib_drawTextLineAt(&w_sttime, HU_HUDX, y, false);
}
}
//jff 3/4/98 display last to give priority
@ -1743,10 +1733,9 @@ void WI_DrawTimeWidget(void)
{
if (hud_timests & HU_STTIME)
{
HU_MoveHud();
// leveltime is already added to totalleveltimes before WI_Start()
//HU_widget_build_sttime();
HUlib_drawTextLine(&w_sttime, false);
HUlib_drawTextLineAt(&w_sttime, HU_HUDX, 0, false);
}
}