mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Fix console autocomplete window not padding elements correctly when size is between the clamped values
This commit is contained in:
parent
1f41f3c9d0
commit
eca922d3df
@ -263,15 +263,7 @@ void CConsole::DrawSurface(void)
|
||||
m_bReclaimFocus = false;
|
||||
}
|
||||
|
||||
float nPad = 0.f;
|
||||
if (m_vSuggest.size() > 1)
|
||||
{
|
||||
// Pad with 18 to keep all items in view.
|
||||
nPad = ImGui::GetItemRectSize().y - 3;
|
||||
}
|
||||
m_ivSuggestWindowPos = ImGui::GetItemRectMin();
|
||||
m_ivSuggestWindowPos.y += ImGui::GetItemRectSize().y;
|
||||
m_ivSuggestWindowSize = ImVec2(600, nPad + std::clamp(static_cast<float>(m_vSuggest.size()) * fontSize.y, 37.0f, 127.5f));
|
||||
BuildSuggestPanelRect();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Submit"))
|
||||
@ -611,6 +603,27 @@ void CConsole::BuildSummary(string svConVar)
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: builds the suggestion panel rect
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::BuildSuggestPanelRect(void)
|
||||
{
|
||||
float flSinglePadding = 0.f;
|
||||
float flItemHeight = ImGui::GetTextLineHeightWithSpacing() + 1.0f;
|
||||
|
||||
if (m_vSuggest.size() > 1)
|
||||
{
|
||||
// Pad with 18 to keep all items in view.
|
||||
flSinglePadding = flItemHeight;
|
||||
}
|
||||
|
||||
m_ivSuggestWindowPos = ImGui::GetItemRectMin();
|
||||
m_ivSuggestWindowPos.y += ImGui::GetItemRectSize().y;
|
||||
|
||||
float flWindowHeight = flSinglePadding + std::clamp(static_cast<float>(m_vSuggest.size()) * (flItemHeight), 37.0f, 127.5f);
|
||||
m_ivSuggestWindowSize = ImVec2(600, flWindowHeight);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: clamps the size of the log vector
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -31,7 +31,9 @@ private:
|
||||
|
||||
void FindFromPartial(void);
|
||||
void ProcessCommand(const char* pszCommand);
|
||||
|
||||
void BuildSummary(string svConVar = "");
|
||||
void BuildSuggestPanelRect(void);
|
||||
|
||||
void ClampLogSize(void);
|
||||
void ClampHistorySize(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user