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.

44 lines
1.2 KiB

  1. using IPA.Config;
  2. using IPA.Config.Stores;
  3. using IPA.Config.Stores.Attributes;
  4. using IPA.Config.Stores.Converters;
  5. using IPA.Utilities;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace IPA.Loader
  12. {
  13. internal class DisabledConfig
  14. {
  15. public static Config.Config Disabled { get; set; }
  16. public static DisabledConfig Instance;
  17. public static void Load()
  18. {
  19. Disabled = Config.Config.GetConfigFor("Disabled Mods", "json");
  20. Instance = Disabled.Generated<DisabledConfig>();
  21. }
  22. public virtual bool Reset { get; set; } = true;
  23. [NonNullable]
  24. [UseConverter(typeof(CollectionConverter<string, HashSet<string>>))]
  25. public virtual HashSet<string> DisabledModIds { get; set; } = new HashSet<string>();
  26. protected internal virtual void Changed() { }
  27. protected internal virtual IDisposable ChangeTransaction() => null;
  28. protected virtual void OnReload()
  29. {
  30. if (DisabledModIds == null || Reset)
  31. {
  32. DisabledModIds = new HashSet<string>();
  33. Reset = false;
  34. }
  35. }
  36. }
  37. }