diff --git a/Source/UI/ProbabilityTable/UIProbabilityTable.cpp b/Source/UI/ProbabilityTable/UIProbabilityTable.cpp index fe99b133..1902058b 100644 --- a/Source/UI/ProbabilityTable/UIProbabilityTable.cpp +++ b/Source/UI/ProbabilityTable/UIProbabilityTable.cpp @@ -121,6 +121,15 @@ void CUIListBoxEx::OnScr template <> bool CUIListBoxEx::RebindIndex(int index); +template <> +void CUIListBoxEx::AddNewItem(); + +template <> +void CUIListBoxEx::Slot53(int resolveSkin); + +template <> +void CUIListBoxEx::Resize(int width, int height); + // OFFSET: 0x00A47EF0 // FUNCTION: fn_16104 bool UnusedTrueA47EF0() { @@ -193,6 +202,11 @@ void CUIListBoxEx::Slot1 namespace ProbabilityTable { +// OFFSET: 0x00A4D620 +// FUNCTION: fn_16190 +CUIItem::CUIItem() : CUIListItem(), nameText(nullptr), probabilityText(nullptr), backgroundColor(0xFFFFFFFF) { +} + // OFFSET: 0x00A48A70 // FUNCTION: fn_16118 void CUIItem::Slot15(int width, int height) { @@ -241,6 +255,76 @@ void CUIItem::Slot15(int width, int height) { } +// OFFSET: 0x00A4C090 +// FUNCTION: fn_16122 +template <> +void CUIListBoxEx::AddNewItem() { + if (this->itemWidth <= 0 || this->rowHeight <= 0) { + return; + } + + for (ProbabilityTable::CUIItem* item : this->items) { + this->RemoveChild(item, 1); + } + this->items.clear(); + this->selected = static_cast(-1); + + if (this->rowHeight <= this->geometry.height) { + unsigned int count = static_cast(this->geometry.height / this->rowHeight) + 1; + if (this->geometry.height % this->rowHeight > 1) { + ++count; + } + this->items.resize(count, nullptr); + for (ProbabilityTable::CUIItem*& slot : this->items) { + ProbabilityTable::CUIItem* item = new ProbabilityTable::CUIItem(); + 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 (ProbabilityTable::CUIItem* 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: 0x00A4C2F0 +// FUNCTION: fn_16123 +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 (ProbabilityTable::CUIItem* item : this->items) { + item->SetImageResources(images[0], images[1], images[2], images[3]); + } +} + +// OFFSET: 0x00A4C500 +// FUNCTION: fn_16124 +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: 0x00A4BFF0 // FUNCTION: fn_16120 template <> diff --git a/Source/UI/ProbabilityTable/UIProbabilityTable.h b/Source/UI/ProbabilityTable/UIProbabilityTable.h index c2b0f235..8584c579 100644 --- a/Source/UI/ProbabilityTable/UIProbabilityTable.h +++ b/Source/UI/ProbabilityTable/UIProbabilityTable.h @@ -21,6 +21,7 @@ public: class CUIItem : public CUIListItem { public: + CUIItem(); void Slot15(int width, int height) override; void Slot16() override; void Paint() override;