Save skipped checks (#2476)

This commit is contained in:
Garrett Cox 2023-02-14 19:50:59 -06:00 committed by GitHub
parent 66b2d2d5fa
commit 462ab00c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 4 deletions

View File

@ -64,6 +64,7 @@ typedef struct {
/* */ u32 count[COUNT_MAX];
/* */ u32 entrancesDiscovered[SAVEFILE_ENTRANCES_DISCOVERED_IDX_COUNT];
/* */ u32 scenesDiscovered[SAVEFILE_SCENES_DISCOVERED_IDX_COUNT];
/* */ u8 locationsSkipped[RC_MAX];
} SohStats;
typedef struct {

View File

@ -31,6 +31,7 @@ void UpdateOrdering(bool init = false);
bool ShouldUpdateChecks();
bool CompareCheckObject(RandomizerCheckObject i, RandomizerCheckObject j);
bool HasItemBeenCollected(RandomizerCheckObject obj);
bool HasItemBeenSkipped(RandomizerCheckObject obj);
void RainbowTick();
RandomizerCheckShow GetCheckStatus(RandomizerCheckObject rcObj, int idx);
@ -700,8 +701,7 @@ RandomizerCheckShow GetCheckStatus(RandomizerCheckObject rcObj, int idx) {
if (HasItemBeenCollected(rcObj))
return RCSHOW_SAVED; // TODO: use SAVED until we hook into game elements without requiring a save. Then we'll use CHECKED
//If the status hasn't updated, keep showing as skipped
if (checkStatusMap.find(rcObj.rc)->second == RCSHOW_SKIPPED)
if (HasItemBeenSkipped(rcObj))
return RCSHOW_SKIPPED;
return RCSHOW_UNCHECKED;
@ -709,6 +709,9 @@ RandomizerCheckShow GetCheckStatus(RandomizerCheckObject rcObj, int idx) {
// TODO Seen, Hinted, Scummed, saved/checked
}
bool HasItemBeenSkipped(RandomizerCheckObject obj) {
return gSaveContext.sohStats.locationsSkipped[obj.rc] == 1;
}
bool HasItemBeenCollected(RandomizerCheckObject obj) {
ItemLocation* x = Location(obj.rc);
@ -816,11 +819,14 @@ void DrawLocation(RandomizerCheckObject rcObj, RandomizerCheckShow* thisCheckSta
if (*thisCheckStatus == RCSHOW_UNCHECKED || *thisCheckStatus == RCSHOW_SKIPPED) {
bool skipped = (*thisCheckStatus == RCSHOW_SKIPPED);
if (ImGui::ArrowButton(std::to_string(rcObj.rc).c_str(), skipped ? ImGuiDir_Left : ImGuiDir_Right)) {
if (skipped)
if (skipped) {
gSaveContext.sohStats.locationsSkipped[rcObj.rc] = 0;
*thisCheckStatus = RCSHOW_UNCHECKED;
else
} else {
gSaveContext.sohStats.locationsSkipped[rcObj.rc] = 1;
*thisCheckStatus = RCSHOW_SKIPPED;
}
}
} else {
ImGui::InvisibleButton("", ImVec2(20.0f, 10.0f));
}

View File

@ -483,6 +483,9 @@ void SaveManager::InitFileNormal() {
for (int entrancesIdx = 0; entrancesIdx < ARRAY_COUNT(gSaveContext.sohStats.entrancesDiscovered); entrancesIdx++) {
gSaveContext.sohStats.entrancesDiscovered[entrancesIdx] = 0;
}
for (int rc = 0; rc < ARRAY_COUNT(gSaveContext.sohStats.locationsSkipped); rc++) {
gSaveContext.sohStats.locationsSkipped[rc] = 0;
}
for (int scene = 0; scene < ARRAY_COUNT(gSaveContext.sceneFlags); scene++) {
gSaveContext.sceneFlags[scene].chest = 0;
gSaveContext.sceneFlags[scene].swch = 0;
@ -1255,6 +1258,9 @@ void SaveManager::LoadBaseVersion3() {
SaveManager::Instance->LoadArray("entrancesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.entrancesDiscovered), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.sohStats.entrancesDiscovered[i]);
});
SaveManager::Instance->LoadArray("locationsSkipped", ARRAY_COUNT(gSaveContext.sohStats.locationsSkipped), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.sohStats.locationsSkipped[i]);
});
});
SaveManager::Instance->LoadArray("sceneFlags", ARRAY_COUNT(gSaveContext.sceneFlags), [](size_t i) {
SaveManager::Instance->LoadStruct("", [&i]() {
@ -1445,6 +1451,9 @@ void SaveManager::SaveBase() {
SaveManager::Instance->SaveArray("entrancesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.entrancesDiscovered), [](size_t i) {
SaveManager::Instance->SaveData("", gSaveContext.sohStats.entrancesDiscovered[i]);
});
SaveManager::Instance->SaveArray("locationsSkipped", ARRAY_COUNT(gSaveContext.sohStats.locationsSkipped), [](size_t i) {
SaveManager::Instance->SaveData("", gSaveContext.sohStats.locationsSkipped[i]);
});
});
SaveManager::Instance->SaveArray("sceneFlags", ARRAY_COUNT(gSaveContext.sceneFlags), [](size_t i) {
SaveManager::Instance->SaveStruct("", [&i]() {