Add cutscenes framerate unlock. Fog fix rewritten

This commit is contained in:
2026-01-15 18:57:45 +01:00
parent f5532b0ebb
commit a9bacaab05

View File

@@ -1,12 +1,7 @@
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
#define IMGUI_HAS_DOCK 1
#include "GameInformations.h"
#include "GameFixes.h"
#include "inicpp.h"
#include <imgui.h>
#include <reshade.hpp>
#include <string>
#include "CommonHeaders.h"
#include <Windows.h>
// Screen informations
@@ -23,14 +18,19 @@ typedef void (*SetFloatFn)(float);
static HMODULE fixLib = nullptr;
static LONG g_coreInitialized = 0;
static SetBoolFn SetFixEnabled = nullptr;
static SetFixesFn SetFixesEnabled = nullptr;
static SetFixesFn SetFixes = nullptr;
static SetIntFn SetFOV = nullptr;
static SetFloatFn SetCameraDistance = nullptr;
static SetFloatFn SetFogDensity = nullptr;
static SetFloatFn SetFogMaxOpacity = nullptr;
static GetGameInfosStruct GetGameInfos = nullptr;
void SetFixesEnabled(GameFixes fix, bool value) { if (SetFixes) SetFixes(fix, value); }
// Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false;
static bool ultrawide_fix_enabled = false;
static bool cutscenes_FPS_fix_enabled = false;
static bool camera_fix_enabled = false;
static bool DOF_fix_enabled = false;
static bool CA_fix_enabled = false;
@@ -40,6 +40,8 @@ static bool fix_enabled = false;
static bool console = true;
static int worldFOVvalue = 0.f;
static float CameraDistancevalue = 1.f;
static float fogDensityValue = 0.15f;
static float fogMaxOpacityValue = 1.f;
// Overlays popups
static bool popup_Informations = false;
@@ -48,12 +50,26 @@ static std::string log_content;
// Plugin settings
const std::string SETTINGS_FILE = "./pluginsettings.ini";
const char* FIX_VERSION = "1.0.1";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Enable ultrawide in custcenes.\n - Control camera distance.\n - Disable depth of field.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Disable fog.\n - Re enable dev console.";
const char* FIX_VERSION = "1.0.2";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Enable ultrawide in custcenes.\n - Unlock cutscenes framerate.\n - Control camera distance.\n - Disable depth of field.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Disable fog.\n - Re enable dev console.";
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
// Prepare arrays of checkboxes for ImGui
static FixToggle individualFixes[] = {
{ "FOV", &fov_fix_enabled, GameFixes::FOV },
{ "Ultrawide", &ultrawide_fix_enabled, GameFixes::UltraWide, "This fix is intended for ultrawide displays only (21/9, 32/9 ...)."},
{ "Vignetting", &Vignetting_fix_enabled, GameFixes::Vignetting },
{ "Fog", &Fog_fix_enabled, GameFixes::Fog },
{ "Cutscenes FPS", &cutscenes_FPS_fix_enabled, GameFixes::Framerate, "Unlock cutscenes up to 240 FPS"},
{ "Camera distance", &camera_fix_enabled, GameFixes::Camera },
{ "Depth of field", &DOF_fix_enabled, GameFixes::DOF },
{ "Chromatic aberrations", &CA_fix_enabled, GameFixes::ChromaticAberrations }
};
// Scaling factor based on screen resolution
float scale = (float)screenHeight / 1200;
// Prepare array of sliders for ImGui
static SliderFix sliders[4];
// Load and unload game core dll functions /!\ necessary
static void LoadFixDLL()
@@ -70,25 +86,37 @@ static void LoadFixDLL()
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFixesEnabled = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled");
SetFixes = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance");
SetFogDensity = (SetFloatFn)GetProcAddress(fixLib, "SetFogDensity");
SetFogMaxOpacity = (SetFloatFn)GetProcAddress(fixLib, "SetFogMaxOpacity");
GetGameInfos = (GetGameInfosStruct)GetProcAddress(fixLib, "GetGameInfos");
// Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue);
if (SetCameraDistance) SetCameraDistance(CameraDistancevalue);
if (SetFogDensity) SetFogDensity(fogDensityValue);
if (SetFogMaxOpacity) SetFogMaxOpacity(fogMaxOpacityValue);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
if (SetFixesEnabled) {
SetFixesEnabled(GameFixes::FOV, fov_fix_enabled);
SetFixesEnabled(GameFixes::UltraWide, ultrawide_fix_enabled);
SetFixesEnabled(GameFixes::Camera, camera_fix_enabled);
SetFixesEnabled(GameFixes::DOF, DOF_fix_enabled);
SetFixesEnabled(GameFixes::ChromaticAberrations, CA_fix_enabled);
SetFixesEnabled(GameFixes::Vignetting, Vignetting_fix_enabled);
SetFixesEnabled(GameFixes::Fog, Fog_fix_enabled);
SetFixesEnabled(GameFixes::DevConsole, console);
if (SetFixes) {
SetFixes(GameFixes::FOV, fov_fix_enabled);
SetFixes(GameFixes::UltraWide, ultrawide_fix_enabled);
SetFixes(GameFixes::Framerate, cutscenes_FPS_fix_enabled);
SetFixes(GameFixes::Camera, camera_fix_enabled);
SetFixes(GameFixes::DOF, DOF_fix_enabled);
SetFixes(GameFixes::ChromaticAberrations, CA_fix_enabled);
SetFixes(GameFixes::Vignetting, Vignetting_fix_enabled);
SetFixes(GameFixes::Fog, Fog_fix_enabled);
SetFixes(GameFixes::DevConsole, console);
}
sliders[0] = { "In game additional FOV", "##FOVValue", SliderType::Int, &worldFOVvalue, -20, 70, SetFOV };
sliders[1] = { "Camera distance (*)", "##CameraOffset", SliderType::Float, &CameraDistancevalue, 0, 4, SetCameraDistance, "%.2f", "Value is a multiplier." };
sliders[2] = { "Fog density (*)", "##FogDensityValue", SliderType::Float, &fogDensityValue, 0, 5, SetFogDensity, "%.2f",
"This will override engine dynamic value." };
sliders[3] = { "Fog opacity (*)", "##FogOpacityValue", SliderType::Float, &fogMaxOpacityValue, 0, 1, SetFogMaxOpacity, "%.2f",
"This will override engine dynamic value." };
}
}
@@ -111,15 +139,17 @@ static void SaveSettings()
pluginIniFile["2#Individual fix"]["Chromatic aberrations"] = CA_fix_enabled;
pluginIniFile["2#Individual fix"]["Vignetting"] = Vignetting_fix_enabled;
pluginIniFile["2#Individual fix"]["Fog"] = Fog_fix_enabled;
pluginIniFile["2#Individual fix"]["Cutscenes FPS"] = cutscenes_FPS_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;
pluginIniFile["3#Fixes tuning"]["Fog density"] = fogDensityValue;
pluginIniFile["3#Fixes tuning"]["Fog opacity"] = fogMaxOpacityValue;
pluginIniFile.save(SETTINGS_FILE);
}
static void LoadSettings()
{
static void LoadSettings() {
ini::IniFile pluginIniFile;
try {
pluginIniFile.load(SETTINGS_FILE);
@@ -132,8 +162,12 @@ static void LoadSettings()
CA_fix_enabled = pluginIniFile["2#Individual fix"]["Chromatic aberrations"].as<bool>();
Vignetting_fix_enabled = pluginIniFile["2#Individual fix"]["Vignetting"].as<bool>();
Fog_fix_enabled = pluginIniFile["2#Individual fix"]["Fog"].as<bool>();
cutscenes_FPS_fix_enabled = pluginIniFile["2#Individual fix"]["Cutscenes FPS"].as<bool>();
worldFOVvalue = pluginIniFile["3#Fixes tuning"]["World FOV"].as<int>();
CameraDistancevalue = pluginIniFile["3#Fixes tuning"]["Camera distance"].as<float>();
fogDensityValue = pluginIniFile["3#Fixes tuning"]["Fog density"].as<float>();
fogMaxOpacityValue = pluginIniFile["3#Fixes tuning"]["Fog opacity"].as<float>();
}
catch (const std::exception& e) {}
}
@@ -153,8 +187,7 @@ void read_log_file(const std::string& filename) {
}
// Initialize ImGui widgets for Reshade
static void on_overlay_draw(reshade::api::effect_runtime* runtime)
{
static void on_overlay_draw(reshade::api::effect_runtime* runtime) {
ImGuiStyle& style = ImGui::GetStyle();
style.ItemSpacing = ImVec2(8 * scale, 8 * scale); // Spacing between widgets
style.FramePadding = ImVec2(3 * scale, 3 * scale); // Widgets padding
@@ -177,16 +210,14 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
show_log_overlay = true; // Fix information
}
if (popup_Informations)
{
if (popup_Informations) {
ImGui::Begin("Informations", &popup_Informations, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
if (show_log_overlay)
{
if (show_log_overlay) {
ImGui::Begin("Game log", &show_log_overlay, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::TextUnformatted(log_content.c_str());
ImGui::End();
@@ -204,31 +235,6 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
}
// Sliders
ImGui::TableSetColumnIndex(0);
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(180 * scale);
if (ImGui::SliderInt("##FOVValue", &worldFOVvalue, -20, 70)) {
if (SetFOV) SetFOV(worldFOVvalue);
SaveSettings();
}
}
if (ImGui::CollapsingHeader("Camera distance (*)", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(150 * scale);
if (ImGui::SliderFloat("##CameraValue", &CameraDistancevalue, 0, 4, "%.2f")) {
if (SetCameraDistance) SetCameraDistance(CameraDistancevalue); SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Value is a multiplier.");
ImGui::EndTooltip();
}
// Individual fixes
ImGui::TableSetColumnIndex(1);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
@@ -238,58 +244,27 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
if (SetFixesEnabled) SetFixesEnabled(GameFixes::FOV, fov_fix_enabled);
SaveSettings();
}
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
if (SetFixesEnabled) SetFixesEnabled(GameFixes::Vignetting, Vignetting_fix_enabled);
SaveSettings();
}
if (ImGui::Checkbox("Fog", &Fog_fix_enabled)) {
if (SetFixesEnabled) SetFixesEnabled(GameFixes::Fog, Fog_fix_enabled);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Enabling this fix is a one way.");
ImGui::Text("Reverting it in real time would end in game crash.");
ImGui::Text("So disabling this fix is only possible by doing it here and restart the game.");
ImGui::EndTooltip();
}
for (int i = 0; i < 4; ++i) DrawFixCheckbox(individualFixes[i]);
ImGui::TableSetColumnIndex(1);
if (ImGui::Checkbox("Ultrawide", &ultrawide_fix_enabled)) {
if (SetFixesEnabled) SetFixesEnabled(GameFixes::UltraWide, ultrawide_fix_enabled);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This fix is intended for ultrawide displays only (21/9, 32/9 ...).");
ImGui::EndTooltip();
}
for (int i = 4; i < IM_ARRAYSIZE(individualFixes); ++i) DrawFixCheckbox(individualFixes[i]);
if (ImGui::Checkbox("Camera distance", &camera_fix_enabled)) {
if (SetFixesEnabled) SetFixesEnabled(GameFixes::Camera, camera_fix_enabled);
SaveSettings();
}
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
if (SetFixesEnabled) SetFixesEnabled(GameFixes::DOF, DOF_fix_enabled);
SaveSettings();
}
if (ImGui::Checkbox("Chromatic aberrations", &CA_fix_enabled)) {
if (SetFixesEnabled) SetFixesEnabled(GameFixes::ChromaticAberrations ,CA_fix_enabled);
SaveSettings();
}
ImGui::EndTable();
}
}
ImGui::EndTable();
}
// Draw individual fix sliders
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 2 * style.ItemSpacing.y);
if (ImGui::BeginTable("FixesSliders", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
for (int i = 0; i < 2; ++i) DrawSlider(sliders[i], 200);
ImGui::TableSetColumnIndex(1);
for (int i = 2; i < 4; ++i) DrawSlider(sliders[i], 200);
ImGui::EndTable();
}
ImGui::EndTabItem();
// Fix status
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
@@ -306,10 +281,8 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
}
// Main dll intrance
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID)
{
switch (ul_reason_for_call)
{
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
if (!reshade::register_addon(hinstDLL))
return FALSE;