mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge pull request #3753 from Jupeyy/pr_generalize_some_ui_stuff
Fix out of list clip clickable/hoverable items
This commit is contained in:
commit
565cd76d31
|
@ -220,6 +220,8 @@ class CMenus : public CComponent
|
|||
CListboxItem UiDoListboxNextRow();
|
||||
int UiDoListboxEnd(float *pScrollValue, bool *pItemActivated, bool *pListBoxActive = 0);
|
||||
|
||||
int UiLogicGetCurrentClickedItem();
|
||||
|
||||
//static void demolist_listdir_callback(const char *name, int is_dir, void *user);
|
||||
//static void demolist_list_callback(const CUIRect *rect, int index, void *user);
|
||||
|
||||
|
|
|
@ -1066,14 +1066,14 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View)
|
|||
|
||||
for(int i = 0; i < pSelectedServer->m_NumReceivedClients; i++)
|
||||
{
|
||||
CListboxItem Item = UiDoListboxNextItem(&i);
|
||||
CListboxItem Item = UiDoListboxNextItem(&pSelectedServer->m_aClients[i]);
|
||||
|
||||
if(!Item.m_Visible)
|
||||
continue;
|
||||
|
||||
CUIRect Name, Clan, Score, Flag;
|
||||
Item.m_Rect.HSplitTop(25.0f, &Name, &Item.m_Rect);
|
||||
if(UI()->DoButtonLogic(&pSelectedServer->m_aClients[i], "", 0, &Name))
|
||||
if(UiLogicGetCurrentClickedItem() == i)
|
||||
{
|
||||
if(pSelectedServer->m_aClients[i].m_FriendState == IFriends::FRIEND_PLAYER)
|
||||
m_pClient->Friends()->RemoveFriend(pSelectedServer->m_aClients[i].m_aName, pSelectedServer->m_aClients[i].m_aClan);
|
||||
|
|
|
@ -620,7 +620,18 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected,
|
|||
|
||||
CListboxItem Item = UiDoListboxNextRow();
|
||||
|
||||
if(Item.m_Visible && UI()->DoButtonLogic(pId, "", gs_ListBoxSelectedIndex == gs_ListBoxItemIndex, &Item.m_HitRect))
|
||||
CUIRect HitRect = Item.m_HitRect;
|
||||
|
||||
if(HitRect.y < gs_ListBoxOriginalView.y)
|
||||
{
|
||||
float TmpDiff = gs_ListBoxOriginalView.y - HitRect.y;
|
||||
HitRect.y = gs_ListBoxOriginalView.y;
|
||||
HitRect.h -= TmpDiff;
|
||||
}
|
||||
|
||||
HitRect.h = minimum(HitRect.h, (gs_ListBoxOriginalView.y + gs_ListBoxOriginalView.h) - HitRect.y);
|
||||
|
||||
if(Item.m_Visible && UI()->DoButtonLogic(pId, "", gs_ListBoxSelectedIndex == gs_ListBoxItemIndex, &HitRect))
|
||||
{
|
||||
gs_ListBoxClicked = true;
|
||||
gs_ListBoxNewSelected = ThisItemIndex;
|
||||
|
@ -696,7 +707,7 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected,
|
|||
r.Margin(1.5f, &r);
|
||||
RenderTools()->DrawUIRect(&r, ColorRGBA(1, 1, 1, 0.5f), CUI::CORNER_ALL, 4.0f);
|
||||
}
|
||||
else if(UI()->MouseInside(&Item.m_Rect) && !NoHoverEffects)
|
||||
else if(UI()->MouseInside(&HitRect) && !NoHoverEffects)
|
||||
{
|
||||
CUIRect r = Item.m_Rect;
|
||||
r.Margin(1.5f, &r);
|
||||
|
@ -718,6 +729,14 @@ int CMenus::UiDoListboxEnd(float *pScrollValue, bool *pItemActivated, bool *pLis
|
|||
return gs_ListBoxNewSelected;
|
||||
}
|
||||
|
||||
int CMenus::UiLogicGetCurrentClickedItem()
|
||||
{
|
||||
if(gs_ListBoxClicked)
|
||||
return gs_ListBoxNewSelected;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CMenus::DemolistFetchCallback(const char *pName, time_t Date, int IsDir, int StorageType, void *pUser)
|
||||
{
|
||||
CMenus *pSelf = (CMenus *)pUser;
|
||||
|
|
Loading…
Reference in a new issue