Added in-game changelogs
This commit is contained in:
66
core/src/io/anuke/mindustry/ui/dialogs/ChangelogDialog.java
Normal file
66
core/src/io/anuke/mindustry/ui/dialogs/ChangelogDialog.java
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user