Check Tracker - Loading Fixes

- Fixes a bug where loading a save file a second time would add all the checks again
- Fixes a bug where the check tracker would not render at all until in a save file
This commit is contained in:
sonoftunk 2022-11-22 21:34:47 -05:00
parent 29b7c45d70
commit 60ec5bb9be

View File

@ -17,6 +17,7 @@ extern PlayState* gPlayState;
}
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
void Teardown();
void InitializeChecks();
void UpdateChecks();
void DrawLocation(RandomizerCheckObject rcObj, RandomizerCheckShow* thisCheckStatus);
@ -85,16 +86,13 @@ std::vector<uint32_t> buttons = { BTN_A, BTN_B, BTN_CUP, BTN_CDOWN, BTN_CLEFT,
BTN_Z, BTN_R, BTN_START, BTN_DUP, BTN_DDOWN, BTN_DLEFT, BTN_DRIGHT };
void DrawCheckTracker(bool& open) {
if (doInitialize)
InitializeChecks();
if (!initialized)
return;
if (!open) {
CVar_SetS32("gCheckTrackerEnabled", 0);
return;
}
if (doInitialize)
InitializeChecks();
if (CVar_GetS32("gCheckTrackerWindowType", 1) == 0) {
if (CVar_GetS32("gCheckTrackerShowOnlyPaused", 0) == 1)
@ -112,6 +110,18 @@ void DrawCheckTracker(bool& open) {
}
}
BeginFloatWindows("Check Tracker", ImGuiWindowFlags_NoScrollbar);
if (!initialized) {
ImGui::Text("Waiting for file load...");
EndFloatWindows();
return;
} else if (gPlayState == nullptr || gSaveContext.fileNum < 0 || gSaveContext.fileNum > 2) {
Teardown();
EndFloatWindows();
return;
}
SceneID sceneId = SCENE_ID_MAX;
if (gPlayState != nullptr) {
sceneId = (SceneID)gPlayState->sceneNum;
@ -132,7 +142,6 @@ void DrawCheckTracker(bool& open) {
UpdateOrdering();
}
BeginFloatWindows("Check Tracker", ImGuiWindowFlags_NoScrollbar);
//Quick Options
#ifdef __WIIU__
@ -331,7 +340,7 @@ void InitializeChecks() {
void Teardown() {
initialized = false;
//delete checkStatus; //TODO may cause crashes due to race conditions during a draw cycle, but if you don't have it, then there's a memory leak when switching files
checkStatusMap.clear();
areasFullyChecked = 0;
checks.clear();
lastSaveCount = -1;