HaloSPV3/HXE

Add descriptions to all config settings

BinToss opened this issue · 2 comments

Add descriptions to all config settings

Descriptions

Remember to add Descriptions to the Blam fields and properties in addition to Configuration properties!

We'll use the built-in Descriptions attribute e.g.

[Description("Description of Number.")]
public int Number { get; set; }

To make this easier on ourselves, we can use ProductivityTools.DescriptionValue

Category Tags/Flags

To help with sorting, organizing, or searching settings, we should use the built-in Category attribute.

Some settings may need to be in multiple categories e.g. Auto-Uncrouch will need to be in both Input and Chimera.

How does one append more categories during runtime? This could be used by other apps or libraries to add more categories as needed.


old ideas

Old "Flag enum" Categories. Use Abstract and implementing classes instead.

If Flag enum, how should the enums value be defined?
UInt for that extra digit.

Remember: use Enum.HasFlag(enum) for less work

[Flags]
public enum BaseCategories : uint
{
    None = 0,
    Kernel = 1,
    Tweaks = 1 << 1,
    Video = 1 << 2,
    Audio = 1 << 3,
    Input = 1 << 4,
    Chimera = 1 << 5,
    OpenSauce = 1 << 6,
    PostProcessing = 1 << 7,
}
Old "Type with Description property". Use Description attribute instead.
internal abstract class CfgSetting
{
  public abstract string Description {get;}
  public abstract string Name {get;}
}
public abstract class CfgBoolean : CfgSetting
{
  public CfgBoolean(string name, string desc, bool newValue);
  public bool Value {get;set;}
}
public class CfgString : CfgSetting
{
  public CfgString(string name, string desc, bool newValue);
  public bool Value {get;set;}
}

CfgString SavegamesPath = new CfgString("SavegamesPath")

Miris:

instead of storing the value in an enum, why not store it in a constant within the class?
(this is where abstract works!)

public abstract class CfgSettingBase
{
  public abstract int    ID          { get; }
  public abstract string Name        { get; }
  public abstract string Description { get; }
  public          int    Value       { get; set; }
}

public class SomeCfgSetting : CfgSettingBase
{
  public override int ID              { get; } = 1;
  public override string Name         { get; } = "some name";
  public override string Description  { get; } = "and a description";
}

var setting = SomeCfgSetting();
setting.Value = 4;

Console.WriteLine(setting.Name); // some name
Console.WriteLine(Value); // 4

Miris:

ah actually, you won't even need constants
just check the object type
...but still need to match each Mode to 0, 1, or 2.

public abstract class ConfigurationMode
{
  public abstract string Name        { get; }
  public abstract string Description { get; }
}

public class HceConfigurationMode : ConfigurationMode
{
  public override string Name         { get; } = "HCE";
  public override string Description  { get; } = "Launch HXE in HCE mode";
}

public class Spv32ConfigurationMode : ConfigurationMode
{
  public override string Name         { get; } = "SPV32";
  public override string Description  { get; } = "Launch HXE in SPV3.2 mode";
}

ConfigurationMode mode = new HceConfigurationMode();

if (mode.TypeOf(HceConfigurationMode)) {
  // HCE Configuration Mode!
}

Some settings may need to be in multiple categories e.g. Auto-Uncrouch will need to be in both Input and Chimera.
A Tags or Categories property should work.
Should the property be a Flag Enum, String collection, or something else?

If Flag enum, how should the enums value be defined?
UInt for that extra digit.

[Flags]
public enum BaseCategories : uint
{
    None = 0,
    Kernel = 1,
    Tweaks = 1 << 1,
    Video = 1 << 2,
    Audio = 1 << 3,
    Input = 1 << 4,
    Chimera = 1 << 5,
    OpenSauce = 1 << 6,
    PostProcessing = 1 << 7,
}

Remember: use Enum.HasFlag(enum) for less work!

How does one append more categories during runtime? This could be used by other apps or libraries to add more categories as needed.

Remember to add Descriptions to the blam fields and properties!