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