Gamepad support

This commit is contained in:
Rendo 2025-07-28 05:07:37 +05:00
commit ed369cf718
24 changed files with 240 additions and 78 deletions

View file

@ -29,7 +29,6 @@ public partial class ShovelButton : TextureButton
public override void _Toggled(bool toggledOn)
{
Cursor.Instance.shovel = toggledOn;
Cursor.Instance.UpdateCursor();
}
public override void _Input(InputEvent @event)
@ -68,7 +67,7 @@ public partial class ShovelButton : TextureButton
if (ButtonPressed)
{
var gridEntity = GetTile(PoolContainer.Instance.Plants.GetGlobalMousePosition());
var gridEntity = GetTile(Cursor.GetCursorPosition());
if (TrySetGridEntity(gridEntity)) return;
if (TrySetDynEntity()) return;
@ -129,7 +128,7 @@ public partial class ShovelButton : TextureButton
}
private bool TrySetDynEntity()
{
raycast.GlobalPosition = PoolContainer.Instance.GetGlobalMousePosition();
raycast.GlobalPosition = Cursor.GetCursorPosition();
if (raycast.IsColliding())
{

View file

@ -22,9 +22,11 @@ public partial class GridLoader : GridContainer
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
AddChild(slot);
slot.SetResource(resource);
slot.SetForbidden(RuntimeLevelData.LevelResource.forbiddenPlants.Contains(resource.internal_id));
slot.SetLocked(PlayerProgress.Instance.PlayerPlants.Contains(resource) == false);
if (GetChildCount() == 1) slot.GrabFocus();
var handler = new ChoosableHandler(slot);
slot.SetHandler(handler);
}

View file

@ -1,4 +1,5 @@
using Godot;
using Newlon.Components.GUI.Seedpackets;
using Newlon.Components.Level;
namespace Newlon.Components.GUI;
@ -8,5 +9,6 @@ public partial class LevelRunButton : Button
public override void _Pressed()
{
RuntimeLevelData.Instance.SetLevelState(RuntimeLevelData.LevelStates.Pregame);
LevelGUIElements.Instance.SeedpacketsHotbar.GetChild<Seedpacket>(0).GrabFocus();
}
}

View file

@ -1,5 +1,7 @@
extends Node
func _ready() -> void:
$InfoButtons/AboutButton.grab_focus()
func _on_play_button_pressed() -> void:
LevelController.call("StartLevel",preload("uid://dd3yegl1xo44m"),preload("uid://dwd5oqr0tuvhv"))

View file

@ -37,14 +37,6 @@ public partial class Seedpacket : TextureButton
public override void _Process(double delta)
{
Disabled = disablePacket || _timer.TimeLeft > 0;
if (Disabled)
{
FocusMode = FocusModeEnum.None;
}
else
{
FocusMode = FocusModeEnum.All;
}
if (_handler is ISeedpacketProcess processHandler) processHandler.Process();
}
public void SetResource(GridEntityResource resource)
@ -88,7 +80,6 @@ public partial class Seedpacket : TextureButton
public void Recharge()
{
_timer.Start();
ReleaseFocus();
}
public void OnUnfocused()