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.
This commit is contained in:
Skyth (Asilkan) 2025-02-04 14:53:43 +03:00 committed by GitHub
parent bbb3ebc25d
commit ee97736d58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 12 deletions

View file

@ -221,6 +221,8 @@ static bool FontBuilder_Build(ImFontAtlas* atlas)
for (size_t i = 0; i < atlas->ConfigData.size(); i++) for (size_t i = 0; i < atlas->ConfigData.size(); i++)
{ {
auto& config = atlas->ConfigData[i]; auto& config = atlas->ConfigData[i];
bool increaseSpacing = strstr(config.Name, "Seurat") != nullptr;
auto& [index, count] = ranges[i]; auto& [index, count] = ranges[i];
for (size_t j = 0; j < count; j++) 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; double x0, y0, x1, y1, u0, v0, u1, v1;
glyph.getQuadPlaneBounds(x0, y0, x1, y1); glyph.getQuadPlaneBounds(x0, y0, x1, y1);
glyph.getQuadAtlasBounds(u0, v0, u1, v1); glyph.getQuadAtlasBounds(u0, v0, u1, v1);
double advance = glyph.getAdvance();
if (increaseSpacing && glyph.getCodepoint() == ' ')
advance *= 1.5;
config.DstFont->AddGlyph( config.DstFont->AddGlyph(
&config, &config,
glyph.getCodepoint(), glyph.getCodepoint(),
@ -239,7 +246,7 @@ static bool FontBuilder_Build(ImFontAtlas* atlas)
v1 / packer.height, v1 / packer.height,
u1 / packer.width, u1 / packer.width,
v0 / packer.height, v0 / packer.height,
glyph.getAdvance()); advance);
} }
config.DstFont->BuildLookupTable(); config.DstFont->BuildLookupTable();

View file

@ -3,6 +3,7 @@
#include <app.h> #include <app.h>
#include <ui/game_window.h> #include <ui/game_window.h>
#include <gpu/video.h> #include <gpu/video.h>
#include <xxHashMap.h>
#include "aspect_ratio_patches.h" #include "aspect_ratio_patches.h"
#include "camera_patches.h" #include "camera_patches.h"
@ -348,7 +349,7 @@ struct CsdModifier
uint32_t cornerIndex{}; uint32_t cornerIndex{};
}; };
static const ankerl::unordered_dense::map<XXH64_hash_t, CsdModifier> g_modifiers = static const xxHashMap<CsdModifier> g_modifiers =
{ {
// ui_balloon // ui_balloon
{ HashStr("ui_balloon/window/bg"), { STRETCH } }, { HashStr("ui_balloon/window/bg"), { STRETCH } },
@ -1147,8 +1148,8 @@ PPC_FUNC(sub_830D1EF0)
y = g_aspectRatioOffsetY + (y + 0.5f) * g_aspectRatioScale; y = g_aspectRatioOffsetY + (y + 0.5f) * g_aspectRatioScale;
} }
vertex[i].x = ((x - 0.5f) / Video::s_viewportWidth) * 2.0f - 1.0f; vertex[i].x = ((round(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].y = ((round(y) - 0.5f) / Video::s_viewportHeight) * -2.0f + 1.0f;
} }
bool letterboxTop = PPC_LOAD_U8(r3.u32 + PRIMITIVE_2D_PADDING_OFFSET + 0x1); bool letterboxTop = PPC_LOAD_U8(r3.u32 + PRIMITIVE_2D_PADDING_OFFSET + 0x1);

View file

@ -339,7 +339,7 @@ static float AlignToNextGrid(float value)
return round(value / GRID_SIZE) * GRID_SIZE; 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); 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); SetShaderModifier(IMGUI_SHADER_MODIFIER_CHECKERBOARD);
drawList->AddRectFilled(min, { min.x + gridSize, max.y }, outerColor); // Container outline left drawList->AddRectFilled({ min.x, min.y + gridSize }, { min.x + gridSize, max.y - gridSize }, outerColor); // Container outline left
drawList->AddRectFilled({ max.x - gridSize, min.y }, max, outerColor); // Container outline right drawList->AddRectFilled({ max.x - gridSize, min.y + gridSize }, { max.x, max.y - gridSize }, drawRightOutline ? outerColor : innerColor); // Container outline right
drawList->AddRectFilled({ min.x + gridSize, min.y }, { max.x - gridSize, min.y + gridSize }, outerColor); // Container outline top drawList->AddRectFilled(min, { max.x, 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, 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 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(); auto drawList = ImGui::GetForegroundDrawList();
SetProceduralOrigin(settingsMin); SetProceduralOrigin(settingsMin);
DrawContainer(settingsMin, settingsMax); DrawContainer(settingsMin, settingsMax, true);
if (DrawCategories()) if (DrawCategories())
{ {
@ -1334,7 +1334,7 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax)
auto drawList = ImGui::GetForegroundDrawList(); auto drawList = ImGui::GetForegroundDrawList();
SetProceduralOrigin(infoMin); SetProceduralOrigin(infoMin);
DrawContainer(infoMin, infoMax); DrawContainer(infoMin, infoMax, false);
auto clipRectMin = drawList->GetClipRectMin(); auto clipRectMin = drawList->GetClipRectMin();
auto clipRectMax = drawList->GetClipRectMax(); auto clipRectMax = drawList->GetClipRectMax();

@ -1 +1 @@
Subproject commit 2d135d175dfbedd84d78fb846bcc7de4a859f8ef Subproject commit 1d2ae6b5f7fd5805e59465e66953bbd8066e75dd