mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-12 19:18:20 +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();
|
CListboxItem UiDoListboxNextRow();
|
||||||
int UiDoListboxEnd(float *pScrollValue, bool *pItemActivated, bool *pListBoxActive = 0);
|
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_listdir_callback(const char *name, int is_dir, void *user);
|
||||||
//static void demolist_list_callback(const CUIRect *rect, int index, 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++)
|
for(int i = 0; i < pSelectedServer->m_NumReceivedClients; i++)
|
||||||
{
|
{
|
||||||
CListboxItem Item = UiDoListboxNextItem(&i);
|
CListboxItem Item = UiDoListboxNextItem(&pSelectedServer->m_aClients[i]);
|
||||||
|
|
||||||
if(!Item.m_Visible)
|
if(!Item.m_Visible)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CUIRect Name, Clan, Score, Flag;
|
CUIRect Name, Clan, Score, Flag;
|
||||||
Item.m_Rect.HSplitTop(25.0f, &Name, &Item.m_Rect);
|
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)
|
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);
|
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();
|
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_ListBoxClicked = true;
|
||||||
gs_ListBoxNewSelected = ThisItemIndex;
|
gs_ListBoxNewSelected = ThisItemIndex;
|
||||||
|
@ -696,7 +707,7 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected,
|
||||||
r.Margin(1.5f, &r);
|
r.Margin(1.5f, &r);
|
||||||
RenderTools()->DrawUIRect(&r, ColorRGBA(1, 1, 1, 0.5f), CUI::CORNER_ALL, 4.0f);
|
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;
|
CUIRect r = Item.m_Rect;
|
||||||
r.Margin(1.5f, &r);
|
r.Margin(1.5f, &r);
|
||||||
|
@ -718,6 +729,14 @@ int CMenus::UiDoListboxEnd(float *pScrollValue, bool *pItemActivated, bool *pLis
|
||||||
return gs_ListBoxNewSelected;
|
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)
|
int CMenus::DemolistFetchCallback(const char *pName, time_t Date, int IsDir, int StorageType, void *pUser)
|
||||||
{
|
{
|
||||||
CMenus *pSelf = (CMenus *)pUser;
|
CMenus *pSelf = (CMenus *)pUser;
|
||||||
|
|
Loading…
Reference in a new issue