Beispiel #1
0
        public static void SortAllPlayers() // This only runs when sort type is changed and when the qm is opened (takes around 1-2ms in a full BClub)
        {
            if (EntryManager.playerLeftPairsEntries.Count == 0)
            {
                return;
            }

            if (IsSortTypeInAllUses(SortType.None))
            {
                return;
            }

            List <PlayerEntry> playerEntries = EntryManager.playerLeftPairsEntries.Select(pairEntry => pairEntry.playerEntry).ToList();

            int num = 0;

            if (PlayerListConfig.showSelfAtTop.Value)
            {
                PlayerLeftPairEntry.SwapPlayerEntries(EntryManager.playerLeftPairsEntries[0], EntryManager.localPlayerEntry.playerLeftPairEntry);
                playerEntries.Remove(EntryManager.localPlayerEntry);
                num = 1;
            }

            playerEntries.Sort(sort);
            for (int i = 0; i < playerEntries.Count; i++)
            {
                EntryManager.playerLeftPairsEntries[i + num].playerEntry = playerEntries[i];
            }
        }
Beispiel #2
0
        public static void SortPlayer(PlayerLeftPairEntry sortEntry)
        {
            if (IsSortTypeInAllUses(SortType.None) ||
                (PlayerListConfig.showSelfAtTop.Value && sortEntry.playerEntry.isSelf) ||
                (PlayerListConfig.freezeSortWhenVisible.Value && MenuManager.playerList.active))
            {
                return;
            }

            // This method is good like 0.2ms
            int oldIndex = EntryManager.playerLeftPairsEntries.IndexOf(sortEntry);

            if (oldIndex < 0)
            {
                return;
            }

            int forwardSort  = oldIndex < EntryManager.playerLeftPairsEntries.Count - 1 ? sort(sortEntry.playerEntry, EntryManager.playerLeftPairsEntries[oldIndex + 1].playerEntry) : 0;
            int backwardSort = oldIndex > sortStartIndex?sort(EntryManager.playerLeftPairsEntries[oldIndex - 1].playerEntry, sortEntry.playerEntry) : 0;

            int sortResult;

            if (backwardSort == 1)
            {
                PlayerLeftPairEntry.SwapPlayerEntries(sortEntry, EntryManager.playerLeftPairsEntries[oldIndex - 1]);

                for (int i = oldIndex - 1; i > sortStartIndex; i--)
                {
                    sortResult = sort(EntryManager.playerLeftPairsEntries[i - 1].playerEntry, EntryManager.playerLeftPairsEntries[i].playerEntry);
                    if (sortResult == 1)
                    {
                        PlayerLeftPairEntry.SwapPlayerEntries(EntryManager.playerLeftPairsEntries[i], EntryManager.playerLeftPairsEntries[i - 1]);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else if (forwardSort == 1)
            {
                PlayerLeftPairEntry.SwapPlayerEntries(sortEntry, EntryManager.playerLeftPairsEntries[oldIndex + 1]);

                for (int i = oldIndex + 1; i < EntryManager.playerLeftPairsEntries.Count - 1; i++)
                {
                    sortResult = sort(EntryManager.playerLeftPairsEntries[i].playerEntry, EntryManager.playerLeftPairsEntries[i + 1].playerEntry);
                    if (sortResult == 1)
                    {
                        PlayerLeftPairEntry.SwapPlayerEntries(EntryManager.playerLeftPairsEntries[i], EntryManager.playerLeftPairsEntries[i + 1]);
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
Beispiel #3
0
        public static void AddPlayerLeftPairEntry(PlayerLeftPairEntry entry)
        {
            playerLeftPairsEntries.Add(entry);
            if (!entry.playerEntry.isSelf)
            {
                playerEntries.Add(entry.playerEntry);
            }
            AddEntry(entry);
            AddEntry(entry.leftSidePlayerEntry);
            AddEntry(entry.playerEntry);

            entry.playerEntry.gameObject.SetActive(true);
            EntrySortManager.SortPlayer(entry);

            RefreshLeftPlayerEntries(0, 0, true);
        }
Beispiel #4
0
        private static void OnStaticConfigChange()
        {
            switch (PlayerListConfig.currentBaseSort.Value)
            {
            case SortType.None:
                currentBaseComparison = null;
                break;

            case SortType.Alphabetical:
                currentBaseComparison = alphabeticalSort;
                break;

            case SortType.AvatarPerf:
                currentBaseComparison = avatarPerfSort;
                break;

            case SortType.Distance:
                if (VRCUtils.AreRiskyFunctionsAllowed)
                {
                    currentBaseComparison = distanceSort;
                }
                else
                {
                    currentBaseComparison = null;
                }
                break;

            case SortType.Friends:
                currentBaseComparison = friendsSort;
                break;

            case SortType.NameColor:
                currentBaseComparison = nameColorSort;
                break;

            case SortType.Ping:
                currentBaseComparison = pingSort;
                break;

            default:
                currentBaseComparison = defaultSort;
                break;
            }

            switch (PlayerListConfig.currentUpperSort.Value)
            {
            case SortType.None:
                currentUpperComparison = null;
                break;

            case SortType.Alphabetical:
                currentUpperComparison = alphabeticalSort;
                break;

            case SortType.AvatarPerf:
                currentUpperComparison = avatarPerfSort;
                break;

            case SortType.Distance:
                if (VRCUtils.AreRiskyFunctionsAllowed)
                {
                    currentUpperComparison = distanceSort;
                }
                else
                {
                    currentUpperComparison = null;
                }
                break;

            case SortType.Friends:
                currentUpperComparison = friendsSort;
                break;

            case SortType.NameColor:
                currentUpperComparison = nameColorSort;
                break;

            case SortType.Ping:
                currentUpperComparison = pingSort;
                break;

            default:
                currentUpperComparison = defaultSort;
                break;
            }

            switch (PlayerListConfig.currentHighestSort.Value)
            {
            case SortType.None:
                currentHighestComparison = null;
                break;

            case SortType.Alphabetical:
                currentHighestComparison = alphabeticalSort;
                break;

            case SortType.AvatarPerf:
                currentHighestComparison = avatarPerfSort;
                break;

            case SortType.Distance:
                if (VRCUtils.AreRiskyFunctionsAllowed)
                {
                    currentHighestComparison = distanceSort;
                }
                else
                {
                    currentHighestComparison = null;
                }
                break;

            case SortType.Friends:
                currentHighestComparison = friendsSort;
                break;

            case SortType.NameColor:
                currentHighestComparison = nameColorSort;
                break;

            case SortType.Ping:
                currentHighestComparison = pingSort;
                break;

            default:
                currentHighestComparison = defaultSort;
                break;
            }

            if (PlayerListConfig.reverseBaseSort.Value)
            {
                reverseBase = -1;
            }
            else
            {
                reverseBase = 1;
            }

            if (PlayerListConfig.reverseUpperSort.Value)
            {
                reverseUpper = -1;
            }
            else
            {
                reverseUpper = 1;
            }

            if (PlayerListConfig.reverseHighestSort.Value)
            {
                reverseHighest = -1;
            }
            else
            {
                reverseHighest = 1;
            }

            if (PlayerListConfig.showSelfAtTop.Value)
            {
                if (EntryManager.playerLeftPairsEntries.Count != 0)
                {
                    PlayerLeftPairEntry.SwapPlayerEntries(EntryManager.playerLeftPairsEntries[0], EntryManager.localPlayerEntry.playerLeftPairEntry);
                }

                sortStartIndex = 1;
            }
            else
            {
                sortStartIndex = 0;
            }

            SortAllPlayers();
        }