-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathCustomAttributes.cs
More file actions
73 lines (65 loc) · 2.64 KB
/
CustomAttributes.cs
File metadata and controls
73 lines (65 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using RT.Util;
namespace KtaneWeb
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
internal sealed class KtaneFilterOptionAttribute : Attribute
{
public string TranslationString { get; private set; }
public char? Accel { get; private set; }
public KtaneFilterOptionAttribute(string translationString)
{
TranslationString = translationString;
Accel = null;
}
public KtaneFilterOptionAttribute(string translationString, char accel)
{
TranslationString = translationString;
Accel = accel;
}
public string Translate(TranslationInfo translation) => translation.GetFieldValue<string>(TranslationString);
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
internal sealed class KtaneSouvenirInfoAttribute(char ch, string tooltip) : Attribute
{
public char Char { get; private set; } = ch;
public string Tooltip { get; private set; } = tooltip;
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
internal sealed class EditableFieldAttribute : Attribute
{
public string ReadableName { get; private set; }
public string Explanation { get; private set; }
public bool Multiline { get; set; }
public char[] AllowedSeparators { get; set; }
public char[] AllowedDictSeparators { get; set; }
public string DefaultKey { get; set; }
public EditableFieldAttribute(string readable, string explanation = null)
{
ReadableName = readable;
Explanation = explanation;
AllowedSeparators ??= [';'];
AllowedDictSeparators ??= [':'];
DefaultKey ??= "default";
}
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
internal sealed class EditableIfAttribute(string otherField, params object[] values) : Attribute
{
public string OtherField { get; private set; } = otherField;
public object[] Values { get; private set; } = values;
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
internal sealed class EditableNestedAttribute : Attribute
{
public EditableNestedAttribute()
{
}
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
internal sealed class EditableHelpAttribute(string translationString) : Attribute
{
public string TranslationString { get; private set; } = translationString;
public string Translate(TranslationInfo translation) => translation.GetFieldValue<string>(TranslationString);
}
}