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;
}
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)
{
if (!tryMoveTileView(delta)) return;
@ -120,23 +140,6 @@ namespace stardew_access.Features
this.prevPlayerPosition = this.PlayerPosition;
if (MainClass.Config.SnapMouse)
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)
@ -146,11 +149,7 @@ namespace stardew_access.Features
//prevent mousing over the toolbar or any other UI component with the tile cursor
foreach (IClickableMenu menu in Game1.onScreenMenus)
{
if (menu.allClickableComponents == null) continue;
foreach (ClickableComponent component in menu.allClickableComponents)
{
if (component.containsPoint((int)point.X, (int)point.Y)) return false;
}
if (menu.isWithinBounds((int)point.X - Game1.viewport.X, (int)point.Y - Game1.viewport.Y)) return false;
}
return true;
}

View File

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