mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
changed the serverlisting info
This commit is contained in:
parent
bac0e5eb8a
commit
7630468806
@ -7,11 +7,12 @@ class ServerListing
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
std::string token;
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::string map;
|
||||||
|
std::string ip;
|
||||||
std::string version;
|
std::string version;
|
||||||
|
|
||||||
ServerListing(std::string token, std::string name, std::string version);
|
ServerListing(std::string name, std::string map, std::string ip, std::string version);
|
||||||
bool Select();
|
bool Select();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -480,8 +480,7 @@ public:
|
|||||||
memset(MatchmakingServerStringBuffer, 0, sizeof(MatchmakingServerStringBuffer));
|
memset(MatchmakingServerStringBuffer, 0, sizeof(MatchmakingServerStringBuffer));
|
||||||
memset(ServerNameBuffer, 0, sizeof(ServerNameBuffer));
|
memset(ServerNameBuffer, 0, sizeof(ServerNameBuffer));
|
||||||
memset(ServerConnStringBuffer, 0, sizeof(ServerConnStringBuffer));
|
memset(ServerConnStringBuffer, 0, sizeof(ServerConnStringBuffer));
|
||||||
|
|
||||||
strcpy_s(ServerConnStringBuffer, "localhost");
|
|
||||||
|
|
||||||
strcpy_s(MatchmakingServerStringBuffer, "localhost");
|
strcpy_s(MatchmakingServerStringBuffer, "localhost");
|
||||||
|
|
||||||
@ -511,9 +510,9 @@ public:
|
|||||||
json root = json::parse(res->body);
|
json root = json::parse(res->body);
|
||||||
for (auto obj : root["servers"])
|
for (auto obj : root["servers"])
|
||||||
{
|
{
|
||||||
ServerList.push_back(
|
//ServerList.push_back(
|
||||||
new ServerListing(obj["token"], obj["name"], obj["version"])
|
// new ServerListing(obj["token"], obj["name"], obj["version"])
|
||||||
);
|
//);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,7 +539,13 @@ public:
|
|||||||
}
|
}
|
||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string stringtolower(std::string source)
|
||||||
|
{
|
||||||
|
for (auto& ch : source)
|
||||||
|
ch = std::tolower(ch);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
void ServerBrowserSection()
|
void ServerBrowserSection()
|
||||||
{
|
{
|
||||||
@ -553,31 +558,47 @@ public:
|
|||||||
RefreshServerList();
|
RefreshServerList();
|
||||||
}
|
}
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
ImGui::BeginChild("ServerListChild", { 0, 780 }, false, ImGuiWindowFlags_HorizontalScrollbar);
|
ImGui::BeginChild("ServerListChild", { 0, 780 }, false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
|
|
||||||
ImGui::BeginTable("bumbumceau", 4);
|
ImGui::BeginTable("bumbumceau", 5);
|
||||||
|
|
||||||
ImGui::TableSetupColumn("Token", 0, 20);
|
ImGui::TableSetupColumn("Name", 0, 40);
|
||||||
ImGui::TableSetupColumn("Server Name", 0, 30);
|
ImGui::TableSetupColumn("IP Address", 0, 20);
|
||||||
ImGui::TableSetupColumn("Server Version", 0, 30);
|
ImGui::TableSetupColumn("Map", 0, 20);
|
||||||
ImGui::TableSetupColumn("Operations", 0, 5);
|
ImGui::TableSetupColumn("Version", 0, 10);
|
||||||
|
ImGui::TableSetupColumn("", 0, 10);
|
||||||
ImGui::TableHeadersRow();
|
ImGui::TableHeadersRow();
|
||||||
|
|
||||||
for (ServerListing* server : ServerList)
|
for (ServerListing* server : ServerList)
|
||||||
{
|
{
|
||||||
if (!strcmp(FilterBuffer, "") || strstr(server->token.c_str(), FilterBuffer) != NULL || strstr(server->name.c_str(), FilterBuffer) != NULL)
|
const char* name = stringtolower(server->name).c_str();
|
||||||
|
const char* ip = stringtolower(server->ip).c_str();
|
||||||
|
const char* map = stringtolower(server->map).c_str();
|
||||||
|
const char* version = stringtolower(server->version).c_str();
|
||||||
|
|
||||||
|
|
||||||
|
if (!strcmp(FilterBuffer, "")
|
||||||
|
|| strstr(name, FilterBuffer) != NULL
|
||||||
|
|| strstr(ip, FilterBuffer) != NULL
|
||||||
|
|| strstr(map, FilterBuffer) != NULL
|
||||||
|
|| strstr(version, FilterBuffer) != NULL)
|
||||||
{
|
{
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::Text(server->token.c_str());
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text(server->name.c_str());
|
ImGui::Text(server->name.c_str());
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
|
ImGui::Text(server->ip.c_str());
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
|
ImGui::Text(server->map.c_str());
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
ImGui::Text(server->version.c_str());
|
ImGui::Text(server->version.c_str());
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
std::string selectButtonText = "Select##";
|
std::string selectButtonText = "Connect##";
|
||||||
selectButtonText += server->token;
|
selectButtonText += (server->name + server->ip + server->map);
|
||||||
|
|
||||||
if (ImGui::Button(selectButtonText.c_str()))
|
if (ImGui::Button(selectButtonText.c_str()))
|
||||||
{
|
{
|
||||||
@ -592,7 +613,7 @@ public:
|
|||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::InputText("##ServerBrowser_ServerConnString", ServerConnStringBuffer, IM_ARRAYSIZE(ServerConnStringBuffer));
|
ImGui::InputTextWithHint("##ServerBrowser_ServerConnString", "Enter an ip address or \"localhost\"", ServerConnStringBuffer, IM_ARRAYSIZE(ServerConnStringBuffer));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Connect to the server", ImVec2(ImGui::GetWindowSize().x * (1.f / 3.f), 19)))
|
if (ImGui::Button("Connect to the server", ImVec2(ImGui::GetWindowSize().x * (1.f / 3.f), 19)))
|
||||||
{
|
{
|
||||||
|
@ -2,20 +2,17 @@
|
|||||||
#include "overlay.h"
|
#include "overlay.h"
|
||||||
#include "httplib.h"
|
#include "httplib.h"
|
||||||
|
|
||||||
ServerListing::ServerListing(std::string token, std::string name, std::string version)
|
ServerListing::ServerListing(std::string name, std::string map, std::string ip, std::string version)
|
||||||
{
|
{
|
||||||
this->token = token;
|
|
||||||
this->name = name;
|
this->name = name;
|
||||||
|
this->map = map;
|
||||||
this->version = version;
|
this->version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerListing::Select()
|
bool ServerListing::Select()
|
||||||
{
|
{
|
||||||
httplib::Client client("http://localhost:80");
|
std::stringstream cmd;
|
||||||
std::stringstream body;
|
cmd << "connect " << this->ip;
|
||||||
|
RunConsoleCommand(cmd.str().c_str());
|
||||||
body << "uid=" << OriginUID << "&servertoken=" << token;
|
|
||||||
client.Post("/browse/select", body.str(), "application/x-www-form-urlencoded");
|
|
||||||
std::cout << body.str() << "\n";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user