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.

105 lines
3.7 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. // This option only takes effect after a full game restart, unless new logs are created again
  60. public bool CondenseModLogs = false;
  61. // LINE: ignore 2
  62. public static bool CondenseModLogs_ => SelfConfigRef.Value.Debug.CondenseModLogs
  63. && CommandLineValues.Debug.CondenseModLogs;
  64. public bool ShowHandledErrorStackTraces = false;
  65. // LINE: ignore
  66. public static bool ShowHandledErrorStackTraces_ => SelfConfigRef.Value.Debug.ShowHandledErrorStackTraces;
  67. public bool HideMessagesForPerformance = true;
  68. // LINE: ignore
  69. public static bool HideMessagesForPerformance_ => SelfConfigRef.Value.Debug.HideMessagesForPerformance;
  70. public int HideLogThreshold = 512;
  71. // LINE: ignore
  72. public static int HideLogThreshold_ => SelfConfigRef.Value.Debug.HideLogThreshold;
  73. }
  74. public Debug_ Debug = new Debug_();
  75. public bool YeetMods = true;
  76. // LINE: ignore 2
  77. public static bool YeetMods_ => SelfConfigRef.Value.YeetMods
  78. && CommandLineValues.YeetMods;
  79. [JsonProperty(Required = Required.Default)]
  80. public string LastGameVersion = null;
  81. // LINE: ignore
  82. public static string LastGameVersion_ => SelfConfigRef.Value.LastGameVersion;
  83. }
  84. }