diff options
Diffstat (limited to 'game')
-rw-r--r-- | game/audio/music/Brunels_Waltz_2.mp3.import | 19 | ||||
-rw-r--r-- | game/audio/music/Deliverance.mp3.import | 19 | ||||
-rw-r--r-- | game/audio/music/The_Crown.mp3.import | 19 | ||||
-rw-r--r-- | game/src/GameMenu.tscn | 22 | ||||
-rw-r--r-- | game/src/MusicConductor/MusicConductor.gd | 75 | ||||
-rw-r--r-- | game/src/MusicConductor/MusicConductor.tscn | 4 | ||||
-rw-r--r-- | game/src/MusicConductor/MusicPlayer.gd | 68 | ||||
-rw-r--r-- | game/src/MusicConductor/MusicPlayer.tscn | 61 | ||||
-rw-r--r-- | game/src/MusicConductor/MusicUIController.gd | 66 | ||||
-rw-r--r-- | game/src/MusicConductor/MusicUIController.tscn | 64 | ||||
-rw-r--r-- | game/src/MusicConductor/SongInfo.gd | 12 | ||||
-rw-r--r-- | game/src/OptionMenu/OptionsMenu.tscn | 2 |
12 files changed, 247 insertions, 184 deletions
diff --git a/game/audio/music/Brunels_Waltz_2.mp3.import b/game/audio/music/Brunels_Waltz_2.mp3.import new file mode 100644 index 0000000..bca8e72 --- /dev/null +++ b/game/audio/music/Brunels_Waltz_2.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://jv2gmmla7efh" +path="res://.godot/imported/Brunels_Waltz_2.mp3-9089b7cea8551690620c78deb2f5893e.mp3str" + +[deps] + +source_file="res://audio/music/Brunels_Waltz_2.mp3" +dest_files=["res://.godot/imported/Brunels_Waltz_2.mp3-9089b7cea8551690620c78deb2f5893e.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/game/audio/music/Deliverance.mp3.import b/game/audio/music/Deliverance.mp3.import new file mode 100644 index 0000000..673eba8 --- /dev/null +++ b/game/audio/music/Deliverance.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://b3l1dxak84lmw" +path="res://.godot/imported/Deliverance.mp3-503781482297f95faeb04be77c6c4a8e.mp3str" + +[deps] + +source_file="res://audio/music/Deliverance.mp3" +dest_files=["res://.godot/imported/Deliverance.mp3-503781482297f95faeb04be77c6c4a8e.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/game/audio/music/The_Crown.mp3.import b/game/audio/music/The_Crown.mp3.import new file mode 100644 index 0000000..85dd783 --- /dev/null +++ b/game/audio/music/The_Crown.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://cvlvbcifaif0p" +path="res://.godot/imported/The_Crown.mp3-cac26a6fb3ac34d1dc06e96fb0b873c1.mp3str" + +[deps] + +source_file="res://audio/music/The_Crown.mp3" +dest_files=["res://.godot/imported/The_Crown.mp3-cac26a6fb3ac34d1dc06e96fb0b873c1.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/game/src/GameMenu.tscn b/game/src/GameMenu.tscn index 5493870..f3c55dd 100644 --- a/game/src/GameMenu.tscn +++ b/game/src/GameMenu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://b4pg2y2ivib8f"] +[gd_scene load_steps=9 format=3 uid="uid://o4u142w4qkln"] [ext_resource type="Script" path="res://src/GameMenu.gd" id="1_cafwe"] [ext_resource type="Theme" uid="uid://cr4lh0vraucx7" path="res://default_theme.tres" id="1_q3b4c"] @@ -7,7 +7,7 @@ [ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="4_jno35"] [ext_resource type="PackedScene" uid="uid://c8knthxkwj1uj" path="res://src/Credits/Credits.tscn" id="4_n0hoo"] [ext_resource type="PackedScene" uid="uid://crhkgngfnxf4y" path="res://src/LobbyMenu/LobbyMenu.tscn" id="4_nofk1"] -[ext_resource type="PackedScene" uid="uid://dmnqyvl3qfq2e" path="res://src/MusicConductor/MusicUIController.tscn" id="6_lts1m"] +[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/MusicConductor/MusicPlayer.tscn" id="6_lts1m"] [node name="GameMenu" type="Control"] layout_mode = 3 @@ -23,14 +23,6 @@ script = ExtResource("1_cafwe") layout_mode = 1 metadata/_edit_vertical_guides_ = [251.0, 269.0, 504.0, 523.0, 15.0, 759.0, 777.0] -[node name="MusicUIController" parent="." instance=ExtResource("6_lts1m")] -layout_mode = 1 -anchor_left = 0.843 -anchor_right = 0.953 -offset_left = -0.0400391 -offset_right = 0.159912 -metadata/_edit_use_anchors_ = true - [node name="OptionsMenu" parent="." instance=ExtResource("3_111lv")] visible = false layout_mode = 1 @@ -59,6 +51,16 @@ alignment = 2 [node name="LocaleButton" parent="HBox" instance=ExtResource("4_jno35")] layout_mode = 2 +[node name="MusicPlayer" parent="." instance=ExtResource("6_lts1m")] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -184.0 +offset_right = -34.0 +offset_bottom = 110.0 +grow_horizontal = 0 + [connection signal="credits_button_pressed" from="MainMenu" to="." method="_on_main_menu_credits_button_pressed"] [connection signal="new_game_button_pressed" from="MainMenu" to="." method="_on_main_menu_new_game_button_pressed"] [connection signal="options_button_pressed" from="MainMenu" to="." method="_on_main_menu_options_button_pressed"] diff --git a/game/src/MusicConductor/MusicConductor.gd b/game/src/MusicConductor/MusicConductor.gd index a463d6d..1dfa95d 100644 --- a/game/src/MusicConductor/MusicConductor.gd +++ b/game/src/MusicConductor/MusicConductor.gd @@ -1,68 +1,71 @@ extends Node # SS-67 -@export_dir var musicDir : String -@export_file var firstSongName : String +@export_dir var music_directory : String +@export var first_song_name : String -var selectedTrack = 0 -var availableSongs : Array[SongInfo] = [] -var autoPlayNextSong : bool = true +var _selected_track = 0 +var _available_songs : Array[SongInfo] = [] +var _auto_play_next_song : bool = true -func getAllSongNames() -> Array[String]: +## True if music player should be visible. +## Used to keep keep consistency between scene changes +var is_music_player_visible : bool = true + +func get_all_song_names() -> Array[String]: var songNames : Array[String] = [] - for si in availableSongs: - songNames.append(si.readableName) + for si in _available_songs: + songNames.append(si.song_name) return songNames -func getCurrentSongIndex() -> int: - return selectedTrack +func get_current_song_index() -> int: + return _selected_track -func getCurrentSongName() -> String: - return availableSongs[selectedTrack].readableName +func get_current_song_name() -> String: + return _available_songs[_selected_track].song_name -func scrubSongByPercentage(percentage: float) -> void: +func scrub_song_by_percentage(percentage: float) -> void: var percentInSeconds : float = (percentage / 100.0) * $AudioStreamPlayer.stream.get_length() $AudioStreamPlayer.play(percentInSeconds) -func getCurrentSongProgressPercentage() -> float: +func get_current_song_progress_percentage() -> float: return 100 * ($AudioStreamPlayer.get_playback_position() / $AudioStreamPlayer.stream.get_length()) -func isPaused() -> bool: +func is_paused() -> bool: return $AudioStreamPlayer.stream_paused -func togglePlayPause() -> void: +func toggle_play_pause() -> void: $AudioStreamPlayer.stream_paused = !$AudioStreamPlayer.stream_paused -func startCurrentSong() -> void: - $AudioStreamPlayer.stream = availableSongs[selectedTrack].loadedStream +func start_current_song() -> void: + $AudioStreamPlayer.stream = _available_songs[_selected_track].song_stream $AudioStreamPlayer.play() # SS-70 -func startSongByIndex(id: int) -> void: - selectedTrack = id - startCurrentSong() +func start_song_by_index(id: int) -> void: + _selected_track = id + start_current_song() # SS-69 -func nextSong() -> void: - selectedTrack = (selectedTrack + 1) % len(availableSongs) - startCurrentSong() +func select_next_song() -> void: + _selected_track = (_selected_track + 1) % len(_available_songs) + start_current_song() -func prevSong() -> void: - selectedTrack = (len(availableSongs) - 1) if (selectedTrack == 0) else (selectedTrack - 1) - startCurrentSong() +func select_previous_song() -> void: + _selected_track = (len(_available_songs) - 1) if (_selected_track == 0) else (_selected_track - 1) + start_current_song() -# Called when the node enters the scene tree for the first time. func _ready(): - var dir = DirAccess.open(musicDir) + var dir = DirAccess.open(music_directory) for fname in dir.get_files(): if !fname.ends_with(".import"): - if fname.get_basename() == firstSongName: - selectedTrack = availableSongs.size() - availableSongs.append(SongInfo.new(musicDir, fname)) - startCurrentSong() + if fname.get_basename() == first_song_name: + _selected_track = _available_songs.size() + _available_songs.append(SongInfo.new(music_directory, fname)) + start_current_song() func _on_audio_stream_player_finished(): - if autoPlayNextSong: - nextSong() - startCurrentSong() + if _auto_play_next_song: + select_next_song() + start_current_song() diff --git a/game/src/MusicConductor/MusicConductor.tscn b/game/src/MusicConductor/MusicConductor.tscn index 69529d8..7194f0b 100644 --- a/game/src/MusicConductor/MusicConductor.tscn +++ b/game/src/MusicConductor/MusicConductor.tscn @@ -4,8 +4,8 @@ [node name="MusicConductor" type="Node"] script = ExtResource("1_56t1b") -musicDir = "res://audio/music/" -firstSongName = "The_Crown" +music_directory = "res://audio/music" +first_song_name = "The_Crown" [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] bus = &"Music" diff --git a/game/src/MusicConductor/MusicPlayer.gd b/game/src/MusicConductor/MusicPlayer.gd new file mode 100644 index 0000000..baf8a43 --- /dev/null +++ b/game/src/MusicConductor/MusicPlayer.gd @@ -0,0 +1,68 @@ +extends Control + +@export var _song_selector_button : OptionButton +@export var _progress_slider : HSlider +@export var _previous_song_button : Button +@export var _play_pause_button : Button +@export var _next_song_button : Button +@export var _visbility_button : Button + +var _is_user_dragging_progress_slider : bool = false + +func _ready(): + for songName in MusicConductor.get_all_song_names(): + _song_selector_button.add_item(songName, _song_selector_button.item_count) + _update_song_name_visual() + _update_play_pause_button() + _set_music_player_visible(MusicConductor.is_music_player_visible) + + +func _process(_delta): + if !_is_user_dragging_progress_slider: + _progress_slider.value = MusicConductor.get_current_song_progress_percentage() + +func _update_song_name_visual(): + _song_selector_button.selected = MusicConductor.get_current_song_index() + +func _update_play_pause_button(): + _play_pause_button.text = "◼" if MusicConductor.is_paused() else "▶" + +func _on_play_pause_button_pressed(): + MusicConductor.toggle_play_pause() + _update_play_pause_button() + +func _on_next_song_button_pressed(): + MusicConductor.select_next_song() + _update_song_name_visual() + _update_play_pause_button() + +func _on_previous_song_button_pressed(): + MusicConductor.select_previous_song() + _update_song_name_visual() + _update_play_pause_button() + +func _on_option_button_item_selected(index): + # UIFUN-92 + MusicConductor.start_song_by_index(index) + + +func _on_progress_slider_drag_started(): + _is_user_dragging_progress_slider = true + + +func _on_progress_slider_drag_ended(_value_changed): + MusicConductor.scrub_song_by_percentage(_progress_slider.value) + _is_user_dragging_progress_slider = false + _update_play_pause_button() + +func _set_music_player_visible(is_player_visible : bool) -> void: + MusicConductor.is_music_player_visible = is_player_visible + _visbility_button.text = "⬆️" if is_player_visible else "⬇" + _song_selector_button.visible = is_player_visible + _progress_slider.visible = is_player_visible + _previous_song_button.visible = is_player_visible + _play_pause_button.visible = is_player_visible + _next_song_button.visible = is_player_visible + +func _on_music_ui_visibility_button_pressed(): + _set_music_player_visible(not MusicConductor.is_music_player_visible) diff --git a/game/src/MusicConductor/MusicPlayer.tscn b/game/src/MusicConductor/MusicPlayer.tscn new file mode 100644 index 0000000..91b6fd3 --- /dev/null +++ b/game/src/MusicConductor/MusicPlayer.tscn @@ -0,0 +1,61 @@ +[gd_scene load_steps=2 format=3 uid="uid://cvl76duuym1wq"] + +[ext_resource type="Script" path="res://src/MusicConductor/MusicPlayer.gd" id="1_gcm4m"] + +[node name="MusicPlayer" type="BoxContainer" node_paths=PackedStringArray("_song_selector_button", "_progress_slider", "_previous_song_button", "_play_pause_button", "_next_song_button", "_visbility_button")] +editor_description = "UI-104" +mouse_filter = 2 +script = ExtResource("1_gcm4m") +_song_selector_button = NodePath("Control/SongSelectorButton") +_progress_slider = NodePath("Control/ProgressSlider") +_previous_song_button = NodePath("Control/HBoxContainer/PreviousSongButton") +_play_pause_button = NodePath("Control/HBoxContainer/PlayPauseButton") +_next_song_button = NodePath("Control/HBoxContainer/NextSongButton") +_visbility_button = NodePath("Control/MusicUIVisibilityButton") + +[node name="Control" type="VBoxContainer" parent="."] +custom_minimum_size = Vector2(150, 0) +layout_mode = 2 +mouse_filter = 2 + +[node name="SongSelectorButton" type="OptionButton" parent="Control"] +editor_description = "UI-107" +layout_mode = 2 +alignment = 1 +text_overrun_behavior = 3 +fit_to_longest_item = false + +[node name="ProgressSlider" type="HSlider" parent="Control"] +layout_mode = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="Control"] +layout_mode = 2 +size_flags_horizontal = 4 +mouse_filter = 2 + +[node name="PreviousSongButton" type="Button" parent="Control/HBoxContainer"] +layout_mode = 2 +text = "<" + +[node name="PlayPauseButton" type="Button" parent="Control/HBoxContainer"] +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +text = "▶" + +[node name="NextSongButton" type="Button" parent="Control/HBoxContainer"] +layout_mode = 2 +text = ">" + +[node name="MusicUIVisibilityButton" type="Button" parent="Control"] +editor_description = "UI-106" +layout_mode = 2 +size_flags_horizontal = 4 +text = "⬆" + +[connection signal="item_selected" from="Control/SongSelectorButton" to="." method="_on_option_button_item_selected"] +[connection signal="drag_ended" from="Control/ProgressSlider" to="." method="_on_progress_slider_drag_ended"] +[connection signal="drag_started" from="Control/ProgressSlider" to="." method="_on_progress_slider_drag_started"] +[connection signal="pressed" from="Control/HBoxContainer/PreviousSongButton" to="." method="_on_previous_song_button_pressed"] +[connection signal="pressed" from="Control/HBoxContainer/PlayPauseButton" to="." method="_on_play_pause_button_pressed"] +[connection signal="pressed" from="Control/HBoxContainer/NextSongButton" to="." method="_on_next_song_button_pressed"] +[connection signal="pressed" from="Control/MusicUIVisibilityButton" to="." method="_on_music_ui_visibility_button_pressed"] diff --git a/game/src/MusicConductor/MusicUIController.gd b/game/src/MusicConductor/MusicUIController.gd deleted file mode 100644 index f2c9225..0000000 --- a/game/src/MusicConductor/MusicUIController.gd +++ /dev/null @@ -1,66 +0,0 @@ -extends Control - -@export var songSelectorButton : OptionButton -@export var progressSlider : HSlider -@export var prevSongButton : Button -@export var playPauseButton : Button -@export var nextSongButton : Button -@export var widgetVisibilityButton : Button - -var isMusicPlayerVisible : bool = true -var isUserDraggingProgressSlider : bool = false - -# Called when the node enters the scene tree for the first time. -func _ready(): - for songName in MusicConductor.getAllSongNames(): - songSelectorButton.add_item(songName, songSelectorButton.item_count) - updateSongNameVisual() - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(_delta): - if !isUserDraggingProgressSlider: - progressSlider.value = MusicConductor.getCurrentSongProgressPercentage() - -func updateSongNameVisual(): - songSelectorButton.selected = MusicConductor.getCurrentSongIndex() - -func updatePlayPauseButtonVisual(): - playPauseButton.text = "||" if MusicConductor.isPaused() else ">" - -func _on_play_pause_button_pressed(): - MusicConductor.togglePlayPause() - updatePlayPauseButtonVisual() - -func _on_next_song_button_pressed(): - MusicConductor.nextSong() - updateSongNameVisual() - updatePlayPauseButtonVisual() - -func _on_previous_song_button_pressed(): - MusicConductor.prevSong() - updateSongNameVisual() - updatePlayPauseButtonVisual() - -func _on_option_button_item_selected(index): - # UIFUN-92 - MusicConductor.startSongByIndex(index) - - -func _on_progress_slider_drag_started(): - isUserDraggingProgressSlider = true - - -func _on_progress_slider_drag_ended(_value_changed): - MusicConductor.scrubSongByPercentage(progressSlider.value) - isUserDraggingProgressSlider = false - updatePlayPauseButtonVisual() - -func _on_music_ui_visibility_button_pressed(): - isMusicPlayerVisible = !isMusicPlayerVisible - widgetVisibilityButton.text = "Hide Player" if isMusicPlayerVisible else "Show Player" - songSelectorButton.visible = isMusicPlayerVisible - progressSlider.visible = isMusicPlayerVisible - prevSongButton.visible = isMusicPlayerVisible - playPauseButton.visible = isMusicPlayerVisible - nextSongButton.visible = isMusicPlayerVisible diff --git a/game/src/MusicConductor/MusicUIController.tscn b/game/src/MusicConductor/MusicUIController.tscn deleted file mode 100644 index 49ea355..0000000 --- a/game/src/MusicConductor/MusicUIController.tscn +++ /dev/null @@ -1,64 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dmnqyvl3qfq2e"] - -[ext_resource type="Script" path="res://src/MusicConductor/MusicUIController.gd" id="1_u4qbn"] - -[node name="MusicUIController" type="Control" node_paths=PackedStringArray("songSelectorButton", "progressSlider", "prevSongButton", "playPauseButton", "nextSongButton", "widgetVisibilityButton")] -editor_description = "UI-104" -layout_mode = 3 -anchor_right = 0.11 -anchor_bottom = 0.165 -offset_right = 0.199997 -offset_bottom = 0.199997 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_u4qbn") -songSelectorButton = NodePath("VBoxContainer/SongSelectorButton") -progressSlider = NodePath("VBoxContainer/ProgressSlider") -prevSongButton = NodePath("VBoxContainer/HBoxContainer/PreviousSongButton") -playPauseButton = NodePath("VBoxContainer/HBoxContainer/PlayPauseButton") -nextSongButton = NodePath("VBoxContainer/HBoxContainer/NextSongButton") -widgetVisibilityButton = NodePath("VBoxContainer/MusicUIVisibilityButton") - -[node name="VBoxContainer" type="VBoxContainer" parent="."] -layout_mode = 0 -offset_right = 40.0 -offset_bottom = 40.0 - -[node name="SongSelectorButton" type="OptionButton" parent="VBoxContainer"] -editor_description = "UI-107" -layout_mode = 2 - -[node name="ProgressSlider" type="HSlider" parent="VBoxContainer"] -layout_mode = 2 - -[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] -layout_mode = 2 -size_flags_horizontal = 4 - -[node name="PreviousSongButton" type="Button" parent="VBoxContainer/HBoxContainer"] -layout_mode = 2 -text = "Prev" - -[node name="PlayPauseButton" type="Button" parent="VBoxContainer/HBoxContainer"] -custom_minimum_size = Vector2(30, 0) -layout_mode = 2 -text = ">" - -[node name="NextSongButton" type="Button" parent="VBoxContainer/HBoxContainer"] -layout_mode = 2 -text = "Next" - -[node name="MusicUIVisibilityButton" type="Button" parent="VBoxContainer"] -editor_description = "UI-106" -layout_mode = 2 -size_flags_horizontal = 4 -size_flags_vertical = 3 -text = "Hide Player" - -[connection signal="item_selected" from="VBoxContainer/SongSelectorButton" to="." method="_on_option_button_item_selected"] -[connection signal="drag_ended" from="VBoxContainer/ProgressSlider" to="." method="_on_progress_slider_drag_ended"] -[connection signal="drag_started" from="VBoxContainer/ProgressSlider" to="." method="_on_progress_slider_drag_started"] -[connection signal="pressed" from="VBoxContainer/HBoxContainer/PreviousSongButton" to="." method="_on_previous_song_button_pressed"] -[connection signal="pressed" from="VBoxContainer/HBoxContainer/PlayPauseButton" to="." method="_on_play_pause_button_pressed"] -[connection signal="pressed" from="VBoxContainer/HBoxContainer/NextSongButton" to="." method="_on_next_song_button_pressed"] -[connection signal="pressed" from="VBoxContainer/MusicUIVisibilityButton" to="." method="_on_music_ui_visibility_button_pressed"] diff --git a/game/src/MusicConductor/SongInfo.gd b/game/src/MusicConductor/SongInfo.gd index 85ef96a..f7343c0 100644 --- a/game/src/MusicConductor/SongInfo.gd +++ b/game/src/MusicConductor/SongInfo.gd @@ -1,11 +1,11 @@ extends Node class_name SongInfo -var fullyQualifiedPath : String = "" -var readableName : String = "" -var loadedStream : Resource +var song_path : String = "" +var song_name : String = "" +var song_stream : Resource func _init(dirname:String, fname:String): - fullyQualifiedPath = dirname + fname - readableName = fname.get_basename().replace("_", " ") - loadedStream = load(fullyQualifiedPath) + song_path = dirname.path_join(fname) + song_name = fname.get_basename().replace("_", " ") + song_stream = load(song_path) diff --git a/game/src/OptionMenu/OptionsMenu.tscn b/game/src/OptionMenu/OptionsMenu.tscn index bdb80f1..10d92b5 100644 --- a/game/src/OptionMenu/OptionsMenu.tscn +++ b/game/src/OptionMenu/OptionsMenu.tscn @@ -15,6 +15,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 script = ExtResource("1_tlein") [node name="Margin" type="MarginContainer" parent="."] @@ -24,6 +25,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 theme_override_constants/margin_left = 250 theme_override_constants/margin_top = 100 theme_override_constants/margin_right = 250 |