New version format / Updated bundles / ConnectPacket encoding fix
This commit is contained in:
@@ -11,10 +11,10 @@ import java.io.IOException;
|
||||
public class Version{
|
||||
/**Build type. 'official' for official releases; 'custom' or 'bleeding edge' are also used.*/
|
||||
public static String type;
|
||||
/**Number specifying the major version, e.g. '4.0'*/
|
||||
public static String number;
|
||||
/**Build modifier, e.g. 'alpha' or 'release'*/
|
||||
public static String modifier;
|
||||
/**Number specifying the major version, e.g. '4'*/
|
||||
public static int number;
|
||||
/**Build number, e.g. '43'. set to '-1' for custom builds.*/
|
||||
public static int build = 0;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Version{
|
||||
PropertiesUtils.load(map, file.reader());
|
||||
|
||||
type = map.get("type");
|
||||
number = map.get("number");
|
||||
number = Integer.parseInt(map.get("number"));
|
||||
modifier = map.get("modifier");
|
||||
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
|
||||
}catch(IOException e){
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.anuke.mindustry.net;
|
||||
|
||||
import com.badlogic.gdx.utils.Base64Coder;
|
||||
import io.anuke.mindustry.game.Version;
|
||||
import io.anuke.ucore.io.IOUtils;
|
||||
import io.anuke.mindustry.io.TypeIO;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -65,6 +65,7 @@ public class Packets{
|
||||
|
||||
public static class ConnectPacket implements Packet{
|
||||
public int version;
|
||||
public String versionType;
|
||||
public String name, uuid, usid;
|
||||
public boolean mobile;
|
||||
public int color;
|
||||
@@ -72,8 +73,9 @@ public class Packets{
|
||||
@Override
|
||||
public void write(ByteBuffer buffer){
|
||||
buffer.putInt(Version.build);
|
||||
IOUtils.writeString(buffer, name);
|
||||
IOUtils.writeString(buffer, usid);
|
||||
TypeIO.writeString(buffer, versionType);
|
||||
TypeIO.writeString(buffer, name);
|
||||
TypeIO.writeString(buffer, usid);
|
||||
buffer.put(mobile ? (byte) 1 : 0);
|
||||
buffer.putInt(color);
|
||||
buffer.put(Base64Coder.decode(uuid));
|
||||
@@ -82,8 +84,9 @@ public class Packets{
|
||||
@Override
|
||||
public void read(ByteBuffer buffer){
|
||||
version = buffer.getInt();
|
||||
name = IOUtils.readString(buffer);
|
||||
usid = IOUtils.readString(buffer);
|
||||
versionType = TypeIO.readString(buffer);
|
||||
name = TypeIO.readString(buffer);
|
||||
usid = TypeIO.readString(buffer);
|
||||
mobile = buffer.get() == 1;
|
||||
color = buffer.getInt();
|
||||
byte[] idbytes = new byte[8];
|
||||
|
||||
@@ -11,6 +11,7 @@ import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -42,7 +43,7 @@ public class MenuFragment extends Fragment{
|
||||
}
|
||||
|
||||
//version info
|
||||
parent.fill(c -> c.bottom().left().add("Mindustry " + Version.number + "-" + Version.modifier + " " + Version.type + " / " + (Version.build == -1 ? "custom build" : "build " + Version.build))
|
||||
parent.fill(c -> c.bottom().left().add(Strings.formatArgs("Mindustry v{0} {1}-{2} {3}", Version.number, Version.modifier, Version.type, (Version.build == -1 ? "custom build" : "build " + Version.build)))
|
||||
.visible(() -> state.is(State.menu)));
|
||||
}
|
||||
|
||||
@@ -55,14 +56,14 @@ public class MenuFragment extends Fragment{
|
||||
container.defaults().size(size).pad(5).padTop(4f);
|
||||
|
||||
MobileButton
|
||||
play = new MobileButton("icon-play-2", isize, "$text.play", this::showPlaySelect),
|
||||
maps = new MobileButton("icon-map", isize, "$text.maps", ui.maps::show),
|
||||
load = new MobileButton("icon-load", isize, "$text.load", ui.load::show),
|
||||
join = new MobileButton("icon-add", isize, "$text.joingame", ui.join::show),
|
||||
editor = new MobileButton("icon-editor", isize, "$text.editor", () -> ui.loadGraphics(ui.editor::show)),
|
||||
tools = new MobileButton("icon-tools", isize, "$text.settings", ui.settings::show),
|
||||
unlocks = new MobileButton("icon-unlocks", isize, "$text.unlocks", ui.unlocks::show),
|
||||
donate = new MobileButton("icon-donate", isize, "$text.donate", Platform.instance::openDonations);
|
||||
play = new MobileButton("icon-play-2", isize, "$text.play", this::showPlaySelect),
|
||||
maps = new MobileButton("icon-map", isize, "$text.maps", ui.maps::show),
|
||||
load = new MobileButton("icon-load", isize, "$text.load", ui.load::show),
|
||||
join = new MobileButton("icon-add", isize, "$text.joingame", ui.join::show),
|
||||
editor = new MobileButton("icon-editor", isize, "$text.editor", () -> ui.loadGraphics(ui.editor::show)),
|
||||
tools = new MobileButton("icon-tools", isize, "$text.settings", ui.settings::show),
|
||||
unlocks = new MobileButton("icon-unlocks", isize, "$text.unlocks", ui.unlocks::show),
|
||||
donate = new MobileButton("icon-donate", isize, "$text.donate", Platform.instance::openDonations);
|
||||
|
||||
if(Gdx.graphics.getWidth() > Gdx.graphics.getHeight()){
|
||||
container.add(play);
|
||||
|
||||
Reference in New Issue
Block a user