Added version type
This commit is contained in:
@@ -9,11 +9,14 @@ import io.anuke.ucore.util.Strings;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Version{
|
||||
public static String name;
|
||||
/**Build type. 'official' for official releases; 'custom' or 'bleeding edge' are also used.*/
|
||||
public static String type;
|
||||
public static String code;
|
||||
/**Number specifying the major version, e.g. '4.0'*/
|
||||
public static String number;
|
||||
/**Build modifier, e.g. 'alpha' or 'release'*/
|
||||
public static String modifier;
|
||||
/**Build number, e.g. '43'. set to '-1' for custom builds.*/
|
||||
public static int build = 0;
|
||||
public static String buildName;
|
||||
|
||||
public static void init(){
|
||||
try{
|
||||
@@ -22,12 +25,10 @@ public class Version{
|
||||
ObjectMap<String, String> map = new ObjectMap<>();
|
||||
PropertiesUtils.load(map, file.reader());
|
||||
|
||||
name = map.get("name");
|
||||
type = map.get("version");
|
||||
code = map.get("code");
|
||||
type = map.get("type");
|
||||
number = map.get("number");
|
||||
modifier = map.get("modifier");
|
||||
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
|
||||
buildName = build == -1 ? map.get("build") : "build " + build;
|
||||
|
||||
}catch(IOException e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -7,13 +7,15 @@ public class Host{
|
||||
public final int wave;
|
||||
public final int players;
|
||||
public final int version;
|
||||
public final String versionType;
|
||||
|
||||
public Host(String name, String address, String mapname, int wave, int players, int version){
|
||||
public Host(String name, String address, String mapname, int wave, int players, int version, String versionType){
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.players = players;
|
||||
this.mapname = mapname;
|
||||
this.wave = wave;
|
||||
this.version = version;
|
||||
this.versionType = versionType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,6 +310,8 @@ public class NetworkIO{
|
||||
buffer.putInt(playerGroup.size());
|
||||
buffer.putInt(state.wave);
|
||||
buffer.putInt(Version.build);
|
||||
buffer.put((byte)Version.type.getBytes().length);
|
||||
buffer.put(Version.type.getBytes());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -328,7 +330,11 @@ public class NetworkIO{
|
||||
int players = buffer.getInt();
|
||||
int wave = buffer.getInt();
|
||||
int version = buffer.getInt();
|
||||
byte tlength = buffer.get();
|
||||
byte[] tb = new byte[tlength];
|
||||
buffer.get(tb);
|
||||
String vertype = new String(tb);
|
||||
|
||||
return new Host(host, hostAddress, map, wave, players, version);
|
||||
return new Host(host, hostAddress, map, wave, players, version, vertype);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
versionString = Bundles.get("text.server.outdated.client") + "\n" +
|
||||
Bundles.format("text.server.version", host.version);
|
||||
}else{
|
||||
versionString = Bundles.format("text.server.version", host.version);
|
||||
versionString = Bundles.format("text.server.version", host.version, host.versionType);
|
||||
}
|
||||
|
||||
server.content.clear();
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MenuFragment extends Fragment{
|
||||
}
|
||||
|
||||
//version info
|
||||
parent.fill(c -> c.bottom().left().add("Mindustry " + Version.code + " " + Version.type + " / " + Version.buildName)
|
||||
parent.fill(c -> c.bottom().left().add("Mindustry " + Version.number + "-" + Version.modifier + " " + Version.type + " / " + (Version.build == -1 ? "custom build" : "build " + Version.build))
|
||||
.visible(() -> state.is(State.menu)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user