| | 1 | | using DCL; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using ExploreV2Analytics; |
| | 4 | | using System; |
| | 5 | | using System.Collections; |
| | 6 | | using System.Collections.Generic; |
| | 7 | | using System.Linq; |
| | 8 | | using UnityEngine; |
| | 9 | | using Variables.RealmsInfo; |
| | 10 | |
|
| | 11 | | /// <summary> |
| | 12 | | /// Main controller for the feature "Explore V2". |
| | 13 | | /// </summary> |
| | 14 | | public class ExploreV2MenuComponentController : IExploreV2MenuComponentController |
| | 15 | | { |
| | 16 | | internal const float MIN_TIME_AFTER_CLOSE_OTHER_UI_TO_OPEN_START_MENU = 0.1f; |
| | 17 | |
|
| 138 | 18 | | internal UserProfile ownUserProfile => UserProfile.GetOwnUserProfile(); |
| 46 | 19 | | internal RectTransform topMenuTooltipReference { get => view.currentTopMenuTooltipReference; } |
| 46 | 20 | | internal RectTransform placesAndEventsTooltipReference { get => view.currentPlacesAndEventsTooltipReference; } |
| 46 | 21 | | internal RectTransform backpackTooltipReference { get => view.currentBackpackTooltipReference; } |
| 46 | 22 | | internal RectTransform mapTooltipReference { get => view.currentMapTooltipReference; } |
| 46 | 23 | | internal RectTransform builderTooltipReference { get => view.currentBuilderTooltipReference; } |
| 46 | 24 | | internal RectTransform questTooltipReference { get => view.currentQuestTooltipReference; } |
| 46 | 25 | | internal RectTransform settingsTooltipReference { get => view.currentSettingsTooltipReference; } |
| 46 | 26 | | internal RectTransform profileCardTooltipReference { get => view.currentProfileCardTooltipReference; } |
| | 27 | |
|
| | 28 | | internal IExploreV2MenuComponentView view; |
| | 29 | | internal IPlacesAndEventsSectionComponentController placesAndEventsSectionController; |
| | 30 | | internal IExploreV2Analytics exploreV2Analytics; |
| | 31 | | internal ExploreSection currentOpenSection; |
| | 32 | | internal float controlsHUDCloseTime = 0f; |
| | 33 | | internal float emotesHUDCloseTime = 0f; |
| | 34 | | internal float playerInfoCardHUDCloseTime = 0f; |
| | 35 | | internal float chatInputHUDCloseTime = 0f; |
| 46 | 36 | | internal List<RealmRowComponentModel> currentAvailableRealms = new List<RealmRowComponentModel>(); |
| | 37 | |
|
| 262 | 38 | | internal BaseVariable<bool> isOpen => DataStore.i.exploreV2.isOpen; |
| 138 | 39 | | internal BaseVariable<int> currentSectionIndex => DataStore.i.exploreV2.currentSectionIndex; |
| 63 | 40 | | internal BaseVariable<bool> profileCardIsOpen => DataStore.i.exploreV2.profileCardIsOpen; |
| 97 | 41 | | internal BaseVariable<bool> isInitialized => DataStore.i.exploreV2.isInitialized; |
| 138 | 42 | | internal BaseVariable<bool> isPlacesAndEventsSectionInitialized => DataStore.i.exploreV2.isPlacesAndEventsSectionIni |
| 201 | 43 | | internal BaseVariable<bool> placesAndEventsVisible => DataStore.i.exploreV2.placesAndEventsVisible; |
| 189 | 44 | | internal BaseVariable<bool> isAvatarEditorInitialized => DataStore.i.HUDs.isAvatarEditorInitialized; |
| 201 | 45 | | internal BaseVariable<bool> avatarEditorVisible => DataStore.i.HUDs.avatarEditorVisible; |
| 189 | 46 | | internal BaseVariable<bool> isNavmapInitialized => DataStore.i.HUDs.isNavMapInitialized; |
| 201 | 47 | | internal BaseVariable<bool> navmapVisible => DataStore.i.HUDs.navmapVisible; |
| 189 | 48 | | internal BaseVariable<bool> isBuilderInitialized => DataStore.i.builderInWorld.isInitialized; |
| 201 | 49 | | internal BaseVariable<bool> builderVisible => DataStore.i.HUDs.builderProjectsPanelVisible; |
| 189 | 50 | | internal BaseVariable<bool> isQuestInitialized => DataStore.i.Quests.isInitialized; |
| 201 | 51 | | internal BaseVariable<bool> questVisible => DataStore.i.HUDs.questsPanelVisible; |
| 189 | 52 | | internal BaseVariable<bool> isSettingsPanelInitialized => DataStore.i.settings.isInitialized; |
| 201 | 53 | | internal BaseVariable<bool> settingsVisible => DataStore.i.settings.settingsPanelVisible; |
| | 54 | |
|
| 46 | 55 | | internal BaseVariable<bool> controlsVisible => DataStore.i.HUDs.controlsVisible; |
| 46 | 56 | | internal BaseVariable<bool> emotesVisible => DataStore.i.HUDs.emotesVisible; |
| 46 | 57 | | internal BaseVariable<bool> chatInputVisible => DataStore.i.HUDs.chatInputVisible; |
| 46 | 58 | | internal BooleanVariable playerInfoCardVisible => CommonScriptableObjects.playerInfoCardVisibleState; |
| | 59 | |
|
| | 60 | | public void Initialize() |
| | 61 | | { |
| 46 | 62 | | exploreV2Analytics = CreateAnalyticsController(); |
| 46 | 63 | | view = CreateView(); |
| 46 | 64 | | SetVisibility(false); |
| | 65 | |
|
| 46 | 66 | | DataStore.i.realm.playerRealm.OnChange += UpdateRealmInfo; |
| 46 | 67 | | UpdateRealmInfo(DataStore.i.realm.playerRealm.Get(), null); |
| | 68 | |
|
| 46 | 69 | | DataStore.i.realm.realmsInfo.OnSet += UpdateAvailableRealmsInfo; |
| 46 | 70 | | UpdateAvailableRealmsInfo(DataStore.i.realm.realmsInfo.Get()); |
| | 71 | |
|
| 46 | 72 | | ownUserProfile.OnUpdate += UpdateProfileInfo; |
| 46 | 73 | | UpdateProfileInfo(ownUserProfile); |
| 46 | 74 | | view.currentProfileCard.onClick?.AddListener(() => { profileCardIsOpen.Set(!profileCardIsOpen.Get()); }); |
| 46 | 75 | | view.currentRealmViewer.onLogoClick?.AddListener(view.ShowRealmSelectorModal); |
| 46 | 76 | | view.OnCloseButtonPressed += OnCloseButtonPressed; |
| 46 | 77 | | view.OnAfterShowAnimation += OnAfterShowAnimation; |
| | 78 | |
|
| 46 | 79 | | DataStore.i.exploreV2.topMenuTooltipReference.Set(topMenuTooltipReference); |
| 46 | 80 | | DataStore.i.exploreV2.placesAndEventsTooltipReference.Set(placesAndEventsTooltipReference); |
| 46 | 81 | | DataStore.i.exploreV2.backpackTooltipReference.Set(backpackTooltipReference); |
| 46 | 82 | | DataStore.i.exploreV2.mapTooltipReference.Set(mapTooltipReference); |
| 46 | 83 | | DataStore.i.exploreV2.builderTooltipReference.Set(builderTooltipReference); |
| 46 | 84 | | DataStore.i.exploreV2.questTooltipReference.Set(questTooltipReference); |
| 46 | 85 | | DataStore.i.exploreV2.settingsTooltipReference.Set(settingsTooltipReference); |
| 46 | 86 | | DataStore.i.exploreV2.profileCardTooltipReference.Set(profileCardTooltipReference); |
| | 87 | |
|
| 46 | 88 | | view.OnSectionOpen += OnSectionOpen; |
| | 89 | |
|
| 46 | 90 | | isOpen.OnChange += IsOpenChanged; |
| 46 | 91 | | IsOpenChanged(isOpen.Get(), false); |
| | 92 | |
|
| 46 | 93 | | currentSectionIndex.OnChange += CurrentSectionIndexChanged; |
| 46 | 94 | | CurrentSectionIndexChanged(currentSectionIndex.Get(), 0); |
| | 95 | |
|
| 46 | 96 | | isPlacesAndEventsSectionInitialized.OnChange += IsPlacesAndEventsSectionInitializedChanged; |
| 46 | 97 | | IsPlacesAndEventsSectionInitializedChanged(isPlacesAndEventsSectionInitialized.Get(), false); |
| 46 | 98 | | placesAndEventsVisible.OnChange += PlacesAndEventsVisibleChanged; |
| 46 | 99 | | PlacesAndEventsVisibleChanged(placesAndEventsVisible.Get(), false); |
| | 100 | |
|
| 46 | 101 | | isAvatarEditorInitialized.OnChange += IsAvatarEditorInitializedChanged; |
| 46 | 102 | | IsAvatarEditorInitializedChanged(isAvatarEditorInitialized.Get(), false); |
| 46 | 103 | | avatarEditorVisible.OnChange += AvatarEditorVisibleChanged; |
| 46 | 104 | | AvatarEditorVisibleChanged(avatarEditorVisible.Get(), false); |
| | 105 | |
|
| 46 | 106 | | isNavmapInitialized.OnChange += IsNavMapInitializedChanged; |
| 46 | 107 | | IsNavMapInitializedChanged(isNavmapInitialized.Get(), false); |
| 46 | 108 | | navmapVisible.OnChange += NavmapVisibleChanged; |
| 46 | 109 | | NavmapVisibleChanged(navmapVisible.Get(), false); |
| | 110 | |
|
| 46 | 111 | | isBuilderInitialized.OnChange += IsBuilderInitializedChanged; |
| 46 | 112 | | IsBuilderInitializedChanged(isBuilderInitialized.Get(), false); |
| 46 | 113 | | builderVisible.OnChange += BuilderVisibleChanged; |
| 46 | 114 | | BuilderVisibleChanged(builderVisible.Get(), false); |
| | 115 | |
|
| 46 | 116 | | isQuestInitialized.OnChange += IsQuestInitializedChanged; |
| 46 | 117 | | IsQuestInitializedChanged(isQuestInitialized.Get(), false); |
| 46 | 118 | | questVisible.OnChange += QuestVisibleChanged; |
| 46 | 119 | | QuestVisibleChanged(questVisible.Get(), false); |
| | 120 | |
|
| 46 | 121 | | isSettingsPanelInitialized.OnChange += IsSettingsPanelInitializedChanged; |
| 46 | 122 | | IsSettingsPanelInitializedChanged(isSettingsPanelInitialized.Get(), false); |
| 46 | 123 | | settingsVisible.OnChange += SettingsVisibleChanged; |
| 46 | 124 | | SettingsVisibleChanged(settingsVisible.Get(), false); |
| | 125 | |
|
| 46 | 126 | | ConfigureOhterUIDependencies(); |
| | 127 | |
|
| 46 | 128 | | isInitialized.Set(true); |
| 46 | 129 | | } |
| | 130 | |
|
| | 131 | | internal void InitializePlacesAndEventsSection() |
| | 132 | | { |
| 1 | 133 | | if (placesAndEventsSectionController != null) |
| 0 | 134 | | return; |
| | 135 | |
|
| 1 | 136 | | placesAndEventsSectionController = new PlacesAndEventsSectionComponentController(view.currentPlacesAndEventsSect |
| 1 | 137 | | placesAndEventsSectionController.OnCloseExploreV2 += OnCloseButtonPressed; |
| 1 | 138 | | } |
| | 139 | |
|
| | 140 | | internal void OnSectionOpen(ExploreSection section) |
| | 141 | | { |
| 6 | 142 | | if (section != currentOpenSection) |
| 5 | 143 | | exploreV2Analytics.SendStartMenuSectionVisibility(currentOpenSection, false); |
| | 144 | |
|
| 6 | 145 | | currentOpenSection = section; |
| | 146 | |
|
| 6 | 147 | | if (currentOpenSection == ExploreSection.Backpack) |
| | 148 | | { |
| 1 | 149 | | view.ConfigureEncapsulatedSection( |
| | 150 | | ExploreSection.Backpack, |
| | 151 | | DataStore.i.exploreV2.configureBackpackInFullscreenMenu); |
| | 152 | | } |
| | 153 | |
|
| 6 | 154 | | placesAndEventsVisible.Set(currentOpenSection == ExploreSection.Explore); |
| 6 | 155 | | avatarEditorVisible.Set(currentOpenSection == ExploreSection.Backpack); |
| 6 | 156 | | navmapVisible.Set(currentOpenSection == ExploreSection.Map); |
| 6 | 157 | | builderVisible.Set(currentOpenSection == ExploreSection.Builder); |
| 6 | 158 | | questVisible.Set(currentOpenSection == ExploreSection.Quest); |
| 6 | 159 | | settingsVisible.Set(currentOpenSection == ExploreSection.Settings); |
| 6 | 160 | | profileCardIsOpen.Set(false); |
| 6 | 161 | | } |
| | 162 | |
|
| | 163 | | public void Dispose() |
| | 164 | | { |
| 46 | 165 | | DataStore.i.realm.playerRealm.OnChange -= UpdateRealmInfo; |
| 46 | 166 | | DataStore.i.realm.realmsInfo.OnSet -= UpdateAvailableRealmsInfo; |
| 46 | 167 | | ownUserProfile.OnUpdate -= UpdateProfileInfo; |
| 46 | 168 | | view?.currentProfileCard.onClick?.RemoveAllListeners(); |
| 46 | 169 | | isOpen.OnChange -= IsOpenChanged; |
| 46 | 170 | | currentSectionIndex.OnChange -= CurrentSectionIndexChanged; |
| 46 | 171 | | isPlacesAndEventsSectionInitialized.OnChange -= IsPlacesAndEventsSectionInitializedChanged; |
| 46 | 172 | | placesAndEventsVisible.OnChange -= PlacesAndEventsVisibleChanged; |
| 46 | 173 | | isAvatarEditorInitialized.OnChange -= IsAvatarEditorInitializedChanged; |
| 46 | 174 | | avatarEditorVisible.OnChange -= AvatarEditorVisibleChanged; |
| 46 | 175 | | isNavmapInitialized.OnChange -= IsNavMapInitializedChanged; |
| 46 | 176 | | navmapVisible.OnChange -= NavmapVisibleChanged; |
| 46 | 177 | | isBuilderInitialized.OnChange -= IsBuilderInitializedChanged; |
| 46 | 178 | | builderVisible.OnChange -= BuilderVisibleChanged; |
| 46 | 179 | | isQuestInitialized.OnChange -= IsQuestInitializedChanged; |
| 46 | 180 | | questVisible.OnChange -= QuestVisibleChanged; |
| 46 | 181 | | isSettingsPanelInitialized.OnChange -= IsSettingsPanelInitializedChanged; |
| 46 | 182 | | settingsVisible.OnChange -= SettingsVisibleChanged; |
| | 183 | |
|
| 46 | 184 | | if (view != null) |
| | 185 | | { |
| 46 | 186 | | view.currentProfileCard.onClick?.RemoveAllListeners(); |
| 46 | 187 | | view.currentRealmViewer.onLogoClick?.RemoveAllListeners(); |
| 46 | 188 | | view.OnCloseButtonPressed -= OnCloseButtonPressed; |
| 46 | 189 | | view.OnAfterShowAnimation -= OnAfterShowAnimation; |
| 46 | 190 | | view.OnSectionOpen -= OnSectionOpen; |
| 46 | 191 | | view.Dispose(); |
| | 192 | | } |
| | 193 | |
|
| 46 | 194 | | if (placesAndEventsSectionController != null) |
| | 195 | | { |
| 1 | 196 | | placesAndEventsSectionController.OnCloseExploreV2 -= OnCloseButtonPressed; |
| 1 | 197 | | placesAndEventsSectionController.Dispose(); |
| | 198 | | } |
| 46 | 199 | | } |
| | 200 | |
|
| 120 | 201 | | public void SetVisibility(bool visible) { isOpen.Set(visible); } |
| | 202 | |
|
| 130 | 203 | | internal void IsOpenChanged(bool current, bool previous) { SetVisibility_Internal(current); } |
| | 204 | |
|
| | 205 | | internal void CurrentSectionIndexChanged(int current, int previous) |
| | 206 | | { |
| 350 | 207 | | if (DataStore.i.exploreV2.isInShowAnimationTransiton.Get()) |
| 0 | 208 | | return; |
| | 209 | |
|
| 350 | 210 | | if (Enum.IsDefined(typeof(ExploreSection), current)) |
| | 211 | | { |
| 297 | 212 | | if (!view.IsSectionActive((ExploreSection)current)) |
| 297 | 213 | | CurrentSectionIndexChanged(current + 1, current); |
| | 214 | | else |
| 0 | 215 | | view.GoToSection((ExploreSection)current); |
| 0 | 216 | | } |
| | 217 | | else |
| 53 | 218 | | view.GoToSection(0); |
| 53 | 219 | | } |
| | 220 | |
|
| | 221 | | internal void SetVisibility_Internal(bool visible) |
| | 222 | | { |
| 65 | 223 | | if (view == null || DataStore.i.common.isSignUpFlow.Get()) |
| 0 | 224 | | return; |
| | 225 | |
|
| 65 | 226 | | if (visible) |
| | 227 | | { |
| 15 | 228 | | Utils.UnlockCursor(); |
| | 229 | |
|
| 15 | 230 | | if (DataStore.i.common.isTutorialRunning.Get()) |
| 1 | 231 | | view.GoToSection(ExploreV2MenuComponentView.DEFAULT_SECTION); |
| 1 | 232 | | } |
| | 233 | | else |
| | 234 | | { |
| 50 | 235 | | CommonScriptableObjects.isFullscreenHUDOpen.Set(false); |
| 50 | 236 | | placesAndEventsVisible.Set(false); |
| 50 | 237 | | avatarEditorVisible.Set(false); |
| 50 | 238 | | profileCardIsOpen.Set(false); |
| 50 | 239 | | navmapVisible.Set(false); |
| 50 | 240 | | builderVisible.Set(false); |
| 50 | 241 | | questVisible.Set(false); |
| 50 | 242 | | settingsVisible.Set(false); |
| | 243 | | } |
| | 244 | |
|
| 65 | 245 | | view.SetVisible(visible); |
| 65 | 246 | | } |
| | 247 | |
|
| 0 | 248 | | internal void OnAfterShowAnimation() { CommonScriptableObjects.isFullscreenHUDOpen.Set(true); } |
| | 249 | |
|
| | 250 | | internal void IsPlacesAndEventsSectionInitializedChanged(bool current, bool previous) |
| | 251 | | { |
| 46 | 252 | | view.SetSectionActive(ExploreSection.Explore, current); |
| | 253 | |
|
| 46 | 254 | | if (current) |
| 0 | 255 | | InitializePlacesAndEventsSection(); |
| 46 | 256 | | } |
| | 257 | |
|
| | 258 | | internal void PlacesAndEventsVisibleChanged(bool current, bool previous) |
| | 259 | | { |
| 49 | 260 | | if (!isInitialized.Get() || DataStore.i.common.isSignUpFlow.Get()) |
| 1 | 261 | | return; |
| | 262 | |
|
| 48 | 263 | | if (current) |
| | 264 | | { |
| 2 | 265 | | if (!isOpen.Get()) |
| | 266 | | { |
| 2 | 267 | | SetVisibility(true); |
| 2 | 268 | | exploreV2Analytics.SendStartMenuVisibility(true, ExploreUIVisibilityMethod.FromShortcut); |
| | 269 | | } |
| | 270 | |
|
| 2 | 271 | | view.GoToSection(ExploreSection.Explore); |
| 2 | 272 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Explore, true); |
| 2 | 273 | | } |
| 46 | 274 | | else if (currentOpenSection == ExploreSection.Explore) |
| | 275 | | { |
| 46 | 276 | | if (isOpen.Get()) |
| | 277 | | { |
| 0 | 278 | | SetVisibility(false); |
| 0 | 279 | | exploreV2Analytics.SendStartMenuVisibility(false, ExploreUIVisibilityMethod.FromShortcut); |
| | 280 | | } |
| | 281 | |
|
| 46 | 282 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Explore, false); |
| | 283 | | } |
| 46 | 284 | | } |
| | 285 | |
|
| 98 | 286 | | internal void IsAvatarEditorInitializedChanged(bool current, bool previous) { view.SetSectionActive(ExploreSection.B |
| | 287 | |
|
| | 288 | | internal void AvatarEditorVisibleChanged(bool current, bool previous) |
| | 289 | | { |
| 49 | 290 | | if (!isAvatarEditorInitialized.Get() || DataStore.i.common.isSignUpFlow.Get()) |
| 5 | 291 | | return; |
| | 292 | |
|
| 44 | 293 | | if (current) |
| | 294 | | { |
| 2 | 295 | | if (!isOpen.Get()) |
| | 296 | | { |
| 2 | 297 | | SetVisibility(true); |
| 2 | 298 | | exploreV2Analytics.SendStartMenuVisibility(true, ExploreUIVisibilityMethod.FromShortcut); |
| | 299 | | } |
| | 300 | |
|
| 2 | 301 | | view.GoToSection(ExploreSection.Backpack); |
| 2 | 302 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Backpack, true); |
| 2 | 303 | | } |
| 42 | 304 | | else if (currentOpenSection == ExploreSection.Backpack) |
| | 305 | | { |
| 1 | 306 | | if (isOpen.Get()) |
| | 307 | | { |
| 0 | 308 | | SetVisibility(false); |
| 0 | 309 | | exploreV2Analytics.SendStartMenuVisibility(false, ExploreUIVisibilityMethod.FromShortcut); |
| | 310 | | } |
| | 311 | |
|
| 1 | 312 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Backpack, false); |
| | 313 | | } |
| 42 | 314 | | } |
| | 315 | |
|
| | 316 | | internal void IsNavMapInitializedChanged(bool current, bool previous) |
| | 317 | | { |
| 49 | 318 | | view.SetSectionActive(ExploreSection.Map, current); |
| | 319 | |
|
| 49 | 320 | | if (current) |
| 20 | 321 | | view.ConfigureEncapsulatedSection(ExploreSection.Map, DataStore.i.exploreV2.configureMapInFullscreenMenu); |
| 49 | 322 | | } |
| | 323 | |
|
| | 324 | | internal void NavmapVisibleChanged(bool current, bool previous) |
| | 325 | | { |
| 49 | 326 | | if (!isNavmapInitialized.Get() || DataStore.i.common.isSignUpFlow.Get()) |
| 28 | 327 | | return; |
| | 328 | |
|
| 21 | 329 | | if (current) |
| | 330 | | { |
| 2 | 331 | | if (!isOpen.Get()) |
| | 332 | | { |
| 2 | 333 | | SetVisibility(true); |
| 2 | 334 | | exploreV2Analytics.SendStartMenuVisibility(true, ExploreUIVisibilityMethod.FromShortcut); |
| | 335 | | } |
| | 336 | |
|
| 2 | 337 | | view.GoToSection(ExploreSection.Map); |
| 2 | 338 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Map, true); |
| 2 | 339 | | } |
| 19 | 340 | | else if (currentOpenSection == ExploreSection.Map) |
| | 341 | | { |
| 1 | 342 | | if (isOpen.Get()) |
| | 343 | | { |
| 0 | 344 | | SetVisibility(false); |
| 0 | 345 | | exploreV2Analytics.SendStartMenuVisibility(false, ExploreUIVisibilityMethod.FromShortcut); |
| | 346 | | } |
| | 347 | |
|
| 1 | 348 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Map, false); |
| | 349 | | } |
| 19 | 350 | | } |
| | 351 | |
|
| | 352 | | internal void IsBuilderInitializedChanged(bool current, bool previous) |
| | 353 | | { |
| 49 | 354 | | view.SetSectionActive(ExploreSection.Builder, current); |
| | 355 | |
|
| 49 | 356 | | if (current) |
| 41 | 357 | | view.ConfigureEncapsulatedSection(ExploreSection.Builder, DataStore.i.exploreV2.configureBuilderInFullscreen |
| 49 | 358 | | } |
| | 359 | |
|
| | 360 | | internal void BuilderVisibleChanged(bool current, bool previous) |
| | 361 | | { |
| 49 | 362 | | if (!isBuilderInitialized.Get() || DataStore.i.common.isSignUpFlow.Get()) |
| 7 | 363 | | return; |
| | 364 | |
|
| 42 | 365 | | if (current) |
| | 366 | | { |
| 2 | 367 | | if (!isOpen.Get()) |
| | 368 | | { |
| 2 | 369 | | SetVisibility(true); |
| 2 | 370 | | exploreV2Analytics.SendStartMenuVisibility(true, ExploreUIVisibilityMethod.FromShortcut); |
| | 371 | | } |
| | 372 | |
|
| 2 | 373 | | view.GoToSection(ExploreSection.Builder); |
| 2 | 374 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Builder, true); |
| 2 | 375 | | } |
| 40 | 376 | | else if (currentOpenSection == ExploreSection.Builder) |
| | 377 | | { |
| 1 | 378 | | if (isOpen.Get()) |
| | 379 | | { |
| 0 | 380 | | SetVisibility(false); |
| 0 | 381 | | exploreV2Analytics.SendStartMenuVisibility(false, ExploreUIVisibilityMethod.FromShortcut); |
| | 382 | | } |
| | 383 | |
|
| 1 | 384 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Builder, false); |
| | 385 | | } |
| 40 | 386 | | } |
| | 387 | |
|
| | 388 | | internal void IsQuestInitializedChanged(bool current, bool previous) |
| | 389 | | { |
| 49 | 390 | | view.SetSectionActive(ExploreSection.Quest, current); |
| | 391 | |
|
| 49 | 392 | | if (current) |
| 10 | 393 | | view.ConfigureEncapsulatedSection(ExploreSection.Quest, DataStore.i.exploreV2.configureQuestInFullscreenMenu |
| 49 | 394 | | } |
| | 395 | |
|
| | 396 | | internal void QuestVisibleChanged(bool current, bool previous) |
| | 397 | | { |
| 49 | 398 | | if (!isQuestInitialized.Get() || DataStore.i.common.isSignUpFlow.Get()) |
| 39 | 399 | | return; |
| | 400 | |
|
| 10 | 401 | | if (current) |
| | 402 | | { |
| 1 | 403 | | if (!isOpen.Get()) |
| | 404 | | { |
| 1 | 405 | | SetVisibility(true); |
| 1 | 406 | | exploreV2Analytics.SendStartMenuVisibility(true, ExploreUIVisibilityMethod.FromShortcut); |
| | 407 | | } |
| | 408 | |
|
| 1 | 409 | | view.GoToSection(ExploreSection.Quest); |
| 1 | 410 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Quest, true); |
| 1 | 411 | | } |
| 9 | 412 | | else if (currentOpenSection == ExploreSection.Quest) |
| | 413 | | { |
| 1 | 414 | | if (isOpen.Get()) |
| | 415 | | { |
| 0 | 416 | | SetVisibility(false); |
| 0 | 417 | | exploreV2Analytics.SendStartMenuVisibility(false, ExploreUIVisibilityMethod.FromShortcut); |
| | 418 | | } |
| | 419 | |
|
| 1 | 420 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Quest, false); |
| | 421 | | } |
| 9 | 422 | | } |
| | 423 | |
|
| | 424 | | internal void IsSettingsPanelInitializedChanged(bool current, bool previous) |
| | 425 | | { |
| 49 | 426 | | view.SetSectionActive(ExploreSection.Settings, current); |
| | 427 | |
|
| 49 | 428 | | if (current) |
| 8 | 429 | | view.ConfigureEncapsulatedSection(ExploreSection.Settings, DataStore.i.exploreV2.configureSettingsInFullscre |
| 49 | 430 | | } |
| | 431 | |
|
| | 432 | | internal void SettingsVisibleChanged(bool current, bool previous) |
| | 433 | | { |
| 49 | 434 | | if (!isSettingsPanelInitialized.Get() || DataStore.i.common.isSignUpFlow.Get()) |
| 41 | 435 | | return; |
| | 436 | |
|
| 8 | 437 | | if (current) |
| | 438 | | { |
| 1 | 439 | | if (!isOpen.Get()) |
| | 440 | | { |
| 1 | 441 | | SetVisibility(true); |
| 1 | 442 | | exploreV2Analytics.SendStartMenuVisibility(true, ExploreUIVisibilityMethod.FromShortcut); |
| | 443 | | } |
| 1 | 444 | | view.GoToSection(ExploreSection.Settings); |
| 1 | 445 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Settings, true); |
| 1 | 446 | | } |
| 7 | 447 | | else if (currentOpenSection == ExploreSection.Settings) |
| | 448 | | { |
| 1 | 449 | | if (isOpen.Get()) |
| | 450 | | { |
| 0 | 451 | | SetVisibility(false); |
| 0 | 452 | | exploreV2Analytics.SendStartMenuVisibility(false, ExploreUIVisibilityMethod.FromShortcut); |
| | 453 | | } |
| 1 | 454 | | exploreV2Analytics.SendStartMenuSectionVisibility(ExploreSection.Settings, false); |
| | 455 | | } |
| 7 | 456 | | } |
| | 457 | |
|
| | 458 | | internal void UpdateRealmInfo(CurrentRealmModel currentRealm, CurrentRealmModel previousRealm) |
| | 459 | | { |
| 48 | 460 | | if (currentRealm == null) |
| 46 | 461 | | return; |
| | 462 | |
|
| | 463 | | // Get the name of the current realm |
| 2 | 464 | | view.currentRealmViewer.SetRealm(currentRealm.serverName); |
| 2 | 465 | | view.currentRealmSelectorModal.SetCurrentRealm(currentRealm.serverName); |
| | 466 | |
|
| | 467 | | // Calculate number of users in the current realm |
| 2 | 468 | | List<RealmModel> realmList = DataStore.i.realm.realmsInfo.Get()?.ToList(); |
| 3 | 469 | | RealmModel currentRealmModel = realmList?.FirstOrDefault(r => r.serverName == currentRealm.serverName); |
| 2 | 470 | | int realmUsers = 0; |
| 2 | 471 | | if (currentRealmModel != null) |
| 1 | 472 | | realmUsers = currentRealmModel.usersCount; |
| | 473 | |
|
| 2 | 474 | | view.currentRealmViewer.SetNumberOfUsers(realmUsers); |
| 2 | 475 | | } |
| | 476 | |
|
| | 477 | | internal void UpdateAvailableRealmsInfo(IEnumerable<RealmModel> currentRealmList) |
| | 478 | | { |
| 48 | 479 | | if (!NeedToRefreshRealms(currentRealmList)) |
| 46 | 480 | | return; |
| | 481 | |
|
| 2 | 482 | | currentAvailableRealms.Clear(); |
| 2 | 483 | | CurrentRealmModel currentRealm = DataStore.i.realm.playerRealm.Get(); |
| | 484 | |
|
| 2 | 485 | | if (currentRealmList != null) |
| | 486 | | { |
| 12 | 487 | | foreach (RealmModel realmModel in currentRealmList) |
| | 488 | | { |
| 4 | 489 | | RealmRowComponentModel realmToAdd = new RealmRowComponentModel |
| | 490 | | { |
| | 491 | | name = realmModel.serverName, |
| | 492 | | players = realmModel.usersCount, |
| | 493 | | isConnected = realmModel.serverName == currentRealm?.serverName |
| | 494 | | }; |
| | 495 | |
|
| 4 | 496 | | currentAvailableRealms.Add(realmToAdd); |
| | 497 | | } |
| | 498 | | } |
| | 499 | |
|
| 2 | 500 | | view.currentRealmSelectorModal.SetAvailableRealms(currentAvailableRealms); |
| 2 | 501 | | } |
| | 502 | |
|
| | 503 | | internal bool NeedToRefreshRealms(IEnumerable<RealmModel> newRealmList) |
| | 504 | | { |
| 48 | 505 | | if (newRealmList == null) |
| 0 | 506 | | return true; |
| | 507 | |
|
| 48 | 508 | | bool needToRefresh = false; |
| 48 | 509 | | if (newRealmList.Count() == currentAvailableRealms.Count) |
| | 510 | | { |
| 92 | 511 | | foreach (RealmModel realm in newRealmList) |
| | 512 | | { |
| 0 | 513 | | if (!currentAvailableRealms.Exists(x => x.name == realm.serverName && x.players == realm.usersCount)) |
| | 514 | | { |
| 0 | 515 | | needToRefresh = true; |
| 0 | 516 | | break; |
| | 517 | | } |
| | 518 | | } |
| | 519 | | } |
| | 520 | | else |
| 2 | 521 | | needToRefresh = true; |
| | 522 | |
|
| 48 | 523 | | return needToRefresh; |
| | 524 | | } |
| | 525 | |
|
| | 526 | | internal void UpdateProfileInfo(UserProfile profile) |
| | 527 | | { |
| 47 | 528 | | view.currentProfileCard.SetIsClaimedName(profile.hasClaimedName); |
| 47 | 529 | | view.currentProfileCard.SetProfileName(profile.userName); |
| 47 | 530 | | view.currentProfileCard.SetProfileAddress(profile.ethAddress); |
| 47 | 531 | | view.currentProfileCard.SetProfilePicture(profile.face256SnapshotURL); |
| 47 | 532 | | } |
| | 533 | |
|
| | 534 | | internal void OnCloseButtonPressed(bool fromShortcut) |
| | 535 | | { |
| 2 | 536 | | if (!fromShortcut) |
| | 537 | | { |
| 1 | 538 | | SetVisibility(false); |
| 1 | 539 | | exploreV2Analytics.SendStartMenuVisibility(false, fromShortcut ? ExploreUIVisibilityMethod.FromShortcut : Ex |
| 1 | 540 | | } |
| | 541 | | else |
| | 542 | | { |
| 1 | 543 | | if (isOpen.Get()) |
| | 544 | | { |
| 1 | 545 | | SetVisibility(false); |
| 1 | 546 | | exploreV2Analytics.SendStartMenuVisibility(false, fromShortcut ? ExploreUIVisibilityMethod.FromShortcut |
| 1 | 547 | | } |
| | 548 | | else |
| | 549 | | { |
| 0 | 550 | | if (Time.realtimeSinceStartup - controlsHUDCloseTime >= MIN_TIME_AFTER_CLOSE_OTHER_UI_TO_OPEN_START_MENU |
| | 551 | | Time.realtimeSinceStartup - emotesHUDCloseTime >= MIN_TIME_AFTER_CLOSE_OTHER_UI_TO_OPEN_START_MENU & |
| | 552 | | Time.realtimeSinceStartup - playerInfoCardHUDCloseTime >= MIN_TIME_AFTER_CLOSE_OTHER_UI_TO_OPEN_STAR |
| | 553 | | Time.realtimeSinceStartup - chatInputHUDCloseTime >= MIN_TIME_AFTER_CLOSE_OTHER_UI_TO_OPEN_START_MEN |
| | 554 | | { |
| 0 | 555 | | SetVisibility(true); |
| 0 | 556 | | exploreV2Analytics.SendStartMenuVisibility(true, fromShortcut ? ExploreUIVisibilityMethod.FromShortc |
| | 557 | | } |
| | 558 | | } |
| | 559 | | } |
| 0 | 560 | | } |
| | 561 | |
|
| | 562 | | internal void ConfigureOhterUIDependencies() |
| | 563 | | { |
| 46 | 564 | | controlsHUDCloseTime = Time.realtimeSinceStartup; |
| 46 | 565 | | controlsVisible.OnChange += (current, old) => |
| | 566 | | { |
| 0 | 567 | | if (!current) |
| 0 | 568 | | controlsHUDCloseTime = Time.realtimeSinceStartup; |
| 0 | 569 | | }; |
| | 570 | |
|
| 46 | 571 | | emotesHUDCloseTime = Time.realtimeSinceStartup; |
| 46 | 572 | | emotesVisible.OnChange += (current, old) => |
| | 573 | | { |
| 0 | 574 | | if (!current) |
| 0 | 575 | | emotesHUDCloseTime = Time.realtimeSinceStartup; |
| 0 | 576 | | }; |
| | 577 | |
|
| 46 | 578 | | chatInputHUDCloseTime = Time.realtimeSinceStartup; |
| 46 | 579 | | chatInputVisible.OnChange += (current, old) => |
| | 580 | | { |
| 0 | 581 | | if (!current) |
| 0 | 582 | | chatInputHUDCloseTime = Time.realtimeSinceStartup; |
| 0 | 583 | | }; |
| | 584 | |
|
| 46 | 585 | | playerInfoCardHUDCloseTime = Time.realtimeSinceStartup; |
| 46 | 586 | | playerInfoCardVisible.OnChange += (current, old) => |
| | 587 | | { |
| 92 | 588 | | if (!current) |
| 46 | 589 | | playerInfoCardHUDCloseTime = Time.realtimeSinceStartup; |
| 92 | 590 | | }; |
| 46 | 591 | | } |
| | 592 | |
|
| 0 | 593 | | internal virtual IExploreV2Analytics CreateAnalyticsController() => new ExploreV2Analytics.ExploreV2Analytics(); |
| | 594 | |
|
| 0 | 595 | | internal virtual IExploreV2MenuComponentView CreateView() => ExploreV2MenuComponentView.Create(); |
| | 596 | | } |