Пример #1
0
        public static void RefreshData(LevelSO song = null)
        {
            try
            {
                if (queuedSong == null)
                {
                    if (song == null)
                    {
                        song = SongListUtils.GetInstalledSong();
                    }
                    Logger.Debug($"Refresh Waiting Menu data - Song is {(song != null ? "not" : "")} loaded");
                    if (song != null)
                    {
                        level.text = $"Queued: { song.songName} by { song.songAuthorName }";
                        if (song is CustomLevel)
                        {
                            SongLoader.Instance.LoadAudioClipForLevel((CustomLevel)song, (customLevel) =>
                            {
                                Logger.Debug($"Loaded audio Clip for {song.songName}");
                                ReadyUp(customLevel);
                            });
                        }
                        else
                        {
                            ReadyUp(song);
                        }
                    }
                    else if (!downloading)
                    {
                        level.text = $"Downloading: { SteamAPI.GetSongName()}";

                        Logger.Debug($"We do not have the song in our library, lets start downloading it.");
                        downloading = true;
                        Instance.StartCoroutine(Utils.SongDownloader.Instance.DownloadSong(SteamAPI.GetSongId(), LevelDownloadProgress, LevelDownloaded));
                    }
                }
                if (Instance && Instance.isActiveAndEnabled)
                {
                    Dictionary <string, float> status = Controllers.PlayerController.Instance.GetConnectedPlayerDownloadStatus();
                    middleViewController.Data.Clear();
                    foreach (KeyValuePair <string, float> user in status.OrderBy(u => u.Value))
                    {
                        CustomCellInfo cell = new CustomCellInfo(user.Key, user.Value == -1f ? "FAILED TO DOWNLOAD": user.Value == 1f ? "Ready" : $"Downloading song ${(int) Math.Round(user.Value * 100, 0)}%", user.Value == 1f ? Sprites.checkmarkIcon : Sprites.crossIcon);
                        middleViewController.Data.Add(cell);
                    }
                    middleViewController._customListTableView.ReloadData();
                    middleViewController._customListTableView.ScrollToRow(0, false);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Пример #2
0
        private static void refreshFriendsList(ListViewController leftViewController)
        {
            friends = SteamAPI.GetOnlineFriends();
            leftViewController.Data.Clear();
            CGameID gameId = SteamAPI.GetGameID();

            foreach (KeyValuePair <CSteamID, string[]> entry in friends)
            {
                if ("" + gameId != entry.Value[1] || entry.Value[1] == "0")
                {
                    continue;
                }
                Logger.Debug($"{entry.Value[0]} playing Beat Saber");
                leftViewController.Data.Add(new CustomCellInfo(entry.Value[0], "Playing Beat Saber"));
            }
            foreach (KeyValuePair <CSteamID, string[]> entry in friends)
            {
                if ("" + gameId == entry.Value[1] || entry.Value[1] == "0")
                {
                    continue;
                }
                Logger.Debug($"{entry.Value[0]} playing Other Game");
                leftViewController.Data.Add(new CustomCellInfo(entry.Value[0], "Playing Other Game"));
            }
            foreach (KeyValuePair <CSteamID, string[]> entry in friends)
            {
                if ("0" != entry.Value[1])
                {
                    continue;
                }
                Logger.Debug($"{entry.Value[0]} online");
                leftViewController.Data.Add(new CustomCellInfo(entry.Value[0], "Online"));
            }

            leftViewController._customListTableView.ReloadData();
            leftViewController._customListTableView.ScrollToCellWithIdx(0, TableView.ScrollPositionType.Beginning, false);
            leftViewController.DidSelectRowEvent = (view, row) =>
            {
                invite.interactable = false;
                CustomCellInfo cell = leftViewController.Data[row];
                KeyValuePair <CSteamID, string[]> friend = friends.Where(entry => entry.Value[0] == cell.text).First();
                selectedPlayer      = friend.Key.m_SteamID;
                invite.interactable = true;
            };
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            base.DidActivate(firstActivation, activationType);

            if (firstActivation)
            {
                this.customListTableData.cellSize = 8.5f;

                // Create the Default Menu Pointer option
                var defaultPointersIcon = UIUtilities.LoadSpriteFromResources("CustomMenuPointers.Resources.DefaultPointers.png");
                var defaultMenuPointers = new CustomCellInfo(
                    "Default",
                    "Use the default menu pointers",
                    defaultPointersIcon.texture);
                this.customListTableData.data.Add(defaultMenuPointers);

                // Create the Custom Saber option if available
                if (CustomSabersMod.instance.IsLoaded)
                {
                    var customSabersIcon   = UIUtilities.LoadSpriteFromResources("CustomMenuPointers.Resources.CustomSaberIcon.png");
                    var currentCustomSaber = new CustomCellInfo(
                        "Custom Saber",
                        "Use the currently selected Custom Saber as Menu Pointers",
                        customSabersIcon.texture);
                    this.customListTableData.data.Add(currentCustomSaber);
                }
            }

            // Determine which cell to select
            if (ConfigOptions.instance.UsePointerType == PointerType.Default)
            {
                Logger.Info("Selected Default");
                this.customListTableData.tableView.ScrollToCellWithIdx(0, TableViewScroller.ScrollPositionType.Beginning, false);
                this.customListTableData.tableView.SelectCellWithIdx(0, false);
            }

            if (ConfigOptions.instance.UsePointerType == PointerType.Custom)
            {
                Logger.Info("Selected CustomSaber");
                this.customListTableData.tableView.ScrollToCellWithIdx(1, TableViewScroller.ScrollPositionType.Beginning, false);
                this.customListTableData.tableView.SelectCellWithIdx(1, false);
            }

            this.customListTableData.tableView.ReloadData();
        }