Merge branch 'master' into mod-dependencies
This commit is contained in:
@@ -72,6 +72,7 @@ public class ModsDialog extends BaseDialog{
|
||||
browserTable = tablebrow;
|
||||
}).scrollX(false);
|
||||
browser.addCloseButton();
|
||||
browser.makeButtonOverlay();
|
||||
|
||||
browser.onResize(this::rebuildBrowser);
|
||||
|
||||
@@ -106,40 +107,56 @@ public class ModsDialog extends BaseDialog{
|
||||
ui.showErrorMessage("@feature.unsupported");
|
||||
}else if(error instanceof HttpStatusException st){
|
||||
ui.showErrorMessage(Core.bundle.format("connectfail", Strings.capitalize(st.status.toString().toLowerCase())));
|
||||
}else if(error.getMessage() != null && error.getMessage().toLowerCase(Locale.ROOT).contains("writable dex")){
|
||||
ui.showException("@error.moddex", error);
|
||||
}else{
|
||||
ui.showException(error);
|
||||
}
|
||||
}
|
||||
|
||||
void getModList(Cons<Seq<ModListing>> listener){
|
||||
if(modList == null){
|
||||
Http.get("https://raw.githubusercontent.com/Anuken/MindustryMods/master/mods.json", response -> {
|
||||
String strResult = response.getResultAsString();
|
||||
void getModList(int index, Cons<Seq<ModListing>> listener){
|
||||
if(index >= modJsonURLs.length) return;
|
||||
|
||||
if(modList != null){
|
||||
listener.get(modList);
|
||||
return;
|
||||
}
|
||||
|
||||
Http.get(modJsonURLs[index], response -> {
|
||||
String strResult = response.getResultAsString();
|
||||
|
||||
Core.app.post(() -> {
|
||||
try{
|
||||
modList = JsonIO.json.fromJson(Seq.class, ModListing.class, strResult);
|
||||
|
||||
var d = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
Func<String, Date> parser = text -> {
|
||||
try{
|
||||
return d.parse(text);
|
||||
}catch(Exception e){
|
||||
return new Date();
|
||||
}
|
||||
};
|
||||
|
||||
modList.sortComparing(m -> parser.get(m.lastUpdated)).reverse();
|
||||
listener.get(modList);
|
||||
}catch(Exception e){
|
||||
Log.err(e);
|
||||
ui.showException(e);
|
||||
}
|
||||
});
|
||||
}, error -> {
|
||||
if(index < modJsonURLs.length - 1){
|
||||
getModList(index + 1, listener);
|
||||
}else{
|
||||
Core.app.post(() -> {
|
||||
try{
|
||||
modList = JsonIO.json.fromJson(Seq.class, ModListing.class, strResult);
|
||||
|
||||
var d = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
Func<String, Date> parser = text -> {
|
||||
try{
|
||||
return d.parse(text);
|
||||
}catch(Exception e){
|
||||
return new Date();
|
||||
}
|
||||
};
|
||||
|
||||
modList.sortComparing(m -> parser.get(m.lastUpdated)).reverse();
|
||||
listener.get(modList);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
ui.showException(e);
|
||||
modError(error);
|
||||
if(browser != null){
|
||||
browser.hide();
|
||||
}
|
||||
});
|
||||
}, error -> Core.app.post(() -> modError(error)));
|
||||
}else{
|
||||
listener.get(modList);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setup(){
|
||||
@@ -174,7 +191,7 @@ public class ModsDialog extends BaseDialog{
|
||||
mods.importMod(file);
|
||||
setup();
|
||||
}catch(Exception e){
|
||||
ui.showException(e);
|
||||
ui.showException(e.getMessage() != null && e.getMessage().toLowerCase(Locale.ROOT).contains("writable dex") ? "@error.moddex" : "", e);
|
||||
Log.err(e);
|
||||
}
|
||||
}, "zip", "jar");
|
||||
@@ -391,6 +408,12 @@ public class ModsDialog extends BaseDialog{
|
||||
desc.add(mod.meta.author).growX().wrap().padTop(2);
|
||||
desc.row();
|
||||
}
|
||||
if(mod.meta.version != null){
|
||||
desc.add("@mod.version").padRight(10).color(Color.gray).top();
|
||||
desc.row();
|
||||
desc.add(mod.meta.version).growX().wrap().padTop(2);
|
||||
desc.row();
|
||||
}
|
||||
if(mod.meta.description != null){
|
||||
desc.add("@editor.description").padRight(10).color(Color.gray).top();
|
||||
desc.row();
|
||||
@@ -448,7 +471,7 @@ public class ModsDialog extends BaseDialog{
|
||||
|
||||
int cols = (int)Math.max(Core.graphics.getWidth() / Scl.scl(480), 1);
|
||||
|
||||
getModList(rlistings -> {
|
||||
getModList(0, rlistings -> {
|
||||
browserTable.clear();
|
||||
int i = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user