using Microsoft.Xna.Framework; using StardewValley; namespace StardewModdingAPI.Framework { /// Defines a position on a given map at different reference points. internal class CursorPosition : ICursorPosition { /********* ** Accessors *********/ /// public Vector2 AbsolutePixels { get; } /// public Vector2 ScreenPixels { get; } /// public Vector2 Tile { get; } /// public Vector2 GrabTile { get; } /********* ** Public methods *********/ /// Construct an instance. /// The pixel position relative to the top-left corner of the in-game map, adjusted for zoom but not UI scaling. /// The pixel position relative to the top-left corner of the visible screen, adjusted for zoom but not UI scaling. /// The tile position relative to the top-left corner of the map. /// The tile position that the game considers under the cursor for purposes of clicking actions. public CursorPosition(Vector2 absolutePixels, Vector2 screenPixels, Vector2 tile, Vector2 grabTile) { this.AbsolutePixels = absolutePixels; this.ScreenPixels = screenPixels; this.Tile = tile; this.GrabTile = grabTile; } /// public bool Equals(ICursorPosition? other) { return other != null && this.AbsolutePixels == other.AbsolutePixels; } /// public Vector2 GetScaledAbsolutePixels() { return Game1.uiMode ? Utility.ModifyCoordinatesForUIScale(this.AbsolutePixels) : this.AbsolutePixels; } /// public Vector2 GetScaledScreenPixels() { return Game1.uiMode ? Utility.ModifyCoordinatesForUIScale(this.ScreenPixels) : this.ScreenPixels; } } }