diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 177a43834..1c7169ccf 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1195,7 +1195,7 @@ extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) { OTRGlobals::Instance->context->GetWindow()->MainLoop(run_one_game_iter); } -extern bool ShouldClearTextureCacheAtEndOfFrame; +extern bool ToggleAltAssetsAtEndOfFrame; extern "C" void Graph_StartFrame() { #ifndef __WIIU__ @@ -1278,10 +1278,7 @@ extern "C" void Graph_StartFrame() { } #endif case KbScancode::LUS_KB_TAB: { - // Toggle HD Assets - CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); - GameInteractor::Instance->ExecuteHooks(); - ShouldClearTextureCacheAtEndOfFrame = true; + ToggleAltAssetsAtEndOfFrame = true; break; } } @@ -1351,10 +1348,14 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { } } - if (ShouldClearTextureCacheAtEndOfFrame) { + if (ToggleAltAssetsAtEndOfFrame) { + ToggleAltAssetsAtEndOfFrame = false; + + // Actually update the CVar now before runing the alt asset update listeners + CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); gfx_texture_cache_clear(); LUS::SkeletonPatcher::UpdateSkeletons(); - ShouldClearTextureCacheAtEndOfFrame = false; + GameInteractor::Instance->ExecuteHooks(); } // OTRTODO: FIGURE OUT END FRAME POINT diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index af452352b..c30f52db2 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -38,7 +38,7 @@ #include "Enhancements/game-interactor/GameInteractor.h" #include "Enhancements/cosmetics/authenticGfxPatches.h" -bool ShouldClearTextureCacheAtEndOfFrame = false; +bool ToggleAltAssetsAtEndOfFrame = false; bool isBetaQuestEnabled = false; extern "C" { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 879b2d5f4..6c3cc1749 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -29,7 +29,7 @@ #include "Enhancements/randomizer/randomizer_item_tracker.h" #include "Enhancements/randomizer/randomizer_settings_window.h" -extern bool ShouldClearTextureCacheAtEndOfFrame; +extern bool ToggleAltAssetsAtEndOfFrame; extern bool isBetaQuestEnabled; extern "C" PlayState* gPlayState; @@ -919,8 +919,10 @@ void DrawEnhancementsMenu() { { if (ImGui::BeginMenu("Mods")) { if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", "gAltAssets", false, false)) { - ShouldClearTextureCacheAtEndOfFrame = true; - GameInteractor::Instance->ExecuteHooks(); + // The checkbox will flip the alt asset CVar, but we instead want it to change at the end of the game frame + // We toggle it back while setting the flag to update the CVar later + CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + ToggleAltAssetsAtEndOfFrame = true; } UIWidgets::Tooltip("Toggle between standard assets and alternate assets. Usually mods will indicate if this setting has to be used or not."); UIWidgets::PaddedEnhancementCheckbox("Disable Bomb Billboarding", "gDisableBombBillboarding", true, false); diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.cpp b/soh/soh/resource/importer/SkeletonLimbFactory.cpp index 22c18da24..7ca8ae1cc 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.cpp +++ b/soh/soh/resource/importer/SkeletonLimbFactory.cpp @@ -132,15 +132,15 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->limbData.lodLimb.sibling = skeletonLimb->siblingIndex; if (skeletonLimb->dListPtr != "") { - auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str()); - skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr); + skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr; + skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)skeletonLimb->dListPtr.c_str(); } else { skeletonLimb->limbData.lodLimb.dLists[0] = nullptr; } if (skeletonLimb->dList2Ptr != "") { - auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str()); - skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr); + skeletonLimb->dList2Ptr = "__OTR__" + skeletonLimb->dList2Ptr; + skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)skeletonLimb->dList2Ptr.c_str(); } else { skeletonLimb->limbData.lodLimb.dLists[1] = nullptr; } @@ -153,8 +153,8 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->limbData.standardLimb.dList = nullptr; if (!skeletonLimb->dListPtr.empty()) { - const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str()); - skeletonLimb->limbData.standardLimb.dList = (Gfx*)(dList ? dList->GetRawPointer() : nullptr); + skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr; + skeletonLimb->limbData.standardLimb.dList = (Gfx*)skeletonLimb->dListPtr.c_str(); } } else if (skeletonLimb->limbType == LUS::LimbType::Curve) { skeletonLimb->limbData.skelCurveLimb.firstChildIdx = skeletonLimb->childIndex; @@ -163,13 +163,13 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->limbData.skelCurveLimb.dList[1] = nullptr; if (!skeletonLimb->dListPtr.empty()) { - const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str()); - skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr); + skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr; + skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)skeletonLimb->dListPtr.c_str(); } if (!skeletonLimb->dList2Ptr.empty()) { - const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str()); - skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr); + skeletonLimb->dList2Ptr = "__OTR__" + skeletonLimb->dList2Ptr; + skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)skeletonLimb->dList2Ptr.c_str(); } } else if (skeletonLimb->limbType == LUS::LimbType::Skin) { skeletonLimb->limbData.skinLimb.jointPos.x = skeletonLimb->transX; @@ -189,14 +189,23 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r } if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) { - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList.c_str()); - skeletonLimb->limbData.skinLimb.segment = res ? res->GetRawPointer() : nullptr; + if (skeletonLimb->skinDList != "") { + skeletonLimb->skinDList = "__OTR__" + skeletonLimb->skinDList; + skeletonLimb->limbData.skinLimb.segment = (Gfx*)skeletonLimb->skinDList.c_str(); + } else { + skeletonLimb->limbData.skinLimb.segment = nullptr; + } } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) { skeletonLimb->skinAnimLimbData.totalVtxCount = skeletonLimb->skinVtxCnt; skeletonLimb->skinAnimLimbData.limbModifCount = skeletonLimb->skinLimbModifCount; skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data(); - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList2.c_str()); - skeletonLimb->skinAnimLimbData.dlist = (Gfx*)(res ? res->GetRawPointer() : nullptr); + + if (skeletonLimb->skinDList2 != "") { + skeletonLimb->skinDList2 = "__OTR__" + skeletonLimb->skinDList2; + skeletonLimb->skinAnimLimbData.dlist = (Gfx*)skeletonLimb->skinDList2.c_str(); + } else { + skeletonLimb->skinAnimLimbData.dlist = nullptr; + } for (size_t i = 0; i < skeletonLimb->skinLimbModifArray.size(); i++) { skeletonLimb->skinAnimLimbData.limbModifications[i].vtxCount = skeletonLimb->skinLimbModifVertexArrays[i].size(); @@ -254,8 +263,8 @@ void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shar limbData.lodLimb.jointPos.z = skelLimb->transZ; if (skelLimb->dListPtr != "") { - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess((const char*)skelLimb->dListPtr.c_str()); - limbData.lodLimb.dLists[0] = (Gfx*)(res ? res->GetRawPointer() : nullptr); + skelLimb->dListPtr = "__OTR__" + skelLimb->dListPtr; + limbData.lodLimb.dLists[0] = (Gfx*)skelLimb->dListPtr.c_str(); } else { limbData.lodLimb.dLists[0] = nullptr; }