From 30021839c74bbe4d331a4b3ee047f282b5a85f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Fri, 20 Sep 2024 10:37:50 +0200 Subject: [PATCH 1/3] Fix some editor quick actions not being clickable Add separate UI element IDs for the quick action buttons in the prompt dialog, to ensure that the UI element IDs are different from the IDs used for the regular menu buttons. Otherwise, some buttons could not be activated with clicks because the menu button with the same ID was rendered first. Closes #8998. --- src/game/editor/prompt.cpp | 2 +- src/game/editor/quick_action.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/game/editor/prompt.cpp b/src/game/editor/prompt.cpp index 64392182b..7e7a1a1ea 100644 --- a/src/game/editor/prompt.cpp +++ b/src/game/editor/prompt.cpp @@ -130,7 +130,7 @@ 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; diff --git a/src/game/editor/quick_action.h b/src/game/editor/quick_action.h index 124713643..b6bb68634 100644 --- a/src/game/editor/quick_action.h +++ b/src/game/editor/quick_action.h @@ -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 From 9597241a4ab7838175385a7ba83a6976b14c99e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Fri, 20 Sep 2024 10:44:42 +0200 Subject: [PATCH 2/3] Add margin between quick action label and description Add a small margin between the label and the description, to make sure there is some spacing if both labels had the maximum length. --- src/game/editor/prompt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/editor/prompt.cpp b/src/game/editor/prompt.cpp index 7e7a1a1ea..8dc12ef53 100644 --- a/src/game/editor/prompt.cpp +++ b/src/game/editor/prompt.cpp @@ -136,9 +136,9 @@ void CPrompt::OnRender(CUIRect _) 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; From 7b641526f9c3a66aae6decfe14e02cb5ddf9bbbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Fri, 20 Sep 2024 10:45:14 +0200 Subject: [PATCH 3/3] Remove unnecessary `Skip` and `DescColor` variables --- src/game/editor/prompt.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/game/editor/prompt.cpp b/src/game/editor/prompt.cpp index 8dc12ef53..822651e00 100644 --- a/src/game/editor/prompt.cpp +++ b/src/game/editor/prompt.cpp @@ -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); } } @@ -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()); }