MCPcopy Create free account
hub / github.com/ddnet/ddnet / DoPickerLogic

Method DoPickerLogic

src/game/client/ui.cpp:623–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621}
622
623EEditState CUi::DoPickerLogic(const void *pId, const CUIRect *pRect, float *pX, float *pY)
624{
625 if(MouseHovered(pRect))
626 SetHotItem(pId);
627
628 EEditState Res = EEditState::EDITING;
629
630 if(HotItem() == pId && MouseButtonClicked(0))
631 {
632 SetActiveItem(pId);
633 if(!m_pLastEditingItem)
634 {
635 m_pLastEditingItem = pId;
636 Res = EEditState::START;
637 }
638 }
639
640 if(CheckActiveItem(pId) && !MouseButton(0))
641 {
642 SetActiveItem(nullptr);
643 if(m_pLastEditingItem == pId)
644 {
645 m_pLastEditingItem = nullptr;
646 Res = EEditState::END;
647 }
648 }
649
650 if(!CheckActiveItem(pId) && Res == EEditState::EDITING)
651 return EEditState::NONE;
652
653 if(Input()->ShiftIsPressed())
654 m_MouseSlow = true;
655
656 if(pX)
657 *pX = std::clamp(MouseX() - pRect->x, 0.0f, pRect->w);
658 if(pY)
659 *pY = std::clamp(MouseY() - pRect->y, 0.0f, pRect->h);
660
661 return Res;
662}
663
664void CUi::DoSmoothScrollLogic(float *pScrollOffset, float *pScrollOffsetChange, float ViewPortSize, float TotalSize, bool SmoothClamp, float ScrollSpeed) const
665{

Callers 1

PopupColorPickerMethod · 0.80

Calls 2

InputFunction · 0.85
ShiftIsPressedMethod · 0.80

Tested by

no test coverage detected