From 84aa101636e8245fab8bc6ced28b3e7dd34552ed Mon Sep 17 00:00:00 2001 From: alex-kumpula Date: Sat, 11 Nov 2023 16:08:10 -0700 Subject: [PATCH] Made the Advance Button disable when it should --- godot/TAS_system/TAS_System.cs | 5 +++++ godot/UI/TAS UI/AdvanceButton.cs | 12 +++++++++++- godot/UI/TAS UI/TAS UI.tscn | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/godot/TAS_system/TAS_System.cs b/godot/TAS_system/TAS_System.cs index ba5a5b8..b72b8f3 100644 --- a/godot/TAS_system/TAS_System.cs +++ b/godot/TAS_system/TAS_System.cs @@ -33,6 +33,11 @@ public partial class TAS_System : Node private set { this._currentFrame = value; } } + public int AdvancedFramesRemaining + { + get { return this.LastAdvancedFrame - this.CurrentFrame; } + } + /// /// The last frame that can be advanced to. This will /// only be greater than CurrentFrame after the player diff --git a/godot/UI/TAS UI/AdvanceButton.cs b/godot/UI/TAS UI/AdvanceButton.cs index 2f688b9..54918d0 100644 --- a/godot/UI/TAS UI/AdvanceButton.cs +++ b/godot/UI/TAS UI/AdvanceButton.cs @@ -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("/root/TAS_System"); + TAS = GetNode("/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; + } } } diff --git a/godot/UI/TAS UI/TAS UI.tscn b/godot/UI/TAS UI/TAS UI.tscn index decba99..4725fe8 100644 --- a/godot/UI/TAS UI/TAS UI.tscn +++ b/godot/UI/TAS UI/TAS UI.tscn @@ -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")