You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.2 KiB

5 years ago
5 years ago
  1. using CustomUI.Settings;
  2. using IPA.Config;
  3. using VRUI;
  4. namespace BSIPA_ModList.UI
  5. {
  6. internal static class SettingsViewController
  7. {
  8. private static SubMenu menu;
  9. private static BoolViewController autoUpdate;
  10. private static BoolViewController autoCheck;
  11. private static BoolViewController showEnableDisable;
  12. public static VRUIViewController Create()
  13. {
  14. menu = SettingsUI.CreateSubMenu("ModListSettings", false);
  15. autoCheck = menu.AddBool("Auto Update Check", "If enabled, automatically checks for updates on game start.");
  16. autoUpdate = menu.AddBool("Auto Update", "If enabled, automatically installs updates after checking for them.");
  17. showEnableDisable = menu.AddBool("Show Enable/Disable Button", "If enabled, BSIPA mods will have a button to enable or disable them.");
  18. autoCheck.applyImmediately = true;
  19. autoCheck.GetValue += () => IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates;
  20. autoCheck.SetValue += val =>
  21. {
  22. IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates = val;
  23. IPA.Config.SelfConfig.LoaderConfig.Store(IPA.Config.SelfConfig.SelfConfigRef.Value);
  24. };
  25. autoUpdate.applyImmediately = true;
  26. autoUpdate.GetValue += () => IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate;
  27. autoUpdate.SetValue += val =>
  28. {
  29. IPA.Config.SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate = val;
  30. IPA.Config.SelfConfig.LoaderConfig.Store(IPA.Config.SelfConfig.SelfConfigRef.Value);
  31. };
  32. showEnableDisable.applyImmediately = true;
  33. showEnableDisable.GetValue += () => Plugin.config.Value.ShowEnableDisable;
  34. showEnableDisable.SetValue += val =>
  35. {
  36. Plugin.config.Value.ShowEnableDisable = val;
  37. Plugin.provider.Store(Plugin.config.Value);
  38. };
  39. autoCheck.Init();
  40. autoUpdate.Init();
  41. showEnableDisable.Init();
  42. return menu.viewController;
  43. }
  44. }
  45. }