From 8ea33946c41dda1fccffdcede11b1e4dffeadd4e Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 22 Aug 2019 21:08:01 -0400 Subject: [PATCH] proper discovery --- .../mindustry/ui/dialogs/JoinDialog.java | 32 +++++++++---------- .../mindustry/desktop/DesktopPlatform.java | 2 +- .../mindustry/desktop/steam/SteamNetImpl.java | 3 ++ 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java index 0ec2b8c8b2..221c8b4f12 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java @@ -158,8 +158,7 @@ public class JoinDialog extends FloatingDialog{ button.row(); - server.content = button.table(t -> { - }).grow().get(); + server.content = button.table(t -> {}).grow().get(); remote.row(); } @@ -183,6 +182,11 @@ public class JoinDialog extends FloatingDialog{ void setupServer(Server server, Host host){ server.lastHost = host; + server.content.clear(); + server.content.table(t -> setupHostTable(t, host)).expand().left().bottom().padLeft(12f).padBottom(8); + } + + void setupHostTable(Table content, Host host){ String versionString; if(host.version == -1){ @@ -199,15 +203,12 @@ public class JoinDialog extends FloatingDialog{ versionString = Core.bundle.format("server.version", host.version, host.versionType); } - server.content.clear(); + content.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true); + content.row(); + content.add("[lightgray]" + (host.players != 1 ? Core.bundle.format("players", host.players == 0 ? host.players : "[accent]" + host.players + "[lightgray]") : Core.bundle.format("players.single", "[accent]" + host.players + "[lightgray]"))).left(); + content.row(); + content.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + "[lightgray] / " + Core.bundle.format("save.wave", host.wave)).width(targetWidth() - 10f).left().get().setEllipsis(true); - server.content.table(t -> { - t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true); - t.row(); - t.add("[lightgray]" + (host.players != 1 ? Core.bundle.format("players", host.players == 0 ? host.players : "[accent]" + host.players + "[lightgray]") : Core.bundle.format("players.single", "[accent]" + host.players + "[lightgray]"))).left(); - t.row(); - t.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + "[lightgray] / " + Core.bundle.format("save.wave", host.wave)).width(targetWidth() - 10f).left().get().setEllipsis(true); - }).expand().left().bottom().padLeft(12f).padBottom(8); } void setup(){ @@ -299,12 +300,11 @@ public class JoinDialog extends FloatingDialog{ local.row(); - TextButton button = local.addButton("[accent]" + host.name, "clear", () -> connect(host.address, port)) - .width(w).height(80f).pad(4f).get(); - button.left(); - button.row(); - button.add("[lightgray]" + (host.players != 1 ? Core.bundle.format("players", host.players) : - Core.bundle.format("players.single", host.players))).padBottom(5); + local.addButton(b -> { + b.margin(5f); + b.left(); + setupHostTable(b, host); + }, "clear", () -> connect(host.address, port)).width(w).pad(4f).get(); } void connect(String ip, int port){ diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java index 9ba2b3e6d4..8c286df8ba 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java @@ -27,7 +27,7 @@ import static io.anuke.mindustry.Vars.*; public class DesktopPlatform extends Platform{ - static boolean useDiscord = OS.is64Bit, useSteam = true, showConsole = false; + static boolean useDiscord = OS.is64Bit, useSteam = true, showConsole = true; final static String applicationId = "610508934456934412"; String[] args; diff --git a/desktop/src/io/anuke/mindustry/desktop/steam/SteamNetImpl.java b/desktop/src/io/anuke/mindustry/desktop/steam/SteamNetImpl.java index 3e45a2dbf5..673ba2df49 100644 --- a/desktop/src/io/anuke/mindustry/desktop/steam/SteamNetImpl.java +++ b/desktop/src/io/anuke/mindustry/desktop/steam/SteamNetImpl.java @@ -142,6 +142,7 @@ public class SteamNetImpl implements SteamNetworkingCallback, SteamMatchmakingCa @Override public void discover(Consumer callback, Runnable done){ + smat.addRequestLobbyListResultCountFilter(32); smat.requestLobbyList(); lobbyCallback = callback; lobbyDoneCallback = done; @@ -275,6 +276,8 @@ public class SteamNetImpl implements SteamNetworkingCallback, SteamMatchmakingCa @Override public void onLobbyMatchList(int matches){ + Log.info("found {0} matches", matches); + if(lobbyDoneCallback != null){ for(int i = 0; i < matches; i++){ SteamID lobby = smat.getLobbyByIndex(i);