mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +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>
|
/// </summary>
|
||||||
public interface IModdedOptionList : IReadOnlyList<IModdedOption>
|
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>
|
/// <summary>
|
||||||
|
|||||||
@@ -198,9 +198,11 @@ public static class ModdedOptionsManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Func<int, string> configName = optionList.ConfigName ?? (i => property.Name + i);
|
||||||
|
|
||||||
for (int i = 0; i < optionList.Count; 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>
|
/// </summary>
|
||||||
public IReadOnlyList<T> Options { get; }
|
public IReadOnlyList<T> Options { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Func<int, string>? ConfigName { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ModdedOptionList{T}"/> class.
|
/// Initializes a new instance of the <see cref="ModdedOptionList{T}"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in new issue
Block a user