From 74b3ce59b3376b298a94ae318a9c48b925de4e82 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 29 Oct 2026 11:00:43 +0000 Subject: [PATCH] Decompile fn_17012 (UIWindow::DrawCenteredText) Batch #2116 by ragnarok-clanker: 0 byte-identical, 1 confirmed by peer review. - fn_17012 UIWindow::DrawCenteredText: logic confirmed by peer review Reviewed-by: ragnarok-clanker --- Source/UI/Window/UIWindow.cpp | 15 +++++++++++++++ Source/UI/Window/UIWindow.h | 1 + 2 files changed, 16 insertions(+) diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index 48add66e..0df67f13 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -807,6 +807,21 @@ void UIWindow::DrawTextAt( context.Draw(x, y, text, bytes); } +// OFFSET: 0x00A847C0 +// FUNCTION: fn_17012 +void UIWindow::DrawCenteredText(int x, int y, const char* text, int width, int family, int height, std::uint32_t color, unsigned char bold) { + TextContext context(*this->geometry.surface); + context.SetFont(family, height, bold, 0); + context.SetColor(color); + const int bytes = static_cast(std::strlen(text)); + if (width) { + const int extent = context.Measure(text, bytes).cx; + context.Draw(static_cast((width - extent) * 0.5 + x), y, text, static_cast(std::strlen(text))); + } else { + context.Draw(x, y, text, bytes); + } +} + // OFFSET: 0x00A7C470 // FUNCTION: fn_16944 void UIWindow::FlushPrimitives(RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd) { diff --git a/Source/UI/Window/UIWindow.h b/Source/UI/Window/UIWindow.h index 4161832f..aa1de222 100644 --- a/Source/UI/Window/UIWindow.h +++ b/Source/UI/Window/UIWindow.h @@ -134,6 +134,7 @@ public: FontCache& fonts, const TextLocale& locale, int x, int y, const char* text, int bytes, int family, int height, std::uint32_t color, unsigned char bold, unsigned char italic ); + void DrawCenteredText(int x, int y, const char* text, int width, int family, int height, std::uint32_t color, unsigned char bold); void DrawRightOutlinedText( int right, int y, const char* text, int bytes, std::uint32_t color, std::uint32_t outline, int family, int height, unsigned char bold