2023-11-11 15:47:37 -07:00
|
|
|
using Godot;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
public partial class RegressButton : Button
|
|
|
|
{
|
2023-11-11 17:23:00 -07:00
|
|
|
TAS_System TAS;
|
2023-11-11 21:23:21 -07:00
|
|
|
bool isButtonPressed = false;
|
2023-11-11 17:23:00 -07:00
|
|
|
|
2023-11-11 15:47:37 -07:00
|
|
|
// Called when the node enters the scene tree for the first time.
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
2023-11-11 17:23:00 -07:00
|
|
|
TAS = GetNode<TAS_System>("/root/TAS_System");
|
2023-11-12 02:53:06 -07:00
|
|
|
this.Pressed += () => {
|
|
|
|
TAS.Regress(1);
|
|
|
|
};
|
2023-11-11 21:23:21 -07:00
|
|
|
|
2023-11-12 02:53:06 -07:00
|
|
|
this.ButtonDown += () => { this.isButtonPressed = true; TAS.StopIncrementingFrames(); };
|
2023-11-12 11:45:10 -07:00
|
|
|
this.ButtonUp += () => { this.isButtonPressed = false; TAS.ResetSpeedup(); };
|
2023-11-11 15:47:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void OnFrameIncremented(int newFrame)
|
|
|
|
{
|
|
|
|
this.Text = $"Current frame: {newFrame}";
|
|
|
|
}
|
2023-11-11 17:23:00 -07:00
|
|
|
|
|
|
|
// 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;
|
2023-11-12 11:45:10 -07:00
|
|
|
TAS.ResetSpeedup();
|
2023-11-11 21:23:21 -07:00
|
|
|
this.isButtonPressed = false;
|
2023-11-11 17:23:00 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.Disabled = false;
|
2023-11-11 21:23:21 -07:00
|
|
|
|
|
|
|
if (this.isButtonPressed)
|
|
|
|
{
|
2023-11-12 11:45:10 -07:00
|
|
|
TAS.RegressWithSpeedup(delta);
|
2023-11-11 21:23:21 -07:00
|
|
|
}
|
2023-11-11 17:23:00 -07:00
|
|
|
}
|
|
|
|
}
|
2023-11-11 15:47:37 -07:00
|
|
|
}
|