// Vibecoded. This need a real implementation later UIControl_List::UIControl_List() : UIControl_Base() { this->nextElementId = 0; this->elementCount = 0; } UIControl_List::~UIControl_List() { for (auto* control : this->childControls) { if (control) { control->destroy(); } } } int UIControl_List::setupControl(UIScene* scene, IggyValuePath* path, const std::string& name) { int result = UIControl_Base::setupControl(scene, path, name); this->iggyRemoveAllItemsId = UIControl::registerFastName(this, "removeAllItems"); this->iggyHighlightItemId = UIControl::registerFastName(this, "HighlightItem"); this->iggyRemoveItemId = UIControl::registerFastName(this, "RemoveItem"); this->iggySetTouchFocusId = UIControl::registerFastName(this, "SetTouchFocus"); this->iggyCanTouchFocusId = UIControl::registerFastName(this, "CanTouchFocus"); this->iggyCanTouchTriggerId = UIControl::registerFastName(this, "CanTouchTrigger"); this->iggyEnableItemId = UIControl::registerFastName(this, "EnableItem"); this->iggySetItemLabelId = UIControl::registerFastName(this, "SetItemLabel"); this->iggyGetItemLabelId = UIControl::registerFastName(this, "GetItemLabel"); return result; } int UIControl_List::addElement(UIControl::eUIControlType type, int id) { if (id < 0) { id = this->nextElementId; } this->nextElementId++; this->elementTypes[id] = type; this->elementStates[id] = true; this->elementList.push_back(id); return id; } void UIControl_List::remElement(int id) { this->elementCount--; this->elementTypes.erase(id); this->elementStates.erase(id); auto it = std::find(this->elementList.begin(), this->elementList.end(), id); if (it != this->elementList.end()) { this->elementList.erase(it); } } bool UIControl_List::istype(UIControl::eUIControlType type, int id) { auto it = this->elementTypes.find(id); if (it != this->elementTypes.end()) { return it->second == type; } return false; } int UIControl_List::getListIndex(int id) { for (size_t i = 0; i < this->elementList.size(); ++i) { if (this->elementList[i] == id) { return i; } } return -1; } void UIControl_List::clearList() { IggyValuePath* path = UIControl::getIggyValuePath(this); IggyPlayerCallMethodRS(this->iggyPlayer, nullptr, path, this->iggyRemoveAllItemsId, 0, 0); this->elementCount = 0; this->elementTypes.clear(); this->elementStates.clear(); this->elementList.clear(); } int UIControl_List::init(int initialValue) { UIController* controller = this->pController; this->value = initialValue; int iggyPath = UIControl::getIggyValuePath(this); int iggyPlayer = controller->getIggyPlayer(); IggyArg arg; arg.type = IGGY_TYPE_INT; arg.value = (double)initialValue; int result = IggyPlayerCallMethodRS(iggyPlayer, &outResult, iggyPath, this->methodId_Init, 1, &arg); unsigned int platformId = *(controller->pPlatformInfo + 96); if (platformId == 3 || (platformId >= 5 && platformId <= 6)) { return TouchBoxAdd(UIController::Instance, this, this->pController); } return result; } int UIControl_List::ReInit() { UIControl::ReInit(); int currentValue = this->value; UIController* controller = this->pController; int iggyPath = UIControl::getIggyValuePath(this); IggyArg arg = { .type = 4, .val = (double)currentValue }; int result = IggyPlayerCallMethodRS(controller->getIggyPlayer(), &out, iggyPath, this->methodId_ReInit, 1, &arg); if (IsTouchPlatform()) { result = TouchBoxAdd(UIController::Instance, this, this->pController); } if (this->mapControlTypes.size > 0) { this->mapControlTypes.clear_and_delete_nodes(); } if (this->mapEnabledStates.size > 0) { this->mapEnabledStates.clear_and_delete_nodes(); } this->prevSelection = this->currentSelection; return result; } void UIControl_List::tick() { UIControl_Base::tick(); for (auto* control : this->childControls) { control->update(); if (control) { control->destroy(3); } } this->childControls.clear(); } int UIControl_List::setCurrentSelection(int index, bool immediate) { if (immediate) { int iggyPath = UIControl::getIggyValuePath(this); IggyArg arg = { .type = 4, .val = (double)index }; return IggyPlayerCallMethodRS(this->pController->getIggyPlayer(), &out, iggyPath, this->methodId_SetSelect, 1, &arg); } else { PendingSetCurrentSelection* pending = new PendingSetCurrentSelection(index, this); return this->pendingUpdates.push_back(pending); } } int UIControl_List::SetItemLabel(int index, UIString text, bool immediate) { int listIndex = this->getListIndex(index); if (immediate) { int iggyPath = UIControl::getIggyValuePath(this); IggyArg args[2]; args[0].set_int(listIndex); args[1].set_string(text.c_str(), text.length()); return IggyPlayerCallMethodRS(this->pController->getIggyPlayer(), &out, iggyPath, this->methodId_SetLabel, 2, args); } else { // Encola la actualización del texto PendingSetLabel* pending = new PendingSetLabel(index, this, text); return this->pendingUpdates.push_back(pending); } }