Added functionallity to some buttons. Hides answer from start. Updated song que list.
This commit is contained in:
@@ -37,7 +37,13 @@ var label := $PanelContainer/HBoxContainer/Label
|
||||
var add_player := $Players/VBoxContainer/HBoxContainer/AddPlayer
|
||||
|
||||
@onready
|
||||
var test := $Button4
|
||||
var show_answer_button := $ShowAnswerButton
|
||||
|
||||
@onready
|
||||
var next_button := $NextButton
|
||||
|
||||
@onready
|
||||
var music_list_scroll := $MusicListPanel/ScrollContainer
|
||||
|
||||
@onready
|
||||
var music_list := $MusicListPanel/ScrollContainer/MusicList
|
||||
@@ -70,9 +76,11 @@ func add_players():
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
play_button.pressed.connect(fetch_first_song)
|
||||
next_button.pressed.connect(fetch_first_song)
|
||||
pause_button.pressed.connect(pause)
|
||||
stop_button.pressed.connect(stop)
|
||||
show_answer_button.pressed.connect(show_answer)
|
||||
|
||||
progress.drag_started.connect(_on_drag_started)
|
||||
progress.drag_ended.connect(_on_drag_ended)
|
||||
character_select.connect("character_selected", _on_character_selected)
|
||||
@@ -82,8 +90,7 @@ func _ready():
|
||||
open_button.pressed.connect(open)
|
||||
get_suggestion_list()
|
||||
|
||||
|
||||
func fetched():
|
||||
func show_answer():
|
||||
var http_request = HTTPRequest.new()
|
||||
add_child(http_request)
|
||||
http_request.request_completed.connect(show_fetched)
|
||||
@@ -93,6 +100,7 @@ func fetched():
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
func fetched():
|
||||
var http_request2 = HTTPRequest.new()
|
||||
add_child(http_request2)
|
||||
http_request2.request_completed.connect(show_fetched_list)
|
||||
@@ -124,15 +132,28 @@ func show_fetched_list(result, response_code, headers, body) -> void:
|
||||
song_list = []
|
||||
song_list.append_array(data_received)
|
||||
delete_children(music_list)
|
||||
song_list.remove_at(song_list.size() - 1)
|
||||
for song in song_list:
|
||||
var label := Label.new()
|
||||
var format_string = "%d. %s - %s"
|
||||
var actual_string = format_string % [(song.SongNo+1), song.Game, song.Song]
|
||||
label.text = actual_string
|
||||
label.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
label.gui_input.connect(song_clicked.bind(song.SongNo))
|
||||
music_list.add_child(label)
|
||||
|
||||
var label := Label.new()
|
||||
label.text = "??? - ???"
|
||||
label.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
label.gui_input.connect(show_fetched)
|
||||
music_list.add_child(label)
|
||||
|
||||
else:
|
||||
print("Unexpected data")
|
||||
#/music_list
|
||||
|
||||
func song_clicked(event, song_no):
|
||||
if (event is InputEventMouseButton && event.pressed && event.button_index == 1):
|
||||
print("Clicked: " + str(song_no))
|
||||
|
||||
# Called when the HTTP request is completed.
|
||||
func _http_request_completed(result, response_code, headers, body):
|
||||
@@ -241,6 +262,9 @@ func fetch_first_song() -> void:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
func first_song_fetched(result, response_code, headers, body) -> void:
|
||||
game_label.text = "????????"
|
||||
song_label.text = "??????"
|
||||
|
||||
if result != HTTPRequest.RESULT_SUCCESS:
|
||||
push_error("Song couldn't be downloaded. Try a different song.")
|
||||
var sound = AudioStreamMP3.new()
|
||||
|
||||
Reference in New Issue
Block a user