|
| 1 | +using DiskCardGame; |
| 2 | +using InscryptionAPI.Helpers; |
| 3 | +using UnityEngine; |
| 4 | + |
| 5 | +namespace InscryptionAPI.Ascension; |
| 6 | + |
| 7 | +public static partial class StarterDeckExtensions |
| 8 | +{ |
| 9 | + #region iconTexture |
| 10 | + /// <summary> |
| 11 | + /// Sets the icon texture for the starter deck. |
| 12 | + /// </summary> |
| 13 | + /// <param name="info">StarterDeckInfo to access.</param> |
| 14 | + /// <param name="pathToArt">The path to the .png file containing the artwork (relative to the Plugins directory).</param> |
| 15 | + /// <returns>The same StarterDeckInfo so a chain can continue.</returns> |
| 16 | + public static StarterDeckInfo SetIconTexture(this StarterDeckInfo info, string pathToArt) |
| 17 | + { |
| 18 | + try |
| 19 | + { |
| 20 | + return info.SetIconTexture(TextureHelper.GetImageAsTexture(pathToArt)); |
| 21 | + } |
| 22 | + catch (FileNotFoundException fnfe) |
| 23 | + { |
| 24 | + throw new ArgumentException($"Image file not found for card \"{info.name}\"!", fnfe); |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + /// <summary> |
| 29 | + /// Sets the icon texture for the starter deck. |
| 30 | + /// </summary> |
| 31 | + /// <param name="info">StarterDeckInfo to access.</param> |
| 32 | + /// <param name="portrait">The texture containing the emission.</param> |
| 33 | + /// <param name="filterMode">The filter mode for the texture, or null if no change.</param> |
| 34 | + /// <returns>The same StarterDeckInfo so a chain can continue.</returns> |
| 35 | + public static StarterDeckInfo SetIconTexture(this StarterDeckInfo info, Texture2D portrait, FilterMode? filterMode = null) |
| 36 | + { |
| 37 | + return info.SetIconTexture(GetPortrait(portrait, TextureHelper.SpriteType.CardPortrait, filterMode)); |
| 38 | + } |
| 39 | + |
| 40 | + /// <summary> |
| 41 | + /// Sets the icon texture for the starter deck. |
| 42 | + /// </summary> |
| 43 | + /// <param name="info">StarterDeckInfo to access.</param> |
| 44 | + /// <param name="sprite">The sprite containing the emission.</param> |
| 45 | + /// <returns>The same StarterDeckInfo so a chain can continue.</returns> |
| 46 | + public static StarterDeckInfo SetIconTexture(this StarterDeckInfo info, Sprite sprite) |
| 47 | + { |
| 48 | + if (info.iconSprite == null) |
| 49 | + throw new InvalidOperationException($"Cannot set emissive portrait before setting normal portrait!"); |
| 50 | + |
| 51 | + info.iconSprite.RegisterEmissionForSprite(sprite); |
| 52 | + |
| 53 | + return info; |
| 54 | + } |
| 55 | + #endregion |
| 56 | +} |
0 commit comments