Add camera distance

This commit is contained in:
2025-09-09 06:18:20 +02:00
parent 3b0b0ea00d
commit 5b5d72585d

View File

@@ -15,6 +15,7 @@ static float aspectRatio = (float)screenWidth / screenHeight;
// Core game dll functions declarations // Core game dll functions declarations
typedef void (*SetBoolFn)(bool, bool); typedef void (*SetBoolFn)(bool, bool);
typedef void (*SetIntFn)(int); typedef void (*SetIntFn)(int);
typedef void (*SetFloatFn)(float);
typedef float (*GetFloatFn)(); typedef float (*GetFloatFn)();
typedef bool (*GetBoolFn)(); typedef bool (*GetBoolFn)();
typedef void (*SetUEConsole)(); typedef void (*SetUEConsole)();
@@ -28,7 +29,9 @@ static SetBoolFn SetAspectRatioFixEnabled = nullptr;
static SetBoolFn SetDOFFixEnabled = nullptr; static SetBoolFn SetDOFFixEnabled = nullptr;
static SetBoolFn SetVignettingFixEnabled = nullptr; static SetBoolFn SetVignettingFixEnabled = nullptr;
static SetBoolFn SetFogFixEnabled = nullptr; static SetBoolFn SetFogFixEnabled = nullptr;
static SetBoolFn SetCameraDistanceFixEnabled = nullptr;
static SetIntFn SetFOV = nullptr; static SetIntFn SetFOV = nullptr;
static SetFloatFn SetCameraDistance = nullptr;
static GetFloatFn GetFOVIn = nullptr; static GetFloatFn GetFOVIn = nullptr;
static GetFloatFn GetCompensadedFOV = nullptr; static GetFloatFn GetCompensadedFOV = nullptr;
static GetFloatFn GetFOVOut = nullptr; static GetFloatFn GetFOVOut = nullptr;
@@ -43,8 +46,10 @@ static bool Aspect_fix_enabled = false;
static bool DOF_fix_enabled = false; static bool DOF_fix_enabled = false;
static bool Vignetting_fix_enabled = false; static bool Vignetting_fix_enabled = false;
static bool Fog_fix_enabled = false; static bool Fog_fix_enabled = false;
static bool camera_Distance_fix_enabled = false;
static bool fix_enabled = false; static bool fix_enabled = false;
static int worldFOVvalue = 0; static int worldFOVvalue = 0;
static float cameraDistancevalue = 0.f;
static bool popup_Informations = false; static bool popup_Informations = false;
@@ -56,9 +61,11 @@ const char* ASPECT_FIX_SETTING = "AspectFIX=";
const char* DOF_FIX_SETTING = "DOFFIX="; const char* DOF_FIX_SETTING = "DOFFIX=";
const char* VIGNETTING_FIX_SETTING = "VignettingFIX="; const char* VIGNETTING_FIX_SETTING = "VignettingFIX=";
const char* FOG_FIX_SETTING = "FogFIX="; const char* FOG_FIX_SETTING = "FogFIX=";
const char* CAMERA_DISTANCE_FIX_SETTING = "CameraDistanceFIX=";
const char* WORLD_FOV_SETTING = "WorldFOV="; const char* WORLD_FOV_SETTING = "WorldFOV=";
const char* FIX_VERSION = "1.0.3"; const char* CAMERA_DISTANCE_SETTING = "CameraDistance=";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Unlock ultrawide resolutions.\n - Remove depth of field.\n - Remove vignetting.\n - Remove fog.\n - Re enable console."; const char* FIX_VERSION = "1.0.4";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Control camera distance.\n - Unlock ultrawide resolutions.\n - Remove depth of field.\n - Remove vignetting.\n - Remove fog.\n - Re enable console.";
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44"; const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
bool IsAlreadyInitialized() bool IsAlreadyInitialized()
@@ -103,7 +110,9 @@ static void LoadFixDLL()
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled"); SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled"); SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogFixEnabled"); SetFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogFixEnabled");
SetCameraDistanceFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCameraDistanceFixEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV"); SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance");
GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn"); GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn");
GetCompensadedFOV = (GetFloatFn)GetProcAddress(fixLib, "GetCompensatedFOV"); GetCompensadedFOV = (GetFloatFn)GetProcAddress(fixLib, "GetCompensatedFOV");
GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut"); GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut");
@@ -112,11 +121,13 @@ static void LoadFixDLL()
// Apply initial values loaded from settings // Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue); if (SetFOV) SetFOV(worldFOVvalue);
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue);
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true); if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, true); if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true); if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true); if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true);
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, true); if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, true);
if (SetCameraDistanceFixEnabled) SetCameraDistanceFixEnabled(camera_Distance_fix_enabled, true);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true); if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
if (SetConsole) SetConsole(); if (SetConsole) SetConsole();
} }
@@ -134,7 +145,9 @@ static void SaveSettings()
file << DOF_FIX_SETTING << (DOF_fix_enabled ? "1" : "0") << "\n"; file << DOF_FIX_SETTING << (DOF_fix_enabled ? "1" : "0") << "\n";
file << VIGNETTING_FIX_SETTING << (Vignetting_fix_enabled ? "1" : "0") << "\n"; file << VIGNETTING_FIX_SETTING << (Vignetting_fix_enabled ? "1" : "0") << "\n";
file << FOG_FIX_SETTING << (Fog_fix_enabled ? "1" : "0") << "\n"; file << FOG_FIX_SETTING << (Fog_fix_enabled ? "1" : "0") << "\n";
file << CAMERA_DISTANCE_FIX_SETTING << (camera_Distance_fix_enabled ? "1" : "0") << "\n";
file << WORLD_FOV_SETTING << worldFOVvalue << "\n"; file << WORLD_FOV_SETTING << worldFOVvalue << "\n";
file << CAMERA_DISTANCE_SETTING << cameraDistancevalue << "\n";
file.close(); file.close();
} }
} }
@@ -177,9 +190,15 @@ static void LoadSettings()
std::string val = line.substr(strlen(FOG_FIX_SETTING)); std::string val = line.substr(strlen(FOG_FIX_SETTING));
Fog_fix_enabled = (val == "1" || val == "true"); Fog_fix_enabled = (val == "1" || val == "true");
} }
else if (line.find(CAMERA_DISTANCE_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(CAMERA_DISTANCE_FIX_SETTING));
camera_Distance_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(WORLD_FOV_SETTING) == 0) else if (line.find(WORLD_FOV_SETTING) == 0)
worldFOVvalue = std::stoi(line.substr(strlen(WORLD_FOV_SETTING))); worldFOVvalue = std::stoi(line.substr(strlen(WORLD_FOV_SETTING)));
else if (line.find(CAMERA_DISTANCE_SETTING) == 0)
cameraDistancevalue = std::stoi(line.substr(strlen(CAMERA_DISTANCE_SETTING)));
} }
file.close(); file.close();
} }
@@ -245,6 +264,20 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
} }
ImGui::EndChild(); ImGui::EndChild();
// Camera distance adjustment
ImGui::SetCursorPos(ImVec2(10, 180));
ImGui::BeginChild("CameraHeader", ImVec2(220, 0), false);
if (ImGui::CollapsingHeader("Camera distance multiplier", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
ImGui::SetNextItemWidth(150.0f);
if (ImGui::SliderFloat("", &cameraDistancevalue, 0, 3)) {}
if (ImGui::IsItemDeactivatedAfterEdit()) {
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue);
SaveSettings();
}
}
ImGui::EndChild();
// Individual fixes // Individual fixes
ImGui::SetCursorPos(ImVec2(240, 60)); ImGui::SetCursorPos(ImVec2(240, 60));
ImGui::BeginChild("IndividualFixesHeader", ImVec2(250, 0), false); ImGui::BeginChild("IndividualFixesHeader", ImVec2(250, 0), false);
@@ -255,6 +288,12 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
SaveSettings(); SaveSettings();
} }
ImGui::SetCursorPos(ImVec2(60, 30));
if (ImGui::Checkbox("Camera distance", &camera_Distance_fix_enabled)) {
if (SetCameraDistanceFixEnabled) SetCameraDistanceFixEnabled(camera_Distance_fix_enabled, false);
SaveSettings();
}
ImGui::SetCursorPos(ImVec2(5, 55)); ImGui::SetCursorPos(ImVec2(5, 55));
if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) { if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) {
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false); if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false);