From 168011586bd35071cd4a820a929444891c250f8c Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 6 Sep 2019 22:09:54 -0400 Subject: [PATCH] More file chooser fixes --- android/AndroidManifest.xml | 25 +--------------------- core/assets/bundles/bundle.properties | 4 ++-- core/src/io/anuke/mindustry/maps/Maps.java | 21 +++++++++++++----- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 6e42e10a0c..a4202d4364 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -32,32 +32,9 @@ - - - - - - - - - + - - - - - - - - - - - - - diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 64da450d11..c451cfd568 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -233,7 +233,7 @@ editor.removeunit = Remove Unit editor.teams = Teams editor.errorload = Error loading file:\n[accent]{0} editor.errorsave = Error saving file:\n[accent]{0} -editor.errorimage = That's an image, not a map. Don't go around changing extensions expecting it to work.\n\nIf you want to import a legacy map, use the 'import legacy map' button in the editor. +editor.errorimage = That's an image, not a map.\n\nIf you want to import a 3.5/build 40 map, use the 'Import Legacy Map' button in the editor. editor.errorlegacy = This map is too old, and uses a legacy map format that is no longer supported. editor.errornot = This is not a map file. editor.errorheader = This map file is either not valid or corrupt. @@ -254,7 +254,7 @@ editor.importmap = Import Map editor.importmap.description = Import an already existing map editor.importfile = Import File editor.importfile.description = Import an external map file -editor.importimage = Import Legacy Image +editor.importimage = Import Legacy Map editor.importimage.description = Import an external map image file editor.export = Export... editor.exportfile = Export File diff --git a/core/src/io/anuke/mindustry/maps/Maps.java b/core/src/io/anuke/mindustry/maps/Maps.java index bfd32b7a02..d751f5fc7d 100644 --- a/core/src/io/anuke/mindustry/maps/Maps.java +++ b/core/src/io/anuke/mindustry/maps/Maps.java @@ -184,7 +184,18 @@ public class Maps{ FileHandle dest = findFile(); file.copyTo(dest); - createNewPreview(loadMap(dest, true)); + Map map = loadMap(dest, true); + Exception[] error = {null}; + + createNewPreview(map, e -> { + maps.remove(map); + error[0] = e; + }); + + if(error[0] != null){ + throw new IOException(error[0]); + } + } /** Attempts to run the following code; @@ -313,7 +324,7 @@ public class Maps{ private void createAllPreviews(){ Core.app.post(() -> { for(Map map : previewList){ - createNewPreview(map); + createNewPreview(map, e -> Core.app.post(() -> map.texture = new Texture("sprites/error.png"))); } previewList.clear(); }); @@ -323,7 +334,7 @@ public class Maps{ Core.app.post(() -> previewList.add(map)); } - private void createNewPreview(Map map){ + private void createNewPreview(Map map, Consumer failed){ try{ //if it's here, then the preview failed to load or doesn't exist, make it //this has to be done synchronously! @@ -337,9 +348,9 @@ public class Maps{ e.printStackTrace(); } }); - }catch(IOException e){ + }catch(Exception e){ + failed.accept(e); Log.err("Failed to generate preview!", e); - Core.app.post(() -> map.texture = new Texture("sprites/error.png")); } }