Skip to content

Commit

Permalink
Simplify: inline method (#12151)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanVanAtta authored Nov 29, 2023
1 parent a1bbd29 commit a676915
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package games.strategy.triplea;

import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.annotations.VisibleForTesting;
import games.strategy.engine.ClientFileSystemHelper;
import games.strategy.engine.framework.GameRunner;
Expand All @@ -25,7 +27,6 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.triplea.game.Exceptions;
import org.triplea.io.ImageLoader;
import org.triplea.io.PathUtils;
import org.triplea.java.UrlStreams;

Expand Down Expand Up @@ -75,8 +76,19 @@ public ResourceLoader(List<Path> assetPaths) {
* with the game are downloaded to this location. Check the gradle build file download images task
* for more information on what will be contained in that folder.
*/
public static Image loadImageAsset(final Path path) {
return ImageLoader.getImage(Path.of(ASSETS_FOLDER).resolve(path));
public static Image loadImageAsset(Path pathRelativeToAssetsFolder) {
Path imagePath = Path.of(ASSETS_FOLDER).resolve(pathRelativeToAssetsFolder);

checkArgument(
Files.exists(imagePath),
"File must exist at path: %s, "
+ "Build with the checked in launcher, or run gradle task 'downloadAssets'.",
imagePath.toAbsolutePath());
try {
return ImageIO.read(imagePath.toFile());
} catch (final IOException e) {
throw new RuntimeException("Unable to load image at path: " + imagePath.toAbsolutePath(), e);
}
}

private static class GameAssetsNotFoundException extends RuntimeException {
Expand Down
33 changes: 0 additions & 33 deletions lib/java-extras/src/main/java/org/triplea/io/ImageLoader.java

This file was deleted.

0 comments on commit a676915

Please sign in to comment.