2024-06-04 22:12:01 -07:00
|
|
|
using Godot;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace SupaLidlGame.UI.Inventory;
|
|
|
|
|
2024-09-16 12:33:29 -07:00
|
|
|
public partial class ShopMenu : BaseMenu, IModal
|
2024-06-04 22:12:01 -07:00
|
|
|
{
|
|
|
|
private Items.IItemCollection<Items.ShopEntry> _source;
|
|
|
|
|
|
|
|
public Items.IItemCollection<Items.ShopEntry> Source
|
|
|
|
{
|
|
|
|
get => _source;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_source = value;
|
|
|
|
_inventoryGrid.Source = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-16 12:33:29 -07:00
|
|
|
public override void ShowModal()
|
2024-06-04 22:12:01 -07:00
|
|
|
{
|
|
|
|
Show();
|
|
|
|
var animPlayer = GetNode<AnimationPlayer>("%AnimationPlayer");
|
|
|
|
animPlayer.Play("open");
|
|
|
|
}
|
|
|
|
|
2024-09-16 12:33:29 -07:00
|
|
|
public override void HideModal()
|
2024-06-04 22:12:01 -07:00
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
_source = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
2024-09-16 12:33:29 -07:00
|
|
|
base._Ready();
|
2024-06-04 22:12:01 -07:00
|
|
|
|
2024-09-16 12:33:29 -07:00
|
|
|
_focusButtonOnSelect = GetNode<Button>("%BuyButton");
|
2024-06-04 22:12:01 -07:00
|
|
|
|
|
|
|
GetNode<Button>("%BuyButton").GuiInput += (InputEvent @event) =>
|
|
|
|
{
|
|
|
|
if (@event.IsActionPressed("ui_cancel"))
|
|
|
|
{
|
|
|
|
GetViewport().SetInputAsHandled();
|
|
|
|
_selected?.GrabFocus();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-09-16 12:33:29 -07:00
|
|
|
protected override void SetTooltipItem(InventorySlot slot)
|
2024-06-04 22:12:01 -07:00
|
|
|
{
|
2024-09-16 12:33:29 -07:00
|
|
|
base.SetTooltipItem(slot);
|
2024-06-04 22:12:01 -07:00
|
|
|
|
|
|
|
if (slot == _selected)
|
|
|
|
{
|
|
|
|
GetNode<Button>("%BuyButton").Disabled = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetNode<Button>("%BuyButton").Disabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-16 12:33:29 -07:00
|
|
|
public override void OnButtonPress(Button button)
|
|
|
|
{
|
|
|
|
throw new System.NotImplementedException("Not yet implemented.");
|
|
|
|
}
|
|
|
|
|
2024-06-04 22:12:01 -07:00
|
|
|
public override void _UnhandledInput(InputEvent @event)
|
|
|
|
{
|
|
|
|
if (@event.IsActionPressed("ui_cancel"))
|
|
|
|
{
|
|
|
|
GetViewport().SetInputAsHandled();
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|