mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 03:28:19 +00:00
Merge #6735
6735: Minor refactoring of `CUI` r=def- a=Robyt3 ## Checklist - [X] 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
3cb0160399
|
@ -112,11 +112,10 @@ CUI::CUI()
|
||||||
{
|
{
|
||||||
m_Enabled = true;
|
m_Enabled = true;
|
||||||
|
|
||||||
m_pHotItem = 0;
|
m_pHotItem = nullptr;
|
||||||
m_pActiveItem = 0;
|
m_pActiveItem = nullptr;
|
||||||
m_pLastActiveItem = 0;
|
m_pLastActiveItem = nullptr;
|
||||||
m_pBecomingHotItem = 0;
|
m_pBecomingHotItem = nullptr;
|
||||||
m_pActiveTooltipItem = 0;
|
|
||||||
|
|
||||||
m_MouseX = 0;
|
m_MouseX = 0;
|
||||||
m_MouseY = 0;
|
m_MouseY = 0;
|
||||||
|
@ -125,10 +124,8 @@ CUI::CUI()
|
||||||
m_MouseButtons = 0;
|
m_MouseButtons = 0;
|
||||||
m_LastMouseButtons = 0;
|
m_LastMouseButtons = 0;
|
||||||
|
|
||||||
m_Screen.x = 0;
|
m_Screen.x = 0.0f;
|
||||||
m_Screen.y = 0;
|
m_Screen.y = 0.0f;
|
||||||
m_Screen.w = 848.0f;
|
|
||||||
m_Screen.h = 480.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CUI::~CUI()
|
CUI::~CUI()
|
||||||
|
@ -226,7 +223,7 @@ void CUI::Update(float MouseX, float MouseY, float MouseDeltaX, float MouseDelta
|
||||||
m_pHotItem = m_pBecomingHotItem;
|
m_pHotItem = m_pBecomingHotItem;
|
||||||
if(m_pActiveItem)
|
if(m_pActiveItem)
|
||||||
m_pHotItem = m_pActiveItem;
|
m_pHotItem = m_pActiveItem;
|
||||||
m_pBecomingHotItem = 0;
|
m_pBecomingHotItem = nullptr;
|
||||||
|
|
||||||
if(Enabled())
|
if(Enabled())
|
||||||
{
|
{
|
||||||
|
@ -246,8 +243,8 @@ void CUI::DebugRender()
|
||||||
MapScreen();
|
MapScreen();
|
||||||
|
|
||||||
char aBuf[128];
|
char aBuf[128];
|
||||||
str_format(aBuf, sizeof(aBuf), "%p %p %p", HotItem(), ActiveItem(), LastActiveItem());
|
str_format(aBuf, sizeof(aBuf), "hot=%p nexthot=%p active=%p lastactive=%p", HotItem(), NextHotItem(), ActiveItem(), LastActiveItem());
|
||||||
TextRender()->Text(10.0f, 10.0f, 10.0f, aBuf);
|
TextRender()->Text(2.0f, Screen()->h - 12.0f, 10.0f, aBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUI::MouseInside(const CUIRect *pRect) const
|
bool CUI::MouseInside(const CUIRect *pRect) const
|
||||||
|
@ -338,15 +335,8 @@ float CUI::ButtonColorMul(const void *pID)
|
||||||
|
|
||||||
const CUIRect *CUI::Screen()
|
const CUIRect *CUI::Screen()
|
||||||
{
|
{
|
||||||
float Aspect = Graphics()->ScreenAspect();
|
m_Screen.h = 600.0f;
|
||||||
float w, h;
|
m_Screen.w = Graphics()->ScreenAspect() * m_Screen.h;
|
||||||
|
|
||||||
h = 600;
|
|
||||||
w = Aspect * h;
|
|
||||||
|
|
||||||
m_Screen.w = w;
|
|
||||||
m_Screen.h = h;
|
|
||||||
|
|
||||||
return &m_Screen;
|
return &m_Screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,7 +753,7 @@ bool CUI::DoEditBox(CLineInput *pLineInput, const CUIRect *pRect, float FontSize
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetActiveItem(0);
|
SetActiveItem(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(HotItem() == pLineInput)
|
else if(HotItem() == pLineInput)
|
||||||
|
|
|
@ -299,7 +299,6 @@ private:
|
||||||
const void *m_pActiveItem;
|
const void *m_pActiveItem;
|
||||||
const void *m_pLastActiveItem;
|
const void *m_pLastActiveItem;
|
||||||
const void *m_pBecomingHotItem;
|
const void *m_pBecomingHotItem;
|
||||||
const void *m_pActiveTooltipItem;
|
|
||||||
bool m_ActiveItemValid = false;
|
bool m_ActiveItemValid = false;
|
||||||
|
|
||||||
vec2 m_UpdatedMousePos = vec2(0.0f, 0.0f);
|
vec2 m_UpdatedMousePos = vec2(0.0f, 0.0f);
|
||||||
|
@ -439,12 +438,10 @@ public:
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void SetActiveTooltipItem(const void *pID) { m_pActiveTooltipItem = pID; }
|
|
||||||
void ClearLastActiveItem() { m_pLastActiveItem = nullptr; }
|
void ClearLastActiveItem() { m_pLastActiveItem = nullptr; }
|
||||||
const void *HotItem() const { return m_pHotItem; }
|
const void *HotItem() const { return m_pHotItem; }
|
||||||
const void *NextHotItem() const { return m_pBecomingHotItem; }
|
const void *NextHotItem() const { return m_pBecomingHotItem; }
|
||||||
const void *ActiveItem() const { return m_pActiveItem; }
|
const void *ActiveItem() const { return m_pActiveItem; }
|
||||||
const void *ActiveTooltipItem() const { return m_pActiveTooltipItem; }
|
|
||||||
const void *LastActiveItem() const { return m_pLastActiveItem; }
|
const void *LastActiveItem() const { return m_pLastActiveItem; }
|
||||||
|
|
||||||
void StartCheck() { m_ActiveItemValid = false; }
|
void StartCheck() { m_ActiveItemValid = false; }
|
||||||
|
|
Loading…
Reference in a new issue