From 3aa4c39beef48b996ecc7e555f0a46e19dbecb43 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 14:53:53 +0000 Subject: [PATCH] Decompile 3 functions in Source/UI/Item/UIEquipmentPropertiesWnd.cpp, Source/UI/Item/UIEquipmentPropertiesWnd.h, ... Batch #8181 by willerthal: 0 byte-identical, 3 confirmed by peer review. - fn_15039 CUIListBoxEx,std::allocator > >::AddNewItem: logic confirmed by peer review - fn_15040 CUIListBoxEx,std::allocator > >::Slot53: logic confirmed by peer review - fn_15041 CUIListBoxEx,std::allocator > >::Resize: logic confirmed by peer review Peer-reviewed-by: Yommy, alisonrag, pedrao Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Item/UIEquipmentPropertiesWnd.cpp | 114 ++++++++++++++++++++ Source/UI/Item/UIEquipmentPropertiesWnd.h | 8 ++ Source/UI/Lists/UIListBoxTemplate.h | 15 ++- 3 files changed, 136 insertions(+), 1 deletion(-) diff --git a/Source/UI/Item/UIEquipmentPropertiesWnd.cpp b/Source/UI/Item/UIEquipmentPropertiesWnd.cpp index fbee4cc4..c555f256 100644 --- a/Source/UI/Item/UIEquipmentPropertiesWnd.cpp +++ b/Source/UI/Item/UIEquipmentPropertiesWnd.cpp @@ -8,7 +8,9 @@ #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/StringUtil.h" +#include #include +#include #include #include @@ -25,6 +27,118 @@ template void CUIListBoxEx::Slot35(int); template void CUIListBoxEx::ClearItems(); +void CUIListItem::SetImageResources(CBitmapRes* normal, CBitmapRes* hover, CBitmapRes* pressed, CBitmapRes* disabled) { + auto& images = *reinterpret_cast*>(reinterpret_cast(this) + 0x80); + images.clear(); + images[0] = normal; + images[1] = hover; + images[2] = pressed; + this->disabledImage = disabled; + this->Invalidate(); +} + +EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine::CUIItemEquipmentPropertiesLine(UIWindowContext& context) + : CUIListItem(context), unknown_00E8(nullptr), unknown_00EC(nullptr), evenRowColor(0), oddRowColor(0) { +} + +template <> +void CUIListBoxEx::SelectItem(CUIListItem* item) { + if (this->unknown_00C4) { + return; + } + for (EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine* other : this->items) { + if (other != item) { + other->SetSelected(0); + } + } + item->SetSelected(1); + if (item->index == static_cast(this->selected) && this->unknown_00E0) { + return; + } + EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine* 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: 0x00A0CF00 +// FUNCTION: fn_15039 +template <> +void CUIListBoxEx::AddNewItem() { + if (this->itemWidth <= 0 || this->rowHeight <= 0) { + return; + } + + for (EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine* item : this->items) { + this->RemoveChild(item, 1); + } + this->items.clear(); + this->selected = static_cast(-1); + + if (this->rowHeight <= this->geometry.height) { + unsigned count = static_cast(this->geometry.height / this->rowHeight) + 1; + if (this->geometry.height % this->rowHeight > 1) { + ++count; + } + this->items.resize(count, nullptr); + for (EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine*& slot : this->items) { + EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine* item = + new EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine(*this->m_context); + item->SetSize(this->itemWidth, this->rowHeight); + item->Show(0); + CResPtr* images = reinterpret_cast*>(reinterpret_cast(this) + 0x80); + item->SetImageResources(images[0], images[1], images[2], images[3]); + item->onHover = [this](CUIListItem* listItem) { + for (EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine* other : this->items) { + other->SetHighlighted(other == listItem); + } + }; + item->onPress = [this](CUIListItem* listItem) { + this->SelectItem(listItem); + }; + this->AddChild(item); + slot = item; + } + } + + this->scrollBar->SetTotal(this->geometry.height); + this->scrollBar->SetVisible(this->geometry.height); +} + +// OFFSET: 0x00A0D160 +// FUNCTION: fn_15040 +template <> +void CUIListBoxEx::Slot53(int resolveSkin) { + CResPtr* images = reinterpret_cast*>(reinterpret_cast(this) + 0x80); + images[0] = CResPtr(this->LoadBitmapResource(this->imageNames[0], resolveSkin)); + images[1] = CResPtr(this->LoadBitmapResource(this->imageNames[1], resolveSkin)); + images[2] = CResPtr(this->LoadBitmapResource(this->imageNames[2], resolveSkin)); + images[3] = CResPtr(this->LoadBitmapResource(this->disabledName, resolveSkin)); + for (EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine* item : this->items) { + item->SetImageResources(images[0], images[1], images[2], images[3]); + } +} + +// OFFSET: 0x00A0D370 +// FUNCTION: fn_15041 +template <> +void CUIListBoxEx::Resize(int width, int height) { + UIWindow::Resize(width, height); + this->AddNewItem(); + this->scrollBar->Resize(this->scrollBar->geometry.width, height); + this->scrollBar->SetTotal(static_cast(this->data.size()) * this->rowHeight + this->itemY); + this->scrollBar->SetVisible(this->geometry.height); + this->scrollBar->SetPosition(this->scrollBar->position); + this->rebind = 1; +} + // OFFSET: 0x00A0D3F0 // FUNCTION: fn_15042 template <> diff --git a/Source/UI/Item/UIEquipmentPropertiesWnd.h b/Source/UI/Item/UIEquipmentPropertiesWnd.h index 481fc770..7b87f964 100644 --- a/Source/UI/Item/UIEquipmentPropertiesWnd.h +++ b/Source/UI/Item/UIEquipmentPropertiesWnd.h @@ -11,6 +11,8 @@ namespace EquipmentPropertiesWnd { class CUIItemEquipmentPropertiesLine : public CUIListItem { public: + explicit CUIItemEquipmentPropertiesLine(UIWindowContext& context); + /* 00E8 */ CUIStaticText* unknown_00E8; /* 00EC */ CUIStaticText* unknown_00EC; /* 00F0 */ std::uint32_t evenRowColor; @@ -61,6 +63,12 @@ template <> CUIListBoxEx::~CUIListBoxEx(); template <> void CUIListBoxEx::Slot15(int width, int height); +template <> +void CUIListBoxEx::AddNewItem(); +template <> +void CUIListBoxEx::Resize(int width, int height); +template <> +void CUIListBoxEx::Slot53(int resolveSkin); #if defined(_WIN32) && !defined(_WIN64) static_assert(sizeof(EquipmentPropertiesWnd::CUIItemEquipmentPropertiesLine) == 0xF8); diff --git a/Source/UI/Lists/UIListBoxTemplate.h b/Source/UI/Lists/UIListBoxTemplate.h index 96a67867..a36171ad 100644 --- a/Source/UI/Lists/UIListBoxTemplate.h +++ b/Source/UI/Lists/UIListBoxTemplate.h @@ -15,6 +15,10 @@ class CUIListItem : public CUIControl { public: + // INLINED + explicit CUIListItem(UIWindowContext& context) : CUIControl(context), selected(0), disabledImage(nullptr), frozen(0), index(-1) { + } + void Slot25(int x, int y) override; void Slot27(int x, int y) override; void Slot31(int x, int y) override; @@ -23,10 +27,11 @@ public: virtual void SetSelected(bool selected); virtual void SetHighlighted(bool highlighted); virtual void SetFrozen(bool frozen); + void SetImageResources(CBitmapRes* normal, CBitmapRes* hover, CBitmapRes* pressed, CBitmapRes* disabled); /* 0084 */ unsigned char unknown_0084[0x04]; /* 0088 */ int selected; - /* 008C */ unsigned char unknown_008C[0x04]; + /* 008C */ CBitmapRes* disabledImage; /* 0090 */ unsigned char frozen; /* 0094 */ int index; /* 0098 */ std::function onHover; @@ -303,6 +308,14 @@ public: bool RebindIndex(int index); void SelectItem(CUIListItem* item); bool SelectIndex(int index); + void AddNewItem() { + } + void Resize(int width, int height) override { + UIWindow::Resize(width, height); + } + void Slot53(int resolveSkin) override { + (void)resolveSkin; + } // OFFSET: 0x00A04B30 // FUNCTION: fn_14963