< Summary

Class:HUDController
Assembly:HUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/HUDController.cs
Covered lines:203
Uncovered lines:67
Coverable lines:270
Total lines:574
Line coverage:75.1% (203 of 270)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
HUDController(...)0%110100%
Initialize()0%220100%
ShowSettings()0%6200%
ShowControls()0%6200%
ToggleUIVisibility_OnTriggered(...)0%42600%
AllUIHiddenOnOnChange(...)0%440100%
ConfigureHUDElement(...)0%53.4451090.21%
OpenChannelSearchWindow()0%6200%
HandleChannelBacked()0%6200%
HandlePublicChatChannelBacked()0%6200%
OpenPublicChatWindow(...)0%6200%
OpenChannelChatWindow(...)0%6200%
OpenPrivateChatWindow(...)0%6200%
PrivateChatWindowHud_OnPressBack()0%12300%
TaskbarHud_onAnyTaskbarButtonClicked()0%6200%
CreateHudElement(...)0%4.074083.33%
UpdateHudElement(...)0%12300%
Cleanup()0%880100%
HandlePublicChatChannelClosed()0%2100%
GetHUDElement(...)0%220100%
IsHUDElementDeprecated(...)0%110100%
TriggerFakePlayerInfoCard()0%2100%
Dispose()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/HUDController.cs

#LineLine coverage
 1using DCL;
 2using DCL.HelpAndSupportHUD;
 3using DCL.Huds.QuestsPanel;
 4using DCL.Huds.QuestsTracker;
 5using DCL.QuestsController;
 6using DCL.SettingsPanelHUD;
 7using SignupHUD;
 8using System;
 9using System.Collections.Generic;
 10using DCL.Chat.HUD;
 11using DCL.Chat;
 12using UnityEngine;
 13using UnityEngine.EventSystems;
 14
 15public class HUDController : IHUDController
 16{
 17    private const string TOGGLE_UI_VISIBILITY_ASSET_NAME = "ToggleUIVisibility";
 18
 19    static bool VERBOSE = false;
 020    public static HUDController i { get; private set; }
 21
 22    public IHUDFactory hudFactory = null;
 23
 24    private InputAction_Trigger toggleUIVisibilityTrigger;
 25
 66926    private readonly DCL.NotificationModel.Model hiddenUINotification = new DCL.NotificationModel.Model()
 27    {
 28        timer = 3,
 29        type = DCL.NotificationModel.Type.UI_HIDDEN,
 30        groupID = "UIHiddenNotification"
 31    };
 32
 66933    public HUDController(IHUDFactory hudFactory = null)
 34    {
 66935        this.hudFactory = hudFactory;
 66936    }
 37
 38    public void Initialize()
 39    {
 66940        i = this;
 41
 66942        if (this.hudFactory == null)
 66743            this.hudFactory = DCL.Environment.i.hud.factory;
 44
 66945        toggleUIVisibilityTrigger = Resources.Load<InputAction_Trigger>(TOGGLE_UI_VISIBILITY_ASSET_NAME);
 66946        toggleUIVisibilityTrigger.OnTriggered += ToggleUIVisibility_OnTriggered;
 47
 66948        CommonScriptableObjects.allUIHidden.OnChange += AllUIHiddenOnOnChange;
 66949        UserContextMenu.OnOpenPrivateChatRequest += OpenPrivateChatWindow;
 66950    }
 51
 52
 53    public event Action OnTaskbarCreation;
 54
 055    public ProfileHUDController profileHud => GetHUDElement(HUDElementID.PROFILE_HUD) as ProfileHUDController;
 56
 57    public NotificationHUDController notificationHud =>
 158        GetHUDElement(HUDElementID.NOTIFICATION) as NotificationHUDController;
 59
 360    public MinimapHUDController minimapHud => GetHUDElement(HUDElementID.MINIMAP) as MinimapHUDController;
 61
 62    public AvatarEditorHUDController avatarEditorHud =>
 263        GetHUDElement(HUDElementID.AVATAR_EDITOR) as AvatarEditorHUDController;
 64
 65    public SettingsPanelHUDController settingsPanelHud =>
 366        GetHUDElement(HUDElementID.SETTINGS_PANEL) as SettingsPanelHUDController;
 67
 68    public PlayerInfoCardHUDController playerInfoCardHud =>
 069        GetHUDElement(HUDElementID.PLAYER_INFO_CARD) as PlayerInfoCardHUDController;
 70
 71    public AirdroppingHUDController airdroppingHud =>
 072        GetHUDElement(HUDElementID.AIRDROPPING) as AirdroppingHUDController;
 73
 74    public TermsOfServiceHUDController termsOfServiceHud =>
 075        GetHUDElement(HUDElementID.TERMS_OF_SERVICE) as TermsOfServiceHUDController;
 76
 68577    public TaskbarHUDController taskbarHud => GetHUDElement(HUDElementID.TASKBAR) as TaskbarHUDController;
 78
 279    public LoadingHUDController loadingHud => GetHUDElement(HUDElementID.LOADING) as LoadingHUDController;
 80
 81    public WorldChatWindowController worldChatWindowHud =>
 68582        GetHUDElement(HUDElementID.WORLD_CHAT_WINDOW) as WorldChatWindowController;
 83
 84    public PrivateChatWindowController PrivateChatWindow =>
 67785        GetHUDElement(HUDElementID.PRIVATE_CHAT_WINDOW) as PrivateChatWindowController;
 86
 87    public PublicChatWindowController PublicChatWindowHud =>
 68088        GetHUDElement(HUDElementID.PUBLIC_CHAT) as PublicChatWindowController;
 89
 90    private ChatChannelHUDController chatChannelHud =>
 591        GetHUDElement(HUDElementID.CHANNELS_CHAT) as ChatChannelHUDController;
 92
 93    private SearchChannelsWindowController channelSearchHud =>
 394        GetHUDElement(HUDElementID.CHANNELS_SEARCH) as SearchChannelsWindowController;
 95
 96    private CreateChannelWindowController channelCreateHud =>
 397        GetHUDElement(HUDElementID.CHANNELS_CREATE) as CreateChannelWindowController;
 98
 99    private LeaveChannelConfirmationWindowController channelLeaveHud =>
 3100        GetHUDElement(HUDElementID.CHANNELS_LEAVE_CONFIRMATION) as LeaveChannelConfirmationWindowController;
 101
 677102    public FriendsHUDController friendsHud => GetHUDElement(HUDElementID.FRIENDS) as FriendsHUDController;
 103
 104    public TeleportPromptHUDController teleportHud =>
 0105        GetHUDElement(HUDElementID.TELEPORT_DIALOG) as TeleportPromptHUDController;
 106
 0107    public ControlsHUDController controlsHud => GetHUDElement(HUDElementID.CONTROLS_HUD) as ControlsHUDController;
 108
 109    public HelpAndSupportHUDController helpAndSupportHud =>
 1110        GetHUDElement(HUDElementID.HELP_AND_SUPPORT_HUD) as HelpAndSupportHUDController;
 111
 0112    public MinimapHUDController minimapHUD => GetHUDElement(HUDElementID.MINIMAP) as MinimapHUDController;
 113
 114    public VoiceChatWindowController voiceChatHud =>
 2115        GetHUDElement(HUDElementID.USERS_AROUND_LIST_HUD) as VoiceChatWindowController;
 116
 117    public QuestsPanelHUDController questsPanelHUD =>
 1118        GetHUDElement(HUDElementID.QUESTS_PANEL) as QuestsPanelHUDController;
 119
 120    public QuestsTrackerHUDController questsTrackerHUD =>
 1121        GetHUDElement(HUDElementID.QUESTS_TRACKER) as QuestsTrackerHUDController;
 122
 1123    public SignupHUDController signupHUD => GetHUDElement(HUDElementID.SIGNUP) as SignupHUDController;
 1124    public LoadingHUDController loadingController => GetHUDElement(HUDElementID.LOADING) as LoadingHUDController;
 125
 669126    public Dictionary<HUDElementID, IHUD> hudElements { get; private set; } = new Dictionary<HUDElementID, IHUD>();
 127
 1128    private UserProfile ownUserProfile => UserProfile.GetOwnUserProfile();
 1129    private BaseDictionary<string, WearableItem> wearableCatalog => CatalogController.wearableCatalog;
 130
 131    private void ShowSettings()
 132    {
 0133        settingsPanelHud?.SetVisibility(true);
 0134    }
 135
 136    private void ShowControls()
 137    {
 0138        controlsHud?.SetVisibility(true);
 0139    }
 140
 141    private void ToggleUIVisibility_OnTriggered(DCLAction_Trigger action)
 142    {
 0143        bool anyInputFieldIsSelected = EventSystem.current != null &&
 144                                       EventSystem.current.currentSelectedGameObject != null &&
 145                                       EventSystem.current.currentSelectedGameObject
 146                                           .GetComponent<TMPro.TMP_InputField>() != null;
 147
 0148        if (anyInputFieldIsSelected ||
 149            DataStore.i.exploreV2.isOpen.Get() ||
 150            CommonScriptableObjects.tutorialActive)
 0151            return;
 152
 0153        CommonScriptableObjects.allUIHidden.Set(!CommonScriptableObjects.allUIHidden.Get());
 0154    }
 155
 156    private void AllUIHiddenOnOnChange(bool current, bool previous)
 157    {
 3158        if (current)
 159        {
 2160            NotificationsController.i?.ShowNotification(hiddenUINotification);
 2161        }
 162        else
 163        {
 1164            NotificationsController.i?.DismissAllNotifications(hiddenUINotification.groupID);
 165        }
 1166    }
 167
 168    public void ConfigureHUDElement(HUDElementID hudElementId, HUDConfiguration configuration,
 169        string extraPayload = null)
 170    {
 171        //TODO(Brian): For now, the factory code is using this switch approach.
 172        //             In order to avoid the factory upkeep we can transform the IHUD elements
 173        //             To ScriptableObjects. In this scenario, we can make each element handle its own
 174        //             specific initialization details.
 175        //
 176        //             This will allow us to unify the serialized factory objects design,
 177        //             like we already do with ECS components.
 178
 179        switch (hudElementId)
 180        {
 181            case HUDElementID.NONE:
 182                break;
 183            case HUDElementID.MINIMAP:
 1184                if (minimapHud == null)
 185                {
 1186                    CreateHudElement(configuration, hudElementId);
 187
 1188                    if (minimapHud != null)
 189                    {
 1190                        minimapHud.Initialize();
 191                    }
 192                }
 193
 1194                break;
 195            case HUDElementID.PROFILE_HUD:
 1196                CreateHudElement(configuration, hudElementId);
 1197                break;
 198            case HUDElementID.NOTIFICATION:
 1199                CreateHudElement(configuration, hudElementId);
 1200                NotificationsController.i?.Initialize(notificationHud);
 1201                break;
 202            case HUDElementID.AVATAR_EDITOR:
 1203                CreateHudElement(configuration, hudElementId);
 1204                avatarEditorHud?.Initialize(ownUserProfile, wearableCatalog);
 1205                break;
 206            case HUDElementID.SETTINGS_PANEL:
 1207                CreateHudElement(configuration, hudElementId);
 1208                if (settingsPanelHud != null)
 1209                    settingsPanelHud.Initialize();
 1210                break;
 211            case HUDElementID.PLAYER_INFO_CARD:
 1212                CreateHudElement(configuration, hudElementId);
 1213                break;
 214            case HUDElementID.AIRDROPPING:
 1215                CreateHudElement(configuration, hudElementId);
 1216                break;
 217            case HUDElementID.TERMS_OF_SERVICE:
 1218                CreateHudElement(configuration, hudElementId);
 1219                break;
 220            case HUDElementID.WORLD_CHAT_WINDOW:
 1221                if (worldChatWindowHud == null)
 222                {
 1223                    CreateHudElement(configuration, hudElementId);
 224
 1225                    if (worldChatWindowHud != null)
 226                    {
 1227                        worldChatWindowHud.Initialize(WorldChatWindowComponentView.Create());
 1228                        worldChatWindowHud.SetVisibility(false);
 1229                        worldChatWindowHud.OnOpenPrivateChat -= OpenPrivateChatWindow;
 1230                        worldChatWindowHud.OnOpenPrivateChat += OpenPrivateChatWindow;
 1231                        worldChatWindowHud.OnOpenPublicChat -= OpenPublicChatWindow;
 1232                        worldChatWindowHud.OnOpenPublicChat += OpenPublicChatWindow;
 1233                        worldChatWindowHud.OnOpenChannel -= OpenChannelChatWindow;
 1234                        worldChatWindowHud.OnOpenChannel += OpenChannelChatWindow;
 1235                        worldChatWindowHud.OnOpenChannelSearch -= OpenChannelSearchWindow;
 1236                        worldChatWindowHud.OnOpenChannelSearch += OpenChannelSearchWindow;
 237
 1238                        taskbarHud?.AddWorldChatWindow(worldChatWindowHud);
 239                    }
 0240                }
 241                else
 0242                    UpdateHudElement(configuration, hudElementId);
 243
 1244                if (PublicChatWindowHud == null)
 245                {
 1246                    CreateHudElement(configuration, HUDElementID.PUBLIC_CHAT);
 1247                    PublicChatWindowHud.Initialize();
 1248                    PublicChatWindowHud.Setup(ChatUtils.NEARBY_CHANNEL_ID);
 1249                    PublicChatWindowHud.SetVisibility(false);
 1250                    PublicChatWindowHud.OnBack -= HandlePublicChatChannelBacked;
 1251                    PublicChatWindowHud.OnBack += HandlePublicChatChannelBacked;
 1252                    PublicChatWindowHud.OnClosed -= HandlePublicChatChannelClosed;
 1253                    PublicChatWindowHud.OnClosed += HandlePublicChatChannelClosed;
 1254                    taskbarHud?.AddPublicChatChannel(PublicChatWindowHud);
 0255                }
 256                else
 0257                    UpdateHudElement(configuration, HUDElementID.PUBLIC_CHAT);
 258
 1259                if (PrivateChatWindow == null)
 260                {
 1261                    CreateHudElement(configuration, HUDElementID.PRIVATE_CHAT_WINDOW);
 262
 1263                    if (PrivateChatWindow != null)
 264                    {
 1265                        PrivateChatWindow.Initialize();
 1266                        PrivateChatWindow.SetVisibility(false);
 1267                        PrivateChatWindow.OnBack -= PrivateChatWindowHud_OnPressBack;
 1268                        PrivateChatWindow.OnBack += PrivateChatWindowHud_OnPressBack;
 269
 1270                        taskbarHud?.AddPrivateChatWindow(PrivateChatWindow);
 271                    }
 0272                }
 273                else
 0274                    UpdateHudElement(configuration, HUDElementID.PRIVATE_CHAT_WINDOW);
 275
 1276                if (chatChannelHud == null)
 277                {
 1278                    CreateHudElement(configuration, HUDElementID.CHANNELS_CHAT);
 279
 1280                    chatChannelHud.Initialize();
 1281                    chatChannelHud.SetVisibility(false);
 1282                    chatChannelHud.OnPressBack -= HandleChannelBacked;
 1283                    chatChannelHud.OnPressBack += HandleChannelBacked;
 284
 1285                    taskbarHud?.AddChatChannel(chatChannelHud);
 286                }
 287
 1288                if (channelSearchHud == null)
 289                {
 1290                    CreateHudElement(configuration, HUDElementID.CHANNELS_SEARCH);
 1291                    channelSearchHud.Initialize(SearchChannelsWindowComponentView.Create());
 1292                    channelSearchHud.SetVisibility(false);
 1293                    taskbarHud?.AddChannelSearch(channelSearchHud);
 294                }
 295
 1296                if (channelCreateHud == null)
 297                {
 1298                    CreateHudElement(configuration, HUDElementID.CHANNELS_CREATE);
 1299                    channelCreateHud.Initialize(CreateChannelWindowComponentView.Create());
 1300                    channelCreateHud.SetVisibility(false);
 1301                    taskbarHud?.AddChannelCreation(channelCreateHud);
 302                }
 303
 1304                if (channelLeaveHud == null)
 305                {
 1306                    CreateHudElement(configuration, HUDElementID.CHANNELS_LEAVE_CONFIRMATION);
 1307                    channelLeaveHud.Initialize(LeaveChannelConfirmationWindowComponentView.Create());
 1308                    channelLeaveHud.SetVisibility(false);
 1309                    taskbarHud?.AddChannelLeaveConfirmation(channelLeaveHud);
 310                }
 311
 0312                break;
 313            case HUDElementID.FRIENDS:
 1314                if (friendsHud == null)
 315                {
 1316                    CreateHudElement(configuration, hudElementId);
 317
 1318                    if (friendsHud != null)
 319                    {
 1320                        friendsHud.Initialize();
 1321                        friendsHud.OnPressWhisper -= OpenPrivateChatWindow;
 1322                        friendsHud.OnPressWhisper += OpenPrivateChatWindow;
 323
 1324                        taskbarHud?.AddFriendsWindow(friendsHud);
 325                    }
 1326                }
 327                else
 328                {
 0329                    UpdateHudElement(configuration, hudElementId);
 330
 0331                    if (!configuration.active)
 0332                        taskbarHud?.DisableFriendsWindow();
 333                }
 334
 0335                break;
 336            case HUDElementID.TASKBAR:
 1337                if (taskbarHud == null)
 338                {
 1339                    CreateHudElement(configuration, hudElementId);
 340
 1341                    if (taskbarHud != null)
 342                    {
 1343                        taskbarHud.Initialize(SceneReferences.i.mouseCatcher);
 1344                        taskbarHud.OnAnyTaskbarButtonClicked -= TaskbarHud_onAnyTaskbarButtonClicked;
 1345                        taskbarHud.OnAnyTaskbarButtonClicked += TaskbarHud_onAnyTaskbarButtonClicked;
 346
 1347                        OnTaskbarCreation?.Invoke();
 348                    }
 0349                }
 350                else
 351                {
 0352                    UpdateHudElement(configuration, hudElementId);
 353                }
 354
 0355                break;
 356            case HUDElementID.OPEN_EXTERNAL_URL_PROMPT:
 1357                CreateHudElement(configuration, hudElementId);
 1358                break;
 359            case HUDElementID.NFT_INFO_DIALOG:
 1360                CreateHudElement(configuration, hudElementId);
 1361                break;
 362            case HUDElementID.TELEPORT_DIALOG:
 1363                CreateHudElement(configuration, hudElementId);
 1364                break;
 365            case HUDElementID.CONTROLS_HUD:
 1366                CreateHudElement(configuration, hudElementId);
 1367                break;
 368            case HUDElementID.HELP_AND_SUPPORT_HUD:
 1369                CreateHudElement(configuration, hudElementId);
 1370                settingsPanelHud?.AddHelpAndSupportWindow(helpAndSupportHud);
 1371                break;
 372            case HUDElementID.USERS_AROUND_LIST_HUD:
 1373                CreateHudElement(configuration, hudElementId);
 1374                if (voiceChatHud != null)
 1375                    taskbarHud?.AddVoiceChatWindow(voiceChatHud);
 376
 1377                break;
 378            case HUDElementID.GRAPHIC_CARD_WARNING:
 1379                CreateHudElement(configuration, hudElementId);
 1380                break;
 381            case HUDElementID.QUESTS_PANEL:
 1382                CreateHudElement(configuration, hudElementId);
 1383                if (configuration.active)
 1384                    questsPanelHUD.Initialize(QuestsController.i);
 1385                break;
 386            case HUDElementID.QUESTS_TRACKER:
 1387                CreateHudElement(configuration, hudElementId);
 1388                if (configuration.active)
 1389                    questsTrackerHUD.Initialize(QuestsController.i);
 1390                break;
 391            case HUDElementID.SIGNUP:
 1392                CreateHudElement(configuration, hudElementId);
 1393                if (configuration.active)
 394                {
 395                    //Same race condition risks as with the ProfileHUD
 396                    //TODO Refactor the way AvatarEditor sets its visibility to match our data driven pattern
 397                    //Then this reference can be removed so we just work with a BaseVariable<bool>.
 398                    //This refactor applies to the ProfileHUD and the way kernel asks the HUDController during signup
 1399                    signupHUD.Initialize(avatarEditorHud);
 400                }
 401
 1402                break;
 403            case HUDElementID.LOADING:
 1404                if (loadingHud == null)
 405                {
 1406                    CreateHudElement(configuration, hudElementId);
 1407                    if (loadingHud != null && configuration.active)
 1408                        loadingController.Initialize();
 409                }
 410
 411                break;
 412            case HUDElementID.AVATAR_NAMES:
 413                // TODO Remove the HUDElementId once kernel stops sending the Configure HUD message
 414                break;
 415        }
 416
 37417        var hudElement = GetHUDElement(hudElementId);
 418
 37419        if (hudElement != null)
 28420            hudElement.SetVisibility(configuration.active && configuration.visible);
 37421    }
 422
 423    private void OpenChannelSearchWindow()
 424    {
 0425        taskbarHud?.OpenChannelSearch();
 0426    }
 427
 428    private void HandleChannelBacked()
 429    {
 0430        chatChannelHud.SetVisibility(false);
 0431        taskbarHud?.GoBackFromChat();
 0432    }
 433
 434    private void HandlePublicChatChannelBacked()
 435    {
 0436        PublicChatWindowHud.SetVisibility(false);
 0437        taskbarHud?.GoBackFromChat();
 0438    }
 439
 440    private void OpenPublicChatWindow(string channelId)
 441    {
 0442        taskbarHud?.OpenPublicChat(channelId, true);
 0443    }
 444
 445    private void OpenChannelChatWindow(string channelId)
 446    {
 0447        taskbarHud?.OpenChannelChat(channelId);
 0448    }
 449
 450    private void OpenPrivateChatWindow(string targetUserId)
 451    {
 0452        taskbarHud?.OpenPrivateChat(targetUserId);
 0453    }
 454
 455    private void PrivateChatWindowHud_OnPressBack()
 456    {
 0457        PrivateChatWindow?.SetVisibility(false);
 0458        taskbarHud?.GoBackFromChat();
 0459    }
 460
 461    private void TaskbarHud_onAnyTaskbarButtonClicked()
 462    {
 0463        playerInfoCardHud?.CloseCard();
 0464    }
 465
 466    public void CreateHudElement(HUDConfiguration config, HUDElementID id)
 467    {
 28468        bool controllerCreated = hudElements.ContainsKey(id);
 469
 28470        if (config.active && !controllerCreated)
 471        {
 28472            hudElements.Add(id, hudFactory.CreateHUD(id));
 473
 28474            if (VERBOSE)
 0475                Debug.Log($"Adding {id} .. type {hudElements[id].GetType().Name}");
 476        }
 28477    }
 478
 479    public void UpdateHudElement(HUDConfiguration config, HUDElementID id)
 480    {
 0481        if (!hudElements.ContainsKey(id))
 0482            return;
 483
 0484        if (VERBOSE)
 0485            Debug.Log(
 486                $"Updating {id}, type {hudElements[id].GetType().Name}, active: {config.active} visible: {config.visible
 487
 0488        hudElements[id].SetVisibility(config.visible);
 0489    }
 490
 491    public void Cleanup()
 492    {
 670493        toggleUIVisibilityTrigger.OnTriggered -= ToggleUIVisibility_OnTriggered;
 670494        CommonScriptableObjects.allUIHidden.OnChange -= AllUIHiddenOnOnChange;
 495
 670496        if (worldChatWindowHud != null)
 497        {
 1498            worldChatWindowHud.OnOpenPrivateChat -= OpenPrivateChatWindow;
 1499            worldChatWindowHud.OnOpenPublicChat -= OpenPublicChatWindow;
 1500            worldChatWindowHud.OnOpenChannel -= OpenChannelChatWindow;
 501        }
 502
 670503        if (PrivateChatWindow != null)
 1504            PrivateChatWindow.OnBack -= PrivateChatWindowHud_OnPressBack;
 505
 670506        if (PublicChatWindowHud != null)
 507        {
 1508            PublicChatWindowHud.OnClosed -= HandlePublicChatChannelClosed;
 1509            PublicChatWindowHud.OnBack -= HandlePublicChatChannelBacked;
 510        }
 511
 512
 670513        if (friendsHud != null)
 1514            friendsHud.OnPressWhisper -= OpenPrivateChatWindow;
 515
 670516        if (taskbarHud != null)
 1517            taskbarHud.OnAnyTaskbarButtonClicked -= TaskbarHud_onAnyTaskbarButtonClicked;
 518
 670519        UserContextMenu.OnOpenPrivateChatRequest -= OpenPrivateChatWindow;
 520
 1396521        foreach (var kvp in hudElements)
 522        {
 28523            kvp.Value?.Dispose();
 524        }
 525
 670526        hudElements.Clear();
 670527    }
 528
 529    private void HandlePublicChatChannelClosed()
 530    {
 0531        PublicChatWindowHud.SetVisibility(false);
 0532    }
 533
 534    public IHUD GetHUDElement(HUDElementID id)
 535    {
 3576536        if (!hudElements.ContainsKey(id))
 3447537            return null;
 538
 129539        return hudElements[id];
 540    }
 541
 542    public static bool IsHUDElementDeprecated(HUDElementID element)
 543    {
 37544        Type enumType = typeof(HUDElementID);
 37545        var enumName = enumType.GetEnumName(element);
 37546        var fieldInfo = enumType.GetField(enumName);
 37547        return Attribute.IsDefined(fieldInfo, typeof(ObsoleteAttribute));
 548    }
 549
 550#if UNITY_EDITOR
 551    [ContextMenu("Trigger fake PlayerInfoCard")]
 552    public void TriggerFakePlayerInfoCard()
 553    {
 0554        var newModel = ownUserProfile.CloneModel();
 0555        newModel.name = "FakePassport";
 0556        newModel.description = "Fake Description for Testing";
 0557        newModel.userId = "test-id";
 558
 0559        UserProfileController.i.AddUserProfileToCatalog(newModel);
 0560        UserProfileController.GetProfileByUserId(newModel.userId).SetInventory(new[]
 561        {
 562            "dcl://halloween_2019/machete_headband_top_head",
 563            "dcl://halloween_2019/bee_suit_upper_body",
 564            "dcl://halloween_2019/bride_of_frankie_upper_body",
 565            "dcl://halloween_2019/creepy_nurse_upper_body",
 566        });
 0567        Resources.Load<StringVariable>("CurrentPlayerInfoCardId").Set(newModel.userId);
 0568    }
 569#endif
 570    public void Dispose()
 571    {
 669572        Cleanup();
 669573    }
 574}