< 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:24
Coverable lines:24
Total lines:70
Line coverage:0% (0 of 24)
Covered branches:0
Total branches:0

Metrics

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

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using DCL;
 4using DCL.Interface;
 5using UnityEngine;
 6
 7public class LoadingBridge : MonoBehaviour
 8{
 9    [Serializable]
 10    public class Payload
 11    {
 12        public bool isVisible = false;
 013        public string message = "";
 14        public bool showTips = false;
 15    }
 16
 17    [Serializable]
 18    public class PayloadCoords
 19    {
 20        public int xCoord;
 21        public int yCoord;
 22        public string message;
 23    }
 24
 25    public void SetLoadingScreen(string jsonMessage)
 26    {
 027        Payload payload = JsonUtility.FromJson<Payload>(jsonMessage);
 28
 029        if (payload.isVisible && !DataStore.i.HUDs.loadingHUD.fadeIn.Get() && !DataStore.i.HUDs.loadingHUD.visible.Get()
 030            DataStore.i.HUDs.loadingHUD.fadeIn.Set(true);
 31
 032        if (!payload.isVisible && !DataStore.i.HUDs.loadingHUD.fadeOut.Get())
 033            DataStore.i.HUDs.loadingHUD.fadeOut.Set(true);
 34
 035        if (!string.IsNullOrEmpty(payload.message))
 036            DataStore.i.HUDs.loadingHUD.message.Set(payload.message);
 037        DataStore.i.HUDs.loadingHUD.showTips.Set(payload.showTips);
 038    }
 39
 40    public void FadeInLoadingHUD(string jsonMessage)
 41    {
 42        //TODO: Logic to be cleaned by the RFC-1
 043        StartCoroutine(WaitForLoadingHUDVisible(jsonMessage));
 044    }
 45
 46    IEnumerator WaitForLoadingHUDVisible(string jsonMessage)
 47    {
 48        //TODO: Logic to be cleaned by the RFC-1
 049        WebInterface.ReportControlEvent(new WebInterface.DeactivateRenderingACK());
 50
 051        PayloadCoords payload = JsonUtility.FromJson<PayloadCoords>(jsonMessage);
 052        if (!string.IsNullOrEmpty(payload.message))
 53        {
 054            DataStore.i.HUDs.loadingHUD.message.Set(payload.message);
 055        }
 56        else
 57        {
 058            DataStore.i.HUDs.loadingHUD.message.Set("Teleporting to " + payload.xCoord + ", " + payload.yCoord + "...");
 59        }
 060        DataStore.i.HUDs.loadingHUD.percentage.Set(0);
 061        DataStore.i.HUDs.loadingHUD.fadeIn.Set(true);
 62
 063        while (!DataStore.i.HUDs.loadingHUD.visible.Get())
 64        {
 065            yield return null;
 66        }
 67
 068        WebInterface.LoadingHUDReadyForTeleport(payload.xCoord, payload.yCoord);
 069    }
 70}