Added volume bar and song list and refactored character select
This commit is contained in:
44
CharacterSelect.gd
Normal file
44
CharacterSelect.gd
Normal file
@@ -0,0 +1,44 @@
|
||||
extends Control
|
||||
|
||||
@onready
|
||||
var character_grid_container := $ScrollContainer2
|
||||
|
||||
@onready
|
||||
var character_grid := $ScrollContainer2/GridContainer
|
||||
|
||||
signal character_selected(file_name)
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
var characters := DirAccess.open("res://characters/")
|
||||
if characters:
|
||||
characters.list_dir_begin()
|
||||
var file_name = characters.get_next()
|
||||
while file_name != "":
|
||||
if !file_name.ends_with(".import"):
|
||||
|
||||
var texture = load("res://characters/" + file_name)
|
||||
|
||||
var texture_btn := TextureButton.new()
|
||||
|
||||
character_grid.add_child(texture_btn)
|
||||
texture_btn.custom_minimum_size = Vector2(80, 40)
|
||||
texture_btn.ignore_texture_size = true
|
||||
texture_btn.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT
|
||||
texture_btn.texture_normal = texture
|
||||
|
||||
texture_btn.pressed.connect(select_character.bind(file_name))
|
||||
|
||||
file_name = characters.get_next()
|
||||
|
||||
func show_grid():
|
||||
character_grid_container.visible = true
|
||||
|
||||
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
|
||||
25
CharacterSelect.tscn
Normal file
25
CharacterSelect.tscn
Normal file
@@ -0,0 +1,25 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://b16on0oscg1bv"]
|
||||
|
||||
[ext_resource type="Script" path="res://CharacterSelect.gd" id="1_4bba6"]
|
||||
|
||||
[node name="CharacterSelect" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("1_4bba6")
|
||||
|
||||
[node name="ScrollContainer2" type="ScrollContainer" parent="."]
|
||||
clip_contents = false
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 0
|
||||
offset_left = 194.0
|
||||
offset_top = 152.0
|
||||
offset_right = 670.0
|
||||
offset_bottom = 375.0
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="ScrollContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
columns = 3
|
||||
@@ -10,13 +10,10 @@ var fileDialog := $FileDialog
|
||||
var list := $ScrollContainer/VBoxContainer
|
||||
|
||||
@onready
|
||||
var game_label := $GameLabel
|
||||
var game_label := $VBoxContainer/GameLabel
|
||||
|
||||
@onready
|
||||
var character_grid_container := $ScrollContainer2
|
||||
|
||||
@onready
|
||||
var character_grid := $ScrollContainer2/GridContainer
|
||||
var song_label := $VBoxContainer/SongLabel
|
||||
|
||||
@onready
|
||||
var play_button := $PanelContainer/HBoxContainer/PlayButton
|
||||
@@ -39,9 +36,18 @@ var label := $PanelContainer/HBoxContainer/Label
|
||||
@onready
|
||||
var add_player := $Players/VBoxContainer/HBoxContainer/AddPlayer
|
||||
|
||||
@onready
|
||||
var test := $Button4
|
||||
|
||||
@onready
|
||||
var music_list := $MusicListPanel/ScrollContainer/MusicList
|
||||
|
||||
@onready
|
||||
var players := $Players/VBoxContainer
|
||||
|
||||
@onready
|
||||
var character_select := $CharacterSelect
|
||||
|
||||
var Player := preload("res://Player.tscn")
|
||||
|
||||
@onready
|
||||
@@ -69,36 +75,13 @@ func _ready():
|
||||
stop_button.pressed.connect(stop)
|
||||
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()
|
||||
|
||||
var characters := DirAccess.open("res://characters/")
|
||||
if characters:
|
||||
characters.list_dir_begin()
|
||||
var file_name = characters.get_next()
|
||||
while file_name != "":
|
||||
if !file_name.ends_with(".import"):
|
||||
|
||||
var texture = load("res://characters/" + file_name)
|
||||
|
||||
var texture_btn := TextureButton.new()
|
||||
|
||||
character_grid.add_child(texture_btn)
|
||||
texture_btn.custom_minimum_size = Vector2(80, 40)
|
||||
texture_btn.ignore_texture_size = true
|
||||
texture_btn.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT
|
||||
texture_btn.texture_normal = texture
|
||||
|
||||
texture_btn.pressed.connect(select_character.bind(file_name))
|
||||
|
||||
file_name = characters.get_next()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func fetched():
|
||||
var http_request = HTTPRequest.new()
|
||||
@@ -110,6 +93,16 @@ func fetched():
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
var http_request2 = HTTPRequest.new()
|
||||
add_child(http_request2)
|
||||
http_request2.request_completed.connect(show_fetched_list)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var error2 = http_request2.request("https://music.sanplex.tech/music/list")
|
||||
if error2 != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
|
||||
func show_fetched(result, response_code, headers, body) -> void:
|
||||
var json = JSON.new()
|
||||
var error = json.parse(body.get_string_from_utf8())
|
||||
@@ -118,6 +111,28 @@ func show_fetched(result, response_code, headers, body) -> void:
|
||||
var data_received = json.get_data()
|
||||
print("data_received: ", data_received)
|
||||
game_label.text = data_received.Game
|
||||
song_label.text = data_received.Song
|
||||
|
||||
var song_list = []
|
||||
func show_fetched_list(result, response_code, headers, body) -> void:
|
||||
var json = JSON.new()
|
||||
var error = json.parse(body.get_string_from_utf8())
|
||||
|
||||
if error == OK:
|
||||
var data_received = json.get_data()
|
||||
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()
|
||||
var format_string = "%d. %s - %s"
|
||||
var actual_string = format_string % [(song.SongNo+1), song.Game, song.Song]
|
||||
label.text = actual_string
|
||||
music_list.add_child(label)
|
||||
else:
|
||||
print("Unexpected data")
|
||||
#/music_list
|
||||
|
||||
# Called when the HTTP request is completed.
|
||||
func _http_request_completed(result, response_code, headers, body):
|
||||
@@ -287,9 +302,15 @@ var current_player
|
||||
func _on_player_change_character_clicked(new_player):
|
||||
print("_on_player_change_character_clicked")
|
||||
current_player = new_player
|
||||
character_grid_container.visible = true
|
||||
character_select.visible = true
|
||||
|
||||
func select_character(file_name: String):
|
||||
print("select_character")
|
||||
character_grid_container.visible = false
|
||||
func _on_character_selected(file_name: String):
|
||||
print("_on_character_selected")
|
||||
character_select.visible = false
|
||||
current_player._on_control_character_selected_clicked(file_name)
|
||||
|
||||
|
||||
static func delete_children(node):
|
||||
for n in node.get_children():
|
||||
node.remove_child(n)
|
||||
n.queue_free()
|
||||
|
||||
150
MainWindow.tscn
150
MainWindow.tscn
@@ -1,9 +1,17 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://xwq863o6uvsu"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://xwq863o6uvsu"]
|
||||
|
||||
[ext_resource type="Script" path="res://MainWindow.gd" id="1_eu0t5"]
|
||||
[ext_resource type="PackedScene" uid="uid://b16on0oscg1bv" path="res://CharacterSelect.tscn" id="2_76kf4"]
|
||||
[ext_resource type="PackedScene" uid="uid://w400rnew7453" path="res://volume_slider.tscn" id="3_rxhba"]
|
||||
[ext_resource type="AudioStream" uid="uid://n2g8jddr85h2" path="res://01. Opening.mp3" id="4_5kvsq"]
|
||||
[ext_resource type="Texture2D" uid="uid://o5go6smk7hm1" path="res://person_add_alt_1-black-36dp.svg" id="4_op458"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_qspbu"]
|
||||
font_size = 70
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_3m52w"]
|
||||
font_size = 50
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
@@ -11,10 +19,10 @@ script = ExtResource("1_eu0t5")
|
||||
|
||||
[node name="Open" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
offset_left = 106.0
|
||||
offset_top = 438.0
|
||||
offset_right = 156.0
|
||||
offset_bottom = 469.0
|
||||
offset_left = 65.0
|
||||
offset_top = 877.0
|
||||
offset_right = 115.0
|
||||
offset_bottom = 908.0
|
||||
text = "Open"
|
||||
|
||||
[node name="FileDialog" type="FileDialog" parent="."]
|
||||
@@ -28,10 +36,10 @@ show_hidden_files = true
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 690.0
|
||||
offset_top = 25.0
|
||||
offset_right = 1060.0
|
||||
offset_bottom = 314.0
|
||||
offset_left = 1204.0
|
||||
offset_top = 17.0
|
||||
offset_right = 1771.0
|
||||
offset_bottom = 465.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"]
|
||||
layout_mode = 2
|
||||
@@ -45,35 +53,36 @@ text = "Test
|
||||
layout_mode = 2
|
||||
text = "Test2"
|
||||
|
||||
[node name="GameLabel" type="Label" parent="."]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 143.0
|
||||
offset_top = 141.0
|
||||
offset_right = 557.0
|
||||
offset_bottom = 253.0
|
||||
offset_left = 52.0
|
||||
offset_top = 64.0
|
||||
offset_right = 977.0
|
||||
offset_bottom = 368.0
|
||||
|
||||
[node name="ScrollContainer2" type="ScrollContainer" parent="."]
|
||||
visible = false
|
||||
clip_contents = false
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 0
|
||||
offset_left = 194.0
|
||||
offset_top = 152.0
|
||||
offset_right = 670.0
|
||||
offset_bottom = 375.0
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="ScrollContainer2"]
|
||||
[node name="GameLabel" type="Label" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
columns = 3
|
||||
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
|
||||
|
||||
[node name="CharacterSelect" parent="." instance=ExtResource("2_76kf4")]
|
||||
visible = false
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 110.0
|
||||
offset_top = 485.0
|
||||
offset_right = 758.0
|
||||
offset_bottom = 525.0
|
||||
offset_left = 69.0
|
||||
offset_top = 924.0
|
||||
offset_right = 955.0
|
||||
offset_bottom = 964.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
@@ -101,15 +110,23 @@ scrollable = false
|
||||
layout_mode = 2
|
||||
text = "1:00 / 3:00"
|
||||
|
||||
[node name="VolumeSlider" parent="." instance=ExtResource("3_rxhba")]
|
||||
layout_mode = 0
|
||||
offset_left = 983.0
|
||||
offset_top = 916.0
|
||||
offset_right = 1214.0
|
||||
offset_bottom = 955.0
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("4_5kvsq")
|
||||
bus = &"music"
|
||||
|
||||
[node name="Players" type="PanelContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 837.0
|
||||
offset_top = 264.0
|
||||
offset_right = 1102.0
|
||||
offset_bottom = 453.0
|
||||
offset_left = 1283.0
|
||||
offset_top = 642.0
|
||||
offset_right = 1820.0
|
||||
offset_bottom = 1003.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Players"]
|
||||
layout_mode = 2
|
||||
@@ -128,4 +145,65 @@ layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
texture_normal = ExtResource("4_op458")
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 125.0
|
||||
offset_top = 1017.0
|
||||
offset_right = 236.0
|
||||
offset_bottom = 1048.0
|
||||
text = "Reset playlist"
|
||||
|
||||
[node name="Button2" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 247.0
|
||||
offset_top = 1018.0
|
||||
offset_right = 358.0
|
||||
offset_bottom = 1049.0
|
||||
text = "Reset points"
|
||||
|
||||
[node name="Button3" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 370.0
|
||||
offset_top = 1016.0
|
||||
offset_right = 481.0
|
||||
offset_bottom = 1047.0
|
||||
text = "Sync games"
|
||||
|
||||
[node name="Button4" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 491.0
|
||||
offset_top = 1016.0
|
||||
offset_right = 602.0
|
||||
offset_bottom = 1047.0
|
||||
text = "Sound test"
|
||||
|
||||
[node name="Button5" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 611.0
|
||||
offset_top = 1016.0
|
||||
offset_right = 722.0
|
||||
offset_bottom = 1047.0
|
||||
text = "Show answer"
|
||||
|
||||
[node name="Button6" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 729.0
|
||||
offset_top = 1017.0
|
||||
offset_right = 904.0
|
||||
offset_bottom = 1048.0
|
||||
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
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="MusicListPanel"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MusicList" type="VBoxContainer" parent="MusicListPanel/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[connection signal="dir_selected" from="FileDialog" to="." method="_on_file_dialog_dir_selected"]
|
||||
|
||||
10
default_bus_layout.tres
Normal file
10
default_bus_layout.tres
Normal file
@@ -0,0 +1,10 @@
|
||||
[gd_resource type="AudioBusLayout" format=3 uid="uid://fh6m2mrhi2q6"]
|
||||
|
||||
[resource]
|
||||
bus/0/volume_db = -0.0327297
|
||||
bus/1/name = &"music"
|
||||
bus/1/solo = false
|
||||
bus/1/mute = false
|
||||
bus/1/bypass_fx = false
|
||||
bus/1/volume_db = 0.0
|
||||
bus/1/send = &"Master"
|
||||
@@ -18,6 +18,8 @@ config/icon="res://icon.svg"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1080
|
||||
window/subwindows/embed_subwindows=false
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
15
volume_slider.gd
Normal file
15
volume_slider.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
extends HSlider
|
||||
|
||||
@export
|
||||
var audio_bus_name := "music"
|
||||
|
||||
@onready
|
||||
var _bus: int
|
||||
|
||||
func _ready():
|
||||
_bus = AudioServer.get_bus_index(audio_bus_name)
|
||||
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))
|
||||
10
volume_slider.tscn
Normal file
10
volume_slider.tscn
Normal file
@@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://w400rnew7453"]
|
||||
|
||||
[ext_resource type="Script" path="res://volume_slider.gd" id="1_1aufb"]
|
||||
|
||||
[node name="VolumeSlider" type="HSlider"]
|
||||
offset_right = 8.0
|
||||
offset_bottom = 16.0
|
||||
max_value = 1.0
|
||||
step = 0.001
|
||||
script = ExtResource("1_1aufb")
|
||||
Reference in New Issue
Block a user