< Summary

Class:LoadingHUDView
Assembly:LoadingHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingHUDView.cs
Covered lines:26
Uncovered lines:11
Coverable lines:37
Total lines:79
Line coverage:70.2% (26 of 37)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CreateView()0%110100%
Initialize()0%110100%
OnFinishHide(...)0%2100%
OnFinishStart(...)0%2100%
SetVisible(...)0%220100%
SetMessage(...)0%110100%
SetPercentage(...)0%110100%
SetTips(...)0%110100%
OnDestroy()0%110100%
Dispose()0%2.012085.71%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingHUDView.cs

#LineLine coverage
 1using System;
 2using DCL;
 3using TMPro;
 4using UnityEngine;
 5using UnityEngine.UI;
 6
 7public class LoadingHUDView : MonoBehaviour
 8{
 9    [SerializeField] internal TextMeshProUGUI text;
 10    [SerializeField] internal Image loadingBar;
 11    [SerializeField] internal GameObject tipsContainer;
 12    [SerializeField] internal GameObject noTipsContainer;
 13    [SerializeField] internal ShowHideAnimator showHideAnimator;
 14
 15    private bool isDestroyed = false;
 16
 17    public static LoadingHUDView CreateView()
 18    {
 619        LoadingHUDView view = Instantiate(Resources.Load<GameObject>("LoadingHUD")).GetComponent<LoadingHUDView>();
 620        view.gameObject.name = "_LoadingHUD";
 621        return view;
 22    }
 23
 24    public void Initialize()
 25    {
 726        SetMessage("");
 727        SetPercentage(0);
 728        SetTips(false);
 729    }
 30
 31    private void OnFinishHide(ShowHideAnimator obj)
 32    {
 033        showHideAnimator.OnWillFinishHide -= OnFinishHide;
 034        DataStore.i.HUDs.loadingHUD.fadeIn.Set(false);
 035        DataStore.i.HUDs.loadingHUD.fadeOut.Set(false);
 036        DataStore.i.HUDs.loadingHUD.visible.Set(false);
 037    }
 38
 39    private void OnFinishStart(ShowHideAnimator obj)
 40    {
 041        showHideAnimator.OnWillFinishStart -= OnFinishStart;
 042        DataStore.i.HUDs.loadingHUD.fadeIn.Set(false);
 043        DataStore.i.HUDs.loadingHUD.fadeOut.Set(false);
 044        DataStore.i.HUDs.loadingHUD.visible.Set(true);
 045    }
 46
 47    public void SetVisible(bool isVisible, bool instant) {
 948        if (isVisible)
 49        {
 250            showHideAnimator.OnWillFinishStart += OnFinishStart;
 251            showHideAnimator.Show(instant);
 252        }
 53        else
 54        {
 755            showHideAnimator.OnWillFinishHide += OnFinishHide;
 756            showHideAnimator.Hide(instant);
 57        }
 758    }
 59
 3060    public void SetMessage(string message) { text.text = message; }
 2861    public void SetPercentage(float percentage) { loadingBar.transform.localScale = new Vector3(percentage, 1, 1); }
 62    public void SetTips(bool showTips)
 63    {
 1664        tipsContainer.gameObject.SetActive(showTips);
 1665        noTipsContainer.gameObject.SetActive(!showTips);
 1666    }
 67
 2668    private void OnDestroy() { isDestroyed = true; }
 69
 70    public void Dispose()
 71    {
 172        showHideAnimator.OnWillFinishHide -= OnFinishHide;
 173        showHideAnimator.OnWillFinishStart -= OnFinishStart;
 174        if (isDestroyed)
 075            return;
 176        isDestroyed = true;
 177        Destroy(gameObject);
 178    }
 79}