Merge pull request #9003 from Robyt3/Editor-Prompt-Fix

Fix some editor quick actions not being clickable, small refactoring
This commit is contained in:
Dennis Felsing 2024-09-20 09:58:46 +00:00 committed by GitHub
commit 034e4971f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 11 deletions

View file

@ -112,11 +112,7 @@ void CPrompt::OnRender(CUIRect _)
if(m_PromptInput.IsEmpty() || FuzzyMatch(pQuickAction->Label(), m_PromptInput.GetString()))
{
bool Skip = false;
if(m_ResetFilterResults)
if(pQuickAction == m_pLastAction)
Skip = true;
if(!Skip)
if(!m_ResetFilterResults || pQuickAction != m_pLastAction)
m_vpFilteredPromptList.push_back(pQuickAction);
}
}
@ -130,15 +126,15 @@ void CPrompt::OnRender(CUIRect _)
for(size_t i = 0; i < m_vpFilteredPromptList.size(); i++)
{
const CListboxItem Item = s_ListBox.DoNextItem(m_vpFilteredPromptList[i], m_PromptSelectedIndex >= 0 && (size_t)m_PromptSelectedIndex == i);
const CListboxItem Item = s_ListBox.DoNextItem(m_vpFilteredPromptList[i]->ActionButtonId(), m_PromptSelectedIndex >= 0 && (size_t)m_PromptSelectedIndex == i);
if(!Item.m_Visible)
continue;
CUIRect LabelColumn, DescColumn;
float Margin = 5.0f;
Item.m_Rect.VSplitLeft(Margin, nullptr, &LabelColumn);
Item.m_Rect.VMargin(Margin, &LabelColumn);
LabelColumn.VSplitLeft(LabelWidth, &LabelColumn, &DescColumn);
DescColumn.VSplitRight(Margin, &DescColumn, nullptr);
DescColumn.VSplitLeft(Margin, nullptr, &DescColumn);
SLabelProperties Props;
Props.m_MaxWidth = LabelColumn.w;
@ -146,9 +142,7 @@ void CPrompt::OnRender(CUIRect _)
Ui()->DoLabel(&LabelColumn, m_vpFilteredPromptList[i]->Label(), 10.0f, TEXTALIGN_ML, Props);
Props.m_MaxWidth = DescColumn.w;
ColorRGBA DescColor = TextRender()->DefaultTextColor();
DescColor.a = Item.m_Selected ? 1.0f : 0.8f;
TextRender()->TextColor(DescColor);
TextRender()->TextColor(TextRender()->DefaultTextColor().WithAlpha(Item.m_Selected ? 1.0f : 0.8f));
Ui()->DoLabel(&DescColumn, m_vpFilteredPromptList[i]->Description(), 10.0f, TEXTALIGN_MR, Props);
TextRender()->TextColor(TextRender()->DefaultTextColor());
}

View file

@ -20,6 +20,8 @@ private:
FButtonActiveCallback m_pfnActiveCallback;
FButtonColorCallback m_pfnColorCallback;
const char m_ActionButtonId = 0;
public:
CQuickAction(
const char *pLabel,
@ -64,6 +66,8 @@ public:
}
const char *Description() const { return m_pDescription; }
const void *ActionButtonId() const { return &m_ActionButtonId; }
};
#endif