< Summary

Class:ShortcutsController
Assembly:Shortcuts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Shortcuts/ShortcutsController.cs
Covered lines:0
Uncovered lines:61
Coverable lines:61
Total lines:119
Line coverage:0% (0 of 61)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ShortcutsController()0%2100%
Subscribe()0%2100%
Unsubscribe()0%2100%
ToggleControlsTriggered(...)0%2100%
ToggleAvatarEditorTriggered(...)0%6200%
ToggleAvatarNamesTriggered(...)0%2100%
ToggleQuestPanel(...)0%6200%
ToggleStartMenuTriggered(...)0%12300%
ToggleExpressionsTriggered(...)0%2100%
ToggleNavMapTriggered(...)0%6200%
TogglePlacesAndEventsTriggered(...)0%6200%
Dispose()0%2100%
SendQuestToggledAnalytic(...)0%2100%
SendExploreToggledAnalytics(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Shortcuts/ShortcutsController.cs

#LineLine coverage
 1using System;
 2using DCL;
 3using ExploreV2Analytics;
 4using UnityEngine;
 5
 6public class ShortcutsController : IDisposable
 7{
 8    internal InputAction_Trigger toggleQuestsPanel;
 9    internal InputAction_Trigger toggleAvatarNames;
 10    internal InputAction_Trigger toggleControls;
 11    internal InputAction_Trigger toggleAvatarEditor;
 12    internal InputAction_Trigger toggleStartMenu;
 13    internal InputAction_Trigger toggleExpressionsHUD;
 14    internal InputAction_Trigger toggleNavMap;
 15    internal InputAction_Trigger togglePlacesAndEvents;
 16
 017    public ShortcutsController()
 18    {
 019        toggleQuestsPanel = Resources.Load<InputAction_Trigger>("ToggleQuestsPanelHUD");
 020        toggleAvatarNames = Resources.Load<InputAction_Trigger>("ToggleAvatarNames");
 021        toggleControls = Resources.Load<InputAction_Trigger>("ToggleControlsHud");
 022        toggleAvatarEditor = Resources.Load<InputAction_Trigger>("ToggleAvatarEditorHud");
 023        toggleStartMenu = Resources.Load<InputAction_Trigger>("ToggleStartMenu");
 024        toggleExpressionsHUD = Resources.Load<InputAction_Trigger>("OpenExpressions");
 025        toggleNavMap = Resources.Load<InputAction_Trigger>("ToggleNavMap");
 026        togglePlacesAndEvents = Resources.Load<InputAction_Trigger>("TogglePlacesAndEventsHud");
 27
 028        Subscribe();
 029    }
 30
 31    internal void Subscribe()
 32    {
 33
 034        toggleControls.OnTriggered += ToggleControlsTriggered;
 035        toggleAvatarEditor.OnTriggered += ToggleAvatarEditorTriggered;
 036        toggleAvatarNames.OnTriggered += ToggleAvatarNamesTriggered;
 037        toggleQuestsPanel.OnTriggered += ToggleQuestPanel;
 038        toggleStartMenu.OnTriggered += ToggleStartMenuTriggered;
 039        toggleExpressionsHUD.OnTriggered += ToggleExpressionsTriggered;
 040        toggleNavMap.OnTriggered += ToggleNavMapTriggered;
 041        togglePlacesAndEvents.OnTriggered += TogglePlacesAndEventsTriggered;
 042    }
 43
 44    internal void Unsubscribe()
 45    {
 046        toggleControls.OnTriggered -= ToggleControlsTriggered;
 047        toggleAvatarEditor.OnTriggered -= ToggleAvatarEditorTriggered;
 048        toggleAvatarNames.OnTriggered -= ToggleAvatarNamesTriggered;
 049        toggleQuestsPanel.OnTriggered -= ToggleQuestPanel;
 050        toggleStartMenu.OnTriggered -= ToggleStartMenuTriggered;
 051        toggleExpressionsHUD.OnTriggered -= ToggleExpressionsTriggered;
 052        toggleNavMap.OnTriggered -= ToggleNavMapTriggered;
 053        togglePlacesAndEvents.OnTriggered -= TogglePlacesAndEventsTriggered;
 054    }
 55
 056    private void ToggleControlsTriggered(DCLAction_Trigger action) { DataStore.i.HUDs.controlsVisible.Set(!DataStore.i.H
 57
 58    private void ToggleAvatarEditorTriggered(DCLAction_Trigger action)
 59    {
 060        if (!DataStore.i.HUDs.isAvatarEditorInitialized.Get())
 061            return;
 62
 063        DataStore.i.HUDs.avatarEditorVisible.Set(!DataStore.i.HUDs.avatarEditorVisible.Get());
 064    }
 65
 066    private void ToggleAvatarNamesTriggered(DCLAction_Trigger action) { DataStore.i.HUDs.avatarNamesVisible.Set(!DataSto
 67
 68    private void ToggleQuestPanel(DCLAction_Trigger action)
 69    {
 070        if (!DataStore.i.Quests.isInitialized.Get())
 071            return;
 72
 073        bool value = !DataStore.i.HUDs.questsPanelVisible.Get();
 074        SendQuestToggledAnalytic(value);
 075        DataStore.i.HUDs.questsPanelVisible.Set(value);
 076    }
 77
 78    private void ToggleStartMenuTriggered(DCLAction_Trigger action)
 79    {
 080        bool value = !DataStore.i.exploreV2.isOpen.Get();
 081        if (DataStore.i.common.isSignUpFlow.Get()) return;
 82
 083        if (value)
 84        {
 085            SendExploreToggledAnalytics(value);
 086            DataStore.i.exploreV2.isOpen.Set(value);
 087        }
 88        else
 89        {
 090            DataStore.i.exploreV2.currentSectionIndex.Set(DataStore.i.exploreV2.currentSectionIndex.Get() + 1);
 91        }
 092    }
 93
 094    private void ToggleExpressionsTriggered(DCLAction_Trigger action) { DataStore.i.HUDs.emotesVisible.Set(!DataStore.i.
 95
 96    private void ToggleNavMapTriggered(DCLAction_Trigger action)
 97    {
 098        if (!DataStore.i.HUDs.isNavMapInitialized.Get())
 099            return;
 100
 0101        DataStore.i.HUDs.navmapVisible.Set(!DataStore.i.HUDs.navmapVisible.Get());
 0102    }
 103
 104    private void TogglePlacesAndEventsTriggered(DCLAction_Trigger action)
 105    {
 0106        if (!DataStore.i.exploreV2.isPlacesAndEventsSectionInitialized.Get())
 0107            return;
 108
 0109        DataStore.i.exploreV2.placesAndEventsVisible.Set(!DataStore.i.exploreV2.placesAndEventsVisible.Get());
 0110    }
 111
 0112    public void Dispose() { Unsubscribe(); }
 113
 114    // In the future the analytics will be received through DI in the shape of a service locator,
 115    // so we can remove these methods and mock the locator itself
 0116    internal virtual void SendQuestToggledAnalytic(bool value) { QuestsUIAnalytics.SendQuestLogVisibiltyChanged(value, "
 0117    internal virtual void SendExploreToggledAnalytics(bool value) { new ExploreV2Analytics.ExploreV2Analytics().SendStar
 118
 119}