diff --git a/src/itdelatrisu/opsu/GameImage.java b/src/itdelatrisu/opsu/GameImage.java index 21d10812..de479156 100644 --- a/src/itdelatrisu/opsu/GameImage.java +++ b/src/itdelatrisu/opsu/GameImage.java @@ -461,6 +461,37 @@ public enum GameImage { } } + public static void destroyAll() { + for (GameImage img : GameImage.values()) { + destroyAll(img.defaultImages); + destroyImage(img.defaultImage); + destroyAll(img.skinImages); + destroyImage(img.skinImage); + img.isSkinned = false; + img.defaultImages = img.skinImages = null; + img.defaultImage = img.skinImage = null; + } + } + + public static void destroyAll(Image[] imgs) { + if (imgs == null) { + return; + } + for (Image i : imgs) { + destroyImage(i); + } + } + + public static void destroyImage(Image image) { + if (image == null) { + return; + } + try { + image.destroy(); + } catch (SlickException ignored) { + } + } + /** * Returns the bitmask image type from a type string. * @param type the type string diff --git a/src/yugecin/opsudance/core/DisplayContainer.java b/src/yugecin/opsudance/core/DisplayContainer.java index ee8912d7..4ede5648 100644 --- a/src/yugecin/opsudance/core/DisplayContainer.java +++ b/src/yugecin/opsudance/core/DisplayContainer.java @@ -212,6 +212,8 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen } public void teardown() { + InternalTextureLoader.get().clear(); + GameImage.destroyAll(); Display.destroy(); }