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

Method ShowPopupSelection

src/game/client/ui.cpp:1943–1970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1941}
1942
1943void CUi::ShowPopupSelection(float X, float Y, SSelectionPopupContext *pContext)
1944{
1945 const STextBoundingBox TextBoundingBox = TextRender()->TextBoundingBox(pContext->m_FontSize, pContext->m_aMessage, -1, pContext->m_Width);
1946 const float PopupHeight = minimum((pContext->m_aMessage[0] == '\0' ? -pContext->m_EntrySpacing : TextBoundingBox.m_H) + pContext->m_vEntries.size() * (pContext->m_EntryHeight + pContext->m_EntrySpacing) + (SPopupMenu::POPUP_BORDER + SPopupMenu::POPUP_MARGIN) * 2 + CScrollRegion::HEIGHT_MAGIC_FIX, Screen()->h * 0.4f);
1947 pContext->m_pUI = this;
1948 pContext->m_pSelection = nullptr;
1949 pContext->m_SelectionIndex = -1;
1950 pContext->m_Props.m_Corners = IGraphics::CORNER_ALL;
1951 if(pContext->m_AlignmentHeight >= 0.0f)
1952 {
1953 constexpr float Margin = SPopupMenu::POPUP_BORDER + SPopupMenu::POPUP_MARGIN;
1954 if(X + pContext->m_Width > Screen()->w - Margin)
1955 {
1956 X = maximum<float>(X - pContext->m_Width, Margin);
1957 }
1958 if(Y + pContext->m_AlignmentHeight + PopupHeight > Screen()->h - Margin)
1959 {
1960 Y -= PopupHeight;
1961 pContext->m_Props.m_Corners = IGraphics::CORNER_T;
1962 }
1963 else
1964 {
1965 Y += pContext->m_AlignmentHeight;
1966 pContext->m_Props.m_Corners = IGraphics::CORNER_B;
1967 }
1968 }
1969 DoPopupMenu(pContext, X, Y, pContext->m_Width, PopupHeight, pContext, PopupSelection, pContext->m_Props);
1970}
1971
1972int CUi::DoDropDown(CUIRect *pRect, int CurSelection, const char **pStrs, int Num, SDropDownState &State)
1973{

Callers 2

PopupImageMethod · 0.80
PopupSoundMethod · 0.80

Calls 3

TextRenderFunction · 0.85
TextBoundingBoxMethod · 0.80
minimumFunction · 0.50

Tested by

no test coverage detected