From 736dccb00b161a007a387b04267bdc30ef91e0af Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 2 Jun 2024 15:34:53 -0400 Subject: [PATCH] update to latest LUS main (#4202) Includes supporting changes from: * https://github.com/HarbourMasters/Shipwright/pull/4197 (alt assets variable changes) * https://github.com/HarbourMasters/Shipwright/pull/4199 (WindowBackend enum changes) * https://github.com/HarbourMasters/Shipwright/pull/4200 (Extract gMtxClear) --------- Co-authored-by: Malkierian Co-authored-by: inspectredc --- CMake/lus-cvars.cmake | 1 - libultraship | 2 +- soh/assets/xml/GC_MQ_D/code/sys_matrix.xml | 5 +++ .../xml/GC_MQ_D/scenes/dungeons/bdan.xml | 1 + .../xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml | 1 + .../xml/GC_MQ_PAL_F/code/sys_matrix.xml | 5 +++ .../xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml | 1 + .../GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml | 1 + soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml | 5 +++ .../xml/GC_NMQ_D/scenes/dungeons/bdan.xml | 1 + .../GC_NMQ_D/scenes/dungeons/bdan_boss.xml | 1 + .../xml/GC_NMQ_PAL_F/code/sys_matrix.xml | 5 +++ .../xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml | 1 + .../scenes/dungeons/bdan_boss.xml | 1 + soh/assets/xml/N64_PAL_10/code/sys_matrix.xml | 5 +++ .../xml/N64_PAL_10/scenes/dungeons/bdan.xml | 1 + .../N64_PAL_10/scenes/dungeons/bdan_boss.xml | 1 + soh/assets/xml/N64_PAL_11/code/sys_matrix.xml | 5 +++ .../xml/N64_PAL_11/scenes/dungeons/bdan.xml | 1 + .../N64_PAL_11/scenes/dungeons/bdan_boss.xml | 1 + soh/soh/OTRGlobals.cpp | 31 ++++++++++--------- soh/soh/OTRGlobals.h | 1 + soh/soh/SohGui.cpp | 1 - soh/soh/SohMenuBar.cpp | 27 ++++++---------- soh/soh/resource/type/Skeleton.cpp | 7 ++--- soh/src/code/game.c | 2 +- soh/src/code/gfxprint.c | 2 +- 27 files changed, 75 insertions(+), 41 deletions(-) create mode 100644 soh/assets/xml/GC_MQ_D/code/sys_matrix.xml create mode 100644 soh/assets/xml/GC_MQ_PAL_F/code/sys_matrix.xml create mode 100644 soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml create mode 100644 soh/assets/xml/GC_NMQ_PAL_F/code/sys_matrix.xml create mode 100644 soh/assets/xml/N64_PAL_10/code/sys_matrix.xml create mode 100644 soh/assets/xml/N64_PAL_11/code/sys_matrix.xml diff --git a/CMake/lus-cvars.cmake b/CMake/lus-cvars.cmake index e7376cfe28d..dee8f8c084f 100644 --- a/CMake/lus-cvars.cmake +++ b/CMake/lus-cvars.cmake @@ -16,7 +16,6 @@ set(CVAR_STATS_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.Stats" CACHE STRING "") set(CVAR_ENABLE_MULTI_VIEWPORTS "${CVAR_PREFIX_SETTING}.EnableMultiViewports" CACHE STRING "") set(CVAR_LOW_RES_MODE "${CVAR_PREFIX_SETTING}.LowResMode" CACHE STRING "") set(CVAR_SIMULATED_INPUT_LAG "${CVAR_PREFIX_SETTING}.SimulatedInputLag" CACHE STRING "") -set(CVAR_ALT_ASSETS "${CVAR_PREFIX_ENHANCEMENT}.AltAssets" CACHE STRING "") set(CVAR_GAME_OVERLAY_FONT "${CVAR_PREFIX_SETTING}.OverlayFont" CACHE STRING "") set(CVAR_MENU_BAR_OPEN "${CVAR_PREFIX_SETTING}.OpenMenuBar" CACHE STRING "") set(CVAR_PREFIX_CONTROLLERS "${CVAR_PREFIX_SETTING}.Controllers" CACHE STRING "") diff --git a/libultraship b/libultraship index 9def18e6246..fb10cd2feb4 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 9def18e62467b4225d26e206e0039a31ed406573 +Subproject commit fb10cd2feb488cf58899a7d5283195fc50b07b23 diff --git a/soh/assets/xml/GC_MQ_D/code/sys_matrix.xml b/soh/assets/xml/GC_MQ_D/code/sys_matrix.xml new file mode 100644 index 00000000000..b39033d5976 --- /dev/null +++ b/soh/assets/xml/GC_MQ_D/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan.xml b/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan.xml index 18d39d57b0d..9eb1ee61aa2 100644 --- a/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_MQ_PAL_F/code/sys_matrix.xml b/soh/assets/xml/GC_MQ_PAL_F/code/sys_matrix.xml new file mode 100644 index 00000000000..a3fed368bef --- /dev/null +++ b/soh/assets/xml/GC_MQ_PAL_F/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml b/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml index 18d39d57b0d..9eb1ee61aa2 100644 --- a/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml b/soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml new file mode 100644 index 00000000000..ed2a859c655 --- /dev/null +++ b/soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan.xml b/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan.xml index 41c009d7d5e..a9e520f4cf2 100644 --- a/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_NMQ_PAL_F/code/sys_matrix.xml b/soh/assets/xml/GC_NMQ_PAL_F/code/sys_matrix.xml new file mode 100644 index 00000000000..d2143f4e488 --- /dev/null +++ b/soh/assets/xml/GC_NMQ_PAL_F/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml b/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml index 41c009d7d5e..a9e520f4cf2 100644 --- a/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/N64_PAL_10/code/sys_matrix.xml b/soh/assets/xml/N64_PAL_10/code/sys_matrix.xml new file mode 100644 index 00000000000..706c249d454 --- /dev/null +++ b/soh/assets/xml/N64_PAL_10/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan.xml b/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan.xml index 41c009d7d5e..a9e520f4cf2 100644 --- a/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/N64_PAL_11/code/sys_matrix.xml b/soh/assets/xml/N64_PAL_11/code/sys_matrix.xml new file mode 100644 index 00000000000..97b57a57c76 --- /dev/null +++ b/soh/assets/xml/N64_PAL_11/code/sys_matrix.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan.xml b/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan.xml index 41c009d7d5e..a9e520f4cf2 100644 --- a/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan.xml +++ b/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan.xml @@ -1,4 +1,5 @@ + diff --git a/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan_boss.xml b/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan_boss.xml index b88d6eb03bc..9fccf2c3010 100644 --- a/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan_boss.xml +++ b/soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan_boss.xml @@ -1,4 +1,5 @@ + diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 12f94e5fd31..11ea494d5d2 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -149,6 +149,8 @@ Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 }; float previousImGuiScale; +bool prevAltAssets = false; + // Same as NaviColor type from OoT src (z_actor.c), but modified to be sans alpha channel for Controller LED. typedef struct { Color_RGB8 inner; @@ -320,6 +322,8 @@ OTRGlobals::OTRGlobals() { // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) context->InitResourceManager(OTRFiles, {}, 3); + prevAltAssets = CVarGetInteger(CVAR_ENHANCEMENT("AltAssets"), 0); + context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets); context->InitControlDeck({BTN_MODIFIER1, BTN_MODIFIER2}); context->GetControlDeck()->SetSinglePlayerMappingMode(true); @@ -468,7 +472,7 @@ bool OTRGlobals::HasOriginal() { } uint32_t OTRGlobals::GetInterpolationFPS() { - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { return CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20); } @@ -484,9 +488,6 @@ struct ExtensionEntry { std::string ext; }; -extern uintptr_t clearMtx; -extern "C" Mtx gMtxClear; -extern "C" MtxF gMtxFClear; extern "C" void OTRMessage_Init(); extern "C" void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples); extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len); @@ -1145,7 +1146,6 @@ extern "C" void InitOTR() { GameInteractorSail::Instance = new GameInteractorSail(); #endif - clearMtx = (uintptr_t)&gMtxClear; OTRMessage_Init(); OTRAudio_Init(); OTRExtScanner(); @@ -1254,8 +1254,6 @@ extern "C" uint64_t GetUnixTimestamp() { return (uint64_t)millis.count(); } -extern bool ToggleAltAssetsAtEndOfFrame; - extern "C" void Graph_StartFrame() { #ifndef __WIIU__ using Ship::KbScancode; @@ -1337,7 +1335,7 @@ extern "C" void Graph_StartFrame() { } #endif case KbScancode::LUS_KB_TAB: { - ToggleAltAssetsAtEndOfFrame = true; + CVarSetInteger(CVAR_ENHANCEMENT("AltAssets"), !CVarGetInteger(CVAR_ENHANCEMENT("AltAssets"), 0)); break; } } @@ -1420,11 +1418,10 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { } } - if (ToggleAltAssetsAtEndOfFrame) { - ToggleAltAssetsAtEndOfFrame = false; - - // Actually update the CVar now before runing the alt asset update listeners - CVarSetInteger(CVAR_ALT_ASSETS, !CVarGetInteger(CVAR_ALT_ASSETS, 0)); + bool curAltAssets = CVarGetInteger(CVAR_ENHANCEMENT("AltAssets"), 0); + if (prevAltAssets != curAltAssets) { + prevAltAssets = curAltAssets; + Ship::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets); gfx_texture_cache_clear(); SOH::SkeletonPatcher::UpdateSkeletons(); GameInteractor::Instance->ExecuteHooks(); @@ -1610,10 +1607,14 @@ extern "C" uint8_t ResourceMgr_FileAltExists(const char* filePath) { return ExtensionCache.contains(path); } +extern "C" bool ResourceMgr_IsAltAssetsEnabled() { + return Ship::Context::GetInstance()->GetResourceManager()->IsAltAssetsEnabled(); +} + // Unloads a resource if an alternate version exists when alt assets are enabled // The resource is only removed from the internal cache to prevent it from used in the next resource lookup extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) { - if (CVarGetInteger(CVAR_ALT_ASSETS, 0) && ResourceMgr_FileAltExists((char*) resName)) { + if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileAltExists((char*)resName)) { ResourceMgr_UnloadResource((char*) resName); } } @@ -1964,7 +1965,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel pathStr = pathStr.substr(sOtr.length()); } - bool isAlt = CVarGetInteger(CVAR_ALT_ASSETS, 0); + bool isAlt = ResourceMgr_IsAltAssetsEnabled(); if (isAlt) { pathStr = Ship::IResource::gAltAssetPrefix + pathStr; diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index e0b5c7a3816..d0001534a55 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -137,6 +137,7 @@ void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size); void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size); uint64_t GetPerfCounter(); +bool ResourceMgr_IsAltAssetsEnabled(); struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime); void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime); void ResourceMgr_ClearSkeletons(); diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 7fde4f351b0..25763525d64 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -43,7 +43,6 @@ #include "Enhancements/resolution-editor/ResolutionEditor.h" #include "Enhancements/debugger/MessageViewer.h" -bool ToggleAltAssetsAtEndOfFrame = false; bool isBetaQuestEnabled = false; extern "C" { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 9cd2c684416..00f7994f5b4 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -37,7 +37,6 @@ #include "Enhancements/randomizer/randomizer_settings_window.h" #include "Enhancements/resolution-editor/ResolutionEditor.h" -extern bool ToggleAltAssetsAtEndOfFrame; extern bool isBetaQuestEnabled; extern "C" PlayState* gPlayState; @@ -319,7 +318,7 @@ void DrawSettingsMenu() { { // FPS Slider const int minFps = 20; static int maxFps; - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { maxFps = 360; } else { maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); @@ -387,12 +386,12 @@ void DrawSettingsMenu() { Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); #else bool matchingRefreshRate = - CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11; + CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::FAST3D_DXGI_DX11; UIWidgets::PaddedEnhancementSliderInt( (currentFps == 20) ? "Frame Rate: Original (20 fps)" : "Frame Rate: %d fps", "##FPSInterpolation", CVAR_SETTING("InterpolationFPS"), minFps, maxFps, "", 20, true, true, false, matchingRefreshRate); #endif - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { UIWidgets::Tooltip( "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics.\n" "This is purely visual and does not impact game logic, execution of glitches etc.\n" @@ -407,7 +406,7 @@ void DrawSettingsMenu() { } } // END FPS Slider - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { UIWidgets::Spacer(0); if (ImGui::Button("Match Frame Rate to Refresh Rate")) { int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); @@ -421,7 +420,7 @@ void DrawSettingsMenu() { } UIWidgets::Tooltip("Matches interpolation value to the game window's current refresh rate."); - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger(CVAR_SETTING("ExtraLatencyThreshold"), 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", "##ExtraLatencyThreshold", CVAR_SETTING("ExtraLatencyThreshold"), 0, 360, "", 80, true, true, false); UIWidgets::Tooltip( @@ -444,17 +443,16 @@ void DrawSettingsMenu() { UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); static std::unordered_map windowBackendNames = { - { Ship::WindowBackend::DX11, "DirectX" }, - { Ship::WindowBackend::SDL_OPENGL, "OpenGL"}, - { Ship::WindowBackend::SDL_METAL, "Metal" }, - { Ship::WindowBackend::GX2, "GX2"} + { Ship::WindowBackend::FAST3D_DXGI_DX11, "DirectX" }, + { Ship::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL"}, + { Ship::WindowBackend::FAST3D_SDL_METAL, "Metal" } }; ImGui::Text("Renderer API (Needs reload)"); Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend(); Ship::WindowBackend configWindowBackend; int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); - if (configWindowBackendId != -1 && configWindowBackendId < static_cast(Ship::WindowBackend::BACKEND_COUNT)) { + if (Ship::Context::GetInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) { configWindowBackend = static_cast(configWindowBackendId); } else { configWindowBackend = runningWindowBackend; @@ -1086,12 +1084,7 @@ void DrawEnhancementsMenu() { if (ImGui::BeginMenu("Graphics")) { if (ImGui::BeginMenu("Mods")) { - if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", CVAR_ALT_ASSETS, false, false)) { - // 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(CVAR_ALT_ASSETS, !CVarGetInteger(CVAR_ALT_ASSETS, 0)); - ToggleAltAssetsAtEndOfFrame = true; - } + UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", CVAR_ENHANCEMENT("AltAssets"), false, false); 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", CVAR_ENHANCEMENT("DisableBombBillboarding"), true, false); UIWidgets::Tooltip("Disables bombs always rotating to face the camera. To be used in conjunction with mods that want to replace bombs with 3D objects."); diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 8ac676c5557..057f24b6585 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -65,12 +65,11 @@ void SkeletonPatcher::ClearSkeletons() } void SkeletonPatcher::UpdateSkeletons() { - bool isHD = CVarGetInteger(CVAR_ALT_ASSETS, 0); + auto resourceMgr = Ship::Context::GetInstance()->GetResourceManager(); + bool isHD = resourceMgr->IsAltAssetsEnabled(); for (auto skel : skeletons) { Skeleton* newSkel = - (Skeleton*)Ship::Context::GetInstance()->GetResourceManager() - ->LoadResource((isHD ? Ship::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true) - .get(); + (Skeleton*)resourceMgr->LoadResource((isHD ? Ship::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true).get(); if (newSkel != nullptr) { skel.skelAnime->skeleton = newSkel->skeletonData.skeletonHeader.segment; diff --git a/soh/src/code/game.c b/soh/src/code/game.c index f0988c7c39d..aa0670a21ce 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -467,7 +467,7 @@ void GameState_Destroy(GameState* gameState) { // Performing clear skeletons before unload resources fixes an actor heap corruption crash due to the skeleton patching system. ResourceMgr_ClearSkeletons(); - if (CVarGetInteger(CVAR_ALT_ASSETS, 0)) { + if (ResourceMgr_IsAltAssetsEnabled()) { ResourceUnloadDirectory("alt/*"); gfx_texture_cache_clear(); } diff --git a/soh/src/code/gfxprint.c b/soh/src/code/gfxprint.c index 1717e46b3cc..6d8686074eb 100644 --- a/soh/src/code/gfxprint.c +++ b/soh/src/code/gfxprint.c @@ -141,7 +141,7 @@ static const ALIGN_ASSET(2) char rGfxPrintFontDataAlt[] = drGfxPrintFontDataAlt; // https://github.com/HarbourMasters/Shipwright/issues/2762 typedef enum {hardcoded, otrDefault, otrAlt} font_texture_t; font_texture_t GfxPrint_TextureToUse() { - if (CVarGetInteger(CVAR_ALT_ASSETS, 0) && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { + if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { // If we have alt assets enabled, and we have alt prefixed font texture, use that return otrAlt; } else if (ResourceMgr_FileExists(rGfxPrintFontData)) {