diff --git a/.gitignore b/.gitignore
index e6e57d0..2943ff7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,6 @@
.godot/
/web/
*.exe
-*.dmg
\ No newline at end of file
+*.dmg
+.idea
+.vscode
\ No newline at end of file
diff --git a/MainWindow.gd b/MainWindow.gd
index 5831c70..d40bc75 100644
--- a/MainWindow.gd
+++ b/MainWindow.gd
@@ -3,217 +3,190 @@ extends Control
# 601 LOC 11/9 - 2023
# 628 LOC 15/9 - 2023
# 631 LOC 16/9 - 2023
+# 554 LOC 30/5 - 2024
+# 551 LOC 3/6 - 2024
+# 386 LOC 12/6 - 2024
##TODO
-# 11. Refactor components
# 13. Fix graphics in lists
# 14. Fix layout
# 15. Fix for local play
-# 16. Change all calls to make_request and function in function
-# 17. Change some buttons to icons
@onready
-var open_button := $Open
+var open_button: Button = $Open
@onready
-var fileDialog := $FileDialog
+var fileDialog: FileDialog = $FileDialog
@onready
-var insperation_scroll := $ScrollContainer
+var inspiration_scroll: ScrollContainer = $ScrollContainer
@onready
-var insperation_list := $ScrollContainer/VBoxContainer
+var inspiration_list: VBoxContainer = $ScrollContainer/VBoxContainer
@onready
-var game_label := $VBoxContainer/GameLabel
+var game_label: Label = $VBoxContainer/GameLabel
@onready
-var song_label := $VBoxContainer/SongLabel
+var song_label: Label = $VBoxContainer/SongLabel
@onready
-var play_button := $PanelContainer/HBoxContainer/PlayButton
+var add_player_container: VBoxContainer = $Players/VBoxContainer/AddPlayerContainer
@onready
-var restart_button := $PanelContainer/HBoxContainer/RestartButton
+var add_players_button: Button = $Players/VBoxContainer/HBoxContainer/AddPlayersButton
@onready
-var audio := $AudioStreamPlayer
+var add_player_button: Button = $Players/VBoxContainer/AddPlayerContainer/AddPlayerButton
@onready
-var progress := $PanelContainer/HBoxContainer/HSlider
+var new_player_name_field: LineEdit = $Players/VBoxContainer/AddPlayerContainer/PlayerNameField
@onready
-var label := $PanelContainer/HBoxContainer/Label
+var reset_playlist_button: Button = $ResetPlaylistButton
@onready
-var add_player_container := $Players/VBoxContainer/AddPlayerContainer
+var reset_points_button: Button = $ResetPointsButton
@onready
-var add_players_button := $Players/VBoxContainer/HBoxContainer/AddPlayersButton
+var sound_test_button: Button = $SoundTestButton
@onready
-var add_player_button := $Players/VBoxContainer/AddPlayerContainer/AddPlayerButton
+var sync_button: Button = $SyncButton
@onready
-var new_player_name_field := $Players/VBoxContainer/AddPlayerContainer/PlayerNameField
+var sync_popup: PopupPanel = $SyncPopupPanel
@onready
-var reset_playlist_button := $ResetPlaylistButton
+var settings_button: Button = $SettingsButton
@onready
-var reset_points_button := $ResetPointsButton
+var settings_popup: PopupPanel = $SettingsPopupPanel
@onready
-var sound_test_button := $SoundTestButton
+var statistics_button: Button = $StatisticsButton
@onready
-var sync_button := $SyncButton
+var statistic_popup: PopupPanel = $StatisticsPopupPanel
@onready
-var sync_popup := $SyncPopupPanel
+var statistic_label: Label = $StatisticsPopupPanel/StatisticsLabel
@onready
-var settings_button := $SettingsButton
+var about_button: Button = $AboutButton
@onready
-var settings_popup := $SettingsPopupPanel
+var about_popup: PopupPanel = $AboutPopupPanel
@onready
-var statistics_button := $StatisticsButton
+var show_answer_button: Button = $ShowAnswerButton
@onready
-var statistic_popup := $StatisticsPopupPanel
+var next_button: Button = $NextButton
@onready
-var statistic_label := $StatisticsPopupPanel/StatisticsLabel
+var music_list_scroll: ScrollContainer = $MusicListPanel/ScrollContainer
@onready
-var about_button := $AboutButton
+var music_list: VBoxContainer = $MusicListPanel/ScrollContainer/MusicList
@onready
-var about_popup := $AboutPopupPanel
+var players: VBoxContainer = $Players/VBoxContainer
@onready
-var show_answer_button := $ShowAnswerButton
+var character_select: Control = $CharacterSelect
@onready
-var next_button := $NextButton
+var search_button: Button = $SearchButton
@onready
-var music_list_scroll := $MusicListPanel/ScrollContainer
+var search_view: Control= $Search
@onready
-var music_list := $MusicListPanel/ScrollContainer/MusicList
+var version_label: Label = $AboutPopupPanel/VBoxContainer/VersionLabel
@onready
-var players := $Players/VBoxContainer
+var whats_new_label: Label = $AboutPopupPanel/VBoxContainer/HBoxContainer/NewLabel
@onready
-var character_select := $CharacterSelect
+var shortcut_label: Label = $AboutPopupPanel/VBoxContainer/HBoxContainer/ShortcutsLabel
@onready
-var search_button := $SearchButton
+var coming_label: Label = $AboutPopupPanel/VBoxContainer/HBoxContainer/CommingLabel
@onready
-var search_view := $Search
+var winner_popup: PopupPanel = $WinnerPopupPanel
@onready
-var version_label := $AboutPopupPanel/VBoxContainer/VersionLabel
+var winner_label: Label = $WinnerPopupPanel/WinnerLabel
@onready
-var new_label := $AboutPopupPanel/VBoxContainer/HBoxContainer/NewLabel
-
-@onready
-var shortcut_label := $AboutPopupPanel/VBoxContainer/HBoxContainer/ShortcutsLabel
-
-@onready
-var comming_label := $AboutPopupPanel/VBoxContainer/HBoxContainer/CommingLabel
-
-@onready
-var winner_popup := $WinnerPopupPanel
-
-@onready
-var winner_label := $WinnerPopupPanel/WinnerLabel
+var music_player_container: PanelContainer = $MusicPlayer
var player := preload("res://Player.tscn")
-@onready
-var path = '/Users/sebastian/ResilioSync/Sorterat_test/Metal Gear Solid 4 - Guns of the Patriots/2-16 Metal Gear Saga.mp3'
+var songs: Array= []
+var games: Array = []
+var song_list: Array = []
+var next_label: Label
+var current_player: Node
# Called when the node enters the scene tree for the first time.
-func _ready():
- next_button.pressed.connect(fetch_next_song)
- play_button.pressed.connect(play_or_pause)
- restart_button.pressed.connect(restart)
- show_answer_button.pressed.connect(show_answer)
+func _ready() -> void:
+ next_button.pressed.connect(music_player_container.fetch_next_song)
+ show_answer_button.pressed.connect(show_answer_pressed)
search_button.pressed.connect(show_search)
sync_button.pressed.connect(sync_games)
- sound_test_button.pressed.connect(get_sound_test_song)
+ sound_test_button.pressed.connect(music_player_container.get_sound_test_song)
statistics_button.pressed.connect(get_statistics)
about_button.pressed.connect(show_about)
settings_button.pressed.connect(show_settings)
reset_playlist_button.pressed.connect(reset_playlist)
reset_points_button.pressed.connect(reset_points)
- progress.drag_started.connect(_on_drag_started)
- progress.drag_ended.connect(_on_drag_ended)
character_select.connect("character_selected", _on_character_selected)
new_player_name_field.connect("enter_key_pressed", add_player)
+ music_player_container.connect("add_to_queue", _on_add_to_queue)
add_players_button.pressed.connect(add_players)
add_player_button.pressed.connect(add_player)
-
open_button.pressed.connect(open)
+
get_suggestion_list()
fetch_full_music_list_at_start()
-
-func reset_playlist():
+
+func reset_playlist() -> void:
print("reset_playlist")
Settings.make_request2("/music/reset", fetch_full_music_list_at_start, false)
-func reset_points():
- var players_to_reset := players.get_children()
- for player_to_reset in players_to_reset:
+func reset_points() -> void:
+ var players_to_reset: Array = players.get_children()
+ for player_to_reset: Node in players_to_reset:
if player_to_reset.has_method("reset_points"):
player_to_reset.reset_points()
-func show_about():
+func show_about() -> void:
about_popup.visible = true
version_label.text = Settings.version
- new_label.text = Settings.whats_new
+ whats_new_label.text = Settings.whats_new
shortcut_label.text = Settings.shortcuts
- comming_label.text = Settings.whats_left
+ coming_label.text = Settings.whats_left
-func show_settings():
+func show_settings() -> void:
settings_popup.visible = true
-func get_statistics():
+func get_statistics() -> void:
statistic_popup.visible = true
statistic_label.text = "Total amount of games in the playlist: " + str(games.size())
-
-func get_sound_test_song():
- var play_sound_test_song = func(result, _response_code, _headers, body):
- if result != HTTPRequest.RESULT_SUCCESS:
- push_error("Song couldn't be downloaded. Try a different song.")
- var sound = AudioStreamMP3.new()
- sound.data = body
- audio.stream = sound
- audio.play()
- stream = audio.stream
- progress.max_value = round(stream.get_length())
- progress.tick_count = round(stream.get_length() / 60)
-
- make_request(Settings.default_path + "/music/soundTest", play_sound_test_song)
-
-func sound_test_local():
- audio.stream = preload("res://01. Opening.mp3")
- audio.play()
- stream = audio.stream
- progress.max_value = round(stream.get_length())
- progress.tick_count = round(stream.get_length() / 60)
-func sync_games():
- var games_synced = func():
+func _on_add_to_queue() -> void:
+ print("add_to_queue")
+ Settings.make_request2("/music/addQue", fetched, false)
+ game_label.text = "????????"
+ song_label.text = "??????"
+
+func sync_games() -> void:
+ var games_synced: Callable = func() -> void:
sync_popup.visible = true
print("games_synced")
reset_playlist()
@@ -221,86 +194,72 @@ func sync_games():
Settings.make_request2("/sync", games_synced, false)
func get_suggestion_list() -> void:
- var populate_list = func(array):
+ var populate_list: Callable = func(array: Array) -> void:
if typeof(array) == TYPE_ARRAY:
games.append_array(array)
- for game in games:
- var insperation_label := Label.new()
- insperation_label.text = game
- insperation_label.autowrap_mode = TextServer.AUTOWRAP_WORD
- insperation_list.add_child(insperation_label)
- insperation_scroll.scroll_to_bottom()
+ for game: String in games:
+ var inspiration_label: Label= Label.new()
+ inspiration_label.text = game
+ inspiration_label.autowrap_mode = TextServer.AUTOWRAP_WORD
+ inspiration_list.add_child(inspiration_label)
+ inspiration_scroll.scroll_to_bottom()
else:
print("Unexpected data")
Settings.make_request2("/music/all", populate_list, true)
-func add_players():
+func add_players() -> void:
add_player_container.visible = !add_player_container.visible
new_player_name_field.grab_focus()
-func add_player():
- var new_player := player.instantiate()
- new_player.new_name(new_player_name_field.text + ": 0")
+func add_player() -> void:
+ var new_player: Node = player.instantiate()
+ new_player.player_name = new_player_name_field.text
+ new_player.player_score = new_player_name_field.text + ": 0"
new_player_name_field.text = ""
players.add_child(new_player)
new_player.connect("change_character_clicked", _on_player_change_character_clicked.bind(new_player))
- new_player.connect("first_point_triggerd", _on_point_triggerd.bind("first", ""))
- new_player.connect("match_point_triggerd", _on_point_triggerd.bind("match", ""))
- new_player.connect("winner_triggerd", _on_point_triggerd.bind("winner", new_player.player_name))
+ new_player.connect("first_point_triggerd", music_player_container._on_point_triggered.bind("first"))
+ new_player.connect("match_point_triggerd", music_player_container._on_point_triggered.bind("match"))
+ new_player.connect("winner_triggerd", _on_player_won.bind(new_player.player_name))
new_player.connect("player_removed", _on_player_removed.bind(new_player))
-
-func _on_point_triggerd(point: String, player_name: String):
- if point == "first":
- var value = randi_range(0, 10)
- if value == 0:
- audio.stream = preload("res://sounds/sound1.mp3")
- elif value < 5:
- audio.stream = preload("res://sounds/intro_long.mp3")
- else:
- audio.stream = preload("res://sounds/intro_short.mp3")
- elif point == "match":
- audio.stream = preload("res://sounds/sound0.mp3")
- elif point == "winner":
- audio.stream = preload("res://sounds/winning.mp3")
- winner_popup.visible = true
- winner_label.text = player_name + " won!!"
-
- audio.play()
- play_button.text = "Pause"
- stream = audio.stream
- progress.max_value = round(stream.get_length())
- progress.tick_count = round(stream.get_length() / 60)
-func show_search():
+func _on_player_won(player_name: String) -> void:
+ winner_popup.visible = true
+ winner_label.text = player_name + " won!!"
+ music_player_container.play_sound(preload("res://sounds/winning.mp3"))
+
+func show_search() -> void:
if search_view.visible == false:
search_view.visible = true
else:
search_view.visible = false
-func show_answer():
- var http_request = HTTPRequest.new()
- add_child(http_request)
- http_request.request_completed.connect(show_fetched)
-
- # Perform a GET request. The URL below returns JSON as of writing.
- var error = http_request.request(Settings.default_path + "/music/info")
- if error != OK:
- push_error("An error occurred in the HTTP request.")
+func show_answer_pressed() -> void:
+ var show_fetched: Callable = func(data_received: Dictionary) -> void:
+ print("show_fetched data_received: ", data_received)
+ game_label.text = data_received.Game
+ song_label.text = data_received.Song
+ var format_string: String = "%d. %s - %s"
+ var actual_string: String = format_string % [(data_received.SongNo+1), data_received.Game, data_received.Song]
+ if next_label == null:
+ next_label = Label.new()
+ next_label.text = actual_string
+ Settings.make_request2("/music/info", show_fetched, true)
-func fetch_full_music_list_at_start():
+func fetch_full_music_list_at_start() -> void:
print("fetch_full_music_list_at_start")
- var show_music_list_at_start = func(data):
+ var show_music_list_at_start: Callable = func(data: Array) -> void:
if data == null:
song_list = []
- delete_children(music_list)
+ Settings.delete_children(music_list)
return
if typeof(data) == TYPE_ARRAY:
song_list = []
song_list.append_array(data)
- for song in song_list:
- var music_list_label := Label.new()
- var format_string = "%d. %s - %s"
- var actual_string = format_string % [(song.SongNo+1), song.Game, song.Song]
+ for song: Dictionary in song_list:
+ var music_list_label: Label = Label.new()
+ var format_string: String = "%d. %s - %s"
+ var actual_string: String = format_string % [(song.SongNo+1), song.Game, song.Song]
music_list_label.text = actual_string
music_list_label.mouse_filter = Control.MOUSE_FILTER_PASS
music_list_label.gui_input.connect(song_clicked.bind(music_list_label, song.SongNo))
@@ -309,105 +268,55 @@ func fetch_full_music_list_at_start():
print("Unexpected data")
Settings.make_request2("/music/list", show_music_list_at_start, true)
-func fetch_full_music_list(event, song_no: int):
+func fetch_full_music_list(event: InputEvent, song_no: int) -> void:
if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT):
- var show_music_list = func(_result, _response_code, _headers, body):
- var json = JSON.new()
- var error = json.parse(body.get_string_from_utf8())
-
- if error == OK:
- var data_received = json.get_data()
- if typeof(data_received) == TYPE_ARRAY:
- song_list = []
- song_list.append_array(data_received)
- delete_children(music_list)
- for song in song_list:
- var label := Label.new()
- game_label.text = song.Game
- song_label.text = song.Song
- 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(label, song.SongNo))
- print(str(music_list.get_child_count()) + " | " + str(song_list.size() - 1))
- if music_list.get_child_count() == song_list.size() - 1:
- label.add_theme_color_override("font_color", Color(1, 0.5, 0))
- music_list.add_child(label)
- else:
- print("Unexpected data")
- make_request(Settings.default_path + "/music/list", show_music_list)
- var play_clicked_song = func(result, _response_code, _headers, body):
- if result != HTTPRequest.RESULT_SUCCESS:
- push_error("Song couldn't be downloaded. Try a different song.")
- var sound = AudioStreamMP3.new()
- sound.data = body
- audio.stream = sound
- audio.play()
- play_button.text = "Pause"
- stream = audio.stream
- progress.max_value = round(stream.get_length())
- progress.tick_count = round(stream.get_length() / 60)
- make_request(Settings.default_path + "/music?song=" + str(song_no), play_clicked_song)
- var show_answer = func(result, response_code, headers, body):
- var json = JSON.new()
- var error = json.parse(body.get_string_from_utf8())
-
- if error == OK:
- var data_received = json.get_data()
- game_label.text = data_received.Game
- song_label.text = data_received.Song
- make_request(Settings.default_path + "/music/info", show_answer)
-
+ var show_music_list: Callable = func(data_received: Array) -> void:
+ if typeof(data_received) == TYPE_ARRAY:
+ song_list = []
+ song_list.append_array(data_received)
+ Settings.delete_children(music_list)
+ for song: Dictionary in song_list:
+ var music_label: Label= Label.new()
+ game_label.text = song.Game
+ song_label.text = song.Song
+ var format_string: String = "%d. %s - %s"
+ var actual_string: String = format_string % [(song.SongNo+1), song.Game, song.Song]
+ music_label.text = actual_string
+ music_label.mouse_filter = Control.MOUSE_FILTER_PASS
+ music_label.gui_input.connect(song_clicked.bind(music_label, song.SongNo))
+ print(str(music_list.get_child_count()) + " | " + str(song_list.size() - 1))
+ if music_list.get_child_count() == song_list.size() - 1:
+ music_label.add_theme_color_override("font_color", Color(1, 0.5, 0))
+ music_list.add_child(music_label)
+ else:
+ print("Unexpected data")
+ Settings.make_request2("/music/list", show_music_list, true)
+ Settings.make_request2("/music?song=" + str(song_no), music_player_container.play_song, true)
+ Settings.make_request2("/music/info", show_answer, true)
-func fetched():
- var http_request2 = HTTPRequest.new()
- add_child(http_request2)
- http_request2.request_completed.connect(show_fetched_list)
-
- # Perform a GET request. The URL below returns JSON as of writing.
- var error2 = http_request2.request(Settings.default_path + "/music/list")
- if error2 != OK:
- push_error("An error occurred in the HTTP request.")
-
+func show_answer(answer: JSON) -> void:
+ print("show_answer1: ", answer)
+ game_label.text = answer.Game
+ song_label.text = answer.Song
-var next_label: Label
-func show_fetched(result, response_code, headers, body) -> void:
- var json = JSON.new()
- var error = json.parse(body.get_string_from_utf8())
-
- if error == OK:
- var data_received = json.get_data()
- print("data_received: ", data_received)
- game_label.text = data_received.Game
- song_label.text = data_received.Song
- var format_string = "%d. %s - %s"
- var actual_string = format_string % [(data_received.SongNo+1), data_received.Game, data_received.Song]
- next_label.text = actual_string
-
-var song_list = []
-func show_fetched_list(result, response_code, headers, body) -> void:
- var json = JSON.new()
- var error = json.parse(body.get_string_from_utf8())
-
- if error == OK:
- var data_received = json.get_data()
+func fetched() -> void:
+ var show_fetched_list: Callable = func(data_received: Array) -> void:
if typeof(data_received) == TYPE_ARRAY:
song_list = []
song_list.append_array(data_received)
- delete_children(music_list)
+ Settings.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(label, song.SongNo))
- music_list.add_child(label)
+ for song: Dictionary in song_list:
+ var fetched_song_label: Label = Label.new()
+ var format_string: String = "%d. %s - %s"
+ var actual_string: String = format_string % [(song.SongNo+1), song.Game, song.Song]
+ fetched_song_label.text = actual_string
+ fetched_song_label.mouse_filter = Control.MOUSE_FILTER_PASS
+ fetched_song_label.gui_input.connect(song_clicked.bind(fetched_song_label, song.SongNo))
+ music_list.add_child(fetched_song_label)
- var songs := music_list.get_children()
- for song in songs:
+ songs = music_list.get_children()
+ for song: Label in songs:
song.remove_theme_color_override("font_color")
next_label = Label.new()
next_label.add_theme_color_override("font_color", Color(1, 0.5, 0))
@@ -415,61 +324,49 @@ func show_fetched_list(result, response_code, headers, body) -> void:
next_label.mouse_filter = Control.MOUSE_FILTER_PASS
next_label.gui_input.connect(fetch_full_music_list.bind(songs.size()))
music_list.add_child(next_label)
-
else:
print("Unexpected data")
+ Settings.make_request2("/music/list", show_fetched_list, true)
-func song_clicked(event, label: Label, song_no: int):
+func song_clicked(event: InputEvent, clicked_song_label: Label, song_no: int) -> void:
if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT):
print("Song Clicked: " + str(song_no))
- var songs := music_list.get_children()
- for song in songs:
+ songs = music_list.get_children()
+ for song: Label in songs:
song.remove_theme_color_override("font_color")
- label.add_theme_color_override("font_color", Color(1, 0.5, 0))
- var play_clicked_song = func(result, response_code, headers, body):
- if result != HTTPRequest.RESULT_SUCCESS:
- push_error("Song couldn't be downloaded. Try a different song.")
- var sound = AudioStreamMP3.new()
- sound.data = body
- audio.stream = sound
- audio.play()
- play_button.text = "Pause"
- stream = audio.stream
- progress.max_value = round(stream.get_length())
- progress.tick_count = round(stream.get_length() / 60)
- make_request(Settings.default_path + "/music?song=" + str(song_no), play_clicked_song)
- var show_answer = func(result, response_code, headers, body):
- var json = JSON.new()
- var error = json.parse(body.get_string_from_utf8())
-
- if error == OK:
- var data_received = json.get_data()
- game_label.text = data_received.Game
- song_label.text = data_received.Song
- make_request(Settings.default_path + "/music/info", show_answer)
+ clicked_song_label.add_theme_color_override("font_color", Color(1, 0.5, 0))
+ Settings.make_request2("/music?song=" + str(song_no), music_player_container.play_song, true)
+ Settings.make_request2("/music/info", show_answer, true)
+func _on_player_removed(new_player: Node) -> void:
+ players.remove_child(new_player)
-func open():
+func _on_player_change_character_clicked(new_player: Node) -> void:
+ print("_on_player_change_character_clicked")
+ current_player = new_player
+ character_select.visible = true
+
+func _on_character_selected(file_name: String) -> void:
+ print("_on_character_selected")
+ character_select.visible = false
+ current_player._on_control_character_selected_clicked(file_name)
+
+###Local
+
+var local_path: String = '/Users/sebastian/ResilioSync/Sorterat_test/Metal Gear Solid 4 - Guns of the Patriots/2-16 Metal Gear Saga.mp3'
+
+func open() -> void:
fileDialog.popup()
-
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-func _process(delta):
- if audio.has_stream_playback() && !is_changing && !audio.stream_paused:
- progress.value = audio.get_playback_position()
- label.text = format_text(progress.value, stream.get_length())
-
-func _on_file_dialog_dir_selected(path):
+
+func _on_file_dialog_dir_selected(path: String) -> void:
print(path)
dir_contents(path)
-var songs := []
-var games := []
-
func dir_contents(path: String) -> void:
- var dir = DirAccess.open(path)
+ var dir: DirAccess = DirAccess.open(path)
if dir:
dir.list_dir_begin()
- var file_name = dir.get_next()
+ var file_name: String = dir.get_next()
songs.clear()
while file_name != "":
if dir.current_is_dir():
@@ -480,151 +377,10 @@ func dir_contents(path: String) -> void:
if file_name.ends_with(".mp3"):
songs.append(path + "/" + file_name)
file_name = dir.get_next()
-
else:
print("An error occurred when trying to access the path.")
-
- for game in games:
- var label := Label.new()
- label.text = game
- insperation_list.add_child(label)
-
-
-
-
-var is_changing: bool = false
-var playback_position: float
-var stream: AudioStream
-
-func set_songs(new_songs) -> void:
- songs = new_songs
-
-func make_request(address, func_name) -> void:
- var http_request = HTTPRequest.new()
- add_child(http_request)
- http_request.request_completed.connect(func_name)
-
- # Perform a GET request. The URL below returns JSON as of writing.
- var error = http_request.request(address)
- if error != OK:
- push_error("An error occurred in the HTTP request.")
-
-
-func format_time(time: float) -> String:
- var mins: String = "%02d" % floor(time / 60)
- var sec: String = "%02d" % round(fmod(time, 60))
- return mins + ":" + sec
-
-func format_text(part: float, total: float) -> String:
- return format_time(part) + " / " + format_time(total)
-
-
-func fetch_next_song() -> void:
- var http_request = HTTPRequest.new()
- add_child(http_request)
- http_request.request_completed.connect(song_fetched)
-
- # Perform a GET request. The URL below returns JSON as of writing.
- var path = ""
- if Settings.use_low_played_mode:
- path = "/music/rand/low"
- else:
- path = "/music/rand"
- var error = http_request.request(Settings.default_path + path)
- if error != OK:
- push_error("An error occurred in the HTTP request.")
-
-func song_fetched(result, response_code, headers, body) -> void:
- if result != HTTPRequest.RESULT_SUCCESS:
- push_error("Song couldn't be downloaded. Try a different song.")
- var sound = AudioStreamMP3.new()
- sound.data = body
- print("play given song")
- audio.stream = sound
- audio.play()
- play_button.text = "Pause"
- stream = audio.stream
- make_request(Settings.default_path + "/music/addQue", add_que)
- progress.max_value = round(stream.get_length())
- progress.tick_count = round(stream.get_length() / 60)
- game_label.text = "????????"
- song_label.text = "??????"
- if Settings.add_to_stats:
- Settings.make_request2("/music/played", func(): pass , false)
- if !Settings.stop_after_current:
- audio.finished.connect(fetch_next_song)
- if !Settings.hide_next_track:
- show_answer()
-
-func add_que(result, response_code, headers, body) -> void:
- print("response_code", response_code)
- fetched()
-
-func play_local_song(song) -> void:
- if songs:
- path = songs[0]
- print(path)
- print(FileAccess.file_exists(path))
- audio.stream = load_mp3(path)
- print("play")
- audio.play()
- stream = audio.stream
- progress.max_value = round(stream.get_length())
- progress.tick_count = round(stream.get_length() / 60)
-
-func play_or_pause():
- if audio.stream_paused:
- play_button.text = "Pause"
- audio.stream_paused = false
- audio.seek(playback_position)
- print("continue")
- progress.max_value = round(stream.get_length())
- progress.tick_count = round(stream.get_length() / 60)
- else:
- audio.stream_paused = true
- playback_position = audio.get_playback_position()
- play_button.text = "Play"
-
-func restart() -> void:
- audio.stop()
- audio.stream_paused = false
- progress.value = 0
- playback_position = audio.get_playback_position()
- audio.seek(playback_position)
- play_button.text = "Pause"
- audio.play()
-
-func _on_drag_started() -> void:
- is_changing = true
-
-func _on_drag_ended(_changed) -> void:
- audio.seek(progress.value)
- playback_position = progress.value
- is_changing = false
-
-func load_mp3(_path) -> AudioStream:
- var file = FileAccess.open(_path, FileAccess.READ)
- var sound = AudioStreamMP3.new()
- sound.data = file.get_buffer(file.get_length())
- return sound
-
-func _on_player_removed(new_player):
- players.remove_child(new_player)
-
-var current_player
-func _on_player_change_character_clicked(new_player):
- print("_on_player_change_character_clicked")
- current_player = new_player
- character_select.visible = true
-
-func _on_character_selected(file_name: String):
- print("_on_character_selected")
- character_select.visible = false
- current_player._on_control_character_selected_clicked(file_name)
-
-
-func delete_children(node):
- for n in node.get_children():
- node.remove_child(n)
- n.queue_free()
+ for game: String in games:
+ var local_inspiration_label: Label = Label.new()
+ local_inspiration_label.text = game
+ inspiration_list.add_child(local_inspiration_label)
diff --git a/MainWindow.tscn b/MainWindow.tscn
index 1e0fc14..6fd0632 100644
--- a/MainWindow.tscn
+++ b/MainWindow.tscn
@@ -1,11 +1,11 @@
-[gd_scene load_steps=28 format=3 uid="uid://xwq863o6uvsu"]
+[gd_scene load_steps=26 format=3 uid="uid://xwq863o6uvsu"]
[ext_resource type="Script" path="res://MainWindow.gd" id="1_eu0t5"]
[ext_resource type="PackedScene" uid="uid://b16on0oscg1bv" path="res://CharacterSelect.tscn" id="2_76kf4"]
[ext_resource type="Script" path="res://InsperationScrollContainer.gd" id="2_gxtxm"]
-[ext_resource type="PackedScene" uid="uid://w400rnew7453" path="res://volume_slider.tscn" id="3_rxhba"]
[ext_resource type="AudioStream" uid="uid://n2g8jddr85h2" path="res://01. Opening.mp3" id="4_5kvsq"]
-[ext_resource type="Texture2D" uid="uid://o5go6smk7hm1" path="res://person_add_alt_1-black-36dp.svg" id="4_op458"]
+[ext_resource type="PackedScene" uid="uid://ds15cgsf8vpvc" path="res://MusicPlayer.tscn" id="5_emn36"]
+[ext_resource type="Texture2D" uid="uid://o5go6smk7hm1" path="res://icons/person_add_alt_1-black-36dp.svg" id="7_75f2e"]
[ext_resource type="Script" path="res://MusicListScrollContainer.gd" id="7_dj026"]
[ext_resource type="Script" path="res://PlayerNameField.gd" id="7_qsdfy"]
[ext_resource type="Theme" uid="uid://rxexo3ur85as" path="res://LightGrayTheme.tres" id="7_wxbv6"]
@@ -21,15 +21,6 @@ font_size = 50
[sub_resource type="LabelSettings" id="LabelSettings_3m52w"]
font_size = 35
-[sub_resource type="InputEventKey" id="InputEventKey_n2hsq"]
-device = -1
-alt_pressed = true
-keycode = 88
-unicode = 8776
-
-[sub_resource type="Shortcut" id="Shortcut_6mgjo"]
-events = [SubResource("InputEventKey_n2hsq")]
-
[sub_resource type="InputEventKey" id="InputEventKey_03bm3"]
device = -1
alt_pressed = true
@@ -95,6 +86,7 @@ text = "Music Player Randomizer"
label_settings = SubResource("LabelSettings_ychxr")
[node name="Open" type="Button" parent="."]
+visible = false
layout_mode = 2
offset_left = 1296.0
offset_top = 66.0
@@ -150,40 +142,19 @@ autowrap_mode = 2
[node name="CharacterSelect" parent="." instance=ExtResource("2_76kf4")]
visible = false
-[node name="PanelContainer" type="PanelContainer" parent="."]
+[node name="MusicPlayer" parent="." instance=ExtResource("5_emn36")]
layout_mode = 0
+anchors_preset = 0
+anchor_left = 0.0
+anchor_top = 0.0
+anchor_right = 0.0
+anchor_bottom = 0.0
offset_left = 65.0
-offset_top = 1003.0
-offset_right = 1856.0
-offset_bottom = 1043.0
-
-[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer"]
-layout_mode = 2
-size_flags_vertical = 4
-
-[node name="PlayButton" type="Button" parent="PanelContainer/HBoxContainer"]
-layout_mode = 2
-shortcut = SubResource("Shortcut_6mgjo")
-text = "Play"
-
-[node name="RestartButton" type="Button" parent="PanelContainer/HBoxContainer"]
-layout_mode = 2
-text = "Restart"
-
-[node name="HSlider" type="HSlider" parent="PanelContainer/HBoxContainer"]
-layout_mode = 2
-size_flags_horizontal = 3
-size_flags_vertical = 4
-scrollable = false
-
-[node name="Label" type="Label" parent="PanelContainer/HBoxContainer"]
-layout_mode = 2
-text = "1:00 / 3:00"
-
-[node name="VolumeSlider" parent="PanelContainer/HBoxContainer" instance=ExtResource("3_rxhba")]
-custom_minimum_size = Vector2(100, 0)
-layout_mode = 2
-size_flags_vertical = 4
+offset_top = 1048.0
+offset_right = 1854.0
+offset_bottom = 1080.0
+grow_horizontal = 1
+grow_vertical = 1
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("4_5kvsq")
@@ -217,7 +188,7 @@ custom_minimum_size = Vector2(2.08165e-12, 40)
layout_mode = 2
size_flags_horizontal = 8
shortcut = SubResource("Shortcut_jafqj")
-texture_normal = ExtResource("4_op458")
+texture_normal = ExtResource("7_75f2e")
[node name="AddPlayerContainer" type="HBoxContainer" parent="Players/VBoxContainer"]
visible = false
@@ -450,8 +421,8 @@ size = Vector2i(268, 233)
[node name="SettingsWindow" parent="SettingsPopupPanel" instance=ExtResource("11_k62u5")]
offset_left = 4.0
offset_top = 4.0
-offset_right = -4.0
-offset_bottom = 51.0
+offset_right = 264.0
+offset_bottom = 319.0
[node name="WinnerPopupPanel" type="PopupPanel" parent="."]
initial_position = 2
diff --git a/MediaPlayer.gd b/MediaPlayer.gd
deleted file mode 100644
index 98118ca..0000000
--- a/MediaPlayer.gd
+++ /dev/null
@@ -1,126 +0,0 @@
-extends PanelContainer
-
-# LOC 20/1-24: 136
-
-@onready
-var play_button := $HBoxContainer/PlayButton
-
-@onready
-var pause_button := $HBoxContainer/PauseButton
-
-@onready
-var stop_button := $HBoxContainer/StopButton
-
-@onready
-var audio := $AudioStreamPlayer
-
-@onready
-var progress := $HBoxContainer/HSlider
-
-@onready
-var label := $HBoxContainer/Label
-
-@onready
-var path = '/Users/sebastian/ResilioSync/Sorterat_test/Metal Gear Solid 4 - Guns of the Patriots/2-16 Metal Gear Saga.mp3'
-
-var songs := []
-
-var is_changing: bool = false
-var playback_position: float
-var stream: AudioStream
-
-signal fetched
-
-func set_songs(new_songs) -> void:
- songs = new_songs
-
-func make_request(address, func_name) -> void:
- var http_request = HTTPRequest.new()
- add_child(http_request)
- http_request.request_completed.connect(func_name)
-
- # Perform a GET request. The URL below returns JSON as of writing.
- var error = http_request.request(address)
- if error != OK:
- push_error("An error occurred in the HTTP request.")
-
-# Called when the node enters the scene tree for the first time.
-func _ready() -> void:
- play_button.pressed.connect(fetch_first_song)
- pause_button.pressed.connect(pause)
- stop_button.pressed.connect(stop)
- progress.drag_started.connect(_on_drag_started)
- progress.drag_ended.connect(_on_drag_ended)
-
-func format_time(time: float) -> String:
- var mins: String = "%02d" % floor(time / 60)
- var sec: String = "%02d" % round(fmod(time, 60))
- return mins + ":" + sec
-
-func format_text(part: float, total: float) -> String:
- return format_time(part) + " / " + format_time(total)
-
-func _process(_delta):
- if audio.has_stream_playback() && !is_changing && !audio.stream_paused:
- progress.value = audio.get_playback_position()
- label.text = format_text(progress.value, stream.get_length())
-
-func fetch_first_song() -> void:
- var first_song_fetched = func(result, _response_code, _headers, body):
- if result != HTTPRequest.RESULT_SUCCESS:
- push_error("Song couldn't be downloaded. Try a different song.")
- var sound = AudioStreamMP3.new()
- sound.data = body
- Settings.make_request2("/music/addQue", func(): fetched.emit(), true)
- play(sound)
-
- Settings.make_request2("/music/rand", first_song_fetched, true)
-
-func add_que(_result, response_code, _headers, _body) -> void:
- print("response_code", response_code)
- fetched.emit()
-
-func play(song) -> void:
- if audio.stream_paused:
- audio.stream_paused = false
- audio.seek(playback_position)
- print("continue")
- elif song:
- print("play given song")
- audio.stream = song
- audio.play()
- stream = audio.stream
- else:
- if songs:
- path = songs[0]
- print(path)
- print(FileAccess.file_exists(path))
- audio.stream = load_mp3(path)
- print("play")
- audio.play()
- stream = audio.stream
- progress.max_value = round(stream.get_length())
- progress.tick_count = round(stream.get_length() / 60)
-
-func pause() -> void:
- audio.stream_paused = true
- playback_position = audio.get_playback_position()
-
-func stop() -> void:
- audio.stop()
- audio.stream_paused = false
- progress.value = 0
-
-func _on_drag_started() -> void:
- is_changing = true
-
-func _on_drag_ended(_changed) -> void:
- audio.seek(progress.value)
- playback_position = progress.value
- is_changing = false
-
-func load_mp3(_path) -> AudioStream:
- var file = FileAccess.open(_path, FileAccess.READ)
- var sound = AudioStreamMP3.new()
- sound.data = file.get_buffer(file.get_length())
- return sound
\ No newline at end of file
diff --git a/MediaPlayer.tscn b/MediaPlayer.tscn
deleted file mode 100644
index bd741d6..0000000
--- a/MediaPlayer.tscn
+++ /dev/null
@@ -1,48 +0,0 @@
-[gd_scene load_steps=3 format=3 uid="uid://ds15cgsf8vpvc"]
-
-[ext_resource type="Script" path="res://MediaPlayer.gd" id="1_7xb8h"]
-[ext_resource type="AudioStream" uid="uid://n2g8jddr85h2" path="res://01. Opening.mp3" id="2_sv4nm"]
-
-[node name="MediaPlayer" type="PanelContainer"]
-anchors_preset = 8
-anchor_left = 0.5
-anchor_top = 0.5
-anchor_right = 0.5
-anchor_bottom = 0.5
-offset_left = -121.0
-offset_top = -15.5
-offset_right = 121.0
-offset_bottom = 15.5
-grow_horizontal = 2
-grow_vertical = 2
-size_flags_vertical = 4
-script = ExtResource("1_7xb8h")
-
-[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
-stream = ExtResource("2_sv4nm")
-
-[node name="HBoxContainer" type="HBoxContainer" parent="."]
-layout_mode = 2
-size_flags_vertical = 4
-
-[node name="PlayButton" type="Button" parent="HBoxContainer"]
-layout_mode = 2
-text = "Play"
-
-[node name="PauseButton" type="Button" parent="HBoxContainer"]
-layout_mode = 2
-text = "Pause"
-
-[node name="StopButton" type="Button" parent="HBoxContainer"]
-layout_mode = 2
-text = "Stop"
-
-[node name="HSlider" type="HSlider" parent="HBoxContainer"]
-layout_mode = 2
-size_flags_horizontal = 3
-size_flags_vertical = 4
-scrollable = false
-
-[node name="Label" type="Label" parent="HBoxContainer"]
-layout_mode = 2
-text = "1:00 / 3:00"
diff --git a/MusicPlayer.gd b/MusicPlayer.gd
new file mode 100644
index 0000000..568fff1
--- /dev/null
+++ b/MusicPlayer.gd
@@ -0,0 +1,170 @@
+class_name MusicPlayer
+extends PanelContainer
+
+# LOC 20/1-24: 136
+# LOC 12/6-24: 170
+
+@onready
+var play_button: TextureButton = $MusicPlayerContainer/PlayTextureButton
+
+@onready
+var restart_button: TextureButton = $MusicPlayerContainer/RestartTextureButton
+
+@onready
+var audio_player: AudioStreamPlayer = $AudioStreamPlayer
+
+@onready
+var progress_slider: HSlider = $MusicPlayerContainer/MusicPlayerSlider
+
+@onready
+var music_time_label: Label = $MusicPlayerContainer/MusicTimeLabel
+
+@onready
+var path: String = '/Users/sebastian/ResilioSync/Sorterat_test/Metal Gear Solid 4 - Guns of the Patriots/2-16 Metal Gear Saga.mp3'
+
+var play_icon: Texture = preload("res://icons/play_icon.svg")
+var pause_icon: Texture = preload("res://icons/pause_icon.svg")
+
+var songs: Array = []
+
+var is_changing: bool = false
+var playback_position: float
+var stream: AudioStream
+
+signal fetched
+signal winner(player_name: String)
+signal add_to_queue
+signal show_answer
+
+# Called when the node enters the scene tree for the first time.
+func _ready() -> void:
+ play_button.pressed.connect(play_or_pause)
+ restart_button.pressed.connect(restart)
+ progress_slider.drag_started.connect(_on_drag_started)
+ progress_slider.drag_ended.connect(_on_drag_ended)
+
+func _process(_delta: float) -> void:
+ if audio_player.has_stream_playback() && !is_changing && !audio_player.stream_paused:
+ progress_slider.value = audio_player.get_playback_position()
+ if stream != null:
+ music_time_label.text = format_text(progress_slider.value, stream.get_length())
+ else:
+ music_time_label.text = format_text(progress_slider.value, 0.0)
+
+func format_time(time: float) -> String:
+ var mins: String = "%02d" % floor(time / 60)
+ var sec: String = "%02d" % round(fmod(time, 60))
+ return mins + ":" + sec
+
+func format_text(part: float, total: float) -> String:
+ return format_time(part) + " / " + format_time(total)
+
+func play_or_pause() -> void:
+ if audio_player.stream_paused:
+ play_button.texture_normal = pause_icon
+ audio_player.stream_paused = false
+ audio_player.seek(playback_position)
+ print("continue")
+ progress_slider.max_value = round(stream.get_length())
+ progress_slider.tick_count = round(stream.get_length() / 60)
+ else:
+ audio_player.stream_paused = true
+ playback_position = audio_player.get_playback_position()
+ play_button.texture_normal = play_icon
+
+func restart() -> void:
+ audio_player.stop()
+ audio_player.stream_paused = false
+ progress_slider.value = 0
+ playback_position = audio_player.get_playback_position()
+ audio_player.seek(playback_position)
+ play_button.texture_normal = pause_icon
+ audio_player.play()
+
+func _on_drag_started() -> void:
+ is_changing = true
+
+func _on_drag_ended(_changed: bool) -> void:
+ audio_player.seek(progress_slider.value)
+ playback_position = progress_slider.value
+ is_changing = false
+
+func _on_point_triggered(point: String) -> void:
+ if point == "first":
+ var value: int = randi_range(0, 10)
+ if value == 0:
+ play_sound(preload("res://sounds/sound1.mp3"))
+ elif value < 5:
+ play_sound(preload("res://sounds/intro_long.mp3"))
+ else:
+ play_sound(preload("res://sounds/intro_short.mp3"))
+ elif point == "match":
+ play_sound(preload("res://sounds/sound0.mp3"))
+
+func play_sound(sound_name: AudioStream) -> void:
+ audio_player.stream = sound_name
+ audio_player.play()
+ play_button.texture_normal = pause_icon
+ stream = audio_player.stream
+ progress_slider.max_value = round(stream.get_length())
+ progress_slider.tick_count = round(stream.get_length() / 60)
+
+func play_song(body: PackedByteArray) -> void:
+ var sound: AudioStream = AudioStreamMP3.new()
+ sound.data = body
+ audio_player.stream = sound
+ audio_player.play()
+ play_button.texture_normal = pause_icon
+ stream = audio_player.stream
+ progress_slider.max_value = round(stream.get_length())
+ progress_slider.tick_count = round(stream.get_length() / 60)
+
+func song_fetched(body: PackedByteArray) -> void:
+ print("song_fetched")
+ var sound: AudioStream = AudioStreamMP3.new()
+ sound.data = body
+ print("play given song")
+ audio_player.stream = sound
+ audio_player.play()
+ play_button.texture_normal = pause_icon
+ stream = audio_player.stream
+ progress_slider.max_value = round(stream.get_length())
+ progress_slider.tick_count = round(stream.get_length() / 60)
+ add_to_queue.emit()
+
+ if Settings.add_to_stats:
+ Settings.make_request3("/music/played")
+ if !Settings.stop_after_current:
+ audio_player.finished.connect(fetch_next_song)
+ if !Settings.hide_next_track:
+ show_answer.emit()
+
+func fetch_next_song() -> void:
+ var url: String = ""
+ if Settings.use_low_played_mode:
+ url = "/music/rand/low"
+ else:
+ url = "/music/rand"
+ Settings.make_request2(url, song_fetched, true)
+
+func get_sound_test_song() -> void:
+ Settings.make_request2("/music/soundTest", play_song, true)
+
+##### LOCAL
+var local_path: String = '/Users/sebastian/ResilioSync/Sorterat_test/Metal Gear Solid 4 - Guns of the Patriots/2-16 Metal Gear Saga.mp3'
+
+func load_mp3(_path: String) -> AudioStream:
+ var file: FileAccess = FileAccess.open(_path, FileAccess.READ)
+ var sound: AudioStream = AudioStreamMP3.new()
+ sound.data = file.get_buffer(file.get_length())
+ return sound
+
+func play_local_song() -> void:
+ if songs:
+ local_path = songs[0]
+ print(local_path)
+ print(FileAccess.file_exists(local_path))
+ play_sound(load_mp3(local_path))
+
+func sound_test_local() -> void:
+ play_sound(preload("res://01. Opening.mp3"))
diff --git a/MusicPlayer.tscn b/MusicPlayer.tscn
new file mode 100644
index 0000000..64993a6
--- /dev/null
+++ b/MusicPlayer.tscn
@@ -0,0 +1,59 @@
+[gd_scene load_steps=6 format=3 uid="uid://ds15cgsf8vpvc"]
+
+[ext_resource type="Script" path="res://MusicPlayer.gd" id="1_t24ra"]
+[ext_resource type="AudioStream" uid="uid://n2g8jddr85h2" path="res://01. Opening.mp3" id="2_xti80"]
+[ext_resource type="Texture2D" uid="uid://balbkfmupmj8u" path="res://icons/play_icon.svg" id="3_2ym83"]
+[ext_resource type="Texture2D" uid="uid://cu5d30apj6os6" path="res://icons/134221_refresh_reload_repeat_update_arrow_icon.svg" id="4_1grnq"]
+[ext_resource type="PackedScene" uid="uid://w400rnew7453" path="res://volume_slider.tscn" id="5_iifuj"]
+
+[node name="MusicPlayer" type="PanelContainer"]
+anchors_preset = 8
+anchor_left = 0.5
+anchor_top = 0.5
+anchor_right = 0.5
+anchor_bottom = 0.5
+offset_left = -121.0
+offset_top = -15.5
+offset_right = 121.0
+offset_bottom = 16.5
+grow_horizontal = 2
+grow_vertical = 2
+size_flags_vertical = 4
+script = ExtResource("1_t24ra")
+
+[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
+stream = ExtResource("2_xti80")
+
+[node name="MusicPlayerContainer" type="HBoxContainer" parent="."]
+layout_mode = 2
+size_flags_vertical = 4
+
+[node name="PlayTextureButton" type="TextureButton" parent="MusicPlayerContainer"]
+custom_minimum_size = Vector2(32, 32)
+layout_mode = 2
+texture_normal = ExtResource("3_2ym83")
+ignore_texture_size = true
+stretch_mode = 0
+
+[node name="RestartTextureButton" type="TextureButton" parent="MusicPlayerContainer"]
+custom_minimum_size = Vector2(32, 32)
+layout_mode = 2
+texture_normal = ExtResource("4_1grnq")
+ignore_texture_size = true
+stretch_mode = 0
+flip_h = true
+
+[node name="MusicPlayerSlider" type="HSlider" parent="MusicPlayerContainer"]
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 4
+scrollable = false
+
+[node name="MusicTimeLabel" type="Label" parent="MusicPlayerContainer"]
+layout_mode = 2
+text = "1:00 / 3:00"
+
+[node name="VolumeSlider" parent="MusicPlayerContainer" instance=ExtResource("5_iifuj")]
+custom_minimum_size = Vector2(100, 0)
+layout_mode = 2
+size_flags_vertical = 4
diff --git a/Player.gd b/Player.gd
index 1f686fd..a00869a 100644
--- a/Player.gd
+++ b/Player.gd
@@ -1,3 +1,4 @@
+class_name Player
extends Control
@onready
@@ -24,18 +25,18 @@ signal player_removed
@export
var player_name: String
+@export
+var player_score: String
+
var is_first_point: bool = true
# Called when the node enters the scene tree for the first time.
-func _ready():
+func _ready() -> void:
add.pressed.connect(add_point)
minus.pressed.connect(minus_point)
character.pressed.connect(change_character)
remove_player.pressed.connect(func(): player_removed.emit())
- player_name_field.text = player_name
-
-func new_player_name(new_name: String):
- player_name = new_name
+ player_name_field.text = player_score
func add_point():
if is_first_point:
diff --git a/Player.tscn b/Player.tscn
index 4b28b1e..e9cffad 100644
--- a/Player.tscn
+++ b/Player.tscn
@@ -2,7 +2,7 @@
[ext_resource type="Script" path="res://Player.gd" id="1_if4kc"]
[ext_resource type="Texture2D" uid="uid://r4as0nmtoa7p" path="res://noCharacter.png" id="2_hpj3s"]
-[ext_resource type="Texture2D" uid="uid://t1tnj6nqpi4a" path="res://person_remove-black-36dp.svg" id="2_xw2ck"]
+[ext_resource type="Texture2D" uid="uid://t1tnj6nqpi4a" path="res://icons/person_remove-black-36dp.svg" id="3_5cuu3"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_821k2"]
bg_color = Color(0.180392, 0.180392, 0.180392, 1)
@@ -86,4 +86,4 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_b2crt")
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
size_flags_horizontal = 3
-texture_normal = ExtResource("2_xw2ck")
+texture_normal = ExtResource("3_5cuu3")
diff --git a/SearchWindow.gd b/SearchWindow.gd
index 5fbbd7d..87eec84 100644
--- a/SearchWindow.gd
+++ b/SearchWindow.gd
@@ -33,7 +33,7 @@ func close():
func search():
print(search_bar.text)
- delete_children(search_list)
+ Settings.delete_children(search_list)
for game in games:
if is_match(search_bar.text, game):
var label := Label.new()
@@ -60,31 +60,11 @@ func compile_regex(search_term: String) -> RegEx:
print(regText)
regex.compile(regText)
return regex
-
-func delete_children(node):
- for n in node.get_children():
- node.remove_child(n)
- n.queue_free()
func get_list_of_games() -> void:
- var http_request = HTTPRequest.new()
- add_child(http_request)
- http_request.request_completed.connect(self._http_request_completed)
-
- # Perform a GET request. The URL below returns JSON as of writing.
- var error = http_request.request(Settings.default_path + "/music/all/order")
- if error != OK:
- push_error("An error occurred in the HTTP request.")
-
-# Called when the HTTP request is completed.
-func _http_request_completed(_result, _response_code, _headers, body):
- var json = JSON.new()
- var error = json.parse(body.get_string_from_utf8())
-
- if error == OK:
- var data_received = json.get_data()
- if typeof(data_received) == TYPE_ARRAY:
- games.append_array(data_received)
+ var handle_games = func(array):
+ if typeof(array) == TYPE_ARRAY:
+ games.append_array(array)
for game in games:
var label := Label.new()
label.text = game
@@ -92,6 +72,7 @@ func _http_request_completed(_result, _response_code, _headers, body):
search_list.add_child(label)
else:
print("Unexpected data")
+ Settings.make_request2("/music/all/order", handle_games, true)
func clear():
search_bar.text = ""
diff --git a/Settings.gd b/Settings.gd
index 75ab786..072d28d 100644
--- a/Settings.gd
+++ b/Settings.gd
@@ -1,7 +1,7 @@
extends Node
var default_path: String = "https://tmusic.sanplex.tech"
-var selected_server = 0
+var selected_server: int = 0
var is_local: bool = false
@@ -11,6 +11,7 @@ var add_to_stats: bool = false
var use_low_played_mode: bool = false
var winning_score: int = 20
var fullscreen: bool = false
+var play_local: bool = false
var version: String = "0.9.0-Beta"
@@ -39,26 +40,46 @@ Alt + V = Show Answer"
#visa svar = v
#lägga till poäng? 1, 2, 3, 4, 5, 6
-
func make_request2(address: String, func_name: Callable, expect_data: bool) -> void:
- var error_handling = func(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray):
+ var error_handling: Callable = func(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray) -> void:
if response_code == 200:
if !expect_data:
func_name.call()
else:
- var json = JSON.new()
- var error = json.parse(body.get_string_from_utf8())
+ var json: JSON = JSON.new()
+ var error: int = json.parse(body.get_string_from_utf8())
if error == OK:
var data_received = json.get_data()
- print("data_received: ", data_received)
+ #print("data_received: ", data_received)
+ print("data_received type: ", typeof(data_received))
func_name.call(data_received)
+ else:
+ print("song_received")
+ func_name.call(body)
var http_request: HTTPRequest = HTTPRequest.new()
add_child(http_request)
http_request.request_completed.connect(error_handling)
# Perform a GET request. The URL below returns JSON as of writing.
- var request_error = http_request.request(default_path + address)
+ var request_error: int = http_request.request(default_path + address)
+ if request_error != OK:
+ push_error("An error occurred in the HTTP request.")
+
+func make_request3(address: String) -> void:
+ var error_handling: Callable = func(_result: int, response_code: int, _headers: PackedStringArray, _body: PackedByteArray) -> void:
+ if response_code != 200:
+ print("Error: " + str(response_code))
+
+ var http_request: HTTPRequest = HTTPRequest.new()
+ add_child(http_request)
+ http_request.request_completed.connect(error_handling)
+ # Perform a GET request. The URL below returns JSON as of writing.
+ var request_error: int = http_request.request(default_path + address)
if request_error != OK:
push_error("An error occurred in the HTTP request.")
+func delete_children(node: Node) -> void:
+ for n: Node in node.get_children():
+ node.remove_child(n)
+ n.queue_free()
diff --git a/SettingsWindow.gd b/SettingsWindow.gd
index d213f3e..ef7fd94 100644
--- a/SettingsWindow.gd
+++ b/SettingsWindow.gd
@@ -27,6 +27,9 @@ var select_server_button := $SelectServerButton
@onready
var fullscreen_button := $FullscreenButton
+@onready
+var local_button := $LocalButton
+
# Called when the node enters the scene tree for the first time.
func _ready():
stop_after_current_button.pressed.connect(stop_after_current)
@@ -37,6 +40,7 @@ func _ready():
increase_winning_score_button.pressed.connect(increase_winning_score)
select_server_button.pressed.connect(select_server)
fullscreen_button.pressed.connect(fullscreen)
+ local_button.pressed.connect(local_play)
stop_after_current_button.button_pressed = Settings.stop_after_current
hide_next_track_button.button_pressed = Settings.hide_next_track
@@ -50,6 +54,9 @@ func fullscreen():
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
if Settings.fullscreen == false:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
+
+func local_play():
+ Settings.play_local = !Settings.play_local
func stop_after_current():
Settings.stop_after_current = !Settings.stop_after_current
diff --git a/SettingsWindow.tscn b/SettingsWindow.tscn
index 022b23e..5231380 100644
--- a/SettingsWindow.tscn
+++ b/SettingsWindow.tscn
@@ -82,3 +82,8 @@ popup/item_2/id = 2
[node name="FullscreenButton" type="CheckButton" parent="."]
layout_mode = 2
text = "Fullscreen"
+
+[node name="LocalButton" type="CheckButton" parent="."]
+layout_mode = 2
+disabled = true
+text = "Local"
diff --git a/addons/godot-git-plugin/linux/libgit_plugin.linux.editor.x86_64.so b/addons/godot-git-plugin/linux/libgit_plugin.linux.editor.x86_64.so
index 8dab6db..3e4694e 100644
Binary files a/addons/godot-git-plugin/linux/libgit_plugin.linux.editor.x86_64.so and b/addons/godot-git-plugin/linux/libgit_plugin.linux.editor.x86_64.so differ
diff --git a/addons/godot-git-plugin/macos/libgit_plugin.macos.editor.universal.dylib b/addons/godot-git-plugin/macos/libgit_plugin.macos.editor.universal.dylib
index 644aa2a..dc22ff3 100644
Binary files a/addons/godot-git-plugin/macos/libgit_plugin.macos.editor.universal.dylib and b/addons/godot-git-plugin/macos/libgit_plugin.macos.editor.universal.dylib differ
diff --git a/addons/godot-git-plugin/plugin.cfg b/addons/godot-git-plugin/plugin.cfg
index 9c4e36f..209e13f 100644
--- a/addons/godot-git-plugin/plugin.cfg
+++ b/addons/godot-git-plugin/plugin.cfg
@@ -3,5 +3,5 @@
name="Godot Git Plugin"
description="This plugin lets you interact with Git without leaving the Godot editor. More information can be found at https://github.com/godotengine/godot-git-plugin/wiki"
author="twaritwaikar"
-version="v3.1.1"
+version="v3.1.0"
script="godot-git-plugin.gd"
diff --git a/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.dll b/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.dll
index 47bbb1d..60e5fe6 100644
Binary files a/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.dll and b/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.dll differ
diff --git a/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.exp b/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.exp
index 6c68d89..d5c91fe 100644
Binary files a/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.exp and b/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.exp differ
diff --git a/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.lib b/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.lib
index 4537929..98c9b4b 100644
Binary files a/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.lib and b/addons/godot-git-plugin/win64/libgit_plugin.windows.editor.x86_64.lib differ
diff --git a/icons/134221_refresh_reload_repeat_update_arrow_icon.svg b/icons/134221_refresh_reload_repeat_update_arrow_icon.svg
new file mode 100644
index 0000000..8f942b0
--- /dev/null
+++ b/icons/134221_refresh_reload_repeat_update_arrow_icon.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/icons/134221_refresh_reload_repeat_update_arrow_icon.svg.import b/icons/134221_refresh_reload_repeat_update_arrow_icon.svg.import
new file mode 100644
index 0000000..7bb9409
--- /dev/null
+++ b/icons/134221_refresh_reload_repeat_update_arrow_icon.svg.import
@@ -0,0 +1,37 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://cu5d30apj6os6"
+path="res://.godot/imported/134221_refresh_reload_repeat_update_arrow_icon.svg-2f211a3a6698868bbe9157ba00acac34.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://icons/134221_refresh_reload_repeat_update_arrow_icon.svg"
+dest_files=["res://.godot/imported/134221_refresh_reload_repeat_update_arrow_icon.svg-2f211a3a6698868bbe9157ba00acac34.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0
+editor/scale_with_editor_scale=false
+editor/convert_colors_with_editor_theme=false
diff --git a/icons/pause_icon.svg b/icons/pause_icon.svg
new file mode 100644
index 0000000..5bb17c7
--- /dev/null
+++ b/icons/pause_icon.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/icons/pause_icon.svg.import b/icons/pause_icon.svg.import
new file mode 100644
index 0000000..613b194
--- /dev/null
+++ b/icons/pause_icon.svg.import
@@ -0,0 +1,37 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://dy3s5efx3t48l"
+path="res://.godot/imported/pause_icon.svg-68ce3214f66117eb84625596d75649f0.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://icons/pause_icon.svg"
+dest_files=["res://.godot/imported/pause_icon.svg-68ce3214f66117eb84625596d75649f0.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0
+editor/scale_with_editor_scale=false
+editor/convert_colors_with_editor_theme=false
diff --git a/person_add_alt_1-black-36dp.svg b/icons/person_add_alt_1-black-36dp.svg
similarity index 100%
rename from person_add_alt_1-black-36dp.svg
rename to icons/person_add_alt_1-black-36dp.svg
diff --git a/person_add_alt_1-black-36dp.svg.import b/icons/person_add_alt_1-black-36dp.svg.import
similarity index 78%
rename from person_add_alt_1-black-36dp.svg.import
rename to icons/person_add_alt_1-black-36dp.svg.import
index 72bca90..c1d43a0 100644
--- a/person_add_alt_1-black-36dp.svg.import
+++ b/icons/person_add_alt_1-black-36dp.svg.import
@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://o5go6smk7hm1"
-path="res://.godot/imported/person_add_alt_1-black-36dp.svg-bf42e8ddf13a4f7adae8637f26a86e94.ctex"
+path="res://.godot/imported/person_add_alt_1-black-36dp.svg-25623c537799fb927948ac6a1b469357.ctex"
metadata={
"vram_texture": false
}
[deps]
-source_file="res://person_add_alt_1-black-36dp.svg"
-dest_files=["res://.godot/imported/person_add_alt_1-black-36dp.svg-bf42e8ddf13a4f7adae8637f26a86e94.ctex"]
+source_file="res://icons/person_add_alt_1-black-36dp.svg"
+dest_files=["res://.godot/imported/person_add_alt_1-black-36dp.svg-25623c537799fb927948ac6a1b469357.ctex"]
[params]
diff --git a/person_remove-black-36dp.svg b/icons/person_remove-black-36dp.svg
similarity index 100%
rename from person_remove-black-36dp.svg
rename to icons/person_remove-black-36dp.svg
diff --git a/person_remove-black-36dp.svg.import b/icons/person_remove-black-36dp.svg.import
similarity index 78%
rename from person_remove-black-36dp.svg.import
rename to icons/person_remove-black-36dp.svg.import
index 0e2311f..9982c29 100644
--- a/person_remove-black-36dp.svg.import
+++ b/icons/person_remove-black-36dp.svg.import
@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://t1tnj6nqpi4a"
-path="res://.godot/imported/person_remove-black-36dp.svg-60481722f4b86c76228674c37c2e8b80.ctex"
+path="res://.godot/imported/person_remove-black-36dp.svg-963386011d14140f65e426970f38ba33.ctex"
metadata={
"vram_texture": false
}
[deps]
-source_file="res://person_remove-black-36dp.svg"
-dest_files=["res://.godot/imported/person_remove-black-36dp.svg-60481722f4b86c76228674c37c2e8b80.ctex"]
+source_file="res://icons/person_remove-black-36dp.svg"
+dest_files=["res://.godot/imported/person_remove-black-36dp.svg-963386011d14140f65e426970f38ba33.ctex"]
[params]
diff --git a/icons/play_icon.svg b/icons/play_icon.svg
new file mode 100644
index 0000000..c54977e
--- /dev/null
+++ b/icons/play_icon.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/icons/play_icon.svg.import b/icons/play_icon.svg.import
new file mode 100644
index 0000000..4db4969
--- /dev/null
+++ b/icons/play_icon.svg.import
@@ -0,0 +1,37 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://balbkfmupmj8u"
+path="res://.godot/imported/play_icon.svg-0a6a03003397e38401a1f89bcd5454b2.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://icons/play_icon.svg"
+dest_files=["res://.godot/imported/play_icon.svg-0a6a03003397e38401a1f89bcd5454b2.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0
+editor/scale_with_editor_scale=false
+editor/convert_colors_with_editor_theme=false
diff --git a/project.godot b/project.godot
index 5a2d63a..2e1d219 100644
--- a/project.godot
+++ b/project.godot
@@ -20,6 +20,11 @@ config/icon="res://icon.svg"
Settings="*res://Settings.gd"
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+gdscript/warnings/inferred_declaration=1
+
[display]
window/size/viewport_width=1920
@@ -36,6 +41,10 @@ project/assembly_name="MusicPlayer"
version_control/plugin_name="GitPlugin"
version_control/autoload_on_startup=true
+[dotnet]
+
+project/assembly_name="MusicPlayer"
+
[rendering]
textures/vram_compression/import_s3tc_bptc=true