mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
Merge #5608
5608: Minor client refactorings r=heinrich5991 a=Robyt3 <!-- What is the motivation for the changes of this pull request --> ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
bf7dc6c555
|
@ -285,8 +285,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
||||||
r.Margin(0.5f, &r);
|
r.Margin(0.5f, &r);
|
||||||
RenderTools()->DrawUIElRect(*pItem->m_pUIElement->Get(0), &r, ColorRGBA(1, 1, 1, 0.5f), CUI::CORNER_ALL, 4.0f);
|
RenderTools()->DrawUIElRect(*pItem->m_pUIElement->Get(0), &r, ColorRGBA(1, 1, 1, 0.5f), CUI::CORNER_ALL, 4.0f);
|
||||||
}
|
}
|
||||||
|
else if(UI()->MouseHovered(&Row))
|
||||||
if(!Selected && UI()->MouseHovered(&Row))
|
|
||||||
{
|
{
|
||||||
CUIRect r = Row;
|
CUIRect r = Row;
|
||||||
r.Margin(0.5f, &r);
|
r.Margin(0.5f, &r);
|
||||||
|
|
|
@ -9,7 +9,7 @@ CTooltips::CTooltips()
|
||||||
|
|
||||||
void CTooltips::OnReset()
|
void CTooltips::OnReset()
|
||||||
{
|
{
|
||||||
HoverTime = -1;
|
m_HoverTime = -1;
|
||||||
m_Tooltips.clear();
|
m_Tooltips.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ void CTooltips::SetActiveTooltip(CTooltip &Tooltip)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ActiveTooltip.emplace(Tooltip);
|
m_ActiveTooltip.emplace(Tooltip);
|
||||||
HoverTime = time_get();
|
m_HoverTime = time_get();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CTooltips::ClearActiveTooltip()
|
inline void CTooltips::ClearActiveTooltip()
|
||||||
|
@ -68,7 +68,7 @@ void CTooltips::OnRender()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Delay tooltip until 1 second passed.
|
// Delay tooltip until 1 second passed.
|
||||||
if(HoverTime > time_get() - time_freq())
|
if(m_HoverTime > time_get() - time_freq())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const float MARGIN = 5.0f;
|
const float MARGIN = 5.0f;
|
||||||
|
|
|
@ -18,20 +18,20 @@ struct CTooltip
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A component that manages and renders UI tooltips.
|
* A component that manages and renders UI tooltips.
|
||||||
*
|
*
|
||||||
* Should be among the last components to render.
|
* Should be among the last components to render.
|
||||||
*/
|
*/
|
||||||
class CTooltips : public CComponent
|
class CTooltips : public CComponent
|
||||||
{
|
{
|
||||||
std::unordered_map<uintptr_t, CTooltip> m_Tooltips;
|
std::unordered_map<uintptr_t, CTooltip> m_Tooltips;
|
||||||
std::optional<std::reference_wrapper<CTooltip>> m_ActiveTooltip;
|
std::optional<std::reference_wrapper<CTooltip>> m_ActiveTooltip;
|
||||||
int64_t HoverTime;
|
int64_t m_HoverTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The passed tooltip is only actually set if there is no currently active tooltip.
|
* The passed tooltip is only actually set if there is no currently active tooltip.
|
||||||
*
|
*
|
||||||
* @param Tooltip A reference to the tooltip that should be active.
|
* @param Tooltip A reference to the tooltip that should be active.
|
||||||
*/
|
*/
|
||||||
void SetActiveTooltip(CTooltip &Tooltip);
|
void SetActiveTooltip(CTooltip &Tooltip);
|
||||||
|
|
||||||
inline void ClearActiveTooltip();
|
inline void ClearActiveTooltip();
|
||||||
|
@ -42,9 +42,9 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the tooltip to a cache and renders it when active.
|
* Adds the tooltip to a cache and renders it when active.
|
||||||
*
|
*
|
||||||
* On the first call to this function, the data passed is cached, afterwards the calls are used to detect if the tooltip should be activated.
|
* On the first call to this function, the data passed is cached, afterwards the calls are used to detect if the tooltip should be activated.
|
||||||
*
|
*
|
||||||
* For now only works correctly with single line tooltips, since Text width calculation gets broken when there are multiple lines.
|
* For now only works correctly with single line tooltips, since Text width calculation gets broken when there are multiple lines.
|
||||||
*
|
*
|
||||||
* @param pID The ID of the tooltip. Usually a reference to some g_Config value.
|
* @param pID The ID of the tooltip. Usually a reference to some g_Config value.
|
||||||
|
|
Loading…
Reference in a new issue