Removed reload, forced mandatory mod restart

This commit is contained in:
Anuken 2020-06-25 22:31:47 -04:00
parent ecfac00c30
commit c12865eabc
5 changed files with 11 additions and 52 deletions

View file

@ -106,6 +106,7 @@ mods.guide = Modding Guide
mods.report = Report Bug
mods.openfolder = Open Folder
mods.reload = Reload
mods.reloadexit = The game will now exit, to reload mods.
mod.display = [gray]Mod:[orange] {0}
mod.enabled = [lightgray]Enabled
mod.disabled = [scarlet]Disabled
@ -120,7 +121,7 @@ mod.noerrorplay = [scarlet]You have mods with errors.[] Either disable the affec
mod.nowdisabled = [scarlet]Mod '{0}' is missing dependencies:[accent] {1}\n[lightgray]These mods need to be downloaded first.\nThis mod will be automatically disabled.
mod.enable = Enable
mod.requiresrestart = The game will now close to apply the mod changes.
mod.reloadrequired = [scarlet]Reload Required
mod.reloadrequired = [scarlet]Restart Required
mod.import = Import Mod
mod.import.file = Import File
mod.import.github = Import From GitHub

View file

@ -333,10 +333,17 @@ public class UI implements ApplicationListener, Loadable{
}
public void showInfo(String info){
showInfo(info, () -> {});
}
public void showInfo(String info, Runnable listener){
new Dialog(""){{
getCell(cont).growX();
cont.margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
buttons.button("$ok", this::hide).size(110, 50).pad(4);
buttons.button("$ok", () -> {
hide();
listener.run();
}).size(110, 50).pad(4);
}}.show();
}

View file

@ -42,7 +42,6 @@ public class EventType{
public static class SaveLoadEvent{}
public static class ClientCreateEvent{}
public static class ServerLoadEvent{}
public static class ContentReloadEvent{}
public static class DisposeEvent{}
public static class PlayEvent{}
public static class ResetEvent{}

View file

@ -45,7 +45,6 @@ public class Mods implements Loadable{
public Mods(){
Events.on(ClientLoadEvent.class, e -> Core.app.post(this::checkWarnings));
Events.on(ContentReloadEvent.class, e -> Core.app.post(this::checkWarnings));
}
/** Returns a file named 'config.json' in a special folder for the specified plugin.
@ -423,42 +422,6 @@ public class Mods implements Loadable{
return mods.contains(LoadedMod::hasContentErrors) || (scripts != null && scripts.hasErrored());
}
/** Reloads all mod content. How does this even work? I refuse to believe that it functions correctly.*/
public void reloadContent(){
//epic memory leak
//TODO make it less epic
Core.atlas = new TextureAtlas(Core.files.internal("sprites/sprites.atlas"));
createdAtlas = true;
mods.each(LoadedMod::dispose);
mods.clear();
Core.bundle = I18NBundle.createBundle(Core.files.internal("bundles/bundle"), Core.bundle.getLocale());
load();
Sounds.dispose();
Sounds.load();
Core.assets.finishLoading();
if(scripts != null){
scripts.dispose();
scripts = null;
}
content.clear();
content.createBaseContent();
content.loadColors();
loadScripts();
content.createModContent();
loadAsync();
loadSync();
content.init();
content.load();
content.loadColors();
Core.atlas.getTextures().each(t -> t.setFilter(Core.settings.getBool("linear") ? TextureFilter.linear : TextureFilter.nearest));
requiresReload = false;
loadIcons();
Events.fire(new ContentReloadEvent());
}
/** This must be run on the main thread! */
public void loadScripts(){
Time.mark();

View file

@ -110,7 +110,6 @@ public class ModsDialog extends BaseDialog{
file.delete();
Core.app.post(() -> {
try{
mods.reloadContent();
setup();
ui.loadfrag.hide();
}catch(Throwable e){
@ -132,8 +131,6 @@ public class ModsDialog extends BaseDialog{
dialog.show();
}).margin(margin);
buttons.button("$mods.reload", Icon.refresh, style, this::reload).margin(margin);
if(!mobile){
buttons.button("$mods.openfolder", Icon.link, style, () -> Core.app.openFolder(modDirectory.absolutePath())).margin(margin);
}
@ -234,15 +231,7 @@ public class ModsDialog extends BaseDialog{
}
private void reload(){
ui.loadAnd("$reloading", () -> {
mods.eachEnabled(mod -> {
if(mod.hasUnmetDependencies()){
ui.showErrorMessage(Core.bundle.format("mod.nowdisabled", mod.name, mod.missingDependencies.toString(", ")));
}
});
mods.reloadContent();
setup();
});
ui.showInfo("$mods.reloadexit", () -> Core.app.exit());
}
private void showMod(LoadedMod mod){