Show tooltip when the server version is incompatible
This commit is contained in:
+23
-6
@@ -197,6 +197,7 @@ scenes::lobby::lobby()
|
||||
.autoconnect = i["autoconnect"].get_bool(),
|
||||
.manual = i["manual"].get_bool(),
|
||||
.visible = false,
|
||||
.compatible = true,
|
||||
.service = {
|
||||
.name = (std::string)i["pretty_name"],
|
||||
.hostname = (std::string)i["hostname"],
|
||||
@@ -411,15 +412,30 @@ void scenes::lobby::update_server_list()
|
||||
data.visible = false;
|
||||
}
|
||||
|
||||
char protocol_string[17];
|
||||
sprintf(protocol_string, "%016lx", xrt::drivers::wivrn::protocol_version);
|
||||
|
||||
for(auto& service: discovered_services)
|
||||
{
|
||||
if (service.txt.find("cookie") == service.txt.end())
|
||||
{
|
||||
spdlog::info("Ignored {} because there is no cookie field", service.name);
|
||||
continue;
|
||||
}
|
||||
std::string cookie;
|
||||
bool compatible = true;
|
||||
|
||||
auto it = service.txt.find("cookie");
|
||||
if (it == service.txt.end())
|
||||
{
|
||||
cookie = service.hostname;
|
||||
compatible = false;
|
||||
}
|
||||
else
|
||||
cookie = it->second;
|
||||
|
||||
auto protocol = service.txt.find("protocol");
|
||||
if (protocol == service.txt.end())
|
||||
compatible = false;
|
||||
|
||||
if (protocol->second != protocol_string)
|
||||
compatible = false;
|
||||
|
||||
auto cookie = service.txt.at("cookie");
|
||||
auto server = servers.find(cookie);
|
||||
if (server == servers.end())
|
||||
{
|
||||
@@ -428,6 +444,7 @@ void scenes::lobby::update_server_list()
|
||||
.autoconnect = false,
|
||||
.manual = false,
|
||||
.visible = true,
|
||||
.compatible = compatible,
|
||||
.service = service
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ class lobby : public scene_impl<lobby>
|
||||
bool autoconnect;
|
||||
bool manual;
|
||||
bool visible;
|
||||
bool compatible;
|
||||
|
||||
wivrn_discover::service service;
|
||||
};
|
||||
|
||||
@@ -245,7 +245,7 @@ void scenes::lobby::gui_server_list()
|
||||
button_position.x -= button_size.x + style.WindowPadding.x;
|
||||
ImGui::SetCursorPos(button_position);
|
||||
|
||||
bool enable_connect_button = data.visible || data.manual;
|
||||
bool enable_connect_button = (data.visible || data.manual) && data.compatible;
|
||||
ImGui::BeginDisabled(!enable_connect_button);
|
||||
if (enable_connect_button)
|
||||
{
|
||||
@@ -266,6 +266,12 @@ void scenes::lobby::gui_server_list()
|
||||
}
|
||||
vibrate_on_hover();
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
if (!data.compatible)
|
||||
ImGui::SetTooltip("Incompatible server version");
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
ImGui::EndDisabled();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user