mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Remove usages of CUI::LastActiveItem
Use `CLineInput::GetActiveInput` and `CLineInput::IsActive` instead for consistency. The last active item pointer is now only tracked internally in `CUI` to deactivate the active line input when it's no longer used in the UI.
This commit is contained in:
parent
ce96dfc256
commit
47f4f21266
|
@ -243,7 +243,7 @@ void CUI::DebugRender()
|
|||
MapScreen();
|
||||
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "hot=%p nexthot=%p active=%p lastactive=%p", HotItem(), NextHotItem(), ActiveItem(), LastActiveItem());
|
||||
str_format(aBuf, sizeof(aBuf), "hot=%p nexthot=%p active=%p lastactive=%p", HotItem(), NextHotItem(), ActiveItem(), m_pLastActiveItem);
|
||||
TextRender()->Text(2.0f, Screen()->h - 12.0f, 10.0f, aBuf);
|
||||
}
|
||||
|
||||
|
@ -749,7 +749,7 @@ void CUI::DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRe
|
|||
bool CUI::DoEditBox(CLineInput *pLineInput, const CUIRect *pRect, float FontSize, int Corners)
|
||||
{
|
||||
const bool Inside = MouseHovered(pRect);
|
||||
const bool Active = LastActiveItem() == pLineInput;
|
||||
const bool Active = m_pLastActiveItem == pLineInput;
|
||||
const bool Changed = pLineInput->WasChanged();
|
||||
|
||||
const float VSpacing = 2.0f;
|
||||
|
|
|
@ -298,7 +298,7 @@ private:
|
|||
|
||||
const void *m_pHotItem;
|
||||
const void *m_pActiveItem;
|
||||
const void *m_pLastActiveItem;
|
||||
const void *m_pLastActiveItem; // only used internally to track active CLineInput
|
||||
const void *m_pBecomingHotItem;
|
||||
bool m_ActiveItemValid = false;
|
||||
|
||||
|
@ -439,11 +439,9 @@ public:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
void ClearLastActiveItem() { m_pLastActiveItem = nullptr; }
|
||||
const void *HotItem() const { return m_pHotItem; }
|
||||
const void *NextHotItem() const { return m_pBecomingHotItem; }
|
||||
const void *ActiveItem() const { return m_pActiveItem; }
|
||||
const void *LastActiveItem() const { return m_pLastActiveItem; }
|
||||
|
||||
void StartCheck() { m_ActiveItemValid = false; }
|
||||
void FinishCheck()
|
||||
|
|
|
@ -6258,7 +6258,7 @@ void CEditor::RenderServerSettingsEditor(CUIRect View, bool ShowServerSettingsEd
|
|||
// buttons
|
||||
ToolBar.VSplitRight(50.0f, &ToolBar, &Button);
|
||||
static int s_AddButton = 0;
|
||||
if(DoButton_Editor(&s_AddButton, "Add", 0, &Button, 0, "Add a command to command list.") || ((Input()->KeyPress(KEY_RETURN) || Input()->KeyPress(KEY_KP_ENTER)) && UI()->LastActiveItem() == &m_SettingsCommandInput && m_Dialog == DIALOG_NONE))
|
||||
if(DoButton_Editor(&s_AddButton, "Add", 0, &Button, 0, "Add a command to command list.") || ((Input()->KeyPress(KEY_RETURN) || Input()->KeyPress(KEY_KP_ENTER)) && m_SettingsCommandInput.IsActive() && m_Dialog == DIALOG_NONE))
|
||||
{
|
||||
if(!m_SettingsCommandInput.IsEmpty() && str_find(m_SettingsCommandInput.GetString(), " "))
|
||||
{
|
||||
|
@ -6287,7 +6287,7 @@ void CEditor::RenderServerSettingsEditor(CUIRect View, bool ShowServerSettingsEd
|
|||
ToolBar.VSplitRight(50.0f, &ToolBar, &Button);
|
||||
Button.VSplitRight(5.0f, &Button, nullptr);
|
||||
static int s_ModButton = 0;
|
||||
if(DoButton_Editor(&s_ModButton, "Mod", 0, &Button, 0, "Modify a command from the command list.") || (Input()->KeyPress(KEY_M) && UI()->LastActiveItem() != &m_SettingsCommandInput && m_Dialog == DIALOG_NONE))
|
||||
if(DoButton_Editor(&s_ModButton, "Mod", 0, &Button, 0, "Modify a command from the command list.") || (Input()->KeyPress(KEY_M) && CLineInput::GetActiveInput() == nullptr && m_Dialog == DIALOG_NONE))
|
||||
{
|
||||
if(!m_SettingsCommandInput.IsEmpty() && str_comp(m_Map.m_vSettings[s_CommandSelectedIndex].m_aCommand, m_SettingsCommandInput.GetString()) != 0 && str_find(m_SettingsCommandInput.GetString(), " "))
|
||||
{
|
||||
|
@ -6316,7 +6316,7 @@ void CEditor::RenderServerSettingsEditor(CUIRect View, bool ShowServerSettingsEd
|
|||
ToolBar.VSplitRight(50.0f, &ToolBar, &Button);
|
||||
Button.VSplitRight(5.0f, &Button, nullptr);
|
||||
static int s_DelButton = 0;
|
||||
if(DoButton_Editor(&s_DelButton, "Del", 0, &Button, 0, "Delete a command from the command list.") || (Input()->KeyPress(KEY_DELETE) && UI()->LastActiveItem() != &m_SettingsCommandInput && m_Dialog == DIALOG_NONE))
|
||||
if(DoButton_Editor(&s_DelButton, "Del", 0, &Button, 0, "Delete a command from the command list.") || (Input()->KeyPress(KEY_DELETE) && CLineInput::GetActiveInput() == nullptr && m_Dialog == DIALOG_NONE))
|
||||
{
|
||||
m_Map.m_vSettings.erase(m_Map.m_vSettings.begin() + s_CommandSelectedIndex);
|
||||
if(s_CommandSelectedIndex >= (int)m_Map.m_vSettings.size())
|
||||
|
|
Loading…
Reference in a new issue