From ee97736d586f909f266c4e0cfd6fb074c661706d Mon Sep 17 00:00:00 2001 From: "Skyth (Asilkan)" <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Tue, 4 Feb 2025 14:53:43 +0300 Subject: [PATCH] Make custom UI a bit more accurate looking. (#274) * Update spacing for default font & pixel snap 2D primitives. * Replicate the missing info outline from world map. --- UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp | 9 ++++++++- UnleashedRecomp/patches/aspect_ratio_patches.cpp | 7 ++++--- UnleashedRecomp/ui/options_menu.cpp | 14 +++++++------- UnleashedRecompResources | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp b/UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp index 7371015..5d07ab0 100644 --- a/UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp +++ b/UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp @@ -221,6 +221,8 @@ static bool FontBuilder_Build(ImFontAtlas* atlas) for (size_t i = 0; i < atlas->ConfigData.size(); i++) { auto& config = atlas->ConfigData[i]; + bool increaseSpacing = strstr(config.Name, "Seurat") != nullptr; + auto& [index, count] = ranges[i]; for (size_t j = 0; j < count; j++) { @@ -228,6 +230,11 @@ static bool FontBuilder_Build(ImFontAtlas* atlas) double x0, y0, x1, y1, u0, v0, u1, v1; glyph.getQuadPlaneBounds(x0, y0, x1, y1); glyph.getQuadAtlasBounds(u0, v0, u1, v1); + + double advance = glyph.getAdvance(); + if (increaseSpacing && glyph.getCodepoint() == ' ') + advance *= 1.5; + config.DstFont->AddGlyph( &config, glyph.getCodepoint(), @@ -239,7 +246,7 @@ static bool FontBuilder_Build(ImFontAtlas* atlas) v1 / packer.height, u1 / packer.width, v0 / packer.height, - glyph.getAdvance()); + advance); } config.DstFont->BuildLookupTable(); diff --git a/UnleashedRecomp/patches/aspect_ratio_patches.cpp b/UnleashedRecomp/patches/aspect_ratio_patches.cpp index a830b43..2cfe69c 100644 --- a/UnleashedRecomp/patches/aspect_ratio_patches.cpp +++ b/UnleashedRecomp/patches/aspect_ratio_patches.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "aspect_ratio_patches.h" #include "camera_patches.h" @@ -348,7 +349,7 @@ struct CsdModifier uint32_t cornerIndex{}; }; -static const ankerl::unordered_dense::map g_modifiers = +static const xxHashMap g_modifiers = { // ui_balloon { HashStr("ui_balloon/window/bg"), { STRETCH } }, @@ -1147,8 +1148,8 @@ PPC_FUNC(sub_830D1EF0) y = g_aspectRatioOffsetY + (y + 0.5f) * g_aspectRatioScale; } - vertex[i].x = ((x - 0.5f) / Video::s_viewportWidth) * 2.0f - 1.0f; - vertex[i].y = ((y - 0.5f) / Video::s_viewportHeight) * -2.0f + 1.0f; + vertex[i].x = ((round(x) - 0.5f) / Video::s_viewportWidth) * 2.0f - 1.0f; + vertex[i].y = ((round(y) - 0.5f) / Video::s_viewportHeight) * -2.0f + 1.0f; } bool letterboxTop = PPC_LOAD_U8(r3.u32 + PRIMITIVE_2D_PADDING_OFFSET + 0x1); diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 8e6a79b..9469d4e 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -339,7 +339,7 @@ static float AlignToNextGrid(float value) return round(value / GRID_SIZE) * GRID_SIZE; } -static void DrawContainer(ImVec2 min, ImVec2 max) +static void DrawContainer(ImVec2 min, ImVec2 max, bool drawRightOutline) { double containerHeight = g_isStage ? 1.0 : ComputeMotion(g_appearTime, 0.0, CONTAINER_LINE_ANIMATION_DURATION); @@ -365,10 +365,10 @@ static void DrawContainer(ImVec2 min, ImVec2 max) SetShaderModifier(IMGUI_SHADER_MODIFIER_CHECKERBOARD); - drawList->AddRectFilled(min, { min.x + gridSize, max.y }, outerColor); // Container outline left - drawList->AddRectFilled({ max.x - gridSize, min.y }, max, outerColor); // Container outline right - drawList->AddRectFilled({ min.x + gridSize, min.y }, { max.x - gridSize, min.y + gridSize }, outerColor); // Container outline top - drawList->AddRectFilled({ min.x + gridSize, max.y - gridSize }, { max.x - gridSize, max.y }, outerColor); // Container outline bottom + drawList->AddRectFilled({ min.x, min.y + gridSize }, { min.x + gridSize, max.y - gridSize }, outerColor); // Container outline left + drawList->AddRectFilled({ max.x - gridSize, min.y + gridSize }, { max.x, max.y - gridSize }, drawRightOutline ? outerColor : innerColor); // Container outline right + drawList->AddRectFilled(min, { max.x, min.y + gridSize }, outerColor); // Container outline top + drawList->AddRectFilled({ min.x, max.y - gridSize }, max, outerColor); // Container outline bottom drawList->AddRectFilled({ min.x + gridSize, min.y + gridSize }, { max.x - gridSize, max.y - gridSize }, innerColor); // Inner container @@ -1310,7 +1310,7 @@ static void DrawSettingsPanel(ImVec2 settingsMin, ImVec2 settingsMax) auto drawList = ImGui::GetForegroundDrawList(); SetProceduralOrigin(settingsMin); - DrawContainer(settingsMin, settingsMax); + DrawContainer(settingsMin, settingsMax, true); if (DrawCategories()) { @@ -1334,7 +1334,7 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax) auto drawList = ImGui::GetForegroundDrawList(); SetProceduralOrigin(infoMin); - DrawContainer(infoMin, infoMax); + DrawContainer(infoMin, infoMax, false); auto clipRectMin = drawList->GetClipRectMin(); auto clipRectMax = drawList->GetClipRectMax(); diff --git a/UnleashedRecompResources b/UnleashedRecompResources index 2d135d1..1d2ae6b 160000 --- a/UnleashedRecompResources +++ b/UnleashedRecompResources @@ -1 +1 @@ -Subproject commit 2d135d175dfbedd84d78fb846bcc7de4a859f8ef +Subproject commit 1d2ae6b5f7fd5805e59465e66953bbd8066e75dd