Esempio n. 1
0
        public static void OnLoad()
        {
            try
            {
                var _levelListViewController = Resources.FindObjectsOfTypeAll <SelectLevelCategoryViewController>().Last();

                _levelListViewController.didActivateEvent += _levelListViewController_didActivateEvent;

                if (_levelListViewController)
                {
                    // move the icon control
                    var iconSegmentedControl = _levelListViewController.GetField <IconSegmentedControl, SelectLevelCategoryViewController>("_levelFilterCategoryIconSegmentedControl");
                    ((RectTransform)iconSegmentedControl.transform).anchoredPosition = new Vector2(0, 4.5f);

                    _requestButton = _levelListViewController.CreateUIButton("SRMButton", "PracticeButton", new Vector2(14, -4.5f), new Vector2(15f, 105f),
                                                                             () =>
                    {
                        _requestButton.interactable = false;
                        SRMButtonPressed();
                        _requestButton.interactable = true;
                    },
                                                                             "SRM");


                    _requestButton.ToggleWordWrapping(false);
                    _requestButton.SetButtonTextSize(5f);

                    UIHelper.AddHintText(_requestButton.transform as RectTransform, "Manage the current request queue");

                    UpdateRequestUI();
                    Plugin.Log("Created request button!");
                }
            }
            catch
            {
                Plugin.Log("Unable to create request button");
            }

            // check if flow coordinator has been setup yet
            if (_flowCoordinator == null)
            {
                _flowCoordinator = BeatSaberMarkupLanguage.BeatSaberUI.CreateFlowCoordinator <RequestFlowCoordinator>();
            }

            SongListUtils.Initialize();

            ChatHandler.instance.Init();

            WriteQueueSummaryToFile();
            WriteQueueStatusToFile(QueueMessage(RequestBotConfig.Instance.RequestQueueOpen));

            if (Instance)
            {
                return;
            }
            new GameObject("SongRequestManager").AddComponent <RequestBot>();
        }
        public static void OnLoad()
        {
            try
            {
                var _levelListViewController = Resources.FindObjectsOfTypeAll <LevelCollectionViewController>().First();
                if (_levelListViewController)
                {
                    _requestButton = UIHelper.CreateUIButton(_levelListViewController.rectTransform, "OkButton", new Vector2(66, -3.5f),
                                                             new Vector2(9f, 5.5f), () => { _requestButton.interactable = false; SRMButtonPressed(); _requestButton.interactable = true; }, "SRM");

                    (_requestButton.transform as RectTransform).anchorMin = new Vector2(1, 1);
                    (_requestButton.transform as RectTransform).anchorMax = new Vector2(1, 1);

                    _requestButton.ToggleWordWrapping(false);
                    _requestButton.SetButtonTextSize(3.5f);
                    UIHelper.AddHintText(_requestButton.transform as RectTransform, "Manage the current request queue");

                    UpdateRequestUI();
                    Plugin.Log("Created request button!");
                }
            }
            catch
            {
                Plugin.Log("Unable to create request button");
            }

            // check if flow coordinator has been setup yet
            if (_flowCoordinator == null)
            {
                _flowCoordinator = BeatSaberMarkupLanguage.BeatSaberUI.CreateFlowCoordinator <RequestFlowCoordinator>();
            }

            SongListUtils.Initialize();

            ChatHandler.instance.Init();

            WriteQueueSummaryToFile();
            WriteQueueStatusToFile(QueueMessage(RequestBotConfig.Instance.RequestQueueOpen));

            if (Instance)
            {
                return;
            }
            new GameObject("SongRequestManager").AddComponent <RequestBot>();
        }