CustomDropDown::CustomDropDown(): Widget(), DrawableCursorEventsListener(this) { mItemsList = mnew CustomList(); mItemsList->SetInternalParent(this, false); mItemsList->onSelectedItem += [&](auto x) { OnItemSelected(); }; mItemsList->SetMultiselectionAvailable(false); }
FontComboBox::FontComboBox( Control& parent ) : ComboBox( parent ), onFontSelected( 0 ), onFontSelectedReceiver( 0 ), onFontHighlighted( 0 ), onFontHighlightedReceiver( 0 ) { ResetFonts(); OnItemSelected( (ComboBox::item_event_handler)&FontComboBox::__ItemSelected, *this ); OnItemHighlighted( (ComboBox::item_event_handler)&FontComboBox::__ItemHighlighted, *this ); }
CustomDropDown::CustomDropDown(const CustomDropDown& other): Widget(other), DrawableCursorEventsListener(this), mClipLayout(other.mClipLayout), mMaxListItems(other.mMaxListItems), selectedItem(this), selectedItemPos(this), itemsCount(this) { mItemsList = FindInternalWidgetByType<CustomList>(); mItemsList->onSelectedItem += [&](auto x) { OnItemSelected(); }; mItemsList->Hide(true); mItemsList->SetMultiselectionAvailable(false); RetargetStatesAnimations(); }
MenuItem* ComboBox::AddItem(const std::string& label, const std::string& name) { MenuItem* item = _menu->AddItem(label, ""); item->SetName(name); item->SetTextPadding(Padding(2, 0, 0, 0)); item->_on_selected.Add(this, &ComboBox::OnItemSelected); if (_selected_item == nullptr) { OnItemSelected(item); } return item; }
bool ComboBox::OnKeyDown(bool is_down) { if (is_down) { std::list<Base*>& children = _menu->GetChildren(); auto i = std::find(children.begin(), children.end(), _selected_item); if (i != children.end() && (++i != children.end())) { Base* down_element = *i; OnItemSelected(down_element); } } return true; }
void CustomDropDown::CopyData(const Actor& otherActor) { const CustomDropDown& other = dynamic_cast<const CustomDropDown&>(otherActor); Widget::CopyData(other); mItemsList = FindInternalWidgetByType<CustomList>(); mItemsList->onSelectedItem += [&](auto x) { OnItemSelected(); }; mItemsList->Hide(true); mItemsList->SetMultiselectionAvailable(false); mClipLayout = other.mClipLayout; mMaxListItems = other.mMaxListItems; RetargetStatesAnimations(); }
void BatUITextBox::Update(float baseX, float baseY) { if(IsOnFocus()) { if(Global::KeyDown(KEY_A)) { OnItemSelected(); Global::ClearKeyState(); } } mSprBG.Update(); mSprCursor.SetPosition(112.0f, -122.0f - mSelectId*32.0f); mSprCursor.Update(); for(int i=0; i<MAX_TEXT_LINES; i++) { mTxtLines[i].Update(); } }
void CUIDragDropReferenceList::OnItemDrop(CUIWindow* w, void* pData) { OnItemSelected(w, pData); CUICellItem* itm = smart_cast<CUICellItem*>(w); VERIFY(itm->OwnerList() == itm->OwnerList()); if(m_f_item_drop && m_f_item_drop(itm)) { DestroyDragItem(); return; } CUIDragDropListEx* old_owner = itm->OwnerList(); CUIDragDropListEx* new_owner = m_drag_item->BackList(); if(old_owner && new_owner && old_owner!=new_owner) { inherited::OnItemDrop(w, pData); return; } CActor* actor = smart_cast<CActor*>(Level().CurrentViewEntity()); if(actor) { Ivector2 vec = PickCell(GetUICursor().GetCursorPosition()); if(vec.x!=-1&&vec.y!=-1) { Ivector2 vec2 = m_container->GetItemPos(itm); if(vec2.x!=-1&&vec2.y!=-1) { u8 index = u8(vec2.x); shared_str tmp = ACTOR_DEFS::g_quick_use_slots[vec.x]; xr_strcpy(ACTOR_DEFS::g_quick_use_slots[vec.x], ACTOR_DEFS::g_quick_use_slots[index]); xr_strcpy(ACTOR_DEFS::g_quick_use_slots[index], tmp.c_str()); ReloadReferences(actor); return; } } } DestroyDragItem(); }
void UIMain::Update(float baseX, float baseY) { if(IsOnFocus()) { if(Global::KeyDown(KEY_B)) { CloseUI(); mSelectId = 0; gUIMgr.SetActive(false); } if(Global::KeyDown(KEY_A)) { OnItemSelected(); Global::ClearKeyState(); } if(Global::KeyDown(KEY_UP)) { if(mSelectRow > 0) { mSelectRow--; mSelectId -= 2; FmodSound::PlaySnd(SND_SELECT); } } else if(Global::KeyDown(KEY_DOWN)) { if(mSelectRow < 3) { mSelectRow++; mSelectId += 2; FmodSound::PlaySnd(SND_SELECT); } } else if(Global::KeyDown(KEY_LEFT)) { if(mSelectCol > 0) { mSelectCol--; mSelectId -= 1; FmodSound::PlaySnd(SND_SELECT); } } else if(Global::KeyDown(KEY_RIGHT)) { if(mSelectCol < 1) { mSelectCol++; mSelectId += 1; FmodSound::PlaySnd(SND_SELECT); } } } mSprBG.SetPosition(baseX, baseY-152.0f); mSprBG.Update(); mSprCursor.SetPosition(baseX-285 + 100.0f*mSelectCol, baseY-112.0f - 32.0f*mSelectRow); mSprCursor.Update(); float yIndex = 0.0f; for(int i=0; i<MAX_UIM_ITEMS; i++) { if(i%2 == 0) { mSprHint[i].SetPosition(baseX-240, baseY-112.0f - 32.5f*yIndex); } else { mSprHint[i].SetPosition(baseX-140, baseY-112.0f - 32.5f*yIndex); yIndex += 1.0f; } mSprHint[i].Update(); } mTxtName.Update(); mTxtTankName.Update(); mTxtPlayerInfo.Update(); mTxtTankInfo.Update(); }