Added alt assets

This commit is contained in:
KiritoDv 2024-12-27 23:07:06 -06:00
parent 6869fce01a
commit d0fb09f25c
2 changed files with 11 additions and 6 deletions

View File

@ -45,6 +45,7 @@
namespace fs = std::filesystem; namespace fs = std::filesystem;
extern "C" { extern "C" {
bool prevAltAssets = false;
float gInterpolationStep = 0.0f; float gInterpolationStep = 0.0f;
#include <sf64thread.h> #include <sf64thread.h>
#include <macros.h> #include <macros.h>
@ -172,6 +173,9 @@ GameEngine::GameEngine() {
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinarySoundFontV0>(), RESOURCE_FORMAT_BINARY, loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinarySoundFontV0>(), RESOURCE_FORMAT_BINARY,
"SoundFont", static_cast<uint32_t>(SF64::ResourceType::SoundFont), 0); "SoundFont", static_cast<uint32_t>(SF64::ResourceType::SoundFont), 0);
prevAltAssets = CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0);
context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets);
} }
void GameEngine::Create() { void GameEngine::Create() {
@ -191,8 +195,6 @@ void GameEngine::Destroy() {
free(MemoryPool.memory); free(MemoryPool.memory);
} }
bool ShouldClearTextureCacheAtEndOfFrame = false;
void GameEngine::StartFrame() const { void GameEngine::StartFrame() const {
using Ship::KbScancode; using Ship::KbScancode;
const int32_t dwScancode = this->context->GetWindow()->GetLastScancode(); const int32_t dwScancode = this->context->GetWindow()->GetLastScancode();
@ -201,8 +203,7 @@ void GameEngine::StartFrame() const {
switch (dwScancode) { switch (dwScancode) {
case KbScancode::LUS_KB_TAB: { case KbScancode::LUS_KB_TAB: {
// Toggle HD Assets // Toggle HD Assets
CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); CVarSetInteger("gEnhancements.Mods.AlternateAssets", !CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0));
ShouldClearTextureCacheAtEndOfFrame = true;
break; break;
} }
default: default:
@ -326,9 +327,11 @@ void GameEngine::RunCommands(Gfx* Commands, const std::vector<std::unordered_map
gfx_end_frame(); gfx_end_frame();
} }
if (ShouldClearTextureCacheAtEndOfFrame) { bool curAltAssets = CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0);
if (prevAltAssets != curAltAssets) {
prevAltAssets = curAltAssets;
Ship::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets);
gfx_texture_cache_clear(); gfx_texture_cache_clear();
ShouldClearTextureCacheAtEndOfFrame = false;
} }
} }

View File

@ -371,6 +371,8 @@ void DrawSettingsMenu(){
UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect.");
} }
UIWidgets::PaddedEnhancementCheckbox("Enable Alternative Assets", "gEnhancements.Mods.AlternateAssets");
// If more filters are added to LUS, make sure to add them to the filters list here // If more filters are added to LUS, make sure to add them to the filters list here
ImGui::Text("Texture Filter (Needs reload)"); ImGui::Text("Texture Filter (Needs reload)");