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.

64 lines
1.9 KiB

  1. using IPA.Logging;
  2. using IPA.Utilities;
  3. namespace IPA.Config
  4. {
  5. internal class SelfConfig
  6. {
  7. private static IConfigProvider _loaderConfig;
  8. private static void ConfigFileChangeDelegate(IConfigProvider configProvider, Ref<SelfConfig> selfConfigRef)
  9. {
  10. if (selfConfigRef.Value.Regenerate)
  11. configProvider.Store(selfConfigRef.Value = new SelfConfig { Regenerate = false });
  12. StandardLogger.Configure(selfConfigRef.Value);
  13. }
  14. public static IConfigProvider LoaderConfig
  15. {
  16. get => _loaderConfig;
  17. set
  18. {
  19. _loaderConfig?.RemoveLinks();
  20. value.Load();
  21. // This will set the instance reference to update to a
  22. // new instance every time the config file changes
  23. SelfConfigRef = value.MakeLink<SelfConfig>(ConfigFileChangeDelegate);
  24. _loaderConfig = value;
  25. }
  26. }
  27. public static Ref<SelfConfig> SelfConfigRef;
  28. public static void Set()
  29. {
  30. LoaderConfig = Config.GetProviderFor(IPAName, "json");
  31. }
  32. internal const string IPAName = "Beat Saber IPA";
  33. internal const string IPAVersion = "3.12.16";
  34. public bool Regenerate = true;
  35. public bool ApplyAntiYeet = false;
  36. public class UpdateObject
  37. {
  38. public bool AutoUpdate = true;
  39. public bool AutoCheckUpdates = true;
  40. }
  41. public UpdateObject Updates = new UpdateObject();
  42. public class DebugObject
  43. {
  44. public bool ShowCallSource = false;
  45. public bool ShowDebug = false;
  46. public bool ShowHandledErrorStackTraces = false;
  47. public bool HideMessagesForPerformance = true;
  48. public int HideLogThreshold = 512;
  49. }
  50. public DebugObject Debug = new DebugObject();
  51. }
  52. }