1 using Microsoft.Xna.Framework;
3 using System.ComponentModel;
10 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Class)]
15 this.color =
new Color(r, g, b, a);
22 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Class)]
27 this.color =
new Color(r, g, b, a);
34 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
43 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Class)]
50 public string Label => label.StartsWith(
"$") ? Localization.Language.GetTextValue(label.Substring(1)) : label;
57 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
62 this.tooltip = tooltip;
64 public string Tooltip => tooltip.StartsWith(
"$") ? Localization.Language.GetTextValue(tooltip.Substring(1)) : tooltip;
71 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
78 public string Header => header.StartsWith(
"$") ? Localization.Language.GetTextValue(header.Substring(1)) : header;
84 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Class | AttributeTargets.Enum)]
107 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
113 this.value = TypeDescriptor.GetConverter(type).ConvertFromInvariantString(value);
116 Logging.tML.Error(
"Default value attribute of type " + type.FullName +
" threw converting from the string '" + value +
"'.");
131 public virtual object Value => value;
133 public override bool Equals(
object obj) {
140 return Value.
Equals(other.Value);
143 return (other.Value == null);
149 public override int GetHashCode() => base.GetHashCode();
159 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
165 this.value = TypeDescriptor.GetConverter(type).ConvertFromInvariantString(value);
168 Logging.tML.Error(
"Default value attribute of type " + type.FullName +
" threw converting from the string '" + value +
"'.");
183 public virtual object Value => value;
185 public override bool Equals(
object obj) {
192 return Value.
Equals(other.Value);
195 return (other.Value == null);
201 public override int GetHashCode() => base.GetHashCode();
211 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
234 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
246 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
249 public string[] optionLabels {
get;
set; }
251 this.optionLabels = optionLabels;
259 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
264 this.increment = increment;
267 this.increment = increment;
270 this.increment = increment;
273 this.increment = increment;
280 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
308 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
316 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
324 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
332 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
337 this.showSaturationAndLightness = showSaturationAndLightness;
344 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Class)]
352 [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Class)]
IncrementAttribute(float increment)
This attribute hints that changing the value of the annotated property or field will put the config i...
RangeAttribute(byte min, byte max)
Similar to DefaultListValueAttribute but for reference types. It uses a json string that will be used...
RangeAttribute(int min, int max)
IncrementAttribute(int increment)
Add this attribute and the sliders will show white tick marks at each increment.
JsonDefaultListValueAttribute(string json)
Defines the default key value to be added when using the ModConfig UI to add elements to a Dictionary...
Similar to JsonDefaultListValueAttribute, but for assigning to the Dictionary Key rather than the Val...
Use this attribute to specify a custom UI element to be used for the annotated property, field, or class in the ModConfig UI.
Defines the default value to be added when using the ModConfig UI to add elements to a Collection (Li...
This serves as the central class which loads mods. It contains many static fields and methods related...
LabelAttribute(string label)
JsonDefaultValueAttribute(string json)
override bool Equals(object obj)
Affects whether this data will be presented as a slider of an input field. Add this attribute to use ...
Specifies a range for primitive data values. Without this, default min and max are as follows: float:...
ColorHSLSliderAttribute(bool showSaturationAndLightness=true)
SliderColorAttribute(int r, int g, int b, int a=255)
Similar to DefaultValueAttribute but for reference types. It uses a json string that will be used pop...
IncrementAttribute(uint increment)
This specifies that the annotated item will appear as a button that leads to a separate page in the U...
JsonDefaultDictionaryKeyValueAttribute(string json)
This attribute sets a label for the property, field, or class for use in the ModConfig UI...
Specifies a background color to be used for the property, field, or class in the ModConfig UI...
RangeAttribute(float min, float max)
OptionStringsAttribute(string[] optionLabels)
Specifies a slider color for ModConfig elements that use a slider. The default color is white...
This attribute means the annotated item can possibly be null. This will allow the UI to make the item...
Add this attribute to a Color item and the UI will present a Hue, Saturation, and Lightness sliders r...
Add this attribute to a Color item and Alpha will not be presented in the UI and will remain as 255 u...
void SetValue(object value)
override bool Equals(object obj)
void SetValue(object value)
By default, string fields will provide the user with a text input field. Use this attribute to restri...
Use this to set an increment for sliders. The slider will move by the amount assigned. Remember that this is just a UI suggestion and manual editing of config files can specify other values, so validate your values. Defaults are: float: 0.01f - byte/int/uint: 1
bool showSaturationAndLightness
CustomModConfigItemAttribute(Type t)
DefaultListValueAttribute(Type type, string value)
IncrementAttribute(byte increment)
DefaultDictionaryKeyValueAttribute(Type type, string value)
BackgroundColorAttribute(int r, int g, int b, int a=255)
RangeAttribute(uint min, uint max)