Skip to content

Commit 35a6667

Browse files
committed
Make start button clearer
Start button now grabs focus
1 parent e1d9615 commit 35a6667

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

scenes/BattleDirector/scripts/BattleDirector.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public partial class BattleDirector : Node2D
2828
[Export]
2929
private AudioStreamPlayer Audio;
3030

31+
[Export]
32+
private Button _focusedButton; //Initially start button
33+
3134
private double _timingInterval = .1; //secs, maybe make somewhat note dependent
3235
private double _lastBeat;
3336

@@ -90,16 +93,13 @@ public override void _Ready()
9093
CM.Connect(nameof(InputHandler.NotePressed), new Callable(this, nameof(OnNotePressed)));
9194
CM.Connect(nameof(InputHandler.NoteReleased), new Callable(this, nameof(OnNoteReleased)));
9295

93-
//TODO: This is a temporary measure
94-
Button startButton = new Button();
95-
startButton.Text = "Start";
96-
startButton.Position = GetViewportRect().Size / 2;
97-
AddChild(startButton);
98-
startButton.Pressed += () =>
96+
_focusedButton.GrabFocus();
97+
_focusedButton.Pressed += () =>
9998
{
10099
var timer = GetTree().CreateTimer(AudioServer.GetTimeToNextMix());
101100
timer.Timeout += Begin;
102-
startButton.QueueFree();
101+
_focusedButton.QueueFree();
102+
_focusedButton = null;
103103
};
104104
}
105105

@@ -118,6 +118,7 @@ private void EndBattle()
118118

119119
public override void _Process(double delta)
120120
{
121+
_focusedButton?.GrabFocus();
121122
TimeKeeper.CurrentTime = Audio.GetPlaybackPosition();
122123
double realBeat = TimeKeeper.CurrentTime / (60 / (double)TimeKeeper.Bpm) % CM.BeatsPerLoop;
123124
CD.CheckMiss(realBeat);

scenes/BattleDirector/test_battle_scene.tscn

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ gradient = SubResource("Gradient_8uy3a")
1717
fill_from = Vector2(1, 0)
1818
fill_to = Vector2(0.738532, 1)
1919

20-
[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "NotePlacementBar", "CD", "Audio")]
20+
[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "NotePlacementBar", "CD", "Audio", "_focusedButton")]
2121
process_mode = 1
2222
script = ExtResource("1_cwqqr")
2323
CM = NodePath("SubViewport")
2424
NotePlacementBar = NodePath("NotePlacementBar")
2525
CD = NodePath("Conductor")
2626
Audio = NodePath("AudioStreamPlayer")
27+
_focusedButton = NodePath("StartButton")
2728
metadata/_edit_lock_ = true
2829

2930
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
@@ -64,3 +65,11 @@ offset_top = 178.0
6465
offset_right = 640.0
6566
offset_bottom = 360.0
6667
texture = ExtResource("6_0ak0g")
68+
69+
[node name="StartButton" type="Button" parent="."]
70+
modulate = Color(5, 5, 5, 1)
71+
offset_left = 241.0
72+
offset_top = 234.0
73+
offset_right = 399.0
74+
offset_bottom = 265.0
75+
text = "Begin Battle [Enter]"

0 commit comments

Comments
 (0)