Fixed Steam public lobby hosting / Misc Steam bugfixes

This commit is contained in:
Anuken
2023-03-25 12:42:29 -04:00
parent 0daafc5ff3
commit e4bef567b5
6 changed files with 41 additions and 44 deletions

View File

@@ -1107,8 +1107,8 @@ setting.bridgeopacity.name = Bridge Opacity
setting.playerchat.name = Display Player Bubble Chat setting.playerchat.name = Display Player Bubble Chat
setting.showweather.name = Show Weather Graphics setting.showweather.name = Show Weather Graphics
setting.hidedisplays.name = Hide Logic Displays 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. steam.friendsonly = Friends Only
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.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. 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.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 uiscale.cancel = Cancel & Exit

View File

@@ -322,6 +322,24 @@ public class UI implements ApplicationListener, Loadable{
Core.scene.add(table); 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. */ /** Shows a fading label at the top of the screen. */
public void showInfoToast(String info, float duration){ public void showInfoToast(String info, float duration){
var cinfo = Core.scene.find("coreinfo"); var cinfo = Core.scene.find("coreinfo");

View File

@@ -38,6 +38,15 @@ public class HostDialog extends BaseDialog{
button.update(() -> button.getStyle().imageUpColor = player.color()); button.update(() -> button.getStyle().imageUpColor = player.color());
}).width(w).height(70f).pad(4).colspan(3); }).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.row();
cont.add().width(65f); cont.add().width(65f);
@@ -51,7 +60,11 @@ public class HostDialog extends BaseDialog{
runHost(); runHost();
}).width(w).height(70f); }).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(() -> { shown(() -> {
if(!steam){ if(!steam){
@@ -68,24 +81,9 @@ public class HostDialog extends BaseDialog{
player.admin = true; player.admin = true;
Events.fire(new HostEvent()); Events.fire(new HostEvent());
if(steam){ if(steam && Core.settings.getBool("steampublichost")){
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(Version.modifier.contains("beta") || Version.modifier.contains("alpha")){ if(Version.modifier.contains("beta") || Version.modifier.contains("alpha")){
Core.settings.put("publichost", false); Core.settings.put("steampublichost", false);
platform.updateLobby(); platform.updateLobby();
Core.settings.getBoolOnce("betapublic", () -> ui.showInfo("@public.beta")); Core.settings.getBoolOnce("betapublic", () -> ui.showInfo("@public.beta"));
} }

View File

@@ -53,11 +53,7 @@ public class PausedDialog extends BaseDialog{
if(net.server() && steam){ if(net.server() && steam){
platform.inviteFriends(); platform.inviteFriends();
}else{ }else{
if(steam){ ui.host.show();
ui.host.runHost();
}else{
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")); }).disabled(b -> !((steam && net.server()) || !net.active())).colspan(2).width(dw * 2 + 10f).update(e -> e.setText(net.server() && steam ? "@invitefriends" : "@hostserver"));

View File

@@ -6,7 +6,6 @@ import arc.func.*;
import arc.graphics.*; import arc.graphics.*;
import arc.graphics.Texture.*; import arc.graphics.Texture.*;
import arc.input.*; import arc.input.*;
import arc.math.geom.*;
import arc.scene.*; import arc.scene.*;
import arc.scene.event.*; import arc.scene.event.*;
import arc.scene.style.*; import arc.scene.style.*;
@@ -356,7 +355,7 @@ public class SettingsMenuDialog extends BaseDialog{
}); });
if(!Version.modifier.contains("beta")){ if(!Version.modifier.contains("beta")){
game.checkPref("publichost", false, i -> { game.checkPref("steampublichost", false, i -> {
platform.updateLobby(); platform.updateLobby();
}); });
} }
@@ -707,21 +706,7 @@ public class SettingsMenuDialog extends BaseDialog{
public abstract void add(SettingsTable table); public abstract void add(SettingsTable table);
public void addDesc(Element elem){ public void addDesc(Element elem){
if(description == null) return; ui.addDescTooltip(elem, description);
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());
}
});
} }
} }

View File

@@ -187,14 +187,14 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
@Override @Override
public void hostServer(int port) throws IOException{ public void hostServer(int port) throws IOException{
provider.hostServer(port); 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())))); Core.app.post(() -> Core.app.post(() -> Core.app.post(() -> Log.info("Server: @\nClient: @\nActive: @", net.server(), net.client(), net.active()))));
} }
public void updateLobby(){ public void updateLobby(){
if(currentLobby != null && net.server()){ 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")); smat.setLobbyMemberLimit(currentLobby, Core.settings.getInt("playerlimit"));
} }
} }