45 lines
925 B
C#
45 lines
925 B
C#
using Godot;
|
|
using System;
|
|
|
|
public partial class RegressButton : Button
|
|
{
|
|
TAS_System TAS;
|
|
bool isButtonPressed = false;
|
|
|
|
// Called when the node enters the scene tree for the first time.
|
|
public override void _Ready()
|
|
{
|
|
TAS = GetNode<TAS_System>("/root/TAS_System");
|
|
this.Pressed += () => {
|
|
TAS.Regress(1);
|
|
};
|
|
|
|
this.ButtonDown += () => { this.isButtonPressed = true; TAS.StopIncrementingFrames(); };
|
|
this.ButtonUp += () => { this.isButtonPressed = false; };
|
|
}
|
|
|
|
public virtual void OnFrameIncremented(int newFrame)
|
|
{
|
|
this.Text = $"Current frame: {newFrame}";
|
|
}
|
|
|
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
public override void _Process(double delta)
|
|
{
|
|
if (TAS.CurrentFrame == 0)
|
|
{
|
|
this.Disabled = true;
|
|
this.isButtonPressed = false;
|
|
}
|
|
else
|
|
{
|
|
this.Disabled = false;
|
|
|
|
if (this.isButtonPressed)
|
|
{
|
|
TAS.Regress(1);
|
|
}
|
|
}
|
|
}
|
|
}
|