From df0c369678dbfc5c798900dbdaaf91790ea13618 Mon Sep 17 00:00:00 2001 From: Tim <15017472+doodlum@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:27:44 +0000 Subject: [PATCH] chore: better skyrim upscaler compat --- src/Menu.cpp | 50 ++++++++++++++++++++++++++----------------------- src/Upscaling.h | 22 +++++++++++++--------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/Menu.cpp b/src/Menu.cpp index d8e0f171f..880c961d9 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -951,35 +951,39 @@ void Menu::DrawDisableAtBootSettings() void Menu::DrawDisplaySettings() { - auto& themeSettings = Menu::GetSingleton()->settings.Theme; - - const std::vector>> features = { - { "Upscaling", []() { Upscaling::GetSingleton()->DrawSettings(); } }, - { "Frame Generation", []() { Streamline::GetSingleton()->DrawSettings(); } } - }; + if (!State::GetSingleton()->upscalerLoaded) { + auto& themeSettings = Menu::GetSingleton()->settings.Theme; - for (const auto& [featureName, drawFunc] : features) { - bool isDisabled = State::GetSingleton()->IsFeatureDisabled(featureName); + const std::vector>> features = { + { "Upscaling", []() { Upscaling::GetSingleton()->DrawSettings(); } }, + { "Frame Generation", []() { Streamline::GetSingleton()->DrawSettings(); } } + }; - if (featureName == "Frame Generation" && REL::Module::IsVR()) { - isDisabled = true; - } + for (const auto& [featureName, drawFunc] : features) { + bool isDisabled = State::GetSingleton()->IsFeatureDisabled(featureName); - if (!isDisabled) { - if (ImGui::CollapsingHeader(featureName.c_str(), ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) { - drawFunc(); + if (featureName == "Frame Generation" && REL::Module::IsVR()) { + isDisabled = true; } - } else { - ImGui::PushStyleColor(ImGuiCol_Text, themeSettings.StatusPalette.Disable); - ImGui::CollapsingHeader(featureName.c_str(), ImGuiTreeNodeFlags_NoTreePushOnOpen); - ImGui::PopStyleColor(); - if (auto _tt = Util::HoverTooltipWrapper()) { - ImGui::Text( - "%s has been disabled at boot. " - "Reenable in the Advanced -> Disable at Boot Menu.", - featureName.c_str()); + + if (!isDisabled) { + if (ImGui::CollapsingHeader(featureName.c_str(), ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) { + drawFunc(); + } + } else { + ImGui::PushStyleColor(ImGuiCol_Text, themeSettings.StatusPalette.Disable); + ImGui::CollapsingHeader(featureName.c_str(), ImGuiTreeNodeFlags_NoTreePushOnOpen); + ImGui::PopStyleColor(); + if (auto _tt = Util::HoverTooltipWrapper()) { + ImGui::Text( + "%s has been disabled at boot. " + "Reenable in the Advanced -> Disable at Boot Menu.", + featureName.c_str()); + } } } + } else { + ImGui::Text("Display options disabled due to Skyrim Upscaler"); } } diff --git a/src/Upscaling.h b/src/Upscaling.h index 2586ebf43..175c7b1cf 100644 --- a/src/Upscaling.h +++ b/src/Upscaling.h @@ -115,14 +115,18 @@ class Upscaling : public RE::BSTEventSink static void InstallHooks() { - bool isGOG = !std::filesystem::exists(L"steam_api64.dll"); - - stl::write_thunk_call(REL::RelocationID(75460, 77245).address() + REL::Relocate(0xE5, isGOG ? 0x133 : 0xE2, 0x104)); - stl::write_thunk_call(REL::RelocationID(100540, 107270).address() + REL::Relocate(0x3E9, 0x3EA, 0x448)); - stl::write_thunk_call(REL::RelocationID(100540, 107270).address() + REL::Relocate(0x3F3, 0x3F4, 0x452)); - logger::info("[Upscaling] Installed hooks"); - - RE::UI::GetSingleton()->GetEventSource()->AddEventSink(Upscaling::GetSingleton()); - logger::info("[Upscaling] Registered for MenuOpenCloseEvent"); + if (!State::GetSingleton()->upscalerLoaded) { + bool isGOG = !std::filesystem::exists(L"steam_api64.dll"); + + stl::write_thunk_call(REL::RelocationID(75460, 77245).address() + REL::Relocate(0xE5, isGOG ? 0x133 : 0xE2, 0x104)); + stl::write_thunk_call(REL::RelocationID(100540, 107270).address() + REL::Relocate(0x3E9, 0x3EA, 0x448)); + stl::write_thunk_call(REL::RelocationID(100540, 107270).address() + REL::Relocate(0x3F3, 0x3F4, 0x452)); + logger::info("[Upscaling] Installed hooks"); + + RE::UI::GetSingleton()->GetEventSource()->AddEventSink(Upscaling::GetSingleton()); + logger::info("[Upscaling] Registered for MenuOpenCloseEvent"); + } else { + logger::info("[Upscaling] Not installing hooks due to Skyrim Upscaler"); + } } };