mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Server browser UX improvement
Auto focus token input field when private server modal is invoked or a token is submitted without success.
This commit is contained in:
parent
66f31916d1
commit
4116edfe4c
@ -45,6 +45,7 @@ CBrowser::CBrowser(void)
|
||||
, m_bActivate(false)
|
||||
, m_bInitialized(false)
|
||||
, m_bReclaimFocus(false)
|
||||
, m_bReclaimFocusTokenField(false)
|
||||
, m_bQueryListNonRecursive(false)
|
||||
, m_bQueryGlobalBanList(true)
|
||||
, m_flFadeAlpha(0.f)
|
||||
@ -176,8 +177,9 @@ void CBrowser::RunTask()
|
||||
}
|
||||
else // Refresh server list the next time 'm_bActivate' evaluates to true.
|
||||
{
|
||||
m_bQueryListNonRecursive = true;
|
||||
m_bReclaimFocus = true;
|
||||
m_bReclaimFocusTokenField = true;
|
||||
m_bQueryListNonRecursive = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,6 +410,12 @@ void CBrowser::HiddenServersModal(void)
|
||||
ImGui::InputTextWithHint("##HiddenServersConnectModal_TokenInput", "Token (required)", &m_svHiddenServerToken);
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
if (m_bReclaimFocusTokenField)
|
||||
{
|
||||
ImGui::SetKeyboardFocusHere(-1); // -1 means previous widget.
|
||||
m_bReclaimFocusTokenField = false;
|
||||
}
|
||||
|
||||
ImGui::Dummy(ImVec2(ImGui::GetWindowContentRegionWidth(), 19.f)); // Place a dummy, basically making space inserting a blank element.
|
||||
|
||||
ImGui::TextColored(m_ivHiddenServerMessageColor, m_svHiddenServerRequestMessage.c_str());
|
||||
@ -416,6 +424,8 @@ void CBrowser::HiddenServersModal(void)
|
||||
if (ImGui::Button("Connect", ImVec2(ImGui::GetWindowContentRegionWidth(), 24)))
|
||||
{
|
||||
m_svHiddenServerRequestMessage.clear();
|
||||
m_bReclaimFocusTokenField = true;
|
||||
|
||||
if (!m_svHiddenServerToken.empty())
|
||||
{
|
||||
NetGameServer_t server;
|
||||
@ -443,6 +453,8 @@ void CBrowser::HiddenServersModal(void)
|
||||
if (ImGui::Button("Close", ImVec2(ImGui::GetWindowContentRegionWidth(), 24)))
|
||||
{
|
||||
m_svHiddenServerRequestMessage.clear();
|
||||
m_bReclaimFocusTokenField = true;
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
@ -452,6 +464,8 @@ void CBrowser::HiddenServersModal(void)
|
||||
else if (!bModalOpen)
|
||||
{
|
||||
m_svHiddenServerRequestMessage.clear();
|
||||
m_bReclaimFocusTokenField = true;
|
||||
|
||||
ImGui::PopStyleVar(nVars);
|
||||
}
|
||||
else
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
private:
|
||||
bool m_bInitialized;
|
||||
bool m_bReclaimFocus;
|
||||
bool m_bReclaimFocusTokenField;
|
||||
bool m_bQueryListNonRecursive; // When set, refreshes the server list once the next frame.
|
||||
bool m_bQueryGlobalBanList;
|
||||
char m_szServerAddressBuffer[256];
|
||||
|
Loading…
x
Reference in New Issue
Block a user