Batch #3850 by youko: 0 byte-identical, 3 confirmed by peer review. - fn_15200 CUIListBoxEx<ExchangeUI::CUIItem,ExchangeUI::CItemData>::OnScroll: logic confirmed by peer review - fn_15286 CUIListBoxEx<ExchangeUI::CUIItem,ExchangeUI::CItemData>::AddData: logic confirmed by peer review - fn_15290 CUIListBoxEx<ExchangeUI::CUIItem,ExchangeUI::CItemData>::ClearData: logic confirmed by peer review Peer-reviewed-by: eAthena, Yommy, superintelligence Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
142 lines
4.2 KiB
C++
142 lines
4.2 KiB
C++
#include "UI/Exchange/UIExchangeUI.h"
|
|
|
|
#include "Resource/ResourceMgr.h"
|
|
#include "Resource/SkinPalette.h"
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
#include <windows.h>
|
|
|
|
template void CUIListBoxEx<ExchangeUI::CUIItem, ExchangeUI::CItemData>::SetOnSelect(std::function<void(ExchangeUI::CUIItem*, const ExchangeUI::CItemData&)>);
|
|
template void CUIListBoxEx<ExchangeUI::CUIItem, ExchangeUI::CItemData>::SetBinder(std::function<void(ExchangeUI::CUIItem*, const ExchangeUI::CItemData&)>);
|
|
template void CUIListBoxEx<ExchangeUI::CUIItem, ExchangeUI::CItemData>::SetImages(const std::string&, const std::string&, const std::string&,
|
|
const std::string&);
|
|
|
|
// OFFSET: 0x00A15150
|
|
// FUNCTION: fn_15193
|
|
template <>
|
|
void CUIListBoxEx<ExchangeUI::CUIItem, ExchangeUI::CItemData>::Paint() {
|
|
this->ClearSurface(0xFFFF00FF);
|
|
}
|
|
|
|
// OFFSET: 0x00A15160
|
|
// FUNCTION: fn_15194
|
|
template <>
|
|
void CUIListBoxEx<ExchangeUI::CUIItem, ExchangeUI::CItemData>::Slot35(int value) {
|
|
if (!this->scrollBar->dragging && this->scrollBar->total > this->scrollBar->visible) {
|
|
this->scrollBar->Slot35(value);
|
|
} else if (this->parent) {
|
|
this->parent->Slot35(value);
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x00A157C0
|
|
// FUNCTION: fn_15200
|
|
template <>
|
|
void CUIListBoxEx<ExchangeUI::CUIItem, ExchangeUI::CItemData>::OnScroll(int position) {
|
|
auto it = this->items.begin();
|
|
if (it == this->items.end()) {
|
|
return;
|
|
}
|
|
if (this->data.size() == 0) {
|
|
for (; it != this->items.end(); ++it) {
|
|
(*it)->index = -1;
|
|
(*it)->Show(0);
|
|
}
|
|
return;
|
|
}
|
|
|
|
const int first = (*it)->index;
|
|
unsigned int row = position / this->rowHeight;
|
|
if (first != -1) {
|
|
if (first < static_cast<int>(row)) {
|
|
if (row - first < static_cast<unsigned int>(this->items.size())) {
|
|
std::rotate(this->items.begin(), this->items.begin() + (row - first), this->items.end());
|
|
}
|
|
} else if (first > static_cast<int>(row)) {
|
|
if (first - row < static_cast<unsigned int>(this->items.size())) {
|
|
std::rotate(this->items.begin(), this->items.end() - (first - row), this->items.end());
|
|
}
|
|
}
|
|
}
|
|
|
|
it = this->items.begin();
|
|
for (int y = this->itemY - position % this->rowHeight; y < this->geometry.height; y += this->rowHeight, ++it, ++row) {
|
|
if (it == this->items.end() || row >= this->data.size()) {
|
|
break;
|
|
}
|
|
ExchangeUI::CUIItem* item = *it;
|
|
if (item) {
|
|
if (this->rebind || row != static_cast<unsigned int>(item->index)) {
|
|
item->index = row;
|
|
if (this->binder) {
|
|
auto node = this->data.begin();
|
|
std::advance(node, static_cast<int>(row));
|
|
this->binder(item, *node);
|
|
}
|
|
}
|
|
item->SetSelected(row == this->selected);
|
|
item->Move(this->itemX, y);
|
|
item->Show(1);
|
|
}
|
|
}
|
|
|
|
for (; it != this->items.end(); ++it) {
|
|
(*it)->index = -1;
|
|
(*it)->Show(0);
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x00A171A0
|
|
// FUNCTION: fn_15286
|
|
template <>
|
|
int CUIListBoxEx<ExchangeUI::CUIItem, ExchangeUI::CItemData>::AddData(const ExchangeUI::CItemData& value, bool refresh) {
|
|
this->data.push_back(value);
|
|
if (refresh) {
|
|
this->UpdateScrollBar();
|
|
}
|
|
return this->data.size() - 1;
|
|
}
|
|
|
|
// OFFSET: 0x00A17530
|
|
// FUNCTION: fn_15289
|
|
void CUIExchangeUI::OnCheckChanged(bool) {
|
|
}
|
|
|
|
// OFFSET: 0x00A17540
|
|
// FUNCTION: fn_15290
|
|
template <>
|
|
void CUIListBoxEx<ExchangeUI::CUIItem, ExchangeUI::CItemData>::ClearData() {
|
|
this->data.clear();
|
|
this->selected = static_cast<unsigned int>(-1);
|
|
this->UpdateScrollBar();
|
|
}
|
|
|
|
// OFFSET: 0x00A17670
|
|
// FUNCTION: fn_15292
|
|
void CUIExchangeUI::OnEditSubmit() {
|
|
}
|
|
|
|
// OFFSET: 0x00A17680
|
|
// FUNCTION: fn_15293
|
|
void CUIExchangeUI::OnSelectFirstListItem(ExchangeUI::CUIItem*, const ExchangeUI::CItemData&) {
|
|
}
|
|
|
|
// OFFSET: 0x00A176A0
|
|
// FUNCTION: fn_15295
|
|
void CUIExchangeUI::OnSelectSecondListItem(ExchangeUI::CUIItem*, const ExchangeUI::CItemData&) {
|
|
}
|
|
|
|
// OFFSET: 0x00A176C0
|
|
// FUNCTION: fn_15297
|
|
void ExchangeUI::CUIItem::Paint() {
|
|
if (this->frozen) {
|
|
unsigned red = 0;
|
|
unsigned green = 0;
|
|
unsigned blue = 0;
|
|
SkinPaletteChannels(ResourceMgr::Instance(), 10, 6, red, green, blue);
|
|
this->ClearSurface(RGB(red, green, blue));
|
|
} else {
|
|
this->ClearSurface(0xFFFFFFFF);
|
|
}
|
|
}
|