< Summary

Class:LoadingHUDView
Assembly:LoadingHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingHUDView.cs
Covered lines:27
Uncovered lines:12
Coverable lines:39
Total lines:81
Line coverage:69.2% (27 of 39)
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        CommonScriptableObjects.isLoadingHUDOpen.Set(true);
 043        DataStore.i.HUDs.loadingHUD.fadeIn.Set(false);
 044        DataStore.i.HUDs.loadingHUD.fadeOut.Set(false);
 045        DataStore.i.HUDs.loadingHUD.visible.Set(true);
 046    }
 47
 48    public void SetVisible(bool isVisible, bool instant) {
 949        if (isVisible)
 50        {
 251            showHideAnimator.OnWillFinishStart += OnFinishStart;
 252            showHideAnimator.Show(instant);
 253        }
 54        else
 55        {
 756            showHideAnimator.OnWillFinishHide += OnFinishHide;
 757            showHideAnimator.Hide(instant);
 758            CommonScriptableObjects.isLoadingHUDOpen.Set(false);
 59        }
 760    }
 61
 3062    public void SetMessage(string message) { text.text = message; }
 2863    public void SetPercentage(float percentage) { loadingBar.transform.localScale = new Vector3(percentage, 1, 1); }
 64    public void SetTips(bool showTips)
 65    {
 1666        tipsContainer.gameObject.SetActive(showTips);
 1667        noTipsContainer.gameObject.SetActive(!showTips);
 1668    }
 69
 2670    private void OnDestroy() { isDestroyed = true; }
 71
 72    public void Dispose()
 73    {
 174        showHideAnimator.OnWillFinishHide -= OnFinishHide;
 175        showHideAnimator.OnWillFinishStart -= OnFinishStart;
 176        if (isDestroyed)
 077            return;
 178        isDestroyed = true;
 179        Destroy(gameObject);
 180    }
 81}