add gamestate, doc and fix

This commit is contained in:
2026-04-16 11:01:04 +02:00
parent dc0bf0ba37
commit e02bd1819f
29 changed files with 466 additions and 71 deletions

View File

@@ -1,7 +1,7 @@
extends Node3D
@onready var radio: Radio = $Radio
@onready var radio: Radio = $%Radio
@onready var button_pause_resume: Button = $%Button_Pause_Resume
func _on_button_play_pressed() -> void:
if !radio.playing:
@@ -10,10 +10,12 @@ func _on_button_play_pressed() -> void:
func _on_button_pause_pressed() -> void:
radio.toggle_pause()
if !button_pause_resume:
button_pause_resume = $%Button_Pause_Resume
if radio.stream_paused:
$Control/MarginContainer/VBoxContainer/Button_Pause_Resume.text = "Resume"
button_pause_resume.text = "Resume"
else:
$Control/MarginContainer/VBoxContainer/Button_Pause_Resume.text = "Pause"
button_pause_resume.text = "Pause"
func _on_button_stop_pressed() -> void:

View File

@@ -8,6 +8,7 @@
script = ExtResource("1_h5r8c")
[node name="Radio" parent="." unique_id=1234112225 instance=ExtResource("1_8yomj")]
unique_name_in_owner = true
playlist = Array[AudioStream]([ExtResource("3_ltpvc")])
[node name="Control" type="Control" parent="." unique_id=1232082176]
@@ -18,40 +19,70 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MarginContainer" type="MarginContainer" parent="Control" unique_id=2102712226]
[node name="VBoxContainer" type="VBoxContainer" parent="Control" unique_id=2097365775]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
theme_override_constants/margin_left = 12
theme_override_constants/margin_top = 12
theme_override_constants/margin_right = 12
theme_override_constants/margin_bottom = 12
offset_left = 50.0
offset_top = 50.0
offset_right = 125.0
offset_bottom = 221.0
[node name="VBoxContainer" type="VBoxContainer" parent="Control/MarginContainer" unique_id=2097365775]
layout_mode = 2
[node name="Button_Play" type="Button" parent="Control/MarginContainer/VBoxContainer" unique_id=1422696340]
[node name="Button_Play" type="Button" parent="Control/VBoxContainer" unique_id=1422696340]
layout_mode = 2
text = "Play"
[node name="Button_Pause_Resume" type="Button" parent="Control/MarginContainer/VBoxContainer" unique_id=2016690081]
[node name="Button_Pause_Resume" type="Button" parent="Control/VBoxContainer" unique_id=2016690081]
unique_name_in_owner = true
layout_mode = 2
text = "Pause"
[node name="Button_Stop" type="Button" parent="Control/MarginContainer/VBoxContainer" unique_id=61861870]
[node name="Button_Stop" type="Button" parent="Control/VBoxContainer" unique_id=61861870]
layout_mode = 2
text = "Stop"
[node name="Button_Next" type="Button" parent="Control/MarginContainer/VBoxContainer" unique_id=957606385]
[node name="Button_Next" type="Button" parent="Control/VBoxContainer" unique_id=957606385]
layout_mode = 2
text = "Next"
[node name="Button_Previous" type="Button" parent="Control/MarginContainer/VBoxContainer" unique_id=929072518]
[node name="Button_Previous" type="Button" parent="Control/VBoxContainer" unique_id=929072518]
layout_mode = 2
text = "Previous"
[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/Button_Play" to="." method="_on_button_play_pressed"]
[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/Button_Pause_Resume" to="." method="_on_button_pause_pressed"]
[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/Button_Stop" to="." method="_on_button_stop_pressed"]
[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/Button_Next" to="." method="_on_button_next_pressed"]
[connection signal="pressed" from="Control/MarginContainer/VBoxContainer/Button_Previous" to="." method="_on_button_previous_pressed"]
[node name="PanelContainer" type="PanelContainer" parent="Control" unique_id=1558442050]
layout_mode = 0
offset_left = 50.0
offset_top = 250.0
offset_right = 400.0
offset_bottom = 1027.0
[node name="ScrollContainer" type="ScrollContainer" parent="Control/PanelContainer" unique_id=7789304]
layout_mode = 2
[node name="Label" type="Label" parent="Control/PanelContainer/ScrollContainer" unique_id=2043293564]
custom_minimum_size = Vector2(1, 1)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
text = "System Logic:
- The system is an extension of AudioStreamPlayer designed to manage sequential audio playback.
- It automatically triggers the next track in the sequence when the current one finishes via the finished signal.
Core Functionality:
- Playlist Management: Stores a list of AudioStream resources and tracks the current song index.
- Track Navigation: Allows cycling forward and backward through the playlist with index wrapping (loops back to start/end).
- Playback Control: Supports jumping to specific tracks, toggling the pause state, and stopping the stream.
Key Methods:
- play_track: Loads a specific stream from the playlist and begins playback.
- next_track / prev_track: Increments or decrements the index to navigate the playlist.
- toggle_pause: Resumes or pauses the current stream without resetting its position.
Adjustable Parameters:
- Playlist: An Array in the inspector where you can assign multiple AudioStream resources (e.g., .mp3, .ogg).
- Current Track Index: Determines which song starts playing by default."
autowrap_mode = 2
[connection signal="pressed" from="Control/VBoxContainer/Button_Play" to="." method="_on_button_play_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/Button_Pause_Resume" to="." method="_on_button_pause_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/Button_Stop" to="." method="_on_button_stop_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/Button_Next" to="." method="_on_button_next_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/Button_Previous" to="." method="_on_button_previous_pressed"]