mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
ImGui: clip server listings if they exceed rect
Use ImGuiListClipper to clip anything not visible.
This commit is contained in:
parent
fda018785e
commit
56feb56998
@ -257,44 +257,56 @@ void CBrowser::DrawBrowserPanel(void)
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
g_ServerListManager.m_Mutex.lock();
|
||||
for (const NetGameServer_t& server : g_ServerListManager.m_vServerList)
|
||||
|
||||
const int numServerItems = (int)g_ServerListManager.m_vServerList.size();
|
||||
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin(numServerItems);
|
||||
|
||||
while (clipper.Step())
|
||||
{
|
||||
const char* pszHostName = server.name.c_str();
|
||||
const char* pszHostMap = server.map.c_str();
|
||||
const char* pszPlaylist = server.playlist.c_str();
|
||||
|
||||
char pszHostPort[32];
|
||||
sprintf(pszHostPort, "%d", server.port);
|
||||
|
||||
if (m_serverBrowserTextFilter.PassFilter(pszHostName)
|
||||
|| m_serverBrowserTextFilter.PassFilter(pszHostMap)
|
||||
|| m_serverBrowserTextFilter.PassFilter(pszHostPort))
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", pszHostName);
|
||||
const NetGameServer_t& server = g_ServerListManager.m_vServerList[i];
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", pszHostMap);
|
||||
const char* pszHostName = server.name.c_str();
|
||||
const char* pszHostMap = server.map.c_str();
|
||||
const char* pszPlaylist = server.playlist.c_str();
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", pszPlaylist);
|
||||
char pszHostPort[32];
|
||||
sprintf(pszHostPort, "%d", server.port);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", Format("%3d/%3d", server.numPlayers, server.maxPlayers).c_str());
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", pszHostPort);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
string svConnectBtn = "Connect##";
|
||||
svConnectBtn.append(server.name + server.address + server.map);
|
||||
|
||||
if (ImGui::Button(svConnectBtn.c_str()))
|
||||
if (m_serverBrowserTextFilter.PassFilter(pszHostName)
|
||||
|| m_serverBrowserTextFilter.PassFilter(pszHostMap)
|
||||
|| m_serverBrowserTextFilter.PassFilter(pszHostPort))
|
||||
{
|
||||
g_ServerListManager.ConnectToServer(server.address, server.port, server.netKey);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", pszHostName);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", pszHostMap);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", pszPlaylist);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", Format("%3d/%3d", server.numPlayers, server.maxPlayers).c_str());
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", pszHostPort);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
string svConnectBtn = "Connect##";
|
||||
svConnectBtn.append(server.name + server.address + server.map);
|
||||
|
||||
if (ImGui::Button(svConnectBtn.c_str()))
|
||||
{
|
||||
g_ServerListManager.ConnectToServer(server.address, server.port, server.netKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_ServerListManager.m_Mutex.unlock();
|
||||
|
||||
ImGui::EndTable();
|
||||
|
Loading…
x
Reference in New Issue
Block a user