From 2d7cb24ac250301496068bb57e5fca50b4d99d9e Mon Sep 17 00:00:00 2001 From: Robbie Lodico Date: Tue, 25 Feb 2025 09:42:32 -0500 Subject: [PATCH] replace Pointf with System.Numerics.Vector2 --- Framework/Intersect.Framework.Core/Point.cs | 5 ++ Intersect.Client.Core/Core/Graphics.cs | 11 +-- Intersect.Client.Core/Entities/Entity.cs | 11 +-- .../Entities/Events/Event.cs | 9 ++- .../Interface/Shared/FPSPanel.cs | 3 +- .../MonoGame/Graphics/MonoRenderer.cs | 20 ++--- .../MonoGame/Graphics/MonoShader.cs | 3 +- .../MonoGame/Input/MonoInput.cs | 10 +-- .../Entities/IEntity.cs | 5 +- .../GenericClasses/FloatRect.cs | 15 ++-- .../GenericClasses/Pointf.cs | 73 ------------------- .../Graphics/GameRenderer.cs | 5 +- .../Graphics/GameShader.cs | 5 +- .../Graphics/GameTexture.cs | 5 +- .../Graphics/IGameRenderer.cs | 7 +- .../Graphics/IGameTexture.cs | 5 +- .../Graphics/ITextHelper.cs | 3 +- .../Gwen/Control/Slider.cs | 3 +- .../Gwen/ControlInternal/SliderBar.cs | 7 +- .../Gwen/Input/IntersectInput.cs | 7 +- .../Gwen/Renderer/Base.cs | 5 +- .../Gwen/Renderer/IntersectRenderer.cs | 2 +- Intersect.Client.Framework/Input/GameInput.cs | 5 +- .../Input/IGameInput.cs | 5 +- 24 files changed, 90 insertions(+), 139 deletions(-) delete mode 100644 Intersect.Client.Framework/GenericClasses/Pointf.cs diff --git a/Framework/Intersect.Framework.Core/Point.cs b/Framework/Intersect.Framework.Core/Point.cs index e28bf45ea2..7e0941a405 100644 --- a/Framework/Intersect.Framework.Core/Point.cs +++ b/Framework/Intersect.Framework.Core/Point.cs @@ -1,3 +1,4 @@ +using System.Numerics; using MessagePack; namespace Intersect; @@ -81,4 +82,8 @@ public void Deconstruct(out int x, out int y) x = X; y = Y; } + + public static implicit operator Point(Vector2 vector) => new((int)vector.X, (int)vector.Y); + + public static implicit operator Vector2(Point point) => new(point.X, point.Y); } diff --git a/Intersect.Client.Core/Core/Graphics.cs b/Intersect.Client.Core/Core/Graphics.cs index e22c308433..745c4a0e28 100644 --- a/Intersect.Client.Core/Core/Graphics.cs +++ b/Intersect.Client.Core/Core/Graphics.cs @@ -1,3 +1,4 @@ +using System.Numerics; using Intersect.Client.Entities; using Intersect.Client.Entities.Events; using Intersect.Client.Framework.Content; @@ -1098,7 +1099,7 @@ private static void GenerateLightMap() return; } - var destRect = new FloatRect(new Pointf(), sDarknessTexture.Dimensions / Globals.Database.WorldZoom); + var destRect = new FloatRect(new Vector2(), sDarknessTexture.Dimensions / Globals.Database.WorldZoom); if (map.IsIndoors) { DrawGameTexture( @@ -1411,9 +1412,9 @@ public static void UpdatePlayerLight() /// /// The point to convert. /// The converted point. - public static Pointf ConvertToWorldPoint(Pointf windowPoint) + public static Vector2 ConvertToWorldPoint(Vector2 windowPoint) { - return new Pointf( + return new Vector2( (int)Math.Floor(windowPoint.X / Globals.Database.WorldZoom + CurrentView.Left), (int)Math.Floor(windowPoint.Y / Globals.Database.WorldZoom + CurrentView.Top) ); @@ -1424,9 +1425,9 @@ public static Pointf ConvertToWorldPoint(Pointf windowPoint) /// /// The point to convert. /// The converted point. - public static Pointf ConvertToWorldPointNoZoom(Pointf windowPoint) + public static Vector2 ConvertToWorldPointNoZoom(Vector2 windowPoint) { - return new Pointf((int)Math.Floor(windowPoint.X + CurrentView.Left), (int)Math.Floor(windowPoint.Y + CurrentView.Top)); + return new Vector2((int)Math.Floor(windowPoint.X + CurrentView.Left), (int)Math.Floor(windowPoint.Y + CurrentView.Top)); } //Rendering Functions diff --git a/Intersect.Client.Core/Entities/Entity.cs b/Intersect.Client.Core/Entities/Entity.cs index 808bc90163..88c3e106fa 100644 --- a/Intersect.Client.Core/Entities/Entity.cs +++ b/Intersect.Client.Core/Entities/Entity.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Numerics; using Intersect.Client.Core; using Intersect.Client.Entities.Events; using Intersect.Client.Entities.Projectiles; @@ -129,7 +130,7 @@ public Guid[] Equipment IReadOnlyDictionary IEntity.MaxVitals => Enum.GetValues().ToDictionary(vital => vital, vital => MaxVital[(int)vital]); - protected Pointf mOrigin = Pointf.Empty; + protected Vector2 mOrigin = Vector2.Zero; //Chat private readonly List mChatBubbles = []; @@ -276,11 +277,11 @@ public Entity(Guid id, EntityPacket? packet, EntityType entityType) IReadOnlyList IEntity.Status => Status; - public Pointf Origin => LatestMap == default ? Pointf.Empty : mOrigin; + public Vector2 Origin => LatestMap == default ? Vector2.Zero : mOrigin; - protected virtual Pointf CenterOffset => (Texture == default) ? Pointf.Empty : (Pointf.UnitY * Texture.Center.Y / Options.Instance.Sprites.Directions); + protected virtual Vector2 CenterOffset => (Texture == default) ? Vector2.Zero : (Vector2.UnitY * Texture.Center.Y / Options.Instance.Sprites.Directions); - public Pointf Center => Origin - CenterOffset; + public Vector2 Center => Origin - CenterOffset; public Direction Dir { @@ -1475,7 +1476,7 @@ protected virtual void CalculateOrigin() return; } - mOrigin = new Pointf( + mOrigin = new Vector2( LatestMap.X + X * Options.Instance.Map.TileWidth + OffsetX + Options.Instance.Map.TileWidth / 2, LatestMap.Y + Y * Options.Instance.Map.TileHeight + OffsetY + Options.Instance.Map.TileHeight ); diff --git a/Intersect.Client.Core/Entities/Events/Event.cs b/Intersect.Client.Core/Entities/Events/Event.cs index c7606738d3..685e27d567 100644 --- a/Intersect.Client.Core/Entities/Events/Event.cs +++ b/Intersect.Client.Core/Entities/Events/Event.cs @@ -1,3 +1,4 @@ +using System.Numerics; using Intersect.Client.Core; using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; @@ -29,24 +30,24 @@ public partial class Event : Entity public EventTrigger Trigger { get; set; } - protected override Pointf CenterOffset + protected override Vector2 CenterOffset { get { switch (Graphic.Type) { case EventGraphicType.None: - return HasAnimations ? Pointf.UnitY * Options.Instance.Map.TileHeight / 2f : Pointf.Empty; + return HasAnimations ? Vector2.UnitY * Options.Instance.Map.TileHeight / 2f : Vector2.Zero; case EventGraphicType.Sprite: return base.CenterOffset; case EventGraphicType.Tileset: - return Pointf.UnitY * Options.Instance.Map.TileHeight * (Graphic.Height + 1) / 2f; + return Vector2.UnitY * Options.Instance.Map.TileHeight * (Graphic.Height + 1) / 2f; default: ApplicationContext.Context.Value?.Logger.LogError($"Unimplemented graphic type: {Graphic.Type}"); - return Pointf.Empty; + return Vector2.Zero; } } } diff --git a/Intersect.Client.Core/Interface/Shared/FPSPanel.cs b/Intersect.Client.Core/Interface/Shared/FPSPanel.cs index 4230eb228e..7c8820f5a9 100644 --- a/Intersect.Client.Core/Interface/Shared/FPSPanel.cs +++ b/Intersect.Client.Core/Interface/Shared/FPSPanel.cs @@ -1,3 +1,4 @@ +using System.Numerics; using Intersect.Client.Core; using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.GenericClasses; @@ -44,7 +45,7 @@ public FPSPanel(Base parent, string name = nameof(FPSPanel)) : base(parent: pare size: 10, fontScale: 1 ) + - new Pointf(16, 8); + new Vector2(16, 8); DelegateDataProvider fpsProvider = new(() => Graphics.Renderer.FPS) { diff --git a/Intersect.Client.Core/MonoGame/Graphics/MonoRenderer.cs b/Intersect.Client.Core/MonoGame/Graphics/MonoRenderer.cs index da06822e3e..b860e2b73b 100644 --- a/Intersect.Client.Core/MonoGame/Graphics/MonoRenderer.cs +++ b/Intersect.Client.Core/MonoGame/Graphics/MonoRenderer.cs @@ -264,9 +264,9 @@ protected override bool RecreateSpriteBatch() return true; } - public Pointf GetMouseOffset() + public Vector2 GetMouseOffset() { - return new Pointf( + return new Vector2( _graphicsDeviceManager.PreferredBackBufferWidth / (float)_gameWindow.ClientBounds.Width, _graphicsDeviceManager.PreferredBackBufferHeight / (float)_gameWindow.ClientBounds.Height ); @@ -703,10 +703,10 @@ public override void DrawTexture( origin = new Vector2(sw / 2f, sh / 2f); //TODO: Optimize in terms of memory AND performance. - var pnt = new Pointf(0, 0); - var pnt1 = new Pointf(tw, 0); - var pnt2 = new Pointf(0, th); - var cntr = new Pointf(tw / 2, th / 2); + var pnt = new Vector2(0, 0); + var pnt1 = new Vector2(tw, 0); + var pnt2 = new Vector2(0, th); + var cntr = new Vector2(tw / 2, th / 2); var pntMod = Rotate(pnt, cntr, rotationDegrees); var pntMod2 = Rotate(pnt1, cntr, rotationDegrees); @@ -778,9 +778,9 @@ private static double GetDistance(double x1, double y1, double x2, double y2) return root; } - private Pointf Rotate(Pointf pnt, Pointf ctr, float angle) + private Vector2 Rotate(Vector2 pnt, Vector2 ctr, float angle) { - return new Pointf( + return new Vector2( (float)(pnt.X + (ctr.X * Math.Cos(angle)) - (ctr.Y * Math.Sin(angle))), (float)(pnt.Y + (ctr.X * Math.Sin(angle)) + (ctr.Y * Math.Cos(angle))) ); @@ -976,7 +976,7 @@ public override GameShader LoadShader(string shaderName) return new MonoShader(shaderName, _contentManager); } - public override Pointf MeasureText(string text, IFont? font, int size, float fontScale) + public override System.Numerics.Vector2 MeasureText(string text, IFont? font, int size, float fontScale) { if (font is not Font platformFont) { @@ -989,7 +989,7 @@ public override Pointf MeasureText(string text, IFont? font, int size, float fon var textMeasurement = spriteFont.MeasureString(text); - return new Pointf(textMeasurement.X * fontScale, textMeasurement.Y * fontScale); + return new System.Numerics.Vector2(textMeasurement.X * fontScale, textMeasurement.Y * fontScale); } private readonly Dictionary _defaultCharacterForSpriteFont = []; diff --git a/Intersect.Client.Core/MonoGame/Graphics/MonoShader.cs b/Intersect.Client.Core/MonoGame/Graphics/MonoShader.cs index 95d88866d0..bfc9afeb68 100644 --- a/Intersect.Client.Core/MonoGame/Graphics/MonoShader.cs +++ b/Intersect.Client.Core/MonoGame/Graphics/MonoShader.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; +using Vector2 = System.Numerics.Vector2; namespace Intersect.Client.MonoGame.Graphics; @@ -65,7 +66,7 @@ public override void SetColor(string key, Color val) } } - public override void SetVector2(string key, Pointf val) + public override void SetVector2(string key, Vector2 val) { //throw new NotImplementedException(); } diff --git a/Intersect.Client.Core/MonoGame/Input/MonoInput.cs b/Intersect.Client.Core/MonoGame/Input/MonoInput.cs index 8205d5cb96..7c3faefc19 100644 --- a/Intersect.Client.Core/MonoGame/Input/MonoInput.cs +++ b/Intersect.Client.Core/MonoGame/Input/MonoInput.cs @@ -154,7 +154,7 @@ private void InputHandlerOnFocusChanged(Base? control, FocusSource focusSource) Mouse.SetPosition((int)center.X, (int)center.Y); var mouseState = Mouse.GetState(); Interface.Interface.GwenInput.ProcessMessage( - new GwenInputMessage(IntersectInput.InputEvent.MouseMove, new Pointf(mouseState.X, mouseState.Y), MouseButton.None, Keys.Alt) + new GwenInputMessage(IntersectInput.InputEvent.MouseMove, new System.Numerics.Vector2(mouseState.X, mouseState.Y), MouseButton.None, Keys.Alt) ); } @@ -197,9 +197,9 @@ public override bool IsKeyDown(Keys key) => public override bool WasKeyDown(Keys key) => _intersectToMonoGameKeyMap.TryGetValue(key, out var mappedKey) && _previousKeyboardState.IsKeyDown(mappedKey); - public override Pointf GetMousePosition() + public override System.Numerics.Vector2 GetMousePosition() { - return new Pointf(mMouseX, mMouseY); + return new System.Numerics.Vector2(mMouseX, mMouseY); } private void CheckMouseButton(Keys modifier, ButtonState bs, MouseButton mb) @@ -242,11 +242,11 @@ private void CheckMouseButton(Keys modifier, ButtonState bs, MouseButton mb) private void CheckMouseScrollWheel(int scrlVValue, int scrlHValue) { - Pointf p = new Pointf(0, 0); + System.Numerics.Vector2 p = default; if (scrlVValue != mMouseVScroll || scrlHValue != mMouseHScroll) { - p = new Pointf(scrlHValue - mMouseHScroll, scrlVValue - mMouseVScroll); + p = new System.Numerics.Vector2(scrlHValue - mMouseHScroll, scrlVValue - mMouseVScroll); Interface.Interface.GwenInput.ProcessMessage( new GwenInputMessage(IntersectInput.InputEvent.MouseScroll, p, MouseButton.Middle, Keys.Alt) diff --git a/Intersect.Client.Framework/Entities/IEntity.cs b/Intersect.Client.Framework/Entities/IEntity.cs index c579b66bbb..80b41f8cd0 100644 --- a/Intersect.Client.Framework/Entities/IEntity.cs +++ b/Intersect.Client.Framework/Entities/IEntity.cs @@ -1,3 +1,4 @@ +using System.Numerics; using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Items; @@ -24,8 +25,8 @@ public interface IEntity : IDisposable FloatRect WorldPos { get; } float OffsetX { get; } float OffsetY { get; } - Pointf Center { get; } - Pointf Origin { get; } + Vector2 Center { get; } + Vector2 Origin { get; } bool IsMoving { get; } bool IsStealthed { get; } bool IsBlocking { get; } diff --git a/Intersect.Client.Framework/GenericClasses/FloatRect.cs b/Intersect.Client.Framework/GenericClasses/FloatRect.cs index 18240f2305..93e5d30586 100644 --- a/Intersect.Client.Framework/GenericClasses/FloatRect.cs +++ b/Intersect.Client.Framework/GenericClasses/FloatRect.cs @@ -1,4 +1,5 @@ -using System.Runtime.CompilerServices; +using System.Numerics; +using System.Runtime.CompilerServices; namespace Intersect.Client.Framework.GenericClasses; @@ -38,9 +39,9 @@ public float Height set => mHeight = value; } - public Pointf Position + public Vector2 Position { - get => new Pointf(X, Y); + get => new Vector2(X, Y); set { X = value.X; @@ -48,9 +49,9 @@ public Pointf Position } } - public Pointf Size + public Vector2 Size { - get => new Pointf(Width, Height); + get => new Vector2(Width, Height); set { Width = value.X; @@ -58,7 +59,7 @@ public Pointf Size } } - public Pointf Center => Position + Size / 2f; + public Vector2 Center => Position + Size / 2f; public float Left => X; @@ -78,7 +79,7 @@ public FloatRect(float x, float y, float w, float h) mHeight = h; } - public FloatRect(Pointf position, Pointf size) : this( + public FloatRect(Vector2 position, Vector2 size) : this( position.X, position.Y, size.X, diff --git a/Intersect.Client.Framework/GenericClasses/Pointf.cs b/Intersect.Client.Framework/GenericClasses/Pointf.cs deleted file mode 100644 index e17e58ed88..0000000000 --- a/Intersect.Client.Framework/GenericClasses/Pointf.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Runtime.Serialization; - -namespace Intersect.Client.Framework.GenericClasses; - -[DataContract] -[DebuggerDisplay("{DebugDisplayString,nq}")] -[StructLayout(LayoutKind.Explicit)] -public partial struct Pointf : IEquatable -{ - [FieldOffset(0)] - public float X; - - [FieldOffset(sizeof(float))] - public float Y; - - public static Pointf Empty => new(); - - public static Pointf UnitX => new(1, 0); - - public static Pointf UnitY => new(0, 1); - - public static Pointf One => new(1, 1); - - private const float Tolerance = 0.001f; - - public Pointf() - { - } - - public Pointf(float value) : this(value, value) { } - - public Pointf(float x, float y) - { - X = x; - Y = y; - } - - public Pointf(double x, double y) : this((float)x, (float)y) - { - } - - public override bool Equals(object? obj) => obj is Pointf point && Equals(point); - - public bool Equals(Pointf other) => this == other; - - public override int GetHashCode() => HashCode.Combine(X, Y); - - public static implicit operator Pointf(Point point) => new(point.X, point.Y); - - public static implicit operator Point(Pointf point) => new((int)point.X, (int)point.Y); - - public static bool operator ==(Pointf left, Pointf right) => left.X.Equals(right.X) && left.Y.Equals(right.Y); - - public static bool operator !=(Pointf left, Pointf right) => !left.X.Equals(right.X) || !left.Y.Equals(right.Y); - - public static Pointf operator +(Pointf left, Pointf right) => new(left.X + right.X, left.Y + right.Y); - - public static Pointf operator -(Pointf left, Pointf right) => new(left.X - right.X, left.Y - right.Y); - - public static Pointf operator *(Pointf lhs, Pointf rhs) => new(lhs.X * rhs.X, lhs.Y * rhs.Y); - - public static Pointf operator *(Pointf point, float scalar) => new(point.X * scalar, point.Y * scalar); - - public static Pointf operator *(float scalar, Pointf point) => new(point.X * scalar, point.Y * scalar); - - public static Pointf operator /(Pointf point, float scalar) => new(point.X / scalar, point.Y / scalar); - - internal string DebugDisplayString => $"{X}, {Y}"; - - public override string ToString() => $"({X}, {Y})"; -} diff --git a/Intersect.Client.Framework/Graphics/GameRenderer.cs b/Intersect.Client.Framework/Graphics/GameRenderer.cs index f54c1968bf..c9f3e0f902 100644 --- a/Intersect.Client.Framework/Graphics/GameRenderer.cs +++ b/Intersect.Client.Framework/Graphics/GameRenderer.cs @@ -1,5 +1,6 @@ using System.Collections.Concurrent; using System.Diagnostics; +using System.Numerics; using Intersect.Client.Framework.GenericClasses; using Intersect.Core; using Intersect.Framework.Collections; @@ -158,7 +159,7 @@ float rotationDegrees public abstract IGameRenderTexture CreateRenderTexture(int width, int height); - public abstract Pointf MeasureText(string? text, IFont? font, int size, float fontScale); + public abstract Vector2 MeasureText(string? text, IFont? font, int size, float fontScale); public abstract void DrawString( string text, @@ -488,7 +489,7 @@ public IGameTexture LoadTexture(string assetName, string filePath) catch { #if DEBUG - Debugger.Break(); + // Debugger.Break(); #endif throw; } diff --git a/Intersect.Client.Framework/Graphics/GameShader.cs b/Intersect.Client.Framework/Graphics/GameShader.cs index 30379b600a..acacab40f0 100644 --- a/Intersect.Client.Framework/Graphics/GameShader.cs +++ b/Intersect.Client.Framework/Graphics/GameShader.cs @@ -1,4 +1,5 @@ -using Intersect.Client.Framework.GenericClasses; +using System.Numerics; +using Intersect.Client.Framework.GenericClasses; namespace Intersect.Client.Framework.Graphics; @@ -14,7 +15,7 @@ public GameShader(string shaderName) public abstract void SetColor(string key, Color val); - public abstract void SetVector2(string key, Pointf val); + public abstract void SetVector2(string key, Vector2 val); public abstract bool ValuesChanged(); diff --git a/Intersect.Client.Framework/Graphics/GameTexture.cs b/Intersect.Client.Framework/Graphics/GameTexture.cs index 0095d6cdab..2fd9cd8551 100644 --- a/Intersect.Client.Framework/Graphics/GameTexture.cs +++ b/Intersect.Client.Framework/Graphics/GameTexture.cs @@ -1,3 +1,4 @@ +using System.Numerics; using System.Runtime.CompilerServices; using Intersect.Client.Framework.Content; using Intersect.Client.Framework.GenericClasses; @@ -184,9 +185,9 @@ protected TPlatformTexture? PlatformTexture public FloatRect Bounds => new(0, 0, Width, Height); - public Pointf Dimensions => new(Width, Height); + public Vector2 Dimensions => new(Width, Height); - public Pointf Center => Dimensions / 2; + public Vector2 Center => Dimensions / 2; public AtlasReference? AtlasReference { diff --git a/Intersect.Client.Framework/Graphics/IGameRenderer.cs b/Intersect.Client.Framework/Graphics/IGameRenderer.cs index fe1d739bd5..b6b55c4f98 100644 --- a/Intersect.Client.Framework/Graphics/IGameRenderer.cs +++ b/Intersect.Client.Framework/Graphics/IGameRenderer.cs @@ -1,4 +1,5 @@ -using Intersect.Client.Framework.GenericClasses; +using System.Numerics; +using Intersect.Client.Framework.GenericClasses; namespace Intersect.Client.Framework.Graphics; @@ -179,8 +180,8 @@ void DrawString( /// The to use to measure the text with. /// /// The scale of the font to measure the text with. - /// Returns a containing the width and height of the measured text. - Pointf MeasureText(string? text, IFont? font, int size, float fontScale); + /// Returns a containing the width and height of the measured text. + Vector2 MeasureText(string? text, IFont? font, int size, float fontScale); /// /// Send a request for the client to take a screenshot the next draw cycle. diff --git a/Intersect.Client.Framework/Graphics/IGameTexture.cs b/Intersect.Client.Framework/Graphics/IGameTexture.cs index 56bb65d4cb..349bb38e77 100644 --- a/Intersect.Client.Framework/Graphics/IGameTexture.cs +++ b/Intersect.Client.Framework/Graphics/IGameTexture.cs @@ -1,3 +1,4 @@ +using System.Numerics; using System.Runtime.CompilerServices; using Intersect.Client.Framework.Content; using Intersect.Client.Framework.GenericClasses; @@ -12,9 +13,9 @@ public interface IGameTexture : IAsset, IComparable, IDisposable bool IsMissingOrCorrupt { get; } bool IsPinned { get; } int Area { get; } - Pointf Dimensions { get; } + Vector2 Dimensions { get; } FloatRect Bounds { get; } - Pointf Center { get; } + Vector2 Center { get; } AtlasReference? AtlasReference { diff --git a/Intersect.Client.Framework/Graphics/ITextHelper.cs b/Intersect.Client.Framework/Graphics/ITextHelper.cs index f4f4bd3246..aaaf78e526 100644 --- a/Intersect.Client.Framework/Graphics/ITextHelper.cs +++ b/Intersect.Client.Framework/Graphics/ITextHelper.cs @@ -1,8 +1,9 @@ +using System.Numerics; using Intersect.Client.Framework.GenericClasses; namespace Intersect.Client.Framework.Graphics; public interface ITextHelper { - Pointf MeasureText(string? text, IFont? font, int size, float fontScale); + Vector2 MeasureText(string? text, IFont? font, int size, float fontScale); } \ No newline at end of file diff --git a/Intersect.Client.Framework/Gwen/Control/Slider.cs b/Intersect.Client.Framework/Gwen/Control/Slider.cs index 4a6a597180..f47fb7d4d4 100644 --- a/Intersect.Client.Framework/Gwen/Control/Slider.cs +++ b/Intersect.Client.Framework/Gwen/Control/Slider.cs @@ -1,3 +1,4 @@ +using System.Numerics; using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; @@ -45,7 +46,7 @@ public Slider(Base parent, string? name = default) : base(parent, name) _sliderBar = new SliderBar(this, name: nameof(_sliderBar)) { - AnchorAxis = new Pointf(0, 0.5f), + AnchorAxis = new Vector2(0, 0.5f), }; _sliderBar.Dragged += SliderBarOnDragged; diff --git a/Intersect.Client.Framework/Gwen/ControlInternal/SliderBar.cs b/Intersect.Client.Framework/Gwen/ControlInternal/SliderBar.cs index 1eb7d43a9b..38fba53ed1 100644 --- a/Intersect.Client.Framework/Gwen/ControlInternal/SliderBar.cs +++ b/Intersect.Client.Framework/Gwen/ControlInternal/SliderBar.cs @@ -1,4 +1,5 @@ -using Intersect.Client.Framework.GenericClasses; +using System.Numerics; +using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Gwen.Control; namespace Intersect.Client.Framework.Gwen.ControlInternal; @@ -8,7 +9,7 @@ namespace Intersect.Client.Framework.Gwen.ControlInternal; /// public partial class SliderBar : Dragger { - private Pointf? _anchorAxis; + private Vector2? _anchorAxis; private Orientation _orientation; /// @@ -23,7 +24,7 @@ public SliderBar(Slider parent, string? name = default) : base(parent, name) Orientation = parent.Orientation; } - public Pointf? AnchorAxis + public Vector2? AnchorAxis { get => _anchorAxis; set => SetAndDoIfChanged(ref _anchorAxis, value, Invalidate); diff --git a/Intersect.Client.Framework/Gwen/Input/IntersectInput.cs b/Intersect.Client.Framework/Gwen/Input/IntersectInput.cs index 53229075da..29c8bb50c2 100644 --- a/Intersect.Client.Framework/Gwen/Input/IntersectInput.cs +++ b/Intersect.Client.Framework/Gwen/Input/IntersectInput.cs @@ -1,4 +1,5 @@ -using Intersect.Client.Framework.GenericClasses; +using System.Numerics; +using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Gwen.Control; using Intersect.Client.Framework.Input; @@ -153,7 +154,7 @@ public partial class GwenInputMessage public MouseButton MouseBtn; - public Pointf MousePosition; + public Vector2 MousePosition; public bool Shift; @@ -163,7 +164,7 @@ public partial class GwenInputMessage public GwenInputMessage( IntersectInput.InputEvent type, - Pointf mousePos, + Vector2 mousePos, MouseButton mousebtn, Keys keyAction, bool alt = false, diff --git a/Intersect.Client.Framework/Gwen/Renderer/Base.cs b/Intersect.Client.Framework/Gwen/Renderer/Base.cs index 9ce3573444..186443aa61 100644 --- a/Intersect.Client.Framework/Gwen/Renderer/Base.cs +++ b/Intersect.Client.Framework/Gwen/Renderer/Base.cs @@ -1,4 +1,5 @@ -using Intersect.Client.Framework.GenericClasses; +using System.Numerics; +using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; #if DEBUG || DIAGNOSTIC #endif @@ -445,6 +446,6 @@ public void AddClipRegion(Rectangle rect) mClipRegion = r; } - public Pointf MeasureText(string? text, IFont? font, int size, float fontScale) => + public Vector2 MeasureText(string? text, IFont? font, int size, float fontScale) => MeasureText(font: font, fontSize: size, text: text, scale: fontScale); } diff --git a/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs b/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs index bfe1697bd8..08c3782a8f 100644 --- a/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs +++ b/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs @@ -58,7 +58,7 @@ public override void DrawLine(int x1, int y1, int x2, int y2) Translate(ref x1, ref y1); Translate(ref x2, ref y2); - Vertex[] line = {new Vertex(new Pointf(x1, y1), m_Color), new Vertex(new Pointf(x2, y2), m_Color)}; + Vertex[] line = {new Vertex(new Vector2(x1, y1), m_Color), new Vertex(new Vector2(x2, y2), m_Color)}; m_Target.Draw(line, PrimitiveType.Lines); } diff --git a/Intersect.Client.Framework/Input/GameInput.cs b/Intersect.Client.Framework/Input/GameInput.cs index 6789826cc8..a7ee79d895 100644 --- a/Intersect.Client.Framework/Input/GameInput.cs +++ b/Intersect.Client.Framework/Input/GameInput.cs @@ -1,4 +1,5 @@ using System.Collections.Immutable; +using System.Numerics; using Intersect.Client.Framework.GenericClasses; using Intersect.Core; using Intersect.Framework.Reflection; @@ -116,9 +117,9 @@ public bool RemoveControlsProviders(params IControlsProvider[] controlsProviders public abstract bool WasKeyDown(Keys key); - public Pointf MousePosition => GetMousePosition(); + public Vector2 MousePosition => GetMousePosition(); - public abstract Pointf GetMousePosition(); + public abstract Vector2 GetMousePosition(); public abstract void Update(TimeSpan elapsed); diff --git a/Intersect.Client.Framework/Input/IGameInput.cs b/Intersect.Client.Framework/Input/IGameInput.cs index b30ec51409..723ef4d011 100644 --- a/Intersect.Client.Framework/Input/IGameInput.cs +++ b/Intersect.Client.Framework/Input/IGameInput.cs @@ -1,4 +1,5 @@ -using Intersect.Client.Framework.GenericClasses; +using System.Numerics; +using Intersect.Client.Framework.GenericClasses; namespace Intersect.Client.Framework.Input; @@ -6,7 +7,7 @@ public interface IGameInput { IControlSet ControlSet { get; set; } - Pointf MousePosition { get; } + Vector2 MousePosition { get; } bool IsKeyDown(Keys key); bool WasKeyDown(Keys key);