< Summary

Class:TaskbarHUDController
Assembly:TaskbarHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TaskbarHUD/TaskbarHUDController.cs
Covered lines:174
Uncovered lines:319
Coverable lines:493
Total lines:873
Line coverage:35.2% (174 of 493)
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%3.333066.67%
MouseCatcher_OnMouseUnlock()0%2100%
MouseCatcher_OnMouseLock()0%20400%
AddWorldChatWindow(...)0%8.518080%
ToggleOffChatIcon()0%110100%
OpenFriendsWindow()0%440100%
CloseFriendsWindow()0%6200%
OpenPrivateChat(...)0%12300%
OpenLastActiveChatWindow(...)0%42600%
OpenWorldChatWindow()0%440100%
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 DCl.Social.Friends;
 6using DCL.Social.Friends;
 7using TMPro;
 8using UnityEngine;
 9using UnityEngine.EventSystems;
 10
 11public class TaskbarHUDController : IHUD
 12{
 13    private readonly IChatController chatController;
 14    private readonly IFriendsController friendsController;
 15
 16    [Serializable]
 17    public struct Configuration
 18    {
 19        public bool enableVoiceChat;
 20        public bool enableQuestPanel;
 21    }
 22
 23    public TaskbarHUDView view;
 24    public WorldChatWindowController worldChatWindowHud;
 25    public PrivateChatWindowController privateChatWindow;
 26    public PublicChatWindowController publicChatWindow;
 27    public ChatChannelHUDController channelChatWindow;
 28    public FriendsHUDController friendsHud;
 29    public VoiceChatWindowController voiceChatHud;
 30
 31    private IMouseCatcher mouseCatcher;
 32    private InputAction_Trigger toggleFriendsTrigger;
 33    private InputAction_Trigger closeWindowTrigger;
 34    private InputAction_Trigger toggleWorldChatTrigger;
 35    private Transform experiencesViewerTransform;
 36    private Transform notificationViewerTransform;
 37    private Transform topNotificationViewerTransform;
 38    private IHUD chatToggleTargetWindow;
 39    private IHUD chatInputTargetWindow;
 40    private IHUD chatBackWindow;
 41    private SearchChannelsWindowController searchChannelsHud;
 42    private CreateChannelWindowController channelCreationWindow;
 43    private LeaveChannelConfirmationWindowController channelLeaveWindow;
 44
 45    public event Action OnAnyTaskbarButtonClicked;
 46
 047    public RectTransform socialTooltipReference => view.socialTooltipReference;
 48
 1249    internal BaseVariable<bool> isEmotesWheelInitialized => DataStore.i.emotesCustomization.isWheelInitialized;
 1150    internal BaseVariable<bool> isEmotesVisible => DataStore.i.HUDs.emotesVisible;
 051    internal BaseVariable<bool> emoteJustTriggeredFromShortcut => DataStore.i.HUDs.emoteJustTriggeredFromShortcut;
 1252    internal BaseVariable<Transform> isExperiencesViewerInitialized => DataStore.i.experiencesViewer.isInitialized;
 853    internal BaseVariable<Transform> notificationPanelTransform => DataStore.i.HUDs.notificationPanelTransform;
 854    internal BaseVariable<Transform> topNotificationPanelTransform => DataStore.i.HUDs.topNotificationPanelTransform;
 1555    internal BaseVariable<bool> isExperiencesViewerOpen => DataStore.i.experiencesViewer.isOpen;
 1256    internal BaseVariable<int> numOfLoadedExperiences => DataStore.i.experiencesViewer.numOfLoadedExperiences;
 057    internal BaseVariable<string> openedChat => DataStore.i.HUDs.openedChat;
 358    internal BaseVariable<bool> isPromoteChannelsToastVisible => DataStore.i.channels.isPromoteToastVisible;
 59
 460    public TaskbarHUDController(IChatController chatController, IFriendsController friendsController)
 61    {
 462        this.chatController = chatController;
 463        this.friendsController = friendsController;
 464    }
 65
 66    protected virtual TaskbarHUDView CreateView()
 67    {
 468        return TaskbarHUDView.Create();
 69    }
 70
 71    public void Initialize(IMouseCatcher mouseCatcher)
 72    {
 473        this.mouseCatcher = mouseCatcher;
 74
 475        view = CreateView();
 76
 477        if (mouseCatcher != null)
 78        {
 179            mouseCatcher.OnMouseLock -= MouseCatcher_OnMouseLock;
 180            mouseCatcher.OnMouseUnlock -= MouseCatcher_OnMouseUnlock;
 181            mouseCatcher.OnMouseLock += MouseCatcher_OnMouseLock;
 182            mouseCatcher.OnMouseUnlock += MouseCatcher_OnMouseUnlock;
 83        }
 84
 485        view.leftWindowContainerLayout.enabled = false;
 86
 487        view.OnChatToggle += HandleChatToggle;
 488        view.OnFriendsToggle += HandleFriendsToggle;
 489        view.OnEmotesToggle += HandleEmotesToggle;
 490        view.OnExperiencesToggle += HandleExperiencesToggle;
 491        view.OnVoiceChatToggle += HandleVoiceChatToggle;
 92
 493        toggleFriendsTrigger = Resources.Load<InputAction_Trigger>("ToggleFriends");
 494        toggleFriendsTrigger.OnTriggered -= ToggleFriendsTrigger_OnTriggered;
 495        toggleFriendsTrigger.OnTriggered += ToggleFriendsTrigger_OnTriggered;
 96
 497        closeWindowTrigger = Resources.Load<InputAction_Trigger>("CloseWindow");
 498        closeWindowTrigger.OnTriggered -= CloseWindowTrigger_OnTriggered;
 499        closeWindowTrigger.OnTriggered += CloseWindowTrigger_OnTriggered;
 100
 4101        toggleWorldChatTrigger = Resources.Load<InputAction_Trigger>("ToggleWorldChat");
 4102        toggleWorldChatTrigger.OnTriggered -= ToggleWorldChatTrigger_OnTriggered;
 4103        toggleWorldChatTrigger.OnTriggered += ToggleWorldChatTrigger_OnTriggered;
 104
 4105        isEmotesWheelInitialized.OnChange += InitializeEmotesSelector;
 4106        InitializeEmotesSelector(isEmotesWheelInitialized.Get(), false);
 4107        isEmotesVisible.OnChange += IsEmotesVisibleChanged;
 108
 4109        isExperiencesViewerOpen.OnChange += IsExperiencesViewerOpenChanged;
 110
 4111        view.leftWindowContainerAnimator.Show();
 112
 4113        CommonScriptableObjects.isTaskbarHUDInitialized.Set(true);
 4114        DataStore.i.builderInWorld.showTaskBar.OnChange += SetVisibility;
 115
 4116        isExperiencesViewerInitialized.OnChange += InitializeExperiencesViewer;
 4117        InitializeExperiencesViewer(isExperiencesViewerInitialized.Get(), null);
 118
 4119        notificationPanelTransform.OnChange += InitializeNotificationPanel;
 4120        InitializeNotificationPanel(notificationPanelTransform.Get(), null);
 121
 4122        topNotificationPanelTransform.OnChange += InitializeTopNotificationPanel;
 4123        InitializeTopNotificationPanel(topNotificationPanelTransform.Get(), null);
 124
 4125        numOfLoadedExperiences.OnChange += NumOfLoadedExperiencesChanged;
 4126        NumOfLoadedExperiencesChanged(numOfLoadedExperiences.Get(), 0);
 4127    }
 128
 129    private void HandleFriendsToggle(bool show)
 130    {
 3131        if (show)
 2132            OpenFriendsWindow();
 133        else
 134        {
 1135            friendsHud?.SetVisibility(false);
 1136            ToggleOffChatIcon();
 137        }
 138
 3139        OnAnyTaskbarButtonClicked?.Invoke();
 0140    }
 141
 142    private void HandleEmotesToggle(bool show)
 143    {
 0144        if (show && emoteJustTriggeredFromShortcut.Get())
 145        {
 0146            emoteJustTriggeredFromShortcut.Set(false);
 0147            return;
 148        }
 149
 0150        if (show)
 151        {
 0152            ToggleOffChatIcon();
 0153            ShowEmotes();
 154        }
 155        else
 156        {
 0157            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Emotes);
 0158            isEmotesVisible.Set(false);
 0159            ToggleOffChatIcon();
 160        }
 161
 0162        OnAnyTaskbarButtonClicked?.Invoke();
 0163    }
 164
 165    private void ShowEmotes()
 166    {
 0167        worldChatWindowHud.SetVisibility(false);
 0168        privateChatWindow.SetVisibility(false);
 0169        channelChatWindow.SetVisibility(false);
 0170        friendsHud?.SetVisibility(false);
 0171        searchChannelsHud.SetVisibility(false);
 0172        isExperiencesViewerOpen.Set(false);
 0173        voiceChatHud?.SetVisibility(false);
 0174        isEmotesVisible.Set(true);
 0175        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Emotes);
 0176    }
 177
 178    private void HandleExperiencesToggle(bool show)
 179    {
 0180        if (show)
 0181            ShowExperiences();
 182        else
 183        {
 0184            isExperiencesViewerOpen.Set(false);
 0185            ToggleOffChatIcon();
 186        }
 187
 0188        OnAnyTaskbarButtonClicked?.Invoke();
 0189    }
 190
 191    private void HandleVoiceChatToggle(bool show)
 192    {
 0193        if (show)
 0194            OpenVoiceChatWindow();
 195        else
 0196            voiceChatHud?.SetVisibility(false);
 0197        OnAnyTaskbarButtonClicked?.Invoke();
 0198    }
 199
 200    private void ShowExperiences()
 201    {
 0202        worldChatWindowHud.SetVisibility(false);
 0203        privateChatWindow.SetVisibility(false);
 0204        publicChatWindow.SetVisibility(false);
 0205        channelChatWindow.SetVisibility(false);
 0206        searchChannelsHud.SetVisibility(false);
 0207        friendsHud?.SetVisibility(false);
 0208        isEmotesVisible.Set(false);
 0209        voiceChatHud?.SetVisibility(false);
 0210        isExperiencesViewerOpen.Set(true);
 0211        isPromoteChannelsToastVisible.Set(false);
 0212    }
 213
 214    private void ToggleFriendsTrigger_OnTriggered(DCLAction_Trigger action)
 215    {
 0216        if (friendsHud == null) return;
 217
 0218        bool anyInputFieldIsSelected = EventSystem.current != null &&
 219                                       EventSystem.current.currentSelectedGameObject != null &&
 220                                       EventSystem.current.currentSelectedGameObject.GetComponent<TMP_InputField>() !=
 221                                       null;
 222
 0223        if (anyInputFieldIsSelected) return;
 224
 0225        mouseCatcher.UnlockCursor();
 226
 0227        if (!friendsHud.View.IsActive())
 228        {
 0229            view.leftWindowContainerAnimator.Show();
 0230            OpenFriendsWindow();
 231        }
 232        else
 233        {
 0234            CloseFriendsWindow();
 0235            ToggleOffChatIcon();
 236        }
 0237    }
 238
 239    private void ToggleWorldChatTrigger_OnTriggered(DCLAction_Trigger action)
 240    {
 0241        bool anyInputFieldIsSelected = EventSystem.current != null &&
 242                                       EventSystem.current.currentSelectedGameObject != null &&
 243                                       EventSystem.current.currentSelectedGameObject.GetComponent<TMP_InputField>() !=
 244                                       null;
 245
 0246        if (anyInputFieldIsSelected) return;
 247
 0248        mouseCatcher.UnlockCursor();
 0249        chatBackWindow = worldChatWindowHud;
 250
 0251        if (!worldChatWindowHud.View.IsActive
 252            && !privateChatWindow.View.IsActive
 253            && !publicChatWindow.View.IsActive)
 0254            OpenLastActiveChatWindow(chatInputTargetWindow);
 0255    }
 256
 257    private void CloseWindowTrigger_OnTriggered(DCLAction_Trigger action)
 258    {
 0259        if (mouseCatcher.isLocked) return;
 260
 0261        if (publicChatWindow.View.IsActive ||
 262            channelChatWindow.View.IsActive ||
 263            privateChatWindow.View.IsActive)
 264        {
 0265            publicChatWindow.SetVisibility(false);
 0266            worldChatWindowHud.SetVisibility(true);
 0267            chatToggleTargetWindow = worldChatWindowHud;
 0268            chatInputTargetWindow = publicChatWindow;
 269        }
 270        else
 271        {
 0272            worldChatWindowHud.SetVisibility(false);
 0273            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 274        }
 275
 0276        publicChatWindow.SetVisibility(false);
 0277        privateChatWindow.SetVisibility(false);
 0278        channelChatWindow.SetVisibility(false);
 0279        CloseFriendsWindow();
 0280        CloseVoiceChatWindow();
 0281        isEmotesVisible.Set(false);
 0282        isExperiencesViewerOpen.Set(false);
 0283    }
 284
 285    private void HandleChatToggle(bool show)
 286    {
 1287        if (show)
 288        {
 1289            chatBackWindow = worldChatWindowHud;
 1290            OpenWorldChatWindow();
 291        }
 292        else
 293        {
 0294            CloseAnyChatWindow();
 295        }
 296
 1297        OnAnyTaskbarButtonClicked?.Invoke();
 0298    }
 299
 300    private void MouseCatcher_OnMouseUnlock()
 301    {
 0302    }
 303
 304    private void MouseCatcher_OnMouseLock()
 305    {
 0306        CloseFriendsWindow();
 0307        CloseChatList();
 0308        CloseVoiceChatWindow();
 0309        isExperiencesViewerOpen.Set(false);
 310
 0311        if (!privateChatWindow.View.IsActive
 312            && !publicChatWindow.View.IsActive
 313            && !channelChatWindow.View.IsActive)
 0314            ToggleOffChatIcon();
 0315    }
 316
 317    public void AddWorldChatWindow(WorldChatWindowController controller)
 318    {
 2319        if (controller?.View == null)
 320        {
 0321            Debug.LogWarning("AddChatWindow >>> World Chat Window doesn't exist yet!");
 0322            return;
 323        }
 324
 2325        if (controller.View.Transform.parent == view.leftWindowContainer) return;
 326
 2327        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 2328        notificationViewerTransform?.SetAsLastSibling();
 2329        topNotificationViewerTransform?.SetAsFirstSibling();
 2330        experiencesViewerTransform?.SetAsLastSibling();
 331
 2332        worldChatWindowHud = controller;
 333
 2334        view.ShowChatButton();
 2335        worldChatWindowHud.OnCloseView += ToggleOffChatIcon;
 2336        worldChatWindowHud.OnOpenChannelCreation += OpenChannelCreation;
 2337        worldChatWindowHud.OnOpenChannelLeave += OpenChannelLeaveConfirmation;
 2338    }
 339
 1340    private void ToggleOffChatIcon() => view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 341
 342    private void OpenFriendsWindow()
 343    {
 2344        worldChatWindowHud.SetVisibility(false);
 2345        privateChatWindow.SetVisibility(false);
 2346        publicChatWindow.SetVisibility(false);
 2347        channelChatWindow?.SetVisibility(false);
 2348        searchChannelsHud.SetVisibility(false);
 2349        isExperiencesViewerOpen.Set(false);
 2350        isEmotesVisible.Set(false);
 2351        voiceChatHud?.SetVisibility(false);
 2352        friendsHud?.SetVisibility(true);
 2353        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Friends);
 2354        chatBackWindow = friendsHud;
 2355        isPromoteChannelsToastVisible.Set(false);
 2356    }
 357
 358    private void CloseFriendsWindow()
 359    {
 0360        friendsHud?.SetVisibility(false);
 0361        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Friends);
 0362    }
 363
 364    public void OpenPrivateChat(string userId)
 365    {
 0366        worldChatWindowHud.SetVisibility(false);
 0367        publicChatWindow.SetVisibility(false);
 0368        channelChatWindow.SetVisibility(false);
 0369        searchChannelsHud.SetVisibility(false);
 0370        friendsHud?.SetVisibility(false);
 0371        isExperiencesViewerOpen.Set(false);
 0372        isEmotesVisible.Set(false);
 0373        voiceChatHud?.SetVisibility(false);
 0374        openedChat.Set(userId);
 0375        privateChatWindow.Setup(userId);
 0376        privateChatWindow.SetVisibility(true);
 0377        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 0378        chatToggleTargetWindow = worldChatWindowHud;
 0379        chatInputTargetWindow = privateChatWindow;
 0380    }
 381
 382    private IHUD OpenLastActiveChatWindow(IHUD lastActiveWindow)
 383    {
 0384        worldChatWindowHud.SetVisibility(false);
 0385        privateChatWindow.SetVisibility(false);
 0386        publicChatWindow.SetVisibility(false);
 0387        channelChatWindow?.SetVisibility(false);
 0388        searchChannelsHud.SetVisibility(false);
 0389        friendsHud?.SetVisibility(false);
 0390        isEmotesVisible.Set(false);
 0391        isExperiencesViewerOpen.Set(false);
 0392        voiceChatHud?.SetVisibility(false);
 0393        isPromoteChannelsToastVisible.Set(false);
 394
 395        IHUD visibleWindow;
 396
 0397        if (lastActiveWindow == publicChatWindow)
 398        {
 0399            publicChatWindow.SetVisibility(true, true);
 0400            visibleWindow = publicChatWindow;
 401        }
 0402        else if (lastActiveWindow != null)
 403        {
 0404            lastActiveWindow.SetVisibility(true);
 0405            visibleWindow = lastActiveWindow;
 406        }
 407        else
 408        {
 0409            publicChatWindow.SetVisibility(true, true);
 0410            visibleWindow = publicChatWindow;
 411        }
 412
 0413        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 414
 0415        return visibleWindow;
 416    }
 417
 418    private void OpenWorldChatWindow()
 419    {
 1420        privateChatWindow.SetVisibility(false);
 1421        publicChatWindow.SetVisibility(false);
 1422        channelChatWindow?.SetVisibility(false);
 1423        searchChannelsHud.SetVisibility(false);
 1424        friendsHud?.SetVisibility(false);
 1425        isEmotesVisible.Set(false);
 1426        isExperiencesViewerOpen.Set(false);
 1427        voiceChatHud?.SetVisibility(false);
 1428        isPromoteChannelsToastVisible.Set(false);
 1429        worldChatWindowHud.SetVisibility(true);
 1430        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 1431    }
 432
 433    private void CloseAnyChatWindow()
 434    {
 0435        worldChatWindowHud.SetVisibility(false);
 0436        privateChatWindow.SetVisibility(false);
 0437        publicChatWindow.SetVisibility(false);
 0438        channelChatWindow.SetVisibility(false);
 0439        searchChannelsHud.SetVisibility(false);
 0440        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 0441    }
 442
 443    public void OpenChannelChat(string channelId)
 444    {
 0445        openedChat.Set(channelId);
 0446        channelChatWindow?.Setup(channelId);
 0447        channelChatWindow?.SetVisibility(true);
 0448        publicChatWindow?.SetVisibility(false);
 0449        worldChatWindowHud?.SetVisibility(false);
 0450        privateChatWindow?.SetVisibility(false);
 0451        searchChannelsHud.SetVisibility(false);
 0452        friendsHud?.SetVisibility(false);
 0453        isExperiencesViewerOpen?.Set(false);
 0454        isEmotesVisible?.Set(false);
 0455        voiceChatHud?.SetVisibility(false);
 456
 0457        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 458
 0459        chatToggleTargetWindow = worldChatWindowHud;
 0460        chatInputTargetWindow = channelChatWindow;
 0461    }
 462
 463
 464    public void OpenPublicChat(string channelId, bool focusInputField)
 465    {
 0466        openedChat.Set(channelId);
 0467        publicChatWindow?.Setup(channelId);
 0468        publicChatWindow?.SetVisibility(true, focusInputField);
 0469        channelChatWindow?.SetVisibility(false);
 0470        worldChatWindowHud?.SetVisibility(false);
 0471        privateChatWindow?.SetVisibility(false);
 0472        searchChannelsHud?.SetVisibility(false);
 0473        friendsHud?.SetVisibility(false);
 0474        isExperiencesViewerOpen?.Set(false);
 0475        isEmotesVisible?.Set(false);
 0476        voiceChatHud?.SetVisibility(false);
 477
 0478        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 479
 0480        chatToggleTargetWindow = worldChatWindowHud;
 0481        chatInputTargetWindow = publicChatWindow;
 0482    }
 483
 484    private void OpenChatList()
 485    {
 0486        privateChatWindow.SetVisibility(false);
 0487        publicChatWindow.SetVisibility(false);
 0488        channelChatWindow.SetVisibility(false);
 0489        searchChannelsHud.SetVisibility(false);
 0490        friendsHud?.SetVisibility(false);
 0491        isExperiencesViewerOpen.Set(false);
 0492        isEmotesVisible.Set(false);
 0493        voiceChatHud?.SetVisibility(false);
 0494        worldChatWindowHud.SetVisibility(true);
 0495        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 496
 0497        chatToggleTargetWindow = worldChatWindowHud;
 0498    }
 499
 500    private void CloseChatList()
 501    {
 0502        if (!worldChatWindowHud.View.IsActive) return;
 0503        worldChatWindowHud.SetVisibility(false);
 0504        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 0505    }
 506
 507    private void OpenVoiceChatWindow()
 508    {
 0509        worldChatWindowHud.SetVisibility(false);
 0510        privateChatWindow.SetVisibility(false);
 0511        publicChatWindow.SetVisibility(false);
 0512        channelChatWindow.SetVisibility(false);
 0513        searchChannelsHud.SetVisibility(false);
 0514        isExperiencesViewerOpen.Set(false);
 0515        isEmotesVisible.Set(false);
 0516        friendsHud?.SetVisibility(false);
 0517        voiceChatHud?.SetVisibility(true);
 0518        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.VoiceChat);
 0519        isPromoteChannelsToastVisible.Set(false);
 0520    }
 521
 522    private void CloseVoiceChatWindow()
 523    {
 0524        voiceChatHud?.SetVisibility(false);
 0525        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.VoiceChat);
 0526    }
 527
 528    public void AddPrivateChatWindow(PrivateChatWindowController controller)
 529    {
 1530        if (controller?.View == null)
 531        {
 0532            Debug.LogWarning("AddPrivateChatWindow >>> Private Chat Window doesn't exist yet!");
 0533            return;
 534        }
 535
 1536        if (controller.View.Transform.parent == view.leftWindowContainer)
 0537            return;
 538
 1539        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 1540        notificationViewerTransform?.SetAsLastSibling();
 1541        topNotificationViewerTransform?.SetAsFirstSibling();
 1542        experiencesViewerTransform?.SetAsLastSibling();
 543
 1544        privateChatWindow = controller;
 545
 1546        controller.OnClosed += ToggleOffChatIcon;
 1547    }
 548
 549    public void AddPublicChatChannel(PublicChatWindowController controller)
 550    {
 1551        if (controller?.View == null)
 552        {
 0553            Debug.LogWarning("AddPublicChatChannel >>> Public Chat Window doesn't exist yet!");
 0554            return;
 555        }
 556
 1557        if (controller.View.Transform.parent == view.leftWindowContainer) return;
 558
 1559        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 1560        notificationViewerTransform?.SetAsLastSibling();
 1561        topNotificationViewerTransform?.SetAsFirstSibling();
 1562        experiencesViewerTransform?.SetAsLastSibling();
 563
 1564        publicChatWindow = controller;
 565
 1566        controller.OnClosed += ToggleOffChatIcon;
 1567    }
 568
 569    private void HandlePublicChannelPreviewModeChanged(bool isPreviewMode)
 570    {
 0571        if (!publicChatWindow.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 HandleChannelPreviewModeChanged(bool isPreviewMode)
 579    {
 0580        if (!channelChatWindow.View.IsActive) return;
 0581        if (isPreviewMode)
 0582            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 583        else
 0584            view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 0585    }
 586
 587    private void HandlePrivateChannelPreviewMode(bool isPreviewMode)
 588    {
 0589        if (!privateChatWindow.View.IsActive) return;
 0590        if (isPreviewMode)
 0591            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Chat);
 592        else
 0593            view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 0594    }
 595
 596    public void AddFriendsWindow(FriendsHUDController controller)
 597    {
 3598        if (controller?.View == null)
 599        {
 0600            Debug.LogWarning("AddFriendsWindow >>> Friends window doesn't exist yet!");
 0601            return;
 602        }
 603
 3604        if (controller.View.Transform.parent == view.leftWindowContainer)
 0605            return;
 606
 3607        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 3608        notificationViewerTransform?.SetAsLastSibling();
 3609        topNotificationViewerTransform?.SetAsFirstSibling();
 3610        experiencesViewerTransform?.SetAsLastSibling();
 611
 3612        friendsHud = controller;
 3613        view.ShowFriendsButton();
 3614        friendsHud.OnViewClosed += () =>
 615        {
 0616            view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Friends);
 0617            ToggleOffChatIcon();
 0618        };
 3619    }
 620
 621    public void AddVoiceChatWindow(VoiceChatWindowController controller)
 622    {
 1623        if (controller?.VoiceChatWindowView == null)
 624        {
 1625            Debug.LogWarning("AddVoiceChatWindow >>> Voice Chat window doesn't exist yet!");
 1626            return;
 627        }
 628
 0629        if (controller.VoiceChatWindowView.Transform.parent == view.leftWindowContainer)
 0630            return;
 631
 0632        controller.VoiceChatWindowView.Transform.SetParent(view.leftWindowContainer, false);
 633
 0634        voiceChatHud = controller;
 0635        view.ShowVoiceChatButton();
 0636        voiceChatHud.OnCloseView += () => view.ToggleOff(TaskbarHUDView.TaskbarButtonType.VoiceChat);
 637
 0638        if (controller?.VoiceChatBarView != null)
 639        {
 0640            controller.VoiceChatBarView.Transform.SetParent(view.altSectionContainer, false);
 0641            controller.VoiceChatBarView.Transform.SetAsFirstSibling();
 642        }
 0643    }
 644
 645    private void InitializeEmotesSelector(bool current, bool previous)
 646    {
 8647        if (!current) return;
 0648        view.ShowEmotesButton();
 0649    }
 650
 0651    private void IsEmotesVisibleChanged(bool current, bool previous) => HandleEmotesToggle(current);
 652
 653    private void InitializeExperiencesViewer(Transform currentViewTransform, Transform previousViewTransform)
 654    {
 4655        if (currentViewTransform == null)
 4656            return;
 657
 0658        experiencesViewerTransform = currentViewTransform;
 0659        experiencesViewerTransform.SetParent(view.leftWindowContainer, false);
 0660        experiencesViewerTransform.SetAsLastSibling();
 661
 0662        view.ShowExperiencesButton();
 0663    }
 664
 665    private void InitializeNotificationPanel(Transform currentPanelTransform, Transform previousPanelTransform)
 666    {
 4667        if (currentPanelTransform == null)
 4668            return;
 669
 0670        notificationViewerTransform = currentPanelTransform;
 0671        notificationViewerTransform.SetParent(view.leftWindowContainer, false);
 0672        notificationViewerTransform.SetAsLastSibling();
 0673        experiencesViewerTransform.SetAsLastSibling();
 0674        notificationViewerTransform.GetComponent<MainChatNotificationsComponentView>().OnClickedNotification += OpenClic
 0675    }
 676
 677    private void InitializeTopNotificationPanel(Transform currentPanelTransform, Transform previousPanelTransform)
 678    {
 4679        if (currentPanelTransform == null)
 4680            return;
 681
 0682        topNotificationViewerTransform = currentPanelTransform;
 0683        topNotificationViewerTransform.SetParent(view.leftWindowContainer, false);
 0684        topNotificationViewerTransform.SetAsFirstSibling();
 0685        topNotificationViewerTransform.GetComponent<TopNotificationComponentView>().OnClickedNotification += OpenClicked
 0686    }
 687
 688    private void OpenClickedChat(string chatId)
 689    {
 690        const string nearbyChannelId = "nearby";
 691        const string conversationListId = "conversationList";
 692
 0693        if (chatId == nearbyChannelId)
 0694            OpenPublicChat(nearbyChannelId, true);
 0695        else if (chatController.GetAllocatedChannel(chatId) != null)
 696        {
 0697            if(chatController.GetAllocatedChannel(chatId).Joined)
 0698                OpenChannelChat(chatId);
 699            else
 0700                return;
 701        }
 0702        else if(chatId == conversationListId)
 0703            OpenChatList();
 704        else
 705        {
 0706            if(friendsController.GetUserStatus(chatId).friendshipStatus == FriendshipStatus.FRIEND)
 0707                OpenPrivateChat(chatId);
 708        }
 0709    }
 710
 711    private void IsExperiencesViewerOpenChanged(bool current, bool previous)
 712    {
 0713        if (current)
 0714            return;
 715
 0716        view.ToggleOff(TaskbarHUDView.TaskbarButtonType.Experiences);
 0717        ToggleOffChatIcon();
 0718    }
 719
 720    private void NumOfLoadedExperiencesChanged(int current, int previous)
 721    {
 4722        view.SetExperiencesVisibility(current > 0);
 723
 4724        if (current == 0)
 4725            isExperiencesViewerOpen.Set(false);
 4726    }
 727
 728    public void DisableFriendsWindow()
 729    {
 0730        view.friendsButton.transform.parent.gameObject.SetActive(false);
 0731    }
 732
 733    public void Dispose()
 734    {
 4735        if (view != null)
 736        {
 4737            view.OnChatToggle -= HandleChatToggle;
 4738            view.OnFriendsToggle -= HandleFriendsToggle;
 4739            view.OnEmotesToggle -= HandleEmotesToggle;
 4740            view.OnExperiencesToggle -= HandleExperiencesToggle;
 4741            view.OnVoiceChatToggle -= HandleVoiceChatToggle;
 742
 4743            view.Destroy();
 744        }
 745
 4746        if (mouseCatcher != null)
 747        {
 1748            mouseCatcher.OnMouseLock -= MouseCatcher_OnMouseLock;
 1749            mouseCatcher.OnMouseUnlock -= MouseCatcher_OnMouseUnlock;
 750        }
 751
 4752        if (toggleFriendsTrigger != null)
 4753            toggleFriendsTrigger.OnTriggered -= ToggleFriendsTrigger_OnTriggered;
 754
 4755        if (closeWindowTrigger != null)
 4756            closeWindowTrigger.OnTriggered -= CloseWindowTrigger_OnTriggered;
 757
 4758        if (toggleWorldChatTrigger != null)
 4759            toggleWorldChatTrigger.OnTriggered -= ToggleWorldChatTrigger_OnTriggered;
 760
 4761        DataStore.i.builderInWorld.showTaskBar.OnChange -= SetVisibility;
 4762        isEmotesWheelInitialized.OnChange -= InitializeEmotesSelector;
 4763        isEmotesVisible.OnChange -= IsEmotesVisibleChanged;
 4764        isExperiencesViewerOpen.OnChange -= IsExperiencesViewerOpenChanged;
 4765        isExperiencesViewerInitialized.OnChange -= InitializeExperiencesViewer;
 4766        numOfLoadedExperiences.OnChange -= NumOfLoadedExperiencesChanged;
 4767    }
 768
 769    private void SetVisibility(bool visible, bool previus)
 770    {
 0771        SetVisibility(visible);
 0772    }
 773
 774    public void SetVisibility(bool visible)
 775    {
 1776        view.SetVisibility(visible);
 1777    }
 778
 779    public void GoBackFromChat()
 780    {
 0781        if (chatBackWindow == friendsHud)
 0782            OpenFriendsWindow();
 783        else
 0784            OpenChatList();
 0785    }
 786
 787    public void AddChatChannel(ChatChannelHUDController controller)
 788    {
 0789        if (controller?.View == null)
 790        {
 0791            Debug.LogWarning("AddChatChannel >>> Chat Window doesn't exist yet!");
 0792            return;
 793        }
 794
 0795        if (controller.View.Transform.parent == view.leftWindowContainer) return;
 796
 0797        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 0798        experiencesViewerTransform?.SetAsLastSibling();
 799
 0800        channelChatWindow = controller;
 801
 0802        controller.OnClosed += ToggleOffChatIcon;
 0803        controller.OnOpenChannelLeave += OpenChannelLeaveConfirmation;
 0804    }
 805
 806    public void AddChannelSearch(SearchChannelsWindowController controller)
 807    {
 1808        if (controller.View.Transform.parent == view.leftWindowContainer) return;
 809
 1810        controller.View.Transform.SetParent(view.leftWindowContainer, false);
 1811        experiencesViewerTransform?.SetAsLastSibling();
 812
 1813        searchChannelsHud = controller;
 814
 1815        controller.OnClosed += () =>
 816        {
 0817            controller.SetVisibility(false);
 0818            ToggleOffChatIcon();
 0819        };
 1820        controller.OnBack += GoBackFromChat;
 1821        controller.OnOpenChannelCreation += OpenChannelCreation;
 1822        controller.OnOpenChannelLeave += OpenChannelLeaveConfirmation;
 1823    }
 824
 825    public void AddChannelCreation(CreateChannelWindowController controller)
 826    {
 0827        if (controller.View.Transform.parent == view.fullScreenWindowContainer) return;
 828
 0829        controller.View.Transform.SetParent(view.fullScreenWindowContainer, false);
 0830        experiencesViewerTransform?.SetAsLastSibling();
 831
 0832        channelCreationWindow = controller;
 833
 0834        controller.OnNavigateToChannelWindow += channelId =>
 835        {
 0836            OpenChannelChat(channelId);
 0837            channelCreationWindow.SetVisibility(false);
 0838        };
 0839    }
 840
 841    private void OpenChannelCreation()
 842    {
 0843        channelCreationWindow.SetVisibility(true);
 0844    }
 845
 846    public void AddChannelLeaveConfirmation(LeaveChannelConfirmationWindowController controller)
 847    {
 0848        if (controller.View.Transform.parent == view.fullScreenWindowContainer) return;
 849
 0850        controller.View.Transform.SetParent(view.fullScreenWindowContainer, false);
 0851        channelLeaveWindow = controller;
 0852    }
 853
 854    private void OpenChannelLeaveConfirmation(string channelId)
 855    {
 0856        channelLeaveWindow.SetChannelToLeave(channelId);
 0857        channelLeaveWindow.SetVisibility(true);
 0858    }
 859
 860    public void OpenChannelSearch()
 861    {
 0862        privateChatWindow.SetVisibility(false);
 0863        publicChatWindow.SetVisibility(false);
 0864        channelChatWindow.SetVisibility(false);
 0865        searchChannelsHud.SetVisibility(true);
 0866        friendsHud?.SetVisibility(false);
 0867        isExperiencesViewerOpen.Set(false);
 0868        isEmotesVisible.Set(false);
 0869        voiceChatHud?.SetVisibility(false);
 0870        worldChatWindowHud.SetVisibility(false);
 0871        view.ToggleOn(TaskbarHUDView.TaskbarButtonType.Chat);
 0872    }
 873}

Methods/Properties

socialTooltipReference()
isEmotesWheelInitialized()
isEmotesVisible()
emoteJustTriggeredFromShortcut()
isExperiencesViewerInitialized()
notificationPanelTransform()
topNotificationPanelTransform()
isExperiencesViewerOpen()
numOfLoadedExperiences()
openedChat()
isPromoteChannelsToastVisible()
TaskbarHUDController(IChatController, DCl.Social.Friends.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)
ToggleOffChatIcon()
OpenFriendsWindow()
CloseFriendsWindow()
OpenPrivateChat(System.String)
OpenLastActiveChatWindow(IHUD)
OpenWorldChatWindow()
CloseAnyChatWindow()
OpenChannelChat(System.String)
OpenPublicChat(System.String, System.Boolean)
OpenChatList()
CloseChatList()
OpenVoiceChatWindow()
CloseVoiceChatWindow()
AddPrivateChatWindow(PrivateChatWindowController)
AddPublicChatChannel(DCL.Chat.HUD.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()