From 3d9c9e639d110a1c7599f13c2c0ba233ff892577 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 9 Jul 2018 11:24:24 -0400 Subject: [PATCH] Automatic external bundle loading --- core/src/io/anuke/mindustry/Vars.java | 2 +- .../io/anuke/mindustry/io/BundleLoader.java | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 6731aed1dc..d98a9c7d50 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -168,7 +168,7 @@ public class Vars{ for(EntityGroup group : Entities.getAllGroups()){ group.setRemoveListener(entity -> { if(entity instanceof SyncTrait && Net.client()){ - netClient.addRemovedEntity(((SyncTrait) entity).getID()); + netClient.addRemovedEntity((entity).getID()); } }); } diff --git a/core/src/io/anuke/mindustry/io/BundleLoader.java b/core/src/io/anuke/mindustry/io/BundleLoader.java index 1133360838..aa786fd9d2 100644 --- a/core/src/io/anuke/mindustry/io/BundleLoader.java +++ b/core/src/io/anuke/mindustry/io/BundleLoader.java @@ -3,9 +3,10 @@ package io.anuke.mindustry.io; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.I18NBundle; -import io.anuke.mindustry.core.Platform; +import io.anuke.mindustry.Vars; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Settings; +import io.anuke.ucore.core.Timers; import io.anuke.ucore.util.Log; import java.util.Locale; @@ -13,7 +14,6 @@ import java.util.Locale; import static io.anuke.mindustry.Vars.headless; public class BundleLoader { - private static final boolean externalBundle = false; public static void load(){ Settings.defaults("locale", "default"); @@ -40,20 +40,20 @@ public class BundleLoader { private static void loadBundle(){ I18NBundle.setExceptionOnMissingKey(false); + try { + //try loading external bundle + FileHandle handle = Gdx.files.local("bundle"); - if(externalBundle){ - try { - FileHandle handle = Gdx.files.local("bundle"); + Locale locale = Locale.ENGLISH; + Core.bundle = I18NBundle.createBundle(handle, locale); - Locale locale = Locale.ENGLISH; - Core.bundle = I18NBundle.createBundle(handle, locale); - }catch (Exception e){ - Log.err(e); - Platform.instance.showError("Failed to find bundle!\nMake sure you have bundle.properties in the same directory\nas the jar file.\n\nIf the problem persists, try running it through the command prompt:\n" + - "Hold left-shift, then right click and select 'open command prompt here'.\nThen, type in 'java -jar mindustry.jar' without quotes."); - Gdx.app.exit(); + Log.info("NOTE: external translation bundle has been loaded."); + if(!headless){ + Timers.run(10f, () -> Vars.ui.showInfo("Note: You have successfully loaded an external translation bundle.")); } - }else{ + }catch (Throwable e){ + //no external bundle found + FileHandle handle = Gdx.files.internal("bundles/bundle"); Locale locale = getLocale(); @@ -61,5 +61,6 @@ public class BundleLoader { if(!headless) Log.info("Got locale: {0}", locale); Core.bundle = I18NBundle.createBundle(handle, locale); } + } }