From 3c6e34849971e42a0a0c243382ba3bcdac656ca0 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:45:22 +0000 Subject: [PATCH] imgui_utils: improve precise outline drawing --- UnleashedRecomp/ui/achievement_menu.cpp | 4 ++-- UnleashedRecomp/ui/imgui_utils.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/UnleashedRecomp/ui/achievement_menu.cpp b/UnleashedRecomp/ui/achievement_menu.cpp index 389eb85..450e519 100644 --- a/UnleashedRecomp/ui/achievement_menu.cpp +++ b/UnleashedRecomp/ui/achievement_menu.cpp @@ -141,14 +141,14 @@ static void DrawHeaderContainer(const char* text) SetTextSkew((min.y + max.y) / 2.0f, Scale(3.0f)); // TODO: Apply bevel. - DrawTextWithOutline + DrawTextWithOutline ( g_fntNewRodinUB, fontSize, { /* X */ min.x + textMarginX, /* Y */ CENTRE_TEXT_VERT(min, max, textSize) - Scale(5) }, IM_COL32(255, 255, 255, 255 * alpha), text, - 3, + 1.65f, IM_COL32(0, 0, 0, 255 * alpha) ); diff --git a/UnleashedRecomp/ui/imgui_utils.h b/UnleashedRecomp/ui/imgui_utils.h index 64cce93..b23a2c9 100644 --- a/UnleashedRecomp/ui/imgui_utils.h +++ b/UnleashedRecomp/ui/imgui_utils.h @@ -188,10 +188,12 @@ static void DrawTextWithOutline(const ImFont* font, float fontSize, const ImVec2 if constexpr (std::is_same_v || std::is_same_v) { + auto step = outlineSize / 2.0f; + // TODO: This is still very inefficient! - for (float i = -outlineSize; i <= outlineSize; i += 0.5f) + for (float i = -outlineSize; i <= outlineSize; i += step) { - for (float j = -outlineSize; j <= outlineSize; j += 0.5f) + for (float j = -outlineSize; j <= outlineSize; j += step) { if (i == 0.0f && j == 0.0f) continue;