Skip to content

Commit

Permalink
update to latest LUS main (HarbourMasters#4202)
Browse files Browse the repository at this point in the history
Includes supporting changes from:
* HarbourMasters#4197 (alt assets variable changes)
* HarbourMasters#4199 (WindowBackend enum changes)
* HarbourMasters#4200 (Extract gMtxClear)

---------

Co-authored-by: Malkierian <malkierian@gmail.com>
Co-authored-by: inspectredc <inspectredc@gmail.com>
  • Loading branch information
3 people authored Jun 2, 2024
1 parent b8c7c71 commit 736dccb
Show file tree
Hide file tree
Showing 27 changed files with 75 additions and 41 deletions.
1 change: 0 additions & 1 deletion CMake/lus-cvars.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down
5 changes: 5 additions & 0 deletions soh/assets/xml/GC_MQ_D/code/sys_matrix.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Root>
<File Name="code" OutName="sys_matrix" RangeStart="0x110CC0" RangeEnd="0x110D00">
<Mtx Name="gMtxClear" Offset="0x110CC0"/>
</File>
</Root>
1 change: 1 addition & 0 deletions soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_scene" Segment="2">
<Texture Name="bdan_sceneTex_013E00" OutName="bdan_sceneTex_013E00" Format="ci8" Width="32" Height="64" Offset="0x13E00" TlutOffset="0x13BF8" AddedByScript="true"/>
<Texture Name="bdan_sceneTex_014600" OutName="bdan_sceneTex_014600" Format="ci8" Width="32" Height="32" Offset="0x14600" TlutOffset="0x13BF8" AddedByScript="true"/>
Expand Down
1 change: 1 addition & 0 deletions soh/assets/xml/GC_MQ_D/scenes/dungeons/bdan_boss.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_boss_scene" Segment="2">
<Scene Name="bdan_boss_scene" Offset="0x0"/>
</File>
Expand Down
5 changes: 5 additions & 0 deletions soh/assets/xml/GC_MQ_PAL_F/code/sys_matrix.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Root>
<File Name="code" OutName="sys_matrix" RangeStart="0xEAD00" RangeEnd="0xEAD40">
<Mtx Name="gMtxClear" Offset="0xEAD00"/>
</File>
</Root>
1 change: 1 addition & 0 deletions soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_scene" Segment="2">
<Texture Name="bdan_sceneTex_013E00" OutName="bdan_sceneTex_013E00" Format="ci8" Width="32" Height="64" Offset="0x13E00" TlutOffset="0x13BF8" AddedByScript="true"/>
<Texture Name="bdan_sceneTex_014600" OutName="bdan_sceneTex_014600" Format="ci8" Width="32" Height="32" Offset="0x14600" TlutOffset="0x13BF8" AddedByScript="true"/>
Expand Down
1 change: 1 addition & 0 deletions soh/assets/xml/GC_MQ_PAL_F/scenes/dungeons/bdan_boss.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_boss_scene" Segment="2">
<Scene Name="bdan_boss_scene" Offset="0x0"/>
</File>
Expand Down
5 changes: 5 additions & 0 deletions soh/assets/xml/GC_NMQ_D/code/sys_matrix.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Root>
<File Name="code" OutName="sys_matrix" RangeStart="0x110CE0" RangeEnd="0x110D20">
<Mtx Name="gMtxClear" Offset="0x110CE0"/>
</File>
</Root>
1 change: 1 addition & 0 deletions soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_scene" Segment="2">
<Texture Name="bdan_sceneTex_013E00" OutName="bdan_sceneTex_013E00" Format="ci8" Width="32" Height="64" Offset="0x13DE0" TlutOffset="0x13BD8" AddedByScript="true"/>
<Texture Name="bdan_sceneTex_014600" OutName="bdan_sceneTex_014600" Format="ci8" Width="32" Height="32" Offset="0x145E0" TlutOffset="0x13BD8" AddedByScript="true"/>
Expand Down
1 change: 1 addition & 0 deletions soh/assets/xml/GC_NMQ_D/scenes/dungeons/bdan_boss.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_boss_scene" Segment="2">
<Scene Name="bdan_boss_scene" Offset="0x0"/>
</File>
Expand Down
5 changes: 5 additions & 0 deletions soh/assets/xml/GC_NMQ_PAL_F/code/sys_matrix.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Root>
<File Name="code" OutName="sys_matrix" RangeStart="0xEAD20" RangeEnd="0xEAD60">
<Mtx Name="gMtxClear" Offset="0xEAD20"/>
</File>
</Root>
1 change: 1 addition & 0 deletions soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_scene" Segment="2">
<Texture Name="bdan_sceneTex_013E00" OutName="bdan_sceneTex_013E00" Format="ci8" Width="32" Height="64" Offset="0x13DE0" TlutOffset="0x13BD8" AddedByScript="true"/>
<Texture Name="bdan_sceneTex_014600" OutName="bdan_sceneTex_014600" Format="ci8" Width="32" Height="32" Offset="0x145E0" TlutOffset="0x13BD8" AddedByScript="true"/>
Expand Down
1 change: 1 addition & 0 deletions soh/assets/xml/GC_NMQ_PAL_F/scenes/dungeons/bdan_boss.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_boss_scene" Segment="2">
<Scene Name="bdan_boss_scene" Offset="0x0"/>
</File>
Expand Down
5 changes: 5 additions & 0 deletions soh/assets/xml/N64_PAL_10/code/sys_matrix.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Root>
<File Name="code" OutName="sys_matrix" RangeStart="0xEB620" RangeEnd="0xEB660">
<Mtx Name="gMtxClear" Offset="0xEB620"/>
</File>
</Root>
1 change: 1 addition & 0 deletions soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_scene" Segment="2">
<Texture Name="bdan_sceneTex_013E00" OutName="bdan_sceneTex_013E00" Format="ci8" Width="32" Height="64" Offset="0x13DE0" TlutOffset="0x13BD8" AddedByScript="true"/>
<Texture Name="bdan_sceneTex_014600" OutName="bdan_sceneTex_014600" Format="ci8" Width="32" Height="32" Offset="0x145E0" TlutOffset="0x13BD8" AddedByScript="true"/>
Expand Down
1 change: 1 addition & 0 deletions soh/assets/xml/N64_PAL_10/scenes/dungeons/bdan_boss.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_boss_scene" Segment="2">
<Scene Name="bdan_boss_scene" Offset="0x0"/>
</File>
Expand Down
5 changes: 5 additions & 0 deletions soh/assets/xml/N64_PAL_11/code/sys_matrix.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Root>
<File Name="code" OutName="sys_matrix" RangeStart="0xEB660" RangeEnd="0xEB6A0">
<Mtx Name="gMtxClear" Offset="0xEB660"/>
</File>
</Root>
1 change: 1 addition & 0 deletions soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_scene" Segment="2">
<Texture Name="bdan_sceneTex_013E00" OutName="bdan_sceneTex_013E00" Format="ci8" Width="32" Height="64" Offset="0x13DE0" TlutOffset="0x13BD8" AddedByScript="true"/>
<Texture Name="bdan_sceneTex_014600" OutName="bdan_sceneTex_014600" Format="ci8" Width="32" Height="32" Offset="0x145E0" TlutOffset="0x13BD8" AddedByScript="true"/>
Expand Down
1 change: 1 addition & 0 deletions soh/assets/xml/N64_PAL_11/scenes/dungeons/bdan_boss.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Root>
<ExternalFile XmlPath="code/sys_matrix.xml" OutPath="code/sys_matrix/"/>
<File Name="bdan_boss_scene" Segment="2">
<Scene Name="bdan_boss_scene" Offset="0x0"/>
</File>
Expand Down
31 changes: 16 additions & 15 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down Expand Up @@ -1145,7 +1146,6 @@ extern "C" void InitOTR() {
GameInteractorSail::Instance = new GameInteractorSail();
#endif

clearMtx = (uintptr_t)&gMtxClear;
OTRMessage_Init();
OTRAudio_Init();
OTRExtScanner();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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<GameInteractor::OnAssetAltChange>();
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions soh/soh/OTRGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion soh/soh/SohGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "Enhancements/resolution-editor/ResolutionEditor.h"
#include "Enhancements/debugger/MessageViewer.h"

bool ToggleAltAssetsAtEndOfFrame = false;
bool isBetaQuestEnabled = false;

extern "C" {
Expand Down
27 changes: 10 additions & 17 deletions soh/soh/SohMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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"
Expand All @@ -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();
Expand All @@ -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(
Expand All @@ -444,17 +443,16 @@ void DrawSettingsMenu() {
UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f);

static std::unordered_map<Ship::WindowBackend, const char*> 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<int>(Ship::WindowBackend::BACKEND_COUNT)) {
if (Ship::Context::GetInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) {
configWindowBackend = static_cast<Ship::WindowBackend>(configWindowBackendId);
} else {
configWindowBackend = runningWindowBackend;
Expand Down Expand Up @@ -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.");
Expand Down
7 changes: 3 additions & 4 deletions soh/soh/resource/type/Skeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion soh/src/code/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion soh/src/code/gfxprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 736dccb

Please sign in to comment.