// Vibecoded. This need a real implementation later UIControl_List::UIControl_List() : UIControl_Base() { nextElementId = 0; elementCount = 0; } UIControl_List::~UIControl_List() { for (auto* control : childControls) { if (control) control->destroy(); } } int UIControl_List::setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName) { int success = UIControl_Base::setupControl(scene, parent, controlName); m_funcRemoveAllItems = registerFastName(L"removeAllItems"); m_funcHighlightItem = registerFastName(L"HighlightItem"); m_funcRemoveItem = registerFastName(L"RemoveItem"); m_funcSetTouchFocus = registerFastName(L"SetTouchFocus"); m_funcCanTouchFocus = registerFastName(L"CanTouchFocus"); m_funcCanTouchTrigger = registerFastName(L"CanTouchTrigger"); m_funcEnableItem = registerFastName(L"EnableItem"); m_funcSetItemLabel = registerFastName(L"SetItemLabel"); m_funcGetItemLabel = registerFastName(L"GetItemLabel"); return success; } int UIControl_List::addElement(UIControl::eUIControlType type, int id) { if (id < 0) id = nextElementId; nextElementId++; elementTypes[id] = type; elementStates[id] = true; elementList.push_back(id); return id; } void UIControl_List::remElement(int id) { elementCount--; elementTypes.erase(id); elementStates.erase(id); auto it = std::find(elementList.begin(), elementList.end(), id); if (it != elementList.end()) elementList.erase(it); } bool UIControl_List::istype(UIControl::eUIControlType type, int id) { auto it = elementTypes.find(id); if (it != elementTypes.end()) return it->second == type; return false; } int UIControl_List::getListIndex(int id) { for (size_t i = 0; i < elementList.size(); ++i) { if (elementList[i] == id) return i; } return -1; } void UIControl_List::clearList() { IggyValuePath* path = UIControl::getIggyValuePath(this); IggyPlayerCallMethodRS(iggyPlayer, nullptr, path, iggyRemoveAllItemsId, 0, 0); elementCount = 0; elementTypes.clear(); elementStates.clear(); elementList.clear(); } int UIControl_List::init(int initialValue) { UIController* controller = pController; 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, methodId_Init, 1, &arg); unsigned int platformId = *(controller->pPlatformInfo + 96); if (platformId == 3 || (platformId >= 5 && platformId <= 6)) return TouchBoxAdd(UIController::Instance, this, pController); return result; } int UIControl_List::ReInit() { UIControl::ReInit(); int currentValue = value; UIController* controller = pController; int iggyPath = UIControl::getIggyValuePath(this); IggyArg arg = { .type = 4, .val = (double)currentValue }; int result = IggyPlayerCallMethodRS(controller->getIggyPlayer(), &out, iggyPath, methodId_ReInit, 1, &arg); if (IsTouchPlatform()) result = TouchBoxAdd(UIController::Instance, this, pController); if (mapControlTypes.size > 0) mapControlTypes.clear_and_delete_nodes(); if (mapEnabledStates.size > 0) mapEnabledStates.clear_and_delete_nodes(); prevSelection = currentSelection; return result; } void UIControl_List::tick() { UIControl_Base::tick(); for (auto* control : childControls) { control->update(); if (control) control->destroy(3); } 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(pController->getIggyPlayer(), &out, iggyPath, methodId_SetSelect, 1, &arg); } else { PendingSetCurrentSelection* pending = new PendingSetCurrentSelection(index, this); return pendingUpdates.push_back(pending); } } int UIControl_List::SetItemLabel(int index, UIString text, bool immediate) { int listIndex = 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(pController->getIggyPlayer(), &out, iggyPath, m_funcSetItemLabel, 2, args); } else { PendingSetLabel* pending = new PendingSetLabel(index, this, text); return pendingUpdates.push_back(pending); } }