| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Linq; |
| | 4 | | using DCL; |
| | 5 | | using Decentraland.Bff; |
| | 6 | | using ExploreV2Analytics; |
| | 7 | | using UnityEngine; |
| | 8 | | using Variables.RealmsInfo; |
| | 9 | |
|
| | 10 | | /// <summary> |
| | 11 | | /// Main controller for the feature "Explore V2". |
| | 12 | | /// </summary> |
| | 13 | | public class ExploreV2MenuComponentController : IExploreV2MenuComponentController |
| | 14 | | { |
| | 15 | | internal const ExploreSection DEFAULT_SECTION = ExploreSection.Explore; |
| | 16 | |
|
| | 17 | | internal const float MIN_TIME_AFTER_CLOSE_OTHER_UI_TO_OPEN_START_MENU = 0.1f; |
| 58 | 18 | | internal readonly List<RealmRowComponentModel> currentAvailableRealms = new List<RealmRowComponentModel>(); |
| | 19 | | internal float chatInputHUDCloseTime = 0f; |
| | 20 | | internal float controlsHUDCloseTime = 0f; |
| | 21 | | internal ExploreSection currentOpenSection; |
| | 22 | | internal float emotesHUDCloseTime = 0f; |
| | 23 | | internal IExploreV2Analytics exploreV2Analytics; |
| | 24 | | internal MouseCatcher mouseCatcher; |
| | 25 | | internal IPlacesAndEventsSectionComponentController placesAndEventsSectionController; |
| | 26 | | internal float playerInfoCardHUDCloseTime = 0f; |
| | 27 | | private Dictionary<BaseVariable<bool>, ExploreSection> sectionsByInitVar; |
| | 28 | | internal Dictionary<BaseVariable<bool>, ExploreSection> sectionsByVisiblityVar; |
| | 29 | |
|
| | 30 | | private Dictionary<ExploreSection, (BaseVariable<bool> initVar, BaseVariable<bool> visibilityVar)> sectionsVariables |
| | 31 | |
|
| | 32 | | internal IExploreV2MenuComponentView view; |
| | 33 | |
|
| 174 | 34 | | internal UserProfile ownUserProfile => UserProfile.GetOwnUserProfile(); |
| 58 | 35 | | internal RectTransform topMenuTooltipReference => view.currentTopMenuTooltipReference; |
| 58 | 36 | | internal RectTransform placesAndEventsTooltipReference => view.currentPlacesAndEventsTooltipReference; |
| 58 | 37 | | internal RectTransform backpackTooltipReference => view.currentBackpackTooltipReference; |
| 58 | 38 | | internal RectTransform mapTooltipReference => view.currentMapTooltipReference; |
| 58 | 39 | | internal RectTransform builderTooltipReference => view.currentBuilderTooltipReference; |
| 58 | 40 | | internal RectTransform questTooltipReference => view.currentQuestTooltipReference; |
| 58 | 41 | | internal RectTransform settingsTooltipReference => view.currentSettingsTooltipReference; |
| 58 | 42 | | internal RectTransform profileCardTooltipReference => view.currentProfileCardTooltipReference; |
| | 43 | |
|
| 347 | 44 | | internal BaseVariable<bool> isOpen => DataStore.i.exploreV2.isOpen; |
| 273 | 45 | | internal BaseVariable<int> currentSectionIndex => DataStore.i.exploreV2.currentSectionIndex; |
| 81 | 46 | | internal BaseVariable<bool> profileCardIsOpen => DataStore.i.exploreV2.profileCardIsOpen; |
| 120 | 47 | | internal BaseVariable<bool> isInitialized => DataStore.i.exploreV2.isInitialized; |
| 58 | 48 | | internal BaseVariable<bool> isPlacesAndEventsSectionInitialized => DataStore.i.exploreV2.isPlacesAndEventsSectionIni |
| 65 | 49 | | internal BaseVariable<bool> placesAndEventsVisible => DataStore.i.exploreV2.placesAndEventsVisible; |
| 60 | 50 | | internal BaseVariable<bool> isAvatarEditorInitialized => DataStore.i.HUDs.isAvatarEditorInitialized; |
| 65 | 51 | | internal BaseVariable<bool> avatarEditorVisible => DataStore.i.HUDs.avatarEditorVisible; |
| 60 | 52 | | internal BaseVariable<bool> isNavmapInitialized => DataStore.i.HUDs.isNavMapInitialized; |
| 65 | 53 | | internal BaseVariable<bool> navmapVisible => DataStore.i.HUDs.navmapVisible; |
| 60 | 54 | | internal BaseVariable<bool> isBuilderInitialized => DataStore.i.builderInWorld.isInitialized; |
| 65 | 55 | | internal BaseVariable<bool> builderVisible => DataStore.i.HUDs.builderProjectsPanelVisible; |
| 60 | 56 | | internal BaseVariable<bool> isQuestInitialized => DataStore.i.Quests.isInitialized; |
| 65 | 57 | | internal BaseVariable<bool> questVisible => DataStore.i.HUDs.questsPanelVisible; |
| 60 | 58 | | internal BaseVariable<bool> isSettingsPanelInitialized => DataStore.i.settings.isInitialized; |
| 65 | 59 | | internal BaseVariable<bool> settingsVisible => DataStore.i.settings.settingsPanelVisible; |
| | 60 | |
|
| 58 | 61 | | internal BaseVariable<bool> controlsVisible => DataStore.i.HUDs.controlsVisible; |
| 58 | 62 | | internal BaseVariable<bool> emotesVisible => DataStore.i.HUDs.emotesVisible; |
| 58 | 63 | | internal BaseVariable<bool> chatInputVisible => DataStore.i.HUDs.chatInputVisible; |
| 58 | 64 | | internal BooleanVariable playerInfoCardVisible => CommonScriptableObjects.playerInfoCardVisibleState; |
| 27 | 65 | | internal BaseVariable<bool> isPromoteChannelsToastVisible => DataStore.i.channels.isPromoteToastVisible; |
| | 66 | |
|
| | 67 | | public void Initialize() |
| | 68 | | { |
| 58 | 69 | | sectionsVariables = new Dictionary<ExploreSection, (BaseVariable<bool>, BaseVariable<bool>)> |
| | 70 | | { |
| | 71 | | { ExploreSection.Explore, (isPlacesAndEventsSectionInitialized, placesAndEventsVisible) }, |
| | 72 | | { ExploreSection.Backpack, (isAvatarEditorInitialized, avatarEditorVisible) }, |
| | 73 | | { ExploreSection.Map, (isNavmapInitialized, navmapVisible) }, |
| | 74 | | { ExploreSection.Builder, (isBuilderInitialized, builderVisible) }, |
| | 75 | | { ExploreSection.Quest, (isQuestInitialized, questVisible) }, |
| | 76 | | { ExploreSection.Settings, (isSettingsPanelInitialized, settingsVisible) }, |
| | 77 | | }; |
| 754 | 78 | | sectionsByInitVar = sectionsVariables.ToDictionary(pair => pair.Value.initVar, pair => pair.Key); |
| 754 | 79 | | sectionsByVisiblityVar = sectionsVariables.ToDictionary(pair => pair.Value.visibilityVar, pair => pair.Key); |
| | 80 | |
|
| 58 | 81 | | mouseCatcher = SceneReferences.i?.mouseCatcher; |
| 58 | 82 | | exploreV2Analytics = CreateAnalyticsController(); |
| 58 | 83 | | view = CreateView(); |
| 58 | 84 | | SetVisibility(false); |
| | 85 | |
|
| 58 | 86 | | DataStore.i.realm.realmName.OnChange += UpdateRealmInfo; |
| 58 | 87 | | UpdateRealmInfo( DataStore.i.realm.realmName.Get()); |
| | 88 | |
|
| 58 | 89 | | DataStore.i.realm.realmsInfo.OnSet += UpdateAvailableRealmsInfo; |
| 58 | 90 | | UpdateAvailableRealmsInfo(DataStore.i.realm.realmsInfo.Get()); |
| | 91 | |
|
| 58 | 92 | | ownUserProfile.OnUpdate += UpdateProfileInfo; |
| 58 | 93 | | UpdateProfileInfo(ownUserProfile); |
| 58 | 94 | | view.currentProfileCard.onClick?.AddListener(() => { profileCardIsOpen.Set(!profileCardIsOpen.Get()); }); |
| 58 | 95 | | view.currentRealmViewer.onLogoClick?.AddListener(view.ShowRealmSelectorModal); |
| 58 | 96 | | view.OnCloseButtonPressed += OnCloseButtonPressed; |
| 58 | 97 | | view.OnAfterShowAnimation += OnAfterShowAnimation; |
| | 98 | |
|
| 58 | 99 | | DataStore.i.exploreV2.topMenuTooltipReference.Set(topMenuTooltipReference); |
| 58 | 100 | | DataStore.i.exploreV2.placesAndEventsTooltipReference.Set(placesAndEventsTooltipReference); |
| 58 | 101 | | DataStore.i.exploreV2.backpackTooltipReference.Set(backpackTooltipReference); |
| 58 | 102 | | DataStore.i.exploreV2.mapTooltipReference.Set(mapTooltipReference); |
| 58 | 103 | | DataStore.i.exploreV2.builderTooltipReference.Set(builderTooltipReference); |
| 58 | 104 | | DataStore.i.exploreV2.questTooltipReference.Set(questTooltipReference); |
| 58 | 105 | | DataStore.i.exploreV2.settingsTooltipReference.Set(settingsTooltipReference); |
| 58 | 106 | | DataStore.i.exploreV2.profileCardTooltipReference.Set(profileCardTooltipReference); |
| | 107 | |
|
| 58 | 108 | | view.OnSectionOpen += OnSectionOpen; |
| | 109 | |
|
| 58 | 110 | | isOpen.OnChange += SetVisibilityOnOpenChanged; |
| 58 | 111 | | SetVisibilityOnOpenChanged(isOpen.Get()); |
| | 112 | |
|
| 58 | 113 | | currentSectionIndex.OnChange += CurrentSectionIndexChanged; |
| 58 | 114 | | CurrentSectionIndexChanged(currentSectionIndex.Get(), 0); |
| | 115 | |
|
| 812 | 116 | | foreach (var sectionsVariables in sectionsVariables.Values) |
| | 117 | | { |
| 348 | 118 | | sectionsVariables.initVar.OnChangeWithSenderInfo += OnSectionInitializedChanged; |
| 348 | 119 | | OnSectionInitializedChanged(sectionsVariables.initVar, sectionsVariables.initVar.Get()); |
| | 120 | |
|
| 348 | 121 | | sectionsVariables.visibilityVar.OnChangeWithSenderInfo += OnSectionVisiblityChanged; |
| 348 | 122 | | OnSectionVisiblityChanged(sectionsVariables.visibilityVar, sectionsVariables.visibilityVar.Get()); |
| | 123 | | } |
| | 124 | |
|
| 58 | 125 | | ConfigureOtherUIDependencies(); |
| | 126 | |
|
| 58 | 127 | | isInitialized.Set(true); |
| | 128 | |
|
| 58 | 129 | | currentSectionIndex.Set((int)DEFAULT_SECTION, false); |
| | 130 | |
|
| | 131 | | //view.ConfigureEncapsulatedSection(ExploreSection.Backpack, DataStore.i.exploreV2.configureBackpackInFullscreen |
| 58 | 132 | | view.ConfigureEncapsulatedSection(ExploreSection.Map, DataStore.i.exploreV2.configureMapInFullscreenMenu); |
| 58 | 133 | | view.ConfigureEncapsulatedSection(ExploreSection.Builder, DataStore.i.exploreV2.configureBuilderInFullscreenMenu |
| 58 | 134 | | view.ConfigureEncapsulatedSection(ExploreSection.Quest, DataStore.i.exploreV2.configureQuestInFullscreenMenu); |
| 58 | 135 | | view.ConfigureEncapsulatedSection(ExploreSection.Settings, DataStore.i.exploreV2.configureSettingsInFullscreenMe |
| 58 | 136 | | } |
| | 137 | |
|
| | 138 | | public void Dispose() |
| | 139 | | { |
| 58 | 140 | | DataStore.i.realm.realmName.OnChange -= UpdateRealmInfo; |
| 58 | 141 | | DataStore.i.realm.realmsInfo.OnSet -= UpdateAvailableRealmsInfo; |
| | 142 | |
|
| 58 | 143 | | ownUserProfile.OnUpdate -= UpdateProfileInfo; |
| 58 | 144 | | view?.currentProfileCard.onClick?.RemoveAllListeners(); |
| | 145 | |
|
| 58 | 146 | | isOpen.OnChange -= SetVisibilityOnOpenChanged; |
| 58 | 147 | | currentSectionIndex.OnChange -= CurrentSectionIndexChanged; |
| | 148 | |
|
| 812 | 149 | | foreach (var sectionsVariables in sectionsVariables.Values) |
| | 150 | | { |
| 348 | 151 | | sectionsVariables.initVar.OnChangeWithSenderInfo -= OnSectionInitializedChanged; |
| 348 | 152 | | sectionsVariables.visibilityVar.OnChangeWithSenderInfo -= OnSectionVisiblityChanged; |
| | 153 | | } |
| | 154 | |
|
| 58 | 155 | | if (placesAndEventsSectionController != null) |
| | 156 | | { |
| 1 | 157 | | placesAndEventsSectionController.OnCloseExploreV2 -= OnCloseButtonPressed; |
| 1 | 158 | | placesAndEventsSectionController.Dispose(); |
| | 159 | | } |
| | 160 | |
|
| 58 | 161 | | if (view != null) |
| | 162 | | { |
| 58 | 163 | | view.currentProfileCard.onClick?.RemoveAllListeners(); |
| 58 | 164 | | view.currentRealmViewer.onLogoClick?.RemoveAllListeners(); |
| 58 | 165 | | view.OnCloseButtonPressed -= OnCloseButtonPressed; |
| 58 | 166 | | view.OnAfterShowAnimation -= OnAfterShowAnimation; |
| 58 | 167 | | view.OnSectionOpen -= OnSectionOpen; |
| 58 | 168 | | view.Dispose(); |
| | 169 | | } |
| 58 | 170 | | } |
| | 171 | |
|
| 84 | 172 | | public void SetVisibility(bool visible) => isOpen.Set(visible); |
| | 173 | |
|
| | 174 | | private void OnSectionInitializedChanged(BaseVariable<bool> initVar, bool initialized, bool _ = false) => |
| 353 | 175 | | SectionInitializedChanged(sectionsByInitVar[initVar], initialized); |
| | 176 | |
|
| | 177 | | internal void SectionInitializedChanged(ExploreSection section, bool initialized, bool _ = false) |
| | 178 | | { |
| 363 | 179 | | view.SetSectionActive(section, initialized); |
| | 180 | |
|
| 363 | 181 | | if (section == ExploreSection.Explore && initialized) |
| 0 | 182 | | InitializePlacesAndEventsSection(); |
| 363 | 183 | | } |
| | 184 | |
|
| | 185 | | private void OnSectionVisiblityChanged(BaseVariable<bool> visibilityVar, bool visible, bool previous = false) |
| | 186 | | { |
| 360 | 187 | | ExploreSection section = sectionsByVisiblityVar[visibilityVar]; |
| 360 | 188 | | BaseVariable<bool> initVar = section == ExploreSection.Explore ? isInitialized : sectionsVariables[section].init |
| | 189 | |
|
| 360 | 190 | | if (!initVar.Get() || DataStore.i.common.isSignUpFlow.Get()) |
| 151 | 191 | | return; |
| | 192 | |
|
| 209 | 193 | | SetMenuTargetVisibility(sectionsByVisiblityVar[visibilityVar], visible); |
| 209 | 194 | | } |
| | 195 | |
|
| | 196 | | internal void InitializePlacesAndEventsSection() |
| | 197 | | { |
| 1 | 198 | | if (placesAndEventsSectionController != null) |
| 0 | 199 | | return; |
| | 200 | |
|
| 1 | 201 | | placesAndEventsSectionController = new PlacesAndEventsSectionComponentController(view.currentPlacesAndEventsSect |
| 1 | 202 | | placesAndEventsSectionController.OnCloseExploreV2 += OnCloseButtonPressed; |
| 1 | 203 | | } |
| | 204 | |
|
| | 205 | | internal void OnSectionOpen(ExploreSection section) |
| | 206 | | { |
| 12 | 207 | | if (section != currentOpenSection) |
| 11 | 208 | | exploreV2Analytics.SendStartMenuSectionVisibility(currentOpenSection, false); |
| | 209 | |
|
| 12 | 210 | | currentOpenSection = section; |
| | 211 | |
|
| 12 | 212 | | if (currentOpenSection == ExploreSection.Backpack) |
| 2 | 213 | | view.ConfigureEncapsulatedSection(ExploreSection.Backpack, DataStore.i.exploreV2.configureBackpackInFullscre |
| | 214 | |
|
| 168 | 215 | | foreach (var visibilityVar in sectionsByVisiblityVar.Keys) |
| 72 | 216 | | visibilityVar.Set(currentOpenSection == sectionsByVisiblityVar[visibilityVar]); |
| | 217 | |
|
| 12 | 218 | | profileCardIsOpen.Set(false); |
| 12 | 219 | | } |
| | 220 | |
|
| 89 | 221 | | internal void SetVisibilityOnOpenChanged(bool open, bool _ = false) => SetVisibility_Internal(open); |
| | 222 | |
|
| | 223 | | internal void CurrentSectionIndexChanged(int current, int previous) |
| | 224 | | { |
| 499 | 225 | | if (DataStore.i.exploreV2.isInShowAnimationTransiton.Get()) |
| 0 | 226 | | return; |
| | 227 | |
|
| 499 | 228 | | if (Enum.IsDefined(typeof(ExploreSection), current)) |
| | 229 | | { |
| 409 | 230 | | if (!view.IsSectionActive((ExploreSection)current)) |
| 409 | 231 | | CurrentSectionIndexChanged(current + 1, current); |
| | 232 | | else |
| 0 | 233 | | view.GoToSection((ExploreSection)current); |
| 0 | 234 | | } |
| | 235 | | else |
| 90 | 236 | | view.GoToSection(0); |
| 90 | 237 | | } |
| | 238 | |
|
| | 239 | | internal void SetVisibility_Internal(bool visible) |
| | 240 | | { |
| 89 | 241 | | if (view == null || DataStore.i.common.isSignUpFlow.Get()) |
| 0 | 242 | | return; |
| | 243 | |
|
| 89 | 244 | | if (visible) |
| | 245 | | { |
| 27 | 246 | | mouseCatcher?.UnlockCursor(); |
| | 247 | |
|
| 27 | 248 | | if (DataStore.i.common.isTutorialRunning.Get()) |
| 1 | 249 | | view.GoToSection(DEFAULT_SECTION); |
| | 250 | |
|
| 27 | 251 | | isPromoteChannelsToastVisible.Set(false); |
| 27 | 252 | | } |
| | 253 | | else |
| | 254 | | { |
| 62 | 255 | | CommonScriptableObjects.isFullscreenHUDOpen.Set(false); |
| | 256 | |
|
| 868 | 257 | | foreach (var sectionsVariables in sectionsVariables.Values) |
| 372 | 258 | | sectionsVariables.visibilityVar.Set(false); |
| | 259 | |
|
| 62 | 260 | | profileCardIsOpen.Set(false); |
| | 261 | | } |
| | 262 | |
|
| 89 | 263 | | view.SetVisible(visible); |
| 89 | 264 | | } |
| | 265 | |
|
| 0 | 266 | | internal void OnAfterShowAnimation() => CommonScriptableObjects.isFullscreenHUDOpen.Set(true); |
| | 267 | |
|
| | 268 | | internal void SetMenuTargetVisibility(ExploreSection section, bool toVisible, bool _ = false) |
| | 269 | | { |
| 227 | 270 | | if (toVisible) |
| | 271 | | { |
| 22 | 272 | | if (currentSectionIndex.Get() != (int)section) |
| 19 | 273 | | currentSectionIndex.Set((int)section); |
| | 274 | |
|
| 22 | 275 | | SetSectionTargetVisibility(section, toVisible: true); |
| 22 | 276 | | view.GoToSection(section); |
| 22 | 277 | | } |
| 205 | 278 | | else if (currentOpenSection == section) |
| | 279 | | { |
| 63 | 280 | | SetSectionTargetVisibility(section, toVisible: false); |
| | 281 | | } |
| 205 | 282 | | } |
| | 283 | |
|
| | 284 | | private void SetSectionTargetVisibility(ExploreSection section, bool toVisible) |
| | 285 | | { |
| 85 | 286 | | bool wasInTargetVisibility = toVisible ^ isOpen.Get(); |
| | 287 | |
|
| 85 | 288 | | if (wasInTargetVisibility) |
| | 289 | | { |
| 22 | 290 | | SetVisibility(toVisible); |
| 22 | 291 | | exploreV2Analytics.SendStartMenuVisibility(toVisible, ExploreUIVisibilityMethod.FromShortcut); |
| | 292 | | } |
| 85 | 293 | | exploreV2Analytics.SendStartMenuSectionVisibility(section, toVisible); |
| 85 | 294 | | } |
| | 295 | |
|
| | 296 | | private void UpdateRealmInfo(string current, string previous) |
| | 297 | | { |
| 0 | 298 | | if (string.IsNullOrEmpty(current)) |
| 0 | 299 | | return; |
| | 300 | |
|
| 0 | 301 | | UpdateRealmInfo(current); |
| 0 | 302 | | } |
| | 303 | |
|
| | 304 | | internal void UpdateRealmInfo(string realmName) |
| | 305 | | { |
| 59 | 306 | | if (string.IsNullOrEmpty(realmName)) |
| 58 | 307 | | return; |
| | 308 | |
|
| | 309 | | // Get the name of the current realm |
| 1 | 310 | | view.currentRealmViewer.SetRealm(realmName); |
| 1 | 311 | | view.currentRealmSelectorModal.SetCurrentRealm(realmName); |
| | 312 | |
|
| | 313 | | // Calculate number of users in the current realm |
| 1 | 314 | | List<RealmModel> realmList = DataStore.i.realm.realmsInfo.Get()?.ToList(); |
| 2 | 315 | | RealmModel currentRealmModel = realmList?.FirstOrDefault(r => r.serverName == realmName); |
| 1 | 316 | | int realmUsers = 0; |
| 1 | 317 | | if (currentRealmModel != null) |
| 1 | 318 | | realmUsers = currentRealmModel.usersCount; |
| | 319 | |
|
| 1 | 320 | | view.currentRealmViewer.SetNumberOfUsers(realmUsers); |
| 1 | 321 | | } |
| | 322 | |
|
| | 323 | | internal void UpdateAvailableRealmsInfo(IEnumerable<RealmModel> currentRealmList) |
| | 324 | | { |
| 60 | 325 | | List<RealmModel> realmList = currentRealmList?.ToList(); |
| | 326 | |
|
| 60 | 327 | | if (!NeedToRefreshRealms(realmList)) |
| 58 | 328 | | return; |
| | 329 | |
|
| 2 | 330 | | currentAvailableRealms.Clear(); |
| | 331 | |
|
| 2 | 332 | | if (realmList != null) |
| | 333 | | { |
| 2 | 334 | | string serverName = ServerNameForCurrentRealm(); |
| 12 | 335 | | foreach (RealmModel realmModel in realmList) |
| | 336 | | { |
| 4 | 337 | | currentAvailableRealms.Add(new RealmRowComponentModel |
| | 338 | | { |
| | 339 | | name = realmModel.serverName, |
| | 340 | | players = realmModel.usersCount, |
| | 341 | | isConnected = realmModel.serverName == serverName |
| | 342 | | }); |
| | 343 | | } |
| | 344 | | } |
| | 345 | |
|
| 2 | 346 | | view.currentRealmSelectorModal.SetAvailableRealms(currentAvailableRealms); |
| 2 | 347 | | } |
| | 348 | |
|
| | 349 | | private string ServerNameForCurrentRealm() |
| | 350 | | { |
| 2 | 351 | | if (DataStore.i.realm.playerRealm.Get() != null) |
| 1 | 352 | | return DataStore.i.realm.playerRealm.Get().serverName; |
| 1 | 353 | | if(DataStore.i.realm.playerRealmAbout.Get() != null) |
| 0 | 354 | | return DataStore.i.realm.playerRealmAbout.Get().Configurations.RealmName; |
| 1 | 355 | | return ""; |
| | 356 | | } |
| | 357 | |
|
| | 358 | | internal bool NeedToRefreshRealms(IEnumerable<RealmModel> newRealmList) |
| | 359 | | { |
| 60 | 360 | | if (newRealmList == null) |
| 0 | 361 | | return true; |
| | 362 | |
|
| 60 | 363 | | bool needToRefresh = false; |
| 60 | 364 | | if (newRealmList.Count() == currentAvailableRealms.Count) |
| | 365 | | { |
| 116 | 366 | | foreach (RealmModel realm in newRealmList) |
| | 367 | | { |
| 0 | 368 | | if (!currentAvailableRealms.Exists(x => x.name == realm.serverName && x.players == realm.usersCount)) |
| | 369 | | { |
| 0 | 370 | | needToRefresh = true; |
| 0 | 371 | | break; |
| | 372 | | } |
| | 373 | | } |
| | 374 | | } |
| | 375 | | else |
| 2 | 376 | | needToRefresh = true; |
| | 377 | |
|
| 60 | 378 | | return needToRefresh; |
| | 379 | | } |
| | 380 | |
|
| | 381 | | internal void UpdateProfileInfo(UserProfile profile) |
| | 382 | | { |
| 59 | 383 | | view.currentProfileCard.SetIsClaimedName(profile.hasClaimedName); |
| 59 | 384 | | view.currentProfileCard.SetProfileName(profile.userName); |
| 59 | 385 | | view.currentProfileCard.SetProfileAddress(profile.ethAddress); |
| 59 | 386 | | view.currentProfileCard.SetProfilePicture(profile.face256SnapshotURL); |
| 59 | 387 | | } |
| | 388 | |
|
| | 389 | | internal void OnCloseButtonPressed(bool fromShortcut) |
| | 390 | | { |
| 2 | 391 | | if (DataStore.i.builderInWorld.areShortcutsBlocked.Get() || !isOpen.Get() ) |
| 0 | 392 | | return; |
| | 393 | |
|
| 2 | 394 | | SetVisibility(false); |
| 2 | 395 | | exploreV2Analytics.SendStartMenuVisibility(false, fromShortcut ? ExploreUIVisibilityMethod.FromShortcut : Explor |
| 2 | 396 | | } |
| | 397 | |
|
| | 398 | | internal void ConfigureOtherUIDependencies() |
| | 399 | | { |
| 58 | 400 | | controlsHUDCloseTime = Time.realtimeSinceStartup; |
| 58 | 401 | | controlsVisible.OnChange += (current, _) => |
| | 402 | | { |
| 0 | 403 | | if (!current) |
| 0 | 404 | | controlsHUDCloseTime = Time.realtimeSinceStartup; |
| 0 | 405 | | }; |
| | 406 | |
|
| 58 | 407 | | emotesHUDCloseTime = Time.realtimeSinceStartup; |
| 58 | 408 | | emotesVisible.OnChange += (current, _) => |
| | 409 | | { |
| 0 | 410 | | if (!current) |
| 0 | 411 | | emotesHUDCloseTime = Time.realtimeSinceStartup; |
| 0 | 412 | | }; |
| | 413 | |
|
| 58 | 414 | | chatInputHUDCloseTime = Time.realtimeSinceStartup; |
| 58 | 415 | | chatInputVisible.OnChange += (current, _) => |
| | 416 | | { |
| 0 | 417 | | if (!current) |
| 0 | 418 | | chatInputHUDCloseTime = Time.realtimeSinceStartup; |
| 0 | 419 | | }; |
| | 420 | |
|
| 58 | 421 | | playerInfoCardHUDCloseTime = Time.realtimeSinceStartup; |
| 58 | 422 | | playerInfoCardVisible.OnChange += (current, _) => |
| | 423 | | { |
| 0 | 424 | | if (!current) |
| 0 | 425 | | playerInfoCardHUDCloseTime = Time.realtimeSinceStartup; |
| 0 | 426 | | }; |
| 58 | 427 | | } |
| | 428 | |
|
| 0 | 429 | | internal virtual IExploreV2Analytics CreateAnalyticsController() => new ExploreV2Analytics.ExploreV2Analytics(); |
| | 430 | |
|
| 0 | 431 | | protected internal virtual IExploreV2MenuComponentView CreateView() => ExploreV2MenuComponentView.Create(); |
| | 432 | | } |