| 10 | import forge.util.ImageFetcher; |
| 11 | |
| 12 | public abstract class CachedCardImage implements ImageFetcher.Callback { |
| 13 | protected final String key; |
| 14 | static final ImageFetcher fetcher = GuiBase.getInterface().getImageFetcher(); |
| 15 | |
| 16 | public CachedCardImage(final CardView card) { |
| 17 | key = card.getCurrentState().getImageKey(MatchController.instance.getLocalPlayers()); |
| 18 | fetch(); |
| 19 | } |
| 20 | |
| 21 | public CachedCardImage(final InventoryItem ii) { |
| 22 | key = ii.getImageKey(false); |
| 23 | fetch(); |
| 24 | } |
| 25 | |
| 26 | public CachedCardImage(String key) { |
| 27 | this.key = key; |
| 28 | fetch(); |
| 29 | } |
| 30 | |
| 31 | public void fetch() { |
| 32 | if (!ImageCache.getInstance().imageKeyFileExists(key)) { |
| 33 | fetcher.fetchImage(key, this); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | public Texture getImage() { |
| 38 | return ImageCache.getInstance().getImage(key, true); |
| 39 | } |
| 40 | |
| 41 | public Texture getImage(String mykey) { |
| 42 | return ImageCache.getInstance().getImage(mykey, true); |
| 43 | } |
| 44 | |
| 45 | public abstract void onImageFetched(); |
| 46 | } |
nothing calls this directly
no test coverage detected