< Summary

Class:DCL.Huds.QuestsPanel.QuestsPanelHUDController
Assembly:QuestsPanelHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsPanelHUD/QuestsPanelHUDController.cs
Covered lines:45
Uncovered lines:0
Coverable lines:45
Total lines:91
Line coverage:100% (45 of 45)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize(...)0%110100%
OnQuestPanelVisibleChanged(...)0%110100%
OnQuestUpdated(...)0%550100%
OnQuestAdded(...)0%440100%
OnQuestRemoved(...)0%110100%
OnQuestSet(...)0%330100%
SetVisibility(...)0%110100%
SetViewActive(...)0%220100%
CreateView()0%110100%
Dispose()0%220100%
ConfigureQuestInFullscreenMenuChanged(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/QuestsPanelHUD/QuestsPanelHUDController.cs

#LineLine coverage
 1using DCL.Helpers;
 2using DCL.QuestsController;
 3using System;
 4using System.Collections.Generic;
 5using UnityEngine;
 6
 7namespace DCL.Huds.QuestsPanel
 8{
 9    public class QuestsPanelHUDController : IHUD
 10    {
 11        internal IQuestsPanelHUDView view;
 12        internal IQuestsController questsController;
 7413        private static BaseDictionary<string, QuestModel> quests => DataStore.i.Quests.quests;
 14
 3115        BaseVariable<bool> questsPanelVisible => DataStore.i.HUDs.questsPanelVisible;
 3016        BaseVariable<Transform> configureQuestInFullscreenMenu => DataStore.i.exploreV2.configureQuestInFullscreenMenu;
 17
 18        public void Initialize(IQuestsController newQuestsController)
 19        {
 1020            questsController = newQuestsController;
 1021            view = CreateView();
 1022            SetViewActive(false);
 23
 1024            questsController.OnQuestUpdated += OnQuestUpdated;
 1025            quests.OnAdded += OnQuestAdded;
 1026            quests.OnRemoved += OnQuestRemoved;
 1027            quests.OnSet += OnQuestSet;
 28
 1029            questsPanelVisible.OnChange -= OnQuestPanelVisibleChanged;
 1030            questsPanelVisible.OnChange += OnQuestPanelVisibleChanged;
 31
 1032            configureQuestInFullscreenMenu.OnChange += ConfigureQuestInFullscreenMenuChanged;
 1033            ConfigureQuestInFullscreenMenuChanged(configureQuestInFullscreenMenu.Get(), null);
 34
 1035            OnQuestSet(quests.Get());
 36
 1037            DataStore.i.Quests.isInitialized.Set(true);
 1038        }
 39
 240        private void OnQuestPanelVisibleChanged(bool current, bool previous) { SetViewActive(current); }
 41
 42        private void OnQuestUpdated(string questId, bool hasProgress)
 43        {
 444            if (!quests.TryGetValue(questId, out QuestModel model) || model.status == QuestsLiterals.Status.BLOCKED || (
 45            {
 346                view.RemoveQuest(questId);
 347                return;
 48            }
 49
 150            view.RequestAddOrUpdateQuest(questId);
 151        }
 52
 53        private void OnQuestAdded(string questId, QuestModel questModel)
 54        {
 1355            if (questModel.status == QuestsLiterals.Status.BLOCKED || (questModel.visibility == QuestsLiterals.Visibilit
 356                return;
 1057            view.RequestAddOrUpdateQuest(questId);
 1058        }
 59
 260        private void OnQuestRemoved(string questId, QuestModel questModel) { view.RemoveQuest(questId); }
 61
 62        private void OnQuestSet(IEnumerable<KeyValuePair<string, QuestModel>> quests)
 63        {
 1364            view.ClearQuests();
 5265            foreach ((string key, QuestModel value) in quests)
 66            {
 1367                OnQuestAdded(key, value);
 68            }
 1369        }
 70
 271        public void SetVisibility(bool visible) { questsPanelVisible.Set(visible); }
 72
 2273        private void SetViewActive(bool visible) { view?.SetVisibility(visible); }
 74
 175        internal virtual IQuestsPanelHUDView CreateView() => QuestsPanelHUDView.Create();
 76
 77        public void Dispose()
 78        {
 1079            view.Dispose();
 1080            if (questsController != null)
 1081                questsController.OnQuestUpdated -= OnQuestUpdated;
 1082            quests.OnAdded -= OnQuestAdded;
 1083            quests.OnRemoved -= OnQuestRemoved;
 1084            quests.OnSet -= OnQuestSet;
 1085            questsPanelVisible.OnChange -= OnQuestPanelVisibleChanged;
 1086            configureQuestInFullscreenMenu.OnChange -= ConfigureQuestInFullscreenMenuChanged;
 1087        }
 88
 2089        private void ConfigureQuestInFullscreenMenuChanged(Transform currentParentTransform, Transform previousParentTra
 90    }
 91}