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
This commit is contained in:
Anonimus 2025-09-21 17:46:24 -04:00
parent 0b1f458fb9
commit 5c6da29657
2 changed files with 28 additions and 11 deletions

View file

@ -913,6 +913,7 @@ struct patch_t
{ {
INT16 width, height; INT16 width, height;
INT16 leftoffset, topoffset; INT16 leftoffset, topoffset;
UINT8 autocentered; // Automatically centered for certain VFX
INT32 *columnofs; // Column offsets. This is relative to patch->columns INT32 *columnofs; // Column offsets. This is relative to patch->columns
UINT8 *columns; // Software column data UINT8 *columns; // Software column data

View file

@ -198,34 +198,50 @@ static boolean ST_IconCanSpinout(UINT8 icon)
// made separate so that skins code can reload custom face graphics // made separate so that skins code can reload custom face graphics
void ST_LoadFaceGraphics(INT32 skinnum) void ST_LoadFaceGraphics(INT32 skinnum)
{ {
#define FACE_MAX (FACE_MINIMAP+1) #define FACE_MAX (FACE_MINIMAP + 1)
spritedef_t *sprdef = &skins[skinnum].sprites[SPR2_XTRA]; spritedef_t* sprdef = &skins[skinnum].sprites[SPR2_XTRA];
spriteframe_t *sprframe; spriteframe_t* sprframe;
UINT8 i = 0, maxer = min(sprdef->numframes, FACE_MAX); UINT8 i = 0, maxer = min(sprdef->numframes, FACE_MAX);
INT16 baseleftoffs, basetopoffs;
boolean alreadycentered = false;
while (i < maxer) while (i < maxer)
{ {
// Reset "base" offsets.
baseleftoffs = basetopoffs = 0;
sprframe = &sprdef->spriteframes[i]; sprframe = &sprdef->spriteframes[i];
faceprefix[skinnum][i] = W_CachePatchNum(sprframe->lumppat[0], PU_HUDGFX); 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. // 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! // This is a shitty, hacky solution... but it's less work for spinout
if (faceprefix[skinnum][i]->leftoffset == 0) // 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++; i++;
} }
if (i < FACE_MAX) if (i < FACE_MAX)
{ {
patch_t *missing = W_CachePatchName("MISSING", PU_HUDGFX); patch_t* missing = W_CachePatchName("MISSING", PU_HUDGFX);
while (i < FACE_MAX) while (i < FACE_MAX)
{ {
faceprefix[skinnum][i] = missing; faceprefix[skinnum][i] = missing;