Merge branch 'fix-button-offsets' into 'master'

Fix offsets for buttons in text drawing

See merge request KartKrew/Kart!2093
This commit is contained in:
James R. 2024-03-13 08:24:55 +00:00
commit 269b6d8469
3 changed files with 22 additions and 11 deletions

View file

@ -5229,7 +5229,7 @@ void M_DrawProfileControls(void)
boolean standardbuttons = gamedata->gonerlevel > GDGONER_PROFILE; boolean standardbuttons = gamedata->gonerlevel > GDGONER_PROFILE;
INT32 xpos = BASEVIDWIDTH - 12; INT32 xpos = BASEVIDWIDTH - 12;
xpos = standardbuttons ? xpos = standardbuttons ?
M_DrawProfileLegend(xpos, ypos, "\xB2/ \xBC Clear", NULL) : M_DrawProfileLegend(xpos, ypos, "\xB2 / \xBC Clear", NULL) :
M_DrawProfileLegend(xpos, ypos, "Clear", "BKSP"); M_DrawProfileLegend(xpos, ypos, "Clear", "BKSP");
} }

View file

@ -1472,7 +1472,7 @@ void ST_DrawSaveReplayHint(INT32 flags)
V_DrawRightAlignedThinString( V_DrawRightAlignedThinString(
BASEVIDWIDTH - 2, 2, BASEVIDWIDTH - 2, 2,
flags|V_YELLOWMAP, flags|V_YELLOWMAP,
demo.willsave ? "Replay will be saved. \xAB" "Change title" : "\xAB" "or " "\xAE" "Save replay" demo.willsave ? "Replay will be saved. \xAB Change title" : "\xAB or \xAE Save replay"
); );
} }

View file

@ -2251,6 +2251,7 @@ typedef struct
fixed_t spacew; fixed_t spacew;
fixed_t lfh; fixed_t lfh;
fixed_t (*dim_fn)(fixed_t,fixed_t,INT32,INT32,fixed_t *); fixed_t (*dim_fn)(fixed_t,fixed_t,INT32,INT32,fixed_t *);
UINT8 button_yofs;
} fontspec_t; } fontspec_t;
static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result) static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result)
@ -2262,6 +2263,7 @@ static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result)
// All other properties are guaranteed to be set // All other properties are guaranteed to be set
result->chw = 0; result->chw = 0;
result->button_yofs = 0;
const INT32 spacing = ( flags & V_SPACINGMASK ); const INT32 spacing = ( flags & V_SPACINGMASK );
@ -2450,6 +2452,16 @@ static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result)
result->dim_fn = BunchedCharacterDim; result->dim_fn = BunchedCharacterDim;
break; break;
} }
switch (fontno)
{
case HU_FONT:
result->button_yofs = 2;
break;
case MENU_FONT:
result->button_yofs = 1;
break;
}
} }
static UINT8 V_GetButtonCodeWidth(UINT8 c) static UINT8 V_GetButtonCodeWidth(UINT8 c)
@ -2484,7 +2496,7 @@ static UINT8 V_GetButtonCodeWidth(UINT8 c)
break; break;
} }
return x + 2; return x;
} }
void V_DrawStringScaled( void V_DrawStringScaled(
@ -2668,8 +2680,8 @@ void V_DrawStringScaled(
case 0x02: return {{0, 3, Draw::Button::right}}; case 0x02: return {{0, 3, Draw::Button::right}};
case 0x03: return {{0, 3, Draw::Button::left}}; case 0x03: return {{0, 3, Draw::Button::left}};
case 0x07: return {{0, 1, Draw::Button::r}}; case 0x07: return {{0, 2, Draw::Button::r}};
case 0x08: return {{0, 1, Draw::Button::l}}; case 0x08: return {{0, 2, Draw::Button::l}};
case 0x09: return {{0, 1, Draw::Button::start}}; case 0x09: return {{0, 1, Draw::Button::start}};
@ -2698,16 +2710,15 @@ void V_DrawStringScaled(
} }
}; };
cw = V_GetButtonCodeWidth(c) * dupx;
cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw);
Draw( Draw(
FixedToFloat(cx) - (bt_inst->x * dupx), FixedToFloat(cx + cxoff) - (bt_inst->x * dupx),
FixedToFloat(cy + cyoff) - (bt_inst->y * dupy)) FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy))
.flags(flags) .flags(flags)
.small_button(bt_inst->type, bt_translate_press()); .small_button(bt_inst->type, bt_translate_press());
cx += cw;
} }
cw = V_GetButtonCodeWidth(c) * dupx;
cx += cw * scale;
break; break;
} }