| | 1 | | using System; |
| | 2 | | using DCL; |
| | 3 | | using ExploreV2Analytics; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | public 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 | |
|
| 0 | 17 | | public ShortcutsController() |
| | 18 | | { |
| 0 | 19 | | toggleQuestsPanel = Resources.Load<InputAction_Trigger>("ToggleQuestsPanelHUD"); |
| 0 | 20 | | toggleAvatarNames = Resources.Load<InputAction_Trigger>("ToggleAvatarNames"); |
| 0 | 21 | | toggleControls = Resources.Load<InputAction_Trigger>("ToggleControlsHud"); |
| 0 | 22 | | toggleAvatarEditor = Resources.Load<InputAction_Trigger>("ToggleAvatarEditorHud"); |
| 0 | 23 | | toggleStartMenu = Resources.Load<InputAction_Trigger>("ToggleStartMenu"); |
| 0 | 24 | | toggleExpressionsHUD = Resources.Load<InputAction_Trigger>("OpenExpressions"); |
| 0 | 25 | | toggleNavMap = Resources.Load<InputAction_Trigger>("ToggleNavMap"); |
| 0 | 26 | | togglePlacesAndEvents = Resources.Load<InputAction_Trigger>("TogglePlacesAndEventsHud"); |
| | 27 | |
|
| 0 | 28 | | Subscribe(); |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | internal void Subscribe() |
| | 32 | | { |
| | 33 | |
|
| 0 | 34 | | toggleControls.OnTriggered += ToggleControlsTriggered; |
| 0 | 35 | | toggleAvatarEditor.OnTriggered += ToggleAvatarEditorTriggered; |
| 0 | 36 | | toggleAvatarNames.OnTriggered += ToggleAvatarNamesTriggered; |
| 0 | 37 | | toggleQuestsPanel.OnTriggered += ToggleQuestPanel; |
| 0 | 38 | | toggleStartMenu.OnTriggered += ToggleStartMenuTriggered; |
| 0 | 39 | | toggleExpressionsHUD.OnTriggered += ToggleExpressionsTriggered; |
| 0 | 40 | | toggleNavMap.OnTriggered += ToggleNavMapTriggered; |
| 0 | 41 | | togglePlacesAndEvents.OnTriggered += TogglePlacesAndEventsTriggered; |
| 0 | 42 | | } |
| | 43 | |
|
| | 44 | | internal void Unsubscribe() |
| | 45 | | { |
| 0 | 46 | | toggleControls.OnTriggered -= ToggleControlsTriggered; |
| 0 | 47 | | toggleAvatarEditor.OnTriggered -= ToggleAvatarEditorTriggered; |
| 0 | 48 | | toggleAvatarNames.OnTriggered -= ToggleAvatarNamesTriggered; |
| 0 | 49 | | toggleQuestsPanel.OnTriggered -= ToggleQuestPanel; |
| 0 | 50 | | toggleStartMenu.OnTriggered -= ToggleStartMenuTriggered; |
| 0 | 51 | | toggleExpressionsHUD.OnTriggered -= ToggleExpressionsTriggered; |
| 0 | 52 | | toggleNavMap.OnTriggered -= ToggleNavMapTriggered; |
| 0 | 53 | | togglePlacesAndEvents.OnTriggered -= TogglePlacesAndEventsTriggered; |
| 0 | 54 | | } |
| | 55 | |
|
| 0 | 56 | | private void ToggleControlsTriggered(DCLAction_Trigger action) { DataStore.i.HUDs.controlsVisible.Set(!DataStore.i.H |
| | 57 | |
|
| | 58 | | private void ToggleAvatarEditorTriggered(DCLAction_Trigger action) |
| | 59 | | { |
| 0 | 60 | | if (!DataStore.i.HUDs.isAvatarEditorInitialized.Get()) |
| 0 | 61 | | return; |
| | 62 | |
|
| 0 | 63 | | DataStore.i.HUDs.avatarEditorVisible.Set(!DataStore.i.HUDs.avatarEditorVisible.Get()); |
| 0 | 64 | | } |
| | 65 | |
|
| 0 | 66 | | private void ToggleAvatarNamesTriggered(DCLAction_Trigger action) { DataStore.i.HUDs.avatarNamesVisible.Set(!DataSto |
| | 67 | |
|
| | 68 | | private void ToggleQuestPanel(DCLAction_Trigger action) |
| | 69 | | { |
| 0 | 70 | | if (!DataStore.i.Quests.isInitialized.Get()) |
| 0 | 71 | | return; |
| | 72 | |
|
| 0 | 73 | | bool value = !DataStore.i.HUDs.questsPanelVisible.Get(); |
| 0 | 74 | | SendQuestToggledAnalytic(value); |
| 0 | 75 | | DataStore.i.HUDs.questsPanelVisible.Set(value); |
| 0 | 76 | | } |
| | 77 | |
|
| | 78 | | private void ToggleStartMenuTriggered(DCLAction_Trigger action) |
| | 79 | | { |
| 0 | 80 | | bool value = !DataStore.i.exploreV2.isOpen.Get(); |
| 0 | 81 | | if (DataStore.i.common.isSignUpFlow.Get()) return; |
| | 82 | |
|
| 0 | 83 | | if (value) |
| | 84 | | { |
| 0 | 85 | | SendExploreToggledAnalytics(value); |
| 0 | 86 | | DataStore.i.exploreV2.isOpen.Set(value); |
| 0 | 87 | | } |
| | 88 | | else |
| | 89 | | { |
| 0 | 90 | | DataStore.i.exploreV2.currentSectionIndex.Set(DataStore.i.exploreV2.currentSectionIndex.Get() + 1); |
| | 91 | | } |
| 0 | 92 | | } |
| | 93 | |
|
| 0 | 94 | | private void ToggleExpressionsTriggered(DCLAction_Trigger action) { DataStore.i.HUDs.emotesVisible.Set(!DataStore.i. |
| | 95 | |
|
| | 96 | | private void ToggleNavMapTriggered(DCLAction_Trigger action) |
| | 97 | | { |
| 0 | 98 | | if (!DataStore.i.HUDs.isNavMapInitialized.Get()) |
| 0 | 99 | | return; |
| | 100 | |
|
| 0 | 101 | | DataStore.i.HUDs.navmapVisible.Set(!DataStore.i.HUDs.navmapVisible.Get()); |
| 0 | 102 | | } |
| | 103 | |
|
| | 104 | | private void TogglePlacesAndEventsTriggered(DCLAction_Trigger action) |
| | 105 | | { |
| 0 | 106 | | if (!DataStore.i.exploreV2.isPlacesAndEventsSectionInitialized.Get()) |
| 0 | 107 | | return; |
| | 108 | |
|
| 0 | 109 | | DataStore.i.exploreV2.placesAndEventsVisible.Set(!DataStore.i.exploreV2.placesAndEventsVisible.Get()); |
| 0 | 110 | | } |
| | 111 | |
|
| 0 | 112 | | 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 |
| 0 | 116 | | internal virtual void SendQuestToggledAnalytic(bool value) { QuestsUIAnalytics.SendQuestLogVisibiltyChanged(value, " |
| 0 | 117 | | internal virtual void SendExploreToggledAnalytics(bool value) { new ExploreV2Analytics.ExploreV2Analytics().SendStar |
| | 118 | |
|
| | 119 | | } |