From 39a6116aab23f5f430c9839e665b8af5e5c670da Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Tue, 20 Jan 2026 18:01:32 +0100 Subject: [PATCH] Add skip intro. Code refactoring --- Cronos The New Dawn/dllmain.cpp | 151 +++++++++++--------------------- 1 file changed, 49 insertions(+), 102 deletions(-) diff --git a/Cronos The New Dawn/dllmain.cpp b/Cronos The New Dawn/dllmain.cpp index 2cfb83a..2bde493 100644 --- a/Cronos The New Dawn/dllmain.cpp +++ b/Cronos The New Dawn/dllmain.cpp @@ -1,13 +1,7 @@ #define IMGUI_DISABLE_INCLUDE_IMCONFIG_H #define IMGUI_HAS_DOCK 1 -#include "GameInformations.h" -#include "GameFixes.h" -#include "inicpp.h" -#include -#include -#include -#include +#include "CommonHeaders.h" #include // Screen informations @@ -24,12 +18,14 @@ typedef void (*SetFloatFn)(float); static HMODULE fixLib = nullptr; static LONG g_coreInitialized = 0; static SetBoolFn SetFixEnabled = nullptr; -static SetFixesFn SetFixesEnabled = nullptr; +static SetFixesFn SetFixes = nullptr; static GetGameInfosStruct GetGameInfos = nullptr; static SetIntFn SetFOV = nullptr; static SetFloatFn SetCameraDistance = nullptr; +void SetFixesEnabled(GameFixes fix, bool value) { if (SetFixes) SetFixes(fix, value); } // Plugin variables for checkboxes and sliders +static bool skip_Intro_enabled = false; static bool fov_fix_enabled = false; static bool Aspect_fix_enabled = false; static bool DOF_fix_enabled = false; @@ -48,16 +44,28 @@ static std::string log_content; // Plugin settings 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* 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 -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 -static void LoadFixDLL() -{ +static void LoadFixDLL() { if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0) return; @@ -70,7 +78,7 @@ static void LoadFixDLL() } SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled"); - SetFixesEnabled = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled"); + SetFixes = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled"); SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV"); SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance"); GetGameInfos = (GetGameInfosStruct)GetProcAddress(fixLib, "GetGameInfos"); @@ -79,29 +87,35 @@ static void LoadFixDLL() if (SetFOV) SetFOV(worldFOVvalue); if (SetCameraDistance) SetCameraDistance(cameraDistancevalue); if (SetFixEnabled) SetFixEnabled(fix_enabled, true); - if (SetFixesEnabled) { - SetFixesEnabled(GameFixes::FOV, fov_fix_enabled); - SetFixesEnabled(GameFixes::UltraWide, Aspect_fix_enabled); - SetFixesEnabled(GameFixes::Camera, camera_Distance_fix_enabled); - SetFixesEnabled(GameFixes::DOF, DOF_fix_enabled); - SetFixesEnabled(GameFixes::Vignetting, Vignetting_fix_enabled); - SetFixesEnabled(GameFixes::Fog, Fog_fix_enabled); - SetFixesEnabled(GameFixes::DevConsole, console); + 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::DOF, DOF_fix_enabled); + SetFixes(GameFixes::Vignetting, Vignetting_fix_enabled); + 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 -static void SaveSettings() -{ +static void SaveSettings() { ini::IniFile pluginIniFile; pluginIniFile["1#General fix"].setComment(std::vector{ "The following sections are saved by plugin", "You should not need to modify them", " ", "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"]["Console"] = console; + pluginIniFile["1#General fix"]["Skip Intro"] = skip_Intro_enabled; pluginIniFile["2#Individual fix"].setComment("Controls each fix individually"); pluginIniFile["2#Individual fix"]["FOV"] = fov_fix_enabled; pluginIniFile["2#Individual fix"]["UltraWide"] = Aspect_fix_enabled; @@ -122,6 +136,7 @@ static void LoadSettings() { pluginIniFile.load(SETTINGS_FILE); fix_enabled = pluginIniFile["1#General fix"]["Enabled"].as(); console = pluginIniFile["1#General fix"]["Console"].as(); + skip_Intro_enabled = pluginIniFile["1#General fix"]["Skip Intro"].as(); fov_fix_enabled = pluginIniFile["2#Individual fix"]["FOV"].as(); Aspect_fix_enabled = pluginIniFile["2#Individual fix"]["UltraWide"].as(); camera_Distance_fix_enabled = pluginIniFile["2#Individual fix"]["Camera"].as(); @@ -137,8 +152,7 @@ static void LoadSettings() { // Read plugin log file void read_log_file(const std::string& filename) { std::ifstream file(filename); - if (!file.is_open()) - { + if (!file.is_open()) { log_content = "Impossible to open file : " + filename; return; } @@ -172,16 +186,14 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime) show_log_overlay = true; // Fix information } - if (popup_Informations) - { + 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) - { + if (show_log_overlay) { ImGui::Begin("Game log", &show_log_overlay, ImGuiWindowFlags_AlwaysAutoResize); ImGui::TextUnformatted(log_content.c_str()); 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(); } // 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(); - } + for (int i = 0; i < 2; ++i) DrawSlider(sliders[i], 150); // Individual fixes ImGui::TableSetColumnIndex(1); - if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) - { + if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) { if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) { ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.4f); ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.6f); ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); - if (ImGui::Checkbox("FOV", &fov_fix_enabled)) { - 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(); - } - + for (int i = 0; i < 3; ++i) DrawFixCheckbox(individualFixes[i]); ImGui::TableSetColumnIndex(1); - if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) { - 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(); - } - + for (int i = 3; i < IM_ARRAYSIZE(individualFixes); ++i) DrawFixCheckbox(individualFixes[i]); ImGui::EndTable(); } } @@ -283,8 +233,7 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime) } // 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); if (GetGameInfos) { GameInfos infos{}; @@ -298,10 +247,8 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime) } // Main dll intrance -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID) -{ - switch (ul_reason_for_call) - { +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;