public void RefreshSkyboxList()
        {
            try
            {
                string   backgroundDir        = Environment.CurrentDirectory + "/CustomBackgrounds/";
                string[] installedBackgrounds = Directory.GetFiles(backgroundDir, "*.*");

                foreach (var background in installedBackgrounds)
                {
                    string backgroundName = background.Substring(backgroundDir.Length);
                    if (background.EndsWith(".png") || background.EndsWith(".jpeg") || background.EndsWith(".jpg") || background.EndsWith(".gif") && !_BackgroundList.Contains(background))
                    {
                        Sprite backgroundIcon = null;
                        if (Settings.instance.EnablePreviews)
                        {
                            backgroundIcon = UIUtilities.LoadSpriteFromFile(background);
                            backgroundIcon.texture.Compress(false);
                            backgroundIcon.texture.Apply();
                        }

                        CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(backgroundName, "Image File", backgroundIcon);

                        backgroundList.data.Add(customCellInfo);
                        _BackgroundList.Add(background);
                    }
                }
                backgroundList.tableView.ReloadData();
            }
            catch (Exception e)
            {
                Logger.Log(e.Message, IPA.Logging.Logger.Level.Error);
                throw;
            }
        }
コード例 #2
0
        public void SetData(List <AdvancedPost> posts)
        {
            newsListTableData.data.Clear();
            newsListTableData.tableView.ReloadData();
            cellInfo.Clear();


            foreach (var post in posts)
            {
                var pT = DateTime.Parse(post.Uploaded);
                pT = pT.ToUniversalTime();

                var taz = pT.ToShortDateString() + " at " + pT.ToShortTimeString() + " UTC";

                var yeehaw = new CustomListTableData.CustomCellInfo(post.Title, $"by {post.Uploader} at {taz}");
                newsListTableData.data.Add(yeehaw);
                cellInfo.Add(post);
                newsListTableData.tableView.ReloadData();

                SharedCoroutineStarter.instance.StartCoroutine(Utilities.LoadScripts.LoadSpriteCoroutine(post.Image, (image) =>
                {
                    post.Texture = image.texture;
                    yeehaw.icon  = image.texture;
                    newsListTableData.tableView.ReloadData();
                }));
            }
        }
コード例 #3
0
        private IEnumerator <WaitForEndOfFrame> OnFileCreated(object sender, FileSystemEventArgs e)
        {
            yield return(new WaitForEndOfFrame());

            SharedCoroutineStarter.instance.StartCoroutine(_platformLoader.LoadFromFileAsync(e.FullPath, (CustomPlatform platform, string path) =>
            {
                _platformManager.HandlePlatformLoaded(platform, path);

                if (_platformListsView.allListTables != null)
                {
                    if (platform.icon == null)
                    {
                        platform.icon = _platformManager.fallbackCover;
                    }
                    CustomListTableData.CustomCellInfo cell = new CustomListTableData.CustomCellInfo(platform.platName, platform.platAuthor, platform.icon);
                    foreach (CustomListTableData listTable in _platformListsView.allListTables)
                    {
                        listTable.data.Add(cell);
                        listTable.tableView.ReloadData();
                    }
                }

                if (apiRequest)
                {
                    _platformManager.apiRequestIndex = _platformManager.allPlatforms.IndexOf(platform);
                    apiRequest = false;
                }
            }));
        }
コード例 #4
0
        private void SetupWebcamList()
        {
            if (!_WebcamList.Contains("None"))
            {
                bool hmdHasCamera = false;
                OpenVR.TrackedCamera.HasCamera(OpenVR.k_unTrackedDeviceIndex_Hmd, ref hmdHasCamera);
                Sprite autoicon = UIUtilities.LoadSpriteFromResources("ARCompanion.Resources.Icons.auto.png");

                CustomListTableData.CustomCellInfo defaultcamCellInfo = new CustomListTableData.CustomCellInfo("None", "No camera");
                CustomListTableData.CustomCellInfo autocamCellInfo    = new CustomListTableData.CustomCellInfo("Auto", "Automatically find any headset cameras.", autoicon);

                webcamList.data.Add(defaultcamCellInfo);
                webcamList.data.Add(autocamCellInfo);
                _WebcamList.Add("None");
                _WebcamList.Add("Auto");

                EVRSettingsError error           = EVRSettingsError.None;
                bool             cameraIsEnabled = OpenVR.Settings.GetBool(OpenVR.k_pch_Camera_Section, OpenVR.k_pch_Camera_EnableCamera_Bool, ref error);
                if (error != EVRSettingsError.None)
                {
                    Logger.Log("Error getting OpenVR camera settings: " + error, IPA.Logging.Logger.Level.Error);
                }
                else if (hmdHasCamera && cameraIsEnabled)
                {
                    Sprite openvricon = UIUtilities.LoadSpriteFromResources("ARCompanion.Resources.Icons.openvr.png");
                    CustomListTableData.CustomCellInfo openvrcamCellInfo = new CustomListTableData.CustomCellInfo("SteamVR", "Use SteamVR's camera system. (Recommended)", openvricon);
                    webcamList.data.Add(openvrcamCellInfo);
                    _WebcamList.Add("SteamVR");
                }
            }
            RefreshWebcamList();
        }
コード例 #5
0
        private IEnumerator UpdateSearchResults(List <YTResult> results)
        {
            List <CustomListTableData.CustomCellInfo> videos = new List <CustomListTableData.CustomCellInfo>();

            foreach (var result in results)
            {
                string description = $"[{result.duration}] {result.description}";
                var    item        = new CustomListTableData.CustomCellInfo(result.title, description);

                UnityWebRequest request = UnityWebRequestTexture.GetTexture(result.thumbnailURL);
                yield return(request.SendWebRequest());

                if (request.isNetworkError || request.isHttpError)
                {
                    Debug.Log(request.error);
                }
                else
                {
                    item.icon = ((DownloadHandlerTexture)request.downloadHandler).texture;
                }

                videos.Add(item);
            }

            customListTableData.data = videos;
            customListTableData.tableView.ReloadData();

            refineButton.interactable = true;
            searchResultsLoadingText.gameObject.SetActive(false);
        }
コード例 #6
0
        public void SetupList()
        {
            customListTableData.tableView.ClearSelection();
            customListTableData.data.Clear();
            foreach (var effect in BundleLoader.effects)
            {
                if (effect.IsEffectSeperateType())
                {
                    //Debug.Log(EffectModel.GetNameWithoutSceneName(effect.Desc.EffectName) + " is Seperate Type " + effect.Desc.EffectName);
                    if (multiTypeAdded.Contains(EffectModel.GetNameWithoutSceneName(effect.Desc.EffectName)))
                    {
                        //Debug.Log(EffectModel.GetNameWithoutSceneName(effect.Desc.EffectName) + " added... Skipping " + effect.Desc.EffectName);
                        continue;
                    }
                    else
                    {
                        //Debug.Log(EffectModel.GetNameWithoutSceneName(effect.Desc.EffectName) + " isnt added... Adding " + effect.Desc.EffectName);
                        multiTypeAdded.Add(EffectModel.GetNameWithoutSceneName(effect.Desc.EffectName));
                    }
                }
                effsInTable.Add(effect);
                var customCellInfo = new CustomListTableData.CustomCellInfo(EffectModel.GetNameWithoutSceneName(effect.Desc.EffectName), effect.Desc.Author, effect.Desc.coverImage);
                customListTableData.data.Add(customCellInfo);
                //if(effect.enabled)
                //{
                //    ReflectionUtil.GetField<HashSet<int>, TableView>(customListTableData.tableView, "_selectedCellIdxs").Add(customListTableData.data.Count-1);
                //    customListTableData.tableView.RefreshCells(true, false);
                //}
            }

            customListTableData.tableView.ReloadData();
            customListTableData.tableView.selectionType = TableViewSelectionType.Single;
        }
コード例 #7
0
        public void SetupList()
        {
            GetVersion();
            SetUpUIElements();

            var hoverHint = modeSelection.gameObject.AddComponent <HoverHint>();

            hoverHint.text = Plugin.Control.GetMode().getDescription();
            HoverHintController hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First();

            hoverHint.SetPrivateField("_hoverHintController", hoverHintController);

            List <ConnectionConfig> Connections = PluginConfig.Instance.GetConnections();

            connectionTableData.data.Clear();

            foreach (ConnectionConfig Connection in Connections)
            {
                Sprite spriteAvail = null;
                if (Connection.Active)
                {
                    spriteAvail = Utilities.LoadSpriteFromResources("LovenseBSControl.Resources.Sprites.available_profile.png");
                }

                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(Connection.Name, Connection.Prefix + Connection.IpAdress + ":" + Connection.Port, spriteAvail);
                connectionTableData.data.Add(customCellInfo);
            }

            connectionTableData.tableView.ReloadData();
            this.selectedConnection = Connections[this.selectedConnectionNumber];
            toggleStatusBtn.text    = this.selectedConnection.Active ? "Disable" : "Enable";

            connectionTableData.tableView.ScrollToCellWithIdx(this.selectedConnectionNumber, TableView.ScrollPositionType.Beginning, false);
            connectionTableData.tableView.SelectCellWithIdx(this.selectedConnectionNumber);


            if (!Plugin.Control.IsToyAvailable())
            {
                return;
            }
            List <Toy> Toys = Plugin.Control.GetToyList();

            customListTableData.data.Clear();

            foreach (Toy toy in Toys)
            {
                Sprite     sprite    = Utilities.LoadSpriteFromResources("LovenseBSControl.Resources.Sprites." + toy.GetPictureName());
                ToysConfig toyConfig = toy.GetToyConfig();
                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(toy.GetNickName(), toy.GetText() + " - " + ((toy.IsConnected() ? "Connected" : "Disconnected") + (toy.IsConnected()? " - " + toy.getBattery() + "%" : "") + " - " + toyConfig.HType), sprite);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            this.selectedToy = Toys[this.selectedToyNumber];

            customListTableData.tableView.ScrollToCellWithIdx(this.selectedToyNumber, TableView.ScrollPositionType.Beginning, false);
            customListTableData.tableView.SelectCellWithIdx(this.selectedToyNumber);
        }
 private void GetBGDir()
 {
     if (!_BackgroundList.Contains("Default"))
     {
         CustomListTableData.CustomCellInfo defaultskyCellInfo = new CustomListTableData.CustomCellInfo("Default", "Default Skybox");
         backgroundList.data.Add(defaultskyCellInfo);
         _BackgroundList.Add("Default");
     }
     RefreshSkyboxList();
 }
コード例 #9
0
        private void FillList(CustomListTableData list, IEnumerable <Texture2D> textures)
        {
            var cells = new List <CustomListTableData.CustomCellInfo>();

            foreach (var tex in textures)
            {
                var cell = new CustomListTableData.CustomCellInfo(tex.name, null, Utilities.LoadSpriteFromTexture(tex));
                cells.Add(cell);
            }

            list.data = cells;
            list.tableView.ReloadData();
        }
コード例 #10
0
        public void RefreshList(List <TextureAsset> items)
        {
            _textureAssets = items;
            var cells = new List <CustomListTableData.CustomCellInfo>();

            foreach (var textureAsset in _textureAssets)
            {
                var cell = new CustomListTableData.CustomCellInfo(textureAsset.Name, null, textureAsset.Sprite);
                cells.Add(cell);
            }

            _itemList.data = cells;
            _itemList.tableView.ReloadData();
        }
コード例 #11
0
 protected void RefreshData()
 {
     data.data.Clear();
     for (int i = -1; i < hudConfig.OtherCanvasSettings.Count; i++)
     {
         HUDCanvas settings            = canvasUtility.GetCanvasSettingsFromID(i);
         int       countersUsingCanvas = flowCoordinator.Value.AllConfigModels.Count(x => x.CanvasID == i);
         var       info = new CustomListTableData.CustomCellInfo(
             settings?.Name ?? "Unknown",
             $"<i>{countersUsingCanvas} counter(s) use this Canvas.</i>", Texture2D.blackTexture);
         data.data.Add(info);
     }
     data.tableView.ReloadData();
 }
コード例 #12
0
        private void Start()
        {
            //List<string> scoreDataText = BeatSaberDiary.DiaryData.GetAllTextData();
            diaryPlayData = BeatSaberDiary.DiaryData.GetAllPlayData();

            foreach (var data in diaryPlayData)
            {
                string txt = "[Title: " + data.GetSongName() + "] [GoodRate: " + data.GetTotalGoodRate() + "]";
                CustomListTableData.CustomCellInfo cellInfo = new CustomListTableData.CustomCellInfo(txt, "2020/07/23"); //To be change playData date
                scoreList.data.Add(cellInfo);
            }

            scoreList.tableView.ReloadData();
        }
コード例 #13
0
        public void SetupList()
        {
            customListTableData.data.Clear();
            foreach (CustomSaberData saber in SaberAssetLoader.CustomSabers)
            {
                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(saber.SaberDescriptor.SaberName, saber.SaberDescriptor.AuthorName, saber.SaberDescriptor.CoverImage?.texture);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            int selectedSaber = SaberAssetLoader.SelectedSaber;

            customListTableData.tableView.ScrollToCellWithIdx(selectedSaber, TableViewScroller.ScrollPositionType.Beginning, false);
            customListTableData.tableView.SelectCellWithIdx(selectedSaber);
        }
コード例 #14
0
        public void SetupList()
        {
            customListTableData.data.Clear();

            foreach (EnergyBar energyBar in _energyLoader.CustomEnergyBars)
            {
                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(energyBar.descriptor.name, energyBar.descriptor.author, energyBar.descriptor.icon);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            int selectedEnergyBar = _energyLoader.SelectedEnergyBar;

            customListTableData.tableView.ScrollToCellWithIdx(selectedEnergyBar, TableView.ScrollPositionType.Beginning, false);
            customListTableData.tableView.SelectCellWithIdx(selectedEnergyBar);
        }
コード例 #15
0
        public void SetupList()
        {
            customListTableData.data.Clear();

            foreach (CustomNote note in _noteAssetLoader.CustomNoteObjects)
            {
                Sprite sprite = Sprite.Create(note.Descriptor.Icon, new Rect(0, 0, note.Descriptor.Icon.width, note.Descriptor.Icon.height), new Vector2(0.5f, 0.5f));
                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(note.Descriptor.NoteName, note.Descriptor.AuthorName, sprite);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            int selectedNote = _noteAssetLoader.SelectedNote;

            customListTableData.tableView.ScrollToCellWithIdx(selectedNote, TableViewScroller.ScrollPositionType.Beginning, false);
            customListTableData.tableView.SelectCellWithIdx(selectedNote);
        }
コード例 #16
0
        private void OnShowSelectTracker()
        {
            this.trackerList.tableView.ClearSelection();
            this.trackerList.data.Clear();

            TrackedDeviceManager.instance.LoadTrackedDevices();
            TrackedDeviceManager.instance.TrackedDevices.ForEach(t =>
            {
                string text        = $"{t.serialNumber}: {t.manufacturer} {t.name}";
                var customCellInfo = new CustomListTableData.CustomCellInfo(text);
                this.trackerList.data.Add(customCellInfo);
            });

            // Save the list of serials for later reference
            this.LoadedSerials = TrackedDeviceManager.instance.TrackedDevices.Select(t => t.serialNumber).ToList();

            this.trackerList.tableView.ReloadData();
        }
コード例 #17
0
        public void SetupList()
        {
            customListTableData.data.Clear();
            foreach (var saber in SaberAssetLoader.CustomSabers)
            {
                var customCellInfo = new CustomListTableData.CustomCellInfo(saber.Descriptor.SaberName, saber.Descriptor.AuthorName, saber.Descriptor.CoverImage?.texture);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            var selectedSaber = SaberAssetLoader.SelectedSaber;

            customListTableData.tableView.SelectCellWithIdx(selectedSaber);
            if (!customListTableData.tableView.visibleCells.Where(x => x.selected).Any())
            {
                customListTableData.tableView.ScrollToCellWithIdx(selectedSaber, TableViewScroller.ScrollPositionType.Beginning, true);
            }
        }
コード例 #18
0
        public void SetupList()
        {
            customListTableData.data.Clear();
            foreach (CustomMaterial material in MaterialAssetLoader.CustomMaterialObjects)
            {
                Sprite sprite = material?.Descriptor?.Icon
                    ? Sprite.Create(material.Descriptor.Icon, new Rect(Vector2.zero, new Vector2(material.Descriptor.Icon.width, material.Descriptor.Icon.height)), new Vector2(0.5f, 0.5f))
                    : null;
                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(material.Descriptor.MaterialName, material.Descriptor.AuthorName, sprite);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            int selectedMaterial = MaterialAssetLoader.SelectedMaterial;

            customListTableData.tableView.ScrollToCellWithIdx(selectedMaterial, TableViewScroller.ScrollPositionType.Beginning, false);
            customListTableData.tableView.SelectCellWithIdx(selectedMaterial);
        }
コード例 #19
0
        public void SetupList()
        {
            customListTableData.data.Clear();
            foreach (var platform in PlatformManager.Instance.GetPlatforms())
            {
                var customCellInfo = new CustomListTableData.CustomCellInfo(platform.platName, platform.platAuthor, platform.icon?.texture);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            var selectedSaber = PlatformManager.Instance.currentPlatformIndex;

            customListTableData.tableView.SelectCellWithIdx(selectedSaber);
            if (!customListTableData.tableView.visibleCells.Where(x => x.selected).Any())
            {
                customListTableData.tableView.ScrollToCellWithIdx(selectedSaber, TableViewScroller.ScrollPositionType.Beginning, true);
            }
        }
コード例 #20
0
 public void SetupFontList()
 {
     fontListData.data.Clear();
     foreach (var font in FontManager.FontList)
     {
         CustomListTableData.CustomCellInfo fontCell;
         if (font.builtin)
         {
             fontCell = new CustomListTableData.CustomCellInfo(font.name, "Built-In");
             fontListData.data.Add(fontCell);
         }
         else
         {
             fontCell = new CustomListTableData.CustomCellInfo(font.name);
             fontListData.data.Add(fontCell);
         }
     }
     fontListData.tableView.ReloadData();
 }
コード例 #21
0
 public void SetupImageList()
 {
     imgListData.data.Clear();
     foreach (var imageChunk in ImageManager.ImageChunks)
     {
         string yes;
         if (!imageChunk.E)
         {
             yes = "with Flickering E";
         }
         else
         {
             yes = "";
         }
         var imgCell = new CustomListTableData.CustomCellInfo(imageChunk.name, yes);
         imgListData.data.Add(imgCell);
     }
     imgListData.tableView.ReloadData();
 }
コード例 #22
0
        public void SetupList()
        {
            customListTableData.data.Clear();

            foreach (MPIAudioContainer audio in MPIAudioLoader.Instance.IntroAudioList)
            {
                Sprite icon;

                if (audio.Icon != null)
                {
                    icon = Sprite.Create(audio.Icon, new Rect(0.0f, 0.0f, audio.Icon.width, audio.Icon.height), new Vector2(0.5f, 0.5f), 100.0f);
                }
                else
                {
                    if (!defaultSprite)
                    {
                        defaultSprite = Sprite.Create(Util.GetDefaultIcon(), new Rect(0.0f, 0.0f, Util.GetDefaultIcon().width, Util.GetDefaultIcon().height), new Vector2(0.5f, 0.5f), 100.0f);
                    }
                    if (!defaultCustomSprite)
                    {
                        defaultCustomSprite = Sprite.Create(Util.GetCustomIcon(), new Rect(0.0f, 0.0f, Util.GetCustomIcon().width, Util.GetCustomIcon().height), new Vector2(0.5f, 0.5f), 100.0f);
                    }
                    if (MPIAudioLoader.DefaultAC == audio)
                    {
                        icon = defaultSprite;
                    }
                    else
                    {
                        icon = defaultCustomSprite;
                    }
                }

                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(audio.Name, audio.ReplacesText, icon);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            int selectedAudio = MPIAudioLoader.Instance.GetIndexOfSelected();

            customListTableData.tableView.ScrollToCellWithIdx(selectedAudio, TableViewScroller.ScrollPositionType.Beginning, false);
            customListTableData.tableView.SelectCellWithIdx(selectedAudio);
        }
コード例 #23
0
        private void CreateKeyboardEnter(string folderName)
        {
            folderName = folderName.Replace("/", "").Replace("\\", "").Replace(".", "");
            if (!string.IsNullOrEmpty(folderName))
            {
                BeatSaberPlaylistsLib.PlaylistManager childManager = currentParentManager.CreateChildManager(folderName);

                if (currentManagers.Contains(childManager))
                {
                    popupModalsController.ShowOkModal(levelSelectionNavigationController.transform, "\"" + folderName + "\" already exists! Please use a different name.", null);
                }
                else
                {
                    CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(folderName, icon: PlaylistLibUtils.DrawFolderIcon(folderName));
                    customListTableData.data.Add(customCellInfo);
                    customListTableData.tableView.ReloadData();
                    customListTableData.tableView.ClearSelection();
                    currentManagers.Add(childManager);
                }
            }
        }
コード例 #24
0
        protected void SetupShaderList()
        {
            customListTableData.data.Clear();
            if (_spriteCache != null)
            {
                _spriteCache.Clear();
            }
            else
            {
                _spriteCache = new Dictionary <Texture2D, Sprite>();
            }

            _selection = -1;
            shadersCleared?.Invoke();

            List <ShaderEffectData> sfxList = _shaderAssetLoader.ShaderEffectList;

            foreach (ShaderEffectData sfx in sfxList)
            {
                Sprite icon = SEUtilities.GetDefaultShaderIcon();

                if (sfx.PreviewImage != null && _spriteCache.TryGetValue(sfx.PreviewImage, out Sprite image))
                {
                    icon = image;
                }
                else if (sfx.PreviewImage != null)
                {
                    icon = Sprite.Create(sfx.PreviewImage, new Rect(0.0f, 0.0f, sfx.PreviewImage.width, sfx.PreviewImage.height), new Vector2(0.5f, 0.5f), 100.0f);
                    _spriteCache.Add(sfx.PreviewImage, icon);
                }

                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(sfx.Name, sfx.Author, icon);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            SEUtilities.UpdateScrollIndicator(customListTableData.tableView, scrollIndicator, true);
        }
コード例 #25
0
 public void RefreshWebcamList()
 {
     try
     {
         WebCamDevice[] avaliableCameras = WebCamTexture.devices;
         foreach (var camera in avaliableCameras)
         {
             string camName = camera.name;
             if (camName != null && !_WebcamList.Contains(camName))
             {
                 string subText = camera.kind.ToString() + " Webcam";
                 CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(camName, subText, null);
                 webcamList.data.Add(customCellInfo);
                 _WebcamList.Add(camName);
             }
         }
         webcamList.tableView.ReloadData();
     }
     catch (Exception e)
     {
         Logger.Log(e.Message, IPA.Logging.Logger.Level.Error);
         throw;
     }
 }
コード例 #26
0
        private IEnumerator SetDataEnumerator()
        {
            yield return(new WaitForSecondsRealtime(.1f));

            using (UnityWebRequest www = UnityWebRequest.Get($"https://tmi.twitch.tv/group/user/{TwitchLoginConfig.Instance.TwitchChannelName}/chatters"))
            {
                www.SetRequestHeader("Client-ID", "gbrndadd5hgnm9inrdsw8xpx5w9xa9");
                yield return(www.SendWebRequest());

                JSONNode      response = JSON.Parse(www.downloadHandler.text);
                List <string> names    = new List <string>();

                var chl = response["chatters"];

                foreach (JSONNode name in chl["broadcaster"].AsArray)
                {
                    names.Add(name);
                }
                foreach (JSONNode name in chl["vips"].AsArray)
                {
                    names.Add(name);
                }
                foreach (JSONNode name in chl["moderators"].AsArray)
                {
                    names.Add(name);
                }
                foreach (JSONNode name in chl["staff"].AsArray)
                {
                    names.Add(name);
                }
                foreach (JSONNode name in chl["admins"].AsArray)
                {
                    names.Add(name);
                }
                foreach (JSONNode name in chl["viewers"].AsArray)
                {
                    names.Add(name);
                }

                List <Viewer> unsorted = new List <Viewer>();

                foreach (var name in names)
                {
                    bool foundCache = AlphaTwitchManager.Viewers.ContainsKey(name);
                    if (foundCache)
                    {
                        AlphaTwitchManager.Viewers.TryGetValue(name, out Viewer v1);
                        string roleText;
                        if (v1.Role == Role.Other)
                        {
                            roleText = "Comfy";
                        }
                        else
                        {
                            roleText = v1.Role.ToString();
                        }

                        var yeehaw = new CustomListTableData.CustomCellInfo($"<color={v1.Color}>{v1.Name}</color>", roleText, v1.Profile);
                        viewerListTableData.data.Add(yeehaw);
                        unsorted.Add(v1);
                    }
                }
                //unsorted.Sort();
                cellInfo = unsorted;
                viewerListTableData.tableView.ReloadData();
            }
        }
コード例 #27
0
        /// <summary>
        /// Destroy the platform and remove all references
        /// </summary>
        private IEnumerator <WaitForEndOfFrame> OnFileDeleted(object sender, FileSystemEventArgs e)
        {
            yield return(new WaitForEndOfFrame());

            if (_platformLoader.platformFilePaths.TryGetValue(e.FullPath, out CustomPlatform platform))
            {
                if (_platformListsView.allListTables != null)
                {
                    foreach (CustomListTableData listTable in _platformListsView.allListTables)
                    {
                        CustomListTableData.CustomCellInfo deletedPlatformCell = listTable.data.Find(x => x.text == platform.platName && x.subtext == platform.platAuthor);
                        listTable.data.Remove(deletedPlatformCell);
                        listTable.tableView.ReloadData();
                    }
                    bool platformDidChange = false;
                    if (_platformManager.currentSingleplayerPlatform == platform)
                    {
                        _platformListsView.singleplayerPlatformListTable.tableView.SelectCellWithIdx(0);
                        platformDidChange = true;
                    }

                    if (_platformManager.currentMultiplayerPlatform == platform)
                    {
                        _platformListsView.multiplayerPlatformListTable.tableView.SelectCellWithIdx(0);
                        platformDidChange = true;
                    }

                    if (_platformManager.currentA360Platform == platform)
                    {
                        _platformListsView.a360PlatformListTable.tableView.SelectCellWithIdx(0);
                        platformDidChange = true;
                    }
                    if (platformDidChange)
                    {
                        _platformSpawner.ChangeToPlatform(0);
                    }
                }
                else
                {
                    bool platformDidChange = false;
                    if (_platformManager.currentSingleplayerPlatform == platform)
                    {
                        _platformManager.currentSingleplayerPlatform = _platformManager.allPlatforms[0];
                        platformDidChange = true;
                    }
                    if (_platformManager.currentMultiplayerPlatform == platform)
                    {
                        _platformManager.currentMultiplayerPlatform = _platformManager.allPlatforms[0];
                        platformDidChange = true;
                    }
                    if (_platformManager.currentA360Platform == platform)
                    {
                        _platformManager.currentA360Platform = _platformManager.allPlatforms[0];
                    }
                    if (platformDidChange)
                    {
                        _platformSpawner.ChangeToPlatform(0);
                    }
                }

                _platformLoader.platformFilePaths.Remove(platform.fullPath);
                _platformManager.allPlatforms.Remove(platform);
                GameObject.Destroy(platform.gameObject);
            }
        }
コード例 #28
0
        private void SetupList(BeatSaberPlaylistsLib.PlaylistManager currentParentManager, bool setBeatmapLevelCollections = true)
        {
            customListTableData.tableView.ClearSelection();
            customListTableData.data.Clear();
            this.currentParentManager = currentParentManager;

            if (currentParentManager == null)
            {
                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo("Level Packs", icon: levelPacksIcon);
                customListTableData.data.Add(customCellInfo);

                customCellInfo = new CustomListTableData.CustomCellInfo("Custom Songs", icon: customPacksIcon);
                customListTableData.data.Add(customCellInfo);

                customCellInfo = new CustomListTableData.CustomCellInfo("Playlists", icon: playlistsIcon);
                customListTableData.data.Add(customCellInfo);

                customCellInfo = new CustomListTableData.CustomCellInfo("Folders", icon: foldersIcon);
                customListTableData.data.Add(customCellInfo);

                backTransform.gameObject.SetActive(false);
            }
            else
            {
                currentManagers = currentParentManager.GetChildManagers().ToList();
                foreach (var childManager in currentManagers)
                {
                    var folderName = Path.GetFileName(childManager.PlaylistPath);
                    CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(folderName, icon: PlaylistLibUtils.DrawFolderIcon(folderName));
                    customListTableData.data.Add(customCellInfo);
                }

                backTransform.gameObject.SetActive(true);
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FolderText)));

                // If root, can't rename or delete
                if (currentParentManager.Parent == null)
                {
                    renameButton.interactable = false;
                    deleteButton.interactable = false;
                }
                else
                {
                    renameButton.interactable = true;
                    deleteButton.interactable = true;
                }

                if (setBeatmapLevelCollections)
                {
                    IAnnotatedBeatmapLevelCollection[] annotatedBeatmapLevelCollections = currentParentManager.GetAllPlaylists(false);
                    LevelCollectionTableViewUpdatedEvent?.Invoke(annotatedBeatmapLevelCollections, 0);
                }
            }

            customListTableData.tableView.ReloadData();
            customListTableData.tableView.ScrollToCellWithIdx(0, TableView.ScrollPositionType.Beginning, false);
            if (currentParentManager == null)
            {
                customListTableData.tableView.SelectCellWithIdx(0);

                // Add hover hint
                TableCell[] visibleCells = customListTableData.tableView.visibleCells.ToArray();
                for (int i = 0; i < visibleCells.Length; i++)
                {
                    HoverHint hoverHint = visibleCells[i].GetComponent <HoverHint>();
                    if (hoverHint == null)
                    {
                        hoverHint = visibleCells[i].gameObject.AddComponent <HoverHint>();
                        hoverHint.SetField("_hoverHintController", hoverHintController);
                    }
                    else
                    {
                        hoverHint.enabled = true;
                    }
                    hoverHint.text = customListTableData.data[i].text;
                }

                if (setBeatmapLevelCollections)
                {
                    Select(customListTableData.tableView, 0);
                }
            }
            else
            {
                // Disable hover hint
                TableCell[] visibleCells = customListTableData.tableView.visibleCells.ToArray();
                for (int i = 0; i < visibleCells.Length; i++)
                {
                    HoverHint hoverHint = visibleCells[i].GetComponent <HoverHint>();
                    if (hoverHint != null)
                    {
                        hoverHint.enabled = false;
                    }
                }
            }

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LeftButtonEnabled)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(RightButtonEnabled)));
        }