Improved UI scaling
This commit is contained in:
@@ -7,6 +7,11 @@
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
|
||||
// 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);
|
||||
@@ -57,6 +62,8 @@ const char* FIX_VERSION = "1.0.3";
|
||||
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Unlock ultrawide resolutions.\n - Remove pillar boxing.\n - Unlock FPS.\n - Disable depth of field.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Disable FOG.";
|
||||
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
|
||||
|
||||
// Scaling factor based vertical resolution
|
||||
float scale = 1.f;
|
||||
|
||||
// Load and unload game core dll functions /!\ necessary
|
||||
static void LoadFixDLL()
|
||||
@@ -178,137 +185,125 @@ static void LoadSettings()
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
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
|
||||
style.CellPadding = ImVec2(10 * scale, 10 * scale); // Table cells padding
|
||||
|
||||
ImGui::SetNextWindowSize(ImVec2(350 * scale, 150 * scale), 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 (ImGui::Button("Like my work ? Consider donation")) ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL);
|
||||
ImGui::SameLine();
|
||||
// Fix information
|
||||
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::Begin("Informations", &popup_Informations);
|
||||
ImGui::Text("Version : %s", FIX_VERSION);
|
||||
ImGui::Text(FIX_INFORMATIONS);
|
||||
ImGui::End();
|
||||
}
|
||||
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, 50)) {}
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()) {
|
||||
if (SetFOV) SetFOV(worldFOVvalue);
|
||||
SaveSettings();
|
||||
if (ImGui::BeginTable("FixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
|
||||
ImGui::TableSetupColumn("LeftFix", ImGuiTableColumnFlags_WidthStretch, 0.4f);
|
||||
ImGui::TableSetupColumn("RightFix", ImGuiTableColumnFlags_WidthStretch, 0.6f);
|
||||
ImGui::TableNextRow();
|
||||
|
||||
// Drawing a left column with slider and general fix
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
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, 50)) {
|
||||
if (SetFOV) SetFOV(worldFOVvalue); SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
// Individual fixes
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
|
||||
ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.35f);
|
||||
ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.65f);
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
|
||||
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Frame time", &FPS_fix_enabled)) {
|
||||
if (SetFPSFixEnabled) SetFPSFixEnabled(FPS_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
|
||||
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
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::TableSetColumnIndex(1);
|
||||
if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) {
|
||||
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("This fix is intended for ultrawide only.");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Resolution", &Resolution_fix_enabled)) {
|
||||
if (SetResolutionFixEnabled) SetResolutionFixEnabled(Resolution_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Depth of field", &DOF_fix_enabled)) {
|
||||
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Chromatic aberrations", &CA_fix_enabled)) {
|
||||
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
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(70, 30));
|
||||
if (ImGui::Checkbox("Frame time", &FPS_fix_enabled)) {
|
||||
if (SetFPSFixEnabled) SetFPSFixEnabled(FPS_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
ImGui::SetCursorPos(ImVec2(5, 55));
|
||||
if (ImGui::Checkbox("Resolution", &Resolution_fix_enabled)) {
|
||||
if (SetResolutionFixEnabled) SetResolutionFixEnabled(Resolution_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
ImGui::SetCursorPos(ImVec2(120, 55));
|
||||
if (ImGui::Checkbox("Aspect ratio", &Aspect_fix_enabled)) {
|
||||
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(Aspect_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
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("Chromatic aberrations", &CA_fix_enabled)) {
|
||||
if (SetCAFixEnabled) SetCAFixEnabled(CA_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
ImGui::SetCursorPos(ImVec2(5, 130));
|
||||
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
|
||||
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
ImGui::SetCursorPos(ImVec2(110, 130));
|
||||
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, 80), true);
|
||||
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::SetCursorPos(ImVec2(5, 30));
|
||||
if (GetFOVIn && GetCompensadedFOV && GetFOVOut) // Test functions in case Core dll is not ready when called
|
||||
ImGui::Text("FOV In: %.2f, Compensated : %.2f, Out : %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut());
|
||||
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", screenWidth, screenHeight, aspectRatio);
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user