Added build revision

This commit is contained in:
Anuken
2018-11-28 17:42:12 -05:00
parent 14e9a94061
commit 75d2ea1519
2 changed files with 16 additions and 2 deletions

View File

@@ -17,6 +17,8 @@ public class Version{
public static int number; public static int number;
/**Build number, e.g. '43'. set to '-1' for custom builds.*/ /**Build number, e.g. '43'. set to '-1' for custom builds.*/
public static int build = 0; public static int build = 0;
/**Revision number. Used for hotfixes. Does not affect server compatibility.*/
public static int revision = 0;
public static void init(){ public static void init(){
try{ try{
@@ -28,7 +30,18 @@ public class Version{
type = map.get("type"); type = map.get("type");
number = Integer.parseInt(map.get("number")); number = Integer.parseInt(map.get("number"));
modifier = map.get("modifier"); modifier = map.get("modifier");
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1; if(map.get("build").contains(".")){
String[] split = map.get("build").split("\\.");
try{
build = Integer.parseInt(split[0]);
revision = Integer.parseInt(split[1]);
}catch(Throwable e){
e.printStackTrace();
build = -1;
}
}else{
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
}
}catch(IOException e){ }catch(IOException e){
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@@ -43,7 +43,8 @@ public class MenuFragment extends Fragment{
} }
//version info //version info
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))) parent.fill(c -> c.bottom().left().add(Strings.formatArgs("Mindustry v{0} {1}-{2} {3}{4}", Version.number, Version.modifier, Version.type,
(Version.build == -1 ? "custom build" : "build " + Version.build), Version.revision == 0 ? "" : "." + Version.revision))
.visible(() -> state.is(State.menu))); .visible(() -> state.is(State.menu)));
} }