Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: better skyrim upscaler compat #794

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,35 +951,39 @@ void Menu::DrawDisableAtBootSettings()

void Menu::DrawDisplaySettings()
{
auto& themeSettings = Menu::GetSingleton()->settings.Theme;

const std::vector<std::pair<std::string, std::function<void()>>> 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<std::pair<std::string, std::function<void()>>> 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");
}
}

Expand Down
22 changes: 13 additions & 9 deletions src/Upscaling.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,18 @@ class Upscaling : public RE::BSTEventSink<RE::MenuOpenCloseEvent>

static void InstallHooks()
{
bool isGOG = !std::filesystem::exists(L"steam_api64.dll");

stl::write_thunk_call<Main_UpdateJitter>(REL::RelocationID(75460, 77245).address() + REL::Relocate(0xE5, isGOG ? 0x133 : 0xE2, 0x104));
stl::write_thunk_call<TAA_BeginTechnique>(REL::RelocationID(100540, 107270).address() + REL::Relocate(0x3E9, 0x3EA, 0x448));
stl::write_thunk_call<TAA_EndTechnique>(REL::RelocationID(100540, 107270).address() + REL::Relocate(0x3F3, 0x3F4, 0x452));
logger::info("[Upscaling] Installed hooks");

RE::UI::GetSingleton()->GetEventSource<RE::MenuOpenCloseEvent>()->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<Main_UpdateJitter>(REL::RelocationID(75460, 77245).address() + REL::Relocate(0xE5, isGOG ? 0x133 : 0xE2, 0x104));
stl::write_thunk_call<TAA_BeginTechnique>(REL::RelocationID(100540, 107270).address() + REL::Relocate(0x3E9, 0x3EA, 0x448));
stl::write_thunk_call<TAA_EndTechnique>(REL::RelocationID(100540, 107270).address() + REL::Relocate(0x3F3, 0x3F4, 0x452));
logger::info("[Upscaling] Installed hooks");

RE::UI::GetSingleton()->GetEventSource<RE::MenuOpenCloseEvent>()->AddEventSink(Upscaling::GetSingleton());
logger::info("[Upscaling] Registered for MenuOpenCloseEvent");
} else {
logger::info("[Upscaling] Not installing hooks due to Skyrim Upscaler");
}
}
};