< Summary

Class:SceneLimitsView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/Inspector/SceneLimitsView.cs
Covered lines:16
Uncovered lines:9
Coverable lines:25
Total lines:108
Line coverage:64% (16 of 25)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Awake()0%110100%
Update()0%6200%
OnDestroy()0%110100%
SetUpdateCallback(...)0%2100%
ToggleSceneLimitsInfo(...)0%220100%
SetBodyActive(...)0%110100%
SetDetailsToggleAsOpen()0%110100%
SetDetailsToggleAsClose()0%110100%
SetTitleText(...)0%110100%
SetLeftDescText(...)0%110100%
SetRightDescText(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/Inspector/SceneLimitsView.cs

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.Events;
 5using UnityEngine.UI;
 6
 7public interface ISceneLimitsView
 8{
 9    Color lfColor { get; }
 10    Color mfColor { get; }
 11    Color hfColor { get; }
 12    Image[] limitUsageFillsImages { get; }
 13
 14    bool isBodyActived { get; }
 15
 16    event Action OnToggleSceneLimitsInfo;
 17
 18    void SetBodyActive(bool isActive);
 19    void SetDetailsToggleAsClose();
 20    void SetDetailsToggleAsOpen();
 21    void SetLeftDescText(string text);
 22    void SetRightDescText(string text);
 23    void SetTitleText(string text);
 24    void SetUpdateCallback(UnityAction call);
 25    void ToggleSceneLimitsInfo(DCLAction_Trigger action);
 26}
 27
 28public class SceneLimitsView : MonoBehaviour, ISceneLimitsView
 29{
 30    private const int FRAMES_BETWEEN_UPDATES = 15;
 31
 032    public Color lfColor => lowFillColor;
 033    public Color mfColor => mediumFillColor;
 034    public Color hfColor => highFillColor;
 035    public Image[] limitUsageFillsImages => limitUsageFillsImgs;
 36
 37    public event Action OnToggleSceneLimitsInfo;
 38
 39    [Header("Sprites")]
 40    [SerializeField] internal Sprite openMenuSprite;
 41    [SerializeField] internal Sprite closeMenuSprite;
 42
 43    [Header("Design")]
 44    [SerializeField] internal Color lowFillColor;
 45    [SerializeField] internal Color mediumFillColor;
 46    [SerializeField] internal Color highFillColor;
 47
 48    [Header("Scene references")]
 49    [SerializeField] internal Image detailsToggleBtn;
 50    [SerializeField] internal GameObject sceneLimitsBodyGO;
 51    [SerializeField] internal TextMeshProUGUI titleTxt;
 52    [SerializeField] internal TextMeshProUGUI leftDescTxt;
 53    [SerializeField] internal TextMeshProUGUI rightDescTxt;
 54    [SerializeField] internal Image[] limitUsageFillsImgs;
 55    [SerializeField] internal Button toggleButton;
 56
 57    [Header("Input Actions")]
 58    [SerializeField] internal InputAction_Trigger toggleSceneInfoInputAction;
 59
 060    public bool isBodyActived => sceneLimitsBodyGO.activeSelf;
 61
 62    private DCLAction_Trigger dummyActionTrigger = new DCLAction_Trigger();
 63    internal UnityAction updateInfoAction;
 64
 65    private const string VIEW_PATH = "GodMode/Inspector/SceneLimitsView";
 66
 67    internal static SceneLimitsView Create()
 68    {
 969        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<SceneLimitsView>();
 970        view.gameObject.name = "_SceneLimitsView";
 71
 972        return view;
 73    }
 74
 75    private void Awake()
 76    {
 1777        toggleSceneInfoInputAction.OnTriggered += ToggleSceneLimitsInfo;
 1778        toggleButton.onClick.AddListener(() => ToggleSceneLimitsInfo(dummyActionTrigger));
 1779    }
 80
 81    private void Update()
 82    {
 083        if (Time.frameCount % FRAMES_BETWEEN_UPDATES == 0)
 084            updateInfoAction();
 085    }
 86
 87    private void OnDestroy()
 88    {
 1789        toggleSceneInfoInputAction.OnTriggered -= ToggleSceneLimitsInfo;
 1790        toggleButton.onClick.RemoveAllListeners();
 1791    }
 92
 093    public void SetUpdateCallback(UnityAction call) { updateInfoAction = call; }
 94
 295    public void ToggleSceneLimitsInfo(DCLAction_Trigger action) { OnToggleSceneLimitsInfo?.Invoke(); }
 96
 497    public void SetBodyActive(bool isActive) { sceneLimitsBodyGO.SetActive(isActive); }
 98
 299    public void SetDetailsToggleAsOpen() { detailsToggleBtn.sprite = openMenuSprite; }
 100
 2101    public void SetDetailsToggleAsClose() { detailsToggleBtn.sprite = closeMenuSprite; }
 102
 2103    public void SetTitleText(string text) { titleTxt.text = text; }
 104
 2105    public void SetLeftDescText(string text) { leftDescTxt.text = text; }
 106
 2107    public void SetRightDescText(string text) { rightDescTxt.text = text; }
 108}