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.

131 lines
5.3 KiB

  1. // BEGIN: section ignore
  2. using IPA.Logging;
  3. using IPA.Utilities;
  4. using IPA.Config.Stores;
  5. // END: section ignore
  6. using Newtonsoft.Json;
  7. namespace IPA.Config
  8. {
  9. internal class SelfConfig
  10. {
  11. // This is to allow the doc generation to parse this file and use Newtonsoft to generate a JSON schema
  12. // BEGIN: section ignore
  13. public static Config LoaderConfig { get; set; }
  14. public static SelfConfig Instance = new SelfConfig();
  15. public static void Load()
  16. {
  17. LoaderConfig = Config.GetConfigFor(IPAName, "json");
  18. Instance = LoaderConfig.Generated<SelfConfig>();
  19. }
  20. protected internal virtual void OnReload()
  21. {
  22. StandardLogger.Configure(this);
  23. }
  24. public static void ReadCommandLine(string[] args)
  25. {
  26. foreach (var arg in args)
  27. {
  28. switch (arg)
  29. {
  30. case "--debug":
  31. case "--mono-debug":
  32. CommandLineValues.Debug.ShowDebug = true;
  33. CommandLineValues.Debug.ShowCallSource = true;
  34. break;
  35. case "--no-yeet":
  36. CommandLineValues.YeetMods = false;
  37. break;
  38. case "--condense-logs":
  39. CommandLineValues.Debug.CondenseModLogs = true;
  40. break;
  41. case "--no-updates":
  42. CommandLineValues.Updates.AutoCheckUpdates = false;
  43. CommandLineValues.Updates.AutoUpdate = false;
  44. break;
  45. case "--trace":
  46. CommandLineValues.Debug.ShowTrace = true;
  47. break;
  48. }
  49. }
  50. }
  51. internal const string IPAName = "Beat Saber IPA";
  52. internal const string IPAVersion = "3.99.99.0";
  53. // uses Updates.AutoUpdate, Updates.AutoCheckUpdates, YeetMods, Debug.ShowCallSource, Debug.ShowDebug,
  54. // Debug.CondenseModLogs
  55. internal static SelfConfig CommandLineValues = new SelfConfig();
  56. // END: section ignore
  57. public virtual bool Regenerate { get; set; } = true;
  58. public class Updates_
  59. {
  60. public virtual bool AutoUpdate { get; set; } = true;
  61. // LINE: ignore 2
  62. public static bool AutoUpdate_ => (Instance?.Updates?.AutoUpdate ?? true)
  63. && CommandLineValues.Updates.AutoUpdate;
  64. public virtual bool AutoCheckUpdates { get; set; } = true;
  65. // LINE: ignore 2
  66. public static bool AutoCheckUpdates_ => (Instance?.Updates?.AutoCheckUpdates ?? true)
  67. && CommandLineValues.Updates.AutoCheckUpdates;
  68. }
  69. public virtual Updates_ Updates { get; set; } = new Updates_();
  70. public class Debug_
  71. {
  72. public virtual bool ShowCallSource { get; set; } = false;
  73. // LINE: ignore 2
  74. public static bool ShowCallSource_ => (Instance?.Debug?.ShowCallSource ?? false)
  75. || CommandLineValues.Debug.ShowCallSource;
  76. public virtual bool ShowDebug { get; set; } = false;
  77. // LINE: ignore 2
  78. public static bool ShowDebug_ => (Instance?.Debug?.ShowDebug ?? false)
  79. || CommandLineValues.Debug.ShowDebug;
  80. // This option only takes effect after a full game restart, unless new logs are created again
  81. public virtual bool CondenseModLogs { get; set; } = false;
  82. // LINE: ignore 2
  83. public static bool CondenseModLogs_ => (Instance?.Debug?.CondenseModLogs ?? false)
  84. || CommandLineValues.Debug.CondenseModLogs;
  85. public virtual bool ShowHandledErrorStackTraces { get; set; } = false;
  86. // LINE: ignore
  87. public static bool ShowHandledErrorStackTraces_ => Instance?.Debug?.ShowHandledErrorStackTraces ?? false;
  88. public virtual bool HideMessagesForPerformance { get; set; } = true;
  89. // LINE: ignore
  90. public static bool HideMessagesForPerformance_ => Instance?.Debug?.HideMessagesForPerformance ?? true;
  91. public virtual int HideLogThreshold { get; set; } = 512;
  92. // LINE: ignore
  93. public static int HideLogThreshold_ => Instance?.Debug?.HideLogThreshold ?? 512;
  94. public virtual bool ShowTrace { get; set; } = false;
  95. // LINE: ignore 2
  96. public static bool ShowTrace_ => (Instance?.Debug?.ShowTrace ?? false)
  97. || CommandLineValues.Debug.ShowTrace;
  98. }
  99. public virtual Debug_ Debug { get; set; } = new Debug_();
  100. public virtual bool YeetMods { get; set; } = true;
  101. // LINE: ignore 2
  102. public static bool YeetMods_ => (Instance?.YeetMods ?? true)
  103. && CommandLineValues.YeetMods;
  104. [JsonProperty(Required = Required.Default)]
  105. public virtual string LastGameVersion { get; set; } = null;
  106. // LINE: ignore
  107. public static string LastGameVersion_ => Instance?.LastGameVersion;
  108. }
  109. }