public static void ClientReportChatEntry(ChatEntry chatEntry)
        {
            var name = chatEntry.From;

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            DialogWindow.ShowDialog(
                title: DialogReport_Title,
                text: DialogReport_AreYouSure
                + "[br]"
                + "[br]"
                + $"\"{name}: {chatEntry.Message}\""
                + "[br]"
                + "[br]"
                + (Api.Client.CurrentGame.IsConnectedToOfficialServer
                             ? DialogReport_OfficialServersDisclaimer
                             : DialogReport_CommunityServerDisclaimer),
                okText: CoreStrings.Chat_MessageMenu_Report,
                okAction: () =>
            {
                // auto-block the offender
                ClientChatBlockList.SetBlockStatus(name,
                                                   block: true,
                                                   askConfirmation: false);

                Instance.CallServer(_ => _.ServerRemote_ReportChatEntry(chatEntry));
            },
                cancelText: CoreStrings.Button_Cancel,
                cancelAction: () => { },
                focusOnCancelButton: true);
        }
Example #2
0
            public override void ClientInitialize()
            {
                ClientChatBlockList.Initialize();
                OnlinePlayersSystem.ClientPlayerAddedOrRemoved  += ClientPlayerJoinedOrLeftHandler;
                Client.Characters.CurrentPlayerCharacterChanged += Refresh;

                Refresh();
Example #3
0
            public override void ClientInitialize()
            {
                ClientChatBlockList.Initialize();
                OnlinePlayersSystem.ClientOnPlayerAddedOrRemoved += ClientPlayerJoinedOrLeftHandler;
                Client.Characters.CurrentPlayerCharacterChanged  += Refresh;

                Refresh();

                void Refresh()
                {
                    sharedLocalChatRoomHolder  = null;
                    sharedGlobalChatRoomHolder = null;

                    if (Api.Client.Characters.CurrentPlayerCharacter != null)
                    {
                        Instance.CallServer(_ => _.ServerRemote_RequestChatRooms());
                    }
                }
            }
        private static void InvitationsCollectionChangedHandler(object sender, NotifyCollectionChangedEventArgs e)
        {
            string inviterName;

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
            {
                inviterName = (string)e.NewItems[0];
                ShowNotification(inviterName);
                break;
            }

            case NotifyCollectionChangedAction.Remove:
            {
                inviterName = (string)e.OldItems[0];
                if (NotificationsFromInviteeDictionary.TryGetValue(inviterName, out var weakReference) &&
                    weakReference.TryGetTarget(out var control))
                {
                    control.Hide(quick: true);
                }

                NotificationsFromInviteeDictionary.Remove(inviterName);
                break;
            }

            case NotifyCollectionChangedAction.Reset:
            {
                // hide all current notifications
                foreach (var notificationControl in NotificationsFromInviteeDictionary)
                {
                    var weakReference = notificationControl.Value;
                    if (weakReference.TryGetTarget(out var control))
                    {
                        control.Hide(quick: true);
                    }
                }

                NotificationsFromInviteeDictionary.Clear();

                // display new notifications
                foreach (var name in PartySystem.ClientCurrentInvitationsFromCharacters)
                {
                    ShowNotification(name);
                }

                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }

            void ShowNotification(string name)
            {
                if (ClientChatBlockList.IsBlocked(name))
                {
                    // don't display invitations from blocked players
                    return;
                }

                var control = NotificationSystem.ClientShowNotification(
                    title: PartyInvitationTitle,
                    message: string.Format(InvitationMessageFormat, name),
                    onClick: () => ShowInvitationDialog(name),
                    autoHide: false,
                    icon: IconPartyInvitation);

                control.CallbackOnRightClickHide = () => PartySystem.ClientInvitationDecline(name);

                NotificationsFromInviteeDictionary.Add(
                    name,
                    new WeakReference <HudNotificationControl>(control));
            }
        }
Example #5
0
 public override void ClientInitialize()
 {
     ClientChatBlockList.Initialize();
     OnlinePlayersSystem.ClientPlayerAddedOrRemoved += ClientPlayerJoinedOrLeftHandler;
 }
Example #6
0
            public override void ClientInitialize()
            {
                ClientChatBlockList.Initialize();
                Client.Characters.CurrentPlayerCharacterChanged += Refresh;

                Refresh();