Fixed settings and updated player view. Fixed many other smaler things
This commit is contained in:
@@ -15,7 +15,8 @@ func _ready():
|
||||
characters.list_dir_begin()
|
||||
var file_name = characters.get_next()
|
||||
while file_name != "":
|
||||
if !file_name.ends_with(".import"):
|
||||
file_name = file_name.replace('.import', '') # <--- remove the .import
|
||||
if file_name.ends_with(".png"):
|
||||
|
||||
var texture = load("res://characters/" + file_name)
|
||||
|
||||
@@ -36,9 +37,4 @@ func show_grid():
|
||||
|
||||
func select_character(file_name: String):
|
||||
print("select_character")
|
||||
#character_grid_container.visible = false
|
||||
character_selected.emit(file_name)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
character_selected.emit(file_name)
|
||||
136
MainWindow.gd
136
MainWindow.gd
@@ -1,10 +1,10 @@
|
||||
extends Control
|
||||
|
||||
# 601 LOC 11/9 - 2023
|
||||
# 628 LOC 15/9 - 2023
|
||||
# 631 LOC 16/9 - 2023
|
||||
|
||||
##TODO
|
||||
# 2. Fix reset buttons
|
||||
# 3. Fix settings
|
||||
# 11. Refactor components
|
||||
# 13. Fix graphics in lists
|
||||
# 14. Fix layout
|
||||
@@ -57,6 +57,12 @@ var add_player_button := $Players/VBoxContainer/AddPlayerContainer/AddPlayerButt
|
||||
@onready
|
||||
var new_player_name_field := $Players/VBoxContainer/AddPlayerContainer/PlayerNameField
|
||||
|
||||
@onready
|
||||
var reset_playlist_button := $ResetPlaylistButton
|
||||
|
||||
@onready
|
||||
var reset_points_button := $ResetPointsButton
|
||||
|
||||
@onready
|
||||
var sound_test_button := $SoundTestButton
|
||||
|
||||
@@ -129,7 +135,7 @@ var winner_popup := $WinnerPopupPanel
|
||||
@onready
|
||||
var winner_label := $WinnerPopupPanel/WinnerLabel
|
||||
|
||||
var Player := preload("res://Player.tscn")
|
||||
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'
|
||||
@@ -146,11 +152,14 @@ func _ready():
|
||||
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)
|
||||
|
||||
add_players_button.pressed.connect(add_players)
|
||||
add_player_button.pressed.connect(add_player)
|
||||
|
||||
@@ -158,6 +167,16 @@ func _ready():
|
||||
get_suggestion_list()
|
||||
fetch_full_music_list_at_start()
|
||||
|
||||
func reset_playlist():
|
||||
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:
|
||||
if player_to_reset.has_method("reset_points"):
|
||||
player_to_reset.reset_points()
|
||||
|
||||
func show_about():
|
||||
about_popup.visible = true
|
||||
version_label.text = Settings.version
|
||||
@@ -173,7 +192,7 @@ func get_statistics():
|
||||
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):
|
||||
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()
|
||||
@@ -187,73 +206,65 @@ func get_sound_test_song():
|
||||
make_request(Settings.default_path + "/music/first", play_sound_test_song)
|
||||
|
||||
func sound_test_local():
|
||||
path = "res://01. Opening.mp3"
|
||||
audio.stream = load_mp3(path)
|
||||
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 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(Settings.default_path + "/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:
|
||||
var games_synced = func():
|
||||
sync_popup.visible = true
|
||||
print("games_synced")
|
||||
reset_playlist()
|
||||
get_suggestion_list()
|
||||
Settings.make_request2("/sync", games_synced, false)
|
||||
|
||||
func get_suggestion_list() -> void:
|
||||
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)
|
||||
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()
|
||||
else:
|
||||
print("Unexpected data")
|
||||
Settings.make_request2("/music/all", populate_list)
|
||||
Settings.make_request2("/music/all", populate_list, true)
|
||||
|
||||
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)
|
||||
var new_player := player.instantiate()
|
||||
new_player.new_name(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("player_removed", _on_player_removed.bind(new_player))
|
||||
|
||||
func _on_point_triggerd(point: String, name: String):
|
||||
var song_path: String
|
||||
func _on_point_triggerd(point: String, player_name: String):
|
||||
if point == "first":
|
||||
var value = randi_range(0, 10)
|
||||
if value == 0:
|
||||
song_path = "res://sounds/sound1.mp3"
|
||||
audio.stream = preload("res://sounds/sound1.mp3")
|
||||
elif value < 5:
|
||||
song_path = "res://sounds/intro_long.mp3"
|
||||
else:
|
||||
song_path = "res://sounds/intro_short.mp3"
|
||||
audio.stream = preload("res://sounds/intro_long.mp3")
|
||||
else:
|
||||
audio.stream = preload("res://sounds/intro_short.mp3")
|
||||
elif point == "match":
|
||||
song_path = "res://sounds/sound0.mp3"
|
||||
audio.stream = preload("res://sounds/sound0.mp3")
|
||||
elif point == "winner":
|
||||
song_path = "res://sounds/winning.mp3"
|
||||
audio.stream = preload("res://sounds/winning.mp3")
|
||||
winner_popup.visible = true
|
||||
winner_label.text = name + " won!!"
|
||||
winner_label.text = player_name + " won!!"
|
||||
|
||||
audio.stream = load_mp3(song_path)
|
||||
audio.play()
|
||||
play_button.text = "Pause"
|
||||
stream = audio.stream
|
||||
@@ -277,26 +288,30 @@ func show_answer():
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
func fetch_full_music_list_at_start():
|
||||
var show_fetched_list = func(data):
|
||||
if data == null: return
|
||||
print("fetch_full_music_list_at_start")
|
||||
var show_music_list_at_start = func(data):
|
||||
if data == null:
|
||||
song_list = []
|
||||
delete_children(music_list)
|
||||
return
|
||||
if typeof(data) == TYPE_ARRAY:
|
||||
song_list = []
|
||||
song_list.append_array(data)
|
||||
for song in song_list:
|
||||
var label := Label.new()
|
||||
var music_list_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)
|
||||
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))
|
||||
music_list.add_child(music_list_label)
|
||||
else:
|
||||
print("Unexpected data")
|
||||
Settings.make_request2("/music/list", show_fetched_list)
|
||||
Settings.make_request2("/music/list", show_music_list_at_start, true)
|
||||
|
||||
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 show_music_list = func(_result, _response_code, _headers, body):
|
||||
var json = JSON.new()
|
||||
var error = json.parse(body.get_string_from_utf8())
|
||||
|
||||
@@ -321,8 +336,8 @@ func fetch_full_music_list(event, song_no: int):
|
||||
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):
|
||||
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()
|
||||
@@ -449,7 +464,6 @@ func _on_file_dialog_dir_selected(path):
|
||||
|
||||
var songs := []
|
||||
var games := []
|
||||
#var player = preload("res://Player.gd")
|
||||
|
||||
func dir_contents(path: String) -> void:
|
||||
var dir = DirAccess.open(path)
|
||||
@@ -509,28 +523,39 @@ func format_text(part: float, total: float) -> String:
|
||||
func fetch_next_song() -> void:
|
||||
var http_request = HTTPRequest.new()
|
||||
add_child(http_request)
|
||||
http_request.request_completed.connect(first_song_fetched)
|
||||
http_request.request_completed.connect(song_fetched)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var error = http_request.request(Settings.default_path + "/music/rand")
|
||||
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 first_song_fetched(result, response_code, headers, body) -> void:
|
||||
game_label.text = "????????"
|
||||
song_label.text = "??????"
|
||||
|
||||
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
|
||||
make_request(Settings.default_path + "/music/addQue", add_que)
|
||||
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)
|
||||
@@ -584,6 +609,9 @@ func load_mp3(_path) -> AudioStream:
|
||||
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")
|
||||
@@ -596,7 +624,7 @@ func _on_character_selected(file_name: String):
|
||||
current_player._on_control_character_selected_clicked(file_name)
|
||||
|
||||
|
||||
static func delete_children(node):
|
||||
func delete_children(node):
|
||||
for n in node.get_children():
|
||||
node.remove_child(n)
|
||||
n.queue_free()
|
||||
|
||||
150
MainWindow.tscn
150
MainWindow.tscn
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=26 format=3 uid="uid://xwq863o6uvsu"]
|
||||
[gd_scene load_steps=28 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"]
|
||||
@@ -39,6 +39,12 @@ unicode = 63743
|
||||
[sub_resource type="Shortcut" id="Shortcut_jafqj"]
|
||||
events = [SubResource("InputEventKey_03bm3")]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qk7sj"]
|
||||
bg_color = Color(0.180392, 0.180392, 0.180392, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_k1ygi"]
|
||||
bg_color = Color(0.180392, 0.180392, 0.180392, 1)
|
||||
|
||||
[sub_resource type="InputEventKey" id="InputEventKey_06rl4"]
|
||||
device = -1
|
||||
alt_pressed = true
|
||||
@@ -80,20 +86,20 @@ offset_bottom = 56.0
|
||||
|
||||
[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
|
||||
offset_left = 64.0
|
||||
offset_top = 12.0
|
||||
offset_right = 369.0
|
||||
offset_bottom = 50.0
|
||||
size_flags_horizontal = 0
|
||||
text = "Music Player Randomizer"
|
||||
label_settings = SubResource("LabelSettings_ychxr")
|
||||
|
||||
[node name="Open" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
offset_left = 65.0
|
||||
offset_top = 877.0
|
||||
offset_right = 115.0
|
||||
offset_bottom = 908.0
|
||||
offset_left = 1296.0
|
||||
offset_top = 66.0
|
||||
offset_right = 1346.0
|
||||
offset_bottom = 97.0
|
||||
text = "Open"
|
||||
|
||||
[node name="FileDialog" type="FileDialog" parent="."]
|
||||
@@ -107,10 +113,10 @@ show_hidden_files = true
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 1204.0
|
||||
offset_top = 95.0
|
||||
offset_right = 1845.0
|
||||
offset_bottom = 465.0
|
||||
offset_left = 1216.0
|
||||
offset_top = 128.0
|
||||
offset_right = 1857.0
|
||||
offset_bottom = 512.0
|
||||
horizontal_scroll_mode = 0
|
||||
vertical_scroll_mode = 3
|
||||
script = ExtResource("2_gxtxm")
|
||||
@@ -122,18 +128,20 @@ size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 52.0
|
||||
offset_top = 81.0
|
||||
offset_right = 977.0
|
||||
offset_bottom = 368.0
|
||||
offset_left = 64.0
|
||||
offset_top = 64.0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 384.0
|
||||
|
||||
[node name="GameLabel" type="Label" parent="VBoxContainer"]
|
||||
custom_minimum_size = Vector2(1, 1)
|
||||
layout_mode = 2
|
||||
label_settings = SubResource("LabelSettings_qspbu")
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="SongLabel" type="Label" parent="VBoxContainer"]
|
||||
custom_minimum_size = Vector2(1, 1)
|
||||
layout_mode = 2
|
||||
label_settings = SubResource("LabelSettings_3m52w")
|
||||
horizontal_alignment = 1
|
||||
@@ -144,10 +152,10 @@ visible = false
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 69.0
|
||||
offset_top = 924.0
|
||||
offset_right = 1057.0
|
||||
offset_bottom = 964.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
|
||||
@@ -183,24 +191,29 @@ bus = &"music"
|
||||
|
||||
[node name="Players" type="PanelContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 1283.0
|
||||
offset_top = 642.0
|
||||
offset_right = 1820.0
|
||||
offset_bottom = 1003.0
|
||||
offset_left = 1216.0
|
||||
offset_top = 576.0
|
||||
offset_right = 1857.0
|
||||
offset_bottom = 977.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Players"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Players/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(2.08165e-12, 40)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Players/VBoxContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(2.08165e-12, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
text = "Players"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="AddPlayersButton" type="TextureButton" parent="Players/VBoxContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(2.08165e-12, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
shortcut = SubResource("Shortcut_jafqj")
|
||||
@@ -208,84 +221,88 @@ texture_normal = ExtResource("4_op458")
|
||||
|
||||
[node name="AddPlayerContainer" type="HBoxContainer" parent="Players/VBoxContainer"]
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(2.08165e-12, 40)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Panel" type="Panel" parent="Players/VBoxContainer/AddPlayerContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_qk7sj")
|
||||
|
||||
[node name="PlayerNameField" type="TextEdit" parent="Players/VBoxContainer/AddPlayerContainer"]
|
||||
custom_minimum_size = Vector2(2.08165e-12, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Player name"
|
||||
script = ExtResource("7_qsdfy")
|
||||
|
||||
[node name="AddPlayerButton" type="Button" parent="Players/VBoxContainer/AddPlayerContainer"]
|
||||
custom_minimum_size = Vector2(2.08165e-12, 40)
|
||||
layout_mode = 2
|
||||
text = "Add"
|
||||
|
||||
[node name="Panel2" type="Panel" parent="Players/VBoxContainer/AddPlayerContainer"]
|
||||
custom_minimum_size = Vector2(2.08165e-12, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_k1ygi")
|
||||
|
||||
[node name="ResetPlaylistButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 125.0
|
||||
offset_top = 1017.0
|
||||
offset_right = 236.0
|
||||
offset_bottom = 1048.0
|
||||
offset_left = 1359.0
|
||||
offset_top = 66.0
|
||||
offset_right = 1470.0
|
||||
offset_bottom = 97.0
|
||||
text = "Reset playlist"
|
||||
|
||||
[node name="ResetPointsButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 247.0
|
||||
offset_top = 1018.0
|
||||
offset_right = 358.0
|
||||
offset_bottom = 1049.0
|
||||
offset_left = 1487.0
|
||||
offset_top = 66.0
|
||||
offset_right = 1598.0
|
||||
offset_bottom = 97.0
|
||||
text = "Reset points"
|
||||
|
||||
[node name="SyncButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 370.0
|
||||
offset_top = 1016.0
|
||||
offset_right = 481.0
|
||||
offset_bottom = 1047.0
|
||||
offset_left = 1615.0
|
||||
offset_top = 66.0
|
||||
offset_right = 1726.0
|
||||
offset_bottom = 97.0
|
||||
text = "Sync games"
|
||||
|
||||
[node name="SoundTestButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 491.0
|
||||
offset_top = 1016.0
|
||||
offset_right = 602.0
|
||||
offset_bottom = 1047.0
|
||||
offset_left = 1743.0
|
||||
offset_top = 66.0
|
||||
offset_right = 1854.0
|
||||
offset_bottom = 97.0
|
||||
text = "Sound test"
|
||||
|
||||
[node name="ShowAnswerButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 611.0
|
||||
offset_top = 1016.0
|
||||
offset_right = 722.0
|
||||
offset_bottom = 1047.0
|
||||
offset_left = 65.0
|
||||
offset_top = 944.0
|
||||
offset_right = 176.0
|
||||
offset_bottom = 975.0
|
||||
shortcut = SubResource("Shortcut_a7fvb")
|
||||
text = "Show answer"
|
||||
|
||||
[node name="NextButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 729.0
|
||||
offset_top = 1017.0
|
||||
offset_right = 904.0
|
||||
offset_bottom = 1048.0
|
||||
offset_left = 193.0
|
||||
offset_top = 944.0
|
||||
offset_right = 368.0
|
||||
offset_bottom = 975.0
|
||||
shortcut = SubResource("Shortcut_d6fml")
|
||||
text = "Randomize new track"
|
||||
|
||||
[node name="MusicListPanel" type="PanelContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 136.0
|
||||
offset_top = 388.0
|
||||
offset_right = 1009.0
|
||||
offset_bottom = 845.0
|
||||
offset_left = 64.0
|
||||
offset_top = 384.0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 896.0
|
||||
theme = ExtResource("7_wxbv6")
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="MusicListPanel"]
|
||||
@@ -298,34 +315,34 @@ layout_mode = 2
|
||||
|
||||
[node name="SearchButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 1528.0
|
||||
offset_left = 1488.0
|
||||
offset_top = 8.0
|
||||
offset_right = 1598.0
|
||||
offset_right = 1558.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_left = 1584.0
|
||||
offset_top = 8.0
|
||||
offset_right = 1694.0
|
||||
offset_right = 1654.0
|
||||
offset_bottom = 48.0
|
||||
text = "Settings"
|
||||
|
||||
[node name="StatisticsButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 1720.0
|
||||
offset_left = 1680.0
|
||||
offset_top = 8.0
|
||||
offset_right = 1798.0
|
||||
offset_right = 1758.0
|
||||
offset_bottom = 48.0
|
||||
text = "Statistics"
|
||||
|
||||
[node name="AboutButton" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 1824.0
|
||||
offset_left = 1784.0
|
||||
offset_top = 8.0
|
||||
offset_right = 1894.0
|
||||
offset_right = 1854.0
|
||||
offset_bottom = 48.0
|
||||
text = "About"
|
||||
|
||||
@@ -379,7 +396,7 @@ size = Vector2i(848, 272)
|
||||
offset_left = 4.0
|
||||
offset_top = 4.0
|
||||
offset_right = 844.0
|
||||
offset_bottom = 273.0
|
||||
offset_bottom = 706.0
|
||||
|
||||
[node name="Label" type="Label" parent="AboutPopupPanel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
@@ -400,6 +417,7 @@ layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="NewLabel" type="Label" parent="AboutPopupPanel/VBoxContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(1, 1)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
@@ -407,9 +425,11 @@ text = "0.7-Beta: Can now hop between songs"
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="ShortcutsLabel" type="Label" parent="AboutPopupPanel/VBoxContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(1, 1)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CommingLabel" type="Label" parent="AboutPopupPanel/VBoxContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(1, 1)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
@@ -431,7 +451,7 @@ size = Vector2i(268, 233)
|
||||
offset_left = 4.0
|
||||
offset_top = 4.0
|
||||
offset_right = 264.0
|
||||
offset_bottom = 252.0
|
||||
offset_bottom = 284.0
|
||||
|
||||
[node name="WinnerPopupPanel" type="PopupPanel" parent="."]
|
||||
initial_position = 2
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
extends PanelContainer
|
||||
|
||||
# LOC 20/1-24: 136
|
||||
|
||||
@onready
|
||||
var play_button := $HBoxContainer/PlayButton
|
||||
|
||||
@@ -27,6 +29,8 @@ var is_changing: bool = false
|
||||
var playback_position: float
|
||||
var stream: AudioStream
|
||||
|
||||
signal fetched
|
||||
|
||||
func set_songs(new_songs) -> void:
|
||||
songs = new_songs
|
||||
|
||||
@@ -61,29 +65,18 @@ func _process(_delta):
|
||||
progress.value = audio.get_playback_position()
|
||||
label.text = format_text(progress.value, stream.get_length())
|
||||
|
||||
signal fetched
|
||||
|
||||
func fetch_first_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")
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
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)
|
||||
|
||||
func first_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
|
||||
make_request("https://music.sanplex.tech/music/addQue", add_que)
|
||||
#fetched.emit()
|
||||
play(sound)
|
||||
Settings.make_request2("/music/rand", first_song_fetched, true)
|
||||
|
||||
func add_que(result, response_code, headers, body) -> void:
|
||||
func add_que(_result, response_code, _headers, _body) -> void:
|
||||
print("response_code", response_code)
|
||||
fetched.emit()
|
||||
|
||||
@@ -99,7 +92,6 @@ func play(song) -> void:
|
||||
stream = audio.stream
|
||||
else:
|
||||
if songs:
|
||||
#print(songs)
|
||||
path = songs[0]
|
||||
print(path)
|
||||
print(FileAccess.file_exists(path))
|
||||
@@ -131,4 +123,4 @@ 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
|
||||
return sound
|
||||
@@ -1,16 +1,8 @@
|
||||
extends ScrollContainer
|
||||
|
||||
var max = 0;
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
var max_value = 0;
|
||||
|
||||
func _draw():
|
||||
if max != self.get_v_scroll_bar().max_value:
|
||||
max = self.get_v_scroll_bar().max_value
|
||||
self.scroll_vertical = max
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
if max_value != self.get_v_scroll_bar().max_value:
|
||||
max_value = self.get_v_scroll_bar().max_value
|
||||
self.scroll_vertical = max_value
|
||||
34
Player.gd
34
Player.gd
@@ -3,9 +3,6 @@ extends Control
|
||||
@onready
|
||||
var player_name_field := $HBoxContainer/Name
|
||||
|
||||
@onready
|
||||
var points := $HBoxContainer/Points
|
||||
|
||||
@onready
|
||||
var add := $HBoxContainer/AddPoint
|
||||
|
||||
@@ -15,26 +12,29 @@ var minus := $HBoxContainer/RemovePoint
|
||||
@onready
|
||||
var character := $HBoxContainer/Character
|
||||
|
||||
@onready
|
||||
var remove_player := $HBoxContainer/RemovePlayer
|
||||
|
||||
signal change_character_clicked
|
||||
signal first_point_triggerd
|
||||
signal match_point_triggerd
|
||||
signal winner_triggerd
|
||||
signal player_removed
|
||||
|
||||
@export
|
||||
var player_name: String
|
||||
|
||||
var is_first_point: bool = true
|
||||
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
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_name(new_name: String):
|
||||
func new_player_name(new_name: String):
|
||||
player_name = new_name
|
||||
|
||||
func add_point():
|
||||
@@ -42,8 +42,8 @@ func add_point():
|
||||
is_first_point = false
|
||||
first_point_triggerd.emit()
|
||||
|
||||
var new_value := int(points.text) + 1
|
||||
points.text = str(new_value)
|
||||
var new_value := get_point() + 1
|
||||
set_point(new_value)
|
||||
|
||||
if new_value == Settings.winning_score - 1:
|
||||
match_point_triggerd.emit()
|
||||
@@ -52,14 +52,18 @@ func add_point():
|
||||
winner_triggerd.emit()
|
||||
|
||||
func minus_point():
|
||||
var new_value := int(points.text) - 1
|
||||
points.text = str(new_value)
|
||||
var new_value := get_point() - 1
|
||||
set_point(new_value)
|
||||
|
||||
if new_value == 0:
|
||||
is_first_point = true
|
||||
|
||||
func reset_points():
|
||||
var new_value := 0
|
||||
set_point(new_value)
|
||||
is_first_point = true
|
||||
|
||||
func change_character():
|
||||
print("change_character")
|
||||
change_character_clicked.emit()
|
||||
|
||||
func _on_control_character_selected_clicked(file_name: String):
|
||||
@@ -70,3 +74,11 @@ func _on_control_character_selected_clicked(file_name: String):
|
||||
character.ignore_texture_size = true
|
||||
character.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT
|
||||
character.texture_normal = texture
|
||||
|
||||
func get_point() -> int:
|
||||
var arr = player_name_field.text.split(":")
|
||||
return arr[1].to_int()
|
||||
|
||||
func set_point(new_point: int):
|
||||
var arr = player_name_field.text.split(":")
|
||||
player_name_field.text = arr[0] + ": " + str(new_point)
|
||||
|
||||
68
Player.tscn
68
Player.tscn
@@ -1,47 +1,89 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cslogy2csnd7a"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://cslogy2csnd7a"]
|
||||
|
||||
[ext_resource type="Script" path="res://Player.gd" id="1_if4kc"]
|
||||
[ext_resource type="Texture2D" uid="uid://bah8j3gu07305" path="res://characters/Kiryu.png" id="1_y7dih"]
|
||||
[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"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_821k2"]
|
||||
bg_color = Color(0.180392, 0.180392, 0.180392, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_w10e8"]
|
||||
bg_color = Color(0.180392, 0.180392, 0.180392, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_78a8g"]
|
||||
bg_color = Color(0.180392, 0.180392, 0.180392, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_i56hb"]
|
||||
bg_color = Color(0.180392, 0.180392, 0.180392, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b2crt"]
|
||||
bg_color = Color(0.180392, 0.180392, 0.180392, 1)
|
||||
|
||||
[node name="Player" type="Control"]
|
||||
custom_minimum_size = Vector2(2.08165e-12, 40)
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
anchors_preset = 0
|
||||
offset_bottom = 40.0
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource("1_if4kc")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
custom_minimum_size = Vector2(2.08165e-12, 40)
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="Name" type="Label" parent="HBoxContainer"]
|
||||
[node name="Panel4" type="Panel" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(5, 40)
|
||||
layout_mode = 2
|
||||
text = "Sansan: "
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_821k2")
|
||||
|
||||
[node name="Points" type="Label" parent="HBoxContainer"]
|
||||
[node name="Name" type="Label" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(130, 40)
|
||||
layout_mode = 2
|
||||
text = "0"
|
||||
size_flags_vertical = 1
|
||||
text = "Sansansans: 100"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Panel3" type="Panel" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(80, 2.08165e-12)
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_w10e8")
|
||||
|
||||
[node name="Character" type="TextureButton" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(80, 40)
|
||||
layout_mode = 2
|
||||
texture_normal = ExtResource("1_y7dih")
|
||||
texture_normal = ExtResource("2_hpj3s")
|
||||
ignore_texture_size = true
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Panel2" type="Panel" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(30, 40)
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_78a8g")
|
||||
|
||||
[node name="AddPoint" type="Button" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
text = "+1"
|
||||
|
||||
[node name="Panel5" type="Panel" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(3, 40)
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_i56hb")
|
||||
|
||||
[node name="RemovePoint" type="Button" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
text = "-1"
|
||||
|
||||
[node name="RemovePlayer" type="TextureButton" parent="HBoxContainer"]
|
||||
[node name="Panel" type="Panel" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(30, 40)
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_b2crt")
|
||||
|
||||
[node name="RemovePlayer" type="TextureButton" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
texture_normal = ExtResource("2_xw2ck")
|
||||
|
||||
@@ -3,10 +3,36 @@ extends TextEdit
|
||||
signal enter_key_pressed
|
||||
signal close_pressed
|
||||
|
||||
@export
|
||||
var LIMIT: int = 10
|
||||
var current_text = ''
|
||||
var cursor_line = 0
|
||||
var cursor_column = 0
|
||||
|
||||
func _ready():
|
||||
text_changed.connect(_on_text_changed)
|
||||
|
||||
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:
|
||||
if event.keycode == KEY_ENTER || event.keycode == KEY_KP_ENTER:
|
||||
enter_key_pressed.emit()
|
||||
|
||||
func _on_text_changed():
|
||||
if text.contains("\n"):
|
||||
text = text.replace("\n", "")
|
||||
|
||||
var new_text : String = text
|
||||
if new_text.length() > LIMIT:
|
||||
text = current_text
|
||||
# when replacing the text, the cursor will get moved to the beginning of the
|
||||
# text, so move it back to where it was
|
||||
set_caret_line(cursor_line)
|
||||
set_caret_column(cursor_column)
|
||||
|
||||
current_text = text
|
||||
# save current position of cursor for when we have reached the limit
|
||||
cursor_line = get_caret_line()
|
||||
cursor_column = get_caret_column()
|
||||
|
||||
@@ -35,13 +35,33 @@ 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()):
|
||||
if is_match(search_bar.text, game):
|
||||
var label := Label.new()
|
||||
label.text = game
|
||||
label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
search_list.add_child(label)
|
||||
|
||||
func is_match(search_term: String, game_name: String) -> bool:
|
||||
search_term = search_term.replace(" ", "").replace("é", "e").to_lower()
|
||||
game_name = game_name.replace(" ", "").replace("é", "e").to_lower()
|
||||
|
||||
static func delete_children(node):
|
||||
if search_term == "":
|
||||
return true
|
||||
elif compile_regex(search_term).search(game_name):
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
func compile_regex(search_term: String) -> RegEx:
|
||||
var regex = RegEx.new()
|
||||
var regText: String = ".*"
|
||||
for letter in search_term:
|
||||
regText += letter + ".*"
|
||||
print(regText)
|
||||
regex.compile(regText)
|
||||
return regex
|
||||
|
||||
func delete_children(node):
|
||||
for n in node.get_children():
|
||||
node.remove_child(n)
|
||||
n.queue_free()
|
||||
@@ -57,7 +77,7 @@ func get_list_of_games() -> void:
|
||||
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):
|
||||
func _http_request_completed(_result, _response_code, _headers, body):
|
||||
var json = JSON.new()
|
||||
var error = json.parse(body.get_string_from_utf8())
|
||||
|
||||
@@ -75,4 +95,6 @@ func _http_request_completed(result, response_code, headers, body):
|
||||
|
||||
func clear():
|
||||
search_bar.text = ""
|
||||
search()
|
||||
search_bar.grab_focus()
|
||||
|
||||
|
||||
44
Settings.gd
44
Settings.gd
@@ -1,26 +1,27 @@
|
||||
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://tmusic.sanplex.tech"
|
||||
var selected_server = 0
|
||||
|
||||
var is_local: bool = false
|
||||
|
||||
var stop_after_current: bool = false
|
||||
var hide_next_track: bool = false
|
||||
var stop_after_current: bool = true
|
||||
var hide_next_track: bool = true
|
||||
var add_to_stats: bool = false
|
||||
var use_low_played_mode: bool = false
|
||||
var winning_score: int = 20
|
||||
var fullscreen: bool = false
|
||||
|
||||
var version: String = "0.9.0-Beta"
|
||||
|
||||
var version: String = "0.7.8-Beta"
|
||||
var whats_new: String = "Changelog:
|
||||
0.9.0-Beta: Fixed settings and updated the player view
|
||||
0.8.0-Beta: Fixed reset buttons and some other small things
|
||||
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 = "Things left to do:
|
||||
Fix reset buttons
|
||||
Fix settings
|
||||
Fix graphics in lists
|
||||
Fix layout
|
||||
Fix for local play
|
||||
@@ -33,28 +34,31 @@ Alt + X = Play/Pause
|
||||
Alt + C = Next Song
|
||||
Alt + V = Show Answer"
|
||||
|
||||
|
||||
#play = X
|
||||
#nästa = c
|
||||
#visa svar = v
|
||||
#lägga till poäng? 1, 2, 3, 4, 5, 6
|
||||
|
||||
|
||||
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()
|
||||
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):
|
||||
if response_code == 200:
|
||||
if !expect_data:
|
||||
func_name.call()
|
||||
else:
|
||||
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 = 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:
|
||||
var request_error = http_request.request(default_path + address)
|
||||
if request_error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ var increase_winning_score_button := $HBoxContainer/IncreaseButton
|
||||
@onready
|
||||
var select_server_button := $SelectServerButton
|
||||
|
||||
@onready
|
||||
var fullscreen_button := $FullscreenButton
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
stop_after_current_button.pressed.connect(stop_after_current)
|
||||
@@ -33,6 +36,7 @@ func _ready():
|
||||
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)
|
||||
fullscreen_button.pressed.connect(fullscreen)
|
||||
|
||||
stop_after_current_button.button_pressed = Settings.stop_after_current
|
||||
hide_next_track_button.button_pressed = Settings.hide_next_track
|
||||
@@ -40,6 +44,13 @@ func _ready():
|
||||
low_played_button.button_pressed = Settings.use_low_played_mode
|
||||
select_server_button.select(Settings.selected_server)
|
||||
|
||||
func fullscreen():
|
||||
Settings.fullscreen = !Settings.fullscreen
|
||||
if Settings.fullscreen == true:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
if Settings.fullscreen == false:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
||||
|
||||
func stop_after_current():
|
||||
Settings.stop_after_current = !Settings.stop_after_current
|
||||
|
||||
|
||||
@@ -78,3 +78,7 @@ 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
|
||||
|
||||
[node name="FullscreenButton" type="CheckButton" parent="."]
|
||||
layout_mode = 2
|
||||
text = "Fullscreen"
|
||||
|
||||
@@ -8,7 +8,7 @@ custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../../ResilioSync/Sorterat/MusicPlayer_0.7.8_Beta.exe"
|
||||
export_path="../../ResilioSync/Sorterat/MusicPlayer_0.9.0_Beta.exe"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
@@ -71,7 +71,7 @@ custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="./MusicPlayer_0.6_Beta.dmg"
|
||||
export_path="./MusicPlayer_0.9_Beta.dmg"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
@@ -79,7 +79,7 @@ encrypt_directory=false
|
||||
|
||||
[preset.1.options]
|
||||
|
||||
export/distribution_type=1
|
||||
export/distribution_type=0
|
||||
binary_format/architecture="universal"
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
|
||||
@@ -24,9 +24,8 @@ Settings="*res://Settings.gd"
|
||||
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1080
|
||||
window/subwindows/embed_subwindows=false
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/aspect="expand"
|
||||
window/energy_saving/keep_screen_on=false
|
||||
window/stretch/mode="viewport"
|
||||
|
||||
[rendering]
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@ func _ready():
|
||||
value_changed.connect(_on_value_changed)
|
||||
value = db_to_linear(AudioServer.get_bus_volume_db(_bus))
|
||||
|
||||
func _on_value_changed(value: float) -> void:
|
||||
AudioServer.set_bus_volume_db(_bus, linear_to_db(value))
|
||||
func _on_value_changed(changed_value: float) -> void:
|
||||
AudioServer.set_bus_volume_db(_bus, linear_to_db(changed_value))
|
||||
|
||||
Reference in New Issue
Block a user