< Summary

Class:DCL.Huds.QuestsTracker.QuestNotification_RewardObtained
Assembly:QuestsTrackerHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsTrackerHUD/QuestNotification_RewardObtained.cs
Covered lines:0
Uncovered lines:21
Coverable lines:21
Total lines:57
Line coverage:0% (0 of 21)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%2100%
Populate(...)0%2100%
SetImage(...)0%12300%
OnImageReady(...)0%2100%
Show()0%2100%
Dispose()0%2100%
Waiter()0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsTrackerHUD/QuestNotification_RewardObtained.cs

#LineLine coverage
 1using System.Collections;
 2using DCL.Helpers;
 3using TMPro;
 4using UnityEngine;
 5using UnityEngine.UI;
 6
 7namespace DCL.Huds.QuestsTracker
 8{
 9    public class QuestNotification_RewardObtained : MonoBehaviour, IQuestNotification
 10    {
 11        [SerializeField] internal TextMeshProUGUI rewardName;
 12        [SerializeField] internal RawImage rewardImage;
 13        [SerializeField] internal Button okButton;
 14        [SerializeField] internal AudioEvent rewardObtainedAudioEvent;
 15
 16        private AssetPromise_Texture imagePromise;
 17        private bool okPressed = false;
 18
 019        private void Awake() { okButton.onClick.AddListener(() => okPressed = true); }
 20
 21        public void Populate(QuestReward reward)
 22        {
 023            this.rewardName.text = reward.name;
 024            SetImage(reward.imageUrl);
 025        }
 26
 27        internal void SetImage(string itemImageURL)
 28        {
 029            if (imagePromise != null)
 30            {
 031                imagePromise.ClearEvents();
 032                AssetPromiseKeeper_Texture.i.Forget(imagePromise);
 33            }
 34
 035            if (string.IsNullOrEmpty(itemImageURL))
 036                return;
 37
 038            imagePromise = new AssetPromise_Texture(itemImageURL);
 039            imagePromise.OnSuccessEvent += OnImageReady;
 040            imagePromise.OnFailEvent += (x, error) => { Debug.Log($"Error downloading reward image: {itemImageURL}, Exce
 41
 042            AssetPromiseKeeper_Texture.i.Keep(imagePromise);
 043        }
 44
 045        private void OnImageReady(Asset_Texture assetTexture) { rewardImage.texture = assetTexture.texture; }
 46
 47        public void Show()
 48        {
 049            gameObject.SetActive(true);
 050            rewardObtainedAudioEvent.Play();
 051            Utils.UnlockCursor();
 052        }
 53
 054        public void Dispose() { Destroy(gameObject); }
 055        public IEnumerator Waiter() { yield return new WaitUntil(() => okPressed); }
 56    }
 57}