Exit after importing
This commit is contained in:
@@ -429,9 +429,13 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showInfoOnHidden(String info, Runnable listener){
|
public void showInfoOnHidden(String info, Runnable listener){
|
||||||
|
showInfoOnHidden(info, Align.center, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showInfoOnHidden(String info, int align, Runnable listener){
|
||||||
new Dialog(""){{
|
new Dialog(""){{
|
||||||
getCell(cont).growX();
|
getCell(cont).growX();
|
||||||
cont.margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
cont.margin(15).add(info).width(400f).wrap().get().setAlignment(align, align);
|
||||||
buttons.button("@ok", this::hide).size(110, 50).pad(4);
|
buttons.button("@ok", this::hide).size(110, 50).pad(4);
|
||||||
hidden(listener);
|
hidden(listener);
|
||||||
closeOnBack();
|
closeOnBack();
|
||||||
|
|||||||
@@ -681,16 +681,29 @@ public class Mods implements Loadable{
|
|||||||
mods.each(LoadedMod::hasUnmetDependencies, mod -> {
|
mods.each(LoadedMod::hasUnmetDependencies, mod -> {
|
||||||
mod.missingDependencies.each(missingDeps::addUnique);
|
mod.missingDependencies.each(missingDeps::addUnique);
|
||||||
});
|
});
|
||||||
int amount = missingDeps.size;
|
int toImport = missingDeps.size;
|
||||||
ui.mods.importDependencies(missingDeps);
|
ui.mods.importDependencies(missingDeps);
|
||||||
if(missingDeps.size < amount) requiresReload = true;
|
|
||||||
|
|
||||||
if(missingDeps.isEmpty()){
|
if(missingDeps.isEmpty()){
|
||||||
ui.showInfo("@mod.dependencies.success");
|
ui.showInfoOnHidden(Core.bundle.get("mod.dependencies.success") + "\n\n" + Core.bundle.get("mods.reloadexit"), () -> {
|
||||||
|
Log.info("Exiting to reload mods.");
|
||||||
|
Core.app.exit();
|
||||||
|
});
|
||||||
}else{
|
}else{
|
||||||
String[] fail = {Core.bundle.get("mod.dependencies.failure")};
|
String[] fail = {Core.bundle.get("mod.dependencies.failure")};
|
||||||
missingDeps.each(d -> fail[0] += "\n " + d);
|
missingDeps.each(d -> fail[0] += "\n " + d);
|
||||||
ui.showStartupInfo(fail[0]);
|
|
||||||
|
boolean imported = missingDeps.size < toImport; //Mods were loaded
|
||||||
|
if(imported){
|
||||||
|
fail[0] += "\n\n" + Core.bundle.get("mods.reloadexit");
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.showInfoOnHidden(fail[0], Align.left, () -> {
|
||||||
|
if(imported){
|
||||||
|
Log.info("Exiting to reload mods.");
|
||||||
|
Core.app.exit();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}).size(150, 50);
|
}).size(150, 50);
|
||||||
});
|
});
|
||||||
@@ -698,6 +711,13 @@ public class Mods implements Loadable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reload(){
|
||||||
|
ui.showInfoOnHidden("@mods.reloadexit", () -> {
|
||||||
|
Log.info("Exiting to reload mods.");
|
||||||
|
Core.app.exit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasContentErrors(){
|
public boolean hasContentErrors(){
|
||||||
return mods.contains(LoadedMod::hasContentErrors) || (scripts != null && scripts.hasErrored());
|
return mods.contains(LoadedMod::hasContentErrors) || (scripts != null && scripts.hasErrored());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user