mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
60 lines
1.3 KiB
C#
60 lines
1.3 KiB
C#
using Godot;
|
|
using System;
|
|
using System.Linq;
|
|
using Cirno.Scripts;
|
|
using GTweens.Builders;
|
|
using GTweens.Easings;
|
|
using GTweens.Tweens;
|
|
using GTweensGodot.Extensions;
|
|
|
|
public partial class AudioNameVisualizer : AudioStreamPlayer2D
|
|
{
|
|
[Export]
|
|
public string TrackName { get; private set; }
|
|
|
|
[Export]
|
|
public string AuthorName { get; private set; }
|
|
|
|
[Export] public PackedScene CanvasTemplate;
|
|
|
|
private MusicVisualizerCanvas _canvasLayer;
|
|
|
|
public override void _Ready()
|
|
{
|
|
Setup();
|
|
|
|
if (Autoplay)
|
|
{
|
|
ShowName();
|
|
}
|
|
}
|
|
|
|
private void Setup()
|
|
{
|
|
var existingCanvas = this.GetTree().Root.GetNodeOrNull<CanvasLayer>("AudioCanvas");
|
|
|
|
if (existingCanvas is null)
|
|
{
|
|
// _canvasLayer = new CanvasLayer();
|
|
// _canvasLayer.Name = "AudioCanvas";
|
|
_canvasLayer = CanvasTemplate.Instantiate<MusicVisualizerCanvas>();
|
|
GetTree().Root.CallDeferred("add_child", _canvasLayer);
|
|
}
|
|
else
|
|
{
|
|
_canvasLayer = (MusicVisualizerCanvas)existingCanvas;
|
|
}
|
|
}
|
|
|
|
public void PlayWithName()
|
|
{
|
|
ShowName();
|
|
Play();
|
|
}
|
|
|
|
public void ShowName()
|
|
{
|
|
GD.Print("show name");
|
|
_canvasLayer.ShowName(TrackName, AuthorName);
|
|
}
|
|
}
|