From 84a5fac5e921a858a27785a0db2360aa4674a6fc Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Thu, 29 Mar 2018 01:14:29 -0400 Subject: [PATCH] Start of a better unlockable checklist Still WIP, doesn't display properly --- src/m_cond.c | 2 +- src/m_cond.h | 1 + src/m_menu.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 88 insertions(+), 10 deletions(-) diff --git a/src/m_cond.c b/src/m_cond.c index 72932365..9025c521 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -197,7 +197,7 @@ void M_ClearSecrets(void) // ---------------------- // Condition set checking // ---------------------- -static UINT8 M_CheckCondition(condition_t *cn) +UINT8 M_CheckCondition(condition_t *cn) { switch (cn->type) { diff --git a/src/m_cond.h b/src/m_cond.h index d34b2cbf..aadf301b 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -151,6 +151,7 @@ void M_ClearSecrets(void); // Updating conditions and unlockables void M_CheckUnlockConditions(void); +UINT8 M_CheckCondition(condition_t *cn); UINT8 M_UpdateUnlockablesAndExtraEmblems(void); void M_SilentUpdateUnlockablesAndEmblems(void); UINT8 M_CheckLevelEmblems(void); diff --git a/src/m_menu.c b/src/m_menu.c index 72f7bc58..349838bd 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4263,26 +4263,103 @@ static void M_LevelSelectWarp(INT32 choice) UINT8 skyRoomMenuTranslations[MAXUNLOCKABLES]; -#define NUMCHECKLIST 8 +{ + char *tempstr = ""; + + switch(cond.type) + { + case UC_PLAYTIME: + tempstr = va("Play for %i:%02i:%02i", + G_TicsToHours(cond.requirement), + G_TicsToMinutes(cond.requirement, false), + G_TicsToSeconds(cond.requirement)); + break; + case UC_MATCHESPLAYED: + tempstr = va("Play %d matches", cond.requirement); + break; + case UC_GAMECLEAR: + if (cond.requirement > 1) + tempstr = va("Beat game %d times", cond.requirement); + else + tempstr = va("Beat the game"); + break; + case UC_ALLEMERALDS: + if (cond.requirement > 1) + tempstr = va("Beat game w/ all emeralds %d times", cond.requirement); + else + tempstr = va("Beat game w/ all emeralds"); + break; + case UC_OVERALLTIME: + tempstr = va("Get overall time of %i:%02i:%02i", + G_TicsToHours(cond.requirement), + G_TicsToMinutes(cond.requirement, false), + G_TicsToSeconds(cond.requirement)); + break; + case UC_MAPVISITED: + tempstr = va("Visit %s", G_BuildMapTitle(cond.requirement-1)); + break; + case UC_MAPBEATEN: + tempstr = va("Beat %s", G_BuildMapTitle(cond.requirement-1)); + break; + case UC_MAPALLEMERALDS: + tempstr = va("Beat %s w/ all emeralds", G_BuildMapTitle(cond.requirement-1)); + break; + case UC_MAPTIME: + tempstr = va("Beat %s in %i:%02i.%02i", G_BuildMapTitle(cond.extrainfo1-1), + G_TicsToMinutes(cond.requirement, true), + G_TicsToSeconds(cond.requirement), + G_TicsToCentiseconds(cond.requirement)); + break; + case UC_TOTALEMBLEMS: + tempstr = va("Get %d emblems", cond.requirement); + break; + case UC_EXTRAEMBLEM: + tempstr = va("Get \"%s\" emblem", extraemblems[cond.requirement-1].name); + break; + default: + break; + } + + return tempstr; +} + +#define NUMCHECKLIST 32 static void M_DrawChecklist(void) { - INT32 i, j = 0; + INT32 i, line = 0; for (i = 0; i < MAXUNLOCKABLES; i++) { + INT32 c, lastid = -1; + if (unlockables[i].name[0] == 0 || unlockables[i].nochecklist || !unlockables[i].conditionset || unlockables[i].conditionset > MAXCONDITIONSETS) continue; - V_DrawString(8, 8+(24*j), V_RETURN8, unlockables[i].name); - V_DrawString(160, 8+(24*j), V_RETURN8, V_WordWrap(160, 292, 0, unlockables[i].objective)); + V_DrawString(8, 8+(line*8), V_RETURN8|(unlockables[i].unlocked ? V_GREENMAP : V_REDMAP), unlockables[i].name); + ++line; - if (unlockables[i].unlocked) - V_DrawString(308, 8+(24*j), V_YELLOWMAP, "Y"); - else - V_DrawString(308, 8+(24*j), V_YELLOWMAP, "N"); + for (c = 0; c < conditionSets[unlockables[i].conditionset].numconditions; c++) + { + condition_t cond = conditionSets[unlockables[i].conditionset].condition[c]; + UINT8 achieved = M_CheckCondition(&cond); + char *str = M_GetConditionString(cond); - if (++j >= NUMCHECKLIST) + if (!str) + continue; + + ++line; + + if (cond.id != lastid) + V_DrawString(16, 8+(line*8), V_MONOSPACE|V_ALLOWLOWERCASE|(achieved ? V_YELLOWMAP : 0), va("* %s", str)); + else + V_DrawString(16, 8+(line*8), V_MONOSPACE|V_ALLOWLOWERCASE|(achieved ? V_YELLOWMAP : 0), va(" AND %s", str)); + + lastid = cond.id; + } + line += 2; + + if (line >= NUMCHECKLIST) break; } }