From 27a98286efe9c74fba4598634f7e301bf639644f Mon Sep 17 00:00:00 2001 From: alex-kumpula Date: Sat, 11 Nov 2023 15:47:37 -0700 Subject: [PATCH] UI is working --- godot/TAS_system/TAS_System.cs | 1 + godot/UI/TAS UI/AdvanceButton.cs | 17 +++++ godot/UI/TAS UI/CurrentFrameLabel.cs | 4 +- godot/UI/TAS UI/RegressButton.cs | 17 +++++ godot/UI/TAS UI/ResetFramesButton.cs | 18 ++++++ godot/UI/TAS UI/StartIncrementButton.cs | 17 +++++ godot/UI/TAS UI/StopIncrementButton.cs | 17 +++++ godot/UI/TAS UI/TAS UI.tscn | 85 ++++++++++++++++++++++++- 8 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 godot/UI/TAS UI/AdvanceButton.cs create mode 100644 godot/UI/TAS UI/RegressButton.cs create mode 100644 godot/UI/TAS UI/ResetFramesButton.cs create mode 100644 godot/UI/TAS UI/StartIncrementButton.cs create mode 100644 godot/UI/TAS UI/StopIncrementButton.cs diff --git a/godot/TAS_system/TAS_System.cs b/godot/TAS_system/TAS_System.cs index dee5c1b..ba5a5b8 100644 --- a/godot/TAS_system/TAS_System.cs +++ b/godot/TAS_system/TAS_System.cs @@ -112,6 +112,7 @@ public partial class TAS_System : Node if (this.TimeSinceLastFrame >= this.FrameLength) { this.CurrentFrame++; + this.LastAdvancedFrame = this.CurrentFrame; EmitSignal(SignalName.FrameIncremented, this.CurrentFrame); this.TimeSinceLastFrame = 0 + (this.TimeSinceLastFrame - this.FrameLength); } diff --git a/godot/UI/TAS UI/AdvanceButton.cs b/godot/UI/TAS UI/AdvanceButton.cs new file mode 100644 index 0000000..2f688b9 --- /dev/null +++ b/godot/UI/TAS UI/AdvanceButton.cs @@ -0,0 +1,17 @@ +using Godot; +using System; + +public partial class AdvanceButton : Button +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + 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) + { + } +} diff --git a/godot/UI/TAS UI/CurrentFrameLabel.cs b/godot/UI/TAS UI/CurrentFrameLabel.cs index c65afc9..f431dd9 100644 --- a/godot/UI/TAS UI/CurrentFrameLabel.cs +++ b/godot/UI/TAS UI/CurrentFrameLabel.cs @@ -8,13 +8,13 @@ public partial class CurrentFrameLabel : Label public override void _Ready() { TAS = GetNode("/root/TAS_System"); - TAS.FrameIncremented += OnFrameIncremented; + // TAS.FrameIncremented += OnFrameIncremented; } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { - + this.Text = $"Current frame: {TAS.CurrentFrame}"; } public virtual void OnFrameIncremented(int newFrame) diff --git a/godot/UI/TAS UI/RegressButton.cs b/godot/UI/TAS UI/RegressButton.cs new file mode 100644 index 0000000..699c63e --- /dev/null +++ b/godot/UI/TAS UI/RegressButton.cs @@ -0,0 +1,17 @@ +using Godot; +using System; + +public partial class RegressButton : Button +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + TAS_System TAS = GetNode("/root/TAS_System"); + this.Pressed += () => { TAS.Regress(1); }; + } + + public virtual void OnFrameIncremented(int newFrame) + { + this.Text = $"Current frame: {newFrame}"; + } +} diff --git a/godot/UI/TAS UI/ResetFramesButton.cs b/godot/UI/TAS UI/ResetFramesButton.cs new file mode 100644 index 0000000..d7e5586 --- /dev/null +++ b/godot/UI/TAS UI/ResetFramesButton.cs @@ -0,0 +1,18 @@ +using Godot; +using System; + +public partial class ResetFramesButton : Button +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + TAS_System TAS = GetNode("/root/TAS_System"); + this.Pressed += () => { TAS.ResetFrameCount(); }; + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + + } +} diff --git a/godot/UI/TAS UI/StartIncrementButton.cs b/godot/UI/TAS UI/StartIncrementButton.cs new file mode 100644 index 0000000..c07eb65 --- /dev/null +++ b/godot/UI/TAS UI/StartIncrementButton.cs @@ -0,0 +1,17 @@ +using Godot; +using System; + +public partial class StartIncrementButton : Button +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + TAS_System TAS = GetNode("/root/TAS_System"); + this.Pressed += () => { TAS.StartIncrementingFrames(); }; + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + } +} diff --git a/godot/UI/TAS UI/StopIncrementButton.cs b/godot/UI/TAS UI/StopIncrementButton.cs new file mode 100644 index 0000000..81f19d0 --- /dev/null +++ b/godot/UI/TAS UI/StopIncrementButton.cs @@ -0,0 +1,17 @@ +using Godot; +using System; + +public partial class StopIncrementButton : Button +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + TAS_System TAS = GetNode("/root/TAS_System"); + this.Pressed += () => { TAS.StopIncrementingFrames(); }; + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + } +} diff --git a/godot/UI/TAS UI/TAS UI.tscn b/godot/UI/TAS UI/TAS UI.tscn index 4443560..decba99 100644 --- a/godot/UI/TAS UI/TAS UI.tscn +++ b/godot/UI/TAS UI/TAS UI.tscn @@ -1,6 +1,11 @@ -[gd_scene load_steps=2 format=3 uid="uid://b1uf31ed6h0ir"] +[gd_scene load_steps=7 format=3 uid="uid://b1uf31ed6h0ir"] [ext_resource type="Script" path="res://UI/TAS UI/CurrentFrameLabel.cs" id="1_27u4w"] +[ext_resource type="Script" path="res://UI/TAS UI/RegressButton.cs" id="2_fhmsa"] +[ext_resource type="Script" path="res://UI/TAS UI/AdvanceButton.cs" id="3_0ti6q"] +[ext_resource type="Script" path="res://UI/TAS UI/StopIncrementButton.cs" id="4_4gd4c"] +[ext_resource type="Script" path="res://UI/TAS UI/StartIncrementButton.cs" id="5_5af83"] +[ext_resource type="Script" path="res://UI/TAS UI/ResetFramesButton.cs" id="6_nwwkv"] [node name="TAS UI" type="Control"] layout_mode = 3 @@ -28,3 +33,81 @@ offset_right = 199.0 grow_vertical = 0 text = "Current Frame: 0" script = ExtResource("1_27u4w") + +[node name="FrameButtons" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -131.5 +offset_top = -52.0 +offset_right = 131.5 +grow_horizontal = 2 +grow_vertical = 0 + +[node name="RegressButton" type="Button" parent="FrameButtons"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 0.5 +anchor_bottom = 1.0 +grow_vertical = 2 +text = "Regress" +script = ExtResource("2_fhmsa") + +[node name="AdvanceButton" type="Button" parent="FrameButtons"] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.5 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_vertical = 2 +text = "Advance" +script = ExtResource("3_0ti6q") + +[node name="TASButtons" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -205.0 +offset_top = -103.0 +grow_horizontal = 0 +grow_vertical = 0 + +[node name="StopIncrementButton" type="Button" parent="TASButtons"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_bottom = 31.0 +grow_horizontal = 2 +text = "Stop Increment" +script = ExtResource("4_4gd4c") + +[node name="StartIncrementButton" type="Button" parent="TASButtons"] +layout_mode = 1 +anchors_preset = 14 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_top = -15.5 +offset_bottom = 15.5 +grow_horizontal = 2 +grow_vertical = 2 +text = "Start Increment" +script = ExtResource("5_5af83") + +[node name="ResetFramesButton" type="Button" parent="TASButtons"] +layout_mode = 1 +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -31.0 +grow_horizontal = 2 +grow_vertical = 0 +text = "Reset Frames" +script = ExtResource("6_nwwkv")