Merge branch 'master' of https://github.com/Anuken/Mindustry into 4.0

# Conflicts:
#	core/assets/sprites/sprites.atlas
#	core/assets/version.properties
This commit is contained in:
Anuken
2018-03-09 20:58:21 -05:00
15 changed files with 2205 additions and 2237 deletions

View File

@@ -45,7 +45,7 @@ public class Vars{
//discord group URL
public static final String discordURL = "https://discord.gg/BKADYds";
public static final String serverURL = "http://localhost:3000";
public static final String releasesURL = "https://api.github.com/repos/Anuken/Mindustry/releases";
//directory for user-created map data
public static final FileHandle customMapDirectory = gwt ? null : UCore.isAssets() ?
Gdx.files.local("../../desktop/mindustry-maps") : Gdx.files.local("mindustry-maps/");

View File

@@ -120,7 +120,8 @@ public class Control extends Module{
"name", android || gwt ? "player" : UCore.getProperty("user.name"),
"servers", "",
"color", Color.rgba8888(playerColors[8]),
"lastVersion", "3.2"
"lastVersion", "3.2",
"lastBuild", 0
);
KeyBinds.load();

View File

@@ -49,6 +49,7 @@ public class UI extends SceneModule{
public BansDialog bans;
public AdminsDialog admins;
public TraceDialog traces;
public ChangelogDialog changelog;
public final MenuFragment menufrag = new MenuFragment();
public final ToolFragment toolfrag = new ToolFragment();
@@ -159,6 +160,7 @@ public class UI extends SceneModule{
bans = new BansDialog();
admins = new AdminsDialog();
traces = new TraceDialog();
changelog = new ChangelogDialog();
build.begin(scene);

View File

@@ -157,7 +157,8 @@ public class DesktopInput extends InputHandler{
}
boolean select(){
return !Inputs.keyDown("select") && !Inputs.keyRelease("select");
return !Inputs.keyDown("select") && !Inputs.keyRelease("select") &&
!Inputs.keyDown("break") && !Inputs.keyRelease("break");
}
public int tilex(){

View File

@@ -0,0 +1,50 @@
package io.anuke.mindustry.io;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Json;
import com.badlogic.gdx.utils.JsonValue;
import io.anuke.mindustry.net.Net;
import io.anuke.ucore.function.Consumer;
import static io.anuke.mindustry.Vars.releasesURL;
public class Changelogs {
public static void getChangelog(Consumer<Array<VersionInfo>> success, Consumer<Throwable> fail){
Net.http(releasesURL, "GET", result -> {
Json j = new Json();
Array<JsonValue> list = j.fromJson(null, result);
Array<VersionInfo> out = new Array<>();
for(JsonValue value : list){
String name = value.getString("name");
String description = value.getString("body").replace("\r", "");
int id = value.getInt("id");
int build = Integer.parseInt(value.getString("tag_name").substring(1));
out.add(new VersionInfo(name, description, id, build));
}
success.accept(out);
}, fail);
}
public static class VersionInfo{
public final String name, description;
public final int id, build;
public VersionInfo(String name, String description, int id, int build) {
this.name = name;
this.description = description;
this.id = id;
this.build = build;
}
@Override
public String toString() {
return "VersionInfo{" +
"name='" + name + '\'' +
", description='" + description + '\'' +
", id=" + id +
", build=" + build +
'}';
}
}
}

View File

@@ -248,9 +248,9 @@ public class Net{
active = false;
}
public static void http(String method, String content, Consumer<String> listener){
public static void http(String url, String method, Consumer<String> listener, Consumer<Throwable> failure){
HttpRequest req = new HttpRequestBuilder().newRequest()
.method(method).content(content).url(serverURL + "/servers").build();
.method(method).url(url).build();
Gdx.net.sendHttpRequest(req, new HttpResponseListener() {
@Override
@@ -260,8 +260,7 @@ public class Net{
@Override
public void failed(Throwable t) {
Log.err("HTTP error:");
Log.err(t);
failure.accept(t);
}
@Override

View File

@@ -0,0 +1,66 @@
package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.io.Changelogs;
import io.anuke.mindustry.io.Changelogs.VersionInfo;
import io.anuke.mindustry.io.Version;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Log;
public class ChangelogDialog extends FloatingDialog{
private final float vw = 600;
private Array<VersionInfo> versions;
public ChangelogDialog(){
super("$text.changelog.title");
Changelogs.getChangelog(result -> {
versions = result;
Gdx.app.postRunnable(this::setup);
}, t -> {
Log.err(t);
Gdx.app.postRunnable(this::setup);
});
}
void setup(){
Table table = new Table();
ScrollPane pane = new ScrollPane(table, "clear");
content().add(pane).grow();
addCloseButton();
if(versions == null){
table.add("$text.changelog.error");
}else{
for(VersionInfo info : versions){
Table in = new Table("clear");
in.top().left().margin(10);
in.add("[accent]" + info.name);
if(info.build == Version.build){
in.row();
in.add("$text.changelog.current");
}else if(info == versions.peek()){
in.row();
in.add("$text.changelog.latest");
}
in.row();
in.labelWrap("[lightgray]" + info.description).width(vw - 20).padTop(12);
table.add(in).width(vw).pad(8).row();
}
int lastid = Settings.getInt("lastBuild");
if(lastid != 0 && versions.peek().build > lastid){
Settings.putInt("lastBuild", versions.peek().build);
Settings.save();
show();
}
}
}
}

View File

@@ -89,6 +89,7 @@ public class MenuFragment implements Fragment{
if(!Vars.android) {
new imagebutton("icon-info", 30f, ui.about::show).margin(14);
}
new imagebutton("icon-menu", 30f, ui.changelog::show).margin(14);
}}.end().visible(()->state.is(State.menu));
//version info