Skip to content

Allow mods to (more easily) create their own [SettingXYZ] attributes for use with mod settings #1064

@aonkeeper4

Description

@aonkeeper4

I am planning on implementing this myself

No

Describe your request

Creating lots of similar CreateXYZEntry methods for mod settings (to facilitate eg. custom input types) sucks, and modifying the settings' TextMenu after Everest has already created it also sucks. I propose there should be a way for mods to create their own [SettingsXYZ]-like attributes to avoid repetition in cases like these, for example:

[SettingInGame(false)]
[SettingFactory(CreateColorSetting, 1f, 1f, 1f)]
public Color MyColorSetting {get; set;} = Color.Red;

public TextMenu.Item CreateColorSetting(PropertyInfo propertyInfo, object?[] parameters)
{
    if (propertyInfo.PropertyType is not typeof(Color)) return;
    float rRange = (parameters[0] as float) ?? 0f, gRange = (parameters[1] as float) ?? 0f, bRange = (parameters[2] as float) ?? 0f;
    // ...
}

(this is very tentative - I have no clue how this API should be best designed; the signature of the factory method should probably be closer to that of the CreateXYZEntry methods I think)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions