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.

126 lines
4.7 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. public static void ReadCommandLine(string[] args)
  21. {
  22. foreach (var arg in args)
  23. {
  24. switch (arg)
  25. {
  26. case "--debug":
  27. case "--mono-debug":
  28. CommandLineValues.Debug.ShowDebug = true;
  29. CommandLineValues.Debug.ShowCallSource = true;
  30. break;
  31. case "--no-yeet":
  32. CommandLineValues.YeetMods = false;
  33. break;
  34. case "--condense-logs":
  35. CommandLineValues.Debug.CondenseModLogs = true;
  36. break;
  37. case "--no-updates":
  38. CommandLineValues.Updates.AutoCheckUpdates = false;
  39. CommandLineValues.Updates.AutoUpdate = false;
  40. break;
  41. case "--trace":
  42. CommandLineValues.Debug.ShowTrace = true;
  43. break;
  44. }
  45. }
  46. }
  47. internal const string IPAName = "Beat Saber IPA";
  48. internal const string IPAVersion = "3.99.99.0";
  49. // uses Updates.AutoUpdate, Updates.AutoCheckUpdates, YeetMods, Debug.ShowCallSource, Debug.ShowDebug,
  50. // Debug.CondenseModLogs
  51. internal static SelfConfig CommandLineValues = new SelfConfig();
  52. // END: section ignore
  53. public bool Regenerate = true;
  54. public class Updates_
  55. {
  56. public bool AutoUpdate = true;
  57. // LINE: ignore 2
  58. public static bool AutoUpdate_ => Instance.Updates.AutoUpdate
  59. && CommandLineValues.Updates.AutoUpdate;
  60. public bool AutoCheckUpdates = true;
  61. // LINE: ignore 2
  62. public static bool AutoCheckUpdates_ => Instance.Updates.AutoCheckUpdates
  63. && CommandLineValues.Updates.AutoCheckUpdates;
  64. }
  65. public Updates_ Updates = new Updates_();
  66. public class Debug_
  67. {
  68. public bool ShowCallSource = false;
  69. // LINE: ignore 2
  70. public static bool ShowCallSource_ => Instance.Debug.ShowCallSource
  71. || CommandLineValues.Debug.ShowCallSource;
  72. public bool ShowDebug = false;
  73. // LINE: ignore 2
  74. public static bool ShowDebug_ => Instance.Debug.ShowDebug
  75. || CommandLineValues.Debug.ShowDebug;
  76. // This option only takes effect after a full game restart, unless new logs are created again
  77. public bool CondenseModLogs = false;
  78. // LINE: ignore 2
  79. public static bool CondenseModLogs_ => Instance?.Debug.CondenseModLogs ?? false
  80. || CommandLineValues.Debug.CondenseModLogs;
  81. public bool ShowHandledErrorStackTraces = false;
  82. // LINE: ignore
  83. public static bool ShowHandledErrorStackTraces_ => Instance.Debug.ShowHandledErrorStackTraces;
  84. public bool HideMessagesForPerformance = true;
  85. // LINE: ignore
  86. public static bool HideMessagesForPerformance_ => Instance.Debug.HideMessagesForPerformance;
  87. public int HideLogThreshold = 512;
  88. // LINE: ignore
  89. public static int HideLogThreshold_ => Instance.Debug.HideLogThreshold;
  90. public bool ShowTrace = false;
  91. // LINE: ignore 2
  92. public static bool ShowTrace_ => Instance.Debug.ShowTrace
  93. || CommandLineValues.Debug.ShowTrace;
  94. }
  95. public Debug_ Debug = new Debug_();
  96. public bool YeetMods = true;
  97. // LINE: ignore 2
  98. public static bool YeetMods_ => Instance.YeetMods
  99. && CommandLineValues.YeetMods;
  100. [JsonProperty(Required = Required.Default)]
  101. public string LastGameVersion = null;
  102. // LINE: ignore
  103. public static string LastGameVersion_ => Instance.LastGameVersion;
  104. }
  105. }