| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using DCL; |
| | 3 | | using DCL.Social.Friends; |
| | 4 | | using DCL.Tasks; |
| | 5 | | using DCL.Wallet; |
| | 6 | | using DCLServices.PlacesAPIService; |
| | 7 | | using DCLServices.WorldsAPIService; |
| | 8 | | using ExploreV2Analytics; |
| | 9 | | using System; |
| | 10 | | using System.Collections.Generic; |
| | 11 | | using System.Linq; |
| | 12 | | using System.Threading; |
| | 13 | | using UnityEngine; |
| | 14 | | using Environment = DCL.Environment; |
| | 15 | |
|
| | 16 | | /// <summary> |
| | 17 | | /// Main controller for the feature "Explore V2". |
| | 18 | | /// Controls different sections: Maps, Backpack, Settings |
| | 19 | | /// their initialization and switching between them |
| | 20 | | /// </summary> |
| | 21 | | public class ExploreV2MenuComponentController : IExploreV2MenuComponentController |
| | 22 | | { |
| | 23 | | private readonly IPlacesAPIService placesAPIService; |
| | 24 | | private readonly IWorldsAPIService worldsAPIService; |
| | 25 | | private readonly IPlacesAnalytics placesAnalytics; |
| | 26 | | private readonly IRealmsInfoBridge realmsInfoBridge; |
| | 27 | |
|
| | 28 | | // TODO: Refactor the ExploreV2MenuComponentController class in order to inject UserProfileWebInterfaceBridge, theGr |
| | 29 | |
|
| | 30 | | internal const ExploreSection DEFAULT_SECTION = ExploreSection.Explore; |
| | 31 | |
|
| | 32 | | internal IExploreV2MenuComponentView view; |
| | 33 | | internal IExploreV2Analytics exploreV2Analytics; |
| | 34 | |
|
| | 35 | | internal IPlacesAndEventsSectionComponentController placesAndEventsSectionController; |
| | 36 | |
|
| | 37 | | internal ExploreSection currentOpenSection; |
| | 38 | | internal Dictionary<BaseVariable<bool>, ExploreSection> sectionsByVisibilityVar; |
| | 39 | | private ExploreV2ComponentRealmsController realmController; |
| | 40 | | private WalletCardHUDController walletCardHUDController; |
| | 41 | |
|
| | 42 | | private MouseCatcher mouseCatcher; |
| | 43 | | private Dictionary<BaseVariable<bool>, ExploreSection> sectionsByInitVar; |
| | 44 | | private Dictionary<ExploreSection, (BaseVariable<bool> initVar, BaseVariable<bool> visibilityVar)> sectionsVariables |
| | 45 | | private CancellationTokenSource openRealmSelectorCancellationToken; |
| | 46 | |
|
| 302 | 47 | | internal BaseVariable<bool> isOpen => DataStore.i.exploreV2.isOpen; |
| 108 | 48 | | internal BaseVariable<bool> isInitialized => DataStore.i.exploreV2.isInitialized; |
| 72 | 49 | | internal BaseVariable<bool> profileCardIsOpen => DataStore.i.exploreV2.profileCardIsOpen; |
| 58 | 50 | | internal BaseVariable<bool> placesAndEventsVisible => DataStore.i.exploreV2.placesAndEventsVisible; |
| 54 | 51 | | internal BaseVariable<bool> isAvatarEditorInitialized => DataStore.i.HUDs.isAvatarEditorInitialized; |
| 58 | 52 | | internal BaseVariable<bool> avatarEditorVisible => DataStore.i.HUDs.avatarEditorVisible; |
| 52 | 53 | | internal BaseVariable<bool> isCameraReelInitialized => DataStore.i.HUDs.isCameraReelInitialized; |
| 52 | 54 | | internal BaseVariable<bool> cameraReelSectionVisible => DataStore.i.HUDs.cameraReelSectionVisible; |
| 54 | 55 | | internal BaseVariable<bool> isNavmapInitialized => DataStore.i.HUDs.isNavMapInitialized; |
| 58 | 56 | | internal BaseVariable<bool> navmapVisible => DataStore.i.HUDs.navmapVisible; |
| 54 | 57 | | internal BaseVariable<bool> isQuestInitialized => DataStore.i.Quests.isInitialized; |
| 58 | 58 | | internal BaseVariable<bool> questVisible => DataStore.i.HUDs.questsPanelVisible; |
| 54 | 59 | | internal BaseVariable<bool> isSettingsPanelInitialized => DataStore.i.settings.isInitialized; |
| 58 | 60 | | internal BaseVariable<bool> settingsVisible => DataStore.i.settings.settingsPanelVisible; |
| 229 | 61 | | internal BaseVariable<bool> isWalletInitialized => DataStore.i.wallet.isInitialized; |
| 52 | 62 | | internal BaseVariable<bool> walletVisible => DataStore.i.wallet.isWalletSectionVisible; |
| 208 | 63 | | internal BaseVariable<bool> isMyAccountInitialized => DataStore.i.myAccount.isInitialized; |
| 52 | 64 | | internal BaseVariable<bool> myAccountVisible => DataStore.i.myAccount.isMyAccountSectionVisible; |
| | 65 | |
|
| 240 | 66 | | internal BaseVariable<int> currentSectionIndex => DataStore.i.exploreV2.currentSectionIndex; |
| 177 | 67 | | private UserProfile ownUserProfile => UserProfile.GetOwnUserProfile(); |
| 52 | 68 | | private BaseVariable<bool> isPlacesAndEventsSectionInitialized => DataStore.i.exploreV2.isPlacesAndEventsSectionInit |
| 21 | 69 | | private BaseVariable<bool> isPromoteChannelsToastVisible => DataStore.i.channels.isPromoteToastVisible; |
| | 70 | |
|
| 52 | 71 | | private RectTransform topMenuTooltipReference => view.currentTopMenuTooltipReference; |
| 52 | 72 | | private RectTransform placesAndEventsTooltipReference => view.currentPlacesAndEventsTooltipReference; |
| 52 | 73 | | private RectTransform backpackTooltipReference => view.currentBackpackTooltipReference; |
| 52 | 74 | | private RectTransform mapTooltipReference => view.currentMapTooltipReference; |
| 52 | 75 | | private RectTransform questTooltipReference => view.currentQuestTooltipReference; |
| 52 | 76 | | private RectTransform settingsTooltipReference => view.currentSettingsTooltipReference; |
| 52 | 77 | | private RectTransform cameraReelTooltipReference => view.cameraReelTooltipReference; |
| 52 | 78 | | private RectTransform profileCardTooltipReference => view.currentProfileCardTooltipReference; |
| | 79 | |
|
| 52 | 80 | | public ExploreV2MenuComponentController(IPlacesAPIService placesAPIService, IWorldsAPIService worldsAPIService, IPla |
| | 81 | | IRealmsInfoBridge realmsInfoBridge) |
| | 82 | | { |
| 52 | 83 | | this.placesAPIService = placesAPIService; |
| 52 | 84 | | this.worldsAPIService = worldsAPIService; |
| 52 | 85 | | this.placesAnalytics = placesAnalytics; |
| 52 | 86 | | this.realmsInfoBridge = realmsInfoBridge; |
| 52 | 87 | | } |
| | 88 | |
|
| | 89 | | public void Initialize() |
| | 90 | | { |
| 52 | 91 | | sectionsVariables = new Dictionary<ExploreSection, (BaseVariable<bool>, BaseVariable<bool>)> |
| | 92 | | { |
| | 93 | | { ExploreSection.Explore, (isPlacesAndEventsSectionInitialized, placesAndEventsVisible) }, |
| | 94 | | { ExploreSection.Quest, (isQuestInitialized, questVisible) }, |
| | 95 | | { ExploreSection.Backpack, (isAvatarEditorInitialized, avatarEditorVisible) }, |
| | 96 | | { ExploreSection.Map, (isNavmapInitialized, navmapVisible) }, |
| | 97 | | { ExploreSection.CameraReel, (isCameraReelInitialized, cameraReelSectionVisible) }, |
| | 98 | | { ExploreSection.Settings, (isSettingsPanelInitialized, settingsVisible) }, |
| | 99 | | { ExploreSection.Wallet, (isWalletInitialized, walletVisible) }, |
| | 100 | | { ExploreSection.MyAccount, (isMyAccountInitialized, myAccountVisible) }, |
| | 101 | | }; |
| | 102 | |
|
| 884 | 103 | | sectionsByInitVar = sectionsVariables.ToDictionary(pair => pair.Value.initVar, pair => pair.Key); |
| 884 | 104 | | sectionsByVisibilityVar = sectionsVariables.ToDictionary(pair => pair.Value.visibilityVar, pair => pair.Key); |
| | 105 | |
|
| 52 | 106 | | mouseCatcher = SceneReferences.i?.mouseCatcher; |
| 52 | 107 | | exploreV2Analytics = CreateAnalyticsController(); |
| | 108 | |
|
| 52 | 109 | | view = CreateView(); |
| 52 | 110 | | SetVisibility(false); |
| | 111 | |
|
| 52 | 112 | | realmController = new ExploreV2ComponentRealmsController(DataStore.i.realm, view); |
| 52 | 113 | | realmController.Initialize(); |
| 52 | 114 | | view.currentRealmViewer.onLogoClick?.AddListener(ShowRealmSelectorModal); |
| | 115 | |
|
| 52 | 116 | | if (isWalletInitialized.Get()) |
| 0 | 117 | | OnWalletInitialized(true, false); |
| | 118 | | else |
| 52 | 119 | | isWalletInitialized.OnChange += OnWalletInitialized; |
| | 120 | |
|
| 52 | 121 | | if (isMyAccountInitialized.Get()) |
| 0 | 122 | | OnMyAccountInitialized(true, false); |
| | 123 | | else |
| 52 | 124 | | isMyAccountInitialized.OnChange += OnMyAccountInitialized; |
| | 125 | |
|
| 52 | 126 | | ownUserProfile.OnUpdate += UpdateProfileInfo; |
| 52 | 127 | | UpdateProfileInfo(ownUserProfile); |
| 52 | 128 | | view.currentProfileCard.onClick?.AddListener(() => { profileCardIsOpen.Set(!profileCardIsOpen.Get()); }); |
| | 129 | |
|
| 52 | 130 | | view.OnCloseButtonPressed += OnCloseButtonPressed; |
| 52 | 131 | | view.OnAfterShowAnimation += OnAfterShowAnimation; |
| | 132 | |
|
| 52 | 133 | | DataStore.i.exploreV2.topMenuTooltipReference.Set(topMenuTooltipReference); |
| 52 | 134 | | DataStore.i.exploreV2.placesAndEventsTooltipReference.Set(placesAndEventsTooltipReference); |
| 52 | 135 | | DataStore.i.exploreV2.questTooltipReference.Set(questTooltipReference); |
| 52 | 136 | | DataStore.i.exploreV2.backpackTooltipReference.Set(backpackTooltipReference); |
| 52 | 137 | | DataStore.i.exploreV2.mapTooltipReference.Set(mapTooltipReference); |
| 52 | 138 | | DataStore.i.exploreV2.settingsTooltipReference.Set(settingsTooltipReference); |
| 52 | 139 | | DataStore.i.exploreV2.profileCardTooltipReference.Set(profileCardTooltipReference); |
| 52 | 140 | | DataStore.i.exploreV2.cameraReelTooltipReference.Set(cameraReelTooltipReference); |
| | 141 | |
|
| 52 | 142 | | view.OnSectionOpen += OnSectionOpen; |
| | 143 | |
|
| 52 | 144 | | isOpen.OnChange += SetVisibilityOnOpenChanged; |
| 52 | 145 | | SetVisibilityOnOpenChanged(isOpen.Get()); |
| | 146 | |
|
| 52 | 147 | | currentSectionIndex.OnChange += CurrentSectionIndexChanged; |
| 52 | 148 | | CurrentSectionIndexChanged(currentSectionIndex.Get(), 0); |
| | 149 | |
|
| 936 | 150 | | foreach ((BaseVariable<bool> initVar, BaseVariable<bool> visibilityVar) sectionsVars in sectionsVariables.Values |
| | 151 | | { |
| 416 | 152 | | sectionsVars.initVar.OnChangeWithSenderInfo += OnSectionInitializedChanged; |
| 416 | 153 | | OnSectionInitializedChanged(sectionsVars.initVar, sectionsVars.initVar.Get()); |
| | 154 | |
|
| 416 | 155 | | sectionsVars.visibilityVar.OnChangeWithSenderInfo += OnSectionVisibilityChanged; |
| 416 | 156 | | OnSectionVisibilityChanged(sectionsVars.visibilityVar, sectionsVars.visibilityVar.Get()); |
| | 157 | | } |
| | 158 | |
|
| 52 | 159 | | isInitialized.Set(true); |
| | 160 | |
|
| 52 | 161 | | currentSectionIndex.Set((int)DEFAULT_SECTION, false); |
| | 162 | |
|
| 52 | 163 | | view.ConfigureEncapsulatedSection(ExploreSection.Map, DataStore.i.exploreV2.configureMapInFullscreenMenu); |
| 52 | 164 | | view.ConfigureEncapsulatedSection(ExploreSection.Settings, DataStore.i.exploreV2.configureSettingsInFullscreenMe |
| 52 | 165 | | view.ConfigureEncapsulatedSection(ExploreSection.CameraReel, DataStore.i.exploreV2.configureCameraReelInFullScre |
| 52 | 166 | | view.ConfigureEncapsulatedSection(ExploreSection.Wallet, DataStore.i.exploreV2.configureWalletSectionInFullscree |
| 52 | 167 | | view.ConfigureEncapsulatedSection(ExploreSection.MyAccount, DataStore.i.exploreV2.configureMyAccountSectionInFul |
| | 168 | |
|
| 52 | 169 | | DataStore.i.common.isWorld.OnChange += OnWorldChange; |
| 52 | 170 | | } |
| | 171 | |
|
| | 172 | | public void Dispose() |
| | 173 | | { |
| 52 | 174 | | realmController.Dispose(); |
| | 175 | |
|
| 52 | 176 | | ownUserProfile.OnUpdate -= UpdateProfileInfo; |
| 52 | 177 | | view?.currentProfileCard.onClick?.RemoveAllListeners(); |
| | 178 | |
|
| 52 | 179 | | isOpen.OnChange -= SetVisibilityOnOpenChanged; |
| 52 | 180 | | currentSectionIndex.OnChange -= CurrentSectionIndexChanged; |
| | 181 | |
|
| 936 | 182 | | foreach ((BaseVariable<bool> initVar, BaseVariable<bool> visibilityVar) sectionsVars in sectionsVariables.Values |
| | 183 | | { |
| 416 | 184 | | sectionsVars.initVar.OnChangeWithSenderInfo -= OnSectionInitializedChanged; |
| 416 | 185 | | sectionsVars.visibilityVar.OnChangeWithSenderInfo -= OnSectionVisibilityChanged; |
| | 186 | | } |
| | 187 | |
|
| 52 | 188 | | if (placesAndEventsSectionController != null) |
| | 189 | | { |
| 1 | 190 | | placesAndEventsSectionController.OnCloseExploreV2 -= OnCloseButtonPressed; |
| 1 | 191 | | placesAndEventsSectionController.Dispose(); |
| | 192 | | } |
| | 193 | |
|
| 52 | 194 | | if (view != null) |
| | 195 | | { |
| 52 | 196 | | view.currentProfileCard.onClick?.RemoveAllListeners(); |
| 52 | 197 | | view.currentRealmViewer.onLogoClick?.RemoveAllListeners(); |
| 52 | 198 | | view.OnCloseButtonPressed -= OnCloseButtonPressed; |
| 52 | 199 | | view.OnAfterShowAnimation -= OnAfterShowAnimation; |
| 52 | 200 | | view.OnSectionOpen -= OnSectionOpen; |
| 52 | 201 | | view.Dispose(); |
| | 202 | | } |
| | 203 | |
|
| 52 | 204 | | DataStore.i.common.isWorld.OnChange -= OnWorldChange; |
| | 205 | |
|
| 52 | 206 | | isWalletInitialized.OnChange -= OnWalletInitialized; |
| 52 | 207 | | walletCardHUDController?.Dispose(); |
| | 208 | |
|
| 52 | 209 | | isMyAccountInitialized.OnChange -= OnMyAccountInitialized; |
| 52 | 210 | | } |
| | 211 | |
|
| | 212 | | protected internal virtual IExploreV2MenuComponentView CreateView() => |
| 0 | 213 | | ExploreV2MenuComponentView.Create(); |
| | 214 | |
|
| | 215 | | private void OnWalletInitialized(bool current, bool previous) |
| | 216 | | { |
| 0 | 217 | | if (!current) |
| 0 | 218 | | return; |
| | 219 | |
|
| 0 | 220 | | isWalletInitialized.OnChange -= OnWalletInitialized; |
| | 221 | |
|
| 0 | 222 | | walletCardHUDController = new WalletCardHUDController( |
| | 223 | | view.currentWalletCard, |
| | 224 | | new UserProfileWebInterfaceBridge(), |
| | 225 | | Environment.i.platform.serviceProviders.theGraph, |
| | 226 | | DataStore.i); |
| 0 | 227 | | } |
| | 228 | |
|
| | 229 | | private void OnMyAccountInitialized(bool current, bool previous) |
| | 230 | | { |
| 0 | 231 | | if (!current) |
| 0 | 232 | | return; |
| | 233 | |
|
| 0 | 234 | | isMyAccountInitialized.OnChange -= OnMyAccountInitialized; |
| 0 | 235 | | } |
| | 236 | |
|
| | 237 | | internal virtual IExploreV2Analytics CreateAnalyticsController() => |
| 0 | 238 | | new ExploreV2Analytics.ExploreV2Analytics(); |
| | 239 | |
|
| | 240 | | internal void InitializePlacesAndEventsSection() |
| | 241 | | { |
| 1 | 242 | | if (placesAndEventsSectionController != null) |
| 0 | 243 | | return; |
| | 244 | |
|
| 1 | 245 | | placesAndEventsSectionController = new PlacesAndEventsSectionComponentController( |
| | 246 | | view.currentPlacesAndEventsSection, exploreV2Analytics, DataStore.i, new UserProfileWebInterfaceBridge(), |
| | 247 | | Environment.i.serviceLocator.Get<IFriendsController>(), placesAPIService, worldsAPIService, placesAnalytics) |
| | 248 | |
|
| 1 | 249 | | placesAndEventsSectionController.OnCloseExploreV2 += OnCloseButtonPressed; |
| 1 | 250 | | } |
| | 251 | |
|
| | 252 | | private void OnSectionInitializedChanged(BaseVariable<bool> initVar, bool initialized, bool _ = false) => |
| 420 | 253 | | SectionInitializedChanged(sectionsByInitVar[initVar], initialized); |
| | 254 | |
|
| | 255 | | internal void SectionInitializedChanged(ExploreSection section, bool initialized, bool _ = false) |
| | 256 | | { |
| 428 | 257 | | view.SetSectionActive(section, initialized); |
| | 258 | |
|
| 428 | 259 | | if (section == ExploreSection.Explore && initialized) |
| 0 | 260 | | InitializePlacesAndEventsSection(); |
| 428 | 261 | | } |
| | 262 | |
|
| | 263 | | public void SetVisibility(bool visible) => |
| 72 | 264 | | isOpen.Set(visible); |
| | 265 | |
|
| | 266 | | internal void SetVisibilityOnOpenChanged(bool open, bool _ = false) => |
| 77 | 267 | | SetVisibility_Internal(open); |
| | 268 | |
|
| | 269 | | internal void SetMenuTargetVisibility(ExploreSection section, bool toVisible, bool _ = false) |
| | 270 | | { |
| 132 | 271 | | if (toVisible) |
| | 272 | | { |
| 16 | 273 | | if (currentSectionIndex.Get() != (int)section) |
| 11 | 274 | | currentSectionIndex.Set((int)section); |
| | 275 | |
|
| 16 | 276 | | SetSectionTargetVisibility(section, toVisible: true); |
| | 277 | | } |
| 116 | 278 | | else if (currentOpenSection == section) |
| 56 | 279 | | SetSectionTargetVisibility(section, toVisible: false); |
| 116 | 280 | | } |
| | 281 | |
|
| | 282 | | private void SetSectionTargetVisibility(ExploreSection section, bool toVisible) |
| | 283 | | { |
| 72 | 284 | | bool wasInTargetVisibility = toVisible ^ isOpen.Get(); |
| | 285 | |
|
| 72 | 286 | | if (wasInTargetVisibility) |
| | 287 | | { |
| 16 | 288 | | SetVisibility(toVisible); |
| 16 | 289 | | exploreV2Analytics.SendStartMenuVisibility(toVisible, ExploreUIVisibilityMethod.FromShortcut); |
| | 290 | | } |
| | 291 | |
|
| 72 | 292 | | exploreV2Analytics.SendStartMenuSectionVisibility(section, toVisible); |
| 72 | 293 | | } |
| | 294 | |
|
| | 295 | | private void SetVisibility_Internal(bool visible) |
| | 296 | | { |
| 77 | 297 | | if (view == null || DataStore.i.common.isSignUpFlow.Get()) |
| 0 | 298 | | return; |
| | 299 | |
|
| 77 | 300 | | if (visible) |
| | 301 | | { |
| | 302 | | // TODO: This is temporal while we want to keep the NEW tag for the new Backpack feature |
| 21 | 303 | | if (DataStore.i.featureFlags.flags.Get().IsFeatureEnabled("backpack_editor_v2")) |
| 0 | 304 | | view.SetSectionAsNew(ExploreSection.Backpack, false); |
| | 305 | |
|
| 21 | 306 | | view.SetWalletActive(isWalletInitialized.Get(), ownUserProfile.isGuest); |
| | 307 | |
|
| 21 | 308 | | if (mouseCatcher != null) |
| 0 | 309 | | mouseCatcher.UnlockCursor(); |
| | 310 | |
|
| 21 | 311 | | if (DataStore.i.common.isTutorialRunning.Get()) |
| 1 | 312 | | view.GoToSection(DEFAULT_SECTION); |
| | 313 | |
|
| 21 | 314 | | isPromoteChannelsToastVisible.Set(false); |
| | 315 | | } |
| | 316 | | else |
| | 317 | | { |
| 56 | 318 | | CommonScriptableObjects.isFullscreenHUDOpen.Set(false); |
| | 319 | |
|
| 1008 | 320 | | foreach ((BaseVariable<bool> initVar, BaseVariable<bool> visibilityVar) sectionsVars in sectionsVariables.Va |
| 448 | 321 | | sectionsVars.visibilityVar.Set(false); |
| | 322 | |
|
| 56 | 323 | | profileCardIsOpen.Set(false); |
| | 324 | | } |
| | 325 | |
|
| 77 | 326 | | DataStore.i.wallet.isWalletCardVisible.Set(visible); |
| 77 | 327 | | view.SetVisible(visible); |
| 77 | 328 | | } |
| | 329 | |
|
| | 330 | | private void OnSectionVisibilityChanged(BaseVariable<bool> visibilityVar, bool visible, bool previous = false) |
| | 331 | | { |
| 426 | 332 | | ExploreSection section = sectionsByVisibilityVar[visibilityVar]; |
| | 333 | |
|
| 426 | 334 | | if (section is ExploreSection.Wallet or ExploreSection.MyAccount) |
| 104 | 335 | | return; |
| | 336 | |
|
| 322 | 337 | | BaseVariable<bool> initVar = section == ExploreSection.Explore ? isInitialized : sectionsVariables[section].init |
| | 338 | |
|
| 322 | 339 | | if (!initVar.Get() || DataStore.i.common.isSignUpFlow.Get()) |
| 205 | 340 | | return; |
| | 341 | |
|
| 117 | 342 | | SetMenuTargetVisibility(sectionsByVisibilityVar[visibilityVar], visible); |
| 117 | 343 | | } |
| | 344 | |
|
| | 345 | | private void ChangeVisibilityVarForSwitchedSections() |
| | 346 | | { |
| 180 | 347 | | foreach (BaseVariable<bool> visibilityVar in sectionsByVisibilityVar.Keys) |
| 80 | 348 | | if (visibilityVar.Get() != (currentOpenSection == sectionsByVisibilityVar[visibilityVar])) |
| 10 | 349 | | visibilityVar.Set(currentOpenSection == sectionsByVisibilityVar[visibilityVar]); |
| 10 | 350 | | } |
| | 351 | |
|
| | 352 | | internal void OnSectionOpen(ExploreSection section) |
| | 353 | | { |
| 10 | 354 | | if (section != currentOpenSection) |
| 9 | 355 | | exploreV2Analytics.SendStartMenuSectionVisibility(currentOpenSection, false); |
| | 356 | |
|
| 10 | 357 | | currentOpenSection = section; |
| | 358 | |
|
| 10 | 359 | | if (currentOpenSection == ExploreSection.Backpack) |
| 2 | 360 | | view.ConfigureEncapsulatedSection(ExploreSection.Backpack, DataStore.i.exploreV2.configureBackpackInFullscre |
| | 361 | |
|
| 10 | 362 | | if (currentOpenSection == ExploreSection.Quest) |
| 2 | 363 | | view.ConfigureEncapsulatedSection(ExploreSection.Quest, DataStore.i.exploreV2.configureQuestInFullscreenMenu |
| | 364 | |
|
| 10 | 365 | | if (currentOpenSection == ExploreSection.CameraReel) |
| 0 | 366 | | DataStore.i.HUDs.cameraReelOpenSource.Set("Menu"); |
| | 367 | |
|
| 10 | 368 | | ChangeVisibilityVarForSwitchedSections(); |
| | 369 | |
|
| 10 | 370 | | profileCardIsOpen.Set(false); |
| 10 | 371 | | } |
| | 372 | |
|
| | 373 | | internal void CurrentSectionIndexChanged(int current, int previous) |
| | 374 | | { |
| 544 | 375 | | if (DataStore.i.exploreV2.isInShowAnimationTransiton.Get()) |
| 0 | 376 | | return; |
| | 377 | |
|
| 544 | 378 | | if (Enum.IsDefined(typeof(ExploreSection), current)) |
| | 379 | | { |
| 473 | 380 | | if (!view.IsSectionActive((ExploreSection)current)) |
| 473 | 381 | | CurrentSectionIndexChanged(current + 1, current); |
| | 382 | | else |
| 0 | 383 | | view.GoToSection((ExploreSection)current); |
| | 384 | | } |
| | 385 | | else |
| 71 | 386 | | view.GoToSection(0); |
| 71 | 387 | | } |
| | 388 | |
|
| | 389 | | private static void OnAfterShowAnimation() => |
| 0 | 390 | | CommonScriptableObjects.isFullscreenHUDOpen.Set(true); |
| | 391 | |
|
| | 392 | | internal void UpdateProfileInfo(UserProfile profile) |
| | 393 | | { |
| 53 | 394 | | view.currentProfileCard.SetIsClaimedName(profile.hasClaimedName); |
| 53 | 395 | | view.currentProfileCard.SetProfileName(profile.userName); |
| 53 | 396 | | view.currentProfileCard.SetProfileAddress(profile.ethAddress); |
| 53 | 397 | | view.currentProfileCard.SetProfilePicture(profile.face256SnapshotURL); |
| 53 | 398 | | } |
| | 399 | |
|
| | 400 | | internal void OnCloseButtonPressed(bool fromShortcut) |
| | 401 | | { |
| 2 | 402 | | SetVisibility(false); |
| 2 | 403 | | exploreV2Analytics.SendStartMenuVisibility(false, fromShortcut ? ExploreUIVisibilityMethod.FromShortcut : Explor |
| 2 | 404 | | } |
| | 405 | |
|
| | 406 | | private void OnWorldChange(bool isWorld, bool wasWorld) |
| | 407 | | { |
| 0 | 408 | | if (isWorld == wasWorld) return; |
| | 409 | |
|
| 0 | 410 | | if (isWorld && view.IsSectionActive(ExploreSection.Map)) |
| 0 | 411 | | view.HideMapOnEnteringWorld(); |
| | 412 | |
|
| 0 | 413 | | view.SetSectionActive(ExploreSection.Map, !isWorld); |
| 0 | 414 | | } |
| | 415 | |
|
| | 416 | | private void ShowRealmSelectorModal() |
| | 417 | | { |
| | 418 | | async UniTask FetchRealmsThenShowModalAsync(CancellationToken cancellationToken) |
| | 419 | | { |
| 2 | 420 | | try { await realmsInfoBridge.FetchRealmsInfo(cancellationToken); } |
| 0 | 421 | | catch (OperationCanceledException) { return; } |
| 0 | 422 | | catch (Exception e) { Debug.LogException(e); } |
| | 423 | |
|
| 1 | 424 | | view.ShowRealmSelectorModal(); |
| 1 | 425 | | } |
| | 426 | |
|
| 1 | 427 | | openRealmSelectorCancellationToken = openRealmSelectorCancellationToken.SafeRestart(); |
| 1 | 428 | | FetchRealmsThenShowModalAsync(openRealmSelectorCancellationToken.Token).Forget(); |
| 1 | 429 | | } |
| | 430 | | } |