Support for built-in servers
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@@ -3,6 +3,7 @@ package io.anuke.mindustry;
|
|||||||
import io.anuke.arc.Application.*;
|
import io.anuke.arc.Application.*;
|
||||||
import io.anuke.arc.*;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.assets.*;
|
import io.anuke.arc.assets.*;
|
||||||
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.files.*;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.graphics.*;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.scene.ui.layout.*;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
@@ -43,6 +44,8 @@ public class Vars implements Loadable{
|
|||||||
public static final String discordURL = "https://discord.gg/mindustry";
|
public static final String discordURL = "https://discord.gg/mindustry";
|
||||||
/** URL for sending crash reports to */
|
/** URL for sending crash reports to */
|
||||||
public static final String crashReportURL = "http://mins.us.to/report";
|
public static final String crashReportURL = "http://mins.us.to/report";
|
||||||
|
/** list of built-in servers.*/
|
||||||
|
public static final Array<String> defaultServers = Array.with(/*"mins.us.to"*/);
|
||||||
/** maximum distance between mine and core that supports automatic transferring */
|
/** maximum distance between mine and core that supports automatic transferring */
|
||||||
public static final float mineTransferRange = 220f;
|
public static final float mineTransferRange = 220f;
|
||||||
/** team of the player by default */
|
/** team of the player by default */
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ public abstract class FlyingUnit extends BaseUnit{
|
|||||||
|
|
||||||
if(!Net.client()){
|
if(!Net.client()){
|
||||||
updateRotation();
|
updateRotation();
|
||||||
wobble();
|
|
||||||
}
|
}
|
||||||
|
wobble();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -188,13 +188,12 @@ public class Tutorial{
|
|||||||
|
|
||||||
protected final String line = Core.bundle.has("tutorial." + name() + ".mobile") && mobile ? "tutorial." + name() + ".mobile" : "tutorial." + name();
|
protected final String line = Core.bundle.has("tutorial." + name() + ".mobile") && mobile ? "tutorial." + name() + ".mobile" : "tutorial." + name();
|
||||||
protected final Function<String, String> text;
|
protected final Function<String, String> text;
|
||||||
protected final Array<String> sentences;
|
protected Array<String> sentences;
|
||||||
protected final BooleanProvider done;
|
protected final BooleanProvider done;
|
||||||
|
|
||||||
TutorialStage(Function<String, String> text, BooleanProvider done){
|
TutorialStage(Function<String, String> text, BooleanProvider done){
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.done = done;
|
this.done = done;
|
||||||
this.sentences = Array.select(Core.bundle.get(line).split("\n"), s -> !s.isEmpty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TutorialStage(BooleanProvider done){
|
TutorialStage(BooleanProvider done){
|
||||||
@@ -203,6 +202,7 @@ public class Tutorial{
|
|||||||
|
|
||||||
/** displayed tutorial stage text.*/
|
/** displayed tutorial stage text.*/
|
||||||
public String text(){
|
public String text(){
|
||||||
|
if(sentences == null) this.sentences = Array.select(Core.bundle.get(line).split("\n"), s -> !s.isEmpty());
|
||||||
String line = sentences.get(control.tutorial.sentence);
|
String line = sentences.get(control.tutorial.sentence);
|
||||||
return line.contains("{") ? text.get(line) : line;
|
return line.contains("{") ? text.get(line) : line;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,11 @@ public class JoinDialog extends FloatingDialog{
|
|||||||
|
|
||||||
void setupServer(Server server, Host host){
|
void setupServer(Server server, Host host){
|
||||||
server.lastHost = host;
|
server.lastHost = host;
|
||||||
|
server.content.clear();
|
||||||
|
buildServer(host, server.content);
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildServer(Host host, Table content){
|
||||||
String versionString;
|
String versionString;
|
||||||
|
|
||||||
if(host.version == -1){
|
if(host.version == -1){
|
||||||
@@ -192,9 +197,8 @@ public class JoinDialog extends FloatingDialog{
|
|||||||
versionString = Core.bundle.format("server.version", host.version, host.versionType);
|
versionString = Core.bundle.format("server.version", host.version, host.versionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
server.content.clear();
|
|
||||||
|
|
||||||
server.content.table(t -> {
|
content.table(t -> {
|
||||||
t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
||||||
t.row();
|
t.row();
|
||||||
t.add("[lightgray]" + (Core.bundle.format("players" + (host.players == 1 ? ".single" : ""), (host.players == 0 ? "[lightgray]" : "[accent]") + host.players + (host.playerLimit > 0 ? "[lightgray]/[accent]" + host.playerLimit : "")+ "[lightgray]"))).left();
|
t.add("[lightgray]" + (Core.bundle.format("players" + (host.players == 1 ? ".single" : ""), (host.players == 0 ? "[lightgray]" : "[accent]") + host.players + (host.playerLimit > 0 ? "[lightgray]/[accent]" + host.playerLimit : "")+ "[lightgray]"))).left();
|
||||||
@@ -268,6 +272,9 @@ public class JoinDialog extends FloatingDialog{
|
|||||||
local.background((Drawable)null);
|
local.background((Drawable)null);
|
||||||
local.table("button", t -> t.label(() -> "[accent]" + Core.bundle.get("hosts.discovering") + Strings.animated(Time.time(), 4, 10f, ".")).pad(10f)).growX();
|
local.table("button", t -> t.label(() -> "[accent]" + Core.bundle.get("hosts.discovering") + Strings.animated(Time.time(), 4, 10f, ".")).pad(10f)).growX();
|
||||||
Net.discoverServers(this::addLocalHost, this::finishLocalHosts);
|
Net.discoverServers(this::addLocalHost, this::finishLocalHosts);
|
||||||
|
for(String host : defaultServers){
|
||||||
|
Net.pingHost(host, port, this::addLocalHost, e -> {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishLocalHosts(){
|
void finishLocalHosts(){
|
||||||
@@ -292,12 +299,10 @@ public class JoinDialog extends FloatingDialog{
|
|||||||
|
|
||||||
local.row();
|
local.row();
|
||||||
|
|
||||||
TextButton button = local.addButton("[accent]" + host.name, "clear", () -> connect(host.address, port))
|
TextButton button = local.addButton("", "clear", () -> connect(host.address, port))
|
||||||
.width(w).height(80f).pad(4f).get();
|
.width(w).pad(5f).get();
|
||||||
button.left();
|
button.clearChildren();
|
||||||
button.row();
|
buildServer(host, button);
|
||||||
button.add("[lightgray]" + (host.players != 1 ? Core.bundle.format("players", host.players) :
|
|
||||||
Core.bundle.format("players.single", host.players))).padBottom(5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void connect(String ip, int port){
|
void connect(String ip, int port){
|
||||||
|
|||||||
Reference in New Issue
Block a user