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:
bors[bot] 2022-07-10 14:02:28 +00:00 committed by GitHub
commit bf7dc6c555
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 14 deletions

View file

@ -285,8 +285,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
r.Margin(0.5f, &r);
RenderTools()->DrawUIElRect(*pItem->m_pUIElement->Get(0), &r, ColorRGBA(1, 1, 1, 0.5f), CUI::CORNER_ALL, 4.0f);
}
if(!Selected && UI()->MouseHovered(&Row))
else if(UI()->MouseHovered(&Row))
{
CUIRect r = Row;
r.Margin(0.5f, &r);

View file

@ -9,7 +9,7 @@ CTooltips::CTooltips()
void CTooltips::OnReset()
{
HoverTime = -1;
m_HoverTime = -1;
m_Tooltips.clear();
}
@ -19,7 +19,7 @@ void CTooltips::SetActiveTooltip(CTooltip &Tooltip)
return;
m_ActiveTooltip.emplace(Tooltip);
HoverTime = time_get();
m_HoverTime = time_get();
}
inline void CTooltips::ClearActiveTooltip()
@ -68,7 +68,7 @@ void CTooltips::OnRender()
return;
// Delay tooltip until 1 second passed.
if(HoverTime > time_get() - time_freq())
if(m_HoverTime > time_get() - time_freq())
return;
const float MARGIN = 5.0f;

View file

@ -25,7 +25,7 @@ class CTooltips : public CComponent
{
std::unordered_map<uintptr_t, CTooltip> m_Tooltips;
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.