Merge branch 'extra-emblem-display' into 'next'

Extra emblem hint display

See merge request STJr/SRB2!721
This commit is contained in:
James R 2020-02-17 00:00:36 -05:00
commit 8e4cb953c8

View file

@ -231,6 +231,8 @@ static void M_Credits(INT32 choice);
static void M_SoundTest(INT32 choice); static void M_SoundTest(INT32 choice);
static void M_PandorasBox(INT32 choice); static void M_PandorasBox(INT32 choice);
static void M_EmblemHints(INT32 choice); static void M_EmblemHints(INT32 choice);
static void M_HandleEmblemHints(INT32 choice);
UINT32 hintpage = 1;
static void M_HandleChecklist(INT32 choice); static void M_HandleChecklist(INT32 choice);
menu_t SR_MainDef, SR_UnlockChecklistDef; menu_t SR_MainDef, SR_UnlockChecklistDef;
@ -727,8 +729,9 @@ static menuitem_t SR_SoundTestMenu[] =
static menuitem_t SR_EmblemHintMenu[] = static menuitem_t SR_EmblemHintMenu[] =
{ {
{IT_STRING|IT_CVAR, NULL, "Emblem Radar", &cv_itemfinder, 10}, {IT_STRING | IT_ARROWS, NULL, "Page", M_HandleEmblemHints, 10},
{IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SPauseDef, 20} {IT_STRING|IT_CVAR, NULL, "Emblem Radar", &cv_itemfinder, 20},
{IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SPauseDef, 30}
}; };
// -------------------------------- // --------------------------------
@ -7234,18 +7237,33 @@ finishchecklist:
} }
#define NUMHINTS 5 #define NUMHINTS 5
static void M_EmblemHints(INT32 choice) static void M_EmblemHints(INT32 choice)
{ {
INT32 i;
UINT32 local = 0;
emblem_t *emblem;
for (i = 0; i < numemblems; i++)
{
emblem = &emblemlocations[i];
if (emblem->level != gamemap || emblem->type > ET_SKIN)
continue;
if (++local > NUMHINTS*2)
break;
}
(void)choice; (void)choice;
SR_EmblemHintMenu[0].status = (M_SecretUnlocked(SECRET_ITEMFINDER)) ? (IT_CVAR|IT_STRING) : (IT_SECRET); SR_EmblemHintMenu[0].status = (local > NUMHINTS*2) ? (IT_STRING | IT_ARROWS) : (IT_DISABLED);
SR_EmblemHintMenu[1].status = (M_SecretUnlocked(SECRET_ITEMFINDER)) ? (IT_CVAR|IT_STRING) : (IT_SECRET);
hintpage = 1;
M_SetupNextMenu(&SR_EmblemHintDef); M_SetupNextMenu(&SR_EmblemHintDef);
itemOn = 1; // always start on back. itemOn = 2; // always start on back.
} }
static void M_DrawEmblemHints(void) static void M_DrawEmblemHints(void)
{ {
INT32 i, j = 0, x, y, left_hints = NUMHINTS; INT32 i, j = 0, x, y, left_hints = NUMHINTS, pageflag = 0;
UINT32 collected = 0, local = 0; UINT32 collected = 0, totalemblems = 0, local = 0;
emblem_t *emblem; emblem_t *emblem;
const char *hint; const char *hint;
@ -7254,17 +7272,34 @@ static void M_DrawEmblemHints(void)
emblem = &emblemlocations[i]; emblem = &emblemlocations[i];
if (emblem->level != gamemap || emblem->type > ET_SKIN) if (emblem->level != gamemap || emblem->type > ET_SKIN)
continue; continue;
if (++local >= NUMHINTS*2)
break; local++;
} }
x = (local > NUMHINTS ? 4 : 12); x = (local > NUMHINTS ? 4 : 12);
y = 8; y = 8;
// If there are more than 1 page's but less than 2 pages' worth of emblems, if (local > NUMHINTS){
if (local > ((hintpage-1)*NUMHINTS*2) && local < ((hintpage)*NUMHINTS*2)){
if (NUMHINTS % 2 == 1)
left_hints = (local - ((hintpage-1)*NUMHINTS*2) + 1) / 2;
else
left_hints = (local - ((hintpage-1)*NUMHINTS*2)) / 2;
}else{
left_hints = NUMHINTS;
}
}
if (local > NUMHINTS*2){
if (itemOn == 0){
pageflag = V_YELLOWMAP;
}
V_DrawString(currentMenu->x + 40, currentMenu->y + 10, pageflag, va("%d of %d",hintpage, local/(NUMHINTS*2) + 1));
}
// If there are more than 1 page's but less than 2 pages' worth of emblems on the last possible page,
// put half (rounded up) of the hints on the left, and half (rounded down) on the right // put half (rounded up) of the hints on the left, and half (rounded down) on the right
if (local > NUMHINTS && local < (NUMHINTS*2)-1)
left_hints = (local + 1) / 2;
if (!local) if (!local)
V_DrawCenteredString(160, 48, V_YELLOWMAP, "No hidden emblems on this map."); V_DrawCenteredString(160, 48, V_YELLOWMAP, "No hidden emblems on this map.");
@ -7274,6 +7309,10 @@ static void M_DrawEmblemHints(void)
if (emblem->level != gamemap || emblem->type > ET_SKIN) if (emblem->level != gamemap || emblem->type > ET_SKIN)
continue; continue;
totalemblems++;
if (totalemblems >= ((hintpage-1)*(NUMHINTS*2) + 1) && totalemblems < (hintpage*NUMHINTS*2)+1){
if (emblem->collected) if (emblem->collected)
{ {
collected = V_GREENMAP; collected = V_GREENMAP;
@ -7291,6 +7330,7 @@ static void M_DrawEmblemHints(void)
else else
hint = M_GetText("No hint available for this emblem."); hint = M_GetText("No hint available for this emblem.");
hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint); hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint);
//always draw tiny if we have more than NUMHINTS*2, visually more appealing
if (local > NUMHINTS) if (local > NUMHINTS)
V_DrawThinString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); V_DrawThinString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint);
else else
@ -7298,6 +7338,9 @@ static void M_DrawEmblemHints(void)
y += 28; y += 28;
// If there are more than 1 page's but less than 2 pages' worth of emblems on the last possible page,
// put half (rounded up) of the hints on the left, and half (rounded down) on the right
if (++j == left_hints) if (++j == left_hints)
{ {
x = 4+(BASEVIDWIDTH/2); x = 4+(BASEVIDWIDTH/2);
@ -7306,10 +7349,40 @@ static void M_DrawEmblemHints(void)
else if (j >= NUMHINTS*2) else if (j >= NUMHINTS*2)
break; break;
} }
}
M_DrawGenericMenu(); M_DrawGenericMenu();
} }
static void M_HandleEmblemHints(INT32 choice)
{
INT32 i;
emblem_t *emblem;
UINT32 stageemblems = 0;
for (i = 0; i < numemblems; i++)
{
emblem = &emblemlocations[i];
if (emblem->level != gamemap || emblem->type > ET_SKIN)
continue;
stageemblems++;
}
if (choice == 0){
if (hintpage > 1){
hintpage--;
}
}else{
if (hintpage < ((stageemblems-1)/(NUMHINTS*2) + 1)){
hintpage++;
}
}
}
/*static void M_DrawSkyRoom(void) /*static void M_DrawSkyRoom(void)
{ {
INT32 i, y = 0; INT32 i, y = 0;