< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Payload()0%2100%
SetLoadingScreen(...)0%72800%
FadeInLoadingHUD(...)0%6200%
WaitForLoadingHUDVisible()0%30500%

File(s)

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

#LineLine coverage
 1using DCL;
 2using DCL.Interface;
 3using System;
 4using System.Collections;
 5using UnityEngine;
 6
 7public class LoadingBridge : MonoBehaviour
 8{
 9    private readonly DataStoreRef<DataStore_LoadingScreen> dataStoreLoadingScreen;
 010    private bool isDecoupledLoadingScreenEnabled => DataStore.i.featureFlags.flags.Get().IsFeatureEnabled(DataStore.i.fe
 11
 12    [Serializable]
 13    public class Payload
 14    {
 15        public bool isVisible;
 016        public string message = "";
 17        public bool showTips;
 18    }
 19
 20    [Serializable]
 21    public class PayloadCoords
 22    {
 23        public int xCoord;
 24        public int yCoord;
 25        public string message;
 26    }
 27
 28    [Obsolete]
 29    public void SetLoadingScreen(string jsonMessage)
 30    {
 031        if (isDecoupledLoadingScreenEnabled) return;
 32
 033        Payload payload = JsonUtility.FromJson<Payload>(jsonMessage);
 34
 035        if (payload.isVisible && !dataStoreLoadingScreen.Ref.loadingHUD.fadeIn.Get() && !dataStoreLoadingScreen.Ref.load
 036            dataStoreLoadingScreen.Ref.loadingHUD.fadeIn.Set(true);
 37
 038        if (!payload.isVisible && !dataStoreLoadingScreen.Ref.loadingHUD.fadeOut.Get())
 039            dataStoreLoadingScreen.Ref.loadingHUD.fadeOut.Set(true);
 40
 041        if (!string.IsNullOrEmpty(payload.message))
 042            dataStoreLoadingScreen.Ref.loadingHUD.message.Set(payload.message);
 43
 044        dataStoreLoadingScreen.Ref.loadingHUD.showTips.Set(payload.showTips);
 045    }
 46
 47    [Obsolete]
 48    public void FadeInLoadingHUD(string jsonMessage)
 49    {
 050        if (isDecoupledLoadingScreenEnabled) return;
 51
 52        //TODO: Logic to be cleaned by the RFC-1
 053        StartCoroutine(WaitForLoadingHUDVisible(jsonMessage));
 054    }
 55
 56    private IEnumerator WaitForLoadingHUDVisible(string jsonMessage)
 57    {
 58        //TODO: Logic to be cleaned by the RFC-1
 059        WebInterface.ReportControlEvent(new WebInterface.DeactivateRenderingACK());
 60
 061        PayloadCoords payload = JsonUtility.FromJson<PayloadCoords>(jsonMessage);
 62
 063        if (!string.IsNullOrEmpty(payload.message))
 064            dataStoreLoadingScreen.Ref.loadingHUD.message.Set(payload.message);
 65        else
 066            dataStoreLoadingScreen.Ref.loadingHUD.message.Set("Teleporting to " + payload.xCoord + ", " + payload.yCoord
 67
 068        dataStoreLoadingScreen.Ref.loadingHUD.percentage.Set(0);
 069        dataStoreLoadingScreen.Ref.loadingHUD.fadeIn.Set(true);
 70
 071        while (!dataStoreLoadingScreen.Ref.loadingHUD.visible.Get())
 072            yield return null;
 73
 074        WebInterface.LoadingHUDReadyForTeleport(payload.xCoord, payload.yCoord);
 075    }
 76}