Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add descriptions to all config settings #261

Open
BinToss opened this issue Jan 26, 2022 · 2 comments · May be fixed by #283
Open

Add descriptions to all config settings #261

BinToss opened this issue Jan 26, 2022 · 2 comments · May be fixed by #283
Labels
p:LOW Low Priority

Comments

@BinToss
Copy link
Member

BinToss commented Jan 26, 2022

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!
}
@BinToss BinToss linked a pull request Mar 6, 2022 that will close this issue
@BinToss BinToss added the p:LOW Low Priority label Mar 18, 2022
@BinToss BinToss changed the title refactor: add descriptions to all config settings Add descriptions to all config settings Mar 18, 2022
@BinToss
Copy link
Member Author

BinToss commented Apr 5, 2022

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.

@BinToss
Copy link
Member Author

BinToss commented May 2, 2022

Remember to add Descriptions to the blam fields and properties!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p:LOW Low Priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant