mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-29 15:58:33 +01:00
Compare commits
No commits in common. "2df9d6a3a80fd597e25bad718e0478773dc5cc87" and "f58e3c94d5b3c176d52419d81c2239570cb1486e" have entirely different histories.
2df9d6a3a8
...
f58e3c94d5
28 changed files with 20 additions and 118 deletions
|
@ -23,7 +23,6 @@ Improvements
|
||||||
- Discard old data when updating a StaticSpriteBatch
|
- Discard old data when updating a StaticSpriteBatch
|
||||||
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
||||||
- Allow retrieving the cost of a calculated path when using AStar
|
- Allow retrieving the cost of a calculated path when using AStar
|
||||||
- Added trimming and AOT annotations and made MLEM trimmable
|
|
||||||
- **Drastically improved StaticSpriteBatch batching performance**
|
- **Drastically improved StaticSpriteBatch batching performance**
|
||||||
- **Made GenericFont and TokenizedString support UTF-32 characters like emoji**
|
- **Made GenericFont and TokenizedString support UTF-32 characters like emoji**
|
||||||
|
|
||||||
|
@ -49,7 +48,6 @@ Improvements
|
||||||
- Close other dropdowns when opening a dropdown
|
- Close other dropdowns when opening a dropdown
|
||||||
- Generified UiMarkdownParser by adding abstract UiParser
|
- Generified UiMarkdownParser by adding abstract UiParser
|
||||||
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
||||||
- Added trimming and AOT annotations and made MLEM.Ui trimmable
|
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed parents of elements that prevent spill not being notified properly
|
- Fixed parents of elements that prevent spill not being notified properly
|
||||||
|
@ -71,7 +69,6 @@ Improvements
|
||||||
- Allow data texture atlas pivots and offsets to be negative
|
- Allow data texture atlas pivots and offsets to be negative
|
||||||
- Made RuntimeTexturePacker restore texture region name and pivot when packing
|
- Made RuntimeTexturePacker restore texture region name and pivot when packing
|
||||||
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
||||||
- Added trimming and AOT annotations and made MLEM.Data trimmable
|
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed data texture atlases not allowing most characters in their region names
|
- Fixed data texture atlases not allowing most characters in their region names
|
||||||
|
@ -82,13 +79,11 @@ Removals
|
||||||
## MLEM.Extended
|
## MLEM.Extended
|
||||||
Improvements
|
Improvements
|
||||||
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
||||||
- Added trimming and AOT annotations and made MLEM.Extended trimmable
|
|
||||||
- **Made GenericBitmapFont and GenericStashFont support UTF-32 characters like emoji**
|
- **Made GenericBitmapFont and GenericStashFont support UTF-32 characters like emoji**
|
||||||
|
|
||||||
## MLEM.Startup
|
## MLEM.Startup
|
||||||
Improvements
|
Improvements
|
||||||
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
||||||
- Added trimming and AOT annotations and made MLEM.Startup trimmable
|
|
||||||
|
|
||||||
## 6.0.0
|
## 6.0.0
|
||||||
|
|
||||||
|
|
|
@ -46,4 +46,3 @@ There are several other libraries and tools that work well in combination with M
|
||||||
- [MonoGame.Extended](https://github.com/craftworkgames/MonoGame.Extended), a package that also provides several additional features for MonoGame
|
- [MonoGame.Extended](https://github.com/craftworkgames/MonoGame.Extended), a package that also provides several additional features for MonoGame
|
||||||
- [Coroutine](https://github.com/Ellpeck/Coroutine), a package that implements Unity-style coroutines for any project
|
- [Coroutine](https://github.com/Ellpeck/Coroutine), a package that implements Unity-style coroutines for any project
|
||||||
- [Illumilib](https://github.com/Ellpeck/Illumilib), a simple keyboard and mouse lighting library with support for Razer, Logitech and Corsair devices
|
- [Illumilib](https://github.com/Ellpeck/Illumilib), a simple keyboard and mouse lighting library with support for Razer, Logitech and Corsair devices
|
||||||
- [DynamicEnums](https://github.com/Ellpeck/DynamicEnums), which provides enum-like single-instance values with additional capabilities, including dynamic addition of new arbitrary values and flags
|
|
||||||
|
|
|
@ -5,52 +5,33 @@ using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace MLEM.Data.Content {
|
namespace MLEM.Data.Content {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a version of <see cref="ContentManager"/> that doesn't load content binary <c>xnb</c> files, but rather as their regular formats.
|
/// Represents a version of <see cref="ContentManager"/> that doesn't load content binary <c>xnb</c> files, but rather as their regular formats.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RawContentManager : ContentManager, IGameComponent {
|
public class RawContentManager : ContentManager, IGameComponent {
|
||||||
|
|
||||||
|
private static List<RawContentReader> readers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The graphics device that this content manager uses
|
/// The graphics device that this content manager uses
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly GraphicsDevice GraphicsDevice;
|
public readonly GraphicsDevice GraphicsDevice;
|
||||||
|
|
||||||
private readonly List<IDisposable> disposableAssets = new List<IDisposable>();
|
private readonly List<IDisposable> disposableAssets = new List<IDisposable>();
|
||||||
private readonly List<RawContentReader> readers;
|
|
||||||
|
|
||||||
#if FNA
|
#if FNA
|
||||||
private Dictionary<string, object> LoadedAssets { get; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
|
private Dictionary<string, object> LoadedAssets { get; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new content manager with an optionally specified root directory.
|
/// Creates a new content manager with an optionally specified root directory.
|
||||||
/// Each <see cref="RawContentReader"/> required for asset loading is gathered and instantiated automatically from the loaded assemblies.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serviceProvider">The service provider of your game</param>
|
/// <param name="serviceProvider">The service provider of your game</param>
|
||||||
/// <param name="rootDirectory">The root directory. Defaults to "Content"</param>
|
/// <param name="rootDirectory">The root directory. Defaults to "Content"</param>
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
[RequiresUnreferencedCode("Automatically gathered RawContentReader types might be removed, use other constructor to add readers manually")]
|
|
||||||
#endif
|
|
||||||
public RawContentManager(IServiceProvider serviceProvider, string rootDirectory = "Content") :
|
public RawContentManager(IServiceProvider serviceProvider, string rootDirectory = "Content") :
|
||||||
this(serviceProvider, RawContentManager.CollectContentReaders(), rootDirectory) {}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new content manager with an optionally specified root directory.
|
|
||||||
/// Each <see cref="RawContentReader"/> required for asset loading has to be passed using <paramref name="readers"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="serviceProvider">The service provider of your game</param>
|
|
||||||
/// <param name="readers">The raw content readers to use, which can be modified externally afterwards to add additional readers if desired.</param>
|
|
||||||
/// <param name="rootDirectory">The root directory. Defaults to "Content"</param>
|
|
||||||
public RawContentManager(IServiceProvider serviceProvider, List<RawContentReader> readers, string rootDirectory) :
|
|
||||||
base(serviceProvider, rootDirectory) {
|
base(serviceProvider, rootDirectory) {
|
||||||
if (serviceProvider.GetService(typeof(IGraphicsDeviceService)) is IGraphicsDeviceService s)
|
if (serviceProvider.GetService(typeof(IGraphicsDeviceService)) is IGraphicsDeviceService s)
|
||||||
this.GraphicsDevice = s.GraphicsDevice;
|
this.GraphicsDevice = s.GraphicsDevice;
|
||||||
this.readers = readers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -82,7 +63,9 @@ namespace MLEM.Data.Content {
|
||||||
|
|
||||||
private T Read<T>(string assetName, T existing) {
|
private T Read<T>(string assetName, T existing) {
|
||||||
var triedFiles = new List<string>();
|
var triedFiles = new List<string>();
|
||||||
foreach (var reader in this.readers) {
|
if (RawContentManager.readers == null)
|
||||||
|
RawContentManager.readers = RawContentManager.CollectContentReaders();
|
||||||
|
foreach (var reader in RawContentManager.readers) {
|
||||||
if (!reader.CanRead(typeof(T)))
|
if (!reader.CanRead(typeof(T)))
|
||||||
continue;
|
continue;
|
||||||
foreach (var ext in reader.GetFileExtensions()) {
|
foreach (var ext in reader.GetFileExtensions()) {
|
||||||
|
@ -121,9 +104,6 @@ namespace MLEM.Data.Content {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialize() {}
|
public void Initialize() {}
|
||||||
|
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
[RequiresUnreferencedCode("Automatically gathered RawContentReader types might be removed, use other constructor to add readers manually")]
|
|
||||||
#endif
|
|
||||||
private static List<RawContentReader> CollectContentReaders() {
|
private static List<RawContentReader> CollectContentReaders() {
|
||||||
var ret = new List<RawContentReader>();
|
var ret = new List<RawContentReader>();
|
||||||
var assemblyExceptions = new List<Exception>();
|
var assemblyExceptions = new List<Exception>();
|
||||||
|
|
|
@ -12,10 +12,6 @@ namespace MLEM.Data.Content {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026",
|
|
||||||
Justification = "RawContentManager does not support XmlReader in a trimmed or AOT context, so this method is not expected to be called.")]
|
|
||||||
#endif
|
|
||||||
public override object Read(RawContentManager manager, string assetPath, Stream stream, Type t, object existing) {
|
public override object Read(RawContentManager manager, string assetPath, Stream stream, Type t, object existing) {
|
||||||
return new XmlSerializer(t).Deserialize(stream);
|
return new XmlSerializer(t).Deserialize(stream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,18 +3,11 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace MLEM.Data {
|
namespace MLEM.Data {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A set of extensions for dealing with copying objects.
|
/// A set of extensions for dealing with copying objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("CopyExtensions has major flaws and insufficient speed compared to other libraries specifically designed for copying objects.")]
|
[Obsolete("CopyExtensions has major flaws and insufficient speed compared to other libraries specifically designed for copying objects.")]
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
[UnconditionalSuppressMessage("Aot", "IL3050"), UnconditionalSuppressMessage("Aot", "IL2070"), UnconditionalSuppressMessage("Aot", "IL2090")]
|
|
||||||
#endif
|
|
||||||
public static class CopyExtensions {
|
public static class CopyExtensions {
|
||||||
|
|
||||||
private const BindingFlags DefaultFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
private const BindingFlags DefaultFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||||
|
@ -22,7 +15,7 @@ namespace MLEM.Data {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a shallow copy of the object and returns it.
|
/// Creates a shallow copy of the object and returns it.
|
||||||
/// Object creation occurs using a constructor with the <see cref="CopyConstructorAttribute"/> or, if none is present, the first constructor with the correct <see cref="BindingFlags"/>.
|
/// Object creation occurs using a constructor with the <see cref="CopyConstructorAttribute"/> or, if none is present, the first constructor with the correct <see cref="BindingFlags"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">The object to create a shallow copy of</param>
|
/// <param name="obj">The object to create a shallow copy of</param>
|
||||||
/// <param name="flags">The binding flags for field searching</param>
|
/// <param name="flags">The binding flags for field searching</param>
|
||||||
|
@ -38,7 +31,7 @@ namespace MLEM.Data {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a deep copy of the object and returns it.
|
/// Creates a deep copy of the object and returns it.
|
||||||
/// Object creation occurs using a constructor with the <see cref="CopyConstructorAttribute"/> or, if none is present, the first constructor with the correct <see cref="BindingFlags"/>.
|
/// Object creation occurs using a constructor with the <see cref="CopyConstructorAttribute"/> or, if none is present, the first constructor with the correct <see cref="BindingFlags"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">The object to create a deep copy of</param>
|
/// <param name="obj">The object to create a deep copy of</param>
|
||||||
/// <param name="flags">The binding flags for field searching</param>
|
/// <param name="flags">The binding flags for field searching</param>
|
||||||
|
@ -70,7 +63,7 @@ namespace MLEM.Data {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Copies the given object <paramref name="obj"/> into the given object <paramref name="otherObj"/> in a deep manner.
|
/// Copies the given object <paramref name="obj"/> into the given object <paramref name="otherObj"/> in a deep manner.
|
||||||
/// Object creation occurs using a constructor with the <see cref="CopyConstructorAttribute"/> or, if none is present, the first constructor with the correct <see cref="BindingFlags"/>.
|
/// Object creation occurs using a constructor with the <see cref="CopyConstructorAttribute"/> or, if none is present, the first constructor with the correct <see cref="BindingFlags"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">The object to create a deep copy of</param>
|
/// <param name="obj">The object to create a deep copy of</param>
|
||||||
/// <param name="otherObj">The object to copy into</param>
|
/// <param name="otherObj">The object to copy into</param>
|
||||||
|
|
|
@ -26,9 +26,6 @@ namespace MLEM.Data {
|
||||||
/// </code>
|
/// </code>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[Obsolete("DynamicEnum has been moved into the DynamicEnums library: https://www.nuget.org/packages/DynamicEnums"), JsonConverter(typeof(DynamicEnumConverter))]
|
[Obsolete("DynamicEnum has been moved into the DynamicEnums library: https://www.nuget.org/packages/DynamicEnums"), JsonConverter(typeof(DynamicEnumConverter))]
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Aot", "IL2067")]
|
|
||||||
#endif
|
|
||||||
public abstract class DynamicEnum {
|
public abstract class DynamicEnum {
|
||||||
|
|
||||||
private static readonly Dictionary<Type, Storage> Storages = new Dictionary<Type, Storage>();
|
private static readonly Dictionary<Type, Storage> Storages = new Dictionary<Type, Storage>();
|
||||||
|
|
|
@ -11,16 +11,9 @@ namespace MLEM.Data.Json {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An array of all of the <see cref="JsonConverter"/>s that are part of MLEM.Data
|
/// An array of all of the <see cref="JsonConverter"/>s that are part of MLEM.Data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly JsonConverter[] Converters = {
|
public static readonly JsonConverter[] Converters = typeof(JsonConverters).Assembly.GetExportedTypes()
|
||||||
new Direction2Converter(),
|
.Where(t => t.IsSubclassOf(typeof(JsonConverter)) && !t.IsGenericType)
|
||||||
#pragma warning disable CS0618
|
.Select(Activator.CreateInstance).Cast<JsonConverter>().ToArray();
|
||||||
new DynamicEnumConverter(),
|
|
||||||
#pragma warning restore CS0618
|
|
||||||
new PointConverter(),
|
|
||||||
new RectangleConverter(),
|
|
||||||
new RectangleFConverter(),
|
|
||||||
new Vector2Converter()
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds all of the <see cref="JsonConverter"/> objects that are part of MLEM.Data to the given <see cref="JsonSerializer"/>
|
/// Adds all of the <see cref="JsonConverter"/> objects that are part of MLEM.Data to the given <see cref="JsonSerializer"/>
|
||||||
|
|
|
@ -9,9 +9,6 @@ namespace MLEM.Data.Json {
|
||||||
/// This class uses <see cref="JsonTypeSafeWrapper"/> for each object stored to ensure that objects with a custom <see cref="JsonConverter"/> get deserialized as an instance of their original type if <see cref="JsonSerializer.TypeNameHandling"/> is not set to <see cref="TypeNameHandling.None"/>.
|
/// This class uses <see cref="JsonTypeSafeWrapper"/> for each object stored to ensure that objects with a custom <see cref="JsonConverter"/> get deserialized as an instance of their original type if <see cref="JsonSerializer.TypeNameHandling"/> is not set to <see cref="TypeNameHandling.None"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataContract]
|
[DataContract]
|
||||||
#if NET7_0_OR_GREATER
|
|
||||||
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for instantiation of JsonTypeSafeWrapper instances might not be available at runtime.")]
|
|
||||||
#endif
|
|
||||||
public class JsonTypeSafeGenericDataHolder : IGenericDataHolder {
|
public class JsonTypeSafeGenericDataHolder : IGenericDataHolder {
|
||||||
|
|
||||||
private static readonly string[] EmptyStrings = new string[0];
|
private static readonly string[] EmptyStrings = new string[0];
|
||||||
|
|
|
@ -34,9 +34,6 @@ namespace MLEM.Data.Json {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The value to wrap</param>
|
/// <param name="value">The value to wrap</param>
|
||||||
/// <returns>A <see cref="JsonTypeSafeWrapper{T}"/> with a type matching the type of <paramref name="value"/></returns>
|
/// <returns>A <see cref="JsonTypeSafeWrapper{T}"/> with a type matching the type of <paramref name="value"/></returns>
|
||||||
#if NET7_0_OR_GREATER
|
|
||||||
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for this instantiation might not be available at runtime.")]
|
|
||||||
#endif
|
|
||||||
public static JsonTypeSafeWrapper Of(object value) {
|
public static JsonTypeSafeWrapper Of(object value) {
|
||||||
var type = typeof(JsonTypeSafeWrapper<>).MakeGenericType(value.GetType());
|
var type = typeof(JsonTypeSafeWrapper<>).MakeGenericType(value.GetType());
|
||||||
return (JsonTypeSafeWrapper) Activator.CreateInstance(type, value);
|
return (JsonTypeSafeWrapper) Activator.CreateInstance(type, value);
|
||||||
|
|
|
@ -4,13 +4,9 @@ using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace MLEM.Data.Json {
|
namespace MLEM.Data.Json {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="JsonConverter{T}"/> that doesn't actually serialize the object, but instead serializes the name given to it by the underlying <see cref="Dictionary{T,T}"/>.
|
/// A <see cref="JsonConverter{T}"/> that doesn't actually serialize the object, but instead serializes the name given to it by the underlying <see cref="Dictionary{T,T}"/>.
|
||||||
/// Optionally, the name of a <see cref="Dictionary{TKey,TValue}"/> can be passed to this converter when used in the <see cref="JsonConverterAttribute"/> by passing the arguments for the <see cref="StaticJsonConverter{T}(Type,string)"/> constructor as <see cref="JsonConverterAttribute.ConverterParameters"/>.
|
/// Optionally, the name of a <see cref="Dictionary{TKey,TValue}"/> can be passed to this converter when used in the <see cref="JsonConverterAttribute"/> by passing the arguments for the <see cref="StaticJsonConverter{T}(Type,string)"/> constructor as <see cref="JsonConverterAttribute.ConverterParameters"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of the object to convert</typeparam>
|
/// <typeparam name="T">The type of the object to convert</typeparam>
|
||||||
|
@ -33,11 +29,7 @@ namespace MLEM.Data.Json {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type">The type that the dictionary is declared in</param>
|
/// <param name="type">The type that the dictionary is declared in</param>
|
||||||
/// <param name="memberName">The name of the dictionary itself</param>
|
/// <param name="memberName">The name of the dictionary itself</param>
|
||||||
public StaticJsonConverter(
|
public StaticJsonConverter(Type type, string memberName) : this(StaticJsonConverter<T>.GetEntries(type, memberName)) {}
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)]
|
|
||||||
#endif
|
|
||||||
Type type, string memberName) : this(StaticJsonConverter<T>.GetEntries(type, memberName)) {}
|
|
||||||
|
|
||||||
/// <summary>Writes the JSON representation of the object.</summary>
|
/// <summary>Writes the JSON representation of the object.</summary>
|
||||||
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
|
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
|
||||||
|
@ -64,11 +56,7 @@ namespace MLEM.Data.Json {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<string, T> GetEntries(
|
private static Dictionary<string, T> GetEntries(Type type, string memberName) {
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)]
|
|
||||||
#endif
|
|
||||||
Type type, string memberName) {
|
|
||||||
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
|
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
|
||||||
var value = type.GetProperty(memberName, flags)?.GetValue(null) ?? type.GetField(memberName, flags)?.GetValue(null);
|
var value = type.GetProperty(memberName, flags)?.GetValue(null) ?? type.GetField(memberName, flags)?.GetValue(null);
|
||||||
if (value == null)
|
if (value == null)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
<RootNamespace>MLEM.Data</RootNamespace>
|
<RootNamespace>MLEM.Data</RootNamespace>
|
||||||
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
||||||
<NoWarn>NU1701</NoWarn>
|
<NoWarn>NU1701</NoWarn>
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
<NoWarn>NU1701</NoWarn>
|
<NoWarn>NU1701</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,6 @@ namespace MLEM.Data {
|
||||||
/// Before serializing and deserializing an object, each of the object's fields has to have a handler. New handlers can be added using <see cref="AddHandler{T}(System.Action{Lidgren.Network.NetBuffer,T},System.Func{Lidgren.Network.NetBuffer,T})"/> or <see cref="AddHandler{T}(Newtonsoft.Json.JsonSerializer)"/>.
|
/// Before serializing and deserializing an object, each of the object's fields has to have a handler. New handlers can be added using <see cref="AddHandler{T}(System.Action{Lidgren.Network.NetBuffer,T},System.Func{Lidgren.Network.NetBuffer,T})"/> or <see cref="AddHandler{T}(Newtonsoft.Json.JsonSerializer)"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Lidgren.Network support is deprecated. Consider using LiteNetLib or a custom implementation instead.")]
|
[Obsolete("Lidgren.Network support is deprecated. Consider using LiteNetLib or a custom implementation instead.")]
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Aot", "IL2070")]
|
|
||||||
#endif
|
|
||||||
public class NetBufferSerializer {
|
public class NetBufferSerializer {
|
||||||
|
|
||||||
private readonly Dictionary<Type, Action<NetBuffer, object>> writeFunctions = new Dictionary<Type, Action<NetBuffer, object>>();
|
private readonly Dictionary<Type, Action<NetBuffer, object>> writeFunctions = new Dictionary<Type, Action<NetBuffer, object>>();
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
<RootNamespace>MLEM.Extended</RootNamespace>
|
<RootNamespace>MLEM.Extended</RootNamespace>
|
||||||
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
||||||
<NoWarn>NU1702</NoWarn>
|
<NoWarn>NU1702</NoWarn>
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
<RootNamespace>MLEM.Startup</RootNamespace>
|
<RootNamespace>MLEM.Startup</RootNamespace>
|
||||||
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||||
<ContentTargetFolders>content</ContentTargetFolders>
|
<ContentTargetFolders>content</ContentTargetFolders>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
<NoWarn>NU5128</NoWarn>
|
<NoWarn>NU5128</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
<RootNamespace>MLEM.Ui</RootNamespace>
|
<RootNamespace>MLEM.Ui</RootNamespace>
|
||||||
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
@ -24,12 +24,7 @@ namespace MLEM.Ui.Parsers {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An array containing all of the <see cref="ElementType"/> enum values.
|
/// An array containing all of the <see cref="ElementType"/> enum values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly ElementType[] ElementTypes =
|
public static readonly ElementType[] ElementTypes = (ElementType[]) Enum.GetValues(typeof(ElementType));
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
Enum.GetValues<ElementType>();
|
|
||||||
#else
|
|
||||||
(ElementType[]) Enum.GetValues(typeof(ElementType));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The base path for images, which is prepended to the image link.
|
/// The base path for images, which is prepended to the image link.
|
||||||
|
|
|
@ -17,21 +17,11 @@ namespace MLEM.Input {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All values of the <see cref="Buttons"/> enum.
|
/// All values of the <see cref="Buttons"/> enum.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Buttons[] AllButtons =
|
public static readonly Buttons[] AllButtons = (Buttons[]) Enum.GetValues(typeof(Buttons));
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
Enum.GetValues<Buttons>();
|
|
||||||
#else
|
|
||||||
(Buttons[]) Enum.GetValues(typeof(Buttons));
|
|
||||||
#endif
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All values of the <see cref="Keys"/> enum.
|
/// All values of the <see cref="Keys"/> enum.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Keys[] AllKeys =
|
public static readonly Keys[] AllKeys = (Keys[]) Enum.GetValues(typeof(Keys));
|
||||||
#if NET6_0_OR_GREATER
|
|
||||||
Enum.GetValues<Keys>();
|
|
||||||
#else
|
|
||||||
(Keys[]) Enum.GetValues(typeof(Keys));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if FNA
|
#if FNA
|
||||||
private const int MaximumGamePadCount = 4;
|
private const int MaximumGamePadCount = 4;
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace MLEM.Input {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All enum values of <see cref="ModifierKey"/>
|
/// All enum values of <see cref="ModifierKey"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly ModifierKey[] ModifierKeys = {ModifierKey.None, ModifierKey.Shift, ModifierKey.Control, ModifierKey.Alt};
|
public static readonly ModifierKey[] ModifierKeys = (ModifierKey[]) Enum.GetValues(typeof(ModifierKey));
|
||||||
private static readonly Dictionary<ModifierKey, Keys[]> KeysLookup = new Dictionary<ModifierKey, Keys[]> {
|
private static readonly Dictionary<ModifierKey, Keys[]> KeysLookup = new Dictionary<ModifierKey, Keys[]> {
|
||||||
{ModifierKey.Shift, new[] {Keys.LeftShift, Keys.RightShift}},
|
{ModifierKey.Shift, new[] {Keys.LeftShift, Keys.RightShift}},
|
||||||
{ModifierKey.Control, new[] {Keys.LeftControl, Keys.RightControl}},
|
{ModifierKey.Control, new[] {Keys.LeftControl, Keys.RightControl}},
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace MLEM.Input {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All enum values of <see cref="MouseButton"/>
|
/// All enum values of <see cref="MouseButton"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly MouseButton[] MouseButtons = {MouseButton.Left, MouseButton.Middle, MouseButton.Right, MouseButton.Extra1, MouseButton.Extra2};
|
public static readonly MouseButton[] MouseButtons = (MouseButton[]) Enum.GetValues(typeof(MouseButton));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the <see cref="ButtonState"/> of the given mouse button.
|
/// Returns the <see cref="ButtonState"/> of the given mouse button.
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
<RootNamespace>MLEM</RootNamespace>
|
<RootNamespace>MLEM</RootNamespace>
|
||||||
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net452;netstandard2.0;net6.0</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
<IsTrimmable>true</IsTrimmable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
@ -71,10 +71,7 @@ namespace MLEM.Misc {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All <see cref="Direction2"/> enum values
|
/// All <see cref="Direction2"/> enum values
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Direction2[] All = {
|
public static readonly Direction2[] All = (Direction2[]) Enum.GetValues(typeof(Direction2));
|
||||||
Direction2.None, Direction2.Up, Direction2.Right, Direction2.Down, Direction2.Left,
|
|
||||||
Direction2.UpRight, Direction2.DownRight, Direction2.UpLeft, Direction2.DownLeft
|
|
||||||
};
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="Direction2.Up"/> through <see cref="Direction2.Left"/> directions
|
/// The <see cref="Direction2.Up"/> through <see cref="Direction2.Left"/> directions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -46,4 +46,3 @@ There are several other libraries and tools that work well in combination with M
|
||||||
- [MonoGame.Extended](https://github.com/craftworkgames/MonoGame.Extended), a package that also provides several additional features for MonoGame
|
- [MonoGame.Extended](https://github.com/craftworkgames/MonoGame.Extended), a package that also provides several additional features for MonoGame
|
||||||
- [Coroutine](https://github.com/Ellpeck/Coroutine), a package that implements Unity-style coroutines for any project
|
- [Coroutine](https://github.com/Ellpeck/Coroutine), a package that implements Unity-style coroutines for any project
|
||||||
- [Illumilib](https://github.com/Ellpeck/Illumilib), a simple keyboard and mouse lighting library with support for Razer, Logitech and Corsair devices
|
- [Illumilib](https://github.com/Ellpeck/Illumilib), a simple keyboard and mouse lighting library with support for Razer, Logitech and Corsair devices
|
||||||
- [DynamicEnums](https://github.com/Ellpeck/DynamicEnums), which provides enum-like single-instance values with additional capabilities, including dynamic addition of new arbitrary values and flags
|
|
||||||
|
|
Loading…
Reference in a new issue