mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 08:45:33 +00:00
Music room music playing
This commit is contained in:
parent
67d7986330
commit
766b04b2ff
9 changed files with 129 additions and 86 deletions
|
|
@ -7,6 +7,7 @@
|
|||
script = ExtResource("1_xdwi3")
|
||||
TrackName = "No Reason"
|
||||
AuthorName = "Fenekhu"
|
||||
Description = "This is a song, it's meant to mean things"
|
||||
ShowAuthor = false
|
||||
Track = ExtResource("1_u5qon")
|
||||
metadata/_custom_type_script = "uid://cx63lvsuj1787"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
script = ExtResource("2_f2m3a")
|
||||
TrackName = "No Restraint"
|
||||
AuthorName = "Fenekhu"
|
||||
Description = "The intro is unfinished"
|
||||
ShowAuthor = false
|
||||
Track = ExtResource("1_d4uiy")
|
||||
metadata/_custom_type_script = "uid://cx63lvsuj1787"
|
||||
|
|
|
|||
|
|
@ -6,5 +6,6 @@
|
|||
script = ExtResource("1_ajy4g")
|
||||
TrackName = "An Overtime Fairy Dance"
|
||||
AuthorName = "Fenekhu"
|
||||
Description = "This song does not exist"
|
||||
ShowAuthor = false
|
||||
metadata/_custom_type_script = "uid://cx63lvsuj1787"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,21 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://c84shrj84g4t2"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://c84shrj84g4t2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c06tspxwnj7pg" path="res://Scripts/UI/MusicRoom.cs" id="1_u3ui8"]
|
||||
[ext_resource type="LabelSettings" uid="uid://wr7cb2qa6w71" path="res://Resources/Styles/Title_Text_Style.tres" id="1_w47yj"]
|
||||
[ext_resource type="Script" uid="uid://cx63lvsuj1787" path="res://Scripts/Resources/MusicResource.cs" id="2_kybwj"]
|
||||
[ext_resource type="Theme" uid="uid://dnsadvmunm76k" path="res://Resources/Styles/MainMenuButtons.tres" id="2_rcbhv"]
|
||||
[ext_resource type="Resource" uid="uid://byo74ews118nl" path="res://Resources/Music/No_Reason.tres" id="3_nkbmj"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpd4ldfmt3s51" path="res://Sprites/UI/Note.png" id="3_u3ui8"]
|
||||
[ext_resource type="Resource" uid="uid://b0aryixgv2vkj" path="res://Resources/Music/No_Restraint.tres" id="4_cv0ke"]
|
||||
[ext_resource type="FontFile" uid="uid://ccm3u37q1hvux" path="res://fonts/Xolonium-Regular.ttf" id="7_nkbmj"]
|
||||
[ext_resource type="LabelSettings" uid="uid://buk3e7bbwmnv1" path="res://Resources/Styles/Hud_Text_Style.tres" id="8_nkbmj"]
|
||||
|
||||
[node name="MusicRoom" type="VBoxContainer" node_paths=PackedStringArray("TracksContainer")]
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_cv0ke"]
|
||||
font = ExtResource("7_nkbmj")
|
||||
font_size = 20
|
||||
outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="MusicRoom" type="VBoxContainer" node_paths=PackedStringArray("TracksContainer", "DescriptionLabel")]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
|
@ -18,30 +25,33 @@ size_flags_horizontal = 3
|
|||
size_flags_vertical = 3
|
||||
script = ExtResource("1_u3ui8")
|
||||
Tracks = Array[ExtResource("2_kybwj")]([ExtResource("3_nkbmj"), ExtResource("4_cv0ke")])
|
||||
TracksContainer = NodePath("HBoxContainer/ItemList")
|
||||
TracksContainer = NodePath("VBoxContainer/ItemList")
|
||||
Icon = ExtResource("3_u3ui8")
|
||||
DescriptionLabel = NodePath("VBoxContainer/MarginContainer/DescriptionLabel")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
text = "MUSIC ROOM"
|
||||
label_settings = ExtResource("1_w47yj")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Button" type="Button" parent="HBoxContainer/VBoxContainer"]
|
||||
[node name="BackButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme = ExtResource("2_rcbhv")
|
||||
text = "Back"
|
||||
|
||||
[node name="ItemList" type="ItemList" parent="HBoxContainer"]
|
||||
[node name="MusicRoomName" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "MUSIC ROOM"
|
||||
label_settings = SubResource("LabelSettings_cv0ke")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ItemList" type="ItemList" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme = ExtResource("2_rcbhv")
|
||||
item_count = 4
|
||||
item_0/text = "No Restraint"
|
||||
|
|
@ -52,3 +62,18 @@ item_2/text = "An Overtime Fairy Dance"
|
|||
item_2/icon = ExtResource("3_u3ui8")
|
||||
item_3/text = "Apparitions Stalk the Factory"
|
||||
item_3/icon = ExtResource("3_u3ui8")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
|
||||
[node name="DescriptionLabel" type="Label" parent="VBoxContainer/MarginContainer"]
|
||||
custom_minimum_size = Vector2(0, 10)
|
||||
layout_mode = 2
|
||||
text = "adfds"
|
||||
label_settings = ExtResource("8_nkbmj")
|
||||
vertical_alignment = 2
|
||||
autowrap_mode = 2
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/BackButton" to="." method="_on_back_button_pressed"]
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ font_size = 12
|
|||
outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="Control" type="Control" node_paths=PackedStringArray("SubMenuHolder")]
|
||||
[node name="Control" type="Control" node_paths=PackedStringArray("SubMenuHolder", "MusicPlayer")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -36,6 +36,7 @@ script = ExtResource("1_702nk")
|
|||
GameScene = "res://Scenes/Maps/Tutorial.tscn"
|
||||
MainMenuScene = "res://Scenes/MainMenu.tscn"
|
||||
SubMenuHolder = NodePath("SubMenuContainer")
|
||||
MusicPlayer = NodePath("AudioStreamPlayer2D")
|
||||
MusicRoomTemplate = ExtResource("2_if7li")
|
||||
DebugMenuTemplate = ExtResource("9_nwlsr")
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,13 @@ public partial class MainMenu : Control
|
|||
|
||||
[Export]
|
||||
public string MainMenuScene { get; set; }
|
||||
|
||||
|
||||
[Export]
|
||||
public Control SubMenuHolder { get; set; } = new Control();
|
||||
|
||||
[Export]
|
||||
public AudioStreamPlayer2D MusicPlayer { get; private set; }
|
||||
|
||||
[ExportCategory("Music Room")]
|
||||
[Export]
|
||||
public PackedScene MusicRoomTemplate { get; set; }
|
||||
|
|
@ -21,7 +24,7 @@ public partial class MainMenu : Control
|
|||
[Export]
|
||||
public PackedScene DebugMenuTemplate { get; set; }
|
||||
|
||||
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -34,7 +37,8 @@ public partial class MainMenu : Control
|
|||
|
||||
private void _on_start_button_pressed()
|
||||
{
|
||||
if (GameScene != null) {
|
||||
if (GameScene != null)
|
||||
{
|
||||
GlobalState.Instance.GotoScene(GameScene);
|
||||
//GetTree().ChangeSceneToFile(GameScene);
|
||||
}
|
||||
|
|
@ -46,15 +50,15 @@ public partial class MainMenu : Control
|
|||
|
||||
// if (DebugMenuTemplate is null || DebugMenuHolder is null) return;
|
||||
// DebugMenuHolder.Visible = true;
|
||||
|
||||
|
||||
// var children = DebugMenuHolder.GetChildren();
|
||||
// foreach (var child in children)
|
||||
// {
|
||||
// child.QueueFree();
|
||||
// }
|
||||
|
||||
|
||||
// var menu = DebugMenuTemplate.Instantiate<DebugMenu>();
|
||||
|
||||
|
||||
// DebugMenuHolder.CallDeferred("add_child", menu);
|
||||
|
||||
// menu.DebugMenuClosed += () =>
|
||||
|
|
@ -66,32 +70,38 @@ public partial class MainMenu : Control
|
|||
private void _on_music_room_button_pressed()
|
||||
{
|
||||
SpawnMenu<MusicRoom>(MusicRoomTemplate, SubMenuHolder);
|
||||
MusicPlayer?.Stop();
|
||||
}
|
||||
|
||||
private void SpawnMenu<T>(PackedScene template, Control holder) where T : MenuBase
|
||||
{
|
||||
if (template is null || holder is null) return;
|
||||
holder.Visible = true;
|
||||
|
||||
|
||||
var children = holder.GetChildren();
|
||||
foreach (var child in children)
|
||||
{
|
||||
child.QueueFree();
|
||||
}
|
||||
|
||||
|
||||
var menu = template.Instantiate<T>();
|
||||
|
||||
|
||||
holder.CallDeferred("add_child", menu);
|
||||
|
||||
menu.MenuClosed += () =>
|
||||
{
|
||||
holder.Visible = false;
|
||||
if (!MusicPlayer.Playing)
|
||||
{
|
||||
MusicPlayer.Play();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void _on_mainmenu_button_pressed()
|
||||
{
|
||||
if (MainMenuScene != null) {
|
||||
if (MainMenuScene != null)
|
||||
{
|
||||
GlobalState.Instance.GotoScene(MainMenuScene);
|
||||
//GetTree().ChangeSceneToFile(MainMenuScene);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ using DebugMapSelectData = Cirno.Scripts.Resources.DebugMenu.DebugMapSelectData;
|
|||
|
||||
public partial class DebugMenu : MenuBase
|
||||
{
|
||||
|
||||
|
||||
[Export]
|
||||
public Theme ButtonTheme { get; private set; }
|
||||
|
||||
|
||||
[Export]
|
||||
public DebugMapSelectData Levels { get; set; }
|
||||
|
||||
|
||||
[Export]
|
||||
public Container ButtonsContainer { get; private set; }
|
||||
|
||||
|
|
@ -29,9 +29,9 @@ public partial class DebugMenu : MenuBase
|
|||
button.Icon = level.Icon;
|
||||
//button.Text = level;
|
||||
button.Theme = ButtonTheme;
|
||||
|
||||
|
||||
ButtonsContainer.CallDeferred("add_child", button);
|
||||
|
||||
|
||||
button.Pressed += () => ButtonOnPressed(level);
|
||||
}
|
||||
}
|
||||
|
|
@ -45,13 +45,6 @@ public partial class DebugMenu : MenuBase
|
|||
GlobalState.Instance.GoToScene(scene.Path, scene.StartData);
|
||||
}
|
||||
|
||||
private void _on_back_button_pressed()
|
||||
{
|
||||
this.QueueFree();
|
||||
|
||||
EmitSignal(SignalName.MenuClosed);
|
||||
}
|
||||
|
||||
private void _on_check_box_toggled(bool state)
|
||||
{
|
||||
GlobalState.Instance.SessionSettings.SkipDialogues = state;
|
||||
|
|
|
|||
|
|
@ -8,5 +8,12 @@ using Godot.Collections;
|
|||
public partial class MenuBase : Control
|
||||
{
|
||||
[Signal]
|
||||
public delegate void MenuClosedEventHandler();
|
||||
public delegate void MenuClosedEventHandler();
|
||||
|
||||
protected void _on_back_button_pressed()
|
||||
{
|
||||
this.QueueFree();
|
||||
|
||||
EmitSignal(SignalName.MenuClosed);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,52 +5,56 @@ using Godot.Collections;
|
|||
|
||||
public partial class MusicRoom : MenuBase
|
||||
{
|
||||
[Export]
|
||||
public Array<MusicResource> Tracks { get; private set; } = new();
|
||||
[Export]
|
||||
public Array<MusicResource> Tracks { get; private set; } = new();
|
||||
|
||||
[Export]
|
||||
public ItemList TracksContainer { get; private set; }
|
||||
[Export]
|
||||
public ItemList TracksContainer { get; private set; }
|
||||
|
||||
[Export]
|
||||
public Texture2D Icon { get; private set; }
|
||||
[Export]
|
||||
public Texture2D Icon { get; private set; }
|
||||
|
||||
private Dictionary<long, AudioNameVisualizer> _tracks = new();
|
||||
[Export]
|
||||
public Label DescriptionLabel { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
TracksContainer.Clear();
|
||||
foreach (var track in Tracks)
|
||||
{
|
||||
var index = TracksContainer.AddItem($"{track.TrackName} ({track.AuthorName})", Icon);
|
||||
private Dictionary<long, AudioNameVisualizer> _tracks = new();
|
||||
|
||||
var visualizer = new AudioNameVisualizer();
|
||||
visualizer.MusicData = track;
|
||||
TracksContainer.CallDeferred("add_child", visualizer);
|
||||
public override void _Ready()
|
||||
{
|
||||
DescriptionLabel.Text = string.Empty;
|
||||
TracksContainer.Clear();
|
||||
foreach (var track in Tracks)
|
||||
{
|
||||
var index = TracksContainer.AddItem($"{track.TrackName} ({track.AuthorName})", Icon);
|
||||
|
||||
_tracks.Add((long)index, visualizer);
|
||||
var visualizer = new AudioNameVisualizer();
|
||||
visualizer.MusicData = track;
|
||||
TracksContainer.CallDeferred("add_child", visualizer);
|
||||
|
||||
}
|
||||
_tracks.Add((long)index, visualizer);
|
||||
|
||||
TracksContainer.ItemSelected += (long selectedItem) =>
|
||||
{
|
||||
var vis = _tracks[selectedItem];
|
||||
if (vis.MusicData is null) { return; }
|
||||
StopAllTracks();
|
||||
vis.PlayWithName();
|
||||
UpdateDescription(vis.MusicData.Description);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void StopAllTracks()
|
||||
{
|
||||
foreach (var track in _tracks)
|
||||
{
|
||||
track.Value.Stop();
|
||||
}
|
||||
}
|
||||
TracksContainer.ItemSelected += (long selectedItem) =>
|
||||
{
|
||||
var vis = _tracks[selectedItem];
|
||||
if (vis.MusicData is null) { return; }
|
||||
StopAllTracks();
|
||||
vis.PlayWithName();
|
||||
UpdateDescription(vis.MusicData.Description);
|
||||
};
|
||||
}
|
||||
|
||||
private void UpdateDescription(string name)
|
||||
{
|
||||
private void StopAllTracks()
|
||||
{
|
||||
foreach (var track in _tracks)
|
||||
{
|
||||
track.Value.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void UpdateDescription(string name)
|
||||
{
|
||||
DescriptionLabel.Text = name;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue