| 62 | import static forge.assets.FSkin.getDefaultSkinFile; |
| 63 | |
| 64 | public class CardRenderer { |
| 65 | public enum CardStackPosition { |
| 66 | Top, |
| 67 | BehindHorz, |
| 68 | BehindVert |
| 69 | } |
| 70 | |
| 71 | /** Pref is normalized to 6 hex chars on the write side; this just parses, |
| 72 | * falling back to the FPref default if the stored value is malformed. */ |
| 73 | private static Color parseActionableHighlightColor() { |
| 74 | String s = FModel.getPreferences().getPref(FPref.UI_ACTIONABLE_HIGHLIGHT_COLOR); |
| 75 | try { |
| 76 | if (s != null && s.length() == 6) return rgbFromHex(s); |
| 77 | } catch (NumberFormatException ignored) {} |
| 78 | return rgbFromHex(FPref.UI_ACTIONABLE_HIGHLIGHT_COLOR.getDefault()); |
| 79 | } |
| 80 | |
| 81 | private static Color rgbFromHex(String s) { |
| 82 | int r = Integer.parseInt(s.substring(0, 2), 16); |
| 83 | int g = Integer.parseInt(s.substring(2, 4), 16); |
| 84 | int b = Integer.parseInt(s.substring(4, 6), 16); |
| 85 | return FSkinColor.fromRGB(r, g, b); |
| 86 | } |
| 87 | |
| 88 | // class that simplifies the callback logic of CachedCardImage |
| 89 | static class RendererCachedCardImage extends CachedCardImage { |
| 90 | boolean clearcardArtCache = false; |
| 91 | |
| 92 | public RendererCachedCardImage(CardView card, boolean clearArtCache) { |
| 93 | super(card); |
| 94 | this.clearcardArtCache = clearArtCache; |
| 95 | } |
| 96 | |
| 97 | public RendererCachedCardImage(InventoryItem ii, boolean clearArtCache) { |
| 98 | super(ii); |
| 99 | this.clearcardArtCache = clearArtCache; |
| 100 | } |
| 101 | |
| 102 | public RendererCachedCardImage(String key, boolean clearArtCache) { |
| 103 | super(key); |
| 104 | this.clearcardArtCache = clearArtCache; |
| 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public void onImageFetched() { |
| 109 | ImageCache.getInstance().clear(); |
| 110 | if (clearcardArtCache) { |
| 111 | clearcardArtCache(); |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | private static float calcSymbolSize(FSkinProp skinProp) { |
| 117 | if (skinProp == null) |
| 118 | return 0f; |
| 119 | FSkinImageInterface image = FSkin.getImages().get(skinProp); |
| 120 | if (image == null) |
| 121 | return 0f; |
nothing calls this directly
no test coverage detected