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.

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