@@ -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 ) ;
0 commit comments