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.

99 lines
3.3 KiB

  1. // BEGIN: section ignore
  2. using IPA.Logging;
  3. using IPA.Utilities;
  4. // END: section ignore
  5. using Newtonsoft.Json;
  6. namespace IPA.Config
  7. {
  8. internal class SelfConfig
  9. {
  10. // This is to allow the doc generation to parse this file and use Newtonsoft to generate a JSON schema
  11. // BEGIN: section ignore
  12. private static IConfigProvider _loaderConfig;
  13. public static IConfigProvider LoaderConfig
  14. {
  15. get => _loaderConfig;
  16. set
  17. {
  18. _loaderConfig?.RemoveLinks();
  19. value.Load();
  20. SelfConfigRef = value.MakeLink<SelfConfig>((c, v) =>
  21. {
  22. if (v.Value.Regenerate)
  23. c.Store(v.Value = new SelfConfig { Regenerate = false });
  24. StandardLogger.Configure(v.Value);
  25. });
  26. _loaderConfig = value;
  27. }
  28. }
  29. public static Ref<SelfConfig> SelfConfigRef;
  30. public static void Load()
  31. {
  32. LoaderConfig = Config.GetProviderFor(IPAName, "json");
  33. }
  34. internal const string IPAName = "Beat Saber IPA";
  35. internal const string IPAVersion = "3.12.25";
  36. // uses Updates.AutoCheckUpdates, YeetMods
  37. internal static SelfConfig CommandLineValues = new SelfConfig();
  38. // END: section ignore
  39. public bool Regenerate = true;
  40. public class Updates_
  41. {
  42. public bool AutoUpdate = true;
  43. // LINE: ignore
  44. public static bool AutoUpdate_ => SelfConfigRef.Value.Updates.AutoUpdate;
  45. public bool AutoCheckUpdates = true;
  46. // LINE: ignore 2
  47. public static bool AutoCheckUpdates_ => SelfConfigRef.Value.Updates.AutoCheckUpdates
  48. && CommandLineValues.Updates.AutoCheckUpdates;
  49. }
  50. public Updates_ Updates = new Updates_();
  51. public class Debug_
  52. {
  53. public bool ShowCallSource = false;
  54. // LINE: ignore
  55. public static bool ShowCallSource_ => SelfConfigRef.Value.Debug.ShowCallSource;
  56. public bool ShowDebug = false;
  57. // LINE: ignore
  58. public static bool ShowDebug_ => SelfConfigRef.Value.Debug.ShowDebug;
  59. public bool ShowHandledErrorStackTraces = false;
  60. // LINE: ignore
  61. public static bool ShowHandledErrorStackTraces_ => SelfConfigRef.Value.Debug.ShowHandledErrorStackTraces;
  62. public bool HideMessagesForPerformance = true;
  63. // LINE: ignore
  64. public static bool HideMessagesForPerformance_ => SelfConfigRef.Value.Debug.HideMessagesForPerformance;
  65. public int HideLogThreshold = 512;
  66. // LINE: ignore
  67. public static int HideLogThreshold_ => SelfConfigRef.Value.Debug.HideLogThreshold;
  68. }
  69. public Debug_ Debug = new Debug_();
  70. public bool YeetMods = true;
  71. // LINE: ignore 2
  72. public static bool YeetMods_ => SelfConfigRef.Value.YeetMods
  73. && CommandLineValues.YeetMods;
  74. [JsonProperty(Required = Required.Default)]
  75. public string LastGameVersion = null;
  76. // LINE: ignore
  77. public static string LastGameVersion_ => SelfConfigRef.Value.LastGameVersion;
  78. }
  79. }