Refactored keyboard tile cursor input to be triggered at the same time as the rest of keyboard input; fix bug in reading UI components with tile cursor.

master
bradjrenshaw 2022-05-10 14:37:43 -04:00
parent 332dd858a8
commit a8bcaf6cef
2 changed files with 24 additions and 22 deletions

View File

@ -61,6 +61,26 @@ namespace stardew_access.Features
return target; return target;
} }
public void HandleInput()
{
if (MainClass.Config.TileCursorUpKey.JustPressed())
{
this.cursorMoveInput(new Vector2(0, -Game1.tileSize));
}
else if (MainClass.Config.TileCursorRightKey.JustPressed())
{
this.cursorMoveInput(new Vector2(Game1.tileSize, 0));
}
else if (MainClass.Config.TileCursorDownKey.JustPressed())
{
this.cursorMoveInput(new Vector2(0, Game1.tileSize));
}
else if (MainClass.Config.TileCursorLeftKey.JustPressed())
{
this.cursorMoveInput(new Vector2(-Game1.tileSize, 0));
}
}
private void cursorMoveInput(Vector2 delta, Boolean precise = false) private void cursorMoveInput(Vector2 delta, Boolean precise = false)
{ {
if (!tryMoveTileView(delta)) return; if (!tryMoveTileView(delta)) return;
@ -120,23 +140,6 @@ namespace stardew_access.Features
this.prevPlayerPosition = this.PlayerPosition; this.prevPlayerPosition = this.PlayerPosition;
if (MainClass.Config.SnapMouse) if (MainClass.Config.SnapMouse)
this.SnapMouseToPlayer(); this.SnapMouseToPlayer();
if (MainClass.Config.TileCursorUpKey.JustPressed())
{
this.cursorMoveInput(new Vector2(0, -Game1.tileSize));
}
else if (MainClass.Config.TileCursorRightKey.JustPressed())
{
this.cursorMoveInput(new Vector2(Game1.tileSize, 0));
}
else if (MainClass.Config.TileCursorDownKey.JustPressed())
{
this.cursorMoveInput(new Vector2(0, Game1.tileSize));
}
else if (MainClass.Config.TileCursorLeftKey.JustPressed())
{
this.cursorMoveInput(new Vector2(-Game1.tileSize, 0));
}
} }
private static bool allowMouseSnap(Vector2 point) private static bool allowMouseSnap(Vector2 point)
@ -146,11 +149,7 @@ namespace stardew_access.Features
//prevent mousing over the toolbar or any other UI component with the tile cursor //prevent mousing over the toolbar or any other UI component with the tile cursor
foreach (IClickableMenu menu in Game1.onScreenMenus) foreach (IClickableMenu menu in Game1.onScreenMenus)
{ {
if (menu.allClickableComponents == null) continue; if (menu.isWithinBounds((int)point.X - Game1.viewport.X, (int)point.Y - Game1.viewport.Y)) return false;
foreach (ClickableComponent component in menu.allClickableComponents)
{
if (component.containsPoint((int)point.X, (int)point.Y)) return false;
}
} }
return true; return true;
} }

View File

@ -267,6 +267,9 @@ get
ReadTile.run(manuallyTriggered: true); ReadTile.run(manuallyTriggered: true);
return; return;
} }
// Tile viewing cursor keys
Mouse.HandleInput();
} }
public static void ErrorLog(string message) public static void ErrorLog(string message)