diff --git a/src/nortantis/MapSettings.java b/src/nortantis/MapSettings.java index c848496..ebb0578 100644 --- a/src/nortantis/MapSettings.java +++ b/src/nortantis/MapSettings.java @@ -1472,7 +1472,7 @@ public boolean equalsIgnoringEdits(MapSettings other) * @return Piece 1 - The path Piece 2 - An optional warning message. */ public Tuple2 getBackgroundImagePath() - { + { if (backgroundTextureSource == TextureSource.File && StringUtils.isEmpty(backgroundTextureImage)) { return new Tuple2<>(Assets.getBackgroundTextureResourcePath(backgroundTextureResource, customImagesPath), diff --git a/src/nortantis/swing/IconsTool.java b/src/nortantis/swing/IconsTool.java index f5e6518..146f18a 100644 --- a/src/nortantis/swing/IconsTool.java +++ b/src/nortantis/swing/IconsTool.java @@ -5,6 +5,7 @@ import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; @@ -731,10 +732,11 @@ private Image createIconPreview(MapSettings settings, List images, int sc Image previewImage; + Path backgroundImagePath = settings.getBackgroundImagePath().getFirst(); Tuple4 tuple = ThemePanel .createBackgroundImageDisplaysImages(size, settings.backgroundRandomSeed, settings.colorizeOcean, settings.colorizeLand, settings.generateBackground, settings.generateBackgroundFromTexture, - settings.getBackgroundImagePath().getFirst().toString()); + backgroundImagePath == null ? null : backgroundImagePath.toString()); if (iconType == IconType.decorations) { previewImage = tuple.getFirst(); diff --git a/src/nortantis/util/Assets.java b/src/nortantis/util/Assets.java index 988f674..ac9f5db 100644 --- a/src/nortantis/util/Assets.java +++ b/src/nortantis/util/Assets.java @@ -185,6 +185,11 @@ public static Path getBackgroundTextureResourcePath(NamedResource resource, Stri { return null; } + if (StringUtils.isEmpty(resource.name) || StringUtils.isEmpty(resource.artPack)) + { + // I don't know how, but in a stack trace of a crash I found that resource.name was null, so I'm adding this to be safe. + return null; + } Path artPackPath = getArtPackPath(resource.artPack, customImagesFolder); if (artPackPath == null) { diff --git a/test/nortantis/test/MapCreatorTest.java b/test/nortantis/test/MapCreatorTest.java index a02d39b..fc89f00 100644 --- a/test/nortantis/test/MapCreatorTest.java +++ b/test/nortantis/test/MapCreatorTest.java @@ -238,31 +238,31 @@ public void iconReplacementsWithMissingIconTypes() }).getWarningMessages(); assertTrue(warnings.contains( - "The art pack 'custom' no longer has tree images, so it does not have tree the image group 'pine'. The art pack 'nortantis' will be used instead because it has the same image group folder name. These trees are not visible because they were drawn at low density, but may become visible if you change the tree height in the Effects tab.")); + "The art pack 'custom' no longer has tree images, so it does not have the tree image group 'pine'. The art pack 'nortantis' will be used instead because it has the same image group folder name. These trees are not visible because they were drawn at low density, but may become visible if you change the tree height in the Effects tab.")); assertTrue(warnings.contains( - "The art pack 'custom' no longer has tree images, so it does not have tree the image group 'generated deciduous 6'. The art pack 'nortantis' will be used instead because it has tree images. These trees are not visible because they were drawn at low density, but may become visible if you change the tree height in the Effects tab.")); + "The art pack 'custom' no longer has tree images, so it does not have the tree image group 'generated deciduous 6'. The art pack 'nortantis' will be used instead because it has tree images. These trees are not visible because they were drawn at low density, but may become visible if you change the tree height in the Effects tab.")); assertTrue(warnings.contains( "Unable to find the tree image group 'generated deciduous 6' in art pack 'nortantis'. The group 'original pine' in that art pack will be used instead. These trees are not visible because they were drawn at low density, but may become visible if you change the tree height in the Effects tab.")); assertTrue(warnings.contains( - "The art pack 'custom' no longer has mountain images, so it does not have mountain the image group 'jagged'. The art pack 'nortantis' will be used instead because it has mountain images.")); + "The art pack 'custom' no longer has mountain images, so it does not have the mountain image group 'jagged'. The art pack 'nortantis' will be used instead because it has mountain images.")); assertTrue(warnings.contains( "Unable to find the mountain image group 'jagged' in art pack 'nortantis'. The group 'round' in that art pack will be used instead.")); assertTrue(warnings.contains( - "The art pack 'custom' no longer has hill images, so it does not have hill the image group 'jagged'. The art pack 'nortantis' will be used instead because it has hill images.")); + "The art pack 'custom' no longer has hill images, so it does not have the hill image group 'jagged'. The art pack 'nortantis' will be used instead because it has hill images.")); assertTrue(warnings.contains( "Unable to find the hill image group 'jagged' in art pack 'nortantis'. The group 'round' in that art pack will be used instead.")); assertTrue(warnings.contains( - "The art pack 'custom' no longer has sand images, so it does not have sand the image group 'dunes'. The art pack 'nortantis' will be used instead because it has the same image group folder name.")); + "The art pack 'custom' no longer has sand images, so it does not have the sand image group 'dunes'. The art pack 'nortantis' will be used instead because it has the same image group folder name.")); assertTrue(warnings.contains( - "The art pack 'custom' no longer has hill images, so it does not have hill the image group 'sharp'. The art pack 'nortantis' will be used instead because it has the same image group folder name.")); + "The art pack 'custom' no longer has hill images, so it does not have the hill image group 'sharp'. The art pack 'nortantis' will be used instead because it has the same image group folder name.")); assertTrue(warnings.contains( - "The art pack 'custom' no longer has tree images, so it does not have tree the image group 'generated deciduous 6'. The art pack 'nortantis' will be used instead because it has tree images.")); + "The art pack 'custom' no longer has tree images, so it does not have the tree image group 'generated deciduous 6'. The art pack 'nortantis' will be used instead because it has tree images.")); assertTrue(warnings.contains( "Unable to find the tree image group 'generated deciduous 6' in art pack 'nortantis'. The group 'original pine' in that art pack will be used instead.")); assertTrue(warnings.contains( - "The art pack 'custom' no longer has tree images, so it does not have tree the image group 'pine'. The art pack 'nortantis' will be used instead because it has the same image group folder name.")); + "The art pack 'custom' no longer has tree images, so it does not have the tree image group 'pine'. The art pack 'nortantis' will be used instead because it has the same image group folder name.")); assertTrue(warnings.contains( - "The art pack 'custom' no longer has mountain images, so it does not have mountain the image group 'sharp'. The art pack 'nortantis' will be used instead because it has the same image group folder name.")); + "The art pack 'custom' no longer has mountain images, so it does not have the mountain image group 'sharp'. The art pack 'nortantis' will be used instead because it has the same image group folder name.")); assertTrue(warnings.contains( "The art pack 'custom' no longer has decoration images, so it does not have the icon 'compass 1 ' from decoration image group 'compasses'. The art pack 'nortantis' will be used instead because it has the same image group folder and image name.")); assertTrue(warnings.contains(