Add skip intro. Code refactoring
This commit is contained in:
@@ -1,13 +1,7 @@
|
|||||||
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
|
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
|
||||||
#define IMGUI_HAS_DOCK 1
|
#define IMGUI_HAS_DOCK 1
|
||||||
|
|
||||||
#include "GameInformations.h"
|
#include "CommonHeaders.h"
|
||||||
#include "GameFixes.h"
|
|
||||||
#include "inicpp.h"
|
|
||||||
#include <imgui.h>
|
|
||||||
#include <reshade.hpp>
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
// Screen informations
|
// Screen informations
|
||||||
@@ -24,12 +18,14 @@ typedef void (*SetFloatFn)(float);
|
|||||||
static HMODULE fixLib = nullptr;
|
static HMODULE fixLib = nullptr;
|
||||||
static LONG g_coreInitialized = 0;
|
static LONG g_coreInitialized = 0;
|
||||||
static SetBoolFn SetFixEnabled = nullptr;
|
static SetBoolFn SetFixEnabled = nullptr;
|
||||||
static SetFixesFn SetFixesEnabled = nullptr;
|
static SetFixesFn SetFixes = nullptr;
|
||||||
static GetGameInfosStruct GetGameInfos = nullptr;
|
static GetGameInfosStruct GetGameInfos = nullptr;
|
||||||
static SetIntFn SetFOV = nullptr;
|
static SetIntFn SetFOV = nullptr;
|
||||||
static SetFloatFn SetCameraDistance = nullptr;
|
static SetFloatFn SetCameraDistance = nullptr;
|
||||||
|
void SetFixesEnabled(GameFixes fix, bool value) { if (SetFixes) SetFixes(fix, value); }
|
||||||
|
|
||||||
// Plugin variables for checkboxes and sliders
|
// Plugin variables for checkboxes and sliders
|
||||||
|
static bool skip_Intro_enabled = false;
|
||||||
static bool fov_fix_enabled = false;
|
static bool fov_fix_enabled = false;
|
||||||
static bool Aspect_fix_enabled = false;
|
static bool Aspect_fix_enabled = false;
|
||||||
static bool DOF_fix_enabled = false;
|
static bool DOF_fix_enabled = false;
|
||||||
@@ -48,16 +44,28 @@ static std::string log_content;
|
|||||||
|
|
||||||
// Plugin settings
|
// Plugin settings
|
||||||
const std::string SETTINGS_FILE = "./pluginsettings.ini";
|
const std::string SETTINGS_FILE = "./pluginsettings.ini";
|
||||||
const char* FIX_VERSION = "1.0.6.1";
|
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.";
|
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";
|
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
|
||||||
|
|
||||||
|
// Prepare arrays of checkboxes for ImGui
|
||||||
|
static FixToggle individualFixes[] = {
|
||||||
|
{ "FOV", &fov_fix_enabled, GameFixes::FOV },
|
||||||
|
{ "Vignetting", &Vignetting_fix_enabled, GameFixes::Vignetting },
|
||||||
|
{ "Fog", &Fog_fix_enabled, GameFixes::Fog },
|
||||||
|
{ "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 },
|
||||||
|
{ "Depth of field", &DOF_fix_enabled, GameFixes::DOF }
|
||||||
|
};
|
||||||
|
|
||||||
// Facteur de scaling basé sur la résolution verticale
|
// Facteur de scaling basé sur la résolution verticale
|
||||||
float scale = 1.f;
|
float scale = (float)screenHeight / 1200;
|
||||||
|
// Prepare array of sliders for ImGui
|
||||||
|
static SliderFix sliders[2];
|
||||||
|
|
||||||
// Load and unload game core dll functions /!\ necessary
|
// Load and unload game core dll functions /!\ necessary
|
||||||
static void LoadFixDLL()
|
static void LoadFixDLL() {
|
||||||
{
|
|
||||||
if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0)
|
if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -70,7 +78,7 @@ static void LoadFixDLL()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
|
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
|
||||||
SetFixesEnabled = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled");
|
SetFixes = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled");
|
||||||
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
|
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
|
||||||
SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance");
|
SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance");
|
||||||
GetGameInfos = (GetGameInfosStruct)GetProcAddress(fixLib, "GetGameInfos");
|
GetGameInfos = (GetGameInfosStruct)GetProcAddress(fixLib, "GetGameInfos");
|
||||||
@@ -79,29 +87,35 @@ static void LoadFixDLL()
|
|||||||
if (SetFOV) SetFOV(worldFOVvalue);
|
if (SetFOV) SetFOV(worldFOVvalue);
|
||||||
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue);
|
if (SetCameraDistance) SetCameraDistance(cameraDistancevalue);
|
||||||
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
|
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
|
||||||
if (SetFixesEnabled) {
|
if (SetFixes) {
|
||||||
SetFixesEnabled(GameFixes::FOV, fov_fix_enabled);
|
SetFixes(GameFixes::SkipIntro, skip_Intro_enabled);
|
||||||
SetFixesEnabled(GameFixes::UltraWide, Aspect_fix_enabled);
|
SetFixes(GameFixes::FOV, fov_fix_enabled);
|
||||||
SetFixesEnabled(GameFixes::Camera, camera_Distance_fix_enabled);
|
SetFixes(GameFixes::UltraWide, Aspect_fix_enabled);
|
||||||
SetFixesEnabled(GameFixes::DOF, DOF_fix_enabled);
|
SetFixes(GameFixes::Camera, camera_Distance_fix_enabled);
|
||||||
SetFixesEnabled(GameFixes::Vignetting, Vignetting_fix_enabled);
|
SetFixes(GameFixes::DOF, DOF_fix_enabled);
|
||||||
SetFixesEnabled(GameFixes::Fog, Fog_fix_enabled);
|
SetFixes(GameFixes::Vignetting, Vignetting_fix_enabled);
|
||||||
SetFixesEnabled(GameFixes::DevConsole, console);
|
SetFixes(GameFixes::Fog, Fog_fix_enabled);
|
||||||
|
SetFixes(GameFixes::DevConsole, console);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sliders[0] = { "In game additional FOV", "##FOVValue", SliderType::Int, &worldFOVvalue, -20, 70, SetFOV };
|
||||||
|
sliders[1] = { "Camera distance (*)", "##CameraOffset", SliderType::Float, &cameraDistancevalue, 0, 4, SetCameraDistance, "%.2f",
|
||||||
|
"Value is a multiplier.\nAffects both normal and weapon aiming distance." };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Settings functions
|
// Settings functions
|
||||||
static void SaveSettings()
|
static void SaveSettings() {
|
||||||
{
|
|
||||||
ini::IniFile pluginIniFile;
|
ini::IniFile pluginIniFile;
|
||||||
pluginIniFile["1#General fix"].setComment(std::vector<std::string>{ "The following sections are saved by plugin",
|
pluginIniFile["1#General fix"].setComment(std::vector<std::string>{ "The following sections are saved by plugin",
|
||||||
"You should not need to modify them",
|
"You should not need to modify them",
|
||||||
" ",
|
" ",
|
||||||
"Controls if fix mod (globally) is enabled",
|
"Controls if fix mod (globally) is enabled",
|
||||||
"Set Console to false if you don't want to enable it" });
|
"Set Console to false if you don't want to enable it",
|
||||||
|
"Set Skip Intro to false if you don't wan't to skip them" });
|
||||||
pluginIniFile["1#General fix"]["Enabled"] = fix_enabled;
|
pluginIniFile["1#General fix"]["Enabled"] = fix_enabled;
|
||||||
pluginIniFile["1#General fix"]["Console"] = console;
|
pluginIniFile["1#General fix"]["Console"] = console;
|
||||||
|
pluginIniFile["1#General fix"]["Skip Intro"] = skip_Intro_enabled;
|
||||||
pluginIniFile["2#Individual fix"].setComment("Controls each fix individually");
|
pluginIniFile["2#Individual fix"].setComment("Controls each fix individually");
|
||||||
pluginIniFile["2#Individual fix"]["FOV"] = fov_fix_enabled;
|
pluginIniFile["2#Individual fix"]["FOV"] = fov_fix_enabled;
|
||||||
pluginIniFile["2#Individual fix"]["UltraWide"] = Aspect_fix_enabled;
|
pluginIniFile["2#Individual fix"]["UltraWide"] = Aspect_fix_enabled;
|
||||||
@@ -122,6 +136,7 @@ static void LoadSettings() {
|
|||||||
pluginIniFile.load(SETTINGS_FILE);
|
pluginIniFile.load(SETTINGS_FILE);
|
||||||
fix_enabled = pluginIniFile["1#General fix"]["Enabled"].as<bool>();
|
fix_enabled = pluginIniFile["1#General fix"]["Enabled"].as<bool>();
|
||||||
console = pluginIniFile["1#General fix"]["Console"].as<bool>();
|
console = pluginIniFile["1#General fix"]["Console"].as<bool>();
|
||||||
|
skip_Intro_enabled = pluginIniFile["1#General fix"]["Skip Intro"].as<bool>();
|
||||||
fov_fix_enabled = pluginIniFile["2#Individual fix"]["FOV"].as<bool>();
|
fov_fix_enabled = pluginIniFile["2#Individual fix"]["FOV"].as<bool>();
|
||||||
Aspect_fix_enabled = pluginIniFile["2#Individual fix"]["UltraWide"].as<bool>();
|
Aspect_fix_enabled = pluginIniFile["2#Individual fix"]["UltraWide"].as<bool>();
|
||||||
camera_Distance_fix_enabled = pluginIniFile["2#Individual fix"]["Camera"].as<bool>();
|
camera_Distance_fix_enabled = pluginIniFile["2#Individual fix"]["Camera"].as<bool>();
|
||||||
@@ -137,8 +152,7 @@ static void LoadSettings() {
|
|||||||
// Read plugin log file
|
// Read plugin log file
|
||||||
void read_log_file(const std::string& filename) {
|
void read_log_file(const std::string& filename) {
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
if (!file.is_open())
|
if (!file.is_open()) {
|
||||||
{
|
|
||||||
log_content = "Impossible to open file : " + filename;
|
log_content = "Impossible to open file : " + filename;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -172,16 +186,14 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
|||||||
show_log_overlay = true; // Fix information
|
show_log_overlay = true; // Fix information
|
||||||
}
|
}
|
||||||
|
|
||||||
if (popup_Informations)
|
if (popup_Informations) {
|
||||||
{
|
|
||||||
ImGui::Begin("Informations", &popup_Informations, ImGuiWindowFlags_AlwaysAutoResize);
|
ImGui::Begin("Informations", &popup_Informations, ImGuiWindowFlags_AlwaysAutoResize);
|
||||||
ImGui::Text("Version : %s", FIX_VERSION);
|
ImGui::Text("Version : %s", FIX_VERSION);
|
||||||
ImGui::Text(FIX_INFORMATIONS);
|
ImGui::Text(FIX_INFORMATIONS);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_log_overlay)
|
if (show_log_overlay) {
|
||||||
{
|
|
||||||
ImGui::Begin("Game log", &show_log_overlay, ImGuiWindowFlags_AlwaysAutoResize);
|
ImGui::Begin("Game log", &show_log_overlay, ImGuiWindowFlags_AlwaysAutoResize);
|
||||||
ImGui::TextUnformatted(log_content.c_str());
|
ImGui::TextUnformatted(log_content.c_str());
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@@ -200,82 +212,20 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
|||||||
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) { if (SetFixEnabled) SetFixEnabled(fix_enabled, false); SaveSettings(); }
|
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) { if (SetFixEnabled) SetFixEnabled(fix_enabled, false); SaveSettings(); }
|
||||||
|
|
||||||
// Sliders
|
// Sliders
|
||||||
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen))
|
for (int i = 0; i < 2; ++i) DrawSlider(sliders[i], 150);
|
||||||
{
|
|
||||||
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
|
// Individual fixes
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen))
|
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||||
{
|
|
||||||
if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
|
if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
|
||||||
ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.4f);
|
ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.4f);
|
||||||
ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.6f);
|
ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.6f);
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
|
for (int i = 0; i < 3; ++i) DrawFixCheckbox(individualFixes[i]);
|
||||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::FOV, fov_fix_enabled);
|
|
||||||
SaveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
|
|
||||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::Vignetting, Vignetting_fix_enabled);
|
|
||||||
SaveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::Checkbox("Fog", &Fog_fix_enabled)) {
|
|
||||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::Fog, Fog_fix_enabled);
|
|
||||||
SaveSettings();
|
|
||||||
}
|
|
||||||
if (ImGui::IsItemHovered()) {
|
|
||||||
ImGui::BeginTooltip();
|
|
||||||
ImGui::Text("Enabling this fix is a one way.");
|
|
||||||
ImGui::Text("Reverting it in real time would end in game crash.");
|
|
||||||
ImGui::Text("So disabling this fix is only possible by doing it here and restart the game.");
|
|
||||||
ImGui::EndTooltip();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) {
|
for (int i = 3; i < IM_ARRAYSIZE(individualFixes); ++i) DrawFixCheckbox(individualFixes[i]);
|
||||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::UltraWide, Aspect_fix_enabled);
|
|
||||||
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("Camera distance", &camera_Distance_fix_enabled)) {
|
|
||||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::Camera, camera_Distance_fix_enabled);
|
|
||||||
SaveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
|
|
||||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::DOF, DOF_fix_enabled);
|
|
||||||
SaveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,8 +233,7 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fix status
|
// Fix status
|
||||||
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen))
|
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||||
{
|
|
||||||
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
|
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
|
||||||
if (GetGameInfos) {
|
if (GetGameInfos) {
|
||||||
GameInfos infos{};
|
GameInfos infos{};
|
||||||
@@ -298,10 +247,8 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Main dll intrance
|
// Main dll intrance
|
||||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID)
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID) {
|
||||||
{
|
switch (ul_reason_for_call) {
|
||||||
switch (ul_reason_for_call)
|
|
||||||
{
|
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
if (!reshade::register_addon(hinstDLL))
|
if (!reshade::register_addon(hinstDLL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
Reference in New Issue
Block a user