Ultrawide fix improvement. Add effects disabling.
This commit is contained in:
@@ -2,10 +2,14 @@
|
||||
#define IMGUI_HAS_DOCK 1
|
||||
|
||||
#include "CommonHeaders.h"
|
||||
#include "HotkeysManager.h"
|
||||
#include "DirectX.h"
|
||||
#include <thread>
|
||||
|
||||
// Constants
|
||||
constexpr ULONGLONG DECIMA_ENGINE_INIT_DELAY = 6000; // Use to wait for Decima engine to be ready
|
||||
// Screen informations
|
||||
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
// Core game dll functions declarations
|
||||
typedef void (*SetBoolFn)(bool, bool);
|
||||
typedef void (*SetFixesFn)(GameFixes, bool);
|
||||
@@ -13,7 +17,6 @@ typedef void (*SetFloatFn)(GameSetting, float);
|
||||
|
||||
static HMODULE fixLib = nullptr;
|
||||
static LONG g_coreInitialized = 0;
|
||||
static LONG g_Patched = 0;
|
||||
static SetBoolFn SetFixEnabled = nullptr;
|
||||
static SetFixesFn SetFixes = nullptr;
|
||||
static SetFloatFn SetValues = nullptr;
|
||||
@@ -25,9 +28,12 @@ static GetGameInfosStruct GetGameInfos = nullptr;
|
||||
static bool fov_fix_enabled = false;
|
||||
static bool ultrawide_fix_enabled = false;
|
||||
static bool camera_fix_enabled = false;
|
||||
static bool DOF_fix_enabled = false;
|
||||
static bool vignetting_fix_enabled = false;
|
||||
static bool fix_enabled = false;
|
||||
static int worldFOVvalue = 0;
|
||||
static float cameraDistancevalue = 1.f;
|
||||
static int triggerDelayMs = 2000; // Default delay between shortcuts
|
||||
|
||||
// Overlays popups
|
||||
static bool popup_Informations = false;
|
||||
@@ -36,8 +42,8 @@ static std::string log_content;
|
||||
|
||||
// Plugin settings
|
||||
const std::string SETTINGS_FILE = "./pluginsettings.ini";
|
||||
const char* FIX_VERSION = "1.0.2";
|
||||
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Control camera distance.\n - Enable ultrawide.";
|
||||
const char* FIX_VERSION = "1.0.3";
|
||||
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Control camera distance.\n - Enable ultrawide.\n - Disable depth of field in cutscenes.\n - Disable vignetting.";
|
||||
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
|
||||
|
||||
// Scaling factor based on screen resolution
|
||||
@@ -46,13 +52,16 @@ float scale = (float)screenHeight / 1200;
|
||||
// Prepare arrays of checkboxes for ImGui
|
||||
static FixToggle individualFixes[] = {
|
||||
{ "FOV", &fov_fix_enabled, GameFixes::FOV },
|
||||
{ "Ultrawide", &ultrawide_fix_enabled, GameFixes::UltraWide, "This fix is only intended for aspect ratio higher than 32/9.\n"
|
||||
"You will have every run to change aspect ratio in the settings,\n"
|
||||
"from (16/9, 21/9, 32/9) to Auto to have it take effect."},
|
||||
{ "Depth of field", &DOF_fix_enabled, GameFixes::DOF },
|
||||
{ "Vignetting", &vignetting_fix_enabled, GameFixes::Vignetting },
|
||||
{ "Ultrawide", &ultrawide_fix_enabled, GameFixes::UltraWide, "This fix targets aspect ratios wider than 32:9.\n"
|
||||
"It forces the engine to redraw the aspect by simulating shortcuts.\n"
|
||||
"Use the threshold slider below to fine tune the delay between simulated shortcuts.\n"
|
||||
"Increase the delay on slower PCs, decrease it on faster ones."},
|
||||
{ "Camera", &camera_fix_enabled, GameFixes::Camera } };
|
||||
|
||||
// Prepare array of sliders for ImGui
|
||||
static SliderFix2 sliders[2];
|
||||
static SliderFix2 sliders[3];
|
||||
|
||||
// Load and unload game core dll functions /!\ necessary
|
||||
static void LoadFixDLL(reshade::api::effect_runtime* runtime) {
|
||||
@@ -81,11 +90,15 @@ static void LoadFixDLL(reshade::api::effect_runtime* runtime) {
|
||||
if (SetFixes) {
|
||||
SetFixes(GameFixes::FOV, fov_fix_enabled);
|
||||
SetFixes(GameFixes::Camera, camera_fix_enabled);
|
||||
SetFixes(GameFixes::DOF, DOF_fix_enabled);
|
||||
SetFixes(GameFixes::Vignetting, vignetting_fix_enabled);
|
||||
}
|
||||
|
||||
sliders[0] = { "In game additional FOV", "##FOVValue", SliderType::Int, &worldFOVvalue, -20, 50, GameSetting::FOV, SetValues };
|
||||
sliders[1] = { "Camera distance", "##CamValue", SliderType::Float, &cameraDistancevalue, 0, 5, GameSetting::CameraDistance, SetValues, "%.1f",
|
||||
"Value is a multiplier.\nFinal value reported below is in meters."};
|
||||
sliders[2] = { "Ultrawide enforce delay", "##AltEnterValue", SliderType::Int, &triggerDelayMs, 1000, 5000, GameSetting::Threshold, SetValues, "",
|
||||
"This value is a threshold in ms between the simulated alt + enter." };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,10 +110,13 @@ static void SaveSettings() {
|
||||
" ",
|
||||
"Controls if fix mod (globally) is enabled" });
|
||||
pluginIniFile["1#General fix"]["Enabled"] = fix_enabled;
|
||||
pluginIniFile["1#General fix"]["TriggerDelayMs"] = triggerDelayMs;
|
||||
pluginIniFile["2#Individual fix"].setComment("Controls each fix individually");
|
||||
pluginIniFile["2#Individual fix"]["FOV"] = fov_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["UltraWide"] = ultrawide_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["Camera"] = camera_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["DOF"] = DOF_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["Vignetting"] = vignetting_fix_enabled;
|
||||
pluginIniFile["3#Fixes tuning"].setComment("Individual fix fine tune");
|
||||
pluginIniFile["3#Fixes tuning"]["World FOV"] = worldFOVvalue;
|
||||
pluginIniFile["3#Fixes tuning"]["Camera distance"] = cameraDistancevalue;
|
||||
@@ -113,9 +129,12 @@ static void LoadSettings() {
|
||||
try {
|
||||
pluginIniFile.load(SETTINGS_FILE);
|
||||
fix_enabled = pluginIniFile["1#General fix"]["Enabled"].as<bool>();
|
||||
triggerDelayMs = pluginIniFile["1#General fix"]["TriggerDelayMs"].as<int>();
|
||||
fov_fix_enabled = pluginIniFile["2#Individual fix"]["FOV"].as<bool>();
|
||||
ultrawide_fix_enabled = pluginIniFile["2#Individual fix"]["UltraWide"].as<bool>();
|
||||
camera_fix_enabled = pluginIniFile["2#Individual fix"]["Camera"].as<bool>();
|
||||
DOF_fix_enabled = pluginIniFile["2#Individual fix"]["DOF"].as<bool>();
|
||||
vignetting_fix_enabled = pluginIniFile["2#Individual fix"]["Vignetting"].as<bool>();
|
||||
worldFOVvalue = pluginIniFile["3#Fixes tuning"]["World FOV"].as<int>();
|
||||
cameraDistancevalue = pluginIniFile["3#Fixes tuning"]["Camera distance"].as<float>();
|
||||
}
|
||||
@@ -191,9 +210,11 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime) {
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
DrawFixCheckbox(individualFixes[0]);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
DrawFixCheckbox(individualFixes[1]);
|
||||
DrawFixCheckbox(individualFixes[2]);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
DrawFixCheckbox(individualFixes[3]);
|
||||
DrawFixCheckbox(individualFixes[4]);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
@@ -208,6 +229,7 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime) {
|
||||
DrawSlider2(sliders[0], 200);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
DrawSlider2(sliders[1], 200);
|
||||
DrawSlider2(sliders[2], 200);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
@@ -228,14 +250,33 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime) {
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
static std::atomic<bool> g_Started{ false };
|
||||
static std::atomic<bool> g_Done{ false };
|
||||
static void on_present(reshade::api::command_queue* queue, reshade::api::swapchain* swapchain,
|
||||
const reshade::api::rect* source_rect, const reshade::api::rect* dest_rect,
|
||||
uint32_t dirty_rect_count, const reshade::api::rect* dirty_rects) {
|
||||
if (InterlockedCompareExchange(&g_Patched, 1, 0) != 0) return;
|
||||
if (SetFixes) {
|
||||
SetFixes(GameFixes::UltraWide, true);
|
||||
SetFixes(GameFixes::None, false);
|
||||
}
|
||||
const reshade::api::rect*, const reshade::api::rect*, uint32_t, const reshade::api::rect*) {
|
||||
if (!ultrawide_fix_enabled || g_Done || !SetFixes || g_Started.exchange(true)) return;
|
||||
|
||||
void* hwnd = swapchain->get_hwnd(); // Retrieve DX12 swapchain
|
||||
HWND hwnd_local = reinterpret_cast<HWND>(hwnd);
|
||||
bool exclusive = IsExclusiveFullscreen(swapchain); // Retrieve display mode (fullscreen or exclusive fullscreen)
|
||||
|
||||
SetFixes(GameFixes::UltraWide, ultrawide_fix_enabled);
|
||||
SetFixes(GameFixes::None, false);
|
||||
|
||||
std::thread([hwnd_local, exclusive]() {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(DECIMA_ENGINE_INIT_DELAY)); // Wait for Decima engine to be ready
|
||||
if (!exclusive) {
|
||||
SimulateAltEnter(); // 1st Alt+Enter
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(triggerDelayMs)); // Give enough time to swapchain rebuild
|
||||
SimulateAltEnter(); // 2nd Alt+Enter
|
||||
}
|
||||
else {
|
||||
SimulateAltTab(); // Simulate ALT+Tab
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(triggerDelayMs));
|
||||
ShowWindow(hwnd_local, SW_RESTORE); // Restore game window
|
||||
}
|
||||
g_Done = true;
|
||||
}).detach();
|
||||
}
|
||||
|
||||
// Main dll intrance
|
||||
|
||||
Reference in New Issue
Block a user