| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using DCL; |
| | 3 | | using DCL.Browser; |
| | 4 | | using DCL.Chat; |
| | 5 | | using DCL.HelpAndSupportHUD; |
| | 6 | | using DCL.ProfanityFiltering; |
| | 7 | | using DCL.Providers; |
| | 8 | | using DCL.SettingsCommon; |
| | 9 | | using DCL.SettingsPanelHUD; |
| | 10 | | using DCL.Social.Chat.Mentions; |
| | 11 | | using DCL.Social.Friends; |
| | 12 | | using SocialFeaturesAnalytics; |
| | 13 | | using System; |
| | 14 | | using System.Collections.Generic; |
| | 15 | | using System.Threading; |
| | 16 | | using static MainScripts.DCL.Controllers.HUD.HUDAssetPath; |
| | 17 | | using Environment = DCL.Environment; |
| | 18 | | using Analytics; |
| | 19 | | using DCL.MyAccount; |
| | 20 | | using DCL.Social.Chat; |
| | 21 | | using DCLServices.CopyPaste.Analytics; |
| | 22 | | using DCLServices.PlacesAPIService; |
| | 23 | | using UnityEngine; |
| | 24 | | using Object = UnityEngine.Object; |
| | 25 | |
|
| | 26 | | public class HUDFactory : IHUDFactory |
| | 27 | | { |
| | 28 | | private readonly DataStoreRef<DataStore_LoadingScreen> dataStoreLoadingScreen; |
| | 29 | | private readonly List<IDisposable> disposableViews; |
| | 30 | |
|
| | 31 | | private Service<IAddressableResourceProvider> assetsProviderService; |
| | 32 | | private IAddressableResourceProvider assetsProviderRef; |
| | 33 | |
|
| 10 | 34 | | private IAddressableResourceProvider assetsProvider => assetsProviderRef ??= assetsProviderService.Ref; |
| 5 | 35 | | private ICopyPasteAnalyticsService copyPasteAnalyticsService => Environment.i.serviceLocator.Get<ICopyPasteAnalytics |
| | 36 | |
|
| 0 | 37 | | protected HUDFactory() |
| | 38 | | { |
| 0 | 39 | | disposableViews = new List<IDisposable>(); |
| 0 | 40 | | } |
| | 41 | |
|
| 427 | 42 | | public HUDFactory(IAddressableResourceProvider assetsProvider) |
| | 43 | | { |
| 427 | 44 | | disposableViews = new List<IDisposable>(); |
| 427 | 45 | | assetsProviderRef = assetsProvider; |
| 427 | 46 | | } |
| | 47 | |
|
| 425 | 48 | | public void Initialize() { } |
| | 49 | |
|
| | 50 | | public void Dispose() |
| | 51 | | { |
| 850 | 52 | | foreach (IDisposable view in disposableViews) |
| 0 | 53 | | view.Dispose(); |
| 425 | 54 | | } |
| | 55 | |
|
| | 56 | | public virtual async UniTask<IHUD> CreateHUD(HUDElementID hudElementId, CancellationToken cancellationToken = defaul |
| | 57 | | { |
| | 58 | | switch (hudElementId) |
| | 59 | | { |
| | 60 | | case HUDElementID.NONE: |
| | 61 | | break; |
| | 62 | | case HUDElementID.MINIMAP: |
| 1 | 63 | | return new MinimapHUDController(MinimapMetadataController.i, |
| | 64 | | new WebInterfaceHomeLocationController(), Environment.i, |
| | 65 | | Environment.i.serviceLocator.Get<IPlacesAPIService>(), |
| | 66 | | new PlacesAnalytics(), Clipboard.Create(), |
| | 67 | | copyPasteAnalyticsService, |
| | 68 | | DataStore.i.contentModeration, |
| | 69 | | Environment.i.world.state); |
| | 70 | | case HUDElementID.PROFILE_HUD: |
| 1 | 71 | | ProfileHUDViewV2 view = Object.Instantiate(Resources.Load<ProfileHUDViewV2>("ProfileHUD_V2")); |
| | 72 | |
|
| 1 | 73 | | var userProfileBridge = new UserProfileWebInterfaceBridge(); |
| 1 | 74 | | var webInterfaceBrowserBridge = new WebInterfaceBrowserBridge(); |
| | 75 | |
|
| 1 | 76 | | return new ProfileHUDController( |
| | 77 | | view, |
| | 78 | | userProfileBridge, |
| | 79 | | new SocialAnalytics( |
| | 80 | | Environment.i.platform.serviceProviders.analytics, |
| | 81 | | userProfileBridge), |
| | 82 | | DataStore.i, |
| | 83 | | new MyAccountCardController( |
| | 84 | | view.MyAccountCardView, |
| | 85 | | DataStore.i, |
| | 86 | | userProfileBridge, |
| | 87 | | Settings.i, |
| | 88 | | webInterfaceBrowserBridge), |
| | 89 | | webInterfaceBrowserBridge); |
| | 90 | | case HUDElementID.NOTIFICATION: |
| 3 | 91 | | return new NotificationHUDController( await CreateHUDView<NotificationHUDView>(VIEW_PATH, cancellationTo |
| | 92 | | case HUDElementID.SETTINGS_PANEL: |
| 1 | 93 | | return new SettingsPanelHUDController(); |
| | 94 | | case HUDElementID.TERMS_OF_SERVICE: |
| 1 | 95 | | return new TermsOfServiceHUDController(); |
| | 96 | | case HUDElementID.FRIENDS: |
| 1 | 97 | | return new FriendsHUDController(DataStore.i, |
| | 98 | | Environment.i.serviceLocator.Get<IFriendsController>(), |
| | 99 | | new UserProfileWebInterfaceBridge(), |
| | 100 | | new SocialAnalytics( |
| | 101 | | Environment.i.platform.serviceProviders.analytics, |
| | 102 | | new UserProfileWebInterfaceBridge()), |
| | 103 | | Environment.i.serviceLocator.Get<IChatController>(), |
| | 104 | | SceneReferences.i.mouseCatcher); |
| | 105 | | case HUDElementID.WORLD_CHAT_WINDOW: |
| 1 | 106 | | return new WorldChatWindowController( |
| | 107 | | new UserProfileWebInterfaceBridge(), |
| | 108 | | Environment.i.serviceLocator.Get<IFriendsController>(), |
| | 109 | | Environment.i.serviceLocator.Get<IChatController>(), |
| | 110 | | DataStore.i, |
| | 111 | | SceneReferences.i.mouseCatcher, |
| | 112 | | new SocialAnalytics( |
| | 113 | | Environment.i.platform.serviceProviders.analytics, |
| | 114 | | new UserProfileWebInterfaceBridge()), |
| | 115 | | Environment.i.serviceLocator.Get<IChannelsFeatureFlagService>(), |
| | 116 | | new WebInterfaceBrowserBridge(), |
| | 117 | | CommonScriptableObjects.rendererState, |
| | 118 | | DataStore.i.mentions, |
| | 119 | | Clipboard.Create(), |
| | 120 | | copyPasteAnalyticsService); |
| | 121 | | case HUDElementID.PRIVATE_CHAT_WINDOW: |
| 1 | 122 | | return new PrivateChatWindowController( |
| | 123 | | DataStore.i, |
| | 124 | | new UserProfileWebInterfaceBridge(), |
| | 125 | | Environment.i.serviceLocator.Get<IChatController>(), |
| | 126 | | Environment.i.serviceLocator.Get<IFriendsController>(), |
| | 127 | | new SocialAnalytics( |
| | 128 | | Environment.i.platform.serviceProviders.analytics, |
| | 129 | | new UserProfileWebInterfaceBridge()), |
| | 130 | | SceneReferences.i.mouseCatcher, |
| | 131 | | new MemoryChatMentionSuggestionProvider(UserProfileController.i, DataStore.i), |
| | 132 | | Clipboard.Create(), |
| | 133 | | copyPasteAnalyticsService); |
| | 134 | | case HUDElementID.PUBLIC_CHAT: |
| 1 | 135 | | return new PublicChatWindowController( |
| | 136 | | Environment.i.serviceLocator.Get<IChatController>(), |
| | 137 | | new UserProfileWebInterfaceBridge(), |
| | 138 | | DataStore.i, |
| | 139 | | Environment.i.serviceLocator.Get<IProfanityFilter>(), |
| | 140 | | SceneReferences.i.mouseCatcher, |
| | 141 | | new MemoryChatMentionSuggestionProvider(UserProfileController.i, DataStore.i), |
| | 142 | | new SocialAnalytics( |
| | 143 | | Environment.i.platform.serviceProviders.analytics, |
| | 144 | | new UserProfileWebInterfaceBridge()), |
| | 145 | | Clipboard.Create(), |
| | 146 | | copyPasteAnalyticsService); |
| | 147 | | case HUDElementID.CHANNELS_CHAT: |
| 1 | 148 | | return new ChatChannelHUDController( |
| | 149 | | DataStore.i, |
| | 150 | | new UserProfileWebInterfaceBridge(), |
| | 151 | | Environment.i.serviceLocator.Get<IChatController>(), |
| | 152 | | SceneReferences.i.mouseCatcher, |
| | 153 | | new SocialAnalytics( |
| | 154 | | Environment.i.platform.serviceProviders.analytics, |
| | 155 | | new UserProfileWebInterfaceBridge()), |
| | 156 | | Environment.i.serviceLocator.Get<IProfanityFilter>(), |
| | 157 | | new MemoryChatMentionSuggestionProvider(UserProfileController.i, DataStore.i), |
| | 158 | | Clipboard.Create(), |
| | 159 | | copyPasteAnalyticsService); |
| | 160 | | case HUDElementID.CHANNELS_SEARCH: |
| 1 | 161 | | return new SearchChannelsWindowController( |
| | 162 | | Environment.i.serviceLocator.Get<IChatController>(), |
| | 163 | | SceneReferences.i.mouseCatcher, |
| | 164 | | DataStore.i, |
| | 165 | | new SocialAnalytics( |
| | 166 | | Environment.i.platform.serviceProviders.analytics, |
| | 167 | | new UserProfileWebInterfaceBridge()), |
| | 168 | | Environment.i.serviceLocator.Get<IChannelsFeatureFlagService>()); |
| | 169 | | case HUDElementID.CHANNELS_CREATE: |
| 1 | 170 | | return new CreateChannelWindowController(Environment.i.serviceLocator.Get<IChatController>(), DataStore. |
| | 171 | | case HUDElementID.CHANNELS_LEAVE_CONFIRMATION: |
| 1 | 172 | | return new LeaveChannelConfirmationWindowController(Environment.i.serviceLocator.Get<IChatController>()) |
| | 173 | | case HUDElementID.TASKBAR: |
| 1 | 174 | | return new TaskbarHUDController(Environment.i.serviceLocator.Get<IChatController>(), Environment.i.servi |
| | 175 | | case HUDElementID.OPEN_EXTERNAL_URL_PROMPT: |
| 1 | 176 | | return new ExternalUrlPromptHUDController(DataStore.i.rpc.context.restrictedActions); |
| | 177 | | case HUDElementID.NFT_INFO_DIALOG: |
| 1 | 178 | | return new NFTPromptHUDController(DataStore.i.rpc.context.restrictedActions, DataStore.i.common.onOpenNF |
| | 179 | | case HUDElementID.CONTROLS_HUD: |
| 1 | 180 | | return new ControlsHUDController(); |
| | 181 | | case HUDElementID.HELP_AND_SUPPORT_HUD: |
| 3 | 182 | | return new HelpAndSupportHUDController(await CreateHUDView<IHelpAndSupportHUDView>(HELP_AND_SUPPORT_HUD, |
| | 183 | | case HUDElementID.USERS_AROUND_LIST_HUD: |
| 1 | 184 | | return new VoiceChatWindowController( |
| | 185 | | new UserProfileWebInterfaceBridge(), |
| | 186 | | Environment.i.serviceLocator.Get<IFriendsController>(), |
| | 187 | | new SocialAnalytics( |
| | 188 | | Environment.i.platform.serviceProviders.analytics, |
| | 189 | | new UserProfileWebInterfaceBridge()), |
| | 190 | | DataStore.i, |
| | 191 | | Settings.i, |
| | 192 | | SceneReferences.i.mouseCatcher); |
| | 193 | | case HUDElementID.GRAPHIC_CARD_WARNING: |
| 1 | 194 | | return new GraphicCardWarningHUDController(); |
| | 195 | | } |
| | 196 | |
|
| 0 | 197 | | return null; |
| 20 | 198 | | } |
| | 199 | |
|
| | 200 | | public async UniTask<T> CreateHUDView<T>(string assetAddress, CancellationToken cancellationToken = default, string |
| | 201 | | { |
| | 202 | | var view = await assetsProvider.Instantiate<T>(assetAddress, $"_{assetAddress}", cancellationToken: cancellatio |
| | 203 | | disposableViews.Add(view); |
| | 204 | |
|
| | 205 | | return view; |
| | 206 | | } |
| | 207 | | } |