From 90ce6619822cd787b77560a1d84f65adecafccef Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 2 Sep 2023 23:14:19 +0200 Subject: [PATCH 1/6] Added some buttons and added search view --- MainWindow.gd | 32 ++++++++++++++++++++- MainWindow.tscn | 67 +++++++++++++++++++++++++++++++++++++++---- SearchWindow.gd | 73 +++++++++++++++++++++++++++++++++++++++++++++++ SearchWindow.tscn | 55 +++++++++++++++++++++++++++++++++++ 4 files changed, 220 insertions(+), 7 deletions(-) create mode 100644 SearchWindow.gd create mode 100644 SearchWindow.tscn diff --git a/MainWindow.gd b/MainWindow.gd index 65479de..3136ea6 100644 --- a/MainWindow.gd +++ b/MainWindow.gd @@ -1,5 +1,22 @@ extends Control +##TODO +# 1. Fix sync +# 2. Fix reset buttons +# 3. Fix settings +# 4. Fix top buttons +# 5. Fix player name +# 6. Fix sound test +# 7. Fix welcome into the game +# 8. Fix match ball sound +# 9. Fix winner +# 10. Fix jump between songs +# 11. Refactor components +# 12. Change add player +# 13. Fix graphics in lists +# 14. Fix layout +# 15. Fix for local play + @onready var open_button := $Open @@ -57,6 +74,12 @@ var players := $Players/VBoxContainer @onready var character_select := $CharacterSelect +@onready +var search_button := $SearchButton + +@onready +var search_view := $Search + var Player := preload("res://Player.tscn") @onready @@ -65,7 +88,7 @@ var path = '/Users/sebastian/ResilioSync/Sorterat_test/Metal Gear Solid 4 - Guns func get_suggestion_list() -> void: var http_request = HTTPRequest.new() add_child(http_request) - http_request.request_completed.connect(self._http_request_completed) + http_request.request_completed.connect(_http_request_completed) # Perform a GET request. The URL below returns JSON as of writing. var error = http_request.request("https://music.sanplex.tech/music/all") @@ -83,6 +106,7 @@ func _ready(): pause_button.pressed.connect(pause) stop_button.pressed.connect(stop) show_answer_button.pressed.connect(show_answer) + search_button.pressed.connect(show_search) progress.drag_started.connect(_on_drag_started) progress.drag_ended.connect(_on_drag_ended) @@ -93,6 +117,12 @@ func _ready(): open_button.pressed.connect(open) get_suggestion_list() +func show_search(): + 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) diff --git a/MainWindow.tscn b/MainWindow.tscn index fd22513..e4c2784 100644 --- a/MainWindow.tscn +++ b/MainWindow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://xwq863o6uvsu"] +[gd_scene load_steps=15 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"] @@ -8,6 +8,10 @@ [ext_resource type="Texture2D" uid="uid://o5go6smk7hm1" path="res://person_add_alt_1-black-36dp.svg" id="4_op458"] [ext_resource type="Script" path="res://MusicListScrollContainer.gd" id="7_dj026"] [ext_resource type="Theme" uid="uid://rxexo3ur85as" path="res://LightGrayTheme.tres" id="7_wxbv6"] +[ext_resource type="PackedScene" uid="uid://bxydgil1yifps" path="res://SearchWindow.tscn" id="9_5ijvr"] + +[sub_resource type="LabelSettings" id="LabelSettings_ychxr"] +font_size = 25 [sub_resource type="LabelSettings" id="LabelSettings_qspbu"] font_size = 50 @@ -15,6 +19,14 @@ font_size = 50 [sub_resource type="LabelSettings" id="LabelSettings_3m52w"] font_size = 35 +[sub_resource type="InputEventKey" id="InputEventKey_ujjlu"] +device = -1 +command_or_control_autoremap = true +keycode = 83 + +[sub_resource type="Shortcut" id="Shortcut_fbju4"] +events = [SubResource("InputEventKey_ujjlu")] + [node name="Control" type="Control"] layout_mode = 3 anchors_preset = 0 @@ -23,15 +35,17 @@ script = ExtResource("1_eu0t5") [node name="TopPanelContainer" type="PanelContainer" parent="."] layout_mode = 0 offset_right = 1920.0 -offset_bottom = 52.0 +offset_bottom = 56.0 -[node name="HBoxContainer" type="HBoxContainer" parent="TopPanelContainer"] -layout_mode = 2 - -[node name="Label" type="Label" parent="TopPanelContainer/HBoxContainer"] +[node name="Title" type="Label" parent="."] layout_mode = 2 +offset_left = 32.0 +offset_top = 8.0 +offset_right = 337.0 +offset_bottom = 46.0 size_flags_horizontal = 0 text = "Music Player Randomizer" +label_settings = SubResource("LabelSettings_ychxr") [node name="Open" type="Button" parent="."] layout_mode = 2 @@ -227,4 +241,45 @@ script = ExtResource("7_dj026") [node name="MusicList" type="VBoxContainer" parent="MusicListPanel/ScrollContainer"] layout_mode = 2 +[node name="SearchButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 1528.0 +offset_top = 8.0 +offset_right = 1598.0 +offset_bottom = 48.0 +shortcut = SubResource("Shortcut_fbju4") +text = "Search" + +[node name="SettingsButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 1624.0 +offset_top = 8.0 +offset_right = 1694.0 +offset_bottom = 48.0 +text = "Settings" + +[node name="StatisticsButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 1720.0 +offset_top = 8.0 +offset_right = 1798.0 +offset_bottom = 48.0 +text = "Statistics" + +[node name="AboutButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 1824.0 +offset_top = 8.0 +offset_right = 1894.0 +offset_bottom = 48.0 +text = "About" + +[node name="Search" parent="." instance=ExtResource("9_5ijvr")] +visible = false +layout_mode = 1 +offset_left = 349.196 +offset_top = 81.2367 +offset_right = 349.196 +offset_bottom = 81.2367 + [connection signal="dir_selected" from="FileDialog" to="." method="_on_file_dialog_dir_selected"] diff --git a/SearchWindow.gd b/SearchWindow.gd new file mode 100644 index 0000000..f19b7bd --- /dev/null +++ b/SearchWindow.gd @@ -0,0 +1,73 @@ +extends Control + +@onready +var search_list := $ScrollContainer/VBoxContainer + +@onready +var clear_button := $ClearButton + +@onready +var close_button := $CloseButton + +@onready +var search_bar := $Searchbar + +var games := [] + +# Called when the node enters the scene tree for the first time. +func _ready(): + get_list_of_games() + clear_button.pressed.connect(clear) + close_button.pressed.connect(close) + search_bar.grab_focus() + search_bar.text_changed.connect(search) + +func close(): + clear() + self.visible = false + +func search(): + print(search_bar.text) + delete_children(search_list) + for game in games: + if search_bar.text == "" || game.replace(" ", "").to_lower().contains(search_bar.text.replace(" ", "").to_lower()): + var label := Label.new() + label.text = game + label.autowrap_mode = TextServer.AUTOWRAP_WORD + search_list.add_child(label) + +static 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("https://music.sanplex.tech/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) + for game in games: + var label := Label.new() + label.text = game + label.autowrap_mode = TextServer.AUTOWRAP_WORD + search_list.add_child(label) + else: + print("Unexpected data") + +func clear(): + search_bar.text = "" + search_bar.grab_focus() diff --git a/SearchWindow.tscn b/SearchWindow.tscn new file mode 100644 index 0000000..3c0dfca --- /dev/null +++ b/SearchWindow.tscn @@ -0,0 +1,55 @@ +[gd_scene load_steps=2 format=3 uid="uid://bxydgil1yifps"] + +[ext_resource type="Script" path="res://SearchWindow.gd" id="1_m7bij"] + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_m7bij") + +[node name="Panel" type="Panel" parent="."] +layout_mode = 0 +offset_right = 1152.0 +offset_bottom = 640.0 + +[node name="ClearButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 880.0 +offset_top = 24.0 +offset_right = 944.0 +offset_bottom = 64.0 +scale = Vector2(2, 2) +text = "Clear" + +[node name="CloseButton" type="Button" parent="."] +layout_mode = 2 +offset_left = 1032.0 +offset_top = 24.0 +offset_right = 1082.0 +offset_bottom = 64.0 +scale = Vector2(2, 2) +text = "Close" + +[node name="Searchbar" type="TextEdit" parent="."] +layout_mode = 0 +offset_left = 64.0 +offset_top = 24.0 +offset_right = 448.0 +offset_bottom = 64.0 +scale = Vector2(2, 2) +placeholder_text = "Search" + +[node name="ScrollContainer" type="ScrollContainer" parent="."] +layout_mode = 2 +offset_top = 128.0 +offset_right = 576.0 +offset_bottom = 384.0 +scale = Vector2(2, 2) + +[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"] +layout_mode = 2 +size_flags_horizontal = 3 From 5b6169ed6c79f62cfed8b96ca90e479fdef1f7f2 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 3 Sep 2023 21:32:30 +0200 Subject: [PATCH 2/6] Changed Play/Pause button. Fixed sync games. Fixed sound test, both local and online. --- MainWindow.gd | 143 +++++++++++++++++++++++++++++++++--------------- MainWindow.tscn | 19 +++++-- Player.gd | 13 +++-- 3 files changed, 122 insertions(+), 53 deletions(-) diff --git a/MainWindow.gd b/MainWindow.gd index 3136ea6..77243f7 100644 --- a/MainWindow.gd +++ b/MainWindow.gd @@ -1,12 +1,10 @@ extends Control ##TODO -# 1. Fix sync # 2. Fix reset buttons # 3. Fix settings # 4. Fix top buttons # 5. Fix player name -# 6. Fix sound test # 7. Fix welcome into the game # 8. Fix match ball sound # 9. Fix winner @@ -16,6 +14,8 @@ extends Control # 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 @@ -38,9 +38,6 @@ var song_label := $VBoxContainer/SongLabel @onready var play_button := $PanelContainer/HBoxContainer/PlayButton -@onready -var pause_button := $PanelContainer/HBoxContainer/PauseButton - @onready var stop_button := $PanelContainer/HBoxContainer/StopButton @@ -56,6 +53,15 @@ var label := $PanelContainer/HBoxContainer/Label @onready var add_player := $Players/VBoxContainer/HBoxContainer/AddPlayer +@onready +var sound_test_button := $SoundTestButton + +@onready +var sync_button := $SyncButton + +@onready +var sync_popup := $PopupPanel + @onready var show_answer_button := $ShowAnswerButton @@ -85,6 +91,61 @@ 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' +# 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) + stop_button.pressed.connect(stop) + show_answer_button.pressed.connect(show_answer) + search_button.pressed.connect(show_search) + sync_button.pressed.connect(sync_games) + sound_test_button.pressed.connect(get_sound_test_song) + + progress.drag_started.connect(_on_drag_started) + progress.drag_ended.connect(_on_drag_ended) + character_select.connect("character_selected", _on_character_selected) + + add_player.pressed.connect(add_players) + + open_button.pressed.connect(open) + get_suggestion_list() + +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("https://music.sanplex.tech/music/first", play_sound_test_song) + +func sound_test_local(): + path = "res://01. Opening.mp3" + audio.stream = load_mp3(path) + audio.play() + stream = audio.stream + progress.max_value = round(stream.get_length()) + progress.tick_count = round(stream.get_length() / 60) + +func sync_games(): + var http_request = HTTPRequest.new() + add_child(http_request) + http_request.request_completed.connect(games_synced) + + # Perform a GET request. The URL below returns JSON as of writing. + var error = http_request.request("https://music.sanplex.tech/sync") + if error != OK: + push_error("An error occurred in the HTTP request.") + +func games_synced(result, response_code, headers, body): + if response_code == 200: + sync_popup.visible = true + func get_suggestion_list() -> void: var http_request = HTTPRequest.new() add_child(http_request) @@ -99,23 +160,6 @@ func add_players(): var new_player := Player.instantiate() players.add_child(new_player) new_player.connect("change_character_clicked", _on_player_change_character_clicked.bind(new_player)) - -# Called when the node enters the scene tree for the first time. -func _ready(): - next_button.pressed.connect(fetch_first_song) - pause_button.pressed.connect(pause) - stop_button.pressed.connect(stop) - show_answer_button.pressed.connect(show_answer) - search_button.pressed.connect(show_search) - - progress.drag_started.connect(_on_drag_started) - progress.drag_ended.connect(_on_drag_ended) - character_select.connect("character_selected", _on_character_selected) - - add_player.pressed.connect(add_players) - - open_button.pressed.connect(open) - get_suggestion_list() func show_search(): if search_view.visible == false: @@ -288,7 +332,7 @@ func format_text(part: float, total: float) -> String: return format_time(part) + " / " + format_time(total) -func fetch_first_song() -> void: +func fetch_next_song() -> void: var http_request = HTTPRequest.new() add_child(http_request) #http.set_download_file("https://music.sanplex.tech/music/first") @@ -308,43 +352,54 @@ func first_song_fetched(result, response_code, headers, body) -> void: var sound = AudioStreamMP3.new() sound.data = body make_request("https://music.sanplex.tech/music/addQue", add_que) - play(sound) + print("play given song") + audio.stream = sound + audio.play() + stream = audio.stream + progress.max_value = round(stream.get_length()) + progress.tick_count = round(stream.get_length() / 60) func add_que(result, response_code, headers, body) -> void: print("response_code", response_code) fetched() -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: - #print(songs) - path = songs[0] +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 pause() -> void: - audio.stream_paused = true - playback_position = audio.get_playback_position() + progress.max_value = round(stream.get_length()) + progress.tick_count = round(stream.get_length() / 60) + +var is_paused: bool = true +func play_or_pause(): + if is_paused: + is_paused = false + play_button.text = "Pause" + if audio.stream_paused: + 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: + fetch_next_song() + else: + audio.stream_paused = true + playback_position = audio.get_playback_position() + is_paused = true + play_button.text = "Play" func stop() -> void: audio.stop() audio.stream_paused = false progress.value = 0 + is_paused = true + play_button.text = "Play" func _on_drag_started() -> void: is_changing = true diff --git a/MainWindow.tscn b/MainWindow.tscn index e4c2784..426b260 100644 --- a/MainWindow.tscn +++ b/MainWindow.tscn @@ -126,10 +126,6 @@ size_flags_vertical = 4 layout_mode = 2 text = "Play" -[node name="PauseButton" type="Button" parent="PanelContainer/HBoxContainer"] -layout_mode = 2 -text = "Pause" - [node name="StopButton" type="Button" parent="PanelContainer/HBoxContainer"] layout_mode = 2 text = "Stop" @@ -193,7 +189,7 @@ offset_right = 358.0 offset_bottom = 1049.0 text = "Reset points" -[node name="SuncButton" type="Button" parent="."] +[node name="SyncButton" type="Button" parent="."] layout_mode = 0 offset_left = 370.0 offset_top = 1016.0 @@ -282,4 +278,17 @@ offset_top = 81.2367 offset_right = 349.196 offset_bottom = 81.2367 +[node name="PopupPanel" type="PopupPanel" parent="."] +initial_position = 2 +size = Vector2i(140, 70) + +[node name="Label" type="Label" parent="PopupPanel"] +offset_left = 4.0 +offset_top = 4.0 +offset_right = 136.0 +offset_bottom = 66.0 +text = "Games synced!" +horizontal_alignment = 1 +vertical_alignment = 1 + [connection signal="dir_selected" from="FileDialog" to="." method="_on_file_dialog_dir_selected"] diff --git a/Player.gd b/Player.gd index 4b9c087..613d5d6 100644 --- a/Player.gd +++ b/Player.gd @@ -1,5 +1,8 @@ extends Control +@onready +var player_name := $HBoxContainer/Name + @onready var points := $HBoxContainer/Points @@ -21,6 +24,12 @@ func _ready(): add.pressed.connect(add_point) minus.pressed.connect(minus_point) character.pressed.connect(change_character) + player_name.mouse_filter = Control.MOUSE_FILTER_PASS + player_name.gui_input.connect(name_clicked) + +func name_clicked(event): + if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT): + print("Clicked: " + player_name.text) func add_point(): var value := int(points.text) @@ -34,10 +43,6 @@ func change_character(): print("change_character") change_character_clicked.emit() -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - func _on_control_character_selected_clicked(file_name: String): print("Back in player list with: " + file_name) From 050d19039c99332a0b518548120f6730991dd681 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 7 Sep 2023 21:55:31 +0200 Subject: [PATCH 3/6] Fixed add player process where name can be set. Added signals for points. Added settings file. Changed some shortcuts. --- MainWindow.gd | 39 ++++++++++++++++++++++++++------------- MainWindow.tscn | 41 ++++++++++++++++++++++++++++++++++++++--- Player.gd | 40 +++++++++++++++++++++++++++++----------- PlayerNameField.gd | 12 ++++++++++++ SearchWindow.gd | 3 ++- Settings.gd | 23 +++++++++++++++++++++++ project.godot | 4 ++++ 7 files changed, 134 insertions(+), 28 deletions(-) create mode 100644 PlayerNameField.gd create mode 100644 Settings.gd diff --git a/MainWindow.gd b/MainWindow.gd index 77243f7..558375b 100644 --- a/MainWindow.gd +++ b/MainWindow.gd @@ -4,13 +4,11 @@ extends Control # 2. Fix reset buttons # 3. Fix settings # 4. Fix top buttons -# 5. Fix player name # 7. Fix welcome into the game # 8. Fix match ball sound # 9. Fix winner # 10. Fix jump between songs # 11. Refactor components -# 12. Change add player # 13. Fix graphics in lists # 14. Fix layout # 15. Fix for local play @@ -51,7 +49,16 @@ var progress := $PanelContainer/HBoxContainer/HSlider var label := $PanelContainer/HBoxContainer/Label @onready -var add_player := $Players/VBoxContainer/HBoxContainer/AddPlayer +var add_player_container := $Players/VBoxContainer/AddPlayerContainer + +@onready +var add_players_button := $Players/VBoxContainer/HBoxContainer/AddPlayersButton + +@onready +var add_player_button := $Players/VBoxContainer/AddPlayerContainer/AddPlayerButton + +@onready +var new_player_name_field := $Players/VBoxContainer/AddPlayerContainer/PlayerNameField @onready var sound_test_button := $SoundTestButton @@ -104,8 +111,9 @@ func _ready(): progress.drag_started.connect(_on_drag_started) progress.drag_ended.connect(_on_drag_ended) character_select.connect("character_selected", _on_character_selected) - - add_player.pressed.connect(add_players) + new_player_name_field.connect("enter_key_pressed", add_player) + add_players_button.pressed.connect(add_players) + add_player_button.pressed.connect(add_player) open_button.pressed.connect(open) get_suggestion_list() @@ -122,7 +130,7 @@ func get_sound_test_song(): progress.max_value = round(stream.get_length()) progress.tick_count = round(stream.get_length() / 60) - make_request("https://music.sanplex.tech/music/first", play_sound_test_song) + make_request(Settings.default_path + "/music/first", play_sound_test_song) func sound_test_local(): path = "res://01. Opening.mp3" @@ -138,7 +146,7 @@ func sync_games(): http_request.request_completed.connect(games_synced) # Perform a GET request. The URL below returns JSON as of writing. - var error = http_request.request("https://music.sanplex.tech/sync") + var error = http_request.request(Settings.default_path + "/sync") if error != OK: push_error("An error occurred in the HTTP request.") @@ -152,12 +160,18 @@ func get_suggestion_list() -> void: http_request.request_completed.connect(_http_request_completed) # Perform a GET request. The URL below returns JSON as of writing. - var error = http_request.request("https://music.sanplex.tech/music/all") + var error = http_request.request(Settings.default_path + "/music/all") if error != OK: push_error("An error occurred in the HTTP request.") func add_players(): + 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) + new_player_name_field.text = "" players.add_child(new_player) new_player.connect("change_character_clicked", _on_player_change_character_clicked.bind(new_player)) @@ -173,7 +187,7 @@ func show_answer(): http_request.request_completed.connect(show_fetched) # Perform a GET request. The URL below returns JSON as of writing. - var error = http_request.request("https://music.sanplex.tech/music/info") + var error = http_request.request(Settings.default_path + "/music/info") if error != OK: push_error("An error occurred in the HTTP request.") @@ -183,7 +197,7 @@ func fetched(): 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("https://music.sanplex.tech/music/list") + var error2 = http_request2.request(Settings.default_path + "/music/list") if error2 != OK: push_error("An error occurred in the HTTP request.") @@ -335,11 +349,10 @@ func format_text(part: float, total: float) -> String: func fetch_next_song() -> void: var http_request = HTTPRequest.new() add_child(http_request) - #http.set_download_file("https://music.sanplex.tech/music/first") http_request.request_completed.connect(first_song_fetched) # Perform a GET request. The URL below returns JSON as of writing. - var error = http_request.request("https://music.sanplex.tech/music/rand") + var error = http_request.request(Settings.default_path + "/music/rand") if error != OK: push_error("An error occurred in the HTTP request.") @@ -351,7 +364,7 @@ func first_song_fetched(result, response_code, headers, body) -> void: push_error("Song couldn't be downloaded. Try a different song.") var sound = AudioStreamMP3.new() sound.data = body - make_request("https://music.sanplex.tech/music/addQue", add_que) + make_request(Settings.default_path + "/music/addQue", add_que) print("play given song") audio.stream = sound audio.play() diff --git a/MainWindow.tscn b/MainWindow.tscn index 426b260..be47615 100644 --- a/MainWindow.tscn +++ b/MainWindow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://xwq863o6uvsu"] +[gd_scene load_steps=18 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"] @@ -7,6 +7,7 @@ [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="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"] [ext_resource type="PackedScene" uid="uid://bxydgil1yifps" path="res://SearchWindow.tscn" id="9_5ijvr"] @@ -19,9 +20,18 @@ font_size = 50 [sub_resource type="LabelSettings" id="LabelSettings_3m52w"] font_size = 35 +[sub_resource type="InputEventKey" id="InputEventKey_03bm3"] +device = -1 +alt_pressed = true +keycode = 65 +unicode = 63743 + +[sub_resource type="Shortcut" id="Shortcut_jafqj"] +events = [SubResource("InputEventKey_03bm3")] + [sub_resource type="InputEventKey" id="InputEventKey_ujjlu"] device = -1 -command_or_control_autoremap = true +alt_pressed = true keycode = 83 [sub_resource type="Shortcut" id="Shortcut_fbju4"] @@ -168,11 +178,36 @@ size_flags_horizontal = 3 text = "Players" horizontal_alignment = 1 -[node name="AddPlayer" type="TextureButton" parent="Players/VBoxContainer/HBoxContainer"] +[node name="AddPlayersButton" type="TextureButton" parent="Players/VBoxContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 8 +shortcut = SubResource("Shortcut_jafqj") texture_normal = ExtResource("4_op458") +[node name="AddPlayerContainer" type="HBoxContainer" parent="Players/VBoxContainer"] +visible = false +layout_mode = 2 + +[node name="Panel" type="Panel" parent="Players/VBoxContainer/AddPlayerContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 0 + +[node name="PlayerNameField" type="TextEdit" parent="Players/VBoxContainer/AddPlayerContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +placeholder_text = "Player name" +script = ExtResource("7_qsdfy") + +[node name="AddPlayerButton" type="Button" parent="Players/VBoxContainer/AddPlayerContainer"] +layout_mode = 2 +text = "Add" + +[node name="Panel2" type="Panel" parent="Players/VBoxContainer/AddPlayerContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 0 + [node name="ResetPlaylistButton" type="Button" parent="."] layout_mode = 0 offset_left = 125.0 diff --git a/Player.gd b/Player.gd index 613d5d6..7c464cf 100644 --- a/Player.gd +++ b/Player.gd @@ -1,7 +1,7 @@ extends Control @onready -var player_name := $HBoxContainer/Name +var player_name_field := $HBoxContainer/Name @onready var points := $HBoxContainer/Points @@ -16,29 +16,47 @@ var minus := $HBoxContainer/RemovePoint var character := $HBoxContainer/Character signal change_character_clicked +signal first_point_triggerd +signal match_point_triggerd +signal winner_triggerd + +var player_name: String + +var is_first_point: bool = true + # Called when the node enters the scene tree for the first time. func _ready(): - print("_ready") add.pressed.connect(add_point) minus.pressed.connect(minus_point) character.pressed.connect(change_character) - player_name.mouse_filter = Control.MOUSE_FILTER_PASS - player_name.gui_input.connect(name_clicked) + player_name_field.text = player_name -func name_clicked(event): - if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT): - print("Clicked: " + player_name.text) +func new_name(new_name: String): + player_name = new_name func add_point(): - var value := int(points.text) - points.text = str(value + 1) + if is_first_point: + is_first_point = false + first_point_triggerd.emit() + + var new_value := int(points.text) + 1 + points.text = str(new_value) + if new_value == Settings.winning_score - 1: + match_point_triggerd.emit() + + if new_value == Settings.winning_score: + winner_triggerd.emit() + func minus_point(): - var value := int(points.text) - points.text = str(value - 1) + var new_value := int(points.text) - 1 + points.text = str(new_value) + if new_value == 0: + is_first_point = true + func change_character(): print("change_character") change_character_clicked.emit() diff --git a/PlayerNameField.gd b/PlayerNameField.gd new file mode 100644 index 0000000..fd2c69d --- /dev/null +++ b/PlayerNameField.gd @@ -0,0 +1,12 @@ +extends TextEdit + +signal enter_key_pressed +signal close_pressed + +func _input(event): + if event is InputEventKey and event.pressed: + if event.alt_pressed && event.keycode == KEY_A: + close_pressed.emit() + + if event.keycode == KEY_ENTER: + enter_key_pressed.emit() diff --git a/SearchWindow.gd b/SearchWindow.gd index f19b7bd..879b056 100644 --- a/SearchWindow.gd +++ b/SearchWindow.gd @@ -21,6 +21,7 @@ func _ready(): close_button.pressed.connect(close) search_bar.grab_focus() search_bar.text_changed.connect(search) + visibility_changed.connect(func(): search_bar.grab_focus()) func close(): clear() @@ -47,7 +48,7 @@ func get_list_of_games() -> void: 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("https://music.sanplex.tech/music/all/order") + var error = http_request.request(Settings.default_path + "/music/all/order") if error != OK: push_error("An error occurred in the HTTP request.") diff --git a/Settings.gd b/Settings.gd new file mode 100644 index 0000000..843cf5d --- /dev/null +++ b/Settings.gd @@ -0,0 +1,23 @@ +extends Node + +var default_path: String = "http://192.168.86.100:8085" +#var default_path: String = "https://music.sanplex.tech" + +var is_local: bool = false + +var stop_after_current: bool = false +var hide_next_track: bool = false +var add_to_stats: bool = false +var use_low_played_mode: bool = false +var winning_score: int = 20 + + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass diff --git a/project.godot b/project.godot index 30655be..23f1018 100644 --- a/project.godot +++ b/project.godot @@ -16,6 +16,10 @@ config/features=PackedStringArray("4.1", "Forward Plus") run/low_processor_mode=true config/icon="res://icon.svg" +[autoload] + +Settings="*res://Settings.gd" + [display] window/size/viewport_width=1920 From c9ea40215d8d364542a1505cc05ce40472369408 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 8 Sep 2023 22:14:54 +0200 Subject: [PATCH 4/6] Fixed sounds effects with points. Fixed buttons statistics and about --- MainWindow.gd | 51 ++++++++++++++++++++++++++++++++++++++++++++++--- MainWindow.tscn | 43 +++++++++++++++++++++++++++++++++++++++++ SearchWindow.gd | 6 +++++- Settings.gd | 9 +++++++-- 4 files changed, 103 insertions(+), 6 deletions(-) diff --git a/MainWindow.gd b/MainWindow.gd index 558375b..331e2d4 100644 --- a/MainWindow.gd +++ b/MainWindow.gd @@ -3,9 +3,6 @@ extends Control ##TODO # 2. Fix reset buttons # 3. Fix settings -# 4. Fix top buttons -# 7. Fix welcome into the game -# 8. Fix match ball sound # 9. Fix winner # 10. Fix jump between songs # 11. Refactor components @@ -69,6 +66,21 @@ var sync_button := $SyncButton @onready var sync_popup := $PopupPanel +@onready +var statistics_button := $StatisticsButton + +@onready +var statistic_popup := $StatisticsPopupPanel + +@onready +var statistic_label := $StatisticsPopupPanel/StatisticsLabel + +@onready +var about_button := $AboutButton + +@onready +var about_popup := $AboutPopupPanel + @onready var show_answer_button := $ShowAnswerButton @@ -107,6 +119,8 @@ func _ready(): search_button.pressed.connect(show_search) sync_button.pressed.connect(sync_games) sound_test_button.pressed.connect(get_sound_test_song) + statistics_button.pressed.connect(get_statistics) + about_button.pressed.connect(show_about) progress.drag_started.connect(_on_drag_started) progress.drag_ended.connect(_on_drag_ended) @@ -118,6 +132,13 @@ func _ready(): open_button.pressed.connect(open) get_suggestion_list() +func show_about(): + about_popup.visible = true + +func get_statistics(): + 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: @@ -174,6 +195,30 @@ func add_player(): 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")) + +func _on_point_triggerd(point: String): + var song_path: String + if point == "first": + var value = randi_range(0, 10) + if value == 0: + song_path = "res://sounds/sound1.mp3" + elif value < 5: + song_path = "res://sounds/intro_long.mp3" + else: + song_path = "res://sounds/intro_short.mp3" + elif point == "match": + song_path = "res://sounds/sound0.mp3" + elif point == "winner": + song_path = "res://sounds/winning.mp3" + + audio.stream = load_mp3(song_path) + audio.play() + stream = audio.stream + progress.max_value = round(stream.get_length()) + progress.tick_count = round(stream.get_length() / 60) func show_search(): if search_view.visible == false: diff --git a/MainWindow.tscn b/MainWindow.tscn index be47615..c99bc0a 100644 --- a/MainWindow.tscn +++ b/MainWindow.tscn @@ -326,4 +326,47 @@ text = "Games synced!" horizontal_alignment = 1 vertical_alignment = 1 +[node name="StatisticsPopupPanel" type="PopupPanel" parent="."] +initial_position = 2 +size = Vector2i(450, 100) + +[node name="Label" type="Label" parent="StatisticsPopupPanel"] +offset_left = 4.0 +offset_top = 4.0 +offset_right = 446.0 +offset_bottom = 96.0 +text = "Statistics" +horizontal_alignment = 1 + +[node name="StatisticsLabel" type="Label" parent="StatisticsPopupPanel"] +offset_left = 4.0 +offset_top = 4.0 +offset_right = 446.0 +offset_bottom = 96.0 +text = "Total amount of games in the playlist: 9000" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="AboutPopupPanel" type="PopupPanel" parent="."] +initial_position = 2 +size = Vector2i(450, 100) + +[node name="Label" type="Label" parent="AboutPopupPanel"] +offset_left = 4.0 +offset_top = 4.0 +offset_right = 446.0 +offset_bottom = 96.0 +text = "Music Player Randomizer v0.6" +horizontal_alignment = 1 + +[node name="AboutLabel" type="Label" parent="AboutPopupPanel"] +offset_left = 4.0 +offset_top = 4.0 +offset_right = 446.0 +offset_bottom = 96.0 +text = "Try your video game music knowledge with this VGM randomizer, invite your friends and see who is the best." +horizontal_alignment = 1 +vertical_alignment = 1 +autowrap_mode = 2 + [connection signal="dir_selected" from="FileDialog" to="." method="_on_file_dialog_dir_selected"] diff --git a/SearchWindow.gd b/SearchWindow.gd index 879b056..ee1138c 100644 --- a/SearchWindow.gd +++ b/SearchWindow.gd @@ -21,7 +21,11 @@ func _ready(): close_button.pressed.connect(close) search_bar.grab_focus() search_bar.text_changed.connect(search) - visibility_changed.connect(func(): search_bar.grab_focus()) + visibility_changed.connect(focus) + +func focus(): + if self.visible == true: + search_bar.grab_focus() func close(): clear() diff --git a/Settings.gd b/Settings.gd index 843cf5d..4e954f8 100644 --- a/Settings.gd +++ b/Settings.gd @@ -1,7 +1,7 @@ extends Node -var default_path: String = "http://192.168.86.100:8085" -#var default_path: String = "https://music.sanplex.tech" +#var default_path: String = "http://192.168.86.100:8085" +var default_path: String = "https://music.sanplex.tech" var is_local: bool = false @@ -12,6 +12,11 @@ var use_low_played_mode: bool = false var winning_score: int = 20 +#play = X +#nästa = c +#visa svar = v +#lägga till poäng? 1, 2, 3, 4, 5, 6 + # Called when the node enters the scene tree for the first time. func _ready(): From 724455b2322ca279e2886c030c6943c6634565a7 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 10 Sep 2023 22:37:57 +0200 Subject: [PATCH 5/6] Added hopping between songs. Added settings menu, not finished. --- .gitignore | 3 + MainWindow.gd | 169 +++++++++++++++++++++++++++++++++++++------- MainWindow.tscn | 82 ++++++++++++++------- Settings.gd | 16 ++++- SettingsWindow.gd | 65 +++++++++++++++++ SettingsWindow.tscn | 80 +++++++++++++++++++++ export_presets.cfg | 88 ++++++----------------- 7 files changed, 386 insertions(+), 117 deletions(-) create mode 100644 SettingsWindow.gd create mode 100644 SettingsWindow.tscn diff --git a/.gitignore b/.gitignore index 4709183..e6e57d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # Godot 4+ specific ignores .godot/ +/web/ +*.exe +*.dmg \ No newline at end of file diff --git a/MainWindow.gd b/MainWindow.gd index 331e2d4..dfcb15c 100644 --- a/MainWindow.gd +++ b/MainWindow.gd @@ -4,13 +4,13 @@ extends Control # 2. Fix reset buttons # 3. Fix settings # 9. Fix winner -# 10. Fix jump between songs # 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 +# 18. Fix shortcuts @onready var open_button := $Open @@ -34,7 +34,7 @@ var song_label := $VBoxContainer/SongLabel var play_button := $PanelContainer/HBoxContainer/PlayButton @onready -var stop_button := $PanelContainer/HBoxContainer/StopButton +var restart_button := $PanelContainer/HBoxContainer/RestartButton @onready var audio := $AudioStreamPlayer @@ -64,7 +64,13 @@ var sound_test_button := $SoundTestButton var sync_button := $SyncButton @onready -var sync_popup := $PopupPanel +var sync_popup := $SyncPopupPanel + +@onready +var settings_button := $SettingsButton + +@onready +var settings_popup := $SettingsPopupPanel @onready var statistics_button := $StatisticsButton @@ -105,6 +111,15 @@ var search_button := $SearchButton @onready var search_view := $Search +@onready +var version_label := $AboutPopupPanel/VBoxContainer/VersionLabel + +@onready +var new_label := $AboutPopupPanel/VBoxContainer/HBoxContainer/NewLabel + +@onready +var comming_label := $AboutPopupPanel/VBoxContainer/HBoxContainer/CommingLabel + var Player := preload("res://Player.tscn") @onready @@ -114,13 +129,14 @@ var path = '/Users/sebastian/ResilioSync/Sorterat_test/Metal Gear Solid 4 - Guns func _ready(): next_button.pressed.connect(fetch_next_song) play_button.pressed.connect(play_or_pause) - stop_button.pressed.connect(stop) + restart_button.pressed.connect(restart) show_answer_button.pressed.connect(show_answer) search_button.pressed.connect(show_search) sync_button.pressed.connect(sync_games) sound_test_button.pressed.connect(get_sound_test_song) statistics_button.pressed.connect(get_statistics) about_button.pressed.connect(show_about) + settings_button.pressed.connect(show_settings) progress.drag_started.connect(_on_drag_started) progress.drag_ended.connect(_on_drag_ended) @@ -131,9 +147,16 @@ func _ready(): open_button.pressed.connect(open) get_suggestion_list() + fetch_full_music_list_at_start() func show_about(): about_popup.visible = true + version_label.text = Settings.version + new_label.text = Settings.whats_new + comming_label.text = Settings.whats_left + +func show_settings(): + settings_popup.visible = true func get_statistics(): statistic_popup.visible = true @@ -235,7 +258,80 @@ func show_answer(): var error = http_request.request(Settings.default_path + "/music/info") if error != OK: push_error("An error occurred in the HTTP request.") + +func fetch_full_music_list_at_start(): + var show_fetched_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) + 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) + else: + print("Unexpected data") + make_request(Settings.default_path + "/music/list", show_fetched_list) + +func fetch_full_music_list(event, song_no: int): + if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT): + var show_fetched_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_fetched_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) + + func fetched(): var http_request2 = HTTPRequest.new() add_child(http_request2) @@ -279,21 +375,50 @@ func show_fetched_list(result, response_code, headers, body) -> void: 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)) + label.gui_input.connect(song_clicked.bind(label, song.SongNo)) music_list.add_child(label) - + + var songs := music_list.get_children() + for song 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)) next_label.text = "??? - ???" next_label.mouse_filter = Control.MOUSE_FILTER_PASS - next_label.gui_input.connect(show_fetched) + next_label.gui_input.connect(fetch_full_music_list.bind(songs.size())) music_list.add_child(next_label) else: print("Unexpected data") -func song_clicked(event, song_no): +func song_clicked(event, label: Label, song_no: int): if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT): - print("Clicked: " + str(song_no)) + print("Song Clicked: " + str(song_no)) + var songs := music_list.get_children() + for song 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) # Called when the HTTP request is completed. func _http_request_completed(result, response_code, headers, body): @@ -433,31 +558,27 @@ func play_local_song(song) -> void: progress.max_value = round(stream.get_length()) progress.tick_count = round(stream.get_length() / 60) -var is_paused: bool = true func play_or_pause(): - if is_paused: - is_paused = false + if audio.stream_paused: play_button.text = "Pause" - if audio.stream_paused: - 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: - fetch_next_song() + 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() - is_paused = true play_button.text = "Play" -func stop() -> void: +func restart() -> void: audio.stop() audio.stream_paused = false progress.value = 0 - is_paused = true - play_button.text = "Play" + playback_position = audio.get_playback_position() + audio.seek(playback_position) + play_button.text = "Pause" + audio.play() func _on_drag_started() -> void: is_changing = true diff --git a/MainWindow.tscn b/MainWindow.tscn index c99bc0a..33d3c9e 100644 --- a/MainWindow.tscn +++ b/MainWindow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=3 uid="uid://xwq863o6uvsu"] +[gd_scene load_steps=19 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"] @@ -10,6 +10,7 @@ [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"] [ext_resource type="PackedScene" uid="uid://bxydgil1yifps" path="res://SearchWindow.tscn" id="9_5ijvr"] +[ext_resource type="PackedScene" uid="uid://dldpeo5y3l5hq" path="res://SettingsWindow.tscn" id="11_k62u5"] [sub_resource type="LabelSettings" id="LabelSettings_ychxr"] font_size = 25 @@ -81,6 +82,7 @@ offset_top = 95.0 offset_right = 1845.0 offset_bottom = 465.0 horizontal_scroll_mode = 0 +vertical_scroll_mode = 3 script = ExtResource("2_gxtxm") [node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"] @@ -88,15 +90,6 @@ layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="Label" type="Label" parent="ScrollContainer/VBoxContainer"] -layout_mode = 2 -text = "Test -" - -[node name="Label2" type="Label" parent="ScrollContainer/VBoxContainer"] -layout_mode = 2 -text = "Test2" - [node name="VBoxContainer" type="VBoxContainer" parent="."] layout_mode = 0 offset_left = 52.0 @@ -106,14 +99,12 @@ offset_bottom = 368.0 [node name="GameLabel" type="Label" parent="VBoxContainer"] layout_mode = 2 -text = "????????" label_settings = SubResource("LabelSettings_qspbu") horizontal_alignment = 1 autowrap_mode = 2 [node name="SongLabel" type="Label" parent="VBoxContainer"] layout_mode = 2 -text = "??????" label_settings = SubResource("LabelSettings_3m52w") horizontal_alignment = 1 autowrap_mode = 2 @@ -136,9 +127,9 @@ size_flags_vertical = 4 layout_mode = 2 text = "Play" -[node name="StopButton" type="Button" parent="PanelContainer/HBoxContainer"] +[node name="RestartButton" type="Button" parent="PanelContainer/HBoxContainer"] layout_mode = 2 -text = "Stop" +text = "Restart" [node name="HSlider" type="HSlider" parent="PanelContainer/HBoxContainer"] layout_mode = 2 @@ -313,11 +304,11 @@ offset_top = 81.2367 offset_right = 349.196 offset_bottom = 81.2367 -[node name="PopupPanel" type="PopupPanel" parent="."] +[node name="SyncPopupPanel" type="PopupPanel" parent="."] initial_position = 2 size = Vector2i(140, 70) -[node name="Label" type="Label" parent="PopupPanel"] +[node name="Label" type="Label" parent="SyncPopupPanel"] offset_left = 4.0 offset_top = 4.0 offset_right = 136.0 @@ -349,24 +340,61 @@ vertical_alignment = 1 [node name="AboutPopupPanel" type="PopupPanel" parent="."] initial_position = 2 -size = Vector2i(450, 100) +size = Vector2i(848, 272) -[node name="Label" type="Label" parent="AboutPopupPanel"] +[node name="VBoxContainer" type="VBoxContainer" parent="AboutPopupPanel"] offset_left = 4.0 offset_top = 4.0 -offset_right = 446.0 -offset_bottom = 96.0 -text = "Music Player Randomizer v0.6" +offset_right = 844.0 +offset_bottom = 268.0 + +[node name="Label" type="Label" parent="AboutPopupPanel/VBoxContainer"] +layout_mode = 2 +text = "Music Player Randomizer" horizontal_alignment = 1 -[node name="AboutLabel" type="Label" parent="AboutPopupPanel"] -offset_left = 4.0 -offset_top = 4.0 -offset_right = 446.0 -offset_bottom = 96.0 +[node name="VersionLabel" type="Label" parent="AboutPopupPanel/VBoxContainer"] +layout_mode = 2 +horizontal_alignment = 1 + +[node name="AboutLabel" type="Label" parent="AboutPopupPanel/VBoxContainer"] +layout_mode = 2 text = "Try your video game music knowledge with this VGM randomizer, invite your friends and see who is the best." horizontal_alignment = 1 -vertical_alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="AboutPopupPanel/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="NewLabel" type="Label" parent="AboutPopupPanel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 0 +text = "0.7-Beta: Can now hop between songs" autowrap_mode = 2 +[node name="CommingLabel" type="Label" parent="AboutPopupPanel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 0 +text = "Fix reset buttons +Fix settings +Fix winner +Fix graphics in lists +Fix layout +Fix for local play +Change some buttons to icons +Add shortcuts" +autowrap_mode = 2 + +[node name="SettingsPopupPanel" type="PopupPanel" parent="."] +initial_position = 2 +size = Vector2i(268, 233) + +[node name="VBoxContainer" parent="SettingsPopupPanel" instance=ExtResource("11_k62u5")] +offset_left = 4.0 +offset_top = 4.0 +offset_right = -4.0 +offset_bottom = 19.0 + [connection signal="dir_selected" from="FileDialog" to="." method="_on_file_dialog_dir_selected"] diff --git a/Settings.gd b/Settings.gd index 4e954f8..aeaff1e 100644 --- a/Settings.gd +++ b/Settings.gd @@ -1,7 +1,9 @@ extends Node #var default_path: String = "http://192.168.86.100:8085" -var default_path: String = "https://music.sanplex.tech" +#var default_path: String = "https://music.sanplex.tech" +var default_path: String = "https://tmusic.sanplex.tech" +var selected_server = 0 var is_local: bool = false @@ -11,6 +13,18 @@ var add_to_stats: bool = false var use_low_played_mode: bool = false var winning_score: int = 20 +var version: String = "0.7.5-Beta" +var whats_new: String = "0.7.5-Beta: Added settings menu, most things don't do anythig yet +0.7-Beta: Can now hop between songs" +var whats_left: String = "Fix reset buttons +Fix settings +Fix winner +Fix graphics in lists +Fix layout +Fix for local play +Change some buttons to icons +Add shortcuts" + #play = X #nästa = c diff --git a/SettingsWindow.gd b/SettingsWindow.gd new file mode 100644 index 0000000..cfa486a --- /dev/null +++ b/SettingsWindow.gd @@ -0,0 +1,65 @@ +extends VBoxContainer + +@onready +var stop_after_current_button := $StopAfterCurrentCheckButton + +@onready +var hide_next_track_button := $HideNextTrackCheckButton + +@onready +var add_to_database_button := $AddToDatabaseCheckButton + +@onready +var low_played_button := $LowPlayedCheckButton + +@onready +var score_label := $HBoxContainer/ScoreLabel + +@onready +var lower_winning_score_button := $HBoxContainer/LowerButton + +@onready +var increase_winning_score_button := $HBoxContainer/IncreaseButton + +@onready +var select_server_button := $SelectServerButton + +# Called when the node enters the scene tree for the first time. +func _ready(): + stop_after_current_button.pressed.connect(stop_after_current) + hide_next_track_button.pressed.connect(hide_next_track) + add_to_database_button.pressed.connect(add_to_database) + low_played_button.pressed.connect(low_played) + lower_winning_score_button.pressed.connect(lower_winning_score) + increase_winning_score_button.pressed.connect(increase_winning_score) + select_server_button.pressed.connect(select_server) + + stop_after_current_button.button_pressed = Settings.stop_after_current + hide_next_track_button.button_pressed = Settings.hide_next_track + add_to_database_button.button_pressed = Settings.add_to_stats + low_played_button.button_pressed = Settings.use_low_played_mode + select_server_button.select(Settings.selected_server) + +func stop_after_current(): + Settings.stop_after_current = !Settings.stop_after_current + +func hide_next_track(): + Settings.hide_next_track = !Settings.hide_next_track + +func add_to_database(): + Settings.add_to_stats = !Settings.add_to_stats + +func low_played(): + Settings.use_low_played_mode = !Settings.use_low_played_mode + +func lower_winning_score(): + Settings.winning_score -= 1 + score_label.text = str(Settings.winning_score) + +func increase_winning_score(): + Settings.winning_score += 1 + score_label.text = str(Settings.winning_score) + +func select_server() -> void: + Settings.default_path = select_server_button.get_item_text(select_server_button.selected) + Settings.selected_server = select_server_button.selected diff --git a/SettingsWindow.tscn b/SettingsWindow.tscn new file mode 100644 index 0000000..51f7a5d --- /dev/null +++ b/SettingsWindow.tscn @@ -0,0 +1,80 @@ +[gd_scene load_steps=3 format=3 uid="uid://dldpeo5y3l5hq"] + +[ext_resource type="Script" path="res://SettingsWindow.gd" id="1_bt55j"] + +[sub_resource type="LabelSettings" id="LabelSettings_3xrlm"] +font_size = 25 + +[node name="VBoxContainer" type="VBoxContainer"] +clip_contents = true +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = ExtResource("1_bt55j") + +[node name="Label" type="Label" parent="."] +layout_mode = 2 +size_flags_vertical = 0 +text = "Settings" +label_settings = SubResource("LabelSettings_3xrlm") +horizontal_alignment = 1 + +[node name="StopAfterCurrentCheckButton" type="CheckButton" parent="."] +layout_mode = 2 +size_flags_horizontal = 0 +action_mode = 0 +text = "Stop after current" + +[node name="HideNextTrackCheckButton" type="CheckButton" parent="."] +layout_mode = 2 +size_flags_horizontal = 0 +action_mode = 0 +text = "Hide next track" + +[node name="AddToDatabaseCheckButton" type="CheckButton" parent="."] +layout_mode = 2 +size_flags_horizontal = 0 +action_mode = 0 +text = "Turn on played to database" + +[node name="LowPlayedCheckButton" type="CheckButton" parent="."] +layout_mode = 2 +size_flags_horizontal = 0 +action_mode = 0 +text = "Use low played mode" + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="Label2" type="Label" parent="HBoxContainer"] +layout_mode = 2 +text = "Winning Score: " + +[node name="ScoreLabel" type="Label" parent="HBoxContainer"] +layout_mode = 2 +text = "20" + +[node name="LowerButton" type="Button" parent="HBoxContainer"] +custom_minimum_size = Vector2(30, 2.08165e-12) +layout_mode = 2 +text = "-1" + +[node name="IncreaseButton" type="Button" parent="HBoxContainer"] +custom_minimum_size = Vector2(30, 2.08165e-12) +layout_mode = 2 +text = "+1" + +[node name="SelectServerButton" type="OptionButton" parent="."] +layout_mode = 2 +item_count = 3 +selected = 0 +popup/item_0/text = "https://tmusic.sanplex.tech" +popup/item_0/id = 0 +popup/item_1/text = "https://music.sanplex.tech" +popup/item_1/id = 1 +popup/item_2/text = "http://192.168.86.100:8085" +popup/item_2/id = 2 diff --git a/export_presets.cfg b/export_presets.cfg index 89dcd54..3155ad7 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -8,28 +8,24 @@ custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="" +export_path="./MusicPlayer_0.7.5_Beta.exe" encryption_include_filters="" encryption_exclude_filters="" encrypt_pck=false encrypt_directory=false -script_encryption_key="" [preset.0.options] custom_template/debug="" custom_template/release="" -debug/export_console_script=1 -binary_format/embed_pck=false +debug/export_console_wrapper=1 +binary_format/embed_pck=true texture_format/bptc=true texture_format/s3tc=true texture_format/etc=false texture_format/etc2=false binary_format/architecture="x86_64" codesign/enable=false -codesign/identity_type=0 -codesign/identity="" -codesign/password="" codesign/timestamp=true codesign/timestamp_server_url="" codesign/digest_algorithm=1 @@ -63,6 +59,7 @@ Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorActi ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue Remove-Item -Recurse -Force '{temp_dir}'" +debug/export_console_script=1 [preset.1] @@ -74,33 +71,40 @@ custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="" +export_path="./MusicPlayer_0.6_Beta.dmg" encryption_include_filters="" encryption_exclude_filters="" encrypt_pck=false encrypt_directory=false -script_encryption_key="" [preset.1.options] +export/distribution_type=1 binary_format/architecture="universal" custom_template/debug="" custom_template/release="" -debug/export_console_script=1 +debug/export_console_wrapper=0 application/icon="" application/icon_interpolation=4 -application/bundle_identifier="" +application/bundle_identifier="tech.sanplex.musicplayer" application/signature="" -application/app_category="Games" +application/app_category="Music-games" application/short_version="1.0" application/version="1.0" application/copyright="" application/copyright_localized={} +application/min_macos_version="10.12" display/high_res=true +xcode/platform_build="14C18" +xcode/sdk_version="13.1" +xcode/sdk_build="22C55" +xcode/sdk_name="macosx13.1" +xcode/xcode_version="1420" +xcode/xcode_build="14C18" codesign/codesign=3 +codesign/installer_identity="" +codesign/apple_team_id="" codesign/identity="" -codesign/certificate_file="" -codesign/certificate_password="" codesign/entitlements/custom_file="" codesign/entitlements/allow_jit_code_execution=false codesign/entitlements/allow_unsigned_executable_memory=false @@ -126,12 +130,6 @@ codesign/entitlements/app_sandbox/files_movies=0 codesign/entitlements/app_sandbox/helper_executables=[] codesign/custom_options=PackedStringArray() notarization/notarization=0 -notarization/apple_id_name="" -notarization/apple_id_password="" -notarization/apple_team_id="" -notarization/api_uuid="" -notarization/api_key="" -notarization/api_key_id="" privacy/microphone_usage_description="" privacy/microphone_usage_description_localized={} privacy/camera_usage_description="" @@ -165,66 +163,26 @@ open \"{temp_dir}/{exe_name}.app\" --args {cmd_args}" ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash kill $(pgrep -x -f \"{temp_dir}/{exe_name}.app/Contents/MacOS/{exe_name} {cmd_args}\") rm -rf \"{temp_dir}\"" +debug/export_console_script=1 +notarization/apple_team_id="" [preset.2] -name="Linux/X11" -platform="Linux/X11" -runnable=true -dedicated_server=false -custom_features="" -export_filter="all_resources" -include_filter="" -exclude_filter="" -export_path="" -encryption_include_filters="" -encryption_exclude_filters="" -encrypt_pck=false -encrypt_directory=false -script_encryption_key="" - -[preset.2.options] - -custom_template/debug="" -custom_template/release="" -debug/export_console_script=1 -binary_format/embed_pck=false -texture_format/bptc=true -texture_format/s3tc=true -texture_format/etc=false -texture_format/etc2=false -binary_format/architecture="x86_64" -ssh_remote_deploy/enabled=false -ssh_remote_deploy/host="user@host_ip" -ssh_remote_deploy/port="22" -ssh_remote_deploy/extra_args_ssh="" -ssh_remote_deploy/extra_args_scp="" -ssh_remote_deploy/run_script="#!/usr/bin/env bash -export DISPLAY=:0 -unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" -\"{temp_dir}/{exe_name}\" {cmd_args}" -ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash -kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") -rm -rf \"{temp_dir}\"" - -[preset.3] - name="Web" platform="Web" -runnable=true +runnable=false dedicated_server=false custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="" +export_path="web/index.html" encryption_include_filters="" encryption_exclude_filters="" encrypt_pck=false encrypt_directory=false -script_encryption_key="" -[preset.3.options] +[preset.2.options] custom_template/debug="" custom_template/release="" From c5e63667601c0935573b1d71d736d0a63adaadf5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 11 Sep 2023 21:20:48 +0200 Subject: [PATCH 6/6] Added shortcuts. Added dialog for winner. Started cleaning code. --- MainWindow.gd | 104 ++++++++++++++++++++------------------------- MainWindow.tscn | 59 ++++++++++++++++++++++--- Player.gd | 1 + Settings.gd | 46 ++++++++++++++------ export_presets.cfg | 4 +- 5 files changed, 136 insertions(+), 78 deletions(-) diff --git a/MainWindow.gd b/MainWindow.gd index dfcb15c..b422088 100644 --- a/MainWindow.gd +++ b/MainWindow.gd @@ -1,16 +1,16 @@ extends Control +# 601 LOC 11/9 - 2023 + ##TODO # 2. Fix reset buttons # 3. Fix settings -# 9. Fix winner # 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 -# 18. Fix shortcuts @onready var open_button := $Open @@ -117,9 +117,18 @@ var version_label := $AboutPopupPanel/VBoxContainer/VersionLabel @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 Player := preload("res://Player.tscn") @onready @@ -153,6 +162,7 @@ func show_about(): about_popup.visible = true version_label.text = Settings.version new_label.text = Settings.whats_new + shortcut_label.text = Settings.shortcuts comming_label.text = Settings.whats_left func show_settings(): @@ -199,14 +209,18 @@ func games_synced(result, response_code, headers, body): sync_popup.visible = true func get_suggestion_list() -> void: - var http_request = HTTPRequest.new() - add_child(http_request) - http_request.request_completed.connect(_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") - if error != OK: - push_error("An error occurred in the HTTP request.") + var populate_list = func(array): + if typeof(array) == TYPE_ARRAY: + games.append_array(array) + for game in games: + var label := Label.new() + label.text = game + label.autowrap_mode = TextServer.AUTOWRAP_WORD + insperation_list.add_child(label) + insperation_scroll.scroll_to_bottom() + else: + print("Unexpected data") + Settings.make_request2("/music/all", populate_list) func add_players(): add_player_container.visible = !add_player_container.visible @@ -218,11 +232,11 @@ func add_player(): 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.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)) -func _on_point_triggerd(point: String): +func _on_point_triggerd(point: String, name: String): var song_path: String if point == "first": var value = randi_range(0, 10) @@ -236,9 +250,12 @@ func _on_point_triggerd(point: String): song_path = "res://sounds/sound0.mp3" elif point == "winner": song_path = "res://sounds/winning.mp3" + winner_popup.visible = true + winner_label.text = name + " won!!" audio.stream = load_mp3(song_path) audio.play() + play_button.text = "Pause" stream = audio.stream progress.max_value = round(stream.get_length()) progress.tick_count = round(stream.get_length() / 60) @@ -260,26 +277,22 @@ func show_answer(): push_error("An error occurred in the HTTP request.") func fetch_full_music_list_at_start(): - var show_fetched_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) - 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) - else: - print("Unexpected data") - make_request(Settings.default_path + "/music/list", show_fetched_list) + var show_fetched_list = func(data): + if data == null: return + if typeof(data) == TYPE_ARRAY: + song_list = [] + song_list.append_array(data) + 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) + else: + print("Unexpected data") + Settings.make_request2("/music/list", show_fetched_list) func fetch_full_music_list(event, song_no: int): if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT): @@ -420,33 +433,10 @@ func song_clicked(event, label: Label, song_no: int): song_label.text = data_received.Song make_request(Settings.default_path + "/music/info", show_answer) -# 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) - for game in games: - var label := Label.new() - label.text = game - label.autowrap_mode = TextServer.AUTOWRAP_WORD - insperation_list.add_child(label) - insperation_scroll.scroll_to_bottom() - else: - print("Unexpected data") - - - # Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org). - #print(response) func open(): 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: diff --git a/MainWindow.tscn b/MainWindow.tscn index 33d3c9e..26f63c6 100644 --- a/MainWindow.tscn +++ b/MainWindow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 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"] @@ -21,6 +21,15 @@ 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 @@ -30,6 +39,24 @@ unicode = 63743 [sub_resource type="Shortcut" id="Shortcut_jafqj"] events = [SubResource("InputEventKey_03bm3")] +[sub_resource type="InputEventKey" id="InputEventKey_06rl4"] +device = -1 +alt_pressed = true +keycode = 86 +unicode = 8249 + +[sub_resource type="Shortcut" id="Shortcut_a7fvb"] +events = [SubResource("InputEventKey_06rl4")] + +[sub_resource type="InputEventKey" id="InputEventKey_7dnqw"] +device = -1 +alt_pressed = true +keycode = 67 +unicode = 231 + +[sub_resource type="Shortcut" id="Shortcut_d6fml"] +events = [SubResource("InputEventKey_7dnqw")] + [sub_resource type="InputEventKey" id="InputEventKey_ujjlu"] device = -1 alt_pressed = true @@ -38,6 +65,9 @@ keycode = 83 [sub_resource type="Shortcut" id="Shortcut_fbju4"] events = [SubResource("InputEventKey_ujjlu")] +[sub_resource type="LabelSettings" id="LabelSettings_hr75l"] +font_size = 35 + [node name="Control" type="Control"] layout_mode = 3 anchors_preset = 0 @@ -125,6 +155,7 @@ 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"] @@ -237,6 +268,7 @@ offset_left = 611.0 offset_top = 1016.0 offset_right = 722.0 offset_bottom = 1047.0 +shortcut = SubResource("Shortcut_a7fvb") text = "Show answer" [node name="NextButton" type="Button" parent="."] @@ -245,6 +277,7 @@ offset_left = 729.0 offset_top = 1017.0 offset_right = 904.0 offset_bottom = 1048.0 +shortcut = SubResource("Shortcut_d6fml") text = "Randomize new track" [node name="MusicListPanel" type="PanelContainer" parent="."] @@ -346,7 +379,7 @@ size = Vector2i(848, 272) offset_left = 4.0 offset_top = 4.0 offset_right = 844.0 -offset_bottom = 268.0 +offset_bottom = 273.0 [node name="Label" type="Label" parent="AboutPopupPanel/VBoxContainer"] layout_mode = 2 @@ -373,6 +406,9 @@ size_flags_vertical = 0 text = "0.7-Beta: Can now hop between songs" autowrap_mode = 2 +[node name="ShortcutsLabel" type="Label" parent="AboutPopupPanel/VBoxContainer/HBoxContainer"] +layout_mode = 2 + [node name="CommingLabel" type="Label" parent="AboutPopupPanel/VBoxContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 @@ -391,10 +427,23 @@ autowrap_mode = 2 initial_position = 2 size = Vector2i(268, 233) -[node name="VBoxContainer" parent="SettingsPopupPanel" instance=ExtResource("11_k62u5")] +[node name="SettingsWindow" parent="SettingsPopupPanel" instance=ExtResource("11_k62u5")] offset_left = 4.0 offset_top = 4.0 -offset_right = -4.0 -offset_bottom = 19.0 +offset_right = 264.0 +offset_bottom = 252.0 + +[node name="WinnerPopupPanel" type="PopupPanel" parent="."] +initial_position = 2 +size = Vector2i(350, 100) + +[node name="WinnerLabel" type="Label" parent="WinnerPopupPanel"] +offset_left = 4.0 +offset_top = 4.0 +offset_right = 346.0 +offset_bottom = 96.0 +text = "Sansan won!!" +label_settings = SubResource("LabelSettings_hr75l") +horizontal_alignment = 1 [connection signal="dir_selected" from="FileDialog" to="." method="_on_file_dialog_dir_selected"] diff --git a/Player.gd b/Player.gd index 7c464cf..5ba39f1 100644 --- a/Player.gd +++ b/Player.gd @@ -20,6 +20,7 @@ signal first_point_triggerd signal match_point_triggerd signal winner_triggerd +@export var player_name: String var is_first_point: bool = true diff --git a/Settings.gd b/Settings.gd index aeaff1e..0011ee5 100644 --- a/Settings.gd +++ b/Settings.gd @@ -13,17 +13,25 @@ var add_to_stats: bool = false var use_low_played_mode: bool = false var winning_score: int = 20 -var version: String = "0.7.5-Beta" -var whats_new: String = "0.7.5-Beta: Added settings menu, most things don't do anythig yet +var version: String = "0.7.8-Beta" +var whats_new: String = "Changelog: +0.7.8-Beta: Added shortcuts. Added dialog for winner. Started cleaning code. +0.7.5-Beta: Added settings menu, most things don't do anythig yet 0.7-Beta: Can now hop between songs" -var whats_left: String = "Fix reset buttons +var whats_left: String = "Things left to do: +Fix reset buttons Fix settings -Fix winner Fix graphics in lists Fix layout Fix for local play -Change some buttons to icons -Add shortcuts" +Change some buttons to icons" + +var shortcuts: String = "Shortcuts: +Alt + S = Search +Alt + A = Add Players +Alt + X = Play/Pause +Alt + C = Next Song +Alt + V = Show Answer" #play = X @@ -32,11 +40,21 @@ Add shortcuts" #lägga till poäng? 1, 2, 3, 4, 5, 6 -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass +func make_request2(address: String, func_name: Callable) -> void: + var error_handling = 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() + print("data_received: ", data_received) + func_name.call(data_received) + + var http_request = 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 error = http_request.request(default_path + address) + if error != OK: + push_error("An error occurred in the HTTP request.") + diff --git a/export_presets.cfg b/export_presets.cfg index 3155ad7..f454433 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -8,7 +8,7 @@ custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="./MusicPlayer_0.7.5_Beta.exe" +export_path="../../ResilioSync/Sorterat/MusicPlayer_0.7.8_Beta.exe" encryption_include_filters="" encryption_exclude_filters="" encrypt_pck=false @@ -18,7 +18,7 @@ encrypt_directory=false custom_template/debug="" custom_template/release="" -debug/export_console_wrapper=1 +debug/export_console_wrapper=0 binary_format/embed_pck=true texture_format/bptc=true texture_format/s3tc=true