Add ini library. Minors improvements
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
|
||||
#define IMGUI_HAS_DOCK 1
|
||||
|
||||
#include "GameInformations.h"
|
||||
#include "inicpp.h"
|
||||
#include <imgui.h>
|
||||
#include <reshade.hpp>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
|
||||
@@ -34,11 +35,7 @@ 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;
|
||||
static GetGameInfosStruct GetGameInfos = nullptr;
|
||||
|
||||
// Plugin variables for checkboxes and sliders
|
||||
static bool fov_fix_enabled = false;
|
||||
@@ -55,25 +52,15 @@ static float cameraDistancevalue = 1.f;
|
||||
static int cameraHeightvalue = -15;
|
||||
static int HUDvalue = 0;
|
||||
|
||||
// Overlay popup
|
||||
static bool show_log_overlay = false;
|
||||
static std::string log_content;
|
||||
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* 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* 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* SETTINGS_FILE = "pluginSettings.ini";
|
||||
const char* FIX_VERSION = "1.0.8";
|
||||
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Disable pillar boxing in cutscences.\n - Control camera distance and height.\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.";
|
||||
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
|
||||
|
||||
// Scaling factor based on screen resolution
|
||||
@@ -106,10 +93,7 @@ static void LoadFixDLL()
|
||||
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");
|
||||
GetGameInfos = (GetGameInfosStruct)GetProcAddress(fixLib, "GetGameInfos");
|
||||
|
||||
// Apply initial values loaded from settings
|
||||
if (SetFOV) SetFOV(worldFOVvalue);
|
||||
@@ -131,90 +115,64 @@ 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 << 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();
|
||||
}
|
||||
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"]["Aspect ratio"] = Aspect_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["Camera"] = camera_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["HUD"] = HUD_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"]["Fog"] = Fog_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"]["Camera height"] = cameraHeightvalue;
|
||||
pluginIniFile["3#Fixes tuning"]["HUD"] = HUDvalue;
|
||||
|
||||
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(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));
|
||||
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(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(FOG_FIX_SETTING) == 0)
|
||||
{
|
||||
std::string val = line.substr(strlen(FOG_FIX_SETTING));
|
||||
Fog_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(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();
|
||||
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>();
|
||||
Aspect_fix_enabled = pluginIniFile["2#Individual fix"]["Aspect ratio"].as<bool>();
|
||||
camera_fix_enabled = pluginIniFile["2#Individual fix"]["Camera"].as<bool>();
|
||||
HUD_fix_enabled = pluginIniFile["2#Individual fix"]["HUD"].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>();
|
||||
Fog_fix_enabled = pluginIniFile["2#Individual fix"]["Fog"].as<bool>();
|
||||
worldFOVvalue = pluginIniFile["3#Fixes tuning"]["World FOV"].as<int>();
|
||||
cameraDistancevalue = pluginIniFile["3#Fixes tuning"]["Camera distance"].as<float>();
|
||||
cameraHeightvalue = pluginIniFile["3#Fixes tuning"]["Camera height"].as<float>();
|
||||
HUDvalue = pluginIniFile["3#Fixes tuning"]["HUD"].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
|
||||
@@ -228,18 +186,35 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
|
||||
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("HellIsUs.log");
|
||||
show_log_overlay = true; // Fix information
|
||||
}
|
||||
|
||||
if (popup_Informations)
|
||||
{
|
||||
ImGui::Begin("Informations", &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);
|
||||
@@ -266,7 +241,7 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
if (ImGui::CollapsingHeader("Camera distance (*)", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(150 * scale);
|
||||
if (ImGui::SliderFloat("##CameraDistanceValue", &cameraDistancevalue, 0, 3)) {
|
||||
if (ImGui::SliderFloat("##CameraDistanceValue", &cameraDistancevalue, 0, 3, "%.2f")) {
|
||||
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue); SaveSettings();
|
||||
}
|
||||
}
|
||||
@@ -381,10 +356,14 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
// 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 F2");
|
||||
if (GetFOVIn && GetCompensadedFOV && GetFOVOut)
|
||||
ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Compensated: %.2f, Out: %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut());
|
||||
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, Compensated: %.2f, Out: %.2f", infos.FOVIn, infos.CompensatedFOV, infos.FOVOut);
|
||||
ImGui::TextColored(ImColor(48, 179, 25), "Camera distance In: %.2f, Out: %.2f", infos.cameraIn, infos.cameraOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user