mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
made overlay enterable
This commit is contained in:
parent
9fd796162a
commit
01c7a06c22
|
@ -2212,6 +2212,9 @@ bool CMenus::OnMouseMove(float x, float y)
|
||||||
if(!m_MenuActive)
|
if(!m_MenuActive)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// prev mouse position
|
||||||
|
m_PrevMousePos = m_MousePos;
|
||||||
|
|
||||||
UI()->ConvertMouseMove(&x, &y);
|
UI()->ConvertMouseMove(&x, &y);
|
||||||
m_MousePos.x += x;
|
m_MousePos.x += x;
|
||||||
m_MousePos.y += y;
|
m_MousePos.y += y;
|
||||||
|
|
|
@ -150,6 +150,7 @@ class CMenus : public CComponent
|
||||||
bool m_MenuActive;
|
bool m_MenuActive;
|
||||||
bool m_UseMouseButtons;
|
bool m_UseMouseButtons;
|
||||||
vec2 m_MousePos;
|
vec2 m_MousePos;
|
||||||
|
vec2 m_PrevMousePos;
|
||||||
bool m_InfoMode;
|
bool m_InfoMode;
|
||||||
|
|
||||||
// images
|
// images
|
||||||
|
@ -332,6 +333,7 @@ class CMenus : public CComponent
|
||||||
const void *m_pData;
|
const void *m_pData;
|
||||||
float m_X;
|
float m_X;
|
||||||
float m_Y;
|
float m_Y;
|
||||||
|
bool m_Reset;
|
||||||
};
|
};
|
||||||
|
|
||||||
CInfoOverlay m_InfoOverlay;
|
CInfoOverlay m_InfoOverlay;
|
||||||
|
|
|
@ -142,11 +142,15 @@ void CMenus::Move(bool Up, int Filter)
|
||||||
|
|
||||||
void CMenus::SetOverlay(int Type, float x, float y, const void *pData)
|
void CMenus::SetOverlay(int Type, float x, float y, const void *pData)
|
||||||
{
|
{
|
||||||
m_InfoOverlayActive = true;
|
if(m_InfoOverlay.m_Reset)
|
||||||
m_InfoOverlay.m_Type = Type;
|
{
|
||||||
m_InfoOverlay.m_X = x;
|
m_InfoOverlayActive = true;
|
||||||
m_InfoOverlay.m_Y = y;
|
m_InfoOverlay.m_Type = Type;
|
||||||
m_InfoOverlay.m_pData = pData;
|
m_InfoOverlay.m_X = x;
|
||||||
|
m_InfoOverlay.m_Y = y;
|
||||||
|
m_InfoOverlay.m_pData = pData;
|
||||||
|
m_InfoOverlay.m_Reset = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMenus::DoBrowserEntry(const void *pID, CUIRect *pRect, const CServerInfo *pEntry, bool Selected)
|
int CMenus::DoBrowserEntry(const void *pID, CUIRect *pRect, const CServerInfo *pEntry, bool Selected)
|
||||||
|
@ -524,16 +528,23 @@ bool CMenus::RenderFilterHeader(CUIRect View, int FilterIndex)
|
||||||
void CMenus::RenderServerbrowserOverlay()
|
void CMenus::RenderServerbrowserOverlay()
|
||||||
{
|
{
|
||||||
if(!m_InfoOverlayActive)
|
if(!m_InfoOverlayActive)
|
||||||
|
{
|
||||||
|
m_InfoOverlay.m_Reset = true;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int Type = m_InfoOverlay.m_Type;
|
int Type = m_InfoOverlay.m_Type;
|
||||||
|
CUIRect View;
|
||||||
|
|
||||||
if(Type == CInfoOverlay::OVERLAY_HEADERINFO)
|
if(Type == CInfoOverlay::OVERLAY_HEADERINFO)
|
||||||
{
|
{
|
||||||
CBrowserFilter *pFilter = (CBrowserFilter*)m_InfoOverlay.m_pData;
|
CBrowserFilter *pFilter = (CBrowserFilter*)m_InfoOverlay.m_pData;
|
||||||
|
|
||||||
// get position
|
// get position
|
||||||
CUIRect View = { m_InfoOverlay.m_X-100.0f, m_InfoOverlay.m_Y, 100.0f, 30.0f };
|
View.x = m_InfoOverlay.m_X-100.0f;
|
||||||
|
View.y = m_InfoOverlay.m_Y;
|
||||||
|
View.w = 100.0f;
|
||||||
|
View.h = 30.0f;
|
||||||
|
|
||||||
// render background
|
// render background
|
||||||
RenderTools()->DrawUIRect(&View, vec4(0.25f, 0.25f, 0.25f, 1.0f), CUI::CORNER_ALL, 6.0f);
|
RenderTools()->DrawUIRect(&View, vec4(0.25f, 0.25f, 0.25f, 1.0f), CUI::CORNER_ALL, 6.0f);
|
||||||
|
@ -553,7 +564,10 @@ void CMenus::RenderServerbrowserOverlay()
|
||||||
const CServerInfo *pInfo = (CServerInfo*)m_InfoOverlay.m_pData;
|
const CServerInfo *pInfo = (CServerInfo*)m_InfoOverlay.m_pData;
|
||||||
|
|
||||||
// get position
|
// get position
|
||||||
CUIRect View = { m_InfoOverlay.m_X-210.0f, m_InfoOverlay.m_Y, 210.0f, pInfo->m_NumClients ? 98.0f + pInfo->m_NumClients*25.0f : 72.0f };
|
View.x = m_InfoOverlay.m_X-210.0f;
|
||||||
|
View.y = m_InfoOverlay.m_Y;
|
||||||
|
View.w = 210.0f;
|
||||||
|
View.h = pInfo->m_NumClients ? 98.0f + pInfo->m_NumClients*25.0f : 72.0f;
|
||||||
if(View.y+View.h >= 590.0f)
|
if(View.y+View.h >= 590.0f)
|
||||||
View.y -= View.y+View.h - 590.0f;
|
View.y -= View.y+View.h - 590.0f;
|
||||||
|
|
||||||
|
@ -575,7 +589,10 @@ void CMenus::RenderServerbrowserOverlay()
|
||||||
if(pInfo && pInfo->m_NumClients)
|
if(pInfo && pInfo->m_NumClients)
|
||||||
{
|
{
|
||||||
// get position
|
// get position
|
||||||
CUIRect View = { m_InfoOverlay.m_X+25.0f, m_InfoOverlay.m_Y, 250.0f, pInfo->m_NumClients*ButtonHeight };
|
View.x = m_InfoOverlay.m_X+25.0f;
|
||||||
|
View.y = m_InfoOverlay.m_Y;
|
||||||
|
View.w = 250.0f;
|
||||||
|
View.h = pInfo->m_NumClients*ButtonHeight;
|
||||||
if(View.x+View.w > Screen.w-5.0f)
|
if(View.x+View.w > Screen.w-5.0f)
|
||||||
{
|
{
|
||||||
View.y += 25.0f;
|
View.y += 25.0f;
|
||||||
|
@ -674,7 +691,10 @@ void CMenus::RenderServerbrowserOverlay()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CUIRect View = { m_InfoOverlay.m_X+25.0f, m_InfoOverlay.m_Y, 150.0f, ButtonHeight };
|
View.x = m_InfoOverlay.m_X+25.0f;
|
||||||
|
View.y = m_InfoOverlay.m_Y;
|
||||||
|
View.w = 150.0f;
|
||||||
|
View.h = ButtonHeight;
|
||||||
if(View.x+View.w > Screen.w-5.0f)
|
if(View.x+View.w > Screen.w-5.0f)
|
||||||
{
|
{
|
||||||
View.y += 25.0f;
|
View.y += 25.0f;
|
||||||
|
@ -695,7 +715,14 @@ void CMenus::RenderServerbrowserOverlay()
|
||||||
}
|
}
|
||||||
|
|
||||||
// deactivate it
|
// deactivate it
|
||||||
m_InfoOverlayActive = false;
|
vec2 OverlayCenter = vec2(View.x+View.w/2.0f, View.y+View.h/2.0f);
|
||||||
|
float MouseDistance = distance(m_MousePos, OverlayCenter);
|
||||||
|
float PrefMouseDistance = distance(m_PrevMousePos, OverlayCenter);
|
||||||
|
if(PrefMouseDistance > MouseDistance && !UI()->MouseInside(&View))
|
||||||
|
{
|
||||||
|
m_InfoOverlayActive = false;
|
||||||
|
m_InfoOverlay.m_Reset = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenus::RenderServerbrowserServerList(CUIRect View)
|
void CMenus::RenderServerbrowserServerList(CUIRect View)
|
||||||
|
|
Loading…
Reference in a new issue