Compare commits
1 commit
main
...
bidouille_
Author | SHA1 | Date | |
---|---|---|---|
|
0022689393 |
3 changed files with 68 additions and 50 deletions
|
@ -5,27 +5,49 @@ var current_song = ""
|
||||||
var current_position = 0.0
|
var current_position = 0.0
|
||||||
var popup
|
var popup
|
||||||
|
|
||||||
func _ready():
|
var musics_path = 'res://assets/musics/'
|
||||||
for song in $Songs.get_children():
|
|
||||||
songs_list.append( song.name )
|
|
||||||
if $Songs.get_child_count() > 0:
|
|
||||||
current_song = songs_list[0]
|
|
||||||
|
|
||||||
|
func list_music_files_in_directory(path):
|
||||||
|
var files = []
|
||||||
|
var dir = Directory.new()
|
||||||
|
dir.open(path)
|
||||||
|
dir.list_dir_begin()
|
||||||
|
|
||||||
|
while true:
|
||||||
|
var file = dir.get_next()
|
||||||
|
if file == "":
|
||||||
|
break
|
||||||
|
elif not file.begins_with(".") and file.ends_with( '.ogg' ):
|
||||||
|
files.append(file.left(file.length()-4))
|
||||||
|
|
||||||
|
dir.list_dir_end()
|
||||||
|
|
||||||
|
return files
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var music_files = list_music_files_in_directory( musics_path )
|
||||||
|
|
||||||
popup = $SongsSelector.get_popup()
|
popup = $SongsSelector.get_popup()
|
||||||
for song in songs_list:
|
for song in music_files:
|
||||||
|
|
||||||
|
var stream = AudioStreamPlayer.new()
|
||||||
|
stream.name = song
|
||||||
|
stream.stream = load( musics_path+song+".ogg" )
|
||||||
|
stream.connect( "finished", self, "_on_song_finished" )
|
||||||
|
$Songs.add_child( stream )
|
||||||
|
|
||||||
popup.add_item( song )
|
popup.add_item( song )
|
||||||
get_node( "Songs" ).get_node( song ).connect( "finished", self, "_on_song_finished" )
|
|
||||||
$SongsSelector.text = current_song
|
$SongsSelector.text = current_song
|
||||||
|
|
||||||
func set_play():
|
func set_play():
|
||||||
if get_node( "Songs" ).get_node( current_song ):
|
if not current_song == "" and get_node( "Songs" ).get_node( current_song ):
|
||||||
get_node( "Songs" ).get_node( current_song ).play( current_position )
|
get_node( "Songs" ).get_node( current_song ).play( current_position )
|
||||||
$Buttons/Pause.text = "Pause"
|
$Buttons/Pause.text = "Pause"
|
||||||
$Title.text = "Musiques (Played):"
|
$Title.text = "Musiques (Played):"
|
||||||
|
|
||||||
func set_pause():
|
func set_pause():
|
||||||
if get_node( "Songs" ).get_node( current_song ):
|
if not current_song == "" and get_node( "Songs" ).get_node( current_song ):
|
||||||
current_position = get_node( "Songs" ).get_node( current_song ).get_playback_position()
|
current_position = get_node( "Songs" ).get_node( current_song ).get_playback_position()
|
||||||
get_node( "Songs" ).get_node( current_song ).stop()
|
get_node( "Songs" ).get_node( current_song ).stop()
|
||||||
else:
|
else:
|
||||||
|
@ -35,7 +57,7 @@ func set_pause():
|
||||||
$Title.text = "Musiques (Paused):"
|
$Title.text = "Musiques (Paused):"
|
||||||
|
|
||||||
func set_stop():
|
func set_stop():
|
||||||
if get_node( "Songs" ).get_node( current_song ):
|
if not current_song == "" and get_node( "Songs" ).get_node( current_song ):
|
||||||
get_node( "Songs" ).get_node( current_song ).stop()
|
get_node( "Songs" ).get_node( current_song ).stop()
|
||||||
current_position = 0.0
|
current_position = 0.0
|
||||||
$Buttons/Pause.pressed = false
|
$Buttons/Pause.pressed = false
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://gui_scene/GUI/MusicControls/Music.gd" type="Script" id=1]
|
[ext_resource path="res://gui_scene/GUI/MusicControls/Music.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://assets/test/musiques/pre-mix_khanat_main_theme_2018-07-23.ogg" type="AudioStream" id=2]
|
|
||||||
[ext_resource path="res://assets/test/musiques/Sangakanat (short instrumental theme).ogg" type="AudioStream" id=3]
|
|
||||||
[ext_resource path="res://assets/test/musiques/pre-mix_Le_concours_de_tartes_aux_klums.ogg" type="AudioStream" id=4]
|
|
||||||
|
|
||||||
|
[node name="Music" type="VBoxContainer" index="0"]
|
||||||
[node name="Music" type="VBoxContainer"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
|
@ -39,37 +35,6 @@ size_flags_horizontal = 1
|
||||||
size_flags_vertical = 1
|
size_flags_vertical = 1
|
||||||
_sections_unfolded = [ "Mouse" ]
|
_sections_unfolded = [ "Mouse" ]
|
||||||
|
|
||||||
[node name="pre-mix_khanat_main_theme" type="AudioStreamPlayer" parent="Songs" index="0"]
|
|
||||||
|
|
||||||
pause_mode = 1
|
|
||||||
stream = ExtResource( 2 )
|
|
||||||
volume_db = 0.0
|
|
||||||
pitch_scale = 1.0
|
|
||||||
autoplay = false
|
|
||||||
mix_target = 0
|
|
||||||
bus = "Master"
|
|
||||||
_sections_unfolded = [ "Pause" ]
|
|
||||||
|
|
||||||
[node name="Sangakanat" type="AudioStreamPlayer" parent="Songs" index="1"]
|
|
||||||
|
|
||||||
pause_mode = 1
|
|
||||||
stream = ExtResource( 3 )
|
|
||||||
volume_db = 0.0
|
|
||||||
pitch_scale = 1.0
|
|
||||||
autoplay = false
|
|
||||||
mix_target = 0
|
|
||||||
bus = "Master"
|
|
||||||
_sections_unfolded = [ "Pause" ]
|
|
||||||
|
|
||||||
[node name="pre-mix_Le_concours_de_tartes_aux_klums" type="AudioStreamPlayer" parent="Songs" index="2"]
|
|
||||||
|
|
||||||
stream = ExtResource( 4 )
|
|
||||||
volume_db = 0.0
|
|
||||||
pitch_scale = 1.0
|
|
||||||
autoplay = false
|
|
||||||
mix_target = 0
|
|
||||||
bus = "Master"
|
|
||||||
|
|
||||||
[node name="Title" type="Label" parent="." index="1"]
|
[node name="Title" type="Label" parent="." index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
|
|
|
@ -145,7 +145,7 @@ anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_top = 65.0
|
margin_top = 65.0
|
||||||
margin_right = 638.0
|
margin_right = 638.0
|
||||||
margin_bottom = 285.0
|
margin_bottom = 334.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
|
@ -167,7 +167,7 @@ anchor_bottom = 0.0
|
||||||
margin_left = 32.0
|
margin_left = 32.0
|
||||||
margin_top = 32.0
|
margin_top = 32.0
|
||||||
margin_right = 606.0
|
margin_right = 606.0
|
||||||
margin_bottom = 220.0
|
margin_bottom = 269.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
|
@ -180,6 +180,7 @@ _sections_unfolded = [ "Margin", "custom_constants" ]
|
||||||
|
|
||||||
[node name="email_box" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container/login_box" index="0"]
|
[node name="email_box" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container/login_box" index="0"]
|
||||||
|
|
||||||
|
editor/display_folded = true
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
|
@ -288,6 +289,7 @@ _sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors",
|
||||||
|
|
||||||
[node name="password_box" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container/login_box" index="1"]
|
[node name="password_box" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container/login_box" index="1"]
|
||||||
|
|
||||||
|
editor/display_folded = true
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
|
@ -398,6 +400,7 @@ _sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors",
|
||||||
|
|
||||||
[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/margin_container/login_box" index="2"]
|
[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/margin_container/login_box" index="2"]
|
||||||
|
|
||||||
|
editor/display_folded = true
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
|
@ -514,10 +517,38 @@ flat = false
|
||||||
align = 1
|
align = 1
|
||||||
_sections_unfolded = [ "Margin", "Material", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts" ]
|
_sections_unfolded = [ "Margin", "Material", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts" ]
|
||||||
|
|
||||||
|
[node name="login_button" type="Button" parent="h_box_container/v_box_container/margin_container/login_box" index="3"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_top = 204.0
|
||||||
|
margin_right = 574.0
|
||||||
|
margin_bottom = 237.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
hint_tooltip = "for testing/debug."
|
||||||
|
focus_mode = 2
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
toggle_mode = false
|
||||||
|
enabled_focus_mode = 2
|
||||||
|
shortcut = null
|
||||||
|
group = null
|
||||||
|
text = "continue without login"
|
||||||
|
flat = false
|
||||||
|
align = 1
|
||||||
|
_sections_unfolded = [ "Hint" ]
|
||||||
|
|
||||||
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
|
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
|
||||||
|
|
||||||
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/login_box/email_box/email_label_box/register_button" to="." method="_on_register_button_pressed"]
|
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/login_box/email_box/email_label_box/register_button" to="." method="_on_register_button_pressed"]
|
||||||
|
|
||||||
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/login_box/h_box_container/play_button" to="." method="_on_play_button_pressed"]
|
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/login_box/h_box_container/play_button" to="." method="_on_play_button_pressed"]
|
||||||
|
|
||||||
|
[connection signal="pressed" from="h_box_container/v_box_container/margin_container/login_box/login_button" to="." method="_on_login_button_pressed"]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue