From bcf0df7cb62c09a3e112ee0eaa9fdeb34d620c9b Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sun, 23 Apr 2017 00:16:09 +0100 Subject: [PATCH] Ended up being stressed and not getting any real work done, so figured I'd finish up the checklist system. --- src/dehacked.c | 1 + src/m_cond.c | 34 ++++----- src/m_menu.c | 194 +++++++++++++++++++++++++++++++++++-------------- 3 files changed, 158 insertions(+), 71 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8563fef95..e91f168e0 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2469,6 +2469,7 @@ static void readunlockable(MYFILE *f, INT32 num) DEH_WriteUndoline("VAR", va("%d", unlockables[num].variable), UNDO_NONE); memset(&unlockables[num], 0, sizeof(unlockable_t)); + unlockables[num].objective[0] = '/'; do { diff --git a/src/m_cond.c b/src/m_cond.c index f12e677dc..b7735d4ce 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -573,31 +573,31 @@ extraemblem_t extraemblems[MAXEXTRAEMBLEMS] = unlockable_t unlockables[MAXUNLOCKABLES] = { // Name, Objective, Menu Height, ConditionSet, Unlock Type, Variable, NoCecho, NoChecklist - /* 01 */ {"Record Attack", "Complete Greenflower Zone, Act 1", 0, 1, SECRET_RECORDATTACK, 0, true, true, 0}, - /* 02 */ {"NiGHTS Mode", "Complete Floral Field", 0, 2, SECRET_NIGHTSMODE, 0, true, true, 0}, + /* 01 */ {"Record Attack", "/", 0, 1, SECRET_RECORDATTACK, 0, true, true, 0}, + /* 02 */ {"NiGHTS Mode", "/", 0, 2, SECRET_NIGHTSMODE, 0, true, true, 0}, - /* 03 */ {"Play Credits", "Complete 1P Mode", 30, 10, SECRET_CREDITS, 0, true, true, 0}, - /* 04 */ {"Sound Test", "Complete 1P Mode", 40, 10, SECRET_SOUNDTEST, 0, false, false, 0}, + /* 03 */ {"Play Credits", "/", 30, 10, SECRET_CREDITS, 0, true, true, 0}, + /* 04 */ {"Sound Test", "/", 40, 10, SECRET_SOUNDTEST, 0, false, false, 0}, - /* 05 */ {"EXTRA LEVELS", "", 58, 0, SECRET_HEADER, 0, true, true, 0}, + /* 05 */ {"EXTRA LEVELS", "/", 58, 0, SECRET_HEADER, 0, true, true, 0}, - /* 06 */ {"Aerial Garden Zone", "Complete 1P Mode w/ all emeralds", 70, 11, SECRET_WARP, 40, false, false, 0}, - /* 07 */ {"Azure Temple Zone", "Complete Aerial Garden Zone", 80, 20, SECRET_WARP, 41, false, false, 0}, + /* 06 */ {"Aerial Garden Zone", "/", 70, 11, SECRET_WARP, 40, false, false, 0}, + /* 07 */ {"Azure Temple Zone", "/", 80, 20, SECRET_WARP, 41, false, false, 0}, - /* 08 */ {"BONUS LEVELS", "", 98, 0, SECRET_HEADER, 0, true, true, 0}, + /* 08 */ {"BONUS LEVELS", "/", 98, 0, SECRET_HEADER, 0, true, true, 0}, - /* 09 */ {"PLACEHOLDER", "PLACEHOLDER", 0, 0, SECRET_NONE, 0, true, true, 0}, - /* 10 */ {"Mario Koopa Blast", "Collect 60 Emblems", 110, 42, SECRET_WARP, 30, false, false, 0}, - /* 11 */ {"PLACEHOLDER", "PLACEHOLDER", 0, 0, SECRET_NONE, 0, true, true, 0}, + /* 09 */ {"PLACEHOLDER", "/", 0, 0, SECRET_NONE, 0, true, true, 0}, + /* 10 */ {"Mario Koopa Blast", "/", 110, 42, SECRET_WARP, 30, false, false, 0}, + /* 11 */ {"PLACEHOLDER", "/", 0, 0, SECRET_NONE, 0, true, true, 0}, - /* 12 */ {"Spring Hill Zone", "Collect 100 Emblems", 0, 44, SECRET_NONE, 0, false, false, 0}, - /* 13 */ {"Black Hole", "A Rank in all Special Stages", 0, 50, SECRET_NONE, 0, false, true, 0}, + /* 12 */ {"Spring Hill Zone", "/", 0, 44, SECRET_NONE, 0, false, false, 0}, + /* 13 */ {"Black Hole", "Get grade A in all Special Stages", 0, 50, SECRET_NONE, 0, false, true, 0}, - /* 14 */ {"Emblem Hints", "Collect 40 Emblems", 0, 41, SECRET_EMBLEMHINTS, 0, false, true, 0}, - /* 15 */ {"Emblem Radar", "Collect 80 Emblems", 0, 43, SECRET_ITEMFINDER, 0, false, true, 0}, + /* 14 */ {"Emblem Hints", "/", 0, 41, SECRET_EMBLEMHINTS, 0, false, true, 0}, + /* 15 */ {"Emblem Radar", "/", 0, 43, SECRET_ITEMFINDER, 0, false, true, 0}, - /* 16 */ {"Pandora's Box", "Collect All Emblems", 0, 45, SECRET_PANDORA, 0, false, false, 0}, - /* 17 */ {"Level Select", "Collect All Emblems", 20, 45, SECRET_LEVELSELECT, 1, false, true, 0}, + /* 16 */ {"Pandora's Box", "/", 0, 45, SECRET_PANDORA, 0, false, false, 0}, + /* 17 */ {"Level Select", "/", 20, 45, SECRET_LEVELSELECT, 1, false, true, 0}, }; // Default number of emblems and extra emblems diff --git a/src/m_menu.c b/src/m_menu.c index ee97e9b00..1fb35bb22 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -241,8 +241,11 @@ static void M_LevelSelectWarp(INT32 choice); static void M_Credits(INT32 choice); static void M_PandorasBox(INT32 choice); static void M_EmblemHints(INT32 choice); +static void M_HandleChecklist(INT32 choice); menu_t SR_MainDef, SR_UnlockChecklistDef; +static UINT8 check_on; + // Misc. Main Menu static void M_SinglePlayerMenu(INT32 choice); static void M_Options(INT32 choice); @@ -712,7 +715,7 @@ static menuitem_t SR_LevelSelectMenu[] = static menuitem_t SR_UnlockChecklistMenu[] = { - {IT_SUBMENU | IT_STRING, NULL, "NEXT", &SR_MainDef, 192}, + {IT_KEYHANDLER | IT_STRING, NULL, "", M_HandleChecklist, 0}, }; static menuitem_t SR_EmblemHintMenu[] = @@ -1497,7 +1500,7 @@ menu_t SR_LevelSelectDef = MAPPLATTERMENUSTYLE(NULL, SR_LevelSelectMenu); menu_t SR_UnlockChecklistDef = { - NULL, + "M_SECRET", 1, &SR_MainDef, SR_UnlockChecklistMenu, @@ -4787,12 +4790,65 @@ static void M_LevelSelectWarp(INT32 choice) UINT8 skyRoomMenuTranslations[MAXUNLOCKABLES]; +static boolean checklist_cangodown; // uuuueeerggghhhh HACK + +static void M_HandleChecklist(INT32 choice) +{ + INT32 j; + switch (choice) + { + case KEY_DOWNARROW: + S_StartSound(NULL, sfx_menu1); + if (checklist_cangodown) + { + for (j = check_on+1; j < MAXUNLOCKABLES; j++) + { + if (!(unlockables[j].name[0] == 0 //|| unlockables[j].nochecklist + || !unlockables[j].conditionset || unlockables[j].conditionset > MAXCONDITIONSETS)) + break; + } + if (j != MAXUNLOCKABLES) + check_on = j; + } + return; + + case KEY_UPARROW: + S_StartSound(NULL, sfx_menu1); + for (j = check_on-1; j > -1; j--) + { + if (!(unlockables[j].name[0] == 0 //|| unlockables[j].nochecklist + || !unlockables[j].conditionset || unlockables[j].conditionset > MAXCONDITIONSETS)) + break; + } + if (j != -1) + check_on = j; + return; + + case KEY_ESCAPE: + if (currentMenu->prevMenu) + M_SetupNextMenu(currentMenu->prevMenu); + else + M_ClearMenus(true); + return; + default: + break; + } +} + +#define addy(add) { y += add; if ((y - currentMenu->y) > (scrollareaheight*2)) goto finishchecklist; } + static void M_DrawChecklist(void) { - INT32 i = 0, j = 0, y = currentMenu->y; + INT32 i = check_on, j = 0, y = currentMenu->y; UINT32 condnum, previd, maxcond; condition_t *cond; + // draw title (or big pic) + M_DrawMenuTitle(); + + if (check_on) + V_DrawString(10, y, V_YELLOWMAP, "\x1A"); + while (i < MAXUNLOCKABLES) { if (unlockables[i].name[0] == 0 //|| unlockables[i].nochecklist @@ -4808,68 +4864,96 @@ static void M_DrawChecklist(void) break; } if ((j != MAXUNLOCKABLES) && (unlockables[i].conditionset == unlockables[j].conditionset)) - y += 8; + addy(8) else { if ((maxcond = conditionSets[unlockables[i].conditionset-1].numconditions)) { cond = conditionSets[unlockables[i].conditionset-1].condition; previd = cond[0].id; - y += 2; - for (condnum = 0; condnum < maxcond; condnum++) + addy(2); + + if (unlockables[i].objective[0] != '/') { - if (cond[condnum].id != previd) + addy(8); + V_DrawString(currentMenu->x, y, + V_ALLOWLOWERCASE, + va("\x1E %s", unlockables[i].objective)); + } + else + { + for (condnum = 0; condnum < maxcond; condnum++) { - y += 8; - V_DrawString(currentMenu->x + 4, y, V_YELLOWMAP, "OR"); - } + if (cond[condnum].id != previd) + { + addy(8); + V_DrawString(currentMenu->x + 4, y, V_YELLOWMAP, "OR"); + } - y += 8; + addy(8); - switch (cond[condnum].type) - { - case UC_MAPBEATEN: - case UC_MAPPERFECT: - { - char *title = G_BuildMapTitle(cond[condnum].requirement); - if (title) + switch (cond[condnum].type) + { + case UC_MAPBEATEN: + case UC_MAPPERFECT: { - V_DrawString(currentMenu->x, y, V_ALLOWLOWERCASE, va("\x1E %s %s", - ((cond[condnum].type == UC_MAPPERFECT) ? "Get every ring in" : "Complete"), - ((M_MapLocked(cond[condnum].requirement) || !((mapheaderinfo[cond[condnum].requirement-1]->menuflags & LF2_NOVISITNEEDED) || mapvisited[cond[condnum].requirement-1])) ? M_CreateSecretMenuOption(title) : title))); - Z_Free(title); + char *title = G_BuildMapTitle(cond[condnum].requirement); + if (title) + { + V_DrawString(currentMenu->x, y, V_ALLOWLOWERCASE, va("\x1E %s %s", + ((cond[condnum].type == UC_MAPPERFECT) ? "Get every ring in" : "Complete"), + ((M_MapLocked(cond[condnum].requirement) || !((mapheaderinfo[cond[condnum].requirement-1]->menuflags & LF2_NOVISITNEEDED) || mapvisited[cond[condnum].requirement-1])) ? M_CreateSecretMenuOption(title) : title))); + Z_Free(title); + } } - } - break; - case UC_GAMECLEAR: - case UC_ALLEMERALDS: - { - const char *emeraldtext = ((cond[condnum].type == UC_ALLEMERALDS) ? " with all emeralds" : ""); - if (cond[condnum].requirement != 1) - V_DrawString(currentMenu->x, y, - V_ALLOWLOWERCASE,va("\x1E Complete the game %d times%s", - cond[condnum].requirement, emeraldtext)); - else - V_DrawString(currentMenu->x, y, - V_ALLOWLOWERCASE, - va("\x1E Complete the game%s", emeraldtext)); - } - break; - case UC_TOTALEMBLEMS: - V_DrawString(currentMenu->x, y, - V_ALLOWLOWERCASE, - va("\x1E Collect %s%d emblems", ((M_CountEmblems() == cond[condnum].requirement) ? "all " : ""), cond[condnum].requirement)); - break; - default: - V_DrawString(currentMenu->x, y, - V_ALLOWLOWERCASE, - va("\x1E id %d, type %d, req %d", cond[condnum].id, cond[condnum].type, cond[condnum].requirement)); - break; + break; + case UC_GAMECLEAR: + case UC_ALLEMERALDS: + { + const char *emeraldtext = ((cond[condnum].type == UC_ALLEMERALDS) ? " with all emeralds" : ""); + if (cond[condnum].requirement != 1) + V_DrawString(currentMenu->x, y, + V_ALLOWLOWERCASE,va("\x1E Beat the game %d times%s", + cond[condnum].requirement, emeraldtext)); + else + V_DrawString(currentMenu->x, y, + V_ALLOWLOWERCASE, + va("\x1E Beat the game%s", emeraldtext)); + } + break; + case UC_TOTALEMBLEMS: + V_DrawString(currentMenu->x, y, + V_ALLOWLOWERCASE, + va("\x1E Collect %s%d emblems", ((M_CountEmblems() == cond[condnum].requirement) ? "all " : ""), cond[condnum].requirement)); + break; + case UC_NIGHTSGRADE: + { + // No support for specific mare information yet. + char *title = G_BuildMapTitle(cond[condnum].extrainfo1); + char grade = ('F' - (char)cond[condnum].requirement); + if (grade < 'A') + grade = 'A'; + + if (title) + { + V_DrawString(currentMenu->x, y, V_ALLOWLOWERCASE, va("\x1E Get grade %c in %s", + grade, + ((M_MapLocked(cond[condnum].extrainfo1) || !((mapheaderinfo[cond[condnum].extrainfo1-1]->menuflags & LF2_NOVISITNEEDED) || mapvisited[cond[condnum].extrainfo1-1])) ? M_CreateSecretMenuOption(title) : title))); + Z_Free(title); + } + } + break; + default: + V_DrawString(currentMenu->x, y, + V_ALLOWLOWERCASE, + va("\x1E id %d, type %d, req %d", cond[condnum].id, cond[condnum].type, cond[condnum].requirement)); + break; + } + previd = cond[condnum].id; } - previd = cond[condnum].id; } } - y += 12; + addy(12); } i = j; @@ -4880,6 +4964,12 @@ static void M_DrawChecklist(void) else V_DrawString(308, 8+(24*j), V_YELLOWMAP, "N");*/ } + +finishchecklist: + if ((checklist_cangodown = ((y - currentMenu->y) > (scrollareaheight*2)))) // haaaaaaacks. + { + V_DrawString(10, currentMenu->y+(scrollareaheight*2), V_YELLOWMAP, "\x1B"); + } } #define NUMHINTS 5 @@ -8025,7 +8115,6 @@ static void M_ToggleSFX(INT32 choice) return; case KEY_ESCAPE: - S_StartSound(NULL, sfx_menu1); if (currentMenu->prevMenu) M_SetupNextMenu(currentMenu->prevMenu); else @@ -8080,7 +8169,6 @@ static void M_ToggleDigital(INT32 choice) return; case KEY_ESCAPE: - S_StartSound(NULL, sfx_menu1); if (currentMenu->prevMenu) M_SetupNextMenu(currentMenu->prevMenu); else @@ -8132,7 +8220,6 @@ static void M_ToggleMIDI(INT32 choice) return; case KEY_ESCAPE: - S_StartSound(NULL, sfx_menu1); if (currentMenu->prevMenu) M_SetupNextMenu(currentMenu->prevMenu); else @@ -8703,7 +8790,6 @@ static void M_HandleFogColor(INT32 choice) break; case KEY_ESCAPE: - S_StartSound(NULL, sfx_menu1); exitmenu = true; break;