Added server descriptions
This commit is contained in:
@@ -411,6 +411,7 @@ public class Administration{
|
||||
/** Server configuration definition. Each config value can be a string, boolean or number. */
|
||||
public enum Config{
|
||||
name("The server name as displayed on clients.", "Server", "servername"),
|
||||
desc("The server description, displayed under the name. Max 100 characters.", "off"),
|
||||
port("The port to host on.", Vars.port),
|
||||
autoUpdate("Whether to auto-update and exit when a new bleeding-edge update arrives.", false),
|
||||
showConnectMessages("Whether to display connect/disconnect messages.", true),
|
||||
|
||||
@@ -21,7 +21,7 @@ import static mindustry.Vars.*;
|
||||
|
||||
public class ArcNetProvider implements NetProvider{
|
||||
final Client client;
|
||||
final Prov<DatagramPacket> packetSupplier = () -> new DatagramPacket(new byte[256], 256);
|
||||
final Prov<DatagramPacket> packetSupplier = () -> new DatagramPacket(new byte[512], 512);
|
||||
|
||||
final Server server;
|
||||
final CopyOnWriteArrayList<ArcConnection> connections = new CopyOnWriteArrayList<>();
|
||||
|
||||
@@ -6,7 +6,7 @@ import mindustry.game.*;
|
||||
public class Host{
|
||||
public final String name;
|
||||
public final String address;
|
||||
public final String mapname;
|
||||
public final String mapname, description;
|
||||
public final int wave;
|
||||
public final int players, playerLimit;
|
||||
public final int version;
|
||||
@@ -14,7 +14,7 @@ public class Host{
|
||||
public final Gamemode mode;
|
||||
public int ping, port = Vars.port;
|
||||
|
||||
public Host(String name, String address, String mapname, int wave, int players, int version, String versionType, Gamemode mode, int playerLimit){
|
||||
public Host(String name, String address, String mapname, int wave, int players, int version, String versionType, Gamemode mode, int playerLimit, String description){
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.players = players;
|
||||
@@ -24,5 +24,6 @@ public class Host{
|
||||
this.versionType = versionType;
|
||||
this.playerLimit = playerLimit;
|
||||
this.mode = mode;
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +63,10 @@ public class NetworkIO{
|
||||
|
||||
public static ByteBuffer writeServerData(){
|
||||
String name = (headless ? Config.name.string() : player.name);
|
||||
String description = headless && !Config.desc.string().equals("off") ? Config.desc.string() : "";
|
||||
String map = world.getMap() == null ? "None" : world.getMap().name();
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.allocate(256);
|
||||
ByteBuffer buffer = ByteBuffer.allocate(512);
|
||||
|
||||
writeString(buffer, name, 100);
|
||||
writeString(buffer, map);
|
||||
@@ -77,6 +78,8 @@ public class NetworkIO{
|
||||
|
||||
buffer.put((byte)Gamemode.bestFit(state.rules).ordinal());
|
||||
buffer.putInt(netServer.admins.getPlayerLimit());
|
||||
|
||||
writeString(buffer, description, 100);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -89,8 +92,9 @@ public class NetworkIO{
|
||||
String vertype = readString(buffer);
|
||||
Gamemode gamemode = Gamemode.all[buffer.get()];
|
||||
int limit = buffer.getInt();
|
||||
String description = readString(buffer);
|
||||
|
||||
return new Host(host, hostAddress, map, wave, players, version, vertype, gamemode, limit);
|
||||
return new Host(host, hostAddress, map, wave, players, version, vertype, gamemode, limit, description);
|
||||
}
|
||||
|
||||
private static void writeString(ByteBuffer buffer, String string, int maxlen){
|
||||
|
||||
@@ -139,16 +139,16 @@ public class JoinDialog extends FloatingDialog{
|
||||
}
|
||||
}
|
||||
|
||||
}).margin(3f).padTop(6f).top().right();
|
||||
}).margin(3f).pad(2).padTop(6f).top().right();
|
||||
|
||||
inner.addImageButton(Icon.refresh, Styles.emptyi, () -> {
|
||||
refreshServer(server);
|
||||
}).margin(3f).padTop(6f).top().right();
|
||||
}).margin(3f).pad(2).padTop(6f).top().right();
|
||||
|
||||
inner.addImageButton(Icon.pencil, Styles.emptyi, () -> {
|
||||
renaming = server;
|
||||
add.show();
|
||||
}).margin(3f).padTop(6f).top().right();
|
||||
}).margin(3f).pad(2).padTop(6f).top().right();
|
||||
|
||||
inner.addImageButton(Icon.trash, Styles.emptyi, () -> {
|
||||
ui.showConfirm("$confirm", "$server.delete", () -> {
|
||||
@@ -157,7 +157,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
setupRemote();
|
||||
refreshRemote();
|
||||
});
|
||||
}).margin(3f).pad(6).top().right();
|
||||
}).margin(3f).pad(2).pad(6).top().right();
|
||||
|
||||
button.row();
|
||||
|
||||
@@ -179,7 +179,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
|
||||
net.pingHost(server.ip, server.port, host -> setupServer(server, host), e -> {
|
||||
server.content.clear();
|
||||
server.content.add("$host.invalid");
|
||||
server.content.add("$host.invalid").padBottom(4);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -212,6 +212,10 @@ public class JoinDialog extends FloatingDialog{
|
||||
content.table(t -> {
|
||||
t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
||||
t.row();
|
||||
if(!host.description.isEmpty()){
|
||||
t.add("[gray]" + host.description).width(targetWidth() - 10f).left().wrap();
|
||||
t.row();
|
||||
}
|
||||
t.add("[lightgray]" + (Core.bundle.format("players" + (host.players == 1 && host.playerLimit <= 0 ? ".single" : ""), (host.players == 0 ? "[lightgray]" : "[accent]") + host.players + (host.playerLimit > 0 ? "[lightgray]/[accent]" + host.playerLimit : "")+ "[lightgray]"))).left();
|
||||
t.row();
|
||||
t.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + "[lightgray] / " + host.mode.toString()).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
||||
|
||||
Reference in New Issue
Block a user