Made the Advance Button disable when it should

This commit is contained in:
alex-kumpula 2023-11-11 16:08:10 -07:00
parent 27a98286ef
commit 84aa101636
3 changed files with 17 additions and 1 deletions

View File

@ -33,6 +33,11 @@ public partial class TAS_System : Node
private set { this._currentFrame = value; }
}
public int AdvancedFramesRemaining
{
get { return this.LastAdvancedFrame - this.CurrentFrame; }
}
/// <summary>
/// The last frame that can be advanced to. This will
/// only be greater than CurrentFrame after the player

View File

@ -3,15 +3,25 @@ using System;
public partial class AdvanceButton : Button
{
TAS_System TAS;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
TAS_System TAS = GetNode<TAS_System>("/root/TAS_System");
TAS = GetNode<TAS_System>("/root/TAS_System");
this.Pressed += () => { TAS.Advance(1); };
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
if (TAS.AdvancedFramesRemaining == 0)
{
this.Disabled = true;
}
else
{
this.Disabled = false;
}
}
}

View File

@ -63,6 +63,7 @@ anchor_left = 0.5
anchor_right = 1.0
anchor_bottom = 1.0
grow_vertical = 2
disabled = true
text = "Advance"
script = ExtResource("3_0ti6q")