1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-21 20:43:29 +01:00

cleaned up preprocessor instructions

This commit is contained in:
Ell 2022-12-13 13:11:36 +01:00
parent e229432d0f
commit 14d0b24aa9
40 changed files with 119 additions and 117 deletions

View file

@ -87,8 +87,9 @@ resharper_indent_nested_for_stmt = true
resharper_indent_nested_lock_stmt = true
resharper_indent_nested_usings_stmt = true
resharper_indent_nested_while_stmt = true
resharper_indent_preprocessor_if = usual_indent
resharper_indent_preprocessor_other = usual_indent
resharper_indent_preprocessor_if = no_indent
resharper_indent_preprocessor_other = no_indent
resharper_indent_preprocessor_region = no_indent
resharper_keep_existing_declaration_parens_arrangement = false
resharper_keep_existing_embedded_arrangement = false
resharper_keep_existing_expr_member_arrangement = false

View file

@ -10,11 +10,11 @@ namespace Demos.DesktopGL;
public static class Program {
public static void Main() {
#if FNA
#if FNA
MlemPlatform.Current = new MlemPlatform.DesktopFna(a => TextInputEXT.TextInput += a);
#else
#else
MlemPlatform.Current = new MlemPlatform.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
#endif
#endif
using var game = new GameImpl();
game.Run();
}

View file

@ -23,9 +23,9 @@ namespace MLEM.Data.Content {
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);
#endif
#endif
/// <summary>
/// Creates a new content manager with an optionally specified root directory.
@ -33,9 +33,9 @@ namespace MLEM.Data.Content {
/// </summary>
/// <param name="serviceProvider">The service provider of your game</param>
/// <param name="rootDirectory">The root directory. Defaults to "Content"</param>
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Automatically gathered RawContentReader types might be removed, use other constructor to add readers manually")]
#endif
#endif
public RawContentManager(IServiceProvider serviceProvider, string rootDirectory = "Content") :
this(serviceProvider, RawContentManager.CollectContentReaders(), rootDirectory) {}
@ -73,9 +73,9 @@ namespace MLEM.Data.Content {
/// <param name="currentAsset">The current asset instance.</param>
/// <typeparam name="T">The asset's type.</typeparam>
protected
#if !FNA
#if !FNA
override
#endif
#endif
void ReloadAsset<T>(string originalAssetName, T currentAsset) {
this.Read(originalAssetName, currentAsset);
}
@ -121,9 +121,9 @@ namespace MLEM.Data.Content {
/// </summary>
public void Initialize() {}
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Automatically gathered RawContentReader types might be removed, use other constructor to add readers manually")]
#endif
#endif
private static List<RawContentReader> CollectContentReaders() {
var ret = new List<RawContentReader>();
var assemblyExceptions = new List<Exception>();

View file

@ -9,12 +9,12 @@ namespace MLEM.Data.Content {
/// <inheritdoc />
protected override Texture2D Read(RawContentManager manager, string assetPath, Stream stream, Texture2D existing) {
#if !FNA
#if !FNA
if (existing != null) {
existing.Reload(stream);
return existing;
}
#endif
#endif
// premultiply the texture's color to be in line with the pipeline's texture reader
using (var texture = Texture2D.FromStream(manager.GraphicsDevice, stream)) {

View file

@ -12,10 +12,10 @@ namespace MLEM.Data.Content {
}
/// <inheritdoc />
#if NET6_0_OR_GREATER
#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
#endif
public override object Read(RawContentManager manager, string assetPath, Stream stream, Type t, object existing) {
return new XmlSerializer(t).Deserialize(stream);
}

View file

@ -12,9 +12,9 @@ namespace MLEM.Data {
/// A set of extensions for dealing with copying objects.
/// </summary>
[Obsolete("CopyExtensions has major flaws and insufficient speed compared to other libraries specifically designed for copying objects.")]
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
[UnconditionalSuppressMessage("Aot", "IL3050"), UnconditionalSuppressMessage("Aot", "IL2070"), UnconditionalSuppressMessage("Aot", "IL2090")]
#endif
#endif
public static class CopyExtensions {
private const BindingFlags DefaultFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

View file

@ -26,9 +26,9 @@ namespace MLEM.Data {
/// </code>
/// </remarks>
[Obsolete("DynamicEnum has been moved into the DynamicEnums library: https://www.nuget.org/packages/DynamicEnums"), JsonConverter(typeof(DynamicEnumConverter))]
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Aot", "IL2067")]
#endif
#endif
public abstract class DynamicEnum {
private static readonly Dictionary<Type, Storage> Storages = new Dictionary<Type, Storage>();

View file

@ -13,9 +13,9 @@ namespace MLEM.Data.Json {
/// </summary>
public static readonly JsonConverter[] Converters = {
new Direction2Converter(),
#pragma warning disable CS0618
#pragma warning disable CS0618
new DynamicEnumConverter(),
#pragma warning restore CS0618
#pragma warning restore CS0618
new PointConverter(),
new RectangleConverter(),
new RectangleFConverter(),

View file

@ -9,9 +9,9 @@ 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"/>.
/// Note that, using <see cref="SetData"/>, adding <see cref="JsonTypeSafeWrapper{T}"/> instances directly is also possible.
/// </summary>
#if NET7_0_OR_GREATER
#if NET7_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for instantiation of JsonTypeSafeWrapper instances might not be available at runtime.")]
#endif
#endif
public class JsonTypeSafeGenericDataHolder : IGenericDataHolder {
private static readonly string[] EmptyStrings = new string[0];

View file

@ -34,9 +34,9 @@ namespace MLEM.Data.Json {
/// </summary>
/// <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>
#if NET7_0_OR_GREATER
#if NET7_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for this instantiation might not be available at runtime if the value's type is a subtype of T.")]
#endif
#endif
public static JsonTypeSafeWrapper Of<T>(T value) {
if (value.GetType() == typeof(T)) {
return new JsonTypeSafeWrapper<T>(value);

View file

@ -34,9 +34,9 @@ namespace MLEM.Data.Json {
/// <param name="type">The type that the dictionary is declared in</param>
/// <param name="memberName">The name of the dictionary itself</param>
public StaticJsonConverter(
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)]
#endif
#endif
Type type, string memberName) : this(StaticJsonConverter<T>.GetEntries(type, memberName)) {}
/// <summary>Writes the JSON representation of the object.</summary>
@ -65,9 +65,9 @@ namespace MLEM.Data.Json {
}
private static Dictionary<string, T> GetEntries(
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)]
#endif
#endif
Type type, string memberName) {
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);

View file

@ -11,9 +11,9 @@ 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)"/>.
/// </summary>
[Obsolete("Lidgren.Network support is deprecated. Consider using LiteNetLib or a custom implementation instead.")]
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Aot", "IL2070")]
#endif
#endif
public class NetBufferSerializer {
private readonly Dictionary<Type, Action<NetBuffer, object>> writeFunctions = new Dictionary<Type, Action<NetBuffer, object>>();

View file

@ -69,9 +69,9 @@ namespace MLEM.Startup {
this.GraphicsDeviceManager = new GraphicsDeviceManager(this) {
PreferredBackBufferWidth = windowWidth,
PreferredBackBufferHeight = windowHeight,
#if !FNA
#if !FNA
HardwareModeSwitch = false
#endif
#endif
};
this.Window.AllowUserResizing = true;
this.Content.RootDirectory = "Content";
@ -116,9 +116,9 @@ namespace MLEM.Startup {
this.PreDraw?.Invoke(this, gameTime);
CoroutineHandler.RaiseEvent(CoroutineEvents.PreDraw);
#pragma warning disable CS0618
#pragma warning disable CS0618
this.UiSystem.DrawEarly(gameTime, this.SpriteBatch);
#pragma warning restore CS0618
#pragma warning restore CS0618
this.DoDraw(gameTime);
this.UiSystem.Draw(gameTime, this.SpriteBatch);

View file

@ -206,10 +206,10 @@ namespace MLEM.Ui.Elements {
/// The call that this element should make to <see cref="SpriteBatch"/> to begin drawing.
/// Note that, when this is non-null, a new <c>SpriteBatch.Begin</c> call is used for this element.
/// </summary>
#pragma warning disable CS0618
#pragma warning disable CS0618
[Obsolete("BeginImpl is deprecated. You can create a custom element class and override Draw instead.")]
public BeginDelegate BeginImpl;
#pragma warning restore CS0618
#pragma warning restore CS0618
/// <summary>
/// Set this field to false to disallow the element from being selected.
/// An unselectable element is skipped by automatic navigation and its <see cref="OnSelected"/> callback will never be called.
@ -983,7 +983,7 @@ namespace MLEM.Ui.Elements {
/// <param name="alpha">The alpha to draw this element and its children with</param>
/// <param name="context">The sprite batch context to use for drawing</param>
public void DrawTransformed(GameTime time, SpriteBatch batch, float alpha, SpriteBatchContext context) {
#pragma warning disable CS0618
#pragma warning disable CS0618
var customDraw = this.BeginImpl != null || this.Transform != Matrix.Identity;
var transformed = context;
transformed.TransformMatrix = this.Transform * transformed.TransformMatrix;
@ -994,12 +994,12 @@ namespace MLEM.Ui.Elements {
// begin our own draw call
batch.Begin(transformed);
}
#pragma warning restore CS0618
#pragma warning restore CS0618
// draw content in custom begin call
#pragma warning disable CS0618
#pragma warning disable CS0618
this.Draw(time, batch, alpha, transformed.BlendState, transformed.SamplerState, transformed.DepthStencilState, transformed.Effect, transformed.TransformMatrix);
#pragma warning restore CS0618
#pragma warning restore CS0618
if (this.System != null)
this.System.Metrics.Draws++;
@ -1043,9 +1043,9 @@ namespace MLEM.Ui.Elements {
foreach (var child in this.GetRelevantChildren()) {
if (!child.IsHidden) {
#pragma warning disable CS0618
#pragma warning disable CS0618
child.DrawTransformed(time, batch, alpha * child.DrawAlpha, context.BlendState, context.SamplerState, context.DepthStencilState, context.Effect, context.TransformMatrix);
#pragma warning restore CS0618
#pragma warning restore CS0618
}
}
}

View file

@ -112,11 +112,11 @@ namespace MLEM.Ui.Elements {
set => this.textInput.Multiline = value;
}
#if FNA
#if FNA
/// <inheritdoc />
// we need to make sure that the enter press doesn't get consumed by our press function so that it still works in TextInput
public override bool CanBePressed => base.CanBePressed && !this.IsSelected;
#endif
#endif
/// <summary>
/// The text that displays in this text field if <see cref="Text"/> is empty
@ -146,9 +146,9 @@ namespace MLEM.Ui.Elements {
/// <param name="multiline">Whether the text field should support multi-line editing</param>
public TextField(Anchor anchor, Vector2 size, Rule rule = null, GenericFont font = null, string text = null, bool multiline = false) : base(anchor, size) {
this.textInput = new TextInput(null, Vector2.Zero, 1
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
, null, ClipboardService.SetText, ClipboardService.GetText
#endif
#endif
) {
OnTextChange = (i, s) => this.OnTextChange?.Invoke(this, s),
InputRule = (i, s) => this.InputRule.Invoke(this, s)

View file

@ -100,9 +100,9 @@ namespace MLEM.Ui.Elements {
public Tooltip(string text = null, Element elementToHover = null) :
base(Anchor.TopLeft, Vector2.One, Vector2.Zero) {
if (text != null) {
#pragma warning disable CS0618
#pragma warning disable CS0618
this.Paragraph = this.AddParagraph(text);
#pragma warning restore CS0618
#pragma warning restore CS0618
}
this.Init(elementToHover);
}
@ -114,9 +114,9 @@ namespace MLEM.Ui.Elements {
/// <param name="elementToHover">The element that should automatically cause the tooltip to appear and disappear when hovered and not hovered, respectively</param>
public Tooltip(Paragraph.TextCallback textCallback, Element elementToHover = null) :
base(Anchor.TopLeft, Vector2.One, Vector2.Zero) {
#pragma warning disable CS0618
#pragma warning disable CS0618
this.Paragraph = this.AddParagraph(textCallback);
#pragma warning restore CS0618
#pragma warning restore CS0618
this.Init(elementToHover);
}
@ -298,11 +298,11 @@ namespace MLEM.Ui.Elements {
foreach (var paragraph in this.Paragraphs)
this.UpdateParagraphStyle(paragraph);
#pragma warning disable CS0618
#pragma warning disable CS0618
// still set style here in case someone changed the paragraph field manually
if (this.Paragraph != null)
this.UpdateParagraphStyle(this.Paragraph);
#pragma warning restore CS0618
#pragma warning restore CS0618
}
private void UpdateParagraphStyle(Paragraph paragraph) {

View file

@ -10,6 +10,7 @@ using MLEM.Ui.Style;
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
using System.Net.Http;
#else
using System.Net;
#endif
@ -25,11 +26,11 @@ namespace MLEM.Ui.Parsers {
/// An array containing all of the <see cref="ElementType"/> enum values.
/// </summary>
public static readonly ElementType[] ElementTypes =
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
Enum.GetValues<ElementType>();
#else
#else
(ElementType[]) Enum.GetValues(typeof(ElementType));
#endif
#endif
/// <summary>
/// The base path for images, which is prepended to the image link.
@ -164,13 +165,13 @@ namespace MLEM.Ui.Parsers {
Texture2D tex;
if (path.StartsWith("http")) {
byte[] src;
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
using (var client = new HttpClient())
src = await client.GetByteArrayAsync(path);
#else
#else
using (var client = new WebClient())
src = await client.DownloadDataTaskAsync(path);
#endif
#endif
using (var memory = new MemoryStream(src))
tex = Texture2D.FromStream(this.GraphicsDevice, memory);
} else {

View file

@ -84,7 +84,7 @@ namespace MLEM.Ui.Style {
/// <param name="obj">The object to compare with the current instance.</param>
/// <returns>true if <paramref name="obj">obj</paramref> and this instance are the same type and represent the same value; otherwise, false.</returns>
[Obsolete("StyleProp equality is ambiguous as it is not clear whether priority is taken into account. Compare Values instead.")]
#pragma warning disable CS0809
#pragma warning disable CS0809
public override bool Equals(object obj) {
return obj is StyleProp<T> other && this.Equals(other);
}
@ -95,7 +95,7 @@ namespace MLEM.Ui.Style {
public override int GetHashCode() {
return EqualityComparer<T>.Default.GetHashCode(this.Value);
}
#pragma warning restore CS0809
#pragma warning restore CS0809
/// <summary>Returns the fully qualified type name of this instance.</summary>
/// <returns>The fully qualified type name.</returns>

View file

@ -309,7 +309,7 @@ namespace MLEM.Ui {
var context = this.SpriteBatchContext;
context.TransformMatrix = root.Transform * context.TransformMatrix;
#pragma warning disable CS0618
#pragma warning disable CS0618
if (this.BlendState != null)
context.BlendState = this.BlendState;
if (this.SamplerState != null)
@ -318,12 +318,12 @@ namespace MLEM.Ui {
context.DepthStencilState = this.DepthStencilState;
if (this.Effect != null)
context.Effect = this.Effect;
#pragma warning restore CS0618
#pragma warning restore CS0618
batch.Begin(context);
#pragma warning disable CS0618
#pragma warning disable CS0618
root.Element.DrawTransformed(time, batch, this.DrawAlpha * root.Element.DrawAlpha, context.BlendState, context.SamplerState, context.DepthStencilState, context.Effect, context.TransformMatrix);
#pragma warning restore CS0618
#pragma warning restore CS0618
batch.End();
}

View file

@ -51,7 +51,7 @@ namespace MLEM.Extensions {
return combos;
}
#if NET452
#if NET452
/// <summary>Appends a value to the end of the sequence.</summary>
/// <param name="source">A sequence of values.</param>
/// <param name="element">The value to append to <paramref name="source"/>.</param>
@ -73,7 +73,7 @@ namespace MLEM.Extensions {
foreach (var src in source)
yield return src;
}
#endif
#endif
}
}

View file

@ -90,12 +90,12 @@ namespace MLEM.Extensions {
/// <param name="target">The target to apply</param>
public TargetContext(GraphicsDevice device, RenderTarget2D target) {
this.device = device;
#if FNA
#if FNA
// RenderTargetCount doesn't exist in FNA but we still want the optimization in MG
this.lastTargets = device.GetRenderTargets();
#else
#else
this.lastTargets = device.RenderTargetCount <= 0 ? null : device.GetRenderTargets();
#endif
#endif
device.SetRenderTarget(target);
}

View file

@ -288,7 +288,7 @@ namespace MLEM.Extensions {
return false;
}
#if FNA
#if FNA
/// <summary>
/// Gets a <see cref="Point"/> representation for this object.
/// </summary>
@ -339,7 +339,7 @@ namespace MLEM.Extensions {
y = vector.Y;
z = vector.Z;
}
#endif
#endif
}
}

View file

@ -360,7 +360,7 @@ namespace MLEM.Font {
var total = new StringBuilder();
var extraWidth = 0F;
var endReached = false;
foreach (var part in (fromBack ? text.Reverse() : text)) {
foreach (var part in fromBack ? text.Reverse() : text) {
var curr = new StringBuilder();
// if we reached the end previously, all the other parts should just be empty
if (!endReached) {

View file

@ -44,10 +44,10 @@ namespace MLEM.Font {
}
private static SpriteFont SetDefaults(SpriteFont font) {
#if FNA
#if FNA
// none of the copying is available with FNA
return font;
#else
#else
// we copy the font here to set the default character to a space
return new SpriteFont(
font.Texture,
@ -58,7 +58,7 @@ namespace MLEM.Font {
font.Spacing,
font.Glyphs.Select(g => new Vector3(g.LeftSideBearing, g.Width, g.RightSideBearing)).ToList(),
' ');
#endif
#endif
}
}

View file

@ -143,9 +143,9 @@ namespace MLEM.Formatting {
private static string StripFormatting(GenericFont font, string s, IEnumerable<Code> codes) {
foreach (var code in codes) {
#pragma warning disable CS0618
#pragma warning disable CS0618
s = code.Regex.Replace(s, code.GetReplacementString(font));
#pragma warning restore CS0618
#pragma warning restore CS0618
}
return s;
}

View file

@ -461,11 +461,11 @@ namespace MLEM.Graphics {
}
private void DrawPrimitives(int vertices) {
#if FNA
#if FNA
this.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices, 0, vertices / 4 * 2);
#else
#else
this.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices / 4 * 2);
#endif
#endif
}
private void AddItemToSet(Item item) {
@ -560,7 +560,7 @@ namespace MLEM.Graphics {
}
#if FNA
#if FNA
private class SpriteEffect : Effect {
private EffectParameter matrixParam;
@ -611,7 +611,7 @@ namespace MLEM.Graphics {
}
}
#endif
#endif
}
}

View file

@ -18,26 +18,26 @@ namespace MLEM.Input {
/// All values of the <see cref="Buttons"/> enum.
/// </summary>
public static readonly Buttons[] AllButtons =
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
Enum.GetValues<Buttons>();
#else
#else
(Buttons[]) Enum.GetValues(typeof(Buttons));
#endif
#endif
/// <summary>
/// All values of the <see cref="Keys"/> enum.
/// </summary>
public static readonly Keys[] AllKeys =
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
Enum.GetValues<Keys>();
#else
#else
(Keys[]) Enum.GetValues(typeof(Keys));
#endif
#endif
#if FNA
#if FNA
private const int MaximumGamePadCount = 4;
#else
#else
private static readonly int MaximumGamePadCount = GamePad.MaximumGamePadCount;
#endif
#endif
private static readonly TouchLocation[] EmptyTouchLocations = new TouchLocation[0];
private static readonly GenericInput[] EmptyGenericInputs = new GenericInput[0];
@ -258,11 +258,11 @@ namespace MLEM.Input {
}
} else {
// mouse position and scroll wheel value should be preserved when the mouse is out of bounds
#if FNA
#if FNA
this.MouseState = new MouseState(state.X, state.Y, state.ScrollWheelValue, 0, 0, 0, 0, 0);
#else
#else
this.MouseState = new MouseState(state.X, state.Y, state.ScrollWheelValue, 0, 0, 0, 0, 0, state.HorizontalScrollWheelValue);
#endif
#endif
}
} else {
this.MouseState = default;

View file

@ -246,7 +246,7 @@ namespace MLEM.Input {
/// <returns>Whether text was successfully input.</returns>
public bool OnTextInput(Keys key, char character) {
// FNA's text input event doesn't supply keys, so we handle this in Update
#if !FNA
#if !FNA
if (key == Keys.Back) {
if (this.CaretPos > 0) {
this.CaretPos--;
@ -261,9 +261,9 @@ namespace MLEM.Input {
return this.InsertText(character);
}
return false;
#else
#else
return this.InsertText(character);
#endif
#endif
}
/// <summary>
@ -274,8 +274,8 @@ namespace MLEM.Input {
public void Update(GameTime time, InputHandler input) {
this.UpdateTextDataIfDirty();
#if FNA
// FNA's text input event doesn't supply keys, so we handle this here
#if FNA
if (this.CaretPos > 0 && input.TryConsumePressed(Keys.Back)) {
this.CaretPos--;
this.RemoveText(this.CaretPos, 1);
@ -284,7 +284,7 @@ namespace MLEM.Input {
} else if (this.Multiline && input.TryConsumePressed(Keys.Enter)) {
this.InsertText('\n');
} else
#endif
#endif
if (this.CaretPos > 0 && input.TryConsumePressed(Keys.Left)) {
this.CaretPos--;
} else if (this.CaretPos < this.text.Length && input.TryConsumePressed(Keys.Right)) {

View file

@ -27,11 +27,11 @@ namespace MLEM.Misc {
/// <typeparam name="T">The type whose enum to get</typeparam>
/// <returns>An enumerable of the values of the enum, in declaration order.</returns>
public static T[] GetValues<T>() where T : struct, Enum {
#if NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
return Enum.GetValues<T>();
#else
#else
return (T[]) Enum.GetValues(typeof(T));
#endif
#endif
}
/// <summary>

View file

@ -399,7 +399,7 @@ public class GameImpl : MlemGame {
Console.WriteLine("Down: " + string.Join(", ", Input.InputsDown));*/
if (MlemGame.Input.InputsPressed.Length > 0)
Console.WriteLine("Pressed: " + string.Join(", ", MlemGame.Input.InputsPressed));
MlemGame.Input.HandleKeyboardRepeats = false;/*
MlemGame.Input.HandleKeyboardRepeats = false; /*
Console.WriteLine("Down time: " + MlemGame.Input.GetDownTime(Keys.A));
Console.WriteLine("Time since press: " + MlemGame.Input.GetTimeSincePress(Keys.A));*/
Console.WriteLine("Up time: " + MlemGame.Input.GetUpTime(Keys.A));

View file

@ -2,7 +2,7 @@
using MLEM.Cameras;
using NUnit.Framework;
namespace Tests;
namespace Tests;
public class CameraTests {

View file

@ -1,7 +1,7 @@
using MLEM.Extensions;
using NUnit.Framework;
namespace Tests;
namespace Tests;
public class CollectionTests {

View file

@ -5,7 +5,7 @@ using MLEM.Data;
using MLEM.Textures;
using NUnit.Framework;
namespace Tests;
namespace Tests;
public class TestDataTextureAtlas {

View file

@ -2,7 +2,7 @@ using Microsoft.Xna.Framework;
using MLEM.Misc;
using NUnit.Framework;
namespace Tests;
namespace Tests;
public class DirectionTests {

View file

@ -2,7 +2,7 @@
using MLEM.Input;
using NUnit.Framework;
namespace Tests;
namespace Tests;
public class KeybindTests {

View file

@ -73,7 +73,7 @@ public class NumberTests {
Assert.AreEqual(penetration, 0);
}
#if !FNA
#if !FNA
[Test]
public void TestRangePercentage() {
Assert.AreEqual(0.5F, new Range<int>(1, 7).GetPercentage(4));
@ -95,6 +95,6 @@ public class NumberTests {
Assert.AreEqual(11, new Range<float>(8, 10).FromPercentage(1.5F));
Assert.AreEqual(7, new Range<float>(8, 10).FromPercentage(-0.5F));
}
#endif
#endif
}

View file

@ -4,7 +4,7 @@ using Microsoft.Xna.Framework;
using MLEM.Pathfinding;
using NUnit.Framework;
namespace Tests;
namespace Tests;
public class PathfindingTests {

View file

@ -3,7 +3,7 @@ using MLEM.Data.Content;
using MLEM.Font;
using MLEM.Startup;
namespace Tests;
namespace Tests;
public class TestGame : MlemGame {

View file

@ -4,7 +4,7 @@ using MLEM.Data;
using MLEM.Textures;
using NUnit.Framework;
namespace Tests;
namespace Tests;
public class TexturePackerTests {

View file

@ -8,7 +8,7 @@ using MLEM.Ui.Elements;
using MLEM.Ui.Style;
using NUnit.Framework;
namespace Tests;
namespace Tests;
public class UiTests {