diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 49db2f8b0a..6a3c4a2c68 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -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 diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index d9187e6674..904dcb9b80 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -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(); } diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index cad55d7931..f8353981b2 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -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{} diff --git a/core/src/mindustry/mod/Mods.java b/core/src/mindustry/mod/Mods.java index 6dcbae2ba5..5f54e05ae9 100644 --- a/core/src/mindustry/mod/Mods.java +++ b/core/src/mindustry/mod/Mods.java @@ -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(); diff --git a/core/src/mindustry/ui/dialogs/ModsDialog.java b/core/src/mindustry/ui/dialogs/ModsDialog.java index 67fc26b00c..0132f954e7 100644 --- a/core/src/mindustry/ui/dialogs/ModsDialog.java +++ b/core/src/mindustry/ui/dialogs/ModsDialog.java @@ -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){