Change ini file management. Version bump. Change default sliders formats
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
#define IMGUI_HAS_DOCK 1
|
||||
|
||||
#include "GameInformations.h"
|
||||
#include "inicpp.h"
|
||||
#include <imgui.h>
|
||||
#include <reshade.hpp>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
|
||||
@@ -49,33 +49,26 @@ 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.4f;
|
||||
static float fogMaxOpacityValue = 0.4f;
|
||||
static float fogDensityValue = 0.1f;
|
||||
static float fogMaxOpacityValue = 1.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* CAMERA_FIX_SETTING = "CameraFIX=";
|
||||
const char* DOF_FIX_SETTING = "DOFFIX=";
|
||||
const char* CA_FIX_SETTING = "CAFIX=";
|
||||
const char* VIGNETTING_FIX_SETTING = "VignettingFIX=";
|
||||
const char* VOLUMETRIC_FOG_FIX_SETTING = "VolumetricFogFIX=";
|
||||
const char* FOG_DENSITY_FIX_SETTING = "FogDensityFIX=";
|
||||
const char* FOG_MAX_OPACITY_FIX_SETTING = "FogMaxOpacityFIX=";
|
||||
const char* WORLD_FOV_SETTING = "WorldFOV=";
|
||||
const char* CAMERA_DISTANCE_SETTING = "CameraDistance=";
|
||||
const char* FOG_DENSITY_SETTING = "FogDensity=";
|
||||
const char* FOG_MAX_OPACITY_SETTING = "FogMaxOpacity=";
|
||||
const char* FIX_VERSION = "1.0.3";
|
||||
const std::string SETTINGS_FILE = "./pluginsettings.ini";
|
||||
const char* FIX_VERSION = "1.0.3.1";
|
||||
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Control camera distance.\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()
|
||||
{
|
||||
@@ -125,90 +118,50 @@ static void LoadFixDLL()
|
||||
// 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 << CAMERA_FIX_SETTING << (camera_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 << VOLUMETRIC_FOG_FIX_SETTING << (volumetric_fog_fix_enabled ? "1" : "0") << "\n";
|
||||
file << FOG_DENSITY_FIX_SETTING << (Fog_density_fix_enabled ? "1" : "0") << "\n";
|
||||
file << FOG_MAX_OPACITY_FIX_SETTING << (Fog_max_opacity_fix_enabled ? "1" : "0") << "\n";
|
||||
file << WORLD_FOV_SETTING << worldFOVvalue << "\n";
|
||||
file << CAMERA_DISTANCE_SETTING << cameraDistanceValue << "\n";
|
||||
file << FOG_DENSITY_SETTING << fogDensityValue << "\n";
|
||||
file << FOG_MAX_OPACITY_SETTING << fogMaxOpacityValue << "\n";
|
||||
file.close();
|
||||
}
|
||||
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"]["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()
|
||||
{
|
||||
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(CAMERA_FIX_SETTING) == 0)
|
||||
{
|
||||
std::string val = line.substr(strlen(CAMERA_FIX_SETTING));
|
||||
camera_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(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));
|
||||
Vignetting_fix_enabled = (val == "1" || val == "true");
|
||||
}
|
||||
else if (line.find(VOLUMETRIC_FOG_FIX_SETTING) == 0)
|
||||
{
|
||||
std::string val = line.substr(strlen(VOLUMETRIC_FOG_FIX_SETTING));
|
||||
volumetric_fog_fix_enabled = (val == "1" || val == "true");
|
||||
}
|
||||
else if (line.find(FOG_DENSITY_FIX_SETTING) == 0)
|
||||
{
|
||||
std::string val = line.substr(strlen(FOG_DENSITY_FIX_SETTING));
|
||||
Fog_density_fix_enabled = (val == "1" || val == "true");
|
||||
}
|
||||
else if (line.find(FOG_MAX_OPACITY_FIX_SETTING) == 0)
|
||||
{
|
||||
std::string val = line.substr(strlen(FOG_MAX_OPACITY_FIX_SETTING));
|
||||
Fog_max_opacity_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)));
|
||||
else if (line.find(FOG_DENSITY_SETTING) == 0)
|
||||
fogDensityValue = std::stof(line.substr(strlen(FOG_DENSITY_SETTING)));
|
||||
else if (line.find(FOG_MAX_OPACITY_SETTING) == 0)
|
||||
fogMaxOpacityValue = std::stof(line.substr(strlen(FOG_MAX_OPACITY_SETTING)));
|
||||
}
|
||||
file.close();
|
||||
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>();
|
||||
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
|
||||
@@ -324,7 +277,7 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
if (ImGui::CollapsingHeader("Camera distance (*)", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(180 * scale);
|
||||
if (ImGui::SliderFloat("##CameraDistanceValue", &cameraDistanceValue, 0, 3)) {
|
||||
if (ImGui::SliderFloat("##CameraDistanceValue", &cameraDistanceValue, 0, 3, "%.2f")) {
|
||||
if (SetCameraDistance) SetCameraDistance(cameraDistanceValue);
|
||||
SaveSettings();
|
||||
}
|
||||
@@ -339,7 +292,7 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
if (ImGui::CollapsingHeader("Fog density (*)", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(180 * scale);
|
||||
if (ImGui::SliderFloat("##FogDensityValue", &fogDensityValue, 0, 5)) {
|
||||
if (ImGui::SliderFloat("##FogDensityValue", &fogDensityValue, 0, 5, "%.2f")) {
|
||||
if (SetFogDensity) SetFogDensity(fogDensityValue);
|
||||
SaveSettings();
|
||||
}
|
||||
@@ -353,7 +306,7 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
if (ImGui::CollapsingHeader("Fog opacity (*)", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(180 * scale);
|
||||
if (ImGui::SliderFloat("##FogOpacityValue", &fogMaxOpacityValue, 0, 1)) {
|
||||
if (ImGui::SliderFloat("##FogOpacityValue", &fogMaxOpacityValue, 0, 1, "%.2f")) {
|
||||
if (SetFogMaxOpacity) SetFogMaxOpacity(fogMaxOpacityValue);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user