From 9aa5bce0eca782fb5e5025101bfc5016a7e96d10 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Fri, 30 Oct 2026 23:28:53 +0000 Subject: [PATCH] Decompile fn_17017 (UIWindow::sub_A85850) Batch #6468 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_17017 UIWindow::sub_A85850: logic confirmed by peer review Peer-reviewed-by: willerthal, Lumen, superintelligence Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Window/UIWindow.cpp | 102 +++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index ec9927cf..a2315c9d 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -42,7 +42,7 @@ #include "UI/Window/WindowPolicy.h" #include "UI/Window/WindowRegistration.h" #include "Utility/Text/StringUtil.h" - +#include "Contents/MapSkyMgr.h" #include #include #include @@ -2549,3 +2549,103 @@ void UINavigationV4Wnd::SelectRouteNode(int node) { } this->Invalidate(); } + +// OFFSET: 0x00A85850 +// FUNCTION: fn_17017 +void UIWindow::sub_A85850( + int x, int y, std::string text, int width, int align, std::uint32_t color, int outlineColor, int family, int height, int bold, unsigned char outlined +) { + int textWidth = 0; + if (const char* const string = text.c_str()) { + unsigned bytes = static_cast(text.size()); + if (!bytes) { + bytes = static_cast(std::strlen(string)); + } + + if (bytes) { + TextContext context(*this->geometry.surface); + context.SetFont(family, height, static_cast(bold), 0); + textWidth = context.Measure(string, bytes).cx; + } + } + + if (align == 2) { + x -= textWidth; + } else if (align == 6) { + x = static_cast((width - textWidth) * g_depthAverageHalf + x); + } + + int offset = 0; + const char* current = text.c_str(); + const char* const end = current + std::strlen(current); + while (current != end) { + const char* const next = CharNextExA(static_cast(g_textCodePage), current, 0); + int glyphWidth = 0; + { + const std::string glyph(current, next); + if (const char* const string = glyph.c_str()) { + if (const unsigned bytes = static_cast(std::strlen(string))) { + TextContext context(*this->geometry.surface); + context.SetFont(family, height, static_cast(bold), 0); + glyphWidth = context.Measure(string, bytes).cx; + } + } + } + + if (outlined == 1) { + { + const std::string glyph(current, next); + const char* const string = glyph.c_str(); + const int bytes = static_cast(std::strlen(string)); + TextContext context(*this->geometry.surface); + context.SetFont(family, height, static_cast(bold), 0); + context.SetColor(outlineColor); + context.Draw(x + offset + 1, y, string, bytes); + } + { + const std::string glyph(current, next); + const char* const string = glyph.c_str(); + const int bytes = static_cast(std::strlen(string)); + TextContext context(*this->geometry.surface); + context.SetFont(family, height, static_cast(bold), 0); + context.SetColor(outlineColor); + context.Draw(x + offset - 1, y, string, bytes); + } + { + const std::string glyph(current, next); + const char* const string = glyph.c_str(); + const int bytes = static_cast(std::strlen(string)); + TextContext context(*this->geometry.surface); + context.SetFont(family, height, static_cast(bold), 0); + context.SetColor(outlineColor); + context.Draw(x + offset, y + 1, string, bytes); + } + { + const std::string glyph(current, next); + const char* const string = glyph.c_str(); + const int bytes = static_cast(std::strlen(string)); + TextContext context(*this->geometry.surface); + context.SetFont(family, height, static_cast(bold), 0); + context.SetColor(outlineColor); + context.Draw(x + offset, y - 1, string, bytes); + } + } + + { + const std::string glyph(current, next); + const char* const string = glyph.c_str(); + const int bytes = static_cast(std::strlen(string)); + TextContext context(*this->geometry.surface); + context.SetFont(family, height, static_cast(bold), 0); + context.SetColor(color); + context.Draw(x + offset, y, string, bytes); + } + + offset += glyphWidth; + if (offset > width) { + break; + } + + current = next; + } +}