< Summary

Class:SpriteManager
Assembly:bamlab.micromissiles
File(s):/github/workspace/Assets/Scripts/UI/TacticalSymbol.cs
Covered lines:0
Uncovered lines:8
Coverable lines:8
Total lines:96
Line coverage:0% (0 of 8)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:1
Method coverage:0% (0 of 1)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LoadSymbolSprite(...)0%6200%

File(s)

/github/workspace/Assets/Scripts/UI/TacticalSymbol.cs

#LineLine coverage
 1using UnityEngine;
 2using TMPro;
 3using UnityEngine.UI;
 4public class TacticalSymbol : MonoBehaviour {
 5  [SerializeField]
 6  private GameObject _directionArrow;
 7  [SerializeField]
 8  private TextMeshProUGUI _uniqueDesignatorText;
 9  [SerializeField]
 10  private TextMeshProUGUI _iffText;
 11  [SerializeField]
 12  private TextMeshProUGUI _typeText;
 13  [SerializeField]
 14  private TextMeshProUGUI _speedAltText;
 15  [SerializeField]
 16  private TextMeshProUGUI _additionalInfoText;
 17
 18  private SpriteManager _spriteManager;
 19
 20  void Awake() {
 21    _spriteManager = new SpriteManager();
 22    _uniqueDesignatorText.text = "";
 23    _iffText.text = "";
 24    _typeText.text = "";
 25    _speedAltText.text = "";
 26    _additionalInfoText.text = "";
 27  }
 28
 29  public void SetDirectionArrowRotation(float rotationDegrees) {
 30    if (_directionArrow != null) {
 31      _directionArrow.GetComponent<RectTransform>().rotation =
 32          Quaternion.Euler(0, 0, rotationDegrees);
 33    }
 34  }
 35
 36  public void DisableDirectionArrow() {
 37    if (_directionArrow != null) {
 38      _directionArrow.SetActive(false);
 39    } else {
 40      Debug.LogWarning("Direction arrow not found on TacticalSymbol" + name);
 41    }
 42  }
 43
 44  public void SetSprite(string spriteName) {
 45    spriteName = spriteName.ToUpper();
 46    // Update main symbol image
 47    Image symbolImage = GetComponent<Image>();
 48    if (symbolImage != null) {
 49      Sprite symbolSprite = _spriteManager.LoadSymbolSprite(spriteName);
 50      if (symbolSprite != null) {
 51        symbolImage.sprite = symbolSprite;
 52      }
 53    }
 54  }
 55
 56  public void SetUniqueDesignator(string text) {
 57    SetText(_uniqueDesignatorText, text);
 58  }
 59
 60  public void SetIFF(string text) {
 61    SetText(_iffText, text);
 62  }
 63
 64  public void SetType(string text) {
 65    SetText(_typeText, text);
 66  }
 67
 68  public void SetSpeedAlt(string text) {
 69    SetText(_speedAltText, text);
 70  }
 71
 72  public void SetAdditionalInfo(string text) {
 73    SetText(_additionalInfoText, text);
 74  }
 75
 76  private void SetText(TextMeshProUGUI textComponent, string text) {
 77    if (textComponent != null) {
 78      textComponent.text = text.ToUpper();
 79    }
 80  }
 81
 82  void Update() {}
 83}
 84
 85public class SpriteManager {
 86  private const string SymbolPathFormat = "APP6-D_Symbology/{0}";
 87
 088  public Sprite LoadSymbolSprite(string symbolName) {
 089    string path = string.Format(SymbolPathFormat, symbolName);
 090    Sprite sprite = Resources.Load<Sprite>(path);
 091    if (sprite == null) {
 092      Debug.LogWarning($"Failed to load sprite at path: {path}");
 093    }
 094    return sprite;
 095  }
 96}

Methods/Properties

LoadSymbolSprite(System.String)