From acbc31e53107b42fdab0f8ef41349637d431cd55 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Fri, 30 Oct 2026 00:19:56 +0000 Subject: [PATCH] Decompile fn_16126 (CUIListBoxEx::SelectItem) Batch #3953 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_16126 CUIListBoxEx::SelectItem: logic confirmed by peer review Peer-reviewed-by: youko, tayoba Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Lists/UIListBoxTemplate.h | 5 +++- .../ProbabilityTable/UIProbabilityTable.cpp | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Source/UI/Lists/UIListBoxTemplate.h b/Source/UI/Lists/UIListBoxTemplate.h index 0b3d9236..d3146323 100644 --- a/Source/UI/Lists/UIListBoxTemplate.h +++ b/Source/UI/Lists/UIListBoxTemplate.h @@ -171,6 +171,8 @@ public: this->selected = static_cast(-1); } + void SelectItem(CUIListItem* item); + // OFFSET: 0x00A04B30 // FUNCTION: fn_14963 int AddData(const D& value, bool refresh) { @@ -295,7 +297,8 @@ public: /* 00B8 */ int rowHeight; /* 00BC */ int itemX; /* 00C0 */ int itemY; - /* 00C4 */ int unknown_00C4; + /* 00C4 */ unsigned char unknown_00C4; + /* 00C5 */ unsigned char unknown_00C5[0x03]; /* 00C8 */ std::vector items; /* 00D4 */ std::list data; /* 00DC */ unsigned int selected; diff --git a/Source/UI/ProbabilityTable/UIProbabilityTable.cpp b/Source/UI/ProbabilityTable/UIProbabilityTable.cpp index d0db8840..fee83e22 100644 --- a/Source/UI/ProbabilityTable/UIProbabilityTable.cpp +++ b/Source/UI/ProbabilityTable/UIProbabilityTable.cpp @@ -77,6 +77,34 @@ void CUIListBoxEx::OnScr } } +// OFFSET: 0x00A4C780 +// FUNCTION: fn_16126 +template <> +void CUIListBoxEx::SelectItem(CUIListItem* item) { + if (this->unknown_00C4) { + return; + } + for (ProbabilityTable::CUIItem* other : this->items) { + if (other != item) { + other->SetSelected(0); + } + } + item->SetSelected(1); + if (item->index == static_cast(this->selected) && this->unknown_00E0) { + return; + } + ProbabilityTable::CUIItem* selectedItem = dynamic_cast(item); + if (!selectedItem) { + return; + } + this->selected = selectedItem->index; + if (this->onSelect && static_cast(this->selected) >= 0 && this->selected < this->data.size()) { + auto node = this->data.begin(); + std::advance(node, static_cast(this->selected)); + this->onSelect(selectedItem, *node); + } +} + // OFFSET: 0x00A4DC90 // FUNCTION: fn_16195 void CUIProbabilityTable::OnButtonClick() {