Compare commits

..

50 Commits

Author SHA1 Message Date
d7424e5e3d Version bump 2025-10-10 14:33:13 +02:00
16b295efd2 Changed optimizations to pass AVs 2025-10-10 14:32:48 +02:00
9ac98a4ea2 Add Little Nightmare III 2025-10-09 22:31:44 +02:00
3bc669be5b Add Little Nightmare III project 2025-10-09 22:31:19 +02:00
178e872128 Set the correct overlay game title 2025-10-09 22:30:27 +02:00
f90bcc9873 Add Blood Of Mehran project 2025-10-09 11:59:48 +02:00
0eec042103 Add Blood Of Mehran 2025-10-09 11:59:21 +02:00
ec55340e6e Add cutscenes ultrawide and framerate fixes 2025-10-07 18:00:27 +02:00
5a11dc8303 Change ini file management. Version bump. Change default sliders formats 2025-10-03 18:57:34 +02:00
72d517dee5 Add ini file library 2025-10-03 18:55:55 +02:00
c749b36fb5 Change C++ version. Add project optimizations 2025-10-03 18:55:14 +02:00
25ac7841be Add ini file library 2025-10-03 18:54:19 +02:00
027e46521c Add fog density and opacity 2025-10-01 14:06:52 +02:00
e1de24d454 Add informations 2025-10-01 14:05:52 +02:00
75353eb1ae Add game shared informations include 2025-09-29 12:03:20 +02:00
a2fad9c942 Add unique function to retrieve game informations 2025-09-29 12:02:11 +02:00
7ee585d4a6 Add include to the project 2025-09-29 12:01:17 +02:00
c822880435 Add game shared informations include 2025-09-29 12:00:29 +02:00
5303fbda90 Add camera distance fix. Version update 2025-09-28 10:02:24 +02:00
89b55d3784 Add Silent Hill f. Not for release. 2025-09-27 20:47:10 +02:00
255d6ff104 Add Silent Hill f 2025-09-27 20:46:34 +02:00
d4792073db Fix version update 2025-09-24 17:38:38 +02:00
7630b42862 Add HUD safezone fix 2025-09-19 19:28:15 +02:00
d9f3070e43 Add console information. Add project optimization 2025-09-17 11:25:04 +02:00
71251f9b25 Add project optimization 2025-09-17 11:24:01 +02:00
957a998f74 Rewritten Core dll loading 2025-09-17 11:23:29 +02:00
d1ad5e28fb Add project optimization 2025-09-17 11:18:27 +02:00
070ec0ca43 Comments removal 2025-09-16 11:57:36 +02:00
1d12991e46 Add character camera height. Enabling console removal 2025-09-16 11:55:45 +02:00
ebb08a6b37 Fixed camera distance fix not initialising 2025-09-15 15:11:43 +02:00
7f6065d87f Builkd optimisations 2025-09-15 14:10:24 +02:00
b77c5fcd70 Add camera distance 2025-09-15 11:46:17 +02:00
af413f1d10 Improved UI scaling 2025-09-14 22:41:16 +02:00
5558483c96 Add dev console and improved UI scaling 2025-09-14 22:40:25 +02:00
5509e115f5 Hell Is Us project build settings change to avoid to trigger AV 2025-09-14 22:38:58 +02:00
8ac0373374 UI scaling improvement 2025-09-13 11:40:28 +02:00
986646e8b1 Update fix version 2025-09-10 21:55:02 +02:00
9cfcda2756 Change build options to not trigger AV 2025-09-09 08:18:36 +02:00
81912e9b74 Fix a bug where camera distance would be set to int instead of float 2025-09-09 07:27:58 +02:00
5b5d72585d Add camera distance 2025-09-09 06:18:20 +02:00
3b0b0ea00d Remove unnecessary include 2025-09-07 22:42:09 +02:00
88fcf9b761 English syntax correction 2025-09-07 19:17:10 +02:00
78fb746242 Remove commented code 2025-09-07 18:52:00 +02:00
07dfc091aa Add Unreal Engine re-enabling. Add fix informations 2025-09-07 18:50:12 +02:00
88950de211 Change addon version 2025-09-05 11:34:11 +02:00
0ed32df0bb Add 20 extra more degrees to FOV 2025-09-04 11:34:36 +02:00
7625accaf7 Add Chronos : The New Dawn 2025-09-04 10:40:56 +02:00
fad7c70afd Test getters functions before calling them 2025-09-03 14:36:30 +02:00
ee49ed1f54 Test getters functions before calling them 2025-09-03 12:28:34 +02:00
4129677b7e Add chromatic aberrations. 2025-09-02 14:47:15 +02:00
16 changed files with 3129 additions and 521 deletions

View File

@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{D2D8B784-7851-4D1D-8D54-8CD448390282}</ProjectGuid>
<RootNamespace>Blood Of Mehran</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>Blood Of Mehran</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetExt>.addon</TargetExt>
<TargetName>BloodOfMehranUI</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetExt>.addon</TargetExt>
<TargetName>BloodOfMehranUI</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetExt>.addon</TargetExt>
<TargetName>BloodOfMehranUI</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetExt>.addon</TargetExt>
<TargetName>BloodOfMehranUI</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
<WholeProgramOptimization>true</WholeProgramOptimization>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
<WholeProgramOptimization>true</WholeProgramOptimization>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
<LanguageStandard>stdcpp20</LanguageStandard>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

290
BloodOfMehran/dllmain.cpp Normal file
View File

@@ -0,0 +1,290 @@
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
#define IMGUI_HAS_DOCK 1
#include "GameInformations.h"
#include "inicpp.h"
#include <imgui.h>
#include <reshade.hpp>
#include <string>
#include <Windows.h>
// Screen informations
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
static float aspectRatio = (float)screenWidth / screenHeight;
// Core game dll functions declarations
typedef void (*SetBoolFn)(bool, bool);
typedef void (*SetIntFn)(int);
typedef void (*SetFloatFn)(float);
typedef float (*GetFloatFn)();
typedef bool (*GetBoolFn)();
static HMODULE fixLib = nullptr;
static LONG g_coreInitialized = 0;
static SetBoolFn SetFixEnabled = nullptr;
static SetBoolFn SetFOVFixEnabled = nullptr;
static SetBoolFn SetUltraWideFixEnabled = nullptr;
static SetBoolFn SetDOFFixEnabled = nullptr;
static SetBoolFn SetCAFixEnabled = nullptr;
static SetBoolFn SetVignettingFixEnabled = nullptr;
static SetBoolFn SetCameraFixEnabled = nullptr;
static SetIntFn SetFOV = nullptr;
static SetFloatFn SetCameraDistance = nullptr;
static GetGameInfosStruct GetGameInfos = nullptr;
// Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false;
static bool ultrawide_fix_enabled = false;
static bool DOF_fix_enabled = false;
static bool CA_fix_enabled = false;
static bool Vignetting_fix_enabled = false;
static bool camera_fix_enabled = false;
static bool fix_enabled = false;
static int worldFOVvalue = 0;
static float cameraDistanceValue = 1.f;
static bool popup_Informations = false;
// 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 cutscenes.\n - Controls camera distance.\n - Disable depth of field.\n - Disable chromatic aberrations.\n - Re enable dev console.";
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
// Scaling factor based on screen resolution
float scale = 1.f;
// Load and unload game core dll functions /!\ necessary
static void LoadFixDLL()
{
if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0)
return;
if (GetModuleHandleA("BloodOfMehranCore.dll") == nullptr) {
fixLib = LoadLibraryA("BloodOfMehranCore.dll");
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
return;
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
SetUltraWideFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetUltraWideFixEnabled");
SetCameraFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCameraFixEnabled");
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetCAFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCAFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance");
GetGameInfos = (GetGameInfosStruct)GetProcAddress(fixLib, "GetGameInfos");
// Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue);
if (SetCameraDistance) SetCameraDistance(cameraDistanceValue);
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetUltraWideFixEnabled) SetUltraWideFixEnabled(ultrawide_fix_enabled, true);
if (SetCameraFixEnabled) SetCameraFixEnabled(camera_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
}
}
// Settings functions
static void SaveSettings()
{
ini::IniFile pluginIniFile;
pluginIniFile["1#General fix"].setComment(std::vector<std::string>{ "The following sections are saved by plugin",
"You should not need to modify them",
" ",
"Controls if fix mod (globally) is enabled" });
pluginIniFile["1#General fix"]["Enabled"] = fix_enabled;
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"]["Chromatic aberrations"] = CA_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;
pluginIniFile.save(SETTINGS_FILE);
}
static void LoadSettings()
{
ini::IniFile pluginIniFile;
try {
pluginIniFile.load(SETTINGS_FILE);
fix_enabled = pluginIniFile["1#General fix"]["Enabled"].as<bool>();
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>();
CA_fix_enabled = pluginIniFile["2#Individual fix"]["Chromatic aberrations"].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>();
}
catch (const std::exception& e) {}
}
// Initialize ImGui widgets for Reshade
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
style.WindowPadding = ImVec2(10 * scale, 10 * scale); // Overlay padding
style.CellPadding = ImVec2(10 * scale, 10 * scale); // Table cells padding
ImGui::SetNextWindowSize(ImVec2(350 * scale, 150 * scale), ImGuiCond_Once);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.84f, 0.12f, 0.51f, 1.0f)); // pink
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.84f, 0.12f, 0.51f, 1.0f)); // pink
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.84f, 0.2f, 0.51f, 1.0f)); // pink
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 1.f, 1.f, 1.f)); // white
if (ImGui::Button("Like my work ? Consider donation")) ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL); // Donation
ImGui::PopStyleColor(4); // Restore color
ImGui::SameLine();
if (ImGui::Button("Fix informations")) popup_Informations = true; // Fix information
if (popup_Informations)
{
ImGui::Begin("Informations", &popup_Informations);
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
if (ImGui::BeginTable("FixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("LeftFix", ImGuiTableColumnFlags_WidthStretch, 0.3f);
ImGui::TableSetupColumn("RightFix", ImGuiTableColumnFlags_WidthStretch, 0.7f);
ImGui::TableNextRow();
// Drawing a left column with slider and general fix
ImGui::TableSetColumnIndex(0);
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
}
// Individual fixes
ImGui::TableSetColumnIndex(1);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.35f);
ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.65f);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Camera", &camera_fix_enabled)) {
if (SetCameraFixEnabled) SetCameraFixEnabled(camera_fix_enabled, false);
SaveSettings();
}
ImGui::TableSetColumnIndex(1);
if (ImGui::Checkbox("Cutscenes pillarboxing", &ultrawide_fix_enabled)) {
if (SetUltraWideFixEnabled) SetUltraWideFixEnabled(ultrawide_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Chromatic aberrations", &CA_fix_enabled)) {
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, false);
SaveSettings();
}
ImGui::EndTable();
}
}
ImGui::EndTable();
}
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 2 * style.ItemSpacing.y);
if (ImGui::BeginTable("FixesSliders", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableNextRow();
// Sliders
ImGui::TableSetColumnIndex(0);
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(180 * scale);
if (ImGui::SliderInt("##FOVValue", &worldFOVvalue, -20, 50)) {
if (SetFOV) SetFOV(worldFOVvalue);
SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This will affect in game FOV only.");
ImGui::EndTooltip();
}
ImGui::TableSetColumnIndex(1);
if (ImGui::CollapsingHeader("Camera distance (*)", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(180 * scale);
if (ImGui::SliderFloat("##CameraDistanceValue", &cameraDistanceValue, 0, 3, "%.2f")) {
if (SetCameraDistance) SetCameraDistance(cameraDistanceValue);
SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Value is a multiplier.");
ImGui::EndTooltip();
}
ImGui::EndTable();
}
// Fix status
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
if (GetGameInfos) {
GameInfos infos{};
GetGameInfos(&infos);
if (infos.consoleEnabled)
ImGui::Text("Console enabled and bound to key Tilde");
ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Out: %.2f", infos.FOVIn, infos.FOVOut);
ImGui::TextColored(ImColor(48, 179, 25), "Camera distance In: %.2f, Out: %.2f", infos.cameraIn, infos.cameraOut);
}
}
}
// Main dll intrance
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;
LoadSettings();
reshade::register_overlay("Blood Of Mehran", &on_overlay_draw);
reshade::register_event<reshade::addon_event::init_effect_runtime>(
[](reshade::api::effect_runtime* runtime) {
LoadFixDLL();
});
break;
case DLL_PROCESS_DETACH:
reshade::unregister_addon(hinstDLL);
break;
}
return TRUE;
}

View File

@@ -21,10 +21,10 @@
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}</ProjectGuid>
<RootNamespace>Gears Of War Reloaded</RootNamespace>
<ProjectGuid>{CFE5F26D-A180-4ED1-B696-7985053B14BA}</ProjectGuid>
<RootNamespace>Cronos The New Dawn</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>Gears Of War Reloaded</ProjectName>
<ProjectName>Cronos The New Dawn</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -50,7 +50,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -140,6 +140,7 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@@ -0,0 +1,354 @@
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
#define IMGUI_HAS_DOCK 1
#include <imgui.h>
#include <reshade.hpp>
#include <fstream>
#include <string>
#include <Windows.h>
// Screen informations
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
static float aspectRatio = (float)screenWidth / screenHeight;
// Core game dll functions declarations
typedef void (*SetBoolFn)(bool, bool);
typedef void (*SetIntFn)(int);
typedef void (*SetFloatFn)(float);
typedef float (*GetFloatFn)();
typedef bool (*GetBoolFn)();
typedef void (*SetUEConsole)();
static HMODULE fixLib = nullptr;
static SetBoolFn SetFixEnabled = nullptr;
static SetBoolFn SetFOVFixEnabled = nullptr;
static SetBoolFn SetFPSFixEnabled = nullptr;
static SetBoolFn SetResolutionFixEnabled = nullptr;
static SetBoolFn SetAspectRatioFixEnabled = nullptr;
static SetBoolFn SetDOFFixEnabled = nullptr;
static SetBoolFn SetVignettingFixEnabled = nullptr;
static SetBoolFn SetFogFixEnabled = nullptr;
static SetBoolFn SetCameraDistanceFixEnabled = nullptr;
static SetIntFn SetFOV = nullptr;
static SetFloatFn SetCameraDistance = nullptr;
static GetFloatFn GetFOVIn = nullptr;
static GetFloatFn GetCompensadedFOV = nullptr;
static GetFloatFn GetFOVOut = nullptr;
static GetBoolFn GetConsoleEnabled = nullptr;
static SetUEConsole SetConsole = nullptr;
// Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false;
static bool FPS_fix_enabled = false;
static bool Resolution_fix_enabled = false;
static bool Aspect_fix_enabled = false;
static bool DOF_fix_enabled = false;
static bool Vignetting_fix_enabled = false;
static bool Fog_fix_enabled = false;
static bool camera_Distance_fix_enabled = false;
static bool fix_enabled = false;
static int worldFOVvalue = 0;
static float cameraDistancevalue = 0.f;
static bool popup_Informations = false;
// Plugin settings
const char* SETTINGS_FILE = "PluginSettings.ini";
const char* GENERAL_FIX_SETTING = "GeneralFIX=";
const char* WORLD_FOV_FIX_SETTING = "WorldFOVFIX=";
const char* ASPECT_FIX_SETTING = "AspectFIX=";
const char* DOF_FIX_SETTING = "DOFFIX=";
const char* VIGNETTING_FIX_SETTING = "VignettingFIX=";
const char* FOG_FIX_SETTING = "FogFIX=";
const char* CAMERA_DISTANCE_FIX_SETTING = "CameraDistanceFIX=";
const char* WORLD_FOV_SETTING = "WorldFOV=";
const char* CAMERA_DISTANCE_SETTING = "CameraDistance=";
const char* FIX_VERSION = "1.0.6";
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";
// Facteur de scaling basé sur la résolution verticale
float scale = 1.f;
bool IsAlreadyInitialized()
{
// Declare a lock
HANDLE hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, "Local\\CronosFixSharedSection");
// If lock is not yet initialized
if (hMap == nullptr)
{
// We create the lock only once
hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 1, "Local\\CronosFixSharedSection");
if (hMap == nullptr) // We ensure the lock is valid
return true;
return false; // First time created we return false
}
// Otherwise we return true
CloseHandle(hMap);
return true;
}
// Load and unload game core dll functions /!\ necessary
static void LoadFixDLL()
{
if (IsAlreadyInitialized())
return; // déjà lancé dans un autre chargement
if (GetModuleHandleA("CronosTNDCore.dll") == nullptr) {
fixLib = LoadLibraryA("CronosTNDCore.dll");
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
return;
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
SetAspectRatioFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetAspectRatioFixEnabled");
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogFixEnabled");
SetCameraDistanceFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCameraDistanceFixEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance");
GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn");
GetCompensadedFOV = (GetFloatFn)GetProcAddress(fixLib, "GetCompensatedFOV");
GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut");
SetConsole = (SetUEConsole)GetProcAddress(fixLib, "SetConsole");
GetConsoleEnabled = (GetBoolFn)GetProcAddress(fixLib, "GetConsoleEnabled");
// Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue);
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue);
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_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 (SetConsole) SetConsole();
}
}
// Settings functions
static void SaveSettings()
{
std::ofstream file(SETTINGS_FILE);
if (file.is_open())
{
file << GENERAL_FIX_SETTING << (fix_enabled ? "1" : "0") << "\n";
file << WORLD_FOV_FIX_SETTING << (fov_fix_enabled ? "1" : "0") << "\n";
file << ASPECT_FIX_SETTING << (Aspect_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 << 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 << CAMERA_DISTANCE_SETTING << cameraDistancevalue << "\n";
file.close();
}
}
static void LoadSettings()
{
std::ifstream file(SETTINGS_FILE);
if (file.is_open())
{
std::string line;
while (std::getline(file, line))
{
if (line.find(GENERAL_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(GENERAL_FIX_SETTING));
fix_enabled = (val == "1" || val == "true");
}
else if (line.find(WORLD_FOV_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(WORLD_FOV_FIX_SETTING));
fov_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(ASPECT_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(ASPECT_FIX_SETTING));
Aspect_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(DOF_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(DOF_FIX_SETTING));
DOF_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(VIGNETTING_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(VIGNETTING_FIX_SETTING));
Vignetting_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(FOG_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(FOG_FIX_SETTING));
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)
worldFOVvalue = std::stoi(line.substr(strlen(WORLD_FOV_SETTING)));
else if (line.find(CAMERA_DISTANCE_SETTING) == 0)
cameraDistancevalue = std::stof(line.substr(strlen(CAMERA_DISTANCE_SETTING)));
}
file.close();
}
}
// Fix informations
static void displayFixInformations() {
ImGui::SetNextWindowSize(ImVec2(250 * scale, 200 * scale));
ImGui::Begin("Informations", &popup_Informations); //
ImGui::SetCursorPos(ImVec2(10 * scale, 36 * scale));
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::SetCursorPos(ImVec2(10 * scale, 76 * scale));
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
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
style.WindowPadding = ImVec2(10 * scale, 10 * scale); // Overlay padding
scale = (float)screenHeight / 1200.f;
ImGui::SetNextWindowSize(ImVec2(480 * scale, 400 * scale), ImGuiCond_Once);
if (ImGui::Button("Like my work ? Consider donation")) ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL); // Donation
ImGui::SameLine();
if (ImGui::Button("Fix informations")) popup_Informations = true; // Fix information
if (popup_Informations)
{
ImGui::Begin("Informations", &popup_Informations);
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
ImGui::Columns(2, NULL, false);
// Drawing a left column with slider and general fix
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) { if (SetFixEnabled) SetFixEnabled(fix_enabled, false); SaveSettings(); }
// Sliders
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(150 * 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, 3)) {
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue); SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Value is a multiplier.");
ImGui::Text("Affects both normal and weapon aiming distance.");
ImGui::EndTooltip();
}
// Individual fixes
ImGui::NextColumn();
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen))
{
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Camera distance", &camera_Distance_fix_enabled)) {
if (SetCameraDistanceFixEnabled) SetCameraDistanceFixEnabled(camera_Distance_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) {
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This is intended for ultrawide only.");
ImGui::Text("Set panini to off in settings to avoid blurry textures and narrow FOV.");
ImGui::EndTooltip();
}
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Fog", &Fog_fix_enabled)) {
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, false);
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();
}
}
ImGui::Columns(1);
// Fix status
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
if (GetConsoleEnabled && GetConsoleEnabled())
ImGui::Text("Console enabled and bound to key Tilde");
if (GetFOVIn && GetCompensadedFOV && GetFOVOut)
ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Compensated: %.2f, Out: %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut());
}
}
// Main dll intrance
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;
LoadSettings();
reshade::register_overlay("Cronos: The New Dawn", &on_overlay_draw);
reshade::register_event<reshade::addon_event::init_effect_runtime>(
[](reshade::api::effect_runtime* runtime) {
LoadFixDLL();
});
break;
case DLL_PROCESS_DETACH:
reshade::unregister_addon(hinstDLL);
break;
}
return TRUE;
}

View File

@@ -1,231 +0,0 @@
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
#define IMGUI_HAS_DOCK 1
#include <imgui.h>
#include <reshade.hpp>
#include <fstream>
#include <string>
#include <Windows.h>
#include <thread>
// Core game dll functions declarations
typedef void (*SetBoolFn)(bool, bool);
typedef void (*SetIntFn)(int);
typedef float (*GetFloatFn)();
// Screen informations
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
static float aspectRatio = (float)screenWidth / screenHeight;
static HMODULE fixLib = nullptr;
static SetBoolFn SetFixEnabled = nullptr;
static SetBoolFn SetFOVFixEnabled = nullptr;
//static SetBoolFn SetDOFFixEnabled = nullptr;
static SetIntFn SetFOV = nullptr;
static GetFloatFn GetFOVIn = nullptr;
static GetFloatFn GetFOVOut = nullptr;
// Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false;
static bool DOF_fix_enabled = false;
static bool fix_enabled = false;
static int worldFOVvalue = 0;
static bool popup_Informations = false;
// Plugin settings
const char* SETTINGS_FILE = "PluginSettings.ini";
const char* GENERAL_FIX_SETTING = "GeneralFIX=";
const char* WORLD_FOV_FIX_SETTING = "WorldFOVFIX=";
//const char* DOF_FIX_SETTING = "DOFFIX=";
const char* WORLD_FOV_SETTING = "WorldFOV=";
const char* FIX_VERSION = "1.0.1";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Disable depth of field.";
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
// Load and unload game core dll functions /!\ necessary
static void LoadFixDLL()
{
if (fixLib) return;
//fixLib = LoadLibraryA("GOWRCore.dll");
//if (GetModuleHandleA("GOWRCore.dll") != nullptr) {
// MessageBoxA(nullptr, "core dll loaded", "Erreur", MB_OK);
//}
//if (!fixLib) {
// MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
// return;
//}
//SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
//SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
////SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
//SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
//GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn");
//GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut");;
// Apply initial values loaded from settings
//if (SetFOV) SetFOV(worldFOVvalue);
//if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
//if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
//if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
}
// Settings functions
static void SaveSettings()
{
std::ofstream file(SETTINGS_FILE);
if (file.is_open())
{
file << GENERAL_FIX_SETTING << (fix_enabled ? "1" : "0") << "\n";
file << WORLD_FOV_FIX_SETTING << (fov_fix_enabled ? "1" : "0") << "\n";
//file << DOF_FIX_SETTING << (DOF_fix_enabled ? "1" : "0") << "\n";
file << WORLD_FOV_SETTING << worldFOVvalue << "\n";
file.close();
}
}
static void LoadSettings()
{
std::ifstream file(SETTINGS_FILE);
if (file.is_open())
{
std::string line;
while (std::getline(file, line))
{
if (line.find(GENERAL_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(GENERAL_FIX_SETTING));
fix_enabled = (val == "1" || val == "true");
}
else if (line.find(WORLD_FOV_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(WORLD_FOV_FIX_SETTING));
fov_fix_enabled = (val == "1" || val == "true");
}
//else if (line.find(DOF_FIX_SETTING) == 0)
//{
// std::string val = line.substr(strlen(DOF_FIX_SETTING));
// DOF_fix_enabled = (val == "1" || val == "true");
//}
else if (line.find(WORLD_FOV_SETTING) == 0)
worldFOVvalue = std::stoi(line.substr(strlen(WORLD_FOV_SETTING)));
}
file.close();
}
}
// Fix informations
static void displayFixInformations() {
ImGui::Begin("Informations", &popup_Informations); //
ImGui::SetCursorPos(ImVec2(10, 36));
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::SetCursorPos(ImVec2(10, 76));
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
// Initialize ImGui widgets for Reshade
static void on_overlay_draw(reshade::api::effect_runtime* runtime)
{
ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(350, 150), ImGuiCond_Once);
// Donation ?
ImGui::SetCursorPos(ImVec2(10, 36));
ImGui::Text("Like my work ?");
ImGui::SetCursorPos(ImVec2(130, 33));
if (ImGui::Button("consider donation"))
{
ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL);
}
// Fix informations
ImGui::SetCursorPos(ImVec2(270, 33));
if (ImGui::Button("Fix informations"))
popup_Informations = true;
if (popup_Informations)
displayFixInformations();
// Generic fix
ImGui::SetCursorPos(ImVec2(10, 60));
ImGui::BeginChild("AllFixesHeader", ImVec2(220, 0), false); // true = border
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
}
}
ImGui::EndChild();
// FOV adjustment
ImGui::SetCursorPos(ImVec2(10, 120));
ImGui::BeginChild("FOVHeader", ImVec2(220, 0), false);
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
ImGui::SetNextItemWidth(150.0f);
if (ImGui::SliderInt("", &worldFOVvalue, -20, 50)) {}
if (ImGui::IsItemDeactivatedAfterEdit()) {
if (SetFOV) SetFOV(worldFOVvalue);
SaveSettings();
}
}
ImGui::EndChild();
// Individual fixes
ImGui::SetCursorPos(ImVec2(240, 60));
ImGui::BeginChild("IndividualFixesHeader", ImVec2(250, 0), false);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
if (ImGui::Checkbox("FOV fix", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
}
//ImGui::SetCursorPos(ImVec2(5, 55));
//if (ImGui::Checkbox("Depth of field fix", &DOF_fix_enabled)) {
// if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
// SaveSettings();
//}
}
ImGui::EndChild();
// Fix status
ImGui::SetCursorPos(ImVec2(10, 220));
ImGui::BeginChild("INFOSHeader", ImVec2(480, 80), true);
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
ImGui::Text("Screen infos width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
//ImGui::Text("FOV In: %.2f, Out : %.2f", GetFOVIn(), GetFOVOut());
}
ImGui::EndChild();
}
// Main dll intrance
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;
LoadSettings();
reshade::register_overlay("Gears Of War Reloaded", &on_overlay_draw);
reshade::register_event<reshade::addon_event::init_effect_runtime>(
[](reshade::api::effect_runtime* runtime) {
LoadFixDLL();
});
break;
case DLL_PROCESS_DETACH:
reshade::unregister_addon(hinstDLL);
break;
}
return TRUE;
}

View File

@@ -50,7 +50,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -140,6 +140,7 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@@ -7,12 +7,20 @@
#include <string>
#include <Windows.h>
// Screen informations
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
static float aspectRatio = (float)screenWidth / screenHeight;
// Core game dll functions declarations
typedef void (*SetBoolFn)(bool, bool);
typedef void (*SetIntFn)(int);
typedef void (*SetFloatFn)(float);
typedef float (*GetFloatFn)();
typedef bool (*GetBoolFn)();
static HMODULE fixLib = nullptr;
static LONG g_coreInitialized = 0;
static SetBoolFn SetFixEnabled = nullptr;
static SetBoolFn SetFOVFixEnabled = nullptr;
static SetBoolFn SetAspectRatioFixEnabled = nullptr;
@@ -20,10 +28,17 @@ static SetBoolFn SetDOFFixEnabled = nullptr;
static SetBoolFn SetCAFixEnabled = nullptr;
static SetBoolFn SetVignettingFixEnabled = nullptr;
static SetBoolFn SetFogFixEnabled = nullptr;
static SetBoolFn SetCameraFixEnabled = nullptr;
static SetBoolFn SetHUDFixEnabled = nullptr;
static SetIntFn SetFOV = nullptr;
static SetFloatFn SetCameraDistance = nullptr;
static SetIntFn SetCameraHeight = nullptr;
static SetIntFn SetHUD = nullptr;
static GetFloatFn GetFOVIn = nullptr;
static GetFloatFn GetCompensadedFOV = nullptr;
static GetFloatFn GetFOVOut = nullptr;
static GetBoolFn GetConsoleEnabled = nullptr;
// Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false;
@@ -32,8 +47,13 @@ static bool DOF_fix_enabled = false;
static bool CA_fix_enabled = false;
static bool Vignetting_fix_enabled = false;
static bool Fog_fix_enabled = false;
static bool camera_fix_enabled = false;
static bool HUD_fix_enabled = false;
static bool fix_enabled = false;
static int worldFOVvalue = 0;
static float cameraDistancevalue = 1.f;
static int cameraHeightvalue = -15;
static int HUDvalue = 0;
static bool popup_Informations = false;
@@ -42,49 +62,70 @@ const char* SETTINGS_FILE = "PluginSettings.ini";
const char* GENERAL_FIX_SETTING = "GeneralFIX=";
const char* WORLD_FOV_FIX_SETTING = "WorldFOVFIX=";
const char* ASPECT_FIX_SETTING = "AspectFIX=";
const char* CAMERA_FIX_SETTING = "CameraFIX=";
const char* HUD_FIX_SETTING = "HUDFIX=";
const char* DOF_FIX_SETTING = "DOFFIX=";
const char* CA_FIX_SETTING = "CAFIX=";
const char* VIGNETTING_FIX_SETTING = "VignettingFIX=";
const char* FOG_FIX_SETTING = "FogFIX=";
const char* WORLD_FOV_SETTING = "WorldFOV=";
const char* FIX_VERSION = "1.0.2";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Disable pillar boxing in cutscences.\n - Disable depth of field.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Disable FOG.\n\nDisabling pillar boxing will compensate FOV\nfor main menu and cutscenes.\nDisabling Fog will not entirely remove it.";
const char* CAMERA_DISTANCE_SETTING = "CameraDistance=";
const char* CAMERA_HEIGHT_SETTING = "CameraHeight=";
const char* HUD_SETTING = "HUDValue=";
const char* FIX_VERSION = "1.0.7";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Disable pillar boxing in cutscences.\n - Control camera.\n - Control HUD safezone.\n - Disable depth of field.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Disable FOG.\n - Re enable console.\n\nDisabling pillar boxing will compensate FOV\nfor main menu and cutscenes.\nDisabling Fog will not entirely remove it.";
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
// Scaling factor based on screen resolution
float scale = 1.f;
// Load and unload game core dll functions /!\ necessary
static void LoadFixDLL()
{
if (fixLib) return;
fixLib = LoadLibraryA("HellIsUsCore.dll");
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0)
return;
if (GetModuleHandleA("HellIsUsCore.dll") == nullptr) {
fixLib = LoadLibraryA("HellIsUsCore.dll");
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
return;
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
SetAspectRatioFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetAspectRatioFixEnabled");
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetCAFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCAFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogFixEnabled");
SetCameraFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCameraFixEnabled");
SetHUDFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetHUDFixEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance");
SetCameraHeight = (SetIntFn)GetProcAddress(fixLib, "SetCameraHeight");
SetHUD = (SetIntFn)GetProcAddress(fixLib, "SetHUD");
GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn");
GetCompensadedFOV = (GetFloatFn)GetProcAddress(fixLib, "GetCompensatedFOV");
GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut");;
GetConsoleEnabled = (GetBoolFn)GetProcAddress(fixLib, "GetConsoleEnabled");
// Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue);
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue);
if (SetCameraHeight) SetCameraHeight(cameraHeightvalue);
if (SetHUD) SetHUD(HUDvalue);
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetCameraFixEnabled) SetCameraFixEnabled(camera_fix_enabled, true);
if (SetHUDFixEnabled) SetHUDFixEnabled(HUD_fix_enabled, true);
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true);
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, true);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
SetAspectRatioFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetAspectRatioFixEnabled");
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetCAFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCAFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogFixEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn");
GetCompensadedFOV = (GetFloatFn)GetProcAddress(fixLib, "GetCompensatedFOV");
GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut");;
// Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue);
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true);
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, true);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
}
// Settings functions
@@ -96,11 +137,16 @@ static void SaveSettings()
file << GENERAL_FIX_SETTING << (fix_enabled ? "1" : "0") << "\n";
file << WORLD_FOV_FIX_SETTING << (fov_fix_enabled ? "1" : "0") << "\n";
file << ASPECT_FIX_SETTING << (Aspect_fix_enabled ? "1" : "0") << "\n";
file << CAMERA_FIX_SETTING << (camera_fix_enabled ? "1" : "0") << "\n";
file << HUD_FIX_SETTING << (HUD_fix_enabled ? "1" : "0") << "\n";
file << DOF_FIX_SETTING << (DOF_fix_enabled ? "1" : "0") << "\n";
file << CA_FIX_SETTING << (CA_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 << WORLD_FOV_SETTING << worldFOVvalue << "\n";
file << CAMERA_DISTANCE_SETTING << cameraDistancevalue << "\n";
file << CAMERA_HEIGHT_SETTING << cameraHeightvalue << "\n";
file << HUD_SETTING << HUDvalue << "\n";
file.close();
}
}
@@ -123,6 +169,16 @@ static void LoadSettings()
std::string val = line.substr(strlen(WORLD_FOV_FIX_SETTING));
fov_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(CAMERA_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(CAMERA_FIX_SETTING));
camera_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(HUD_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(HUD_FIX_SETTING));
HUD_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(ASPECT_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(ASPECT_FIX_SETTING));
@@ -150,142 +206,186 @@ static void LoadSettings()
}
else if (line.find(WORLD_FOV_SETTING) == 0)
worldFOVvalue = std::stoi(line.substr(strlen(WORLD_FOV_SETTING)));
else if (line.find(CAMERA_DISTANCE_SETTING) == 0)
cameraDistancevalue = std::stof(line.substr(strlen(CAMERA_DISTANCE_SETTING)));
else if (line.find(CAMERA_HEIGHT_SETTING) == 0)
cameraHeightvalue = std::stoi(line.substr(strlen(CAMERA_HEIGHT_SETTING)));
else if (line.find(HUD_SETTING) == 0)
HUDvalue = std::stoi(line.substr(strlen(HUD_SETTING)));
}
file.close();
}
}
// Fix informations
static void displayFixInformations() {
ImGui::Begin("Informations", &popup_Informations); //
ImGui::SetCursorPos(ImVec2(10, 36));
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::SetCursorPos(ImVec2(10, 76));
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
// Initialize ImGui widgets for Reshade
static void on_overlay_draw(reshade::api::effect_runtime* runtime)
{
ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(350, 150), ImGuiCond_Once);
ImGuiStyle& style = ImGui::GetStyle();
style.ItemSpacing = ImVec2(8 * scale, 8 * scale); // Spacing between widgets
style.FramePadding = ImVec2(3 * scale, 3 * scale); // Widgets padding
style.WindowPadding = ImVec2(10 * scale, 10 * scale); // Overlay padding
style.CellPadding = ImVec2(10 * scale, 10 * scale); // Table cells padding
// Donation ?
ImGui::SetCursorPos(ImVec2(10, 36));
ImGui::Text("Like my work ?");
ImGui::SetCursorPos(ImVec2(130, 33));
if (ImGui::Button("consider donation"))
{
ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL);
}
ImGui::SetNextWindowSize(ImVec2(350 * scale, 150 * scale), ImGuiCond_Once);
// Fix informations
ImGui::SetCursorPos(ImVec2(270, 33));
if (ImGui::Button("Fix informations"))
popup_Informations = true;
if (ImGui::Button("Like my work ? Consider donation")) ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL); // Donation
ImGui::SameLine();
if (ImGui::Button("Fix informations")) popup_Informations = true; // Fix information
if (popup_Informations)
displayFixInformations();
// Generic fix
ImGui::SetCursorPos(ImVec2(10, 60));
ImGui::BeginChild("AllFixesHeader", ImVec2(220, 0), false); // true = border
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
}
{
ImGui::Begin("Informations", &popup_Informations);
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
ImGui::EndChild();
// FOV adjustment
ImGui::SetCursorPos(ImVec2(10, 120));
ImGui::BeginChild("FOVHeader", ImVec2(220, 0), false);
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
ImGui::SetNextItemWidth(150.0f);
if (ImGui::SliderInt("", &worldFOVvalue, -20, 50)) {}
if (ImGui::IsItemDeactivatedAfterEdit()) {
if (SetFOV) SetFOV(worldFOVvalue);
SaveSettings();
}
}
ImGui::EndChild();
if (ImGui::BeginTable("FixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("LeftFix", ImGuiTableColumnFlags_WidthStretch, 0.4f);
ImGui::TableSetupColumn("RightFix", ImGuiTableColumnFlags_WidthStretch, 0.6f);
ImGui::TableNextRow();
// Individual fixes
ImGui::SetCursorPos(ImVec2(240, 60));
ImGui::BeginChild("IndividualFixesHeader", ImVec2(250, 0), false);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
if (ImGui::Checkbox("FOV fix", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
// Drawing a left column with slider and general fix
ImGui::TableSetColumnIndex(0);
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
}
// Sliders
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(150 * scale);
if (ImGui::SliderInt("##FOVValue", &worldFOVvalue, -20, 50)) {
if (SetFOV) SetFOV(worldFOVvalue);
SaveSettings();
}
}
if (ImGui::CollapsingHeader("Camera distance (*)", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(150 * scale);
if (ImGui::SliderFloat("##CameraDistanceValue", &cameraDistancevalue, 0, 3)) {
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue); SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This won't affect PDA for readability");
ImGui::Text("Value is a multiplier.");
ImGui::EndTooltip();
}
ImGui::SetCursorPos(ImVec2(90, 30));
if (ImGui::Checkbox("Aspect ratio fix", &Aspect_fix_enabled)) {
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false);
SaveSettings();
if (ImGui::CollapsingHeader("Camera height (*)", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(150 * scale);
if (ImGui::SliderInt("##CameraHeightValue", &cameraHeightvalue, -80, 80)) {
if (SetCameraHeight) SetCameraHeight(cameraHeightvalue); SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Aspect ratio fix is only usefull for ultrawide displays.");
ImGui::Text("No need to enable it if you play at 16/9.");
ImGui::Text("Default value is -15.");
ImGui::EndTooltip();
}
ImGui::SetCursorPos(ImVec2(5, 55));
if (ImGui::Checkbox("Depth of field fix", &DOF_fix_enabled)) {
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
SaveSettings();
}
// Individual fixes
ImGui::TableSetColumnIndex(1);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.35f);
ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.65f);
ImGui::TableNextRow();
ImGui::SetCursorPos(ImVec2(5, 80));
if (ImGui::Checkbox("Chromatic aberrations fix", &CA_fix_enabled)) {
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, false);
SaveSettings();
}
ImGui::TableSetColumnIndex(0);
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This won't affect PDA for readability");
ImGui::EndTooltip();
}
ImGui::SetCursorPos(ImVec2(5, 105));
if (ImGui::Checkbox("Vignetting fix", &Vignetting_fix_enabled)) {
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Camera", &camera_fix_enabled)) {
if (SetCameraFixEnabled) SetCameraFixEnabled(camera_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Controls distance and height.");
ImGui::EndTooltip();
}
ImGui::SetCursorPos(ImVec2(140, 105));
if (ImGui::Checkbox("Fog fix", &Fog_fix_enabled)) {
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Fog", &Fog_fix_enabled)) {
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, false);
SaveSettings();
}
ImGui::TableSetColumnIndex(1);
if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) {
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Aspect ratio fix is only usefull for ultrawide displays.");
ImGui::Text("No need to enable it if you play on 16/9.");
ImGui::EndTooltip();
}
if (ImGui::Checkbox("HUD safe zone", &HUD_fix_enabled)) {
if (SetHUDFixEnabled) SetHUDFixEnabled(HUD_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This fix is intended for ultrawide displays only.");
ImGui::EndTooltip();
}
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Chromatic aberrations", &CA_fix_enabled)) {
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, false);
SaveSettings();
}
ImGui::EndTable();
}
}
if (ImGui::CollapsingHeader("HUD safe zone (*)", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(150 * scale);
if (ImGui::SliderInt("##HUDValue", &HUDvalue, 0, 40)) {
if (SetHUD) SetHUD(HUDvalue);
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::Text("Percentage HUD bounds (let and right).");
ImGui::EndTooltip();
}
ImGui::EndTable();
}
ImGui::EndChild();
// Fix status
ImGui::SetCursorPos(ImVec2(10, 220));
ImGui::BeginChild("INFOSHeader", ImVec2(480, 80), true);
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
ImGui::Text("FOV In: %.2f, Compensated : %.2f, Out : %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut());
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
if (GetConsoleEnabled && GetConsoleEnabled())
ImGui::Text("Console enabled and bound to key F2");
if (GetFOVIn && GetCompensadedFOV && GetFOVOut)
ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Compensated: %.2f, Out: %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut());
}
ImGui::EndChild();
}
// Main dll intrance

View File

@@ -0,0 +1,184 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{25D45378-7E86-4677-BD77-238D2EC3005B}</ProjectGuid>
<RootNamespace>Little Nightmare III</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>Little Nightmare III</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetExt>.addon</TargetExt>
<TargetName>LittleNightmareIIIUI</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetExt>.addon</TargetExt>
<TargetName>LittleNightmareIIIUI</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetExt>.addon</TargetExt>
<TargetName>LittleNightmareIIIUI</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetExt>.addon</TargetExt>
<TargetName>LittleNightmareIIIUI</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
<WholeProgramOptimization>false</WholeProgramOptimization>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<IntrinsicFunctions>false</IntrinsicFunctions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>false</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
<WholeProgramOptimization>false</WholeProgramOptimization>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<IntrinsicFunctions>false</IntrinsicFunctions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>false</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WholeProgramOptimization>false</WholeProgramOptimization>
<LanguageStandard>stdcpp20</LanguageStandard>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,285 @@
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
#define IMGUI_HAS_DOCK 1
#include "GameInformations.h"
#include "inicpp.h"
#include <imgui.h>
#include <reshade.hpp>
#include <string>
#include <Windows.h>
// Screen informations
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
static float aspectRatio = (float)screenWidth / screenHeight;
// Core game dll functions declarations
typedef void (*SetBoolFn)(bool, bool);
typedef void (*SetIntFn)(int);
typedef void (*SetFloatFn)(float);
typedef float (*GetFloatFn)();
typedef bool (*GetBoolFn)();
static HMODULE fixLib = nullptr;
static LONG g_coreInitialized = 0;
static SetBoolFn SetFixEnabled = nullptr;
static SetBoolFn SetFOVFixEnabled = nullptr;
static SetBoolFn SetUltraWideFixEnabled = nullptr;
static SetBoolFn SetDOFFixEnabled = nullptr;
static SetBoolFn SetCAFixEnabled = nullptr;
static SetBoolFn SetVignettingFixEnabled = nullptr;
static SetIntFn SetFOV = nullptr;
static GetGameInfosStruct GetGameInfos = nullptr;
// Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false;
static bool ultrawide_fix_enabled = false;
static bool DOF_fix_enabled = false;
static bool CA_fix_enabled = false;
static bool Vignetting_fix_enabled = false;
static bool fix_enabled = false;
static int worldFOVvalue = 0;
// Overlays popups
static bool popup_Informations = false;
static bool show_log_overlay = false;
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 - Enable ultrawide.\n - Disable depth of field.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Re enable dev console.";
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
// Scaling factor based on screen resolution
float scale = 1.f;
// Load and unload game core dll functions /!\ necessary
static void LoadFixDLL()
{
if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0)
return;
if (GetModuleHandleA("LittleNightmareIIICore.dll") == nullptr) {
fixLib = LoadLibraryA("LittleNightmareIIICore.dll");
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
return;
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
SetUltraWideFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetUltraWideFixEnabled");
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetCAFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCAFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
GetGameInfos = (GetGameInfosStruct)GetProcAddress(fixLib, "GetGameInfos");
// Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue);
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetUltraWideFixEnabled) SetUltraWideFixEnabled(ultrawide_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
}
}
// Settings functions
static void SaveSettings()
{
ini::IniFile pluginIniFile;
pluginIniFile["1#General fix"].setComment(std::vector<std::string>{ "The following sections are saved by plugin",
"You should not need to modify them",
" ",
"Controls if fix mod (globally) is enabled" });
pluginIniFile["1#General fix"]["Enabled"] = fix_enabled;
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"]["DOF"] = DOF_fix_enabled;
pluginIniFile["2#Individual fix"]["Chromatic aberrations"] = CA_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.save(SETTINGS_FILE);
}
static void LoadSettings()
{
ini::IniFile pluginIniFile;
try {
pluginIniFile.load(SETTINGS_FILE);
fix_enabled = pluginIniFile["1#General fix"]["Enabled"].as<bool>();
fov_fix_enabled = pluginIniFile["2#Individual fix"]["FOV"].as<bool>();
ultrawide_fix_enabled = pluginIniFile["2#Individual fix"]["UltraWide"].as<bool>();
DOF_fix_enabled = pluginIniFile["2#Individual fix"]["DOF"].as<bool>();
CA_fix_enabled = pluginIniFile["2#Individual fix"]["Chromatic aberrations"].as<bool>();
Vignetting_fix_enabled = pluginIniFile["2#Individual fix"]["Vignetting"].as<bool>();
worldFOVvalue = pluginIniFile["3#Fixes tuning"]["World FOV"].as<int>();
}
catch (const std::exception& e) {}
}
// Read plugin log file
void read_log_file(const std::string& filename) {
std::ifstream file(filename);
if (!file.is_open())
{
log_content = "Impossible to open file : " + filename;
return;
}
std::ostringstream ss;
ss << file.rdbuf();
log_content = ss.str();
}
// Initialize ImGui widgets for Reshade
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
style.WindowPadding = ImVec2(10 * scale, 10 * scale); // Overlay padding
style.CellPadding = ImVec2(10 * scale, 10 * scale); // Table cells padding
ImGui::SetNextWindowSize(ImVec2(350 * scale, 150 * scale), ImGuiCond_Once);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.84f, 0.12f, 0.51f, 1.0f)); // pink
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.84f, 0.12f, 0.51f, 1.0f)); // pink
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.84f, 0.2f, 0.51f, 1.0f)); // pink
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 1.f, 1.f, 1.f)); // white
if (ImGui::Button("Like my work ? Consider donation")) ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL); // Donation
ImGui::PopStyleColor(4); // Restore color
ImGui::SameLine();
if (ImGui::Button("Fix informations")) popup_Informations = true; // Fix information
ImGui::SameLine();
if (ImGui::Button("View logs")) {
read_log_file("LittleNightmareIII.log");
show_log_overlay = true; // Fix information
}
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)
{
ImGui::Begin("Game log", &show_log_overlay, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::TextUnformatted(log_content.c_str());
ImGui::End();
}
if (ImGui::BeginTable("FixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("LeftFix", ImGuiTableColumnFlags_WidthStretch, 0.4f);
ImGui::TableSetupColumn("RightFix", ImGuiTableColumnFlags_WidthStretch, 0.6f);
ImGui::TableNextRow();
// Drawing a left column with slider and general fix
ImGui::TableSetColumnIndex(0);
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
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, 50)) {
if (SetFOV) SetFOV(worldFOVvalue);
SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This will affect in game FOV only.");
ImGui::EndTooltip();
}
// Individual fixes
ImGui::TableSetColumnIndex(1);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.35f);
ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.65f);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
SaveSettings();
}
ImGui::TableSetColumnIndex(1);
if (ImGui::Checkbox("Ultrawide", &ultrawide_fix_enabled)) {
if (SetUltraWideFixEnabled) SetUltraWideFixEnabled(ultrawide_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Chromatic aberrations", &CA_fix_enabled)) {
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, false);
SaveSettings();
}
ImGui::EndTable();
}
}
ImGui::EndTable();
}
// Fix status
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
if (GetGameInfos) {
GameInfos infos{};
GetGameInfos(&infos);
if (infos.consoleEnabled)
ImGui::Text("Console enabled and bound to key F2");
ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Out: %.2f", infos.FOVIn, infos.FOVOut);
}
}
}
// Main dll intrance
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;
LoadSettings();
reshade::register_overlay("Little Nightmare III", &on_overlay_draw);
reshade::register_event<reshade::addon_event::init_effect_runtime>(
[](reshade::api::effect_runtime* runtime) {
LoadFixDLL();
});
break;
case DLL_PROCESS_DETACH:
reshade::unregister_addon(hinstDLL);
break;
}
return TRUE;
}

View File

@@ -50,7 +50,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -140,6 +140,7 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@@ -7,24 +7,34 @@
#include <string>
#include <Windows.h>
// Screen informations
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
static float aspectRatio = (float)screenWidth / screenHeight;
// Core game dll functions declarations
typedef void (*SetBoolFn)(bool, bool);
typedef void (*SetIntFn)(int);
typedef float (*GetFloatFn)();
typedef bool (*GetBoolFn)();
static HMODULE fixLib = nullptr;
static LONG g_coreInitialized = 0;
static SetBoolFn SetFixEnabled = nullptr;
static SetBoolFn SetFOVFixEnabled = nullptr;
static SetBoolFn SetFPSFixEnabled = nullptr;
static SetBoolFn SetResolutionFixEnabled = nullptr;
static SetBoolFn SetAspectRatioFixEnabled = nullptr;
static SetBoolFn SetDOFFixEnabled = nullptr;
static SetBoolFn SetCAFixEnabled = nullptr;
static SetBoolFn SetVignettingFixEnabled = nullptr;
static SetBoolFn SetFogFixEnabled = nullptr;
static SetIntFn SetFOV = nullptr;
static GetFloatFn GetFOVIn = nullptr;
static GetFloatFn GetCompensadedFOV = nullptr;
static GetFloatFn GetFOVOut = nullptr;
static GetBoolFn GetConsoleEnabled = nullptr;
// Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false;
@@ -32,6 +42,7 @@ static bool FPS_fix_enabled = false;
static bool Resolution_fix_enabled = false;
static bool Aspect_fix_enabled = false;
static bool DOF_fix_enabled = false;
static bool CA_fix_enabled = false;
static bool Vignetting_fix_enabled = false;
static bool Fog_fix_enabled = false;
static bool fix_enabled = false;
@@ -47,49 +58,58 @@ const char* FPS_FIX_SETTING = "FPSFIX=";
const char* RESOLUTION_FIX_SETTING = "ResolutionFIX=";
const char* ASPECT_FIX_SETTING = "AspectFIX=";
const char* DOF_FIX_SETTING = "DOFFIX=";
const char* CA_FIX_SETTING = "ChromaticAberrationsFIX=";
const char* VIGNETTING_FIX_SETTING = "VignettingFIX=";
const char* FOG_FIX_SETTING = "FogFIX=";
const char* WORLD_FOV_SETTING = "WorldFOV=";
const char* FIX_VERSION = "1.0.2";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Unlock ultrawide resolutions.\n - Remove pillar boxing.\n - Unlock FPS.\n - Disable depth of field.\n - Disable vignetting.\n - Disable FOG.";
const char* FIX_VERSION = "1.0.4";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Unlock ultrawide resolutions.\n - Remove pillar boxing.\n - Unlock FPS.\n - Disable depth of field.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Disable FOG.\n - Enable dev console.";
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
// Scaling factor based vertical resolution
float scale = 1.f;
// Load and unload game core dll functions /!\ necessary
static void LoadFixDLL()
{
if (fixLib) return;
fixLib = LoadLibraryA("MGSDSECore.dll");
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0)
return;
if (GetModuleHandleA("MGSDSECore.dll") == nullptr) {
fixLib = LoadLibraryA("MGSDSECore.dll");
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
return;
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
SetFPSFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFPSFixEnabled");
SetResolutionFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetResolutionFixEnabled");
SetAspectRatioFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetAspectRatioFixEnabled");
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetCAFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCAFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogFixEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn");
GetCompensadedFOV = (GetFloatFn)GetProcAddress(fixLib, "GetCompensatedFOV");
GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut");;
GetConsoleEnabled = (GetBoolFn)GetProcAddress(fixLib, "GetConsoleEnabled");
// Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue);
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetFPSFixEnabled) SetFPSFixEnabled(FPS_fix_enabled, true);
if (SetResolutionFixEnabled) SetResolutionFixEnabled(Resolution_fix_enabled, true);
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true);
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, true);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
SetFPSFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFPSFixEnabled");
SetResolutionFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetResolutionFixEnabled");
SetAspectRatioFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetAspectRatioFixEnabled");
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogFixEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn");
GetCompensadedFOV = (GetFloatFn)GetProcAddress(fixLib, "GetCompensatedFOV");
GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut");;
// Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue);
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetFPSFixEnabled) SetFPSFixEnabled(FPS_fix_enabled, true);
if (SetResolutionFixEnabled) SetResolutionFixEnabled(Resolution_fix_enabled, true);
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true);
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, true);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
}
// Settings functions
@@ -104,6 +124,7 @@ static void SaveSettings()
file << RESOLUTION_FIX_SETTING << (Resolution_fix_enabled ? "1" : "0") << "\n";
file << ASPECT_FIX_SETTING << (Aspect_fix_enabled ? "1" : "0") << "\n";
file << DOF_FIX_SETTING << (DOF_fix_enabled ? "1" : "0") << "\n";
file << CA_FIX_SETTING << (CA_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 << WORLD_FOV_SETTING << worldFOVvalue << "\n";
@@ -149,6 +170,11 @@ static void LoadSettings()
std::string val = line.substr(strlen(DOF_FIX_SETTING));
DOF_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(CA_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(CA_FIX_SETTING));
CA_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(VIGNETTING_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(VIGNETTING_FIX_SETTING));
@@ -167,136 +193,127 @@ static void LoadSettings()
}
}
// Fix informations
static void displayFixInformations() {
ImGui::SetNextWindowSize(ImVec2(250, 200));
ImGui::Begin("Informations", &popup_Informations); //
ImGui::SetCursorPos(ImVec2(10, 36));
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::SetCursorPos(ImVec2(10, 76));
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
// Initialize ImGui widgets for Reshade
static void on_overlay_draw(reshade::api::effect_runtime* runtime)
{
ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(350, 150), ImGuiCond_Once);
ImGuiStyle& style = ImGui::GetStyle();
style.ItemSpacing = ImVec2(8 * scale, 8 * scale); // Spacing between widgets
style.FramePadding = ImVec2(3 * scale, 3 * scale); // Widgets padding
style.WindowPadding = ImVec2(10 * scale, 10 * scale); // Overlay padding
style.CellPadding = ImVec2(10 * scale, 10 * scale); // Table cells padding
ImGui::SetNextWindowSize(ImVec2(350 * scale, 150 * scale), ImGuiCond_Once);
// Donation ?
ImGui::SetCursorPos(ImVec2(10, 36));
ImGui::Text("Like my work ?");
ImGui::SetCursorPos(ImVec2(130, 33));
if (ImGui::Button("consider donation"))
{
ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL);
}
// Fix informations
ImGui::SetCursorPos(ImVec2(270, 33));
if (ImGui::Button("Fix informations"))
popup_Informations = true;
if (ImGui::Button("Like my work ? Consider donation")) ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL);
ImGui::SameLine();
// Fix information
if (ImGui::Button("Fix informations")) popup_Informations = true;
if (popup_Informations)
displayFixInformations();
// Generic fix
ImGui::SetCursorPos(ImVec2(10, 60));
ImGui::BeginChild("AllFixesHeader", ImVec2(220, 0), false); // true = border
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
}
{
ImGui::Begin("Informations", &popup_Informations);
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
ImGui::EndChild();
// FOV adjustment
ImGui::SetCursorPos(ImVec2(10, 120));
ImGui::BeginChild("FOVHeader", ImVec2(220, 0), false);
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
ImGui::SetNextItemWidth(150.0f);
if (ImGui::SliderInt("", &worldFOVvalue, -20, 50)) {}
if (ImGui::IsItemDeactivatedAfterEdit()) {
if (SetFOV) SetFOV(worldFOVvalue);
SaveSettings();
if (ImGui::BeginTable("FixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("LeftFix", ImGuiTableColumnFlags_WidthStretch, 0.4f);
ImGui::TableSetupColumn("RightFix", ImGuiTableColumnFlags_WidthStretch, 0.6f);
ImGui::TableNextRow();
// Drawing a left column with slider and general fix
ImGui::TableSetColumnIndex(0);
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
}
// Sliders
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(150 * scale);
if (ImGui::SliderInt("##FOVValue", &worldFOVvalue, -20, 50)) {
if (SetFOV) SetFOV(worldFOVvalue); SaveSettings();
}
}
// Individual fixes
ImGui::TableSetColumnIndex(1);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.35f);
ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.65f);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Frame time", &FPS_fix_enabled)) {
if (SetFPSFixEnabled) SetFPSFixEnabled(FPS_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Fog", &Fog_fix_enabled)) {
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, false);
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();
}
ImGui::TableSetColumnIndex(1);
if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) {
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This fix is intended for ultrawide only.");
ImGui::EndTooltip();
}
if (ImGui::Checkbox("Resolution", &Resolution_fix_enabled)) {
if (SetResolutionFixEnabled) SetResolutionFixEnabled(Resolution_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Chromatic aberrations", &CA_fix_enabled)) {
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, false);
SaveSettings();
}
ImGui::EndTable();
}
}
ImGui::EndTable();
}
ImGui::EndChild();
// Individual fixes
ImGui::SetCursorPos(ImVec2(240, 60));
ImGui::BeginChild("IndividualFixesHeader", ImVec2(250, 0), false);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
}
ImGui::SetCursorPos(ImVec2(5, 55));
if (ImGui::Checkbox("Frame time", &FPS_fix_enabled)) {
if (SetFPSFixEnabled) SetFPSFixEnabled(FPS_fix_enabled, false);
SaveSettings();
}
ImGui::SetCursorPos(ImVec2(110, 55));
if (ImGui::Checkbox("Resolution", &Resolution_fix_enabled)) {
if (SetResolutionFixEnabled) SetResolutionFixEnabled(Resolution_fix_enabled, false);
SaveSettings();
}
ImGui::SetCursorPos(ImVec2(5, 80));
if (ImGui::Checkbox("Aspect ratio fix", &Aspect_fix_enabled)) {
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This doesn't remove pillar boxing in cutscenes.");
ImGui::EndTooltip();
}
ImGui::SetCursorPos(ImVec2(5, 105));
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
SaveSettings();
}
ImGui::SetCursorPos(ImVec2(5, 130));
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
SaveSettings();
}
ImGui::SetCursorPos(ImVec2(110, 130));
if (ImGui::Checkbox("Fog", &Fog_fix_enabled)) {
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, false);
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();
}
}
ImGui::EndChild();
// Fix status
ImGui::SetCursorPos(ImVec2(10, 240));
ImGui::BeginChild("INFOSHeader", ImVec2(480, 80), true);
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
ImGui::Text("FOV In: %.2f, Compensated : %.2f, Out : %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut());
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
if (GetConsoleEnabled && GetConsoleEnabled())
ImGui::Text("Console enabled and bound to key Tilde");
if (GetFOVIn && GetCompensadedFOV && GetFOVOut)
ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Compensated: %.2f, Out: %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut());
}
ImGui::EndChild();
}
// Main dll intrance

View File

@@ -5,8 +5,6 @@ VisualStudioVersion = 17.14.36212.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "South Of Midnight", "South Of Midnight\South Of Midnight.vcxproj", "{447F83EB-1D07-45A2-84EF-6313154C3FA6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "externe", "externe", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Days Gone", "Days Gone\Days Gone.vcxproj", "{4ECBBBA5-A265-464D-ADAC-311FB1C3FF38}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TLOU2", "TLOU2\TLOU2.vcxproj", "{B6A3DDFE-83BF-4B2C-B429-0EB36EAE544E}"
@@ -43,7 +41,19 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sword Of The Sea", "Sword O
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Metal Gear Solid Delta Snake Eater", "Metal Gear Solid Delta\MGSDelta.vcxproj", "{B0815637-8194-48E2-9862-3BA0D73FBEE5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Gears Of War Reloaded", "GOWR\GOWR.vcxproj", "{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cronos The New Dawn", "Cronos The New Dawn\CronosTND.vcxproj", "{CFE5F26D-A180-4ED1-B696-7985053B14BA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Silent Hill f", "SilentHillf\SilentHillf.vcxproj", "{122F77EF-8C36-43EA-96FA-3D0D3851CF01}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "includes", "includes", "{3514D178-6BD5-4744-849B-517AAE8343D4}"
ProjectSection(SolutionItems) = preProject
includes\GameInformations.h = includes\GameInformations.h
includes\inicpp.h = includes\inicpp.h
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Blood Of Mehran", "BloodOfMehran\BloodOfMehran.vcxproj", "{D2D8B784-7851-4D1D-8D54-8CD448390282}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Little Nightmare III", "LittleNightmareIII\LittleNightmareIII.vcxproj", "{25D45378-7E86-4677-BD77-238D2EC3005B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -205,14 +215,38 @@ Global
{B0815637-8194-48E2-9862-3BA0D73FBEE5}.Release|x64.Build.0 = Release|x64
{B0815637-8194-48E2-9862-3BA0D73FBEE5}.Release|x86.ActiveCfg = Release|Win32
{B0815637-8194-48E2-9862-3BA0D73FBEE5}.Release|x86.Build.0 = Release|Win32
{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}.Debug|x64.ActiveCfg = Debug|x64
{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}.Debug|x64.Build.0 = Debug|x64
{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}.Debug|x86.ActiveCfg = Debug|Win32
{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}.Debug|x86.Build.0 = Debug|Win32
{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}.Release|x64.ActiveCfg = Release|x64
{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}.Release|x64.Build.0 = Release|x64
{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}.Release|x86.ActiveCfg = Release|Win32
{6F54A5CD-8CB4-486B-B18B-ABA443100FB8}.Release|x86.Build.0 = Release|Win32
{CFE5F26D-A180-4ED1-B696-7985053B14BA}.Debug|x64.ActiveCfg = Debug|x64
{CFE5F26D-A180-4ED1-B696-7985053B14BA}.Debug|x64.Build.0 = Debug|x64
{CFE5F26D-A180-4ED1-B696-7985053B14BA}.Debug|x86.ActiveCfg = Debug|Win32
{CFE5F26D-A180-4ED1-B696-7985053B14BA}.Debug|x86.Build.0 = Debug|Win32
{CFE5F26D-A180-4ED1-B696-7985053B14BA}.Release|x64.ActiveCfg = Release|x64
{CFE5F26D-A180-4ED1-B696-7985053B14BA}.Release|x64.Build.0 = Release|x64
{CFE5F26D-A180-4ED1-B696-7985053B14BA}.Release|x86.ActiveCfg = Release|Win32
{CFE5F26D-A180-4ED1-B696-7985053B14BA}.Release|x86.Build.0 = Release|Win32
{122F77EF-8C36-43EA-96FA-3D0D3851CF01}.Debug|x64.ActiveCfg = Debug|x64
{122F77EF-8C36-43EA-96FA-3D0D3851CF01}.Debug|x64.Build.0 = Debug|x64
{122F77EF-8C36-43EA-96FA-3D0D3851CF01}.Debug|x86.ActiveCfg = Debug|Win32
{122F77EF-8C36-43EA-96FA-3D0D3851CF01}.Debug|x86.Build.0 = Debug|Win32
{122F77EF-8C36-43EA-96FA-3D0D3851CF01}.Release|x64.ActiveCfg = Release|x64
{122F77EF-8C36-43EA-96FA-3D0D3851CF01}.Release|x64.Build.0 = Release|x64
{122F77EF-8C36-43EA-96FA-3D0D3851CF01}.Release|x86.ActiveCfg = Release|Win32
{122F77EF-8C36-43EA-96FA-3D0D3851CF01}.Release|x86.Build.0 = Release|Win32
{D2D8B784-7851-4D1D-8D54-8CD448390282}.Debug|x64.ActiveCfg = Debug|x64
{D2D8B784-7851-4D1D-8D54-8CD448390282}.Debug|x64.Build.0 = Debug|x64
{D2D8B784-7851-4D1D-8D54-8CD448390282}.Debug|x86.ActiveCfg = Debug|Win32
{D2D8B784-7851-4D1D-8D54-8CD448390282}.Debug|x86.Build.0 = Debug|Win32
{D2D8B784-7851-4D1D-8D54-8CD448390282}.Release|x64.ActiveCfg = Release|x64
{D2D8B784-7851-4D1D-8D54-8CD448390282}.Release|x64.Build.0 = Release|x64
{D2D8B784-7851-4D1D-8D54-8CD448390282}.Release|x86.ActiveCfg = Release|Win32
{D2D8B784-7851-4D1D-8D54-8CD448390282}.Release|x86.Build.0 = Release|Win32
{25D45378-7E86-4677-BD77-238D2EC3005B}.Debug|x64.ActiveCfg = Debug|x64
{25D45378-7E86-4677-BD77-238D2EC3005B}.Debug|x64.Build.0 = Debug|x64
{25D45378-7E86-4677-BD77-238D2EC3005B}.Debug|x86.ActiveCfg = Debug|Win32
{25D45378-7E86-4677-BD77-238D2EC3005B}.Debug|x86.Build.0 = Debug|Win32
{25D45378-7E86-4677-BD77-238D2EC3005B}.Release|x64.ActiveCfg = Release|x64
{25D45378-7E86-4677-BD77-238D2EC3005B}.Release|x64.Build.0 = Release|x64
{25D45378-7E86-4677-BD77-238D2EC3005B}.Release|x86.ActiveCfg = Release|Win32
{25D45378-7E86-4677-BD77-238D2EC3005B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{122F77EF-8C36-43EA-96FA-3D0D3851CF01}</ProjectGuid>
<RootNamespace>Silent Hill f</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>Silent Hill f</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetExt>.addon</TargetExt>
<TargetName>SilentHillfUI</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetExt>.addon</TargetExt>
<TargetName>SilentHillfUI</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetExt>.addon</TargetExt>
<TargetName>SilentHillfUI</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetExt>.addon</TargetExt>
<TargetName>SilentHillfUI</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
<WholeProgramOptimization>true</WholeProgramOptimization>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp20</LanguageStandard>
<WholeProgramOptimization>true</WholeProgramOptimization>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\reshade\include;$(SolutionDir)external\reshade\deps\imgui;$(SolutionDir)includes</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WholeProgramOptimization>true</WholeProgramOptimization>
<LanguageStandard>stdcpp20</LanguageStandard>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

396
SilentHillf/dllmain.cpp Normal file
View File

@@ -0,0 +1,396 @@
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
#define IMGUI_HAS_DOCK 1
#include "GameInformations.h"
#include "inicpp.h"
#include <imgui.h>
#include <reshade.hpp>
#include <string>
#include <Windows.h>
// Screen informations
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
static float aspectRatio = (float)screenWidth / screenHeight;
// Core game dll functions declarations
typedef void (*SetBoolFn)(bool, bool);
typedef void (*SetIntFn)(int);
typedef void (*SetFloatFn)(float);
typedef float (*GetFloatFn)();
typedef bool (*GetBoolFn)();
static HMODULE fixLib = nullptr;
static LONG g_coreInitialized = 0;
static SetBoolFn SetFixEnabled = nullptr;
static SetBoolFn SetFOVFixEnabled = nullptr;
static SetBoolFn SetDOFFixEnabled = nullptr;
static SetBoolFn SetCAFixEnabled = nullptr;
static SetBoolFn SetVignettingFixEnabled = nullptr;
static SetBoolFn SetCameraFixEnabled = nullptr;
static SetBoolFn SetCutscenesFixEnabled = nullptr;
static SetBoolFn SetCutscenesFPSFixEnabled = nullptr;
static SetBoolFn SetVolumetricFogFixEnabled = nullptr;
static SetBoolFn SetFogDensityFixEnabled = nullptr;
static SetBoolFn SetFogMaxOpacityFixEnabled = nullptr;
static SetIntFn SetFOV = nullptr;
static SetFloatFn SetCameraDistance = nullptr;
static SetFloatFn SetFogDensity = nullptr;
static SetFloatFn SetFogMaxOpacity = nullptr;
static GetGameInfosStruct GetGameInfos = nullptr;
// Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false;
static bool DOF_fix_enabled = false;
static bool CA_fix_enabled = false;
static bool Vignetting_fix_enabled = false;
static bool camera_fix_enabled = false;
static bool cutscenes_fix_enabled = false;
static bool cutscenes_FPS_fix_enabled = false;
static bool volumetric_fog_fix_enabled = false;
static bool Fog_density_fix_enabled = false;
static bool Fog_max_opacity_fix_enabled = false;
static bool fix_enabled = false;
static int worldFOVvalue = 0;
static float cameraDistanceValue = 1.f;
static float fogDensityValue = 0.1f;
static float fogMaxOpacityValue = 1.f;
static bool popup_Informations = false;
// Plugin settings
const std::string SETTINGS_FILE = "./pluginsettings.ini";
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 cutscenes FPS and enable ultrawide.\n - Disable depth of field.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Control fog.\n - Re enable console.\n\nDisabling Fog will not entirely remove it.";
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
// Scaling factor based on screen resolution
float scale = 1.f;
inline std::string toStringPrecision(float value, int precision) {
char buffer[64];
std::snprintf(buffer, sizeof(buffer), ("%." + std::to_string(precision) + "f").c_str(), value);
return std::string(buffer);
}
// Load and unload game core dll functions /!\ necessary
static void LoadFixDLL()
{
if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0)
return;
if (GetModuleHandleA("SilentHillfCore.dll") == nullptr) {
fixLib = LoadLibraryA("SilentHillfCore.dll");
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
return;
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetCAFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCAFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetVolumetricFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVolumetricFogFixEnabled");
SetFogDensityFixEnabled = (SetBoolFn)GetProcAddress(fixLib,"SetFogDensityFixEnabled");
SetFogMaxOpacityFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogMaxOpacityFixEnabled");
SetCameraFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCameraFixEnabled");
SetCutscenesFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCutscenesFixEnabled");
SetCutscenesFPSFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCutscenesFPSFixEnabled");
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 (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetCameraFixEnabled) SetCameraFixEnabled(camera_fix_enabled, true);
if (SetCutscenesFixEnabled) SetCutscenesFixEnabled(cutscenes_fix_enabled, true);
if (SetCutscenesFPSFixEnabled) SetCutscenesFPSFixEnabled(cutscenes_FPS_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true);
if (SetVolumetricFogFixEnabled) SetVolumetricFogFixEnabled(volumetric_fog_fix_enabled, true);
if (SetFogDensityFixEnabled) SetFogDensityFixEnabled(Fog_density_fix_enabled, true);
if (SetFogMaxOpacityFixEnabled) SetFogMaxOpacityFixEnabled(Fog_max_opacity_fix_enabled, true);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
}
}
// Settings functions
static void SaveSettings()
{
ini::IniFile pluginIniFile;
pluginIniFile["1#General fix"].setComment(std::vector<std::string>{ "The following sections are saved by plugin",
"You should not need to modify them",
" ",
"Controls if fix mod (globally) is enabled" });
pluginIniFile["1#General fix"]["Enabled"] = fix_enabled;
pluginIniFile["2#Individual fix"].setComment("Controls each fix individually");
pluginIniFile["2#Individual fix"]["FOV"] = fov_fix_enabled;
pluginIniFile["2#Individual fix"]["Camera"] = camera_fix_enabled;
pluginIniFile["2#Individual fix"]["Cutscenes"] = cutscenes_fix_enabled;
pluginIniFile["2#Individual fix"]["CutscenesFPS"] = cutscenes_FPS_fix_enabled;
pluginIniFile["2#Individual fix"]["DOF"] = DOF_fix_enabled;
pluginIniFile["2#Individual fix"]["Chromatic aberrations"] = CA_fix_enabled;
pluginIniFile["2#Individual fix"]["Vignetting"] = Vignetting_fix_enabled;
pluginIniFile["2#Individual fix"]["Volumetric fog"] = volumetric_fog_fix_enabled;
pluginIniFile["2#Individual fix"]["Fog density"] = Fog_density_fix_enabled;
pluginIniFile["2#Individual fix"]["Fog opacity"] = Fog_max_opacity_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()
{
ini::IniFile pluginIniFile;
try {
pluginIniFile.load(SETTINGS_FILE);
fix_enabled = pluginIniFile["1#General fix"]["Enabled"].as<bool>();
fov_fix_enabled = pluginIniFile["2#Individual fix"]["FOV"].as<bool>();
camera_fix_enabled = pluginIniFile["2#Individual fix"]["Camera"].as<bool>();
cutscenes_fix_enabled = pluginIniFile["2#Individual fix"]["Cutscenes"].as<bool>();
cutscenes_FPS_fix_enabled = pluginIniFile["2#Individual fix"]["CutscenesFPS"].as<bool>();
DOF_fix_enabled = pluginIniFile["2#Individual fix"]["DOF"].as<bool>();
CA_fix_enabled = pluginIniFile["2#Individual fix"]["Chromatic aberrations"].as<bool>();
Vignetting_fix_enabled = pluginIniFile["2#Individual fix"]["Vignetting"].as<bool>();
volumetric_fog_fix_enabled = pluginIniFile["2#Individual fix"]["Volumetric fog"].as<bool>();
Fog_density_fix_enabled = pluginIniFile["2#Individual fix"]["Fog density"].as<bool>();
Fog_max_opacity_fix_enabled = pluginIniFile["2#Individual fix"]["Fog opacity"].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) {}
}
// Initialize ImGui widgets for Reshade
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
style.WindowPadding = ImVec2(10 * scale, 10 * scale); // Overlay padding
style.CellPadding = ImVec2(10 * scale, 10 * scale); // Table cells padding
ImGui::SetNextWindowSize(ImVec2(350 * scale, 150 * scale), ImGuiCond_Once);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.84f, 0.12f, 0.51f, 1.0f)); // red
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.84f, 0.12f, 0.51f, 1.0f)); // red
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.84f, 0.2f, 0.51f, 1.0f)); // red
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 1.f, 1.f, 1.f)); // white
if (ImGui::Button("Like my work ? Consider donation")) ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL); // Donation
ImGui::PopStyleColor(4); // Restore color
ImGui::SameLine();
if (ImGui::Button("Fix informations")) popup_Informations = true; // Fix information
if (popup_Informations)
{
ImGui::Begin("Informations", &popup_Informations);
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
if (ImGui::BeginTable("FixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("LeftFix", ImGuiTableColumnFlags_WidthStretch, 0.3f);
ImGui::TableSetupColumn("RightFix", ImGuiTableColumnFlags_WidthStretch, 0.7f);
ImGui::TableNextRow();
// Drawing a left column with slider and general fix
ImGui::TableSetColumnIndex(0);
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
}
// Individual fixes
ImGui::TableSetColumnIndex(1);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.35f);
ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.65f);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Cutscenes", &cutscenes_fix_enabled)) {
if (SetCutscenesFixEnabled) SetCutscenesFixEnabled(cutscenes_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Must be enabled before playing cutscenes.");
ImGui::EndTooltip();
}
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Fog density", &Fog_density_fix_enabled)) {
if (SetFogDensityFixEnabled) SetFogDensityFixEnabled(Fog_density_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Fog opacity", &Fog_max_opacity_fix_enabled)) {
if (SetFogMaxOpacityFixEnabled) SetFogMaxOpacityFixEnabled(Fog_max_opacity_fix_enabled, false);
SaveSettings();
}
ImGui::TableSetColumnIndex(1);
if (ImGui::Checkbox("Camera", &camera_fix_enabled)) {
if (SetCameraFixEnabled) SetCameraFixEnabled(camera_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Cutscenes FPS", &cutscenes_FPS_fix_enabled)) {
if (SetCutscenesFPSFixEnabled) SetCutscenesFPSFixEnabled(cutscenes_FPS_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Must be enabled before playing cutscenes.");
ImGui::EndTooltip();
}
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Chromatic aberrations", &CA_fix_enabled)) {
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, false);
SaveSettings();
}
if (ImGui::Checkbox("Volumetric fog", &volumetric_fog_fix_enabled)) {
if (SetVolumetricFogFixEnabled) SetVolumetricFogFixEnabled(volumetric_fog_fix_enabled, false);
SaveSettings();
}
ImGui::EndTable();
}
}
ImGui::EndTable();
}
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 2 * style.ItemSpacing.y);
if (ImGui::BeginTable("FixesSliders", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableNextRow();
// Sliders
ImGui::TableSetColumnIndex(0);
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(180 * scale);
if (ImGui::SliderInt("##FOVValue", &worldFOVvalue, -20, 50)) {
if (SetFOV) SetFOV(worldFOVvalue);
SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This will affect in game FOV only.");
ImGui::EndTooltip();
}
if (ImGui::CollapsingHeader("Camera distance (*)", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(180 * scale);
if (ImGui::SliderFloat("##CameraDistanceValue", &cameraDistanceValue, 0, 3, "%.2f")) {
if (SetCameraDistance) SetCameraDistance(cameraDistanceValue);
SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Value is a multiplier.");
ImGui::EndTooltip();
}
ImGui::TableSetColumnIndex(1);
if (ImGui::CollapsingHeader("Fog density (*)", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(180 * scale);
if (ImGui::SliderFloat("##FogDensityValue", &fogDensityValue, 0, 5, "%.2f")) {
if (SetFogDensity) SetFogDensity(fogDensityValue);
SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This will override engine dynamic value.");
ImGui::EndTooltip();
}
if (ImGui::CollapsingHeader("Fog opacity (*)", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::SetNextItemWidth(180 * scale);
if (ImGui::SliderFloat("##FogOpacityValue", &fogMaxOpacityValue, 0, 1, "%.2f")) {
if (SetFogMaxOpacity) SetFogMaxOpacity(fogMaxOpacityValue);
SaveSettings();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("This will override engine dynamic value.");
ImGui::EndTooltip();
}
ImGui::EndTable();
}
// Fix status
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
if (GetGameInfos) {
GameInfos infos{};
GetGameInfos(&infos);
if (infos.consoleEnabled)
ImGui::Text("Console enabled and bound to key Tilde");
ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Out: %.2f", infos.FOVIn, infos.FOVOut);
ImGui::TextColored(ImColor(48, 179, 25), "Camera distance In: %.2f, Out: %.2f", infos.cameraIn, infos.cameraOut);
ImGui::TextColored(ImColor(48, 179, 25), "Default fog density: %.3f, opacity: %3.f", infos.defaultFogDensity, infos.fogMaxOpacity);
}
}
}
// Main dll intrance
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;
LoadSettings();
reshade::register_overlay("Silent Hill f", &on_overlay_draw);
reshade::register_event<reshade::addon_event::init_effect_runtime>(
[](reshade::api::effect_runtime* runtime) {
LoadFixDLL();
});
break;
case DLL_PROCESS_DETACH:
reshade::unregister_addon(hinstDLL);
break;
}
return TRUE;
}

View File

@@ -0,0 +1,14 @@
#pragma once
// Shared structure values with Core dll
struct GameInfos {
float FOVIn;
float FOVOut;
float cameraIn;
float cameraOut;
float defaultFogDensity;
float fogMaxOpacity;
bool consoleEnabled;
};
typedef void(*GetGameInfosStruct)(GameInfos*);

808
includes/inicpp.h Normal file
View File

@@ -0,0 +1,808 @@
/*
* inicpp.h
*
* Created on: 26 Dec 2015
* Author: Fabian Meyer
* License: MIT
* https://github.com/Rookfighter/inifile-cpp
*/
#ifndef INICPP_H_
#define INICPP_H_
#include <algorithm>
#include <fstream>
#include <istream>
#include <map>
#include <assert.h>
#include <sstream>
#include <stdexcept>
#include <vector>
#include <string>
#ifdef __cpp_lib_string_view // This one is defined in <string> if we have std::string_view
# include <string_view>
#endif
namespace ini
{
/************************************************
* Helper Functions
************************************************/
/** Returns a string of whitespace characters. */
constexpr const char *whitespaces()
{
return " \t\n\r\f\v";
}
/** Returns a string of indentation characters. */
constexpr const char *indents()
{
return " \t";
}
/** Trims a string in place.
* @param str string to be trimmed in place */
inline void trim(std::string &str)
{
// first erasing from end should be slighty more efficient
// because erasing from start potentially moves all chars
// multiple indices towards the front.
auto lastpos = str.find_last_not_of(whitespaces());
if(lastpos == std::string::npos)
{
str.clear();
return;
}
str.erase(lastpos + 1);
str.erase(0, str.find_first_not_of(whitespaces()));
}
/************************************************
* Conversion Functors
************************************************/
inline bool strToLong(const std::string &value, long &result)
{
char *endptr;
// check if decimal
result = std::strtol(value.c_str(), &endptr, 10);
if(*endptr == '\0')
return true;
// check if octal
result = std::strtol(value.c_str(), &endptr, 8);
if(*endptr == '\0')
return true;
// check if hex
result = std::strtol(value.c_str(), &endptr, 16);
if(*endptr == '\0')
return true;
return false;
}
inline bool strToULong(const std::string &value, unsigned long &result)
{
char *endptr;
// check if decimal
result = std::strtoul(value.c_str(), &endptr, 10);
if(*endptr == '\0')
return true;
// check if octal
result = std::strtoul(value.c_str(), &endptr, 8);
if(*endptr == '\0')
return true;
// check if hex
result = std::strtoul(value.c_str(), &endptr, 16);
if(*endptr == '\0')
return true;
return false;
}
template<typename T>
struct Convert
{};
template<>
struct Convert<bool>
{
void decode(const std::string &value, bool &result)
{
std::string str(value);
std::transform(str.begin(), str.end(), str.begin(), [](const char c){
return static_cast<char>(::toupper(c));
});
if(str == "TRUE")
result = true;
else if(str == "FALSE")
result = false;
else
throw std::invalid_argument("field is not a bool");
}
void encode(const bool value, std::string &result)
{
result = value ? "true" : "false";
}
};
template<>
struct Convert<char>
{
void decode(const std::string &value, char &result)
{
assert(value.size() > 0);
result = value[0];
}
void encode(const char value, std::string &result)
{
result = value;
}
};
template<>
struct Convert<unsigned char>
{
void decode(const std::string &value, unsigned char &result)
{
assert(value.size() > 0);
result = value[0];
}
void encode(const unsigned char value, std::string &result)
{
result = value;
}
};
template<>
struct Convert<short>
{
void decode(const std::string &value, short &result)
{
long tmp;
if(!strToLong(value, tmp))
throw std::invalid_argument("field is not a short");
result = static_cast<short>(tmp);
}
void encode(const short value, std::string &result)
{
std::stringstream ss;
ss << value;
result = ss.str();
}
};
template<>
struct Convert<unsigned short>
{
void decode(const std::string &value, unsigned short &result)
{
unsigned long tmp;
if(!strToULong(value, tmp))
throw std::invalid_argument("field is not an unsigned short");
result = static_cast<unsigned short>(tmp);
}
void encode(const unsigned short value, std::string &result)
{
std::stringstream ss;
ss << value;
result = ss.str();
}
};
template<>
struct Convert<int>
{
void decode(const std::string &value, int &result)
{
long tmp;
if(!strToLong(value, tmp))
throw std::invalid_argument("field is not an int");
result = static_cast<int>(tmp);
}
void encode(const int value, std::string &result)
{
std::stringstream ss;
ss << value;
result = ss.str();
}
};
template<>
struct Convert<unsigned int>
{
void decode(const std::string &value, unsigned int &result)
{
unsigned long tmp;
if(!strToULong(value, tmp))
throw std::invalid_argument("field is not an unsigned int");
result = static_cast<unsigned int>(tmp);
}
void encode(const unsigned int value, std::string &result)
{
std::stringstream ss;
ss << value;
result = ss.str();
}
};
template<>
struct Convert<long>
{
void decode(const std::string &value, long &result)
{
if(!strToLong(value, result))
throw std::invalid_argument("field is not a long");
}
void encode(const long value, std::string &result)
{
std::stringstream ss;
ss << value;
result = ss.str();
}
};
template<>
struct Convert<unsigned long>
{
void decode(const std::string &value, unsigned long &result)
{
if(!strToULong(value, result))
throw std::invalid_argument("field is not an unsigned long");
}
void encode(const unsigned long value, std::string &result)
{
std::stringstream ss;
ss << value;
result = ss.str();
}
};
template<>
struct Convert<double>
{
void decode(const std::string &value, double &result)
{
result = std::stod(value);
}
void encode(const double value, std::string &result)
{
std::stringstream ss;
ss << value;
result = ss.str();
}
};
template<>
struct Convert<float>
{
void decode(const std::string &value, float &result)
{
result = std::stof(value);
}
void encode(const float value, std::string &result)
{
std::stringstream ss;
ss << value;
result = ss.str();
}
};
template<>
struct Convert<std::string>
{
void decode(const std::string &value, std::string &result)
{
result = value;
}
void encode(const std::string &value, std::string &result)
{
result = value;
}
};
#ifdef __cpp_lib_string_view
template<>
struct Convert<std::string_view>
{
void decode(const std::string &value, std::string_view &result)
{
result = value;
}
void encode(const std::string_view value, std::string &result)
{
result = value;
}
};
#endif
template<>
struct Convert<const char*>
{
void encode(const char* const &value, std::string &result)
{
result = value;
}
void decode(const std::string &value, const char* &result)
{
result = value.c_str();
}
};
template<>
struct Convert<char*>
{
void encode(const char* const &value, std::string &result)
{
result = value;
}
};
template<size_t n>
struct Convert<char[n]>
{
void encode(const char *value, std::string &result)
{
result = value;
}
};
class IniField
{
private:
std::string value_;
public:
IniField() : value_()
{}
IniField(const std::string &value) : value_(value)
{}
IniField(const IniField &field) : value_(field.value_)
{}
~IniField()
{}
template<typename T>
T as() const
{
Convert<T> conv;
T result;
conv.decode(value_, result);
return result;
}
template<typename T>
IniField &operator=(const T &value)
{
Convert<T> conv;
conv.encode(value, value_);
return *this;
}
IniField &operator=(const IniField &field)
{
value_ = field.value_;
return *this;
}
};
struct StringInsensitiveLess
{
bool operator()(std::string lhs, std::string rhs) const
{
std::transform(lhs.begin(), lhs.end(), lhs.begin(), [](const char c){
return static_cast<char>(::tolower(c));
});
std::transform(rhs.begin(), rhs.end(), rhs.begin(), [](const char c){
return static_cast<char>(::tolower(c));
});
return lhs < rhs;
}
};
template <typename Comparator>
class IniSectionBase : public std::map<std::string, IniField, Comparator>
{
public:
IniSectionBase()
{}
~IniSectionBase()
{}
void setComment(const std::vector<std::string>& c) { comment_.insert(comment_.end(), c.begin(), c.end()); }
void setComment(const std::string& c) { comment_.push_back(c); }
const std::vector<std::string>& getComment() const { return comment_; }
private:
std::vector<std::string> comment_; // Section comment
};
using IniSection = IniSectionBase<std::less<std::string>>;
using IniSectionCaseInsensitive = IniSectionBase<StringInsensitiveLess>;
template <typename Comparator>
class IniFileBase : public std::map<std::string, IniSectionBase<Comparator>, Comparator>
{
private:
char fieldSep_ = '=';
char esc_ = '\\';
//std::vector<std::string> commentPrefixes_ = { "#" , ";" };
std::vector<std::string> commentPrefixes_ = { ";" };
bool multiLineValues_ = false;
bool overwriteDuplicateFields_ = true;
void eraseComment(const std::string &commentPrefix,
std::string &str,
std::string::size_type startpos = 0)
{
size_t prefixpos = str.find(commentPrefix, startpos);
if(std::string::npos == prefixpos)
return;
// Found a comment prefix, is it escaped?
if(0 != prefixpos && str[prefixpos - 1] == esc_)
{
// The comment prefix is escaped, so just delete the escape char
// and keep erasing after the comment prefix
str.erase(prefixpos - 1, 1);
eraseComment(
commentPrefix, str, prefixpos - 1 + commentPrefix.size());
}
else
{
str.erase(prefixpos);
}
}
void eraseComments(std::string &str)
{
for(const std::string &commentPrefix : commentPrefixes_)
eraseComment(commentPrefix, str);
}
/** Tries to find a suitable comment prefix for the string data at the given
* position. Returns commentPrefixes_.end() if not match was found. */
std::vector<std::string>::const_iterator findCommentPrefix(const std::string &str,
const std::size_t startpos) const
{
// if startpos is invalid simply return "not found"
if(startpos >= str.size())
return commentPrefixes_.end();
for(size_t i = 0; i < commentPrefixes_.size(); ++i)
{
const std::string &prefix = commentPrefixes_[i];
// if this comment prefix is longer than the string view itself
// then skip
if(prefix.size() + startpos > str.size())
continue;
bool match = true;
for(size_t j = 0; j < prefix.size() && match; ++j)
match = str[startpos + j] == prefix[j];
if(match)
return commentPrefixes_.begin() + i;
}
return commentPrefixes_.end();
}
void writeEscaped(std::ostream &os, const std::string &str) const
{
for(size_t i = 0; i < str.length(); ++i)
{
auto prefixpos = findCommentPrefix(str, i);
// if no suitable prefix was found at this position
// then simply write the current character
if(prefixpos != commentPrefixes_.end())
{
const std::string &prefix = *prefixpos;
os.put(esc_);
os.write(prefix.c_str(), prefix.size());
i += prefix.size() - 1;
}
else if (multiLineValues_ && str[i] == '\n')
os.write("\n\t", 2);
else
os.put(str[i]);
}
}
public:
IniFileBase() = default;
IniFileBase(const char fieldSep, const char comment)
: fieldSep_(fieldSep), commentPrefixes_(1, std::string(1, comment))
{}
IniFileBase(const std::string &filename)
{
load(filename);
}
IniFileBase(std::istream &is)
{
decode(is);
}
IniFileBase(const char fieldSep,
const std::vector<std::string> &commentPrefixes)
: fieldSep_(fieldSep), commentPrefixes_(commentPrefixes)
{}
IniFileBase(const std::string &filename,
const char fieldSep,
const std::vector<std::string> &commentPrefixes)
: fieldSep_(fieldSep), commentPrefixes_(commentPrefixes)
{
load(filename);
}
IniFileBase(std::istream &is,
const char fieldSep,
const std::vector<std::string> &commentPrefixes)
: fieldSep_(fieldSep), commentPrefixes_(commentPrefixes)
{
decode(is);
}
~IniFileBase()
{}
/** Sets the separator charactor for fields in the INI file.
* @param sep separator character to be used. */
void setFieldSep(const char sep)
{
fieldSep_ = sep;
}
/** Sets the character that should be interpreted as the start of comments.
* Default is '#'.
* Note: If the inifile contains the comment character as data it must be prefixed with
* the configured escape character.
* @param comment comment character to be used. */
void setCommentChar(const char comment)
{
commentPrefixes_ = {std::string(1, comment)};
}
/** Sets the list of strings that should be interpreted as the start of comments.
* Default is [ "#" ].
* Note: If the inifile contains any comment string as data it must be prefixed with
* the configured escape character.
* @param commentPrefixes vector of comment prefix strings to be used. */
void setCommentPrefixes(const std::vector<std::string> &commentPrefixes)
{
commentPrefixes_ = commentPrefixes;
}
/** Sets the character that should be used to escape comment prefixes.
* Default is '\'.
* @param esc escape character to be used. */
void setEscapeChar(const char esc)
{
esc_ = esc;
}
/** Sets whether or not to parse multi-line field values.
* Default is false.
* @param enable enable or disable? */
void setMultiLineValues(bool enable)
{
multiLineValues_ = enable;
}
/** Sets whether or not overwriting duplicate fields is allowed.
* If overwriting duplicate fields is not allowed,
* an exception is thrown when a duplicate field is found inside a section.
* Default is true.
* @param allowed Is overwriting duplicate fields allowed or not? */
void allowOverwriteDuplicateFields(bool allowed)
{
overwriteDuplicateFields_ = allowed;
}
/** Tries to decode a ini file from the given input stream.
* @param is input stream from which data should be read. */
void decode(std::istream &is)
{
this->clear();
int lineNo = 0;
IniSectionBase<Comparator> *currentSection = nullptr;
std::string mutliLineValueFieldName = "";
std::string line;
// iterate file line by line
while(!is.eof() && !is.fail())
{
std::getline(is, line, '\n');
eraseComments(line);
bool hasIndent = line.find_first_not_of(indents()) != 0;
trim(line);
++lineNo;
// skip if line is empty
if(line.size() == 0)
continue;
if(line[0] == '[')
{
// line is a section
// check if the section is also closed on same line
std::size_t pos = line.find("]");
if(pos == std::string::npos)
{
std::stringstream ss;
ss << "l." << lineNo
<< ": ini parsing failed, section not closed";
throw std::logic_error(ss.str());
}
// check if the section name is empty
if(pos == 1)
{
std::stringstream ss;
ss << "l." << lineNo
<< ": ini parsing failed, section is empty";
throw std::logic_error(ss.str());
}
// retrieve section name
std::string secName = line.substr(1, pos - 1);
currentSection = &((*this)[secName]);
// clear multiline value field name
// a new section means there is no value to continue
mutliLineValueFieldName = "";
}
else
{
// line is a field definition
// check if section was already opened
if(currentSection == nullptr)
{
std::stringstream ss;
ss << "l." << lineNo
<< ": ini parsing failed, field has no section"
" or ini file in use by another application";
throw std::logic_error(ss.str());
}
// find key value separator
std::size_t pos = line.find(fieldSep_);
if (multiLineValues_ && hasIndent && mutliLineValueFieldName != "")
{
// extend a multi-line value
IniField previous_value = (*currentSection)[mutliLineValueFieldName];
std::string value = previous_value.as<std::string>() + "\n" + line;
(*currentSection)[mutliLineValueFieldName] = value;
}
else if(pos == std::string::npos)
{
std::stringstream ss;
ss << "l." << lineNo
<< ": ini parsing failed, no '"
<< fieldSep_
<< "' found";
if (multiLineValues_)
ss << ", and not a multi-line value continuation";
throw std::logic_error(ss.str());
}
else
{
// retrieve field name and value
std::string name = line.substr(0, pos);
trim(name);
if (!overwriteDuplicateFields_ && currentSection->count(name) != 0)
{
std::stringstream ss;
ss << "l." << lineNo
<< ": ini parsing failed, duplicate field found";
throw std::logic_error(ss.str());
}
std::string value = line.substr(pos + 1, std::string::npos);
trim(value);
(*currentSection)[name] = value;
// store last field name for potential multi-line values
mutliLineValueFieldName = name;
}
}
}
}
/** Tries to decode a ini file from the given input string.
* @param content string to be decoded. */
void decode(const std::string &content)
{
std::istringstream ss(content);
decode(ss);
}
/** Tries to load and decode a ini file from the file at the given path.
* @param fileName path to the file that should be loaded. */
void load(const std::string &fileName)
{
std::ifstream is(fileName.c_str());
decode(is);
}
/** Encodes this inifile object and writes the output to the given stream.
* @param os target stream. */
void encode(std::ostream &os) const
{
// iterate through all sections in this file
for(const auto &filePair : *this)
{
const auto& sec = filePair.second;
if (!sec.getComment().empty())
{
for (auto comment : sec.getComment()) {
std::istringstream iss(comment);
std::string line;
while (std::getline(iss, line))
os << "; " << line << '\n';
}
}
os.put('[');
writeEscaped(os, filePair.first);
os.put(']');
os.put('\n');
// iterate through all fields in the section
for(const auto &secPair : filePair.second)
{
writeEscaped(os, secPair.first);
os.put(fieldSep_);
writeEscaped(os, secPair.second.template as<std::string>());
os.put('\n');
}
// Add a newline after each section
os.put('\n');
}
}
/** Encodes this inifile object as string and returns the result.
* @return encoded infile string. */
std::string encode() const
{
std::ostringstream ss;
encode(ss);
return ss.str();
}
/** Saves this inifile object to the file at the given path.
* @param fileName path to the file where the data should be stored. */
void save(const std::string &fileName) const
{
std::ofstream os(fileName.c_str());
encode(os);
}
};
using IniFile = IniFileBase<std::less<std::string>>;
using IniSection = IniSectionBase<std::less<std::string>>;
using IniFileCaseInsensitive = IniFileBase<StringInsensitiveLess>;
using IniSectionCaseInsensitive = IniSectionBase<StringInsensitiveLess>;
}
#endif