DDraceNetwork Docs
tooltips.h
Go to the documentation of this file.
1#ifndef GAME_CLIENT_COMPONENTS_TOOLTIPS_H
2#define GAME_CLIENT_COMPONENTS_TOOLTIPS_H
3
6
7#include <cstdint>
8#include <functional>
9#include <optional>
10#include <unordered_map>
11
13{
14 const void *m_pId;
16 const char *m_pText;
18 bool m_OnScreen; // used to know if the tooltip should be rendered.
19};
20
26class CTooltips : public CComponent
27{
28 std::unordered_map<uintptr_t, CTooltip> m_Tooltips;
29 std::optional<std::reference_wrapper<CTooltip>> m_ActiveTooltip;
30 std::optional<std::reference_wrapper<CTooltip>> m_PreviousTooltip;
31 int64_t m_HoverTime;
32
36 void SetActiveTooltip(CTooltip &Tooltip);
37
38 inline void ClearActiveTooltip();
39
40public:
41 CTooltips();
42 virtual int Sizeof() const override { return sizeof(*this); }
43
55 void DoToolTip(const void *pId, const CUIRect *pNearRect, const char *pText, float WidthHint = -1.0f);
56
57 virtual void OnReset() override;
58 virtual void OnRender() override;
59};
60
61#endif
Definition: component.h:20
Definition: tooltips.h:27
std::optional< std::reference_wrapper< CTooltip > > m_ActiveTooltip
Definition: tooltips.h:29
void DoToolTip(const void *pId, const CUIRect *pNearRect, const char *pText, float WidthHint=-1.0f)
Definition: tooltips.cpp:29
std::unordered_map< uintptr_t, CTooltip > m_Tooltips
Definition: tooltips.h:28
virtual void OnReset() override
Definition: tooltips.cpp:11
std::optional< std::reference_wrapper< CTooltip > > m_PreviousTooltip
Definition: tooltips.h:30
virtual int Sizeof() const override
Definition: tooltips.h:42
CTooltips()
Definition: tooltips.cpp:6
int64_t m_HoverTime
Definition: tooltips.h:31
virtual void OnRender() override
Definition: tooltips.cpp:54
void ClearActiveTooltip()
Definition: tooltips.cpp:23
void SetActiveTooltip(CTooltip &Tooltip)
Definition: tooltips.cpp:18
Definition: ui_rect.h:11
Definition: tooltips.h:13
float m_WidthHint
Definition: tooltips.h:17
CUIRect m_Rect
Definition: tooltips.h:15
const char * m_pText
Definition: tooltips.h:16
bool m_OnScreen
Definition: tooltips.h:18
const void * m_pId
Definition: tooltips.h:14