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.

94 lines
3.0 KiB

5 years ago
  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. // END: section ignore
  37. public bool Regenerate = true;
  38. public class Updates_
  39. {
  40. public bool AutoUpdate = true;
  41. // LINE: ignore
  42. public static bool AutoUpdate_ => SelfConfigRef.Value.Updates.AutoUpdate;
  43. public bool AutoCheckUpdates = true;
  44. // LINE: ignore
  45. public static bool AutoCheckUpdates_ => SelfConfigRef.Value.Updates.AutoCheckUpdates;
  46. }
  47. public Updates_ Updates = new Updates_();
  48. public class Debug_
  49. {
  50. public bool ShowCallSource = false;
  51. // LINE: ignore
  52. public static bool ShowCallSource_ => SelfConfigRef.Value.Debug.ShowCallSource;
  53. public bool ShowDebug = false;
  54. // LINE: ignore
  55. public static bool ShowDebug_ => SelfConfigRef.Value.Debug.ShowDebug;
  56. public bool ShowHandledErrorStackTraces = false;
  57. // LINE: ignore
  58. public static bool ShowHandledErrorStackTraces_ => SelfConfigRef.Value.Debug.ShowHandledErrorStackTraces;
  59. public bool HideMessagesForPerformance = true;
  60. // LINE: ignore
  61. public static bool HideMessagesForPerformance_ => SelfConfigRef.Value.Debug.HideMessagesForPerformance;
  62. public int HideLogThreshold = 512;
  63. // LINE: ignore
  64. public static int HideLogThreshold_ => SelfConfigRef.Value.Debug.HideLogThreshold;
  65. }
  66. public Debug_ Debug = new Debug_();
  67. public bool YeetMods = true;
  68. // LINE: ignore
  69. public static bool YeetMods_ => SelfConfigRef.Value.YeetMods;
  70. [JsonProperty(Required = Required.Default)]
  71. public string LastGameVersion = null;
  72. // LINE: ignore
  73. public static string LastGameVersion_ => SelfConfigRef.Value.LastGameVersion;
  74. }
  75. }