Added in-game changelogs

This commit is contained in:
Anuken
2018-03-09 17:11:01 -05:00
parent 1d83e94ad6
commit 8743a60d02
12 changed files with 473 additions and 349 deletions

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