From e4bef567b5c03d871c68c885ef38cf2ac593732c Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 25 Mar 2023 12:42:29 -0400 Subject: [PATCH] Fixed Steam public lobby hosting / Misc Steam bugfixes --- core/assets/bundles/bundle.properties | 4 +-- core/src/mindustry/core/UI.java | 18 ++++++++++ core/src/mindustry/ui/dialogs/HostDialog.java | 34 +++++++++---------- .../mindustry/ui/dialogs/PausedDialog.java | 6 +--- .../ui/dialogs/SettingsMenuDialog.java | 19 ++--------- desktop/src/mindustry/desktop/steam/SNet.java | 4 +-- 6 files changed, 41 insertions(+), 44 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 8593290357..82703a709d 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1107,8 +1107,8 @@ setting.bridgeopacity.name = Bridge Opacity setting.playerchat.name = Display Player Bubble Chat setting.showweather.name = Show Weather Graphics setting.hidedisplays.name = Hide Logic Displays -public.confirm = Do you want to make your game public?\n[accent]Anyone will be able to join your games.\n[lightgray]This can be changed later in Settings->Game->Public Game Visibility. -public.confirm.really = If you want to play with friends, use [green]Invite Friend[] instead of a [scarlet]Public server[]!\nAre you sure you want to make your game [scarlet]public[]? +steam.friendsonly = Friends Only +steam.friendsonly.tooltip = Whether only Steam friends will be able to join your game.\nUnchecking this box will make your game public - anyone can join. public.beta = Note that beta versions of the game cannot make public lobbies. uiscale.reset = UI scale has been changed.\nPress "OK" to confirm this scale.\n[scarlet]Reverting and exiting in[accent] {0}[] seconds... uiscale.cancel = Cancel & Exit diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index c1c9c97b5f..a4650d16a7 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -322,6 +322,24 @@ public class UI implements ApplicationListener, Loadable{ Core.scene.add(table); } + public void addDescTooltip(Element elem, String description){ + if(description == null) return; + + elem.addListener(new Tooltip(t -> t.background(Styles.black8).margin(4f).add(description).color(Color.lightGray)){ + { + allowMobile = true; + } + @Override + protected void setContainerPosition(Element element, float x, float y){ + this.targetActor = element; + Vec2 pos = element.localToStageCoordinates(Tmp.v1.set(0, 0)); + container.pack(); + container.setPosition(pos.x, pos.y, Align.topLeft); + container.setOrigin(0, element.getHeight()); + } + }); + } + /** Shows a fading label at the top of the screen. */ public void showInfoToast(String info, float duration){ var cinfo = Core.scene.find("coreinfo"); diff --git a/core/src/mindustry/ui/dialogs/HostDialog.java b/core/src/mindustry/ui/dialogs/HostDialog.java index f0d3dc867d..6abba5784e 100644 --- a/core/src/mindustry/ui/dialogs/HostDialog.java +++ b/core/src/mindustry/ui/dialogs/HostDialog.java @@ -38,6 +38,15 @@ public class HostDialog extends BaseDialog{ button.update(() -> button.getStyle().imageUpColor = player.color()); }).width(w).height(70f).pad(4).colspan(3); + if(steam){ + cont.row(); + + cont.add().width(65f); + + cont.check("@steam.friendsonly", !Core.settings.getBool("steampublichost"), val -> Core.settings.put("steampublichost", !val)).colspan(2).left() + .with(c -> ui.addDescTooltip(c, "@steam.friendsonly.tooltip")).padBottom(15f).row(); + } + cont.row(); cont.add().width(65f); @@ -51,7 +60,11 @@ public class HostDialog extends BaseDialog{ runHost(); }).width(w).height(70f); - cont.button("?", () -> ui.showInfo("@host.info")).size(65f, 70f).padLeft(6f); + if(!steam){ + cont.button("?", () -> ui.showInfo("@host.info")).size(65f, 70f).padLeft(6f); + }else{ + cont.add().size(65f, 70f).padLeft(6f); + } shown(() -> { if(!steam){ @@ -68,24 +81,9 @@ public class HostDialog extends BaseDialog{ player.admin = true; Events.fire(new HostEvent()); - if(steam){ - Core.app.post(() -> Core.settings.getBoolOnce("steampublic3", () -> { - ui.showCustomConfirm("@setting.publichost.name", "@public.confirm", "@yes", "@no", () -> { - ui.showCustomConfirm("@setting.publichost.name", "@public.confirm.really", "@no", "@yes", () -> { - Core.settings.put("publichost", true); - platform.updateLobby(); - }, () -> { - Core.settings.put("publichost", false); - platform.updateLobby(); - }); - }, () -> { - Core.settings.put("publichost", false); - platform.updateLobby(); - }); - })); - + if(steam && Core.settings.getBool("steampublichost")){ if(Version.modifier.contains("beta") || Version.modifier.contains("alpha")){ - Core.settings.put("publichost", false); + Core.settings.put("steampublichost", false); platform.updateLobby(); Core.settings.getBoolOnce("betapublic", () -> ui.showInfo("@public.beta")); } diff --git a/core/src/mindustry/ui/dialogs/PausedDialog.java b/core/src/mindustry/ui/dialogs/PausedDialog.java index c68eb89c76..129e64d658 100644 --- a/core/src/mindustry/ui/dialogs/PausedDialog.java +++ b/core/src/mindustry/ui/dialogs/PausedDialog.java @@ -53,11 +53,7 @@ public class PausedDialog extends BaseDialog{ if(net.server() && steam){ platform.inviteFriends(); }else{ - if(steam){ - ui.host.runHost(); - }else{ - ui.host.show(); - } + ui.host.show(); } }).disabled(b -> !((steam && net.server()) || !net.active())).colspan(2).width(dw * 2 + 10f).update(e -> e.setText(net.server() && steam ? "@invitefriends" : "@hostserver")); diff --git a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java index 01884eb01a..78bdd96d83 100644 --- a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -6,7 +6,6 @@ import arc.func.*; import arc.graphics.*; import arc.graphics.Texture.*; import arc.input.*; -import arc.math.geom.*; import arc.scene.*; import arc.scene.event.*; import arc.scene.style.*; @@ -356,7 +355,7 @@ public class SettingsMenuDialog extends BaseDialog{ }); if(!Version.modifier.contains("beta")){ - game.checkPref("publichost", false, i -> { + game.checkPref("steampublichost", false, i -> { platform.updateLobby(); }); } @@ -707,21 +706,7 @@ public class SettingsMenuDialog extends BaseDialog{ public abstract void add(SettingsTable table); public void addDesc(Element elem){ - if(description == null) return; - - elem.addListener(new Tooltip(t -> t.background(Styles.black8).margin(4f).add(description).color(Color.lightGray)){ - { - allowMobile = true; - } - @Override - protected void setContainerPosition(Element element, float x, float y){ - this.targetActor = element; - Vec2 pos = element.localToStageCoordinates(Tmp.v1.set(0, 0)); - container.pack(); - container.setPosition(pos.x, pos.y, Align.topLeft); - container.setOrigin(0, element.getHeight()); - } - }); + ui.addDescTooltip(elem, description); } } diff --git a/desktop/src/mindustry/desktop/steam/SNet.java b/desktop/src/mindustry/desktop/steam/SNet.java index d42c542265..0d6a760dc3 100644 --- a/desktop/src/mindustry/desktop/steam/SNet.java +++ b/desktop/src/mindustry/desktop/steam/SNet.java @@ -187,14 +187,14 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, @Override public void hostServer(int port) throws IOException{ provider.hostServer(port); - smat.createLobby(Core.settings.getBool("publichost") ? LobbyType.Public : LobbyType.FriendsOnly, Core.settings.getInt("playerlimit")); + smat.createLobby(Core.settings.getBool("steampublichost") ? LobbyType.Public : LobbyType.FriendsOnly, Core.settings.getInt("playerlimit")); Core.app.post(() -> Core.app.post(() -> Core.app.post(() -> Log.info("Server: @\nClient: @\nActive: @", net.server(), net.client(), net.active())))); } public void updateLobby(){ if(currentLobby != null && net.server()){ - smat.setLobbyType(currentLobby, Core.settings.getBool("publichost") ? LobbyType.Public : LobbyType.FriendsOnly); + smat.setLobbyType(currentLobby, Core.settings.getBool("steampublichost") ? LobbyType.Public : LobbyType.FriendsOnly); smat.setLobbyMemberLimit(currentLobby, Core.settings.getInt("playerlimit")); } }