Add HUD & UI fixes. Code refactoring
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include "HotkeysManager.h"
|
||||
#include "OSDManager.h"
|
||||
#include <chrono>
|
||||
#include <Windows.h>
|
||||
|
||||
// Screen informations
|
||||
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
@@ -13,10 +12,9 @@ static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
static float aspectRatio = (float)screenWidth / screenHeight;
|
||||
|
||||
// Core game dll functions declarations
|
||||
typedef void (*SetBoolFn)(bool, bool);
|
||||
typedef void (*SetFixesFn)(GameFixes, bool);
|
||||
typedef void (*SetIntFn)(int);
|
||||
typedef void (*SetFloatFn)(float);
|
||||
using SetBoolFn = void (*)(bool, bool);
|
||||
using SetFixesFn = void (*)(GameFixes, bool);
|
||||
using SetFloatFn = void (*)(GameSetting, float);
|
||||
|
||||
static HMODULE fixLib = nullptr;
|
||||
static LONG g_coreInitialized = 0;
|
||||
@@ -24,11 +22,8 @@ static LONG g_hotkeysInitialized = 0;
|
||||
static LONG g_uniformReseted = 0;
|
||||
static SetBoolFn SetFixEnabled = nullptr;
|
||||
static SetFixesFn SetFixes = nullptr;
|
||||
static SetFloatFn SetValues = nullptr;
|
||||
static GetGameInfosStruct GetGameInfos = nullptr;
|
||||
static SetIntFn SetFOV = nullptr;
|
||||
static SetFloatFn SetCameraDistance = nullptr;
|
||||
static SetFloatFn SetWorldTimeDilation = nullptr;
|
||||
static SetFloatFn SetAITimeDilation = nullptr;
|
||||
void SetFixesEnabled(GameFixes fix, bool value) { if (SetFixes) SetFixes(fix, value); }
|
||||
|
||||
// Plugin variables for checkboxes and sliders
|
||||
@@ -39,12 +34,14 @@ 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 HUD_fix_enabled = false;
|
||||
static bool fix_enabled = false;
|
||||
static bool Time_Dilation_fix_enabled = false;
|
||||
static bool Ignore_hits_fix_enabled = false;
|
||||
static bool StealthMode_fix_enabled = false;
|
||||
static bool GodMode_fix_enabled = false;
|
||||
static int worldFOVvalue = 0;
|
||||
static int HUDvalue = 0;
|
||||
static float cameraDistancevalue = 0.f;
|
||||
static float worldTimeDilationValue = 1.f;
|
||||
static float AITimeDilationValue = 1.f;
|
||||
@@ -58,8 +55,8 @@ static std::string log_content;
|
||||
|
||||
// Plugin settings
|
||||
const std::string SETTINGS_FILE = "./pluginsettings.ini";
|
||||
const char* FIX_VERSION = "1.0.7";
|
||||
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.\n - Enable cheats";
|
||||
const char* FIX_VERSION = "1.0.8";
|
||||
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Unlock ultrawide resolutions.\n - Control camera distance.\n - Control HUD scaling.\n - Remove depth of field.\n - Remove vignetting.\n - Remove fog.\n - Re enable console.\n - Enable cheats";
|
||||
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
|
||||
|
||||
// Prepare arrays of checkboxes for ImGui
|
||||
@@ -70,6 +67,7 @@ static FixToggle individualFixes[] = {
|
||||
{ "Ultrawide", &Aspect_fix_enabled, GameFixes::UltraWide, "This is intended for ultrawide only.\n"
|
||||
"Set panini to off in settings to avoid blurry textures and narrow FOV."},
|
||||
{ "Camera distance", &camera_Distance_fix_enabled, GameFixes::Camera },
|
||||
{ "HUD", &HUD_fix_enabled, GameFixes::HUD },
|
||||
{ "Depth of field", &DOF_fix_enabled, GameFixes::DOF }
|
||||
};
|
||||
|
||||
@@ -83,7 +81,7 @@ static FixToggle cheatFixes[] = {
|
||||
// Facteur de scaling basé sur la résolution verticale
|
||||
float scale = (float)screenHeight / 1200;
|
||||
// Prepare array of sliders for ImGui
|
||||
static SliderFix sliders[4];
|
||||
static SliderFix2 sliders[5];
|
||||
|
||||
// Load and unload game core dll functions /!\ necessary
|
||||
static void LoadFixDLL() {
|
||||
@@ -100,23 +98,24 @@ static void LoadFixDLL() {
|
||||
|
||||
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
|
||||
SetFixes = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled");
|
||||
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
|
||||
SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance");
|
||||
SetWorldTimeDilation = (SetFloatFn)GetProcAddress(fixLib, "SetWorldTimeDilation");
|
||||
SetAITimeDilation = (SetFloatFn)GetProcAddress(fixLib, "SetAITimeDilation");
|
||||
SetValues = (SetFloatFn)GetProcAddress(fixLib, "SetValues");
|
||||
GetGameInfos = (GetGameInfosStruct)GetProcAddress(fixLib, "GetGameInfos");
|
||||
|
||||
// Apply initial values loaded from settings
|
||||
if (SetFOV) SetFOV(worldFOVvalue);
|
||||
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue);
|
||||
if (SetWorldTimeDilation) SetWorldTimeDilation(worldTimeDilationValue);
|
||||
if (SetAITimeDilation) SetAITimeDilation(AITimeDilationValue);
|
||||
if (SetValues) {
|
||||
SetValues(GameSetting::FOV, worldFOVvalue);
|
||||
SetValues(GameSetting::CameraDistance, cameraDistancevalue);
|
||||
SetValues(GameSetting::HUD, HUDvalue);
|
||||
SetValues(GameSetting::WorldTimeDilation, worldTimeDilationValue);
|
||||
SetValues(GameSetting::AITimeDilation, AITimeDilationValue);
|
||||
}
|
||||
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
|
||||
if (SetFixes) {
|
||||
SetFixes(GameFixes::SkipIntro, skip_Intro_enabled);
|
||||
SetFixes(GameFixes::FOV, fov_fix_enabled);
|
||||
SetFixes(GameFixes::UltraWide, Aspect_fix_enabled);
|
||||
SetFixes(GameFixes::Camera, camera_Distance_fix_enabled);
|
||||
SetFixes(GameFixes::HUD, HUD_fix_enabled);
|
||||
SetFixes(GameFixes::DOF, DOF_fix_enabled);
|
||||
SetFixes(GameFixes::Vignetting, Vignetting_fix_enabled);
|
||||
SetFixes(GameFixes::Fog, Fog_fix_enabled);
|
||||
@@ -127,12 +126,13 @@ static void LoadFixDLL() {
|
||||
SetFixes(GameFixes::DevConsole, console);
|
||||
}
|
||||
|
||||
sliders[0] = { "In game additional FOV", "##FOVValue", SliderType::Int, &worldFOVvalue, -20, 70, SetFOV };
|
||||
sliders[1] = { "Camera distance (*)", "##CameraOffset", SliderType::Float, &cameraDistancevalue, 0, 4, SetCameraDistance, "%.2f",
|
||||
sliders[0] = { "In game additional FOV", "##FOVValue", SliderType::Int, &worldFOVvalue, -20, 70, GameSetting::FOV, SetValues };
|
||||
sliders[1] = { "Camera distance (*)", "##CameraOffset", SliderType::Float, &cameraDistancevalue, 0, 4, GameSetting::CameraDistance, SetValues, "%.2f",
|
||||
"Value is a multiplier.\nAffects both normal and weapon aiming distance." };
|
||||
sliders[2] = { "World time dilation", "##WorldTimeDilationValue", SliderType::Float, &worldTimeDilationValue, 0.f, 2.f, SetWorldTimeDilation, nullptr,
|
||||
sliders[2] = { "HUD scaling", "##HUDValue", SliderType::Int, &HUDvalue, 0, 40, GameSetting::HUD, SetValues };
|
||||
sliders[3] = { "World time dilation", "##WorldTimeDilationValue", SliderType::Float, &worldTimeDilationValue, 0.f, 2.f, GameSetting::WorldTimeDilation, SetValues, "%.1f",
|
||||
"Will affect everything in the world.\nDefault value is 1." };
|
||||
sliders[3] = { "AI time dilation", "##AITimeDilationValue", SliderType::Float, &AITimeDilationValue, 0.f, 2.f, SetAITimeDilation, nullptr,
|
||||
sliders[4] = { "AI time dilation", "##AITimeDilationValue", SliderType::Float, &AITimeDilationValue, 0.f, 2.f, GameSetting::AITimeDilation, SetValues, "%.1f",
|
||||
"Will affect only enemies in the world.\nDefault value is 1." };
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,7 @@ static void SaveSettings() {
|
||||
pluginIniFile["2#Individual fix"]["FOV"] = fov_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["UltraWide"] = Aspect_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["Camera"] = camera_Distance_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["HUD"] = HUD_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["DOF"] = DOF_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["Vignetting"] = Vignetting_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["Fog"] = Fog_fix_enabled;
|
||||
@@ -163,6 +164,7 @@ static void SaveSettings() {
|
||||
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"]["HUD scaling"] = HUDvalue;
|
||||
pluginIniFile["3#Fixes tuning"]["World time dilation scale"] = worldTimeDilationValue;
|
||||
pluginIniFile["3#Fixes tuning"]["AI time dilation scale"] = AITimeDilationValue;
|
||||
|
||||
@@ -179,6 +181,7 @@ static void LoadSettings() {
|
||||
fov_fix_enabled = pluginIniFile["2#Individual fix"]["FOV"].as<bool>();
|
||||
Aspect_fix_enabled = pluginIniFile["2#Individual fix"]["UltraWide"].as<bool>();
|
||||
camera_Distance_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>();
|
||||
Vignetting_fix_enabled = pluginIniFile["2#Individual fix"]["Vignetting"].as<bool>();
|
||||
Fog_fix_enabled = pluginIniFile["2#Individual fix"]["Fog"].as<bool>();
|
||||
@@ -188,6 +191,7 @@ static void LoadSettings() {
|
||||
StealthMode_fix_enabled = pluginIniFile["2#Individual fix"]["Stealth"].as<bool>();
|
||||
worldFOVvalue = pluginIniFile["3#Fixes tuning"]["World FOV"].as<int>();
|
||||
cameraDistancevalue = pluginIniFile["3#Fixes tuning"]["Camera distance"].as<float>();
|
||||
HUDvalue = pluginIniFile["3#Fixes tuning"]["HUD scaling"].as<float>();
|
||||
worldTimeDilationValue = pluginIniFile["3#Fixes tuning"]["World time dilation scale"].as<float>();
|
||||
AITimeDilationValue = pluginIniFile["3#Fixes tuning"]["AI time dilation scale"].as<float>();
|
||||
}
|
||||
@@ -246,6 +250,7 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
|
||||
if (ImGui::BeginTabBar("MainTabs")) {
|
||||
if (ImGui::BeginTabItem("Fixes")) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(10 * scale, 10 * scale));
|
||||
if (ImGui::BeginTable("FixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
|
||||
ImGui::TableSetupColumn("LeftFix", ImGuiTableColumnFlags_WidthStretch, 0.4f);
|
||||
ImGui::TableSetupColumn("RightFix", ImGuiTableColumnFlags_WidthStretch, 0.6f);
|
||||
@@ -256,11 +261,10 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
|
||||
// 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
|
||||
for (int i = 0; i < 2; ++i) DrawSlider(sliders[i], 150);
|
||||
|
||||
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)) {
|
||||
@@ -278,23 +282,37 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 2);
|
||||
if (ImGui::BeginTable("FixesSliders", 2, ImGuiTableFlags_SizingStretchSame)) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
DrawSlider2(sliders[0], 200);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
DrawSlider2(sliders[1], 200);
|
||||
DrawSlider2(sliders[2], 200);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Cheats")) {
|
||||
for (const auto& cheat : cheatFixes) DrawFixCheckbox(cheat);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(10 * scale, 10 * scale));
|
||||
if (ImGui::BeginTable("SlidersTable", 2, ImGuiTableFlags_SizingStretchSame)) {
|
||||
ImGui::TableSetupColumn("LeftSliders", ImGuiTableColumnFlags_WidthStretch, 0.5f);
|
||||
ImGui::TableSetupColumn("RightSliders", ImGuiTableColumnFlags_WidthStretch, 0.5f);
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
DrawSlider(sliders[2], 180);
|
||||
DrawSlider2(sliders[3], 180);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
DrawSlider(sliders[3], 180);
|
||||
DrawSlider2(sliders[4], 180);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
|
||||
Reference in New Issue
Block a user