From 65fbf2cc41dc0a57f7de395f435e6ae9d408338d Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 13 Oct 2024 22:22:49 -0700 Subject: [PATCH] Restore Vanilla Tracking (#4394) * Re-enabled vanilla tracking in the check tracker. Utilized Rando::Context for check status. * Restore check tracker window custom background functionality. --- .../Enhancements/randomizer/location_list.cpp | 2 +- .../randomizer/randomizer_check_tracker.cpp | 31 ++++++++++++++++--- .../randomizer/randomizer_check_tracker.h | 1 + soh/soh/SaveManager.cpp | 9 +++--- .../ovl_file_choose/z_file_choose.c | 2 +- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/location_list.cpp b/soh/soh/Enhancements/randomizer/location_list.cpp index ac45668fa..0c59086bc 100644 --- a/soh/soh/Enhancements/randomizer/location_list.cpp +++ b/soh/soh/Enhancements/randomizer/location_list.cpp @@ -911,7 +911,7 @@ void Rando::StaticData::InitLocationTable() { // 7 5 1 3 -------------------------------*/ // Kokiri Forest - locationTable[RC_KF_SHOP_ITEM_1] = Location::Base(RC_KF_SHOP_ITEM_1, RCQUEST_BOTH, RCTYPE_SHOP, ACTOR_EN_GIRLA, SCENE_KOKIRI_SHOP, 0x00, "Shop Item 1", RHT_KF_SHOP_ITEM_1, RG_BUY_DEKU_SHIELD, SpoilerCollectionCheck(), false, 40); + locationTable[RC_KF_SHOP_ITEM_1] = Location::Base(RC_KF_SHOP_ITEM_1, RCQUEST_BOTH, RCTYPE_SHOP, ACTOR_EN_GIRLA, SCENE_KOKIRI_SHOP, 0x00, "Shop Item 1", RHT_KF_SHOP_ITEM_1, RG_BUY_DEKU_SHIELD, SpoilerCollectionCheck(), true, 40); locationTable[RC_KF_SHOP_ITEM_2] = Location::Base(RC_KF_SHOP_ITEM_2, RCQUEST_BOTH, RCTYPE_SHOP, ACTOR_EN_GIRLA, SCENE_KOKIRI_SHOP, 0x01, "Shop Item 2", RHT_KF_SHOP_ITEM_2, RG_BUY_DEKU_NUTS_5, SpoilerCollectionCheck(), false, 15); locationTable[RC_KF_SHOP_ITEM_3] = Location::Base(RC_KF_SHOP_ITEM_3, RCQUEST_BOTH, RCTYPE_SHOP, ACTOR_EN_GIRLA, SCENE_KOKIRI_SHOP, 0x02, "Shop Item 3", RHT_KF_SHOP_ITEM_3, RG_BUY_DEKU_NUTS_10, SpoilerCollectionCheck(), false, 30); locationTable[RC_KF_SHOP_ITEM_4] = Location::Base(RC_KF_SHOP_ITEM_4, RCQUEST_BOTH, RCTYPE_SHOP, ACTOR_EN_GIRLA, SCENE_KOKIRI_SHOP, 0x03, "Shop Item 4", RHT_KF_SHOP_ITEM_4, RG_BUY_DEKU_STICK_1, SpoilerCollectionCheck(), false, 10); diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 115dc44d9..217eae558 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -647,6 +647,10 @@ void CheckTrackerItemReceive(GetItemEntry giEntry) { } void CheckTrackerSceneFlagSet(int16_t sceneNum, int16_t flagType, int32_t flag) { + if (IS_RANDO) { + return; + } + if (flagType != FLAG_SCENE_TREASURE && flagType != FLAG_SCENE_COLLECTIBLE) { return; } @@ -668,6 +672,10 @@ void CheckTrackerSceneFlagSet(int16_t sceneNum, int16_t flagType, int32_t flag) } void CheckTrackerFlagSet(int16_t flagType, int32_t flag) { + if (IS_RANDO) { + return; + } + SpoilerCollectionCheckType checkMatchType = SpoilerCollectionCheckType::SPOILER_CHK_NONE; switch (flagType) { case FLAG_GS_TOKEN: @@ -1289,8 +1297,12 @@ bool IsCheckShuffled(RandomizerCheck rc) { bool IsVisibleInCheckTracker(RandomizerCheck rc) { auto loc = Rando::StaticData::GetLocation(rc); - return IsCheckShuffled(rc) || (loc->GetRCType() == RCTYPE_SKULL_TOKEN && alwaysShowGS) || - (loc->GetRCType() == RCTYPE_SHOP && (showShops && (!hideShopRightChecks))); + if (IS_RANDO) { + return IsCheckShuffled(rc) || (loc->GetRCType() == RCTYPE_SKULL_TOKEN && alwaysShowGS) || + (loc->GetRCType() == RCTYPE_SHOP && (showShops && (!hideShopRightChecks))); + } else { + return loc->IsVanillaCompletion() && (!loc->IsDungeon() || (loc->IsDungeon() && loc->GetQuest() == gSaveContext.questId)); + } } void UpdateInventoryChecks() { @@ -1639,6 +1651,15 @@ void ImGuiDrawTwoColorPickerSection(const char* text, const char* cvarMainName, } } +void CheckTrackerWindow::Draw() { + if (!IsVisible()) { + return; + } + DrawElement(); + // Sync up the IsVisible flag if it was changed by ImGui + SyncVisibilityConsoleVariable(); +} + static const char* windowType[] = { "Floating", "Window" }; static const char* displayType[] = { "Always", "Combo Button Hold" }; static const char* buttonStrings[] = { "A Button", "B Button", "C-Up", "C-Down", "C-Left", "C-Right", "L Button", @@ -1716,12 +1737,12 @@ void CheckTrackerWindow::InitElement() { GameInteractor::Instance->RegisterGameHook([](uint32_t fileNum) { Teardown(); }); - // GameInteractor::Instance->RegisterGameHook(CheckTrackerItemReceive); + GameInteractor::Instance->RegisterGameHook(CheckTrackerItemReceive); GameInteractor::Instance->RegisterGameHook(CheckTrackerFrame); GameInteractor::Instance->RegisterGameHook(CheckTrackerTransition); GameInteractor::Instance->RegisterGameHook(CheckTrackerShopSlotChange); - // GameInteractor::Instance->RegisterGameHook(CheckTrackerSceneFlagSet); - // GameInteractor::Instance->RegisterGameHook(CheckTrackerFlagSet); + GameInteractor::Instance->RegisterGameHook(CheckTrackerSceneFlagSet); + GameInteractor::Instance->RegisterGameHook(CheckTrackerFlagSet); } void CheckTrackerWindow::UpdateElement() { diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h index f1778c7d5..96aee4dde 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h @@ -21,6 +21,7 @@ class CheckTrackerSettingsWindow : public Ship::GuiWindow { class CheckTrackerWindow : public Ship::GuiWindow { public: using GuiWindow::GuiWindow; + void Draw() override; ~CheckTrackerWindow() {}; protected: diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 4079dd279..cef3149e2 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -2841,11 +2841,12 @@ extern "C" void Save_SaveGlobal(void) { } extern "C" void Save_LoadFile(void) { + // Handle vanilla context reset + OTRGlobals::Instance->gRandoContext.reset(); + OTRGlobals::Instance->gRandoContext = Rando::Context::CreateInstance(); + OTRGlobals::Instance->gRandoContext->GetLogic()->SetSaveContext(&gSaveContext); + if (SaveManager::Instance->fileMetaInfo[gSaveContext.fileNum].randoSave) { - // Reset rando context for rando saves. - OTRGlobals::Instance->gRandoContext.reset(); - OTRGlobals::Instance->gRandoContext = Rando::Context::CreateInstance(); - OTRGlobals::Instance->gRandoContext->GetLogic()->SetSaveContext(&gSaveContext); OTRGlobals::Instance->gRandoContext->AddExcludedOptions(); OTRGlobals::Instance->gRandoContext->GetSettings()->CreateOptions(); } diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 3814eff24..50f846ddc 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -963,7 +963,7 @@ void DrawSeedHashSprites(FileChooseContext* this) { if (this->configMode == CM_MAIN_MENU && (this->selectMode != SM_CONFIRM_FILE || Save_GetSaveMetaInfo(this->selectedFileIndex)->randoSave == 1)) { - if (this->fileInfoAlpha[this->selectedFileIndex] > 0) { + if (this->fileInfoAlpha[this->selectedFileIndex] > 0 && Save_GetSaveMetaInfo(this->selectedFileIndex)->randoSave) { // Use file info alpha to match fading gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, this->fileInfoAlpha[this->selectedFileIndex]);