From 65eb389b7b8c8125d3342a2b78ffbd68139e80d5 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 28 Oct 2026 20:12:41 +0000 Subject: [PATCH] Decompile 6 functions in Source/UI/Window/InputFocus.cpp, Source/UI/Window/InputFocus.h, ... Batch #1689 by ragnarok-clanker: 0 byte-identical, 6 confirmed by peer review. - fn_17197 InputFocus::IsLast: logic confirmed by peer review - fn_17260 InputFocus::Previous: logic confirmed by peer review - fn_16960 UIWindow::NextFocusable: logic confirmed by peer review - fn_16969 UIWindow::PreviousFocusable: logic confirmed by peer review - fn_10911 UIEditCtrl2::SendMsg: logic confirmed by peer review - fn_10913 UIEditCtrl5::SendMsg: logic confirmed by peer review Peer-reviewed-by: eAthena Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Edit/UIEditVariants.cpp | 16 ++++++++-- Source/UI/Window/InputFocus.cpp | 32 ++++++++++---------- Source/UI/Window/InputFocus.h | 3 +- Source/UI/Window/UIWindow.cpp | 50 +++++++++++++++++++++++++++++++ Source/UI/Window/UIWindow.h | 2 ++ 5 files changed, 84 insertions(+), 19 deletions(-) diff --git a/Source/UI/Edit/UIEditVariants.cpp b/Source/UI/Edit/UIEditVariants.cpp index 322170c..fbca819 100644 --- a/Source/UI/Edit/UIEditVariants.cpp +++ b/Source/UI/Edit/UIEditVariants.cpp @@ -16,7 +16,13 @@ int UIEditCtrl2::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::in if (message != 0) { this->UIEditCtrl::SendMsg(sender, message, a, b, c, d); } else { - this->m_edit->focus.Advance(); + InputFocus& focus = this->m_edit->focus; + if (focus.IsLast(focus.window)) { + focus.First(); + } else { + focus.Next(); + } + this->UIWindow::SendMsg(sender, message, a, b, c, d); } @@ -62,7 +68,13 @@ int UIEditCtrl5::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::in if (message != 0) { this->UIEditCtrl::SendMsg(sender, message, a, b, c, d); } else { - this->m_edit->focus.Advance(); + InputFocus& focus = this->m_edit->focus; + if (focus.IsLast(focus.window)) { + focus.First(); + } else { + focus.Next(); + } + this->UIWindow::SendMsg(sender, message, a, b, c, d); } diff --git a/Source/UI/Window/InputFocus.cpp b/Source/UI/Window/InputFocus.cpp index 790a007..6b2af2f 100644 --- a/Source/UI/Window/InputFocus.cpp +++ b/Source/UI/Window/InputFocus.cpp @@ -100,28 +100,28 @@ void InputFocus::Next() { this->window = nullptr; } -// INLINED -void InputFocus::Advance() { +// OFFSET: 0x00A96F60 +// FUNCTION: fn_17197 +bool InputFocus::IsLast(UIWindow* value) { + return value && value->parent->NextFocusable(value) == nullptr; +} + +// OFFSET: 0x00AA9DC0 +// FUNCTION: fn_17260 +void InputFocus::Previous() { if (!this->window) { - this->Next(); return; } - UIWindow* parent = this->window->parent; - bool found = false; - - for (UIWindow* child : parent->m_children) { - if (found && child->Slot05()) { - this->Next(); - return; - } - - if (child == this->window && child->Slot05()) { - found = true; - } + UIWindow* previous = this->window->parent->PreviousFocusable(this->window); + if (!previous) { + this->Set(nullptr); + return; } - this->First(); + if (previous->Slot05()) { + this->Set(previous); + } } // INLINED diff --git a/Source/UI/Window/InputFocus.h b/Source/UI/Window/InputFocus.h index d22dab6..5a7c304 100644 --- a/Source/UI/Window/InputFocus.h +++ b/Source/UI/Window/InputFocus.h @@ -9,7 +9,8 @@ struct InputFocus { void First(); void Last(); void Next(); - void Advance(); + bool IsLast(UIWindow* value); + void Previous(); void Refresh(UIWindow* const& excludedRoot); }; diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index a5d710d..2fea154 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -575,6 +575,56 @@ UIWindow* UIWindow::Root() { return root; } +// OFFSET: 0x00A7ED50 +// FUNCTION: fn_16960 +UIWindow* UIWindow::NextFocusable(UIWindow* child) { + auto it = this->m_children.begin(); + + for (; it != this->m_children.end(); ++it) { + if (*it == child && child->Slot05()) { + break; + } + } + + if (it == this->m_children.end()) { + return nullptr; + } + + for (++it; it != this->m_children.end(); ++it) { + if ((*it)->Slot05()) { + return *it; + } + } + + return nullptr; +} + +// OFFSET: 0x00A7FF30 +// FUNCTION: fn_16969 +UIWindow* UIWindow::PreviousFocusable(UIWindow* child) { + auto it = this->m_children.end(); + + for (; it != this->m_children.begin(); --it) { + UIWindow* window = *std::prev(it); + if (window == child && window->Slot05()) { + break; + } + } + + if (it == this->m_children.begin()) { + return nullptr; + } + + for (--it; it != this->m_children.begin(); --it) { + UIWindow* window = *std::prev(it); + if (window->Slot05()) { + return window; + } + } + + return nullptr; +} + // OFFSET: 0x00A82DD0 // FUNCTION: fn_16995 void UIWindow::DeleteChildren() { diff --git a/Source/UI/Window/UIWindow.h b/Source/UI/Window/UIWindow.h index dea9b2c..6ba1c97 100644 --- a/Source/UI/Window/UIWindow.h +++ b/Source/UI/Window/UIWindow.h @@ -117,6 +117,8 @@ public: return this->m_uid; } UIWindow* Root(); + UIWindow* NextFocusable(UIWindow* child); + UIWindow* PreviousFocusable(UIWindow* child); void ClearSurface(std::uint32_t color); void SetSize(int width, int height); void DrawBitmap(int x, int y, const BitmapImage* image, bool transparent);