mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Added ConfigName property to IModdedOptionList to optionally rename the individual options
This commit is contained in:
1 parent
ffe9194d54
commit
1b587547f7
3 files changed
+12
-1
No files matched your search
@@ -121,6 +121,12 @@ public interface IModdedOption
|
||||
/// </summary>
|
||||
public interface IModdedOptionList : IReadOnlyList<IModdedOption>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the function to name the keys of the individual options in the configuration file.
|
||||
/// <para/>
|
||||
/// Return <see langword="null"/> to use the default of the property's name with its index appended.
|
||||
/// </summary>
|
||||
Func<int, string>? ConfigName { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -198,9 +198,11 @@ public static class ModdedOptionsManager
|
||||
return;
|
||||
}
|
||||
|
||||
Func<int, string> configName = optionList.ConfigName ?? (i => property.Name + i);
|
||||
|
||||
for (int i = 0; i < optionList.Count; i++)
|
||||
{
|
||||
RegisterOption(optionList[i], group, property.Name + i, pluginInfo);
|
||||
RegisterOption(optionList[i], group, configName(i), pluginInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ public class ModdedOptionList<T> : IModdedOptionList
|
||||
/// </summary>
|
||||
public IReadOnlyList<T> Options { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Func<int, string>? ConfigName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModdedOptionList{T}"/> class.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user