internal void Toggle(FriendEntryBase entry)
    {
        RectTransform rectTransform = transform as RectTransform;

        if (entry.transform.parent != null)
        {
            //NOTE(Pravus): By setting the pivot accordingly BEFORE we position the menu, we can have it always
            //              visible in an easier way.
            if (entry.transform.parent.InverseTransformPoint(entry.menuPositionReference.position).y < 0f)
            {
                rectTransform.pivot = new Vector2(0.5f, 0f);
            }
            else
            {
                rectTransform.pivot = new Vector2(0.5f, 1f);
            }
        }

        transform.position = entry.menuPositionReference.position;

        gameObject.SetActive(targetEntry == entry ? !gameObject.activeSelf : true);

        this.targetEntry = entry;

        if (gameObject.activeSelf)
        {
            blockButtonText.text = entry.model.blocked ? BLOCK_BTN_UNBLOCK_TEXT : BLOCK_BTN_BLOCK_TEXT;
        }
    }
    private void OnUpdateUserStatus(string userId, FriendsController.UserStatus newStatus)
    {
        var model = new FriendEntry.Model();

        FriendEntryBase entry = view.friendsList.GetEntry(userId) ?? view.friendRequestsList.GetEntry(userId);

        if (entry != null)
        {
            model = entry.model;
        }

        model.status = newStatus.presence;
        model.coords = newStatus.position;

        if (newStatus.realm != null)
        {
            model.realm           = $"{newStatus.realm.serverName.ToUpperFirst()} {newStatus.realm.layer.ToUpperFirst()}";
            model.realmServerName = newStatus.realm.serverName;
            model.realmLayerName  = newStatus.realm.layer;
        }
        else
        {
            model.realm           = string.Empty;
            model.realmServerName = string.Empty;
            model.realmLayerName  = string.Empty;
        }

        view.friendsList.UpdateEntry(userId, model);
        view.friendRequestsList.UpdateEntry(userId, model);
    }
Example #3
0
 private void Entry_OnDelete(FriendEntryBase entry)
 {
     WebInterface.UpdateFriendshipStatus(
         new FriendsController.FriendshipUpdateStatusMessage()
     {
         action = FriendshipAction.DELETED,
         userId = entry.userId
     });
 }
Example #4
0
    protected virtual void OnPressBlockButton(string userId, bool blockUser)
    {
        FriendEntryBase friendEntryToBlock = GetEntry(userId);

        if (friendEntryToBlock != null)
        {
            friendEntryToBlock.model.blocked = blockUser;
            friendEntryToBlock.Populate(friendEntryToBlock.model);
        }
    }
Example #5
0
 private void Entry_OnBlock(FriendEntryBase entry)
 {
     if (entry.model.blocked)
     {
         WebInterface.SendBlockPlayer(entry.userId);
     }
     else
     {
         WebInterface.SendUnblockPlayer(entry.userId);
     }
 }
Example #6
0
    protected override void OnPressDeleteButton(FriendEntryBase entry)
    {
        if (entry == null)
        {
            return;
        }

        confirmationDialog.SetText($"Are you sure you want to delete {entry.model.userName} as a friend?");
        confirmationDialog.Show(() =>
        {
            RemoveEntry(entry.userId);
            OnDeleteConfirmation?.Invoke(entry as FriendEntry);
        });
    }
Example #7
0
        public void Add(string userId, FriendEntryBase entry)
        {
            if (entries.ContainsKey(userId))
            {
                return;
            }

            entries.Add(userId, entry);

            entry.transform.SetParent(container, false);
            entry.transform.localScale = Vector3.one;

            UpdateToggle();
            ReorderingFriendEntries();
        }
Example #8
0
    protected override void OnPressDeleteButton(string userId)
    {
        if (string.IsNullOrEmpty(userId))
        {
            return;
        }

        FriendEntryBase friendEntryToDelete = GetEntry(userId);

        if (friendEntryToDelete != null)
        {
            confirmationDialog.SetText($"Are you sure you want to delete {friendEntryToDelete.model.userName} as a friend?");
            confirmationDialog.Show(() =>
            {
                RemoveEntry(userId);
                OnDeleteConfirmation?.Invoke(userId);
            });
        }
    }
Example #9
0
    private void ChatController_OnAddMessage(ChatMessage message)
    {
        if (message.messageType != ChatMessage.Type.PRIVATE)
        {
            return;
        }

        FriendEntryBase friend = GetEntry(message.sender != UserProfile.GetOwnUserProfile().userId
            ? message.sender
            : message.recipient);

        if (friend == null)
        {
            return;
        }

        bool reorderFriendEntries = false;

        if (friend.userId != lastProcessedFriend)
        {
            lastProcessedFriend  = friend.userId;
            reorderFriendEntries = true;
        }

        LastFriendTimestampModel timestampToUpdate = new LastFriendTimestampModel
        {
            userId = friend.userId,
            lastMessageTimestamp = message.timestamp
        };

        // Each time a private message is received (or sent by the player), we sort the online and offline lists by timestamp
        if (friend.model.status == PresenceStatus.ONLINE)
        {
            onlineFriendsList.AddOrUpdateLastTimestamp(timestampToUpdate, reorderFriendEntries);
        }
        else
        {
            offlineFriendsList.AddOrUpdateLastTimestamp(timestampToUpdate, reorderFriendEntries);
        }

        lastProcessedFriend = friend.userId;
    }
    private void OnUpdateFriendship(string userId, FriendshipAction friendshipAction)
    {
        var userProfile = UserProfileController.userProfilesCatalog.Get(userId);

        if (userProfile == null)
        {
            Debug.LogError($"UserProfile is null for {userId}! ... friendshipAction {friendshipAction}");
            return;
        }

        var friendEntryModel = new FriendEntry.Model();

        FriendEntryBase entry = view.friendsList.GetEntry(userId) ?? view.friendRequestsList.GetEntry(userId);

        if (entry != null)
        {
            friendEntryModel = entry.model;
        }

        friendEntryModel.userName    = userProfile.userName;
        friendEntryModel.avatarImage = userProfile.faceSnapshot;

        userProfile.OnFaceSnapshotReadyEvent -= friendEntryModel.OnSpriteUpdate;
        userProfile.OnFaceSnapshotReadyEvent += friendEntryModel.OnSpriteUpdate;

        if (ownUserProfile != null && ownUserProfile.blocked != null)
        {
            friendEntryModel.blocked = ownUserProfile.blocked.Contains(userId);
        }

        switch (friendshipAction)
        {
        case FriendshipAction.NONE:
            userProfile.OnFaceSnapshotReadyEvent -= friendEntryModel.OnSpriteUpdate;
            view.friendRequestsList.RemoveEntry(userId);
            view.friendsList.RemoveEntry(userId);
            break;

        case FriendshipAction.APPROVED:
            view.friendRequestsList.RemoveEntry(userId);
            view.friendsList.CreateOrUpdateEntryDeferred(userId, friendEntryModel);
            break;

        case FriendshipAction.REJECTED:
            userProfile.OnFaceSnapshotReadyEvent -= friendEntryModel.OnSpriteUpdate;
            view.friendRequestsList.RemoveEntry(userId);
            break;

        case FriendshipAction.CANCELLED:
            userProfile.OnFaceSnapshotReadyEvent -= friendEntryModel.OnSpriteUpdate;
            view.friendRequestsList.RemoveEntry(userId);
            break;

        case FriendshipAction.REQUESTED_FROM:
            view.friendRequestsList.CreateOrUpdateEntry(userId, friendEntryModel, true);
            break;

        case FriendshipAction.REQUESTED_TO:
            view.friendRequestsList.CreateOrUpdateEntry(userId, friendEntryModel, false);
            break;

        case FriendshipAction.DELETED:
            userProfile.OnFaceSnapshotReadyEvent -= friendEntryModel.OnSpriteUpdate;
            view.friendRequestsList.RemoveEntry(userId);
            view.friendsList.RemoveEntry(userId);
            break;
        }

        UpdateNotificationsCounter();
    }
Example #11
0
    private void Entry_OnPassport(FriendEntryBase entry)
    {
        var currentPlayerId = Resources.Load <StringVariable>(CURRENT_PLAYER_ID);

        currentPlayerId.Set(entry.userId);
    }
Example #12
0
 private void Entry_OnReport(FriendEntryBase entry)
 {
     WebInterface.SendReportPlayer(entry.userId);
 }
Example #13
0
 protected virtual void OnPressBlockButton(FriendEntryBase entry)
 {
     entry.model.blocked = !entry.model.blocked;
     entry.Populate(entry.model);
 }
Example #14
0
 protected virtual void OnPressDeleteButton(FriendEntryBase obj)
 {
 }
Example #15
0
 protected virtual void OnPressPassportButton(FriendEntryBase obj)
 {
 }