#include "UI.h" #include "UIControl_List.h" UIControl_List::UIControl_List() : UIControl_Base() { //elementCount = 0; } UIControl_List::~UIControl_List() { } bool UIControl_List::setupControl(UIScene* scene, IggyValuePath* parent, const std::string& controlName) { //UIControl::setControlType(UIControl::eButtonList); bool success = UIControl_Base::setupControl(scene, parent, controlName); m_removeAllItemsFunc = 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; } void UIControl_List::init(int id) { m_id = id; IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; value[0].number = id; auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_initFunc, 1, value); } void UIControl_List::ReInit() { UIControl_Base::ReInit(); init(m_id); m_itemCount = 0; m_iCurrentSelection = 0; } void UIControl_List::tick() { UIControl_Base::tick(); } void UIControl_List::clearList() { IggyDataValue result; auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_removeAllItemsFunc, 0, nullptr); m_itemCount = 0; } void UIControl_List::removeItem(int index) { IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; value[0].number = index; IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcRemoveItem, 1, value); --m_itemCount; } int UIControl_List::getItemCount() { return m_itemCount; } void UIControl_List::setCurrentSelection(int iSelection) { IggyDataValue result; IggyDataValue value[1]; value[0].type = IGGY_DATATYPE_number; value[0].number = iSelection; auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcHighlightItem, 1, value); } int UIControl_List::getCurrentSelection() { return m_iCurrentSelection; } void UIControl_List::updateChildFocus(int iChild) { m_iCurrentSelection = iChild; } void UIControl_List::SetTouchFocus(S32 iX, S32 iY, bool bRepeat) { IggyDataValue result; IggyDataValue value[3]; value[0].type = IGGY_DATATYPE_number; value[0].number = iX; value[1].type = IGGY_DATATYPE_number; value[1].number = iY; value[2].type = IGGY_DATATYPE_boolean; value[2].boolval = bRepeat; auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcSetTouchFocus, 3, value); } bool UIControl_List::CanTouchTrigger(S32 iX, S32 iY) { IggyDataValue result; IggyDataValue value[2]; value[0].type = IGGY_DATATYPE_number; value[0].number = iX; value[1].type = IGGY_DATATYPE_number; value[1].number = iY; auto out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcCanTouchTrigger, 2, value); S32 bCanTouchTrigger = false; if (result.type == IGGY_DATATYPE_boolean) bCanTouchTrigger = (bool)result.boolval; return bCanTouchTrigger; } void UIControl_List::addElement(eUIControlType type, int index) { //if (index < 0) index = m_elementCount; //m_elementCount++; //UIControl::setControlType(type); //m_elements.push_back(index); } int UIControl_List::getListIndex(int id) { for (auto it = m_list.begin(); it != m_list.end(); ++it) { if (*it == id) return std::distance(m_list.begin(), it); } return -1; }