From bc71ba52b032a85b92c99b8ccd5e262ebddb55eb Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Sat, 3 Feb 2024 12:29:58 +0100 Subject: [PATCH] VR-compatible build --- source/Enderal DLL/src/Main.cpp | 53 ++++++++++--------- .../src/Patches/StayAtSystemPage.h | 4 +- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/source/Enderal DLL/src/Main.cpp b/source/Enderal DLL/src/Main.cpp index 436dc9b4..63afb955 100644 --- a/source/Enderal DLL/src/Main.cpp +++ b/source/Enderal DLL/src/Main.cpp @@ -48,21 +48,23 @@ namespace { GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) { if (message->type == MessagingInterface::kPostLoad) { - if (g_settings.at("StayAtSystemPage")) { - if (const auto pluginInfo = GetLoadInterface()->GetPluginInfo("StayAtSystemPage"); pluginInfo) { - MessageBoxW(NULL, L"Stay At The System Page is already included in Enderal, please, disable it.", L"Enderal SE Error", MB_OK | MB_ICONERROR); - exit(EXIT_FAILURE); + if (!REL::Module::IsVR()) { + if (g_settings.at("StayAtSystemPage")) { + if (const auto pluginInfo = GetLoadInterface()->GetPluginInfo("StayAtSystemPage"); pluginInfo) { + MessageBoxW(NULL, L"Stay At The System Page is already included in Enderal, please, disable it.", L"Enderal SE Error", MB_OK | MB_ICONERROR); + exit(EXIT_FAILURE); + } } - } - if (g_settings.at("FlatMapMarkers")) { - if (const auto pluginInfo = GetLoadInterface()->GetPluginInfo("FlatMapMarkersSSE"); pluginInfo) { - MessageBoxW(NULL, L"Flat Map Markers is already included in Enderal, please, disable it (remove file Data\\SKSE\\Plugins\\FlatMapMarkersSSE.dll).", L"Enderal SE Error", MB_OK | MB_ICONERROR); - exit(EXIT_FAILURE); + if (g_settings.at("FlatMapMarkers")) { + if (const auto pluginInfo = GetLoadInterface()->GetPluginInfo("FlatMapMarkersSSE"); pluginInfo) { + MessageBoxW(NULL, L"Flat Map Markers is already included in Enderal, please, disable it (remove file Data\\SKSE\\Plugins\\FlatMapMarkersSSE.dll).", L"Enderal SE Error", MB_OK | MB_ICONERROR); + exit(EXIT_FAILURE); + } + } + if (g_settings.at("MapMarkerPlacementFixes")) { + logger::info("Initializing map market placement fixes..."); + MapMarkerPlacement::Install(); } - } - if (g_settings.at("MapMarkerPlacementFixes")) { - logger::info("Initializing map market placement fixes..."); - MapMarkerPlacement::Install(); } } else if (message->type == MessagingInterface::kDataLoaded) { if (REL::Module::get().version() > REL::Version(1, 5, 97, 0)) { @@ -157,13 +159,10 @@ SKSEPluginLoad(const LoadInterface* skse) { auto version = plugin->GetVersion(); logger::info("{} {} is loading...", plugin->GetName(), version); - LoadINI(&g_settings, "Data/SKSE/Plugins/EnderalSE.ini"); - Init(skse); InitializeMessaging(); RE::INISettingCollection::GetSingleton()->GetSetting("sIntroSequence:General")->data.s = nullptr; - RE::INISettingCollection::GetSingleton()->GetSetting("bModManagerMenuEnabled:General")->data.b = false; EventListener::Install(); @@ -174,17 +173,21 @@ SKSEPluginLoad(const LoadInterface* skse) { TweenMenuPatch::Install(); HUDMenuPatch::Install(); - if (g_settings.at("VideoInterruptPatch")) { - logger::info("Making videos interruptible..."); - BinkInterruptPatch::Install(); - } + if (!REL::Module::IsVR()) { + LoadINI(&g_settings, "Data/SKSE/Plugins/EnderalSE.ini"); - if (g_settings.at("AchievementFix")) { - logger::info("Patching achievements..."); - AchievementFix::Install(); - } + RE::INISettingCollection::GetSingleton()->GetSetting("bModManagerMenuEnabled:General")->data.b = false; + + if (g_settings.at("AchievementFix")) { + logger::info("Patching achievements..."); + AchievementFix::Install(); + } + + if (g_settings.at("VideoInterruptPatch")) { + logger::info("Making videos interruptible..."); + BinkInterruptPatch::Install(); + } - if (!REL::Module::IsVR()) { if (g_settings.at("ForceBorderless")) { ForceBorderless::Install(); } diff --git a/source/Enderal DLL/src/Patches/StayAtSystemPage.h b/source/Enderal DLL/src/Patches/StayAtSystemPage.h index 21e90e7d..36acd195 100644 --- a/source/Enderal DLL/src/Patches/StayAtSystemPage.h +++ b/source/Enderal DLL/src/Patches/StayAtSystemPage.h @@ -21,11 +21,14 @@ public: RE::UI_MESSAGE_RESULTS Hook_ProcessMessage(RE::UIMessage& a_message) { + static REL::Relocation _savedTabIdx{ REL::RelocationID(520167, 406697) }; + switch (a_message.type.get()) { case RE::UI_MESSAGE_TYPE::kShow: { auto UI = RE::UI::GetSingleton(); auto InterfaceStrings = RE::InterfaceStrings::GetSingleton(); + if (UI && InterfaceStrings && UI->IsMenuOpen(InterfaceStrings->mapMenu)) { *_savedTabIdx = Tab::kQuest; } else { @@ -54,5 +57,4 @@ public: static inline REL::Relocation _Accept; static inline REL::Relocation _ProcessMessage; - static inline REL::Relocation _savedTabIdx{ REL::RelocationID(520167, 406697) }; };