From 7de86a9f2bcf4e25101487b9cdfb48270996693a Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Wed, 12 Jun 2024 01:29:00 +0800 Subject: [PATCH] focus loss option --- data/update/TBoGT/common/data/frontend_menus.xml | 2 ++ data/update/TLAD/common/data/frontend_menus.xml | 1 + data/update/common/data/frontend_menus.xml | 2 ++ source/comvars.ixx | 4 ++++ source/settings.ixx | 1 + source/windowed.ixx | 11 +++++++++++ 6 files changed, 21 insertions(+) diff --git a/data/update/TBoGT/common/data/frontend_menus.xml b/data/update/TBoGT/common/data/frontend_menus.xml index 03e937a0..c167211e 100644 --- a/data/update/TBoGT/common/data/frontend_menus.xml +++ b/data/update/TBoGT/common/data/frontend_menus.xml @@ -438,6 +438,7 @@ + @@ -1188,6 +1189,7 @@ + diff --git a/data/update/TLAD/common/data/frontend_menus.xml b/data/update/TLAD/common/data/frontend_menus.xml index 6e4d6582..6ab0a27e 100644 --- a/data/update/TLAD/common/data/frontend_menus.xml +++ b/data/update/TLAD/common/data/frontend_menus.xml @@ -513,6 +513,7 @@ + diff --git a/data/update/common/data/frontend_menus.xml b/data/update/common/data/frontend_menus.xml index d41eea4b..ca20e2cd 100644 --- a/data/update/common/data/frontend_menus.xml +++ b/data/update/common/data/frontend_menus.xml @@ -373,6 +373,7 @@ + @@ -826,6 +827,7 @@ + diff --git a/source/comvars.ixx b/source/comvars.ixx index 3d995be7..cc5e22c0 100644 --- a/source/comvars.ixx +++ b/source/comvars.ixx @@ -24,6 +24,7 @@ export uint32_t* rage__scrProgram__ms_pGlobalsSize; export bool* rage__grcWindow__ms_bWindowed; export bool* rage__grcWindow__ms_bOnTop; export bool* rage__grcWindow__ms_bFocusLost; +export bool* grcDevice__ms_bNoBlockOnLostFocus; export uint32_t* CCutscenes__m_dwCutsceneState; export void* (__stdcall* getNativeAddress)(uint32_t); export float* fTimeStep; @@ -189,6 +190,9 @@ public: pattern = find_pattern("C6 05 ? ? ? ? ? 85 C0 74 02 FF D0 E8", "C6 05 ? ? ? ? ? 74 02 FF D0 C6 05"); rage__grcWindow__ms_bFocusLost = *pattern.get_first(2); + + pattern = find_pattern("80 3D ? ? ? ? ? 74 29 80 3D ? ? ? ? ? 75 1A", "80 3D ? ? ? ? ? 74 2F 80 3D ? ? ? ? ? 75 20"); + grcDevice__ms_bNoBlockOnLostFocus = *pattern.get_first(2); }; } } Common; \ No newline at end of file diff --git a/source/settings.ixx b/source/settings.ixx index de30d019..13824266 100644 --- a/source/settings.ixx +++ b/source/settings.ixx @@ -167,6 +167,7 @@ public: { 0, "PREF_PILLARBOX", "MISC", "Pillarbox", "", 1, nullptr, 0, 1 }, { 0, "PREF_ANTIALIASING", "MISC", "Antialiasing", "MENU_DISPLAY_ANTIALIASING", 1, nullptr, AntialiasingText.eMO_OFF, std::distance(std::begin(AntialiasingText.data), std::end(AntialiasingText.data)) - 1 }, { 0, "PREF_UPDATE", "UPDATE", "CheckForUpdates", "", 0, nullptr, 0, 1 }, + { 0, "PREF_BLOCKONLOSTFOCUS", "MAIN", "BlockOnLostFocus", "", 0, nullptr, 0, 1 }, // Enums are at capacity, to use more enums, replace multiplayer ones. On/Off toggles should still be possible to add. }; diff --git a/source/windowed.ixx b/source/windowed.ixx index 187a4536..e032fb4a 100644 --- a/source/windowed.ixx +++ b/source/windowed.ixx @@ -189,6 +189,17 @@ public: // Do not process input on focus loss pattern = find_pattern("E8 ? ? ? ? A1 ? ? ? ? A3 ? ? ? ? A1 ? ? ? ? 83 C4 04", "E8 ? ? ? ? 8B 0D ? ? ? ? 8B 15 ? ? ? ? 83 C4 04 83 3D"); hbsub_7870A0.fun = injector::MakeCALL(pattern.get_first(), sub_69F0C0).get(); + + FusionFixSettings.SetCallback("PREF_BLOCKONLOSTFOCUS", [](int32_t value) { + *grcDevice__ms_bNoBlockOnLostFocus = value; + }); + + pattern = find_pattern("B9 ? ? ? ? 66 23 C1 68", "66 25 FF 03 0F B7 C8"); + static auto NoBlockOnLostFocusHook = safetyhook::create_mid(pattern.get_first(), + [](SafetyHookContext& ctx) + { + *grcDevice__ms_bNoBlockOnLostFocus = FusionFixSettings.Get("PREF_BLOCKONLOSTFOCUS"); + }); }; } } Windowed; \ No newline at end of file