diff --git a/data/plugins/GTAIV.EFLC.FusionFix.ini b/data/plugins/GTAIV.EFLC.FusionFix.ini index 2f61fd7e..dc5430ef 100644 --- a/data/plugins/GTAIV.EFLC.FusionFix.ini +++ b/data/plugins/GTAIV.EFLC.FusionFix.ini @@ -5,6 +5,7 @@ BorderlessWindowed = 1 RecoilFix = 1 AimingZoomFix = 1 MotionBlur = 0 // used by main menu toggle, do not modify +Bloom = 1 // used by main menu toggle, do not modify Definition = 6 // used by main menu toggle, do not modify [SHADOWS] @@ -32,7 +33,7 @@ MouseFix = 1 ScreenFilter = 5 // used by main menu toggle, do not modify DistantBlur = 9 // used by main menu toggle, do not modify DepthOfField = 1 // used by main menu toggle, do not modify -FixRainDrops = 0 +FixRainDrops = 1 RainDropsBlur = 2 // 1, 2 or 4 only TreeLighting = 6 // used by main menu toggle, do not modify LightSyncRGB = 0 // used by main menu toggle, do not modify | Only Logitech hardware is supported, requires Logitech G HUB app diff --git a/data/update/TBoGT/common/data/frontend_menus.xml b/data/update/TBoGT/common/data/frontend_menus.xml index b91306fc..fbab548f 100644 --- a/data/update/TBoGT/common/data/frontend_menus.xml +++ b/data/update/TBoGT/common/data/frontend_menus.xml @@ -576,6 +576,7 @@ displayValue="MENU_DISPLAY_ON_OFF" /> + diff --git a/data/update/TLAD/common/data/frontend_menus.xml b/data/update/TLAD/common/data/frontend_menus.xml index 68cd1153..714d4a11 100644 --- a/data/update/TLAD/common/data/frontend_menus.xml +++ b/data/update/TLAD/common/data/frontend_menus.xml @@ -608,6 +608,7 @@ + diff --git a/data/update/common/data/frontend_menus.xml b/data/update/common/data/frontend_menus.xml index 3d0b54d0..bcc412c6 100644 --- a/data/update/common/data/frontend_menus.xml +++ b/data/update/common/data/frontend_menus.xml @@ -480,6 +480,7 @@ + diff --git a/source/dllmain.cpp b/source/dllmain.cpp index 859774c6..75cdfae1 100644 --- a/source/dllmain.cpp +++ b/source/dllmain.cpp @@ -51,23 +51,23 @@ void Init() FusionFix::onInitEvent().executeAll(); } +HRESULT CALLBACK TaskDialogCallbackProc(HWND hwnd, UINT uNotification, WPARAM wParam, LPARAM lParam, LONG_PTR dwRefData) +{ + switch (uNotification) + { + case TDN_HYPERLINK_CLICKED: + ShellExecuteW(hwnd, L"open", (LPCWSTR)lParam, NULL, NULL, SW_SHOW); + break; + } + + return S_OK; +} + void XliveCompat() { if (GetProcAddress(GetModuleHandleW(L"xlive"), "IsUltimateASILoader") != NULL) return; - auto TaskDialogCallbackProc = [](HWND hwnd, UINT uNotification, WPARAM wParam, LPARAM lParam, LONG_PTR dwRefData) -> HRESULT - { - switch (uNotification) - { - case TDN_HYPERLINK_CLICKED: - ShellExecuteW(hwnd, L"open", (LPCWSTR)lParam, NULL, NULL, SW_SHOW); - break; - } - - return S_OK; - }; - TASKDIALOGCONFIG tdc = { sizeof(TASKDIALOGCONFIG) }; int nClickedBtn; BOOL bCheckboxChecked; @@ -95,6 +95,43 @@ void XliveCompat() TerminateProcess(GetCurrentProcess(), 0); } +void UALCompat() +{ + ModuleList dlls; + dlls.Enumerate(ModuleList::SearchLocation::LocalOnly); + for (auto& e : dlls.m_moduleList) + { + auto m = std::get(e); + if (GetProcAddress(m, "IsUltimateASILoader") != NULL) + return; + } + + TASKDIALOGCONFIG tdc = { sizeof(TASKDIALOGCONFIG) }; + int nClickedBtn; + BOOL bCheckboxChecked; + LPCWSTR + szTitle = L"GTAIV.EFLC.FusionFix", + szHeader = L"You are running GTA IV The Complete Edition Fusion Fix with an incompatible version of ASI Loader", + szContent = L"It requires the latest version of " \ + L"Ultimate ASI Loader\n\n" \ + L"https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/latest"; + TASKDIALOG_BUTTON aCustomButtons[] = { { 1000, L"Close the program" } }; + + tdc.hwndParent = gWnd; + tdc.dwFlags = TDF_USE_COMMAND_LINKS | TDF_ENABLE_HYPERLINKS | TDF_SIZE_TO_CONTENT | TDF_CAN_BE_MINIMIZED; + tdc.pButtons = aCustomButtons; + tdc.cButtons = _countof(aCustomButtons); + tdc.pszWindowTitle = szTitle; + tdc.pszMainIcon = TD_INFORMATION_ICON; + tdc.pszMainInstruction = szHeader; + tdc.pszContent = szContent; + tdc.pfCallback = TaskDialogCallbackProc; + tdc.lpCallbackData = 0; + + auto hr = TaskDialogIndirect(&tdc, &nClickedBtn, NULL, &bCheckboxChecked); + TerminateProcess(GetCurrentProcess(), 0); +} + extern "C" { void __declspec(dllexport) InitializeASI() @@ -103,6 +140,7 @@ extern "C" { CallbackHandler::RegisterCallback(Init, hook::pattern("F3 0F 10 44 24 ? F3 0F 59 05 ? ? ? ? EB ? E8")); CallbackHandler::RegisterCallback(L"xlive.dll", XliveCompat); + UALCompat(); }); } } diff --git a/source/settings.ixx b/source/settings.ixx index 697cc633..6488e394 100644 --- a/source/settings.ixx +++ b/source/settings.ixx @@ -113,6 +113,7 @@ public: { 0, "PREF_MOTIONBLUR", "MAIN", "MotionBlur", "" , 0, nullptr, 0, 1 }, { 0, "PREF_LEDILLUMINATION", "MISC", "LightSyncRGB", "" , 0, nullptr, 0, 1 }, { 0, "PREF_DEFINITION", "MAIN", "Definition", "MENU_DISPLAY_DEFINITION" , 1, nullptr, DefinitionText.eClassic, std::distance(std::begin(DefinitionText.data), std::end(DefinitionText.data)) - 1 }, + { 0, "PREF_BLOOM", "MAIN", "Bloom", "" , 0, nullptr, 0, 1 }, }; auto i = firstCustomID; diff --git a/source/shaders.ixx b/source/shaders.ixx index e1bab72e..7b213ea0 100644 --- a/source/shaders.ixx +++ b/source/shaders.ixx @@ -72,16 +72,6 @@ public: static auto dw11A2948 = *find_pattern("C7 05 ? ? ? ? ? ? ? ? 0F 85 ? ? ? ? 6A 00", "D8 05 ? ? ? ? D9 1D ? ? ? ? 83 05").get_first(2); static auto dw103E49C = *hook::get_pattern("A3 ? ? ? ? C7 80", 1); - FusionFix::D3D9::onBeforeCreateDevice() += [](LPDIRECT3D9& pDirect3D9, UINT& Adapter, D3DDEVTYPE& DeviceType, HWND& hFocusWindow, DWORD& BehaviorFlags, D3DPRESENT_PARAMETERS*& pPresentationParameters, IDirect3DDevice9**& ppReturnedDeviceInterface) - { - pHDRTexQuarter = nullptr; - }; - - FusionFix::D3D9::onBeforeReset() += [](LPDIRECT3DDEVICE9& pDevice, D3DPRESENT_PARAMETERS*& pPresentationParameters) - { - pHDRTexQuarter = nullptr; - }; - FusionFix::D3D9::onBeginScene() += [](LPDIRECT3DDEVICE9 pDevice) { if (*dw103E49C) @@ -207,6 +197,47 @@ public: pTexture = pHDRTexQuarter; } }; + + FusionFix::D3D9::onBeforeCreateDevice() += [](LPDIRECT3D9& pDirect3D9, UINT& Adapter, D3DDEVTYPE& DeviceType, HWND& hFocusWindow, DWORD& BehaviorFlags, D3DPRESENT_PARAMETERS*& pPresentationParameters, IDirect3DDevice9**& ppReturnedDeviceInterface) + { + pHDRTexQuarter = nullptr; + }; + + FusionFix::D3D9::onBeforeReset() += [](LPDIRECT3DDEVICE9& pDevice, D3DPRESENT_PARAMETERS*& pPresentationParameters) + { + pHDRTexQuarter = nullptr; + }; + + if (bFixRainDrops) + { + pattern = hook::pattern("A1 ? ? ? ? 50 8B 08 FF 51 40"); + if (!pattern.empty()) + { + static auto Direct3DDevice = *pattern.get_first(1); + struct AuxBeforeResetHook + { + void operator()(injector::reg_pack& regs) + { + regs.eax = *Direct3DDevice; + pHDRTexQuarter = nullptr; + } + }; injector::MakeInline(pattern.get_first(0)); + } + else + { + pattern = hook::pattern("8B 08 8B 51 40 68 ? ? ? ? 50 FF D2 8B"); + struct AuxBeforeResetHook + { + void operator()(injector::reg_pack& regs) + { + regs.ecx = *(uint32_t*)regs.eax; + regs.edx = *(uint32_t*)(regs.ecx + 0x40); + + pHDRTexQuarter = nullptr; + } + }; injector::MakeInline(pattern.get_first(0)); + } + } }; }; } Shaders; \ No newline at end of file diff --git a/source/timecyc.ixx b/source/timecyc.ixx index fef584d0..4ac9f495 100644 --- a/source/timecyc.ixx +++ b/source/timecyc.ixx @@ -47,6 +47,9 @@ int timecyc_scanf(const char* i, const char* fmt, int* mAmbient0ColorR, int* mAm unusedParam10, mSunSize, mUnknown46, mDOFStart, unusedParam11, unusedParam12, mNearDOFBlur, mFarDOFBlur, mWaterReflectionMultiplier, mParticleBrightness, mCoronaSize, mSkyBrightness, mAOStrength, mRimLightingMultiplier, mDistantCoronaBrightness, mDistantCoronaSize, mPedAOStrength); + if (!FusionFixSettings("PREF_BLOOM")) + *mBloomIntensity = 0.0f; + switch (FusionFixSettings("PREF_TCYC_DOF")) { case FusionFixSettings.DofText.eOff: @@ -321,6 +324,16 @@ public: bTimecycUpdated = 200; }); + FusionFixSettings.SetCallback("PREF_BLOOM", [](int32_t value) { + injector::fastcall::call(CTimeCycleInitialise); + bTimecycUpdated = 200; + }); + + FusionFixSettings.SetCallback("PREF_SHADOW_QUALITY", [](int32_t value) { + injector::fastcall::call(CTimeCycleInitialise); + bTimecycUpdated = 200; + }); + // z-fighting fix helpers { auto pattern = hook::pattern("E8 ? ? ? ? 6A 0C E8 ? ? ? ? 8B 0D");