Browse Source

Enable/Disable button now hidden by default behind settings option

pull/13/head
Anairkoen Schno 5 years ago
parent
commit
ee1a1c73ac
5 changed files with 58 additions and 10 deletions
  1. +2
    -2
      BSIPA-ModList/DownloadController.cs
  2. +24
    -1
      BSIPA-ModList/Plugin.cs
  3. +14
    -0
      BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs
  4. +17
    -6
      BSIPA-ModList/UI/ViewControllers/SettingsViewController.cs
  5. +1
    -1
      BSIPA-ModList/manifest.json

+ 2
- 2
BSIPA-ModList/DownloadController.cs View File

@ -41,7 +41,7 @@ namespace BSIPA_ModList
public static DownloadController Create()
{
var inst = new GameObject("BSIPA Modlist Download Controller").AddComponent<DownloadController>();
if (SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates)
if (IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates)
inst.StartCoroutine(inst.StartUpdateCheck());
return inst;
}
@ -149,7 +149,7 @@ namespace BSIPA_ModList
if (downloads.Count == 0)
OnAllDownloadsCompleted(false);
else if (SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate)
else if (IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate)
StartDownloads();
}


+ 24
- 1
BSIPA-ModList/Plugin.cs View File

@ -7,6 +7,9 @@ using IPA.Logging;
using BSIPA_ModList.UI.ViewControllers;
using System.Collections;
using IPA.Loader;
using IPA.Config;
using IPA.Utilities;
using System;
namespace BSIPA_ModList
{
@ -17,20 +20,40 @@ namespace BSIPA_ModList
internal static IPALogger md => log.GetChildLogger("MarkDown");
}
internal class SelfConfig
{
public bool Regenerate = true;
public bool ShowEnableDisable = false;
}
/// <summary>
/// The main plugin type for the in-game mod list mod.
/// </summary>
internal class Plugin : IBeatSaberPlugin
{
internal static IConfigProvider provider;
internal static Ref<SelfConfig> config;
internal static event Action<SelfConfig> OnConfigChaned;
/// <summary>
/// Initializes the plugin with certain parameters. Is only called once.
///
/// This is called by the plugin loader in BSIPA, and thus must be <see langword="public"/>.
/// </summary>
/// <param name="logger">a logger to initialize the plugin with</param>
public void Init(IPALogger logger)
public void Init(IPALogger logger, IConfigProvider provider)
{
Logger.log = logger;
Plugin.provider = provider;
config = provider.MakeLink<SelfConfig>((p, r) =>
{
if (r.Value.Regenerate)
p.Store(r.Value = new SelfConfig { Regenerate = false });
OnConfigChaned?.Invoke(r.Value);
});
IPA.Updating.BeatMods.Updater.ModListPresent = true;


+ 14
- 0
BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs View File

@ -45,6 +45,7 @@ namespace BSIPA_ModList.UI
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;
@ -85,11 +86,24 @@ namespace BSIPA_ModList.UI
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);
}
~ModInfoViewController()
{
Plugin.OnConfigChaned -= OptHideButton;
}
private void OptHideButton(SelfConfig cfg)
{
enableDisableButton?.gameObject.SetActive(cfg.ShowEnableDisable);
}
private Action setAction = () => { };
private void ToggleEnable()
{


+ 17
- 6
BSIPA-ModList/UI/ViewControllers/SettingsViewController.cs View File

@ -9,6 +9,7 @@ namespace BSIPA_ModList.UI
private static SubMenu menu;
private static BoolViewController autoUpdate;
private static BoolViewController autoCheck;
private static BoolViewController showEnableDisable;
public static VRUIViewController Create()
{
@ -16,25 +17,35 @@ namespace BSIPA_ModList.UI
autoCheck = menu.AddBool("Auto Update Check", "If enabled, automatically checks for updates on game start.");
autoUpdate = menu.AddBool("Auto Update", "If enabled, automatically installs updates after checking for them.");
showEnableDisable = menu.AddBool("Show Enable/Disable Button", "If enabled, BSIPA mods will have a button to enable or disable them.");
autoCheck.applyImmediately = true;
autoCheck.GetValue += () => SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates;
autoCheck.GetValue += () => IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates;
autoCheck.SetValue += val =>
{
SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates = val;
SelfConfig.LoaderConfig.Store(SelfConfig.SelfConfigRef.Value);
IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates = val;
IPA.Config.SelfConfig.LoaderConfig.Store(IPA.Config.SelfConfig.SelfConfigRef.Value);
};
autoUpdate.applyImmediately = true;
autoUpdate.GetValue += () => SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate;
autoUpdate.GetValue += () => IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate;
autoUpdate.SetValue += val =>
{
SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate = val;
SelfConfig.LoaderConfig.Store(SelfConfig.SelfConfigRef.Value);
IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate = val;
IPA.Config.SelfConfig.LoaderConfig.Store(IPA.Config.SelfConfig.SelfConfigRef.Value);
};
showEnableDisable.applyImmediately = true;
showEnableDisable.GetValue += () => Plugin.config.Value.ShowEnableDisable;
showEnableDisable.SetValue += val =>
{
Plugin.config.Value.ShowEnableDisable = val;
Plugin.provider.Store(Plugin.config.Value);
};
autoCheck.Init();
autoUpdate.Init();
showEnableDisable.Init();
return menu.viewController;
}


+ 1
- 1
BSIPA-ModList/manifest.json View File

@ -14,7 +14,7 @@
"version": "1.2.5",
"icon": "BSIPA_ModList.Icons.self.png",
"dependsOn": {
"BSIPA": "^3.12.19",
"BSIPA": "^3.12.22",
"CustomUI": "^1.5.4"
},
"features": [],


Loading…
Cancel
Save