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.

78 lines
2.7 KiB

  1. using System.Collections.Generic;
  2. using System.Runtime.CompilerServices;
  3. using IPA.Config.Stores;
  4. using IPA.Config.Stores.Attributes;
  5. using IPA.Config.Stores.Converters;
  6. [assembly: InternalsVisibleTo(GeneratedStore.AssemblyVisibilityTarget)]
  7. namespace Demo
  8. {
  9. /*
  10. public class PluginConfig
  11. */
  12. internal class PluginConfig
  13. {
  14. public static PluginConfig Instance { get; set; }
  15. public class SubThingsObject
  16. {
  17. /*
  18. public double DoubleValue { get; set; } = 2.718281828459045;
  19. */
  20. public virtual double DoubleValue { get; set; } = 2.718281828459045;
  21. }
  22. /*
  23. public int IntValue { get; set; } = 42;
  24. public float FloatValue { get; set; } = 3.14159f;
  25. [NonNullable]
  26. public SubThingsObject SubThings { get; set; } = new SubThingsObject();
  27. [UseConverter(typeof(ListConverter<string>))]
  28. public List<string> ListValue { get; set; } = new List<string>();
  29. [UseConverter(typeof(CollectionConverter<string, HashSet<string>>))]
  30. public HashSet<string> SetValue { get; set; } = new HashSet<string>();
  31. */
  32. public virtual int IntValue { get; set; } = 42;
  33. public virtual float FloatValue { get; set; } = 3.14159f;
  34. [NonNullable]
  35. public virtual SubThingsObject SubThings { get; set; } = new SubThingsObject();
  36. [UseConverter(typeof(ListConverter<string>))]
  37. public virtual List<string> ListValue { get; set; } = new List<string>();
  38. [UseConverter(typeof(CollectionConverter<string, HashSet<string>>))]
  39. public virtual HashSet<string> SetValue { get; set; } = new HashSet<string>();
  40. public virtual void Changed()
  41. {
  42. // this is called whenever one of the virtual properties is changed
  43. // can be called to signal that the content has been changed
  44. }
  45. public virtual void OnReload()
  46. {
  47. // this is called whenever the config file is reloaded from disk
  48. // use it to tell all of your systems that something has changed
  49. // this is called off of the main thread, and is not safe to interact
  50. // with Unity in
  51. }
  52. public virtual void CopyFrom(PluginConfig cfg)
  53. {
  54. // you can call this to copy the structure from the parameter to this object
  55. // think of this as a magic function that "just works", and doesn't actually
  56. // have to have a body.
  57. // any code you put here will be called after the copy is complete though
  58. }
  59. }
  60. }