From 5c6da2965708a99b8fb7df1cabf57b6143edbab3 Mon Sep 17 00:00:00 2001 From: Anonimus Date: Sun, 21 Sep 2025 17:46:24 -0400 Subject: [PATCH] Auto-center ALL rank and minimap patches, make offsets relative to center The current system ended up loading to a lot of visual jank with certain addon characters Most if not all vanilla characters have null offsets, and the edgecase icons should not necessitate using absolute offsets --- src/r_defs.h | 1 + src/st_stuff.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/r_defs.h b/src/r_defs.h index 8911e3b85..b75540c32 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -913,6 +913,7 @@ struct patch_t { INT16 width, height; INT16 leftoffset, topoffset; + UINT8 autocentered; // Automatically centered for certain VFX INT32 *columnofs; // Column offsets. This is relative to patch->columns UINT8 *columns; // Software column data diff --git a/src/st_stuff.c b/src/st_stuff.c index 0704e39df..7f6c7f4c1 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -198,34 +198,50 @@ static boolean ST_IconCanSpinout(UINT8 icon) // made separate so that skins code can reload custom face graphics void ST_LoadFaceGraphics(INT32 skinnum) { -#define FACE_MAX (FACE_MINIMAP+1) - spritedef_t *sprdef = &skins[skinnum].sprites[SPR2_XTRA]; - spriteframe_t *sprframe; +#define FACE_MAX (FACE_MINIMAP + 1) + spritedef_t* sprdef = &skins[skinnum].sprites[SPR2_XTRA]; + spriteframe_t* sprframe; UINT8 i = 0, maxer = min(sprdef->numframes, FACE_MAX); + INT16 baseleftoffs, basetopoffs; + boolean alreadycentered = false; while (i < maxer) { + // Reset "base" offsets. + baseleftoffs = basetopoffs = 0; + sprframe = &sprdef->spriteframes[i]; faceprefix[skinnum][i] = W_CachePatchNum(sprframe->lumppat[0], PU_HUDGFX); - if (ST_IconCanSpinout(i)) + alreadycentered = (boolean)faceprefix[skinnum][i]->autocentered; + + if ((ST_IconCanSpinout(i)) && (!alreadycentered)) { - // Auto-center all minimap and rank patches with no offsets defined. - // This is a shitty, hacky solution... but it's less work for spinout rotations! - if (faceprefix[skinnum][i]->leftoffset == 0) + // Auto-center all minimap and rank patches with the ability to spinout. + // This is a shitty, hacky solution... but it's less work for spinout + // rotations! + if ((!baseleftoffs) && (faceprefix[skinnum][i]->leftoffset)) { - faceprefix[skinnum][i]->leftoffset = faceprefix[skinnum][i]->width / 2; + baseleftoffs = faceprefix[skinnum][i]->leftoffset; } - if (faceprefix[skinnum][i]->topoffset == 0) + if ((!basetopoffs) && (faceprefix[skinnum][i]->topoffset)) { - faceprefix[skinnum][i]->topoffset = faceprefix[skinnum][i]->height / 2; + basetopoffs = faceprefix[skinnum][i]->topoffset; } + + faceprefix[skinnum][i]->leftoffset = + (faceprefix[skinnum][i]->width / 2) + baseleftoffs; + faceprefix[skinnum][i]->topoffset = + (faceprefix[skinnum][i]->height / 2) + basetopoffs; + + // We're centered; don't do this operation again. + faceprefix[skinnum][i]->autocentered = 1; } i++; } if (i < FACE_MAX) { - patch_t *missing = W_CachePatchName("MISSING", PU_HUDGFX); + patch_t* missing = W_CachePatchName("MISSING", PU_HUDGFX); while (i < FACE_MAX) { faceprefix[skinnum][i] = missing;