Files
Enigmos/Manual/PortFixer.cs
2024-06-29 06:35:23 +08:00

48 lines
1.3 KiB
C#

using Godot;
using Nocturnis.Enigmos.Ports;
using Nocturnis.Inventories.ItemSlots.ItemSlots;
namespace Enigmos.Manual;
public partial class PortFixer : Control
{
private bool InitFlag { get; set; }
public void Init(IBasePort port)
{
RelatedPort = port;
InitFlag = true;
}
private IBasePort RelatedPort { get; set; }
private IChemicalItemSlot MaterialSlot { get; set; }
public Button FixPort { get; set; }
private Label PortLabel { get; set; }
private Label QualityLabel { get; set; }
private Label ConditionLabel { get; set; }
public override void _Ready()
{
if (!InitFlag)
throw new Exception("TODO - NOT INIT");
MaterialSlot = GetNode<IChemicalItemSlot>("MaterialSlot");
PortLabel = GetNode<Label>("PortLabel");
FixPort = GetNode<Button>("FixPort");
ConditionLabel = GetNode<Label>("ConditionLabel");
QualityLabel = GetNode<Label>("QualityLabel");
base._Ready();
}
private void UpdateInformation()
{
PortLabel.Text = $"Port : {RelatedPort?.Name}";
QualityLabel.Text = $"Quality : {RelatedPort?.Quality}";
ConditionLabel.Text = $"Condition : {RelatedPort?.Condition} / 100";
}
private void Fix() => RelatedPort.FixWith(MaterialSlot.Item);
public override void _Process(double delta)
{
UpdateInformation();
base._Process(delta);
}
}