#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H #define IMGUI_HAS_DOCK 1 #include #include #include #include #include // Screen informations static int screenWidth = GetSystemMetrics(SM_CXSCREEN); static int screenHeight = GetSystemMetrics(SM_CYSCREEN); static float aspectRatio = (float)screenWidth / screenHeight; // Core game dll functions declarations typedef void (*SetBoolFn)(bool, bool); typedef void (*SetIntFn)(int); typedef void (*SetFloatFn)(float); typedef float (*GetFloatFn)(); typedef bool (*GetBoolFn)(); typedef void (*SetUEConsole)(); static HMODULE fixLib = nullptr; static SetBoolFn SetFixEnabled = nullptr; static SetBoolFn SetFOVFixEnabled = nullptr; static SetBoolFn SetFPSFixEnabled = nullptr; static SetBoolFn SetResolutionFixEnabled = nullptr; static SetBoolFn SetAspectRatioFixEnabled = nullptr; static SetBoolFn SetDOFFixEnabled = nullptr; static SetBoolFn SetVignettingFixEnabled = nullptr; static SetBoolFn SetFogFixEnabled = nullptr; static SetBoolFn SetCameraDistanceFixEnabled = nullptr; static SetIntFn SetFOV = nullptr; static SetFloatFn SetCameraDistance = nullptr; static GetFloatFn GetFOVIn = nullptr; static GetFloatFn GetCompensadedFOV = nullptr; static GetFloatFn GetFOVOut = nullptr; static GetBoolFn GetConsoleEnabled = nullptr; static SetUEConsole SetConsole = nullptr; // Plugin variables for checkboxes and sliders static bool fov_fix_enabled = false; static bool FPS_fix_enabled = false; static bool Resolution_fix_enabled = false; static bool Aspect_fix_enabled = false; 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 fix_enabled = false; static int worldFOVvalue = 0; static float cameraDistancevalue = 0.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* ASPECT_FIX_SETTING = "AspectFIX="; const char* DOF_FIX_SETTING = "DOFFIX="; const char* VIGNETTING_FIX_SETTING = "VignettingFIX="; const char* FOG_FIX_SETTING = "FogFIX="; const char* CAMERA_DISTANCE_FIX_SETTING = "CameraDistanceFIX="; const char* WORLD_FOV_SETTING = "WorldFOV="; const char* CAMERA_DISTANCE_SETTING = "CameraDistance="; const char* FIX_VERSION = "1.0.4"; 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"; bool IsAlreadyInitialized() { // Declare a lock HANDLE hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, "Local\\CronosFixSharedSection"); // If lock is not yet initialized if (hMap == nullptr) { // We create the lock only once hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 1, "Local\\CronosFixSharedSection"); if (hMap == nullptr) // We ensure the lock is valid return true; return false; // First time created we return false } // Otherwise we return true CloseHandle(hMap); return true; } // Load and unload game core dll functions /!\ necessary static void LoadFixDLL() { if (IsAlreadyInitialized()) return; // déjà lancé dans un autre chargement if (GetModuleHandleA("CronosTNDCore.dll") == nullptr) { fixLib = LoadLibraryA("CronosTNDCore.dll"); if (!fixLib) { MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK); return; } SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled"); SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled"); SetAspectRatioFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetAspectRatioFixEnabled"); SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled"); SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled"); SetFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogFixEnabled"); SetCameraDistanceFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetCameraDistanceFixEnabled"); SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV"); SetCameraDistance = (SetFloatFn)GetProcAddress(fixLib, "SetCameraDistance"); GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn"); GetCompensadedFOV = (GetFloatFn)GetProcAddress(fixLib, "GetCompensatedFOV"); GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut"); SetConsole = (SetUEConsole)GetProcAddress(fixLib, "SetConsole"); GetConsoleEnabled = (GetBoolFn)GetProcAddress(fixLib, "GetConsoleEnabled"); // Apply initial values loaded from settings if (SetFOV) SetFOV(worldFOVvalue); if (SetCameraDistance) SetCameraDistance(cameraDistancevalue); if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true); if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, true); if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true); if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true); if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, true); if (SetCameraDistanceFixEnabled) SetCameraDistanceFixEnabled(camera_Distance_fix_enabled, true); if (SetFixEnabled) SetFixEnabled(fix_enabled, true); if (SetConsole) SetConsole(); } } // 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 << DOF_FIX_SETTING << (DOF_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 << CAMERA_DISTANCE_FIX_SETTING << (camera_Distance_fix_enabled ? "1" : "0") << "\n"; file << WORLD_FOV_SETTING << worldFOVvalue << "\n"; file << CAMERA_DISTANCE_SETTING << cameraDistancevalue << "\n"; file.close(); } } 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(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(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(CAMERA_DISTANCE_FIX_SETTING) == 0) { std::string val = line.substr(strlen(CAMERA_DISTANCE_FIX_SETTING)); camera_Distance_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))); } file.close(); } } // Fix informations static void displayFixInformations() { ImGui::SetNextWindowSize(ImVec2(250, 200)); ImGui::Begin("Informations", &popup_Informations); // ImGui::SetCursorPos(ImVec2(10, 36)); ImGui::Text("Version : %s", FIX_VERSION); ImGui::SetCursorPos(ImVec2(10, 76)); ImGui::Text(FIX_INFORMATIONS); ImGui::End(); } // Initialize ImGui widgets for Reshade static void on_overlay_draw(reshade::api::effect_runtime* runtime) { ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_Once); ImGui::SetNextWindowSize(ImVec2(350, 150), ImGuiCond_Once); // Donation ? ImGui::SetCursorPos(ImVec2(10, 36)); ImGui::Text("Like my work ?"); ImGui::SetCursorPos(ImVec2(130, 33)); if (ImGui::Button("consider donation")) { ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL); } // Fix informations ImGui::SetCursorPos(ImVec2(270, 33)); if (ImGui::Button("Fix informations")) popup_Informations = true; if (popup_Informations) displayFixInformations(); // Generic fix ImGui::SetCursorPos(ImVec2(10, 60)); ImGui::BeginChild("AllFixesHeader", ImVec2(220, 0), false); // true = border if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::SetCursorPos(ImVec2(5, 30)); if (ImGui::Checkbox("Fix enabled", &fix_enabled)) { if (SetFixEnabled) SetFixEnabled(fix_enabled, false); SaveSettings(); } } ImGui::EndChild(); // FOV adjustment ImGui::SetCursorPos(ImVec2(10, 120)); ImGui::BeginChild("FOVHeader", ImVec2(220, 0), false); if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::SetCursorPos(ImVec2(5, 30)); ImGui::SetNextItemWidth(150.0f); if (ImGui::SliderInt("", &worldFOVvalue, -20, 70)) {} if (ImGui::IsItemDeactivatedAfterEdit()) { if (SetFOV) SetFOV(worldFOVvalue); SaveSettings(); } } ImGui::EndChild(); // Camera distance adjustment ImGui::SetCursorPos(ImVec2(10, 180)); ImGui::BeginChild("CameraHeader", ImVec2(220, 0), false); if (ImGui::CollapsingHeader("Camera distance multiplier", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::SetCursorPos(ImVec2(5, 30)); ImGui::SetNextItemWidth(150.0f); if (ImGui::SliderFloat("", &cameraDistancevalue, 0, 3)) {} if (ImGui::IsItemDeactivatedAfterEdit()) { if (SetCameraDistance) SetCameraDistance(cameraDistancevalue); SaveSettings(); } } ImGui::EndChild(); // Individual fixes ImGui::SetCursorPos(ImVec2(240, 60)); ImGui::BeginChild("IndividualFixesHeader", ImVec2(250, 0), false); if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::SetCursorPos(ImVec2(5, 30)); if (ImGui::Checkbox("FOV", &fov_fix_enabled)) { if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false); SaveSettings(); } ImGui::SetCursorPos(ImVec2(60, 30)); if (ImGui::Checkbox("Camera distance", &camera_Distance_fix_enabled)) { if (SetCameraDistanceFixEnabled) SetCameraDistanceFixEnabled(camera_Distance_fix_enabled, false); SaveSettings(); } ImGui::SetCursorPos(ImVec2(5, 55)); if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) { if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false); 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(); } ImGui::SetCursorPos(ImVec2(5, 80)); if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) { if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false); SaveSettings(); } ImGui::SetCursorPos(ImVec2(5, 105)); if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) { if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false); SaveSettings(); } ImGui::SetCursorPos(ImVec2(110, 105)); if (ImGui::Checkbox("Fog", &Fog_fix_enabled)) { if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, false); 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::EndChild(); // Fix status ImGui::SetCursorPos(ImVec2(10, 240)); ImGui::BeginChild("INFOSHeader", ImVec2(480, 85), true); if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::SetCursorPos(ImVec2(5, 30)); ImGui::Text("Screen infos width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio); ImGui::SetCursorPos(ImVec2(5, 45)); if (GetConsoleEnabled && GetConsoleEnabled()) ImGui::Text("Console enabled and bound to key Tilde"); ImGui::SetCursorPos(ImVec2(5, 60)); if (GetFOVIn && GetCompensadedFOV && GetFOVOut) // Test functions in case Core dll is not ready when called ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Compensated : %.2f, Out : %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut()); } ImGui::EndChild(); } // Main dll intrance 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; LoadSettings(); reshade::register_overlay("Cronos: The New Dawn", &on_overlay_draw); reshade::register_event( [](reshade::api::effect_runtime* runtime) { LoadFixDLL(); }); break; case DLL_PROCESS_DETACH: reshade::unregister_addon(hinstDLL); break; } return TRUE; }