From 8ac0373374b604ffb44d52c412a2c0e37c1ed1a4 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Sat, 13 Sep 2025 11:40:28 +0200 Subject: [PATCH] UI scaling improvement --- Cronos The New Dawn/dllmain.cpp | 133 ++++++++++++++------------------ 1 file changed, 56 insertions(+), 77 deletions(-) diff --git a/Cronos The New Dawn/dllmain.cpp b/Cronos The New Dawn/dllmain.cpp index e8195dd..d996b3a 100644 --- a/Cronos The New Dawn/dllmain.cpp +++ b/Cronos The New Dawn/dllmain.cpp @@ -64,10 +64,13 @@ 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.5"; +const char* FIX_VERSION = "1.0.6"; 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"; +// Facteur de scaling basé sur la résolution verticale +float scale = 1.f; + bool IsAlreadyInitialized() { // Declare a lock @@ -206,125 +209,106 @@ static void LoadSettings() // Fix informations static void displayFixInformations() { - ImGui::SetNextWindowSize(ImVec2(250, 200)); + ImGui::SetNextWindowSize(ImVec2(250 * scale, 200 * scale)); ImGui::Begin("Informations", &popup_Informations); // - ImGui::SetCursorPos(ImVec2(10, 36)); + ImGui::SetCursorPos(ImVec2(10 * scale, 36 * scale)); ImGui::Text("Version : %s", FIX_VERSION); - ImGui::SetCursorPos(ImVec2(10, 76)); + ImGui::SetCursorPos(ImVec2(10 * scale, 76 * scale)); 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); + ImGuiStyle& style = ImGui::GetStyle(); + style.ItemSpacing = ImVec2(8 * scale, 8 * scale); // Spacing between widgets + style.FramePadding = ImVec2(3 * scale, 3 * scale); // Widgets padding + style.WindowPadding = ImVec2(10 * scale, 10 * scale); // Overlay padding - // 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); - } + scale = (float)screenHeight / 1200.f; - // Fix informations - ImGui::SetCursorPos(ImVec2(270, 33)); - if (ImGui::Button("Fix informations")) - popup_Informations = true; + ImGui::SetNextWindowSize(ImVec2(480 * scale, 400 * scale), ImGuiCond_Once); + + if (ImGui::Button("Like my work ? Consider donation")) ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL); // Donation + ImGui::SameLine(); + if (ImGui::Button("Fix informations")) popup_Informations = true; // Fix information if (popup_Informations) - displayFixInformations(); + { + ImGui::Begin("Informations", &popup_Informations); + ImGui::Text("Version : %s", FIX_VERSION); + ImGui::Text(FIX_INFORMATIONS); + ImGui::End(); + } - // 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::Columns(2, NULL, false); + + // 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 + 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(); } } - 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(); + if (ImGui::CollapsingHeader("Camera distance (*)", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::SetNextItemWidth(150 * scale); + if (ImGui::SliderFloat("##CameraValue", &cameraDistancevalue, 0, 3)) { + if (SetCameraDistance) SetCameraDistance(cameraDistancevalue); 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(); - } + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("Value is a multiplier."); + ImGui::Text("Affects both normal and weapon aiming distance."); + ImGui::EndTooltip(); } - 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)); + ImGui::NextColumn(); + if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) + { 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."); @@ -333,22 +317,17 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime) ImGui::EndTooltip(); } } - ImGui::EndChild(); + ImGui::Columns(1); // 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()) + 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 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()); + if (GetFOVIn && GetCompensadedFOV && GetFOVOut) + ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Compensated: %.2f, Out: %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut()); } - ImGui::EndChild(); } // Main dll intrance