Skip to content

Commit 3fd82a4

Browse files
committed
Fixed throw on EnumSetting.PrettyName
1 parent 0f5dc99 commit 3fd82a4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

RuriLib/Models/Blocks/Settings/EnumSetting.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public Type EnumType
2727
set
2828
{
2929
_enumType = value;
30-
30+
3131
// Populate the enum values dictionary (used to have nicer enum names to display)
3232
foreach (var name in _enumType.GetEnumNames())
3333
{
@@ -54,11 +54,14 @@ public Type EnumType
5454
/// The pretty names of the enum values.
5555
/// </summary>
5656
public IEnumerable<string> PrettyNames => _enumValues.Keys;
57-
57+
5858
/// <summary>
5959
/// The pretty name of the current value.
6060
/// </summary>
61-
public string PrettyName => _enumValues.First(kvp => kvp.Value == Value).Key;
61+
public string PrettyName
62+
=> _enumValues.ContainsValue(Value)
63+
? _enumValues.First(kvp => kvp.Value == Value).Key
64+
: Value;
6265

6366
/// <summary>
6467
/// Sets the value of the setting from a pretty name.

0 commit comments

Comments
 (0)