EverestAPI / EverestAPI/Everest

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

Open
#1,064 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
516
Forks
106
Avg merge
4d 9h
Merged PRs (30d)
5

Description

### 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:
```cs
[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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.