< Summary

Class:LoadingHUDView
Assembly:LoadingHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingHUDView.cs
Covered lines:37
Uncovered lines:1
Coverable lines:38
Total lines:82
Line coverage:97.3% (37 of 38)
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%110100%
OnFinishStart(...)0%110100%
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    private readonly DataStoreRef<DataStore_LoadingScreen> dataStoreLoadingScreen;
 15
 16    private bool isDestroyed = false;
 17
 18    public static LoadingHUDView CreateView()
 19    {
 620        LoadingHUDView view = Instantiate(Resources.Load<GameObject>("LoadingHUD")).GetComponent<LoadingHUDView>();
 621        view.gameObject.name = "_LoadingHUD";
 622        return view;
 23    }
 24
 25    public void Initialize()
 26    {
 727        SetMessage("");
 728        SetPercentage(0);
 729        SetTips(false);
 730    }
 31
 32    private void OnFinishHide(ShowHideAnimator obj)
 33    {
 634        showHideAnimator.OnWillFinishHide -= OnFinishHide;
 635        dataStoreLoadingScreen.Ref.loadingHUD.fadeIn.Set(false);
 636        dataStoreLoadingScreen.Ref.loadingHUD.fadeOut.Set(false);
 637        dataStoreLoadingScreen.Ref.loadingHUD.visible.Set(false);
 638    }
 39
 40    private void OnFinishStart(ShowHideAnimator obj)
 41    {
 242        showHideAnimator.OnWillFinishStart -= OnFinishStart;
 243        CommonScriptableObjects.isLoadingHUDOpen.Set(true);
 244        dataStoreLoadingScreen.Ref.loadingHUD.fadeIn.Set(false);
 245        dataStoreLoadingScreen.Ref.loadingHUD.fadeOut.Set(false);
 246        dataStoreLoadingScreen.Ref.loadingHUD.visible.Set(true);
 247    }
 48
 49    public void SetVisible(bool isVisible, bool instant) {
 950        if (isVisible)
 51        {
 252            showHideAnimator.OnWillFinishStart += OnFinishStart;
 253            showHideAnimator.Show(instant);
 54        }
 55        else
 56        {
 757            showHideAnimator.OnWillFinishHide += OnFinishHide;
 758            showHideAnimator.Hide(instant);
 759            CommonScriptableObjects.isLoadingHUDOpen.Set(false);
 60        }
 761    }
 62
 3063    public void SetMessage(string message) { text.text = message; }
 2864    public void SetPercentage(float percentage) { loadingBar.transform.localScale = new Vector3(percentage, 1, 1); }
 65    public void SetTips(bool showTips)
 66    {
 1667        tipsContainer.gameObject.SetActive(showTips);
 1668        noTipsContainer.gameObject.SetActive(!showTips);
 1669    }
 70
 2671    private void OnDestroy() { isDestroyed = true; }
 72
 73    public void Dispose()
 74    {
 175        showHideAnimator.OnWillFinishHide -= OnFinishHide;
 176        showHideAnimator.OnWillFinishStart -= OnFinishStart;
 177        if (isDestroyed)
 078            return;
 179        isDestroyed = true;
 180        Destroy(gameObject);
 181    }
 82}