Menus/Challenges: optimize drawing by caching unturned tile graphics once

This commit is contained in:
James R 2024-01-04 01:37:01 -08:00
parent 3f58a01774
commit 9eb1f1403e
3 changed files with 24 additions and 8 deletions

View file

@ -1344,6 +1344,8 @@ extern struct challengesmenu_s {
UINT8 fade;
boolean cache_secondrowlocked;
patch_t *tile_category[10][2];
} challengesmenu;
menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu);

View file

@ -6031,16 +6031,10 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili
categoryid = '9';
break;
}
pat = W_CachePatchName(va("UN_RR0%c%c",
categoryid,
(ref->majorunlock) ? 'B' : 'A'),
PU_CACHE);
pat = challengesmenu.tile_category[categoryid - '0'][ref->majorunlock ? 1 : 0];
if (pat == missingpat)
{
pat = W_CachePatchName(va("UN_RR0%c%c",
categoryid,
(ref->majorunlock) ? 'A' : 'B'),
PU_CACHE);
pat = challengesmenu.tile_category[categoryid - '0'][ref->majorunlock ? 0 : 1];
}
}
else if (ref->icon != NULL && ref->icon[0])

View file

@ -289,6 +289,24 @@ static void M_ChallengesAutoFocus(UINT16 unlockid, boolean fresh)
}
}
static void M_CacheChallengeTiles(void)
{
char name[9] = "UN_RR0xy";
int i;
for (i = 0; i < 10; ++i)
{
name[6] = '0' + i;
name[7] = 'A';
challengesmenu.tile_category[i][0] = W_CachePatchName(name, PU_CACHE);
name[7] = 'B';
challengesmenu.tile_category[i][1] = W_CachePatchName(name, PU_CACHE);
}
}
menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
{
UINT16 newunlock;
@ -338,6 +356,8 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
&& (gamedata->chaokeys < GDMAX_CHAOKEYS))
challengesmenu.chaokeyadd = true;
M_CacheChallengeTiles();
return &MISC_ChallengesDef;
}