Terraria ModLoader  0.11.1
A framework for Terraria mods
Terraria.ModLoader.Config.ConfigManager Class Reference
+ Collaboration diagram for Terraria.ModLoader.Config.ConfigManager:

Static Public Member Functions

static object AlternateCreateInstance (Type type)
 
static T GetCustomAttribute< T > (PropertyFieldWrapper memberInfo, object item, object array)
 
static IEnumerable< PropertyFieldWrapper > GetFieldsAndProperties (object item)
 
static void SetPendingChanges (bool changes=true)
 
static Tuple< UIElement, UIElement > WrapIt (UIElement parent, ref int top, PropertyFieldWrapper memberInfo, object item, int order, object list=null, Type arrayType=null, int index=-1)
 

Static Public Attributes

static readonly string ModConfigPath = Path.Combine(Main.SavePath, "Mod Configs")
 
static readonly JsonSerializerSettings serializerSettings
 
static readonly string ServerModConfigPath = Path.Combine(Main.SavePath, "Mod Configs", "Server")
 

Static Private Attributes

static readonly IList< JsonConverter > converters
 
static readonly IDictionary< Mod, List< ModConfig > > LoadTimeConfigs = new Dictionary<Mod, List<ModConfig>>()
 

Detailed Description

Definition at line 17 of file ConfigManager.cs.

Member Function Documentation

◆ AlternateCreateInstance()

static object Terraria.ModLoader.Config.ConfigManager.AlternateCreateInstance ( Type  type)
static

Definition at line 268 of file ConfigManager.cs.

269  {
270  if (type == typeof(string))
271  return "";
272  return Activator.CreateInstance(type);
273  }

◆ GetCustomAttribute< T >()

static T Terraria.ModLoader.Config.ConfigManager.GetCustomAttribute< T > ( PropertyFieldWrapper  memberInfo,
object  item,
object  array 
)
static
Type Constraints
T :Attribute 

Definition at line 277 of file ConfigManager.cs.

277  : Attribute {
278  // Class
279  T attribute = (T)Attribute.GetCustomAttribute(memberInfo.Type, typeof(T), true);
280  if (array != null)
281  {
282  // item null?
283  // attribute = (T)Attribute.GetCustomAttribute(item.GetType(), typeof(T), true) ?? attribute; // TODO: is this wrong?
284  }
285  // Member
286  attribute = (T)Attribute.GetCustomAttribute(memberInfo.MemberInfo, typeof(T)) ?? attribute;
287  return attribute;
288  }

◆ GetFieldsAndProperties()

static IEnumerable<PropertyFieldWrapper> Terraria.ModLoader.Config.ConfigManager.GetFieldsAndProperties ( object  item)
static

Definition at line 253 of file ConfigManager.cs.

Referenced by Terraria.ModLoader.Config.ModConfig.NeedsReload().

254  {
255  PropertyInfo[] properties = item.GetType().GetProperties(
256  //BindingFlags.DeclaredOnly |
257  BindingFlags.Public |
258  BindingFlags.Instance);
259 
260  FieldInfo[] fields = item.GetType().GetFields(
261  //BindingFlags.DeclaredOnly |
262  BindingFlags.Public |
263  BindingFlags.Instance);
264 
265  return fields.Select(x => new PropertyFieldWrapper(x)).Concat(properties.Select(x => new PropertyFieldWrapper(x)));
266  }
+ Here is the caller graph for this function:

◆ SetPendingChanges()

static void Terraria.ModLoader.Config.ConfigManager.SetPendingChanges ( bool  changes = true)
static

Definition at line 296 of file ConfigManager.cs.

296  {
297  // public api for modders.
298  Interface.modConfig.SetPendingChanges(changes);
299  }

◆ WrapIt()

static Tuple<UIElement, UIElement> Terraria.ModLoader.Config.ConfigManager.WrapIt ( UIElement  parent,
ref int  top,
PropertyFieldWrapper  memberInfo,
object  item,
int  order,
object  list = null,
Type  arrayType = null,
int  index = -1 
)
static

Definition at line 290 of file ConfigManager.cs.

291  {
292  // public api for modders.
293  return UIModConfig.WrapIt(parent, ref top, memberInfo, item, order, list, arrayType, index);
294  }

Member Data Documentation

◆ converters

readonly IList<JsonConverter> Terraria.ModLoader.Config.ConfigManager.converters
staticprivate
Initial value:
= new List<JsonConverter>() {
new Newtonsoft.Json.Converters.VersionConverter(),
}

Definition at line 45 of file ConfigManager.cs.

◆ LoadTimeConfigs

readonly IDictionary<Mod, List<ModConfig> > Terraria.ModLoader.Config.ConfigManager.LoadTimeConfigs = new Dictionary<Mod, List<ModConfig>>()
staticprivate

Definition at line 25 of file ConfigManager.cs.

◆ ModConfigPath

readonly string Terraria.ModLoader.Config.ConfigManager.ModConfigPath = Path.Combine(Main.SavePath, "Mod Configs")
static

Definition at line 50 of file ConfigManager.cs.

◆ serializerSettings

readonly JsonSerializerSettings Terraria.ModLoader.Config.ConfigManager.serializerSettings
static
Initial value:
= new JsonSerializerSettings
{
Formatting = Formatting.Indented,
DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
ObjectCreationHandling = ObjectCreationHandling.Replace,
NullValueHandling = NullValueHandling.Ignore,
Converters = converters,
}

Definition at line 27 of file ConfigManager.cs.

◆ ServerModConfigPath

readonly string Terraria.ModLoader.Config.ConfigManager.ServerModConfigPath = Path.Combine(Main.SavePath, "Mod Configs", "Server")
static

Definition at line 51 of file ConfigManager.cs.