< Summary

Class:TaskbarHUDController
Assembly:TaskbarHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TaskbarHUD/TaskbarHUDController.cs
Covered lines:177
Uncovered lines:311
Coverable lines:488
Total lines:864
Line coverage:36.2% (177 of 488)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TaskbarHUDController(...)0%110100%
CreateView()0%110100%
Initialize(...)0%220100%
HandleFriendsToggle(...)0%4.074083.33%
HandleEmotesToggle(...)0%30500%
ShowEmotes()0%12300%
HandleExperiencesToggle(...)0%12300%
HandleVoiceChatToggle(...)0%20400%
ShowExperiences()0%12300%
ToggleFriendsTrigger_OnTriggered(...)0%42600%
ToggleWorldChatTrigger_OnTriggered(...)0%56700%
CloseWindowTrigger_OnTriggered(...)0%30500%
HandleChatToggle(...)0%11.626046.15%
MouseCatcher_OnMouseUnlock()0%2100%
MouseCatcher_OnMouseLock()0%20400%
AddWorldChatWindow(...)0%8.518080%
OpenPublicChatOnPreviewMode()0%110100%
OpenFriendsWindow()0%440100%
CloseFriendsWindow()0%6200%
OpenPrivateChat(...)0%12300%
OpenLastActiveChatWindow(...)0%6.846071.43%
CloseAnyChatWindow()0%2100%
OpenChannelChat(...)0%1101000%
OpenPublicChat(...)0%1321100%
OpenChatList()0%12300%
CloseChatList()0%6200%
OpenVoiceChatWindow()0%12300%
CloseVoiceChatWindow()0%6200%
AddPrivateChatWindow(...)0%98075%
AddPublicChatChannel(...)0%98075%
HandlePublicChannelPreviewModeChanged(...)0%12300%
HandleChannelPreviewModeChanged(...)0%12300%
HandlePrivateChannelPreviewMode(...)0%12300%
AddFriendsWindow(...)0%8.798076.92%
AddVoiceChatWindow(...)0%37.138023.08%
InitializeEmotesSelector(...)0%2.52050%
IsEmotesVisibleChanged(...)0%2100%
InitializeExperiencesViewer(...)0%3.462028.57%
InitializeNotificationPanel(...)0%3.692025%
InitializeTopNotificationPanel(...)0%3.462028.57%
OpenClickedChat(...)0%42600%
IsExperiencesViewerOpenChanged(...)0%6200%
NumOfLoadedExperiencesChanged(...)0%220100%
DisableFriendsWindow()0%2100%
Dispose()0%660100%
SetVisibility(...)0%2100%
SetVisibility(...)0%110100%
GoBackFromChat()0%6200%
AddChatChannel(...)0%42600%
AddChannelSearch(...)0%3.013090%
AddChannelCreation(...)0%12300%
OpenChannelCreation()0%2100%
AddChannelLeaveConfirmation(...)0%6200%
OpenChannelLeaveConfirmation(...)0%2100%
OpenChannelSearch()0%12300%

File(s)

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

#LineLine coverage
 1using System;
 2using DCL;
 3using DCL.Chat.HUD;
 4using DCL.Chat.Notifications;
 5using TMPro;
 6using UnityEngine;
 7using UnityEngine.EventSystems;
 8
 9public class TaskbarHUDController : IHUD
 10{
 11    private readonly IChatController chatController;
 12    private readonly IFriendsController friendsController;
 13
 14    [Serializable]
 15    public struct Configuration
 16    {
 17        public bool enableVoiceChat;
 18        public bool enableQuestPanel;
 19    }
 20
 21    public TaskbarHUDView view;
 22    public WorldChatWindowController worldChatWindowHud;
 23    public PrivateChatWindowController privateChatWindow;
 24    public PublicChatWindowController publicChatWindow;
 25    public ChatChannelHUDController channelChatWindow;
 26    public FriendsHUDController friendsHud;
 27    public VoiceChatWindowController voiceChatHud;
 28
 29    private IMouseCatcher mouseCatcher;
 30    private InputAction_Trigger toggleFriendsTrigger;
 31    private InputAction_Trigger closeWindowTrigger;
 32    private InputAction_Trigger toggleWorldChatTrigger;
 33    private Transform experiencesViewerTransform;
 34    private Transform notificationViewerTransform;
 35    private Transform topNotificationViewerTransform;
 36    private IHUD chatToggleTargetWindow;
 37    private IHUD chatInputTargetWindow;
 38    private IHUD chatBackWindow;
 39    private SearchChannelsWindowController searchChannelsHud;
 40    private CreateChannelWindowController channelCreationWindow;
 41    private LeaveChannelConfirmationWindowController channelLeaveWindow;
 42
 43    public event Action OnAnyTaskbarButtonClicked;
 44
 045    public RectTransform socialTooltipReference => view.socialTooltipReference;
 46
 1247    internal BaseVariable<bool> isEmotesWheelInitialized => DataStore.i.emotesCustomization.isWheelInitialized;
 1148    internal BaseVariable<bool> isEmotesVisible => DataStore.i.HUDs.emotesVisible;
 049    internal BaseVariable<bool> emoteJustTriggeredFromShortcut => DataStore.i.HUDs.emoteJustTriggeredFromShortcut;
 1250    internal BaseVariable<Transform> isExperiencesViewerInitialized => DataStore.i.experiencesViewer.isInitialized;
 851    internal BaseVariable<Transform> notificationPanelTransform => DataStore.i.HUDs.notificationPanelTransform;
 852    internal BaseVariable<Transform> topNotificationPanelTransform => DataStore.i.HUDs.topNotificationPanelTransform;
 1553    internal BaseVariable<bool> isExperiencesViewerOpen => DataStore.i.experiencesViewer.isOpen;
 1254    internal BaseVariable<int> numOfLoadedExperiences => DataStore.i.experiencesViewer.numOfLoadedExperiences;
 055    internal BaseVariable<string> openedChat => DataStore.i.HUDs.openedChat;
 56
 457    public TaskbarHUDController(IChatController chatController, IFriendsController friendsController)
 58    {
 459        this.chatController = chatController;
 460        this.friendsController = friendsController;
 461    }
 62
 63    protected virtual TaskbarHUDView CreateView()
 64    {
 465        return TaskbarHUDView.Create();
 66    }
 67
 68    public void Initialize(IMouseCatcher mouseCatcher)
 69    {
 470        this.mouseCatcher = mouseCatcher;
 71
 472        view = CreateView();
 73
 474        if (mouseCatcher != null)
 75        {
 176            mouseCatcher.OnMouseLock -= MouseCatcher_OnMouseLock;
 177            mouseCatcher.OnMouseUnlock -= MouseCatcher_OnMouseUnlock;
 178            mouseCatcher.OnMouseLock += MouseCatcher_OnMouseLock;
 179            mouseCatcher.OnMouseUnlock += MouseCatcher_OnMouseUnlock;
 80        }
 81
 482        view.leftWindowContainerLayout.enabled = false;
 83
 484        view.OnChatToggle += HandleChatToggle;
 485        view.OnFriendsToggle += HandleFriendsToggle;
 486        view.OnEmotesToggle += HandleEmotesToggle;
 487        view.OnExperiencesToggle += HandleExperiencesToggle;
 488        view.OnVoiceChatToggle += HandleVoiceChatToggle;
 89
 490        toggleFriendsTrigger = Resources.Load<InputAction_Trigger>("ToggleFriends");
 491        toggleFriendsTrigger.OnTriggered -= ToggleFriendsTrigger_OnTriggered;
 492        toggleFriendsTrigger.OnTriggered += ToggleFriendsTrigger_OnTriggered;
 93
 494        closeWindowTrigger = Resources.Load<InputAction_Trigger>("CloseWindow");
 495        closeWindowTrigger.OnTriggered -= CloseWindowTrigger_OnTriggered;
 496        closeWindowTrigger.OnTriggered += CloseWindowTrigger_OnTriggered;
 97
 498        toggleWorldChatTrigger = Resources.Load<InputAction_Trigger>("ToggleWorldChat");
 499        toggleWorldChatTrigger.OnTriggered -= ToggleWorldChatTrigger_OnTriggered;
 4100        toggleWorldChatTrigger.OnTriggered += ToggleWorldChatTrigger_OnTriggered;
 101
 4102        isEmotesWheelInitialized.OnChange += InitializeEmotesSelector;
 4103        InitializeEmotesSelector(isEmotesWheelInitialized.Get(), false);
 4104        isEmotesVisible.OnChange += IsEmotesVisibleChanged;
 105
 4106        isExperiencesViewerOpen.OnChange += IsExperiencesViewerOpenChanged;
 107
 4108        view.leftWindowContainerAnimator.Show();
 109
 4110        CommonScriptableObjects.isTaskbarHUDInitialized.Set(true);
 4111        DataStore.i.builderInWorld.showTaskBar.OnChange += SetVisibility;
 112
 4113        isExperiencesViewerInitialized.OnChange += InitializeExperiencesViewer;
 4114        InitializeExperiencesViewer(isExperiencesViewerInitialized.Get(), null);
 115
 4116        notificationPanelTransform.OnChange += InitializeNotificationPanel;
 4117        InitializeNotificationPanel(notificationPanelTransform.Get(), null);
 118
 4119        topNotificationPanelTransform.OnChange += InitializeTopNotificationPanel;
 4120        InitializeTopNotificationPanel(topNotificationPanelTransform.Get(), null);
 121
 4122        numOfLoadedExperiences.OnChange += NumOfLoadedExperiencesChanged;
 4123        NumOfLoadedExperiencesChanged(numOfLoadedExperiences.Get(), 0);
 4124    }
 125
 126    private void HandleFriendsToggle(bool show)
 127    {
 3128        if (show)
 2129            OpenFriendsWindow();
 130        else
 131        {
 1132            friendsHud?.SetVisibility(false);
 1133            OpenPublicChatOnPreviewMode();
 134        }
 135
 3136        OnAnyTaskbarButtonClicked?.Invoke();
 0137    }
 138
 139    private void HandleEmotesToggle(bool show)
 140    {
 0141        if (show && emoteJustTriggeredFromShortcut.Get())
 142        {
 0143            emoteJustTriggeredFromShortcut.Set(false);
 0144            return;
 145        }
 146
 0147        if (show)
 148        {
 0149            OpenPublicChatOnPreviewMode();
 0150            ShowEmotes();
 0151        }
 152        else
 153        {
 0154            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Emotes);
 0155            isEmotesVisible.Set(false);
 0156            OpenPublicChatOnPreviewMode();
 157        }
 158
 0159        OnAnyTaskbarButtonClicked?.Invoke();
 0160    }
 161
 162    private void ShowEmotes()
 163    {
 0164        worldChatWindowHud.SetVisibility(false);
 0165        privateChatWindow.SetVisibility(false);
 0166        channelChatWindow.SetVisibility(false);
 0167        friendsHud?.SetVisibility(false);
 0168        searchChannelsHud.SetVisibility(false);
 0169        isExperiencesViewerOpen.Set(false);
 0170        voiceChatHud?.SetVisibility(false);
 0171        isEmotesVisible.Set(true);
 0172        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Emotes);
 0173    }
 174
 175    private void HandleExperiencesToggle(bool show)
 176    {
 0177        if (show)
 0178            ShowExperiences();
 179        else
 180        {
 0181            isExperiencesViewerOpen.Set(false);
 0182            OpenPublicChatOnPreviewMode();
 183        }
 184
 0185        OnAnyTaskbarButtonClicked?.Invoke();
 0186    }
 187
 188    private void HandleVoiceChatToggle(bool show)
 189    {
 0190        if (show)
 0191            OpenVoiceChatWindow();
 192        else
 0193            voiceChatHud?.SetVisibility(false);
 0194        OnAnyTaskbarButtonClicked?.Invoke();
 0195    }
 196
 197    private void ShowExperiences()
 198    {
 0199        worldChatWindowHud.SetVisibility(false);
 0200        privateChatWindow.SetVisibility(false);
 0201        publicChatWindow.SetVisibility(false);
 0202        channelChatWindow.SetVisibility(false);
 0203        searchChannelsHud.SetVisibility(false);
 0204        friendsHud?.SetVisibility(false);
 0205        isEmotesVisible.Set(false);
 0206        voiceChatHud?.SetVisibility(false);
 0207        isExperiencesViewerOpen.Set(true);
 0208    }
 209
 210    private void ToggleFriendsTrigger_OnTriggered(DCLAction_Trigger action)
 211    {
 0212        if (friendsHud == null) return;
 213
 0214        bool anyInputFieldIsSelected = EventSystem.current != null &&
 215                                       EventSystem.current.currentSelectedGameObject != null &&
 216                                       EventSystem.current.currentSelectedGameObject.GetComponent<TMP_InputField>() !=
 217                                       null;
 218
 0219        if (anyInputFieldIsSelected) return;
 220
 0221        mouseCatcher.UnlockCursor();
 222
 0223        if (!friendsHud.View.IsActive())
 224        {
 0225            view.leftWindowContainerAnimator.Show();
 0226            OpenFriendsWindow();
 0227        }
 228        else
 229        {
 0230            CloseFriendsWindow();
 0231            OpenPublicChatOnPreviewMode();
 232        }
 0233    }
 234
 235    private void ToggleWorldChatTrigger_OnTriggered(DCLAction_Trigger action)
 236    {
 0237        bool anyInputFieldIsSelected = EventSystem.current != null &&
 238                                       EventSystem.current.currentSelectedGameObject != null &&
 239                                       EventSystem.current.currentSelectedGameObject.GetComponent<TMP_InputField>() !=
 240                                       null;
 241
 0242        if (anyInputFieldIsSelected) return;
 243
 0244        mouseCatcher.UnlockCursor();
 0245        chatBackWindow = worldChatWindowHud;
 246
 0247        if (!worldChatWindowHud.View.IsActive
 248            && !privateChatWindow.View.IsActive
 249            && !publicChatWindow.View.IsActive)
 0250            OpenLastActiveChatWindow(chatInputTargetWindow);
 0251    }
 252
 253    private void CloseWindowTrigger_OnTriggered(DCLAction_Trigger action)
 254    {
 0255        if (mouseCatcher.isLocked) return;
 256
 0257        if (publicChatWindow.View.IsActive ||
 258            channelChatWindow.View.IsActive ||
 259            privateChatWindow.View.IsActive)
 260        {
 0261            publicChatWindow.SetVisibility(false);
 0262            worldChatWindowHud.SetVisibility(true);
 0263            chatToggleTargetWindow = worldChatWindowHud;
 0264            chatInputTargetWindow = publicChatWindow;
 0265        }
 266        else
 267        {
 0268            worldChatWindowHud.SetVisibility(false);
 0269            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 270        }
 271
 0272        publicChatWindow.SetVisibility(false);
 0273        privateChatWindow.SetVisibility(false);
 0274        channelChatWindow.SetVisibility(false);
 0275        CloseFriendsWindow();
 0276        CloseVoiceChatWindow();
 0277        isEmotesVisible.Set(false);
 0278        isExperiencesViewerOpen.Set(false);
 0279    }
 280
 281    private void HandleChatToggle(bool show)
 282    {
 1283        if (show)
 284        {
 1285            chatBackWindow = publicChatWindow;
 1286            var openedWindow = OpenLastActiveChatWindow(chatToggleTargetWindow);
 1287            if (openedWindow == publicChatWindow)
 1288                publicChatWindow.SetVisibility(true);
 0289            else if (openedWindow == privateChatWindow)
 0290                privateChatWindow.SetVisibility(true);
 0291            else if (openedWindow == channelChatWindow)
 0292                channelChatWindow.SetVisibility(true);
 0293        }
 294        else
 295        {
 0296            CloseAnyChatWindow();
 297        }
 298
 1299        OnAnyTaskbarButtonClicked?.Invoke();
 0300    }
 301
 302    private void MouseCatcher_OnMouseUnlock()
 303    {
 304        // TODO: temporary deactivated current window fadein/fadeout until we get the full chat notifications feature im
 305        // view.leftWindowContainerAnimator.Show();
 306        // view.RestoreLastToggle();
 0307    }
 308
 309    private void MouseCatcher_OnMouseLock()
 310    {
 311        // TODO: temporary deactivated current window fadein/fadeout until we get the full chat notifications feature im
 312        // view.leftWindowContainerAnimator.Hide();
 313        // view.ToggleAllOff();
 314
 0315        CloseFriendsWindow();
 0316        CloseChatList();
 0317        CloseVoiceChatWindow();
 0318        isExperiencesViewerOpen.Set(false);
 319
 0320        if (!privateChatWindow.View.IsActive
 321            && !publicChatWindow.View.IsActive
 322            && !channelChatWindow.View.IsActive)
 0323            OpenPublicChatOnPreviewMode();
 0324    }
 325
 326    public void AddWorldChatWindow(WorldChatWindowController controller)
 327    {
 2328        if (controller?.View == null)
 329        {
 0330            Debug.LogWarning("AddChatWindow >>> World Chat Window doesn't exist yet!");
 0331            return;
 332        }
 333
 2334        if (controller.View.Transform.parent == view.leftWindowContainer) return;
 335
 2336        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 2337        notificationViewerTransform?.SetAsLastSibling();
 2338        topNotificationViewerTransform?.SetAsFirstSibling();
 2339        experiencesViewerTransform?.SetAsLastSibling();
 340
 2341        worldChatWindowHud = controller;
 342
 2343        view.ShowChatButton();
 2344        worldChatWindowHud.OnCloseView += OpenPublicChatOnPreviewMode;
 2345        worldChatWindowHud.OnOpenChannelCreation += OpenChannelCreation;
 2346        worldChatWindowHud.OnOpenChannelLeave += OpenChannelLeaveConfirmation;
 2347    }
 348
 1349    private void OpenPublicChatOnPreviewMode() => view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 350
 351    private void OpenFriendsWindow()
 352    {
 2353        worldChatWindowHud.SetVisibility(false);
 2354        privateChatWindow.SetVisibility(false);
 2355        publicChatWindow.SetVisibility(false);
 2356        channelChatWindow?.SetVisibility(false);
 2357        searchChannelsHud.SetVisibility(false);
 2358        isExperiencesViewerOpen.Set(false);
 2359        isEmotesVisible.Set(false);
 2360        voiceChatHud?.SetVisibility(false);
 2361        friendsHud?.SetVisibility(true);
 2362        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Friends);
 2363        chatBackWindow = friendsHud;
 2364    }
 365
 366    private void CloseFriendsWindow()
 367    {
 0368        friendsHud?.SetVisibility(false);
 0369        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Friends);
 0370    }
 371
 372    public void OpenPrivateChat(string userId)
 373    {
 0374        worldChatWindowHud.SetVisibility(false);
 0375        publicChatWindow.SetVisibility(false);
 0376        channelChatWindow.SetVisibility(false);
 0377        searchChannelsHud.SetVisibility(false);
 0378        friendsHud?.SetVisibility(false);
 0379        isExperiencesViewerOpen.Set(false);
 0380        isEmotesVisible.Set(false);
 0381        voiceChatHud?.SetVisibility(false);
 0382        openedChat.Set(userId);
 0383        privateChatWindow.Setup(userId);
 0384        privateChatWindow.SetVisibility(true);
 0385        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 0386        chatToggleTargetWindow = worldChatWindowHud;
 0387        chatInputTargetWindow = privateChatWindow;
 0388    }
 389
 390    private IHUD OpenLastActiveChatWindow(IHUD lastActiveWindow)
 391    {
 1392        worldChatWindowHud.SetVisibility(false);
 1393        privateChatWindow.SetVisibility(false);
 1394        publicChatWindow.SetVisibility(false);
 1395        channelChatWindow?.SetVisibility(false);
 1396        searchChannelsHud.SetVisibility(false);
 1397        friendsHud?.SetVisibility(false);
 1398        isEmotesVisible.Set(false);
 1399        isExperiencesViewerOpen.Set(false);
 1400        voiceChatHud?.SetVisibility(false);
 401
 402        IHUD visibleWindow;
 403
 1404        if (lastActiveWindow == publicChatWindow)
 405        {
 0406            publicChatWindow.SetVisibility(true, true);
 0407            visibleWindow = publicChatWindow;
 0408        }
 1409        else if (lastActiveWindow != null)
 410        {
 0411            lastActiveWindow.SetVisibility(true);
 0412            visibleWindow = lastActiveWindow;
 0413        }
 414        else
 415        {
 1416            publicChatWindow.SetVisibility(true, true);
 1417            visibleWindow = publicChatWindow;
 418        }
 419
 1420        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 421
 1422        return visibleWindow;
 423    }
 424
 425    private void CloseAnyChatWindow()
 426    {
 0427        worldChatWindowHud.SetVisibility(false);
 0428        privateChatWindow.SetVisibility(false);
 0429        publicChatWindow.SetVisibility(false);
 0430        channelChatWindow.SetVisibility(false);
 0431        searchChannelsHud.SetVisibility(false);
 0432        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 0433    }
 434
 435    public void OpenChannelChat(string channelId)
 436    {
 0437        openedChat.Set(channelId);
 0438        channelChatWindow?.Setup(channelId);
 0439        channelChatWindow?.SetVisibility(true);
 0440        publicChatWindow?.SetVisibility(false);
 0441        worldChatWindowHud?.SetVisibility(false);
 0442        privateChatWindow?.SetVisibility(false);
 0443        searchChannelsHud.SetVisibility(false);
 0444        friendsHud?.SetVisibility(false);
 0445        isExperiencesViewerOpen?.Set(false);
 0446        isEmotesVisible?.Set(false);
 0447        voiceChatHud?.SetVisibility(false);
 448
 0449        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 450
 0451        chatToggleTargetWindow = worldChatWindowHud;
 0452        chatInputTargetWindow = channelChatWindow;
 0453    }
 454
 455
 456    public void OpenPublicChat(string channelId, bool focusInputField)
 457    {
 0458        openedChat.Set(channelId);
 0459        publicChatWindow?.Setup(channelId);
 0460        publicChatWindow?.SetVisibility(true, focusInputField);
 0461        channelChatWindow?.SetVisibility(false);
 0462        worldChatWindowHud?.SetVisibility(false);
 0463        privateChatWindow?.SetVisibility(false);
 0464        searchChannelsHud?.SetVisibility(false);
 0465        friendsHud?.SetVisibility(false);
 0466        isExperiencesViewerOpen?.Set(false);
 0467        isEmotesVisible?.Set(false);
 0468        voiceChatHud?.SetVisibility(false);
 469
 0470        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 471
 0472        chatToggleTargetWindow = worldChatWindowHud;
 0473        chatInputTargetWindow = publicChatWindow;
 0474    }
 475
 476    private void OpenChatList()
 477    {
 0478        privateChatWindow.SetVisibility(false);
 0479        publicChatWindow.SetVisibility(false);
 0480        channelChatWindow.SetVisibility(false);
 0481        searchChannelsHud.SetVisibility(false);
 0482        friendsHud?.SetVisibility(false);
 0483        isExperiencesViewerOpen.Set(false);
 0484        isEmotesVisible.Set(false);
 0485        voiceChatHud?.SetVisibility(false);
 0486        worldChatWindowHud.SetVisibility(true);
 0487        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 488
 0489        chatToggleTargetWindow = worldChatWindowHud;
 0490    }
 491
 492    private void CloseChatList()
 493    {
 0494        if (!worldChatWindowHud.View.IsActive) return;
 0495        worldChatWindowHud.SetVisibility(false);
 0496        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 0497    }
 498
 499    private void OpenVoiceChatWindow()
 500    {
 0501        worldChatWindowHud.SetVisibility(false);
 0502        privateChatWindow.SetVisibility(false);
 0503        publicChatWindow.SetVisibility(false);
 0504        channelChatWindow.SetVisibility(false);
 0505        searchChannelsHud.SetVisibility(false);
 0506        isExperiencesViewerOpen.Set(false);
 0507        isEmotesVisible.Set(false);
 0508        friendsHud?.SetVisibility(false);
 0509        voiceChatHud?.SetVisibility(true);
 0510        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.VoiceChat);
 0511    }
 512
 513    private void CloseVoiceChatWindow()
 514    {
 0515        voiceChatHud?.SetVisibility(false);
 0516        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.VoiceChat);
 0517    }
 518
 519    public void AddPrivateChatWindow(PrivateChatWindowController controller)
 520    {
 1521        if (controller?.View == null)
 522        {
 0523            Debug.LogWarning("AddPrivateChatWindow >>> Private Chat Window doesn't exist yet!");
 0524            return;
 525        }
 526
 1527        if (controller.View.Transform.parent == view.leftWindowContainer)
 0528            return;
 529
 1530        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 1531        notificationViewerTransform?.SetAsLastSibling();
 1532        topNotificationViewerTransform?.SetAsFirstSibling();
 1533        experiencesViewerTransform?.SetAsLastSibling();
 534
 1535        privateChatWindow = controller;
 536
 1537        controller.OnClosed += OpenPublicChatOnPreviewMode;
 1538    }
 539
 540    public void AddPublicChatChannel(PublicChatWindowController controller)
 541    {
 1542        if (controller?.View == null)
 543        {
 0544            Debug.LogWarning("AddPublicChatChannel >>> Public Chat Window doesn't exist yet!");
 0545            return;
 546        }
 547
 1548        if (controller.View.Transform.parent == view.leftWindowContainer) return;
 549
 1550        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 1551        notificationViewerTransform?.SetAsLastSibling();
 1552        topNotificationViewerTransform?.SetAsFirstSibling();
 1553        experiencesViewerTransform?.SetAsLastSibling();
 554
 1555        publicChatWindow = controller;
 556
 1557        controller.OnClosed += OpenPublicChatOnPreviewMode;
 1558    }
 559
 560    private void HandlePublicChannelPreviewModeChanged(bool isPreviewMode)
 561    {
 0562        if (!publicChatWindow.View.IsActive) return;
 0563        if (isPreviewMode)
 0564            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 565        else
 0566            view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 0567    }
 568
 569    private void HandleChannelPreviewModeChanged(bool isPreviewMode)
 570    {
 0571        if (!channelChatWindow.View.IsActive) return;
 0572        if (isPreviewMode)
 0573            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 574        else
 0575            view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 0576    }
 577
 578    private void HandlePrivateChannelPreviewMode(bool isPreviewMode)
 579    {
 0580        if (!privateChatWindow.View.IsActive) return;
 0581        if (isPreviewMode)
 0582            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 583        else
 0584            view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 0585    }
 586
 587    public void AddFriendsWindow(FriendsHUDController controller)
 588    {
 3589        if (controller?.View == null)
 590        {
 0591            Debug.LogWarning("AddFriendsWindow >>> Friends window doesn't exist yet!");
 0592            return;
 593        }
 594
 3595        if (controller.View.Transform.parent == view.leftWindowContainer)
 0596            return;
 597
 3598        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 3599        notificationViewerTransform?.SetAsLastSibling();
 3600        topNotificationViewerTransform?.SetAsFirstSibling();
 3601        experiencesViewerTransform?.SetAsLastSibling();
 602
 3603        friendsHud = controller;
 3604        view.ShowFriendsButton();
 3605        friendsHud.OnViewClosed += () =>
 606        {
 0607            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Friends);
 0608            OpenPublicChatOnPreviewMode();
 0609        };
 3610    }
 611
 612    public void AddVoiceChatWindow(VoiceChatWindowController controller)
 613    {
 1614        if (controller?.VoiceChatWindowView == null)
 615        {
 1616            Debug.LogWarning("AddVoiceChatWindow >>> Voice Chat window doesn't exist yet!");
 1617            return;
 618        }
 619
 0620        if (controller.VoiceChatWindowView.Transform.parent == view.leftWindowContainer)
 0621            return;
 622
 0623        controller.VoiceChatWindowView.Transform.SetParent(view.leftWindowContainer, false);
 624
 0625        voiceChatHud = controller;
 0626        view.ShowVoiceChatButton();
 0627        voiceChatHud.OnCloseView += () => view.ToggleOff(TaskbarHUDView.TaskbarButtonType.VoiceChat);
 628
 0629        if (controller?.VoiceChatBarView != null)
 630        {
 0631            controller.VoiceChatBarView.Transform.SetParent(view.altSectionContainer, false);
 0632            controller.VoiceChatBarView.Transform.SetAsFirstSibling();
 633        }
 0634    }
 635
 636    private void InitializeEmotesSelector(bool current, bool previous)
 637    {
 8638        if (!current) return;
 0639        view.ShowEmotesButton();
 0640    }
 641
 0642    private void IsEmotesVisibleChanged(bool current, bool previous) => HandleEmotesToggle(current);
 643
 644    private void InitializeExperiencesViewer(Transform currentViewTransform, Transform previousViewTransform)
 645    {
 4646        if (currentViewTransform == null)
 4647            return;
 648
 0649        experiencesViewerTransform = currentViewTransform;
 0650        experiencesViewerTransform.SetParent(view.leftWindowContainer, false);
 0651        experiencesViewerTransform.SetAsLastSibling();
 652
 0653        view.ShowExperiencesButton();
 0654    }
 655
 656    private void InitializeNotificationPanel(Transform currentPanelTransform, Transform previousPanelTransform)
 657    {
 4658        if (currentPanelTransform == null)
 4659            return;
 660
 0661        notificationViewerTransform = currentPanelTransform;
 0662        notificationViewerTransform.SetParent(view.leftWindowContainer, false);
 0663        notificationViewerTransform.SetAsLastSibling();
 0664        experiencesViewerTransform.SetAsLastSibling();
 0665        notificationViewerTransform.GetComponent<MainChatNotificationsComponentView>().OnClickedNotification += OpenClic
 0666    }
 667
 668    private void InitializeTopNotificationPanel(Transform currentPanelTransform, Transform previousPanelTransform)
 669    {
 4670        if (currentPanelTransform == null)
 4671            return;
 672
 0673        topNotificationViewerTransform = currentPanelTransform;
 0674        topNotificationViewerTransform.SetParent(view.leftWindowContainer, false);
 0675        topNotificationViewerTransform.SetAsFirstSibling();
 0676        topNotificationViewerTransform.GetComponent<TopNotificationComponentView>().OnClickedNotification += OpenClicked
 0677    }
 678
 679    private void OpenClickedChat(string chatId)
 680    {
 681        const string nearbyChannelId = "nearby";
 682        const string conversationListId = "conversationList";
 683
 0684        if (chatId == nearbyChannelId)
 0685            OpenPublicChat(nearbyChannelId, true);
 0686        else if (chatController.GetAllocatedChannel(chatId) != null)
 687        {
 0688            if(chatController.GetAllocatedChannel(chatId).Joined)
 0689                OpenChannelChat(chatId);
 690            else
 0691                return;
 692        }
 0693        else if(chatId == conversationListId)
 0694            OpenChatList();
 695        else
 696        {
 0697            if(friendsController.GetUserStatus(chatId).friendshipStatus == FriendshipStatus.FRIEND)
 0698                OpenPrivateChat(chatId);
 699        }
 0700    }
 701
 702    private void IsExperiencesViewerOpenChanged(bool current, bool previous)
 703    {
 0704        if (current)
 0705            return;
 706
 0707        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Experiences);
 0708        OpenPublicChatOnPreviewMode();
 0709    }
 710
 711    private void NumOfLoadedExperiencesChanged(int current, int previous)
 712    {
 4713        view.SetExperiencesVisibility(current > 0);
 714
 4715        if (current == 0)
 4716            isExperiencesViewerOpen.Set(false);
 4717    }
 718
 719    public void DisableFriendsWindow()
 720    {
 0721        view.friendsButton.transform.parent.gameObject.SetActive(false);
 0722    }
 723
 724    public void Dispose()
 725    {
 4726        if (view != null)
 727        {
 4728            view.OnChatToggle -= HandleChatToggle;
 4729            view.OnFriendsToggle -= HandleFriendsToggle;
 4730            view.OnEmotesToggle -= HandleEmotesToggle;
 4731            view.OnExperiencesToggle -= HandleExperiencesToggle;
 4732            view.OnVoiceChatToggle -= HandleVoiceChatToggle;
 733
 4734            view.Destroy();
 735        }
 736
 4737        if (mouseCatcher != null)
 738        {
 1739            mouseCatcher.OnMouseLock -= MouseCatcher_OnMouseLock;
 1740            mouseCatcher.OnMouseUnlock -= MouseCatcher_OnMouseUnlock;
 741        }
 742
 4743        if (toggleFriendsTrigger != null)
 4744            toggleFriendsTrigger.OnTriggered -= ToggleFriendsTrigger_OnTriggered;
 745
 4746        if (closeWindowTrigger != null)
 4747            closeWindowTrigger.OnTriggered -= CloseWindowTrigger_OnTriggered;
 748
 4749        if (toggleWorldChatTrigger != null)
 4750            toggleWorldChatTrigger.OnTriggered -= ToggleWorldChatTrigger_OnTriggered;
 751
 4752        DataStore.i.builderInWorld.showTaskBar.OnChange -= SetVisibility;
 4753        isEmotesWheelInitialized.OnChange -= InitializeEmotesSelector;
 4754        isEmotesVisible.OnChange -= IsEmotesVisibleChanged;
 4755        isExperiencesViewerOpen.OnChange -= IsExperiencesViewerOpenChanged;
 4756        isExperiencesViewerInitialized.OnChange -= InitializeExperiencesViewer;
 4757        numOfLoadedExperiences.OnChange -= NumOfLoadedExperiencesChanged;
 4758    }
 759
 760    private void SetVisibility(bool visible, bool previus)
 761    {
 0762        SetVisibility(visible);
 0763    }
 764
 765    public void SetVisibility(bool visible)
 766    {
 1767        view.SetVisibility(visible);
 1768    }
 769
 770    public void GoBackFromChat()
 771    {
 0772        if (chatBackWindow == friendsHud)
 0773            OpenFriendsWindow();
 774        else
 0775            OpenChatList();
 0776    }
 777
 778    public void AddChatChannel(ChatChannelHUDController controller)
 779    {
 0780        if (controller?.View == null)
 781        {
 0782            Debug.LogWarning("AddChatChannel >>> Chat Window doesn't exist yet!");
 0783            return;
 784        }
 785
 0786        if (controller.View.Transform.parent == view.leftWindowContainer) return;
 787
 0788        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 0789        experiencesViewerTransform?.SetAsLastSibling();
 790
 0791        channelChatWindow = controller;
 792
 0793        controller.OnClosed += OpenPublicChatOnPreviewMode;
 0794        controller.OnOpenChannelLeave += OpenChannelLeaveConfirmation;
 0795    }
 796
 797    public void AddChannelSearch(SearchChannelsWindowController controller)
 798    {
 1799        if (controller.View.Transform.parent == view.leftWindowContainer) return;
 800
 1801        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 1802        experiencesViewerTransform?.SetAsLastSibling();
 803
 1804        searchChannelsHud = controller;
 805
 1806        controller.OnClosed += () =>
 807        {
 0808            controller.SetVisibility(false);
 0809            OpenPublicChatOnPreviewMode();
 0810        };
 1811        controller.OnBack += GoBackFromChat;
 1812        controller.OnOpenChannelCreation += OpenChannelCreation;
 1813        controller.OnOpenChannelLeave += OpenChannelLeaveConfirmation;
 1814    }
 815
 816    public void AddChannelCreation(CreateChannelWindowController controller)
 817    {
 0818        if (controller.View.Transform.parent == view.fullScreenWindowContainer) return;
 819
 0820        controller.View.Transform.SetParent(view.fullScreenWindowContainer, false);
 0821        experiencesViewerTransform?.SetAsLastSibling();
 822
 0823        channelCreationWindow = controller;
 824
 0825        controller.OnNavigateToChannelWindow += channelId =>
 826        {
 0827            OpenChannelChat(channelId);
 0828            channelCreationWindow.SetVisibility(false);
 0829        };
 0830    }
 831
 832    private void OpenChannelCreation()
 833    {
 0834        channelCreationWindow.SetVisibility(true);
 0835    }
 836
 837    public void AddChannelLeaveConfirmation(LeaveChannelConfirmationWindowController controller)
 838    {
 0839        if (controller.View.Transform.parent == view.fullScreenWindowContainer) return;
 840
 0841        controller.View.Transform.SetParent(view.fullScreenWindowContainer, false);
 0842        channelLeaveWindow = controller;
 0843    }
 844
 845    private void OpenChannelLeaveConfirmation(string channelId)
 846    {
 0847        channelLeaveWindow.SetChannelToLeave(channelId);
 0848        channelLeaveWindow.SetVisibility(true);
 0849    }
 850
 851    public void OpenChannelSearch()
 852    {
 0853        privateChatWindow.SetVisibility(false);
 0854        publicChatWindow.SetVisibility(false);
 0855        channelChatWindow.SetVisibility(false);
 0856        searchChannelsHud.SetVisibility(true);
 0857        friendsHud?.SetVisibility(false);
 0858        isExperiencesViewerOpen.Set(false);
 0859        isEmotesVisible.Set(false);
 0860        voiceChatHud?.SetVisibility(false);
 0861        worldChatWindowHud.SetVisibility(false);
 0862        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 0863    }
 864}

Methods/Properties

socialTooltipReference()
isEmotesWheelInitialized()
isEmotesVisible()
emoteJustTriggeredFromShortcut()
isExperiencesViewerInitialized()
notificationPanelTransform()
topNotificationPanelTransform()
isExperiencesViewerOpen()
numOfLoadedExperiences()
openedChat()
TaskbarHUDController(IChatController, IFriendsController)
CreateView()
Initialize(DCL.IMouseCatcher)
HandleFriendsToggle(System.Boolean)
HandleEmotesToggle(System.Boolean)
ShowEmotes()
HandleExperiencesToggle(System.Boolean)
HandleVoiceChatToggle(System.Boolean)
ShowExperiences()
ToggleFriendsTrigger_OnTriggered(DCLAction_Trigger)
ToggleWorldChatTrigger_OnTriggered(DCLAction_Trigger)
CloseWindowTrigger_OnTriggered(DCLAction_Trigger)
HandleChatToggle(System.Boolean)
MouseCatcher_OnMouseUnlock()
MouseCatcher_OnMouseLock()
AddWorldChatWindow(WorldChatWindowController)
OpenPublicChatOnPreviewMode()
OpenFriendsWindow()
CloseFriendsWindow()
OpenPrivateChat(System.String)
OpenLastActiveChatWindow(IHUD)
CloseAnyChatWindow()
OpenChannelChat(System.String)
OpenPublicChat(System.String, System.Boolean)
OpenChatList()
CloseChatList()
OpenVoiceChatWindow()
CloseVoiceChatWindow()
AddPrivateChatWindow(PrivateChatWindowController)
AddPublicChatChannel(PublicChatWindowController)
HandlePublicChannelPreviewModeChanged(System.Boolean)
HandleChannelPreviewModeChanged(System.Boolean)
HandlePrivateChannelPreviewMode(System.Boolean)
AddFriendsWindow(FriendsHUDController)
AddVoiceChatWindow(VoiceChatWindowController)
InitializeEmotesSelector(System.Boolean, System.Boolean)
IsEmotesVisibleChanged(System.Boolean, System.Boolean)
InitializeExperiencesViewer(UnityEngine.Transform, UnityEngine.Transform)
InitializeNotificationPanel(UnityEngine.Transform, UnityEngine.Transform)
InitializeTopNotificationPanel(UnityEngine.Transform, UnityEngine.Transform)
OpenClickedChat(System.String)
IsExperiencesViewerOpenChanged(System.Boolean, System.Boolean)
NumOfLoadedExperiencesChanged(System.Int32, System.Int32)
DisableFriendsWindow()
Dispose()
SetVisibility(System.Boolean, System.Boolean)
SetVisibility(System.Boolean)
GoBackFromChat()
AddChatChannel(DCL.Chat.HUD.ChatChannelHUDController)
AddChannelSearch(DCL.Chat.HUD.SearchChannelsWindowController)
AddChannelCreation(DCL.Chat.HUD.CreateChannelWindowController)
OpenChannelCreation()
AddChannelLeaveConfirmation(DCL.Chat.HUD.LeaveChannelConfirmationWindowController)
OpenChannelLeaveConfirmation(System.String)
OpenChannelSearch()