functional directory picker
This commit is contained in:
+52
-3
@@ -1,6 +1,23 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://mfcbf2sfino6"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://mfcbf2sfino6"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c8bqyed2abyoy" path="res://Scripts/Test.cs" id="1_jjgbg"]
|
||||
[ext_resource type="Texture2D" uid="uid://daq8wnhtscpjl" path="res://Icons/Skip.png" id="2_bo1nx"]
|
||||
[ext_resource type="Script" uid="uid://bq55jftgugexl" path="res://Scripts/Context.cs" id="3_8gbba"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_bo1nx"]
|
||||
resource_name = "OpenDirGlue"
|
||||
script/source = "extends Button
|
||||
@export var file_dialog: FileDialog
|
||||
@export var Context:Node
|
||||
func _ready() -> void:
|
||||
file_dialog.dir_selected.connect(dirsel)
|
||||
|
||||
func _pressed() -> void:
|
||||
file_dialog.show()
|
||||
|
||||
func dirsel(dir:String):
|
||||
print(dir)
|
||||
Context.call(\"LoadDirectory\",dir)
|
||||
"
|
||||
|
||||
[node name="Main" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -22,7 +39,6 @@ offset_right = 547.0
|
||||
offset_bottom = 293.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_jjgbg")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Padding"]
|
||||
layout_mode = 1
|
||||
@@ -37,6 +53,16 @@ custom_minimum_size = Vector2(0, 50)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="Button" type="Button" parent="Padding/VBoxContainer/Top" node_paths=PackedStringArray("file_dialog", "Context")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_right = 76.0
|
||||
offset_bottom = 31.0
|
||||
text = "Open dir"
|
||||
script = SubResource("GDScript_bo1nx")
|
||||
file_dialog = NodePath("../../../../FileDialog")
|
||||
Context = NodePath("../../../../Context")
|
||||
|
||||
[node name="Control" type="Control" parent="Padding/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
@@ -53,6 +79,29 @@ anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="BackButton" type="Button" parent="Padding/VBoxContainer/Bottom/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(50, 0)
|
||||
layout_mode = 2
|
||||
icon = ExtResource("2_bo1nx")
|
||||
expand_icon = true
|
||||
|
||||
[node name="PlayButton" type="Button" parent="Padding/VBoxContainer/Bottom/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "play"
|
||||
|
||||
[node name="SkipButton" type="Button" parent="Padding/VBoxContainer/Bottom/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(50, 0)
|
||||
layout_mode = 2
|
||||
icon = ExtResource("2_bo1nx")
|
||||
expand_icon = true
|
||||
|
||||
[node name="FileDialog" type="FileDialog" parent="."]
|
||||
oversampling_override = 1.0
|
||||
title = "Open a Directory"
|
||||
size = Vector2i(807, 360)
|
||||
file_mode = 2
|
||||
access = 2
|
||||
use_native_dialog = true
|
||||
|
||||
[node name="Context" type="Node" parent="."]
|
||||
script = ExtResource("3_8gbba")
|
||||
|
||||
@@ -3,5 +3,14 @@ using System;
|
||||
|
||||
public partial class Context : Node
|
||||
{
|
||||
|
||||
String[] Songs;
|
||||
DirectoryManager manager = new();
|
||||
|
||||
|
||||
|
||||
public void LoadDirectory(String path){
|
||||
GD.Print(path);
|
||||
manager.LoadDirectory(path);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-7
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using TagLib;
|
||||
using TagLib.Riff;
|
||||
|
||||
|
||||
@@ -11,6 +12,7 @@ public class Song{
|
||||
public String[] Artists;
|
||||
public String Album;
|
||||
public float Length;
|
||||
public String Comment;
|
||||
public String Directory;
|
||||
}
|
||||
public class DirectoryManager{
|
||||
@@ -21,20 +23,27 @@ public class DirectoryManager{
|
||||
if (!(file.EndsWith(".mp3") || file.EndsWith(".ogg") || file.EndsWith(".wav"))){
|
||||
continue;
|
||||
}
|
||||
var tfile = TagLib.File.Create(file);
|
||||
var TLfile = TagLib.File.Create(file);
|
||||
|
||||
Song song = new();
|
||||
song.Album = tfile.Tag.Album;
|
||||
song.Artists = tfile.Tag.Performers;
|
||||
song.Name = tfile.Tag.Title;
|
||||
song.Length = tfile.Length;
|
||||
song.Album = TLfile.Tag.Album;
|
||||
song.Artists = TLfile.Tag.Performers;
|
||||
song.Name = TLfile.Tag.Title;
|
||||
song.Length = TLfile.Length;
|
||||
song.Directory = file;
|
||||
GD.Print("File Valid, file path ",tfile.Tag.Title);
|
||||
song.Comment = TLfile.Tag.Comment;
|
||||
if (file.EndsWith(".mp3")){
|
||||
song.Comment = TLfile.GetTag(TagLib.TagTypes.Id3v2, true).Comment;
|
||||
}
|
||||
//TLfile.Tag.CopyTo(Tag)
|
||||
|
||||
|
||||
GD.Print("File Valid, file path ",song.Directory);
|
||||
Songs.Append(song);
|
||||
|
||||
//if (file.EndsWith(".mp3"))
|
||||
}
|
||||
|
||||
return [];
|
||||
return Songs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using TagLib;
|
||||
|
||||
public partial class Test : Node
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
DirectoryManager manager = new();
|
||||
manager.LoadDirectory("/run/media/bucket/Old Linux Drive/MainExternalBackup/Music/");
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://c8bqyed2abyoy
|
||||
+2
-1
@@ -6,6 +6,7 @@
|
||||
<ItemGroup>
|
||||
|
||||
<PackageReference Include="TagLibSharp" Version="2.3.0" />
|
||||
|
||||
<PackageReference Include="YoutubeDLSharp" Version="1.1.2" />
|
||||
<PackageReference Include="FFMpegCore" Version="5.2.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -26,6 +26,7 @@ debug/export_console_wrapper=0
|
||||
binary_format/embed_pck=false
|
||||
texture_format/s3tc_bptc=true
|
||||
texture_format/etc2_astc=false
|
||||
shader_baker/enabled=false
|
||||
binary_format/architecture="x86_64"
|
||||
codesign/enable=false
|
||||
codesign/timestamp=true
|
||||
@@ -96,6 +97,7 @@ debug/export_console_wrapper=1
|
||||
binary_format/embed_pck=false
|
||||
texture_format/s3tc_bptc=true
|
||||
texture_format/etc2_astc=false
|
||||
shader_baker/enabled=false
|
||||
binary_format/architecture="x86_64"
|
||||
ssh_remote_deploy/enabled=false
|
||||
ssh_remote_deploy/host="user@host_ip"
|
||||
|
||||
Reference in New Issue
Block a user