Example #1
0
        public void BuildList()
        {
            for (int i = 0; i < videoList.Count; i++)
            {
                ModVideo video = videoList[i];
                switch (video.VideoNumber)
                {
                case 0:
                {
                    var vidButton = new QMSingleButton(videoLibrary, 1, 0, video.VideoName, delegate
                        {
                            if (getLink)
                            {
                                video.GetLink();
                            }

                            else
                            {
                                video.AddVideo(onCooldown);

                                if (!onCooldown)
                                {
                                    MelonCoroutines.Start(CoolDown());
                                }
                            }
                        }, $"Puts {video.VideoName} on the video player", null, null);

                    video.VideoButton = vidButton;
                    vidButton.getGameObject().GetComponentInChildren <Text>().resizeTextForBestFit = true;
                    break;
                }

                case 1:
                {
                    var vidButton = new QMSingleButton(videoLibrary, 2, 0, video.VideoName, delegate
                        {
                            if (getLink)
                            {
                                video.GetLink();
                            }

                            else
                            {
                                video.AddVideo(onCooldown);

                                if (!onCooldown)
                                {
                                    MelonCoroutines.Start(CoolDown());
                                }
                            }
                        }, $"Puts {video.VideoName} on the video player", null, null);

                    video.VideoButton = vidButton;
                    vidButton.getGameObject().GetComponentInChildren <Text>().resizeTextForBestFit = true;
                    break;
                }

                case 2:
                {
                    var vidButton = new QMSingleButton(videoLibrary, 3, 0, video.VideoName, delegate
                        {
                            if (getLink)
                            {
                                video.GetLink();
                            }

                            else
                            {
                                video.AddVideo(onCooldown);

                                if (!onCooldown)
                                {
                                    MelonCoroutines.Start(CoolDown());
                                }
                            }
                        }, $"Puts {video.VideoName} on the video player", null, null);

                    video.VideoButton = vidButton;
                    vidButton.getGameObject().GetComponentInChildren <Text>().resizeTextForBestFit = true;
                    break;
                }

                case 3:
                {
                    var vidButton = new QMSingleButton(videoLibrary, 1, 1, video.VideoName, delegate
                        {
                            if (getLink)
                            {
                                video.GetLink();
                            }

                            else
                            {
                                video.AddVideo(onCooldown);

                                if (!onCooldown)
                                {
                                    MelonCoroutines.Start(CoolDown());
                                }
                            }
                        }, $"Puts {video.VideoName} on the video player", null, null);

                    video.VideoButton = vidButton;
                    vidButton.getGameObject().GetComponentInChildren <Text>().resizeTextForBestFit = true;
                    break;
                }

                case 4:
                {
                    var vidButton = new QMSingleButton(videoLibrary, 2, 1, video.VideoName, delegate
                        {
                            if (getLink)
                            {
                                video.GetLink();
                            }

                            else
                            {
                                video.AddVideo(onCooldown);

                                if (!onCooldown)
                                {
                                    MelonCoroutines.Start(CoolDown());
                                }
                            }
                        }, $"Puts {video.VideoName} on the video player", null, null);

                    video.VideoButton = vidButton;
                    vidButton.getGameObject().GetComponentInChildren <Text>().resizeTextForBestFit = true;
                    break;
                }

                case 5:
                {
                    var vidButton = new QMSingleButton(videoLibrary, 3, 1, video.VideoName, delegate
                        {
                            if (getLink)
                            {
                                video.GetLink();
                            }

                            else
                            {
                                video.AddVideo(onCooldown);

                                if (!onCooldown)
                                {
                                    MelonCoroutines.Start(CoolDown());
                                }
                            }
                        }, $"Puts {video.VideoName} on the video player", null, null);

                    video.VideoButton = vidButton;
                    vidButton.getGameObject().GetComponentInChildren <Text>().resizeTextForBestFit = true;
                    break;
                }

                case 6:
                {
                    var vidButton = new QMSingleButton(videoLibrary, 1, 2, video.VideoName, delegate
                        {
                            if (getLink)
                            {
                                video.GetLink();
                            }

                            else
                            {
                                video.AddVideo(onCooldown);

                                if (!onCooldown)
                                {
                                    MelonCoroutines.Start(CoolDown());
                                }
                            }
                        }, $"Puts {video.VideoName} on the video player", null, null);

                    video.VideoButton = vidButton;
                    vidButton.getGameObject().GetComponentInChildren <Text>().resizeTextForBestFit = true;
                    break;
                }

                case 7:
                {
                    var vidButton = new QMSingleButton(videoLibrary, 2, 2, video.VideoName, delegate
                        {
                            if (getLink)
                            {
                                video.GetLink();
                            }

                            else
                            {
                                video.AddVideo(onCooldown);

                                if (!onCooldown)
                                {
                                    MelonCoroutines.Start(CoolDown());
                                }
                            }
                        }, $"Puts {video.VideoName} on the video player", null, null);

                    video.VideoButton = vidButton;
                    vidButton.getGameObject().GetComponentInChildren <Text>().resizeTextForBestFit = true;
                    break;
                }

                case 8:
                {
                    var vidButton = new QMSingleButton(videoLibrary, 3, 2, video.VideoName, delegate
                        {
                            if (getLink)
                            {
                                video.GetLink();
                            }

                            else
                            {
                                video.AddVideo(onCooldown);

                                if (!onCooldown)
                                {
                                    MelonCoroutines.Start(CoolDown());
                                }
                            }
                        }, $"Puts {video.VideoName} on the video player", null, null);

                    video.VideoButton = vidButton;
                    vidButton.getGameObject().GetComponentInChildren <Text>().resizeTextForBestFit = true;
                    break;
                }
                }

                if (video.IndexNumber != currentMenuIndex)
                {
                    video.VideoButton.setActive(false);
                }
            }

            indexButton.setButtonText("Page:\n" + (currentMenuIndex + 1).ToString() + " of " + (indexNumber + 1).ToString());
        }
Example #2
0
        private IEnumerator LoadMenu()
        {
            while (!libraryInitialized)
            {
                yield return(null);
            }
            indexButton = new QMSingleButton(videoLibrary, 4, 1, "Page:\n" + (currentMenuIndex + 1).ToString() + " of " + (indexNumber + 1).ToString(), delegate { }, "", Color.clear, Color.yellow);
            indexButton.getGameObject().GetComponentInChildren <Button>().enabled = false;
            indexButton.getGameObject().GetComponentInChildren <Image>().enabled  = false;

            previousButton = new QMSingleButton(videoLibrary, 4, 0, "Previous\nPage", delegate
            {
                if (currentMenuIndex != 0)
                {
                    currentMenuIndex--;
                }

                foreach (ModVideo videoButton in videoList)
                {
                    if (videoButton.IndexNumber != currentMenuIndex)
                    {
                        videoButton.VideoButton.setActive(false);
                    }

                    else
                    {
                        videoButton.VideoButton.setActive(true);
                    }
                }
                indexButton.setButtonText("Page:\n" + (currentMenuIndex + 1).ToString() + " of " + (indexNumber + 1).ToString());
            }, "Previous video page", null, null);

            nextButton = new QMSingleButton(videoLibrary, 4, 2, "Next\nPage", delegate
            {
                if (currentMenuIndex != indexNumber)
                {
                    currentMenuIndex++;
                }

                foreach (ModVideo videoButton in videoList)
                {
                    if (videoButton.IndexNumber != currentMenuIndex)
                    {
                        videoButton.VideoButton.setActive(false);
                    }

                    else
                    {
                        videoButton.VideoButton.setActive(true);
                    }
                }
                indexButton.setButtonText("Page:\n" + (currentMenuIndex + 1).ToString() + " of " + (indexNumber + 1).ToString());
            }, "Previous video page", null, null);

            var videoFromClipboard = new QMSingleButton(videoLibrary, 1, -2, "Video From\nClipboard", delegate
            {
                MelonCoroutines.Start(ModVideo.VideoFromClipboard(onCooldown));
            }, "Puts the link in your system clipboard into the world's video player");

            var openListButton = new QMSingleButton(videoLibrary, 2, -2, "Open\nLibrary\nDocument", delegate
            {
                OpenVideoLibrary();
            }, "Opens the Video Library text document\nLibrary Format: \"Button Name|Video Url\"", null, null);

            var openReadMe = new QMSingleButton(videoLibrary, 3, -2, "Read\nMe", delegate
            {
                Process.Start("https://github.com/UshioHiko/VRCVideoLibrary/blob/master/README.md");
            }, "Opens a link to the mod's \"Read Me\"");

            var getLinkToggle = new QMToggleButton(videoLibrary, 4, -2, "Buttons Copy\nVideo Link", delegate
            {
                getLink = true;
            }, "Disabled", delegate
            {
                getLink = false;
            }, "Makes video library buttons copy video url to your system clipboard", null, null, false, false);

            var refreshList = new QMSingleButton(videoLibrary, 5, -2, "Refresh\nList", delegate
            {
                DeleteButtons();
                ClearButtons();
                GetVideoLibrary();
                BuildList();
            }, "Refreshes the list");

            BuildList();

            if (videoList.Count <= 9)
            {
                previousButton.setIntractable(false);
                nextButton.setIntractable(false);
            }
        }