From 052f7dcfd54d9afe68cadc546cfc3e2c3ebf035d Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Tue, 27 Oct 2026 20:27:17 +0000 Subject: [PATCH] Decompile fn_03593 (UIListBox_NaviSearch::Slot26) Batch #1144 by eAthena: 1 byte-identical, 0 confirmed by peer review. - fn_03593 UIListBox_NaviSearch::Slot26: byte-identical Merged automatically: every function is byte-identical to the original. --- Source/UI/Lists/UIListBoxNaviSearch.h | 18 ++ Source/UI/Window/UIWindow.cpp | 300 ++++++++++++++++++++++++++ Source/UI/Window/UIWindow.h | 20 ++ 3 files changed, 338 insertions(+) create mode 100644 Source/UI/Lists/UIListBoxNaviSearch.h diff --git a/Source/UI/Lists/UIListBoxNaviSearch.h b/Source/UI/Lists/UIListBoxNaviSearch.h new file mode 100644 index 0000000..29a0bf5 --- /dev/null +++ b/Source/UI/Lists/UIListBoxNaviSearch.h @@ -0,0 +1,18 @@ +#ifndef RAGNAROK_SOURCE_UI_LISTS_UILISTBOXNAVISEARCH_H +#define RAGNAROK_SOURCE_UI_LISTS_UILISTBOXNAVISEARCH_H + +#include "UI/Lists/UIListBox.h" + +class UIListBox_NaviSearch : public UIListBox { +public: + void Resize(int width, int height) override; + void Slot25(int x, int y) override; + void Slot26(int x, int y) override; + void Slot35(int value) override; + void Clear() override; + + /* 00D4 */ int unknown_00D4; + /* 00D8 */ int unknown_00D8; +}; + +#endif diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index 5c4039e..cdc9f1a 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -1,5 +1,6 @@ #include "Client/Mode/ModeCursor.h" #include "Client/Mode/ModeEvents.h" +#include "Network/TextEncoding.h" #include "Render/DeviceContext/DCBitmap.h" #include "Render/Primitives/RenderPrimitivePool.h" #include "Render/Primitives/RenderQueues.h" @@ -7,11 +8,17 @@ #include "Render/Text/TextContext.h" #include "Render/Textures/Texture.h" #include "Resource/Bitmap/BitmapImage.h" +#include "Resource/Sprites/ActionResource.h" +#include "Resource/Sprites/SpriteResource.h" +#include "UI/Edit/UIEditCtrl.h" +#include "UI/Lists/UIListBoxNaviSearch.h" +#include "UI/Lists/UIScrollBar.h" #include "UI/Window/UIWindow.h" #include "UI/Window/UIWindowMgr.h" #include "UI/Window/WindowRegistration.h" #include +#include #include #include #include @@ -721,3 +728,296 @@ void UIWindow::FlushPrimitives(RenderQueues& queues, bool depthAlpha, float dept this->m_overlayPrimitives.clear(); } + +// OFFSET: 0x00A7B450 +// FUNCTION: fn_16928 +void UIWindow::FillSurface(std::uint32_t color, const RECT* rectangle) { + if (this->geometry.surface) { + this->geometry.surface->Fill(rectangle, color); + } +} + +// OFFSET: 0x00A7BB20 +// FUNCTION: fn_16934 +void UIWindow::DrawBitmapScaled(int x, int y, int width, int height, const BitmapImage* image, int option) { + if (!this->geometry.surface || !image) { + return; + } + + this->geometry.surface->ScaleCopy(x, y, image->width, image->height, width, height, image->pixels, option); +} + +// OFFSET: 0x00A7BBB0 +// FUNCTION: fn_16936 +void UIWindow::DrawBitmapRegion(int x, int y, const BitmapImage* image, bool transparent, bool whole, int left, int top, int right, int bottom) { + if (!this->geometry.surface || !image) { + return; + } + + static_cast(this->geometry.surface)->SetAlpha(image->alpha != 0); + if (whole) { + this->geometry.surface->CopyRegion(x, y, 0, 0, image->width, image->height, image->pixels, image->width, image->height, transparent, false); + } else { + this->geometry.surface->CopyRegion(x, y, left, top, right, bottom, image->pixels, image->width, image->height, transparent, false); + } +} + +// OFFSET: 0x00A7BDD0 +// FUNCTION: fn_16939 +void UIWindow::DrawAuxiliaryScaled(int mode, int x, int y, int width, int height, BitmapImage* image, int option, bool rebuild) { + if (!this->geometry.surface || !image) { + return; + } + + if (rebuild) { + image->ClearAuxiliary(); + } + + image->CreateAuxiliary(mode); + if (image->auxiliary) { + this->geometry.surface->ScaleCopy(x, y, image->width, image->height, width, height, static_cast(image->auxiliary), option); + } +} + +// OFFSET: 0x00A7BE30 +// FUNCTION: fn_16940 +void UIWindow::DrawAuxiliary(int mode, int x, int y, BitmapImage* image, bool transparent, bool rebuild) { + if (!this->geometry.surface || !image) { + return; + } + + if (rebuild) { + image->ClearAuxiliary(); + } + + image->CreateAuxiliary(mode); + if (image->auxiliary) { + this->geometry.surface->Copy(x, y, image->width, image->height, static_cast(image->auxiliary), transparent); + } +} + +// OFFSET: 0x00A7BE90 +// FUNCTION: fn_16941 +void UIWindow::DrawAmount(FontCache& fonts, const TextLocale& locale, int amount, std::string text, int x, int y) { + COLORREF color = 0; + COLORREF shadow = 0; + bool outlined = true; + + if (amount >= 1000000000) { + color = 0x7F00FF; + shadow = 0xFF; + } else if (amount >= 100000000) { + color = 0x64C8C8; + } else if (amount >= 10000000) { + color = 0xFF; + outlined = false; + } else if (amount >= 1000000) { + color = 0xFF00; + } else if (amount >= 100000) { + color = 0xFF0000; + outlined = false; + } else if (amount >= 10000) { + color = 0xFF1EFF; + outlined = false; + } else if (amount >= 1000) { + color = 0xFFFF; + shadow = 0xFF; + } else if (amount >= 100) { + color = 0xFFFF00; + shadow = 0xFF0000; + } else if (amount >= 10) { + color = 0xC800C8; + shadow = 0xFF0000; + } else { + color = 0xFFFF00; + } + + const char* characters = text.c_str(); + const int bytes = static_cast(std::strlen(characters)); + TextContext context(*this->geometry.surface, fonts, locale); + context.SetFont(0, 12, 0, 0); + context.SetColor(color); + if (outlined) { + context.Draw(x, y, characters, bytes); + context.SetColor(shadow); + context.Draw(x - 1, y, characters, bytes); + } else { + context.Draw(x, y, characters, bytes); + } +} + +// OFFSET: 0x00A80170 +// FUNCTION: fn_16971 +int UIWindow::TextHeight( + FontCache& fonts, const TextLocale& locale, const char* text, unsigned bytes, int family, int height, unsigned char bold, unsigned char italic +) { + if (!text) { + return 0; + } + + if (!bytes) { + bytes = static_cast(std::strlen(text)); + if (!bytes) { + return 0; + } + } + + TextContext context(*this->geometry.surface, fonts, locale); + context.SetFont(family, height, bold, italic); + return context.Measure(text, bytes).cy; +} + +// OFFSET: 0x00A80230 +// FUNCTION: fn_16972 +int UIWindow::VerticalTextHeight(FontCache& fonts, const TextLocale& locale, const char* text, unsigned bytes, int family, int height, unsigned char bold) { + if (!text) { + return 0; + } + + if (!bytes) { + bytes = static_cast(std::strlen(text)); + if (!bytes) { + return 0; + } + } + + const char* end = text + bytes; + int total = 0; + const char* marker = text + TextContext::Marker(text, static_cast(end - text), locale.inlineCharset); + TextContext context(*this->geometry.surface, fonts, locale); + context.SetFont(family, height, bold, 0); + if (marker && *marker) { + text = marker + 3; + } + + while (text < end) { + const char* next = CharNextExA(static_cast(g_textCodePage), text, 0); + total += context.Measure(text, static_cast(next - text)).cy; + text = next; + } + + return total; +} + +// OFFSET: 0x00A80340 +// FUNCTION: fn_16973 +SIZE UIWindow::TextSize( + FontCache& fonts, const TextLocale& locale, const char* text, unsigned bytes, int family, int height, unsigned char bold, unsigned char italic +) { + SIZE size = {}; + if (!text) { + return size; + } + + if (!bytes) { + bytes = static_cast(std::strlen(text)); + if (!bytes) { + return size; + } + } + + TextContext context(*this->geometry.surface, fonts, locale); + context.SetFont(family, height, bold, italic); + size = context.Measure(text, bytes); + return size; +} + +// OFFSET: 0x00A80430 +// FUNCTION: fn_16974 +SIZE UIWindow::VerticalTextSize( + FontCache& fonts, const TextLocale& locale, const char* text, unsigned bytes, int family, int height, unsigned char bold, unsigned char italic +) { + SIZE size = {}; + if (!text) { + return size; + } + + if (!bytes) { + bytes = static_cast(std::strlen(text)); + if (!bytes) { + return size; + } + } + + TextContext context(*this->geometry.surface, fonts, locale); + context.SetFont(family, height, bold, italic); + const char* end = text + bytes; + const char* marker = text + TextContext::Marker(text, static_cast(end - text), locale.inlineCharset); + if (marker && *marker) { + text = marker + 3; + } + + while (text < end) { + const char* next = CharNextExA(static_cast(g_textCodePage), text, 0); + const SIZE part = context.Measure(text, static_cast(next - text)); + if (size.cx < part.cx) { + size.cx = part.cx; + } + + size.cy += part.cy; + text = next; + } + + return size; +} + +// OFFSET: 0x00A80640 +// FUNCTION: fn_16976 +int UIWindow::FormattedTextWidth(FontCache& fonts, const TextLocale& locale, std::string text, int family, int height, unsigned char bold) { + int total = 0; + unsigned char currentBold = bold; + const char* current = text.c_str(); + const char* end = current + std::strlen(current); + + while (current != end) { + if (*current == '^') { + if (current[1] == 'b') { + currentBold = 1; + current += 2; + continue; + } + + if (current[1] == '/' && current[2] == 'b') { + currentBold = bold; + current += 3; + continue; + } + + char color[7] = {}; + strncpy_s(color, sizeof(color), current + 1, 6); + char* parsed = nullptr; + std::strtol(color, &parsed, 16); + if (parsed - color == 6) { + current += 7; + continue; + } + } else if (current[1] == '\\' && current[2] == 'n') { + current += 2; + continue; + } + + const char* next = CharNextExA(static_cast(g_textCodePage), current, 0); + const std::string character(current, next); + total += this->TextWidth(fonts, locale, character.c_str(), 0, family, height, currentBold, 0); + current = next; + } + + return total; +} + +// OFFSET: 0x00A836C0 + +// OFFSET: 0x00A83FD0 + +// OFFSET: 0x005C3340 + +// OFFSET: 0x005C6F20 +// FUNCTION: fn_03593 +void UIListBox_NaviSearch::Slot26(int, int) { +} + +// OFFSET: 0x005C6F40 + +// OFFSET: 0x005C7360 + +// OFFSET: 0x005C7AD0 diff --git a/Source/UI/Window/UIWindow.h b/Source/UI/Window/UIWindow.h index e853832..d85a91b 100644 --- a/Source/UI/Window/UIWindow.h +++ b/Source/UI/Window/UIWindow.h @@ -5,6 +5,7 @@ #include "UI/Layout/WindowGeometry.h" #include +#include #include #include @@ -20,6 +21,10 @@ struct RenderQueues; struct BitmapImage; class FontCache; struct TextLocale; +struct tagRECT; +struct tagSIZE; +struct ActionFrame; +class CSprRes; struct UIWindowContext { RenderPrimitivePool& primitives; @@ -121,6 +126,21 @@ public: unsigned char italic ); void FlushPrimitives(RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd); + void FillSurface(std::uint32_t color, const tagRECT* rectangle); + void DrawBitmapScaled(int x, int y, int width, int height, const BitmapImage* image, int option); + void DrawBitmapRegion(int x, int y, const BitmapImage* image, bool transparent, bool whole, int left, int top, int right, int bottom); + void DrawAuxiliaryScaled(int mode, int x, int y, int width, int height, BitmapImage* image, int option, bool rebuild); + void DrawAuxiliary(int mode, int x, int y, BitmapImage* image, bool transparent, bool rebuild); + void DrawAmount(FontCache& fonts, const TextLocale& locale, int amount, std::string text, int x, int y); + int TextHeight(FontCache& fonts, const TextLocale& locale, const char* text, unsigned bytes, int family, int height, unsigned char bold, unsigned char italic); + int VerticalTextHeight(FontCache& fonts, const TextLocale& locale, const char* text, unsigned bytes, int family, int height, unsigned char bold); + tagSIZE TextSize(FontCache& fonts, const TextLocale& locale, const char* text, unsigned bytes, int family, int height, unsigned char bold, unsigned char italic); + tagSIZE VerticalTextSize( + FontCache& fonts, const TextLocale& locale, const char* text, unsigned bytes, int family, int height, unsigned char bold, unsigned char italic + ); + int FormattedTextWidth(FontCache& fonts, const TextLocale& locale, std::string text, int family, int height, unsigned char bold); + int RestoreEditTexts(const unsigned char* data); + bool FitSprite(const ActionFrame* frame, const CSprRes* sprite, int width, int height, int* x, int* y, float* scale); // INLINED bool HasTextBackground() const {