From 7a1b768bdbed437bbafaf0691cdf89b6ab971464 Mon Sep 17 00:00:00 2001 From: bradjrenshaw Date: Tue, 10 May 2022 16:31:54 -0400 Subject: [PATCH] Added option to allow tile cursor to view the entire map regardless if it is visible or not. --- stardew-access/Features/MouseHandler.cs | 13 ++++++++++--- stardew-access/ModConfig.cs | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/stardew-access/Features/MouseHandler.cs b/stardew-access/Features/MouseHandler.cs index f909ab9..a84f52e 100644 --- a/stardew-access/Features/MouseHandler.cs +++ b/stardew-access/Features/MouseHandler.cs @@ -6,7 +6,6 @@ using StardewValley; using StardewValley.Menus; using stardew_access.Features; - namespace stardew_access.Features { public class MouseHandler @@ -137,13 +136,13 @@ namespace stardew_access.Features private bool tryMoveTileView(Vector2 delta) { Vector2 dest = this.getTileCursorPosition() + delta; - if (Utility.isOnScreen(dest, 0)) + if (!isPositionOnMap(dest)) return false; + if ((MainClass.Config.LimitTileCursorToScreen && Utility.isOnScreen(dest, 0)) || !MainClass.Config.LimitTileCursorToScreen) { if (this.relativeOffsetLock) this.relativeOffsetLockPosition += delta; else this.ViewingOffset += delta; - return true; } return false; @@ -180,5 +179,13 @@ namespace stardew_access.Features } return true; } + + private static bool isPositionOnMap(Vector2 position) + { + Map map = Game1.currentLocation.map; + if (position.X < 0 || position.X > map.Layers[0].DisplayWidth) return false; + if (position.Y < 0 || position.Y > map.Layers[0].DisplayHeight) return false; + return true; + } } } diff --git a/stardew-access/ModConfig.cs b/stardew-access/ModConfig.cs index 445fa1b..479c25d 100644 --- a/stardew-access/ModConfig.cs +++ b/stardew-access/ModConfig.cs @@ -25,6 +25,7 @@ namespace stardew_access public KeybindList TimeNSeasonKey { get; set; } = KeybindList.Parse("Q"); public KeybindList ReadTileKey { get; set; } = KeybindList.Parse("J"); public KeybindList ReadStandingTileKey { get; set; } = KeybindList.Parse("LeftAlt + J"); + public bool LimitTileCursorToScreen { get; set; } = false; public int TileCursorPreciseMovementDistance { get; set; } = 8; //Tile viewer keys