Exemple #1
0
#pragma warning disable CS0618
        public void Init(ModListFlowCoordinator flow, IEnumerable <PluginLoader.PluginInfo> bsipaPlugins, IEnumerable <PluginLoader.PluginMetadata> ignoredPlugins, IEnumerable <IPlugin> ipaPlugins)
        {
            Logger.log.Debug("List Controller Init");

            DidActivateEvent  = DidActivate;
            DidSelectRowEvent = DidSelectRow;

            rectTransform.anchorMin = new Vector2(0f, 0f);
            rectTransform.anchorMax = new Vector2(.4f, 1f);

            includePageButtons = true;
            this.flow          = flow;

            reuseIdentifier = "BSIPAModListTableCell";

            foreach (var plugin in bsipaPlugins.Where(p => !p.Metadata.IsBare))
            {
                Data.Add(new BSIPAModCell(this, plugin));
            }
            foreach (var plugin in ignoredPlugins)
            {
                Data.Add(new BSIPAIgnoredModCell(this, plugin));
            }
            foreach (var plugin in bsipaPlugins.Where(p => p.Metadata.IsBare))
            {
                Data.Add(new LibraryModCell(this, plugin));
            }
            foreach (var plugin in ipaPlugins)
            {
                Data.Add(new IPAModCell(this, plugin));
            }
        }
        private static IEnumerator AddModListButton()
        {
            yield return(_bottomPanelExists);

            Logger.log.Debug("Adding button to main menu");

            lock (Instance)
            {
                if (menuFlow == null)
                {
                    menuFlow = new GameObject("BSIPA Mod List Flow Controller").AddComponent <ModListFlowCoordinator>();
                }
                if (panel == null)
                {
                    panel = GameObject.Find(ControllerPanel).transform as RectTransform;
                }

                if (button == null)
                {
                    button = BeatSaberUI.CreateUIButton(panel, CopyButton, () =>
                    {
                        menuFlow.Present();
                    }, "Mod List");
                    panel.Find(CopyButton).SetAsLastSibling();

                    hintText = BeatSaberUI.AddHintText(button.transform as RectTransform, "View and control updates for installed mods");
                }

                yield break;
            }
        }
        public void Init(Sprite icon, string name, string version, string author, string description, PluginLoader.PluginMetadata updateInfo, PluginManifest.LinksObject links = null, bool showEnDis = false, ModListFlowCoordinator mlfc = null)
        {
            showEnableDisable      = showEnDis;
            Plugin.OnConfigChaned -= OptHideButton;

            Icon        = icon;
            Name        = name;
            Version     = version;
            Author      = author;
            Description = description;
            UpdateInfo  = updateInfo;

            enabled = !PluginManager.IsDisabled(updateInfo);

            flowController = mlfc;

            if (rowTransformOriginal == null)
            {
                rowTransformOriginal = MenuButtonUI.Instance.GetPrivateField <RectTransform>("menuButtonsOriginal");
            }

            // i also have no clue why this is necessary
            rectTransform.anchorMin = new Vector2(0f, 0f);
            rectTransform.anchorMax = new Vector2(0.5f, 1f);

            var go = new GameObject("Info View", typeof(RectTransform));

            go.SetActive(false);
            go.AddComponent <RectMask2D>();
            view = go.AddComponent <ModInfoView>();
            var rt = view.transform as RectTransform;

            rt.SetParent(transform);
            rt.anchorMin        = new Vector2(0f, 0f);
            rt.anchorMax        = new Vector2(1f, 1f);
            rt.anchoredPosition = new Vector2(0f, 0);
            view.Init(this);
            go.SetActive(true);

            if (showEnDis)
            {
                restartMessage          = BeatSaberUI.CreateText(rectTransform, "A restart is required to apply", new Vector2(11f, 33.5f));
                restartMessage.fontSize = 4f;
                restartMessage.gameObject.SetActive(false);

                enableDisableButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(33, 32), new Vector2(25, 10), ToggleEnable);
                enableDisableButton.GetComponentInChildren <StartMiddleEndButtonBackgroundController>().SetMiddleSprite();
                UpdateButtonText();

                Plugin.OnConfigChaned += OptHideButton;
                OptHideButton(Plugin.config.Value);
            }

            SetupLinks(links);
        }