save loading

This commit is contained in:
Bucket Of Chicken
2025-09-13 12:39:06 +02:00
parent 1be235df0a
commit 3d75d1712d
12 changed files with 181 additions and 59 deletions
View File
+1 -1
View File
@@ -21,7 +21,7 @@ compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
+1 -1
View File
@@ -21,7 +21,7 @@ compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
+73
View File
@@ -0,0 +1,73 @@
[gd_scene load_steps=3 format=3 uid="uid://bam5mbsffdryc"]
[sub_resource type="LabelSettings" id="LabelSettings_84l0p"]
font_size = 20
shadow_size = 2
shadow_color = Color(0, 0, 0, 0.564706)
[sub_resource type="LabelSettings" id="LabelSettings_24osb"]
font_color = Color(0.791999, 0.791999, 0.791999, 1)
shadow_size = 2
shadow_color = Color(0, 0, 0, 0.564706)
[node name="SourceDisplay" type="Control"]
custom_minimum_size = Vector2(0, 75)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -572.0
offset_bottom = -573.0
grow_horizontal = 2
grow_vertical = 2
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
mouse_filter = 2
[node name="Name" type="Label" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 6
text = "Name"
label_settings = SubResource("LabelSettings_84l0p")
clip_text = true
text_overrun_behavior = 3
[node name="Path" type="Label" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 6
text = "Artist"
label_settings = SubResource("LabelSettings_24osb")
clip_text = true
text_overrun_behavior = 3
[node name="CheckBox" type="CheckBox" parent="."]
layout_mode = 1
anchors_preset = 6
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_left = -24.0
offset_top = -12.0
offset_bottom = 12.0
grow_horizontal = 0
grow_vertical = 2
text = "Enabled"
+5 -2
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=3 uid="uid://mfcbf2sfino6"]
[gd_scene load_steps=18 format=3 uid="uid://mfcbf2sfino6"]
[ext_resource type="Texture2D" uid="uid://0jo87vtoeheu" path="res://Images/pole2.jpg" id="1_6bp64"]
[ext_resource type="Texture2D" uid="uid://df2e70jxwrmjs" path="res://Icons/BackOne.png" id="1_8gbba"]
@@ -12,6 +12,7 @@
[ext_resource type="Texture2D" uid="uid://cekkhyppj88xi" path="res://Icons/Headphones.png" id="4_kry3j"]
[ext_resource type="PackedScene" uid="uid://dds3tnltcg0sg" path="res://Scenes/PerformanceDisplay.tscn" id="5_fdnlq"]
[ext_resource type="Script" uid="uid://ci5h1wwbedkbt" path="res://Scripts/UIManager.cs" id="12_6iyac"]
[ext_resource type="Texture2D" uid="uid://dumymuj4w4si0" path="res://Icons/shuffle.png" id="13_jkdf5"]
[ext_resource type="Texture2D" uid="uid://ch8wymyxftkb3" path="res://Icons/Pause.png" id="14_jkdf5"]
[sub_resource type="GDScript" id="GDScript_bo1nx"]
@@ -224,8 +225,10 @@ icon = ExtResource("4_21xkr")
expand_icon = true
[node name="Shuffle" type="Button" parent="Padding/VBoxContainer/Bottom/HBoxContainer"]
custom_minimum_size = Vector2(42, 0)
layout_mode = 2
text = "shuffle"
icon = ExtResource("13_jkdf5")
expand_icon = true
[node name="Volume" type="Button" parent="Padding/VBoxContainer/Bottom/HBoxContainer"]
custom_minimum_size = Vector2(42, 0)
+4
View File
@@ -1,3 +1,4 @@
using ATL;
using Godot;
using System;
using System.Collections.Generic;
@@ -12,10 +13,13 @@ public partial class Context : Node
DirectoryLoader manager = new();
static public SongPlayer ISongPlayer;
public event Action<IEnumerable<Song>> SongsUpdated;
public SimplaudioSettings Setting;
public override void _Ready()
{
base._Ready();
Setting = SaveManager.LoadSettings();
GD.Print("keys: ", Setting.Sources.Keys);
instance = this;
ISongPlayer = new SongPlayer();
AddChild(ISongPlayer);
+14
View File
@@ -0,0 +1,14 @@
using System;
using DiscordRPC;
using Godot;
public class SaveManager{
const String SaveLocation = "user://Saved.tres";
public static SimplaudioSettings LoadSettings(){
SimplaudioSettings loaded = GD.Load<SimplaudioSettings>(SaveLocation);
if (loaded == null){
return new SimplaudioSettings();
}
return loaded;
}
}
+1
View File
@@ -0,0 +1 @@
uid://vqf4yrwaaggo
+13
View File
@@ -0,0 +1,13 @@
using System;
using Godot;
using Godot.Collections;
[GlobalClass][Tool]
public partial class SimplaudioSettings : Resource{
[Export] public bool Shuffled { get; set; }
[Export] public Dictionary<String,bool> Sources { get; set; }
public SimplaudioSettings(){
Sources = new Dictionary<String, bool>();
}
}
+1
View File
@@ -0,0 +1 @@
uid://dbelngrrq8x2s
+53 -53
View File
@@ -4,64 +4,64 @@ using System.Collections.Generic;
using System.Linq;
public partial class UIManager : Node{
[Export] Button PlayPauseButton;
[Export] Texture2D PauseImage;
[Export] Texture2D PlayImage;
[Export] HSlider ProgressIndicator;
[Export] Button SkipButton;
[Export] Button GoBackButton;
[Export] Button LoopButton;
[Export] Button RandomizeButton;
[Export] Button PlayPauseButton;
[Export] Texture2D PauseImage;
[Export] Texture2D PlayImage;
[Export] HSlider ProgressIndicator;
[Export] Button SkipButton;
[Export] Button GoBackButton;
[Export] Button LoopButton;
[Export] Button RandomizeButton;
bool SliderDragging;
bool SliderDragging;
static UIManager instance;
public override void _Ready()
{
base._Ready();
instance = this;
ProgressIndicator.DragStarted += sliderDrag;
ProgressIndicator.DragEnded += sliderDragEnded;
PlayPauseButton.Toggled += PausePlay;
Context.ISongPlayer.SongStateUpdated += UpdatePausePlay;
}
static UIManager instance;
public override void _Ready()
{
base._Ready();
instance = this;
ProgressIndicator.DragStarted += sliderDrag;
ProgressIndicator.DragEnded += sliderDragEnded;
PlayPauseButton.Toggled += PausePlay;
Context.ISongPlayer.SongStateUpdated += UpdatePausePlay;
}
void PausePlay(bool Newstate){
if (Newstate){
Context.ISongPlayer.PauseSong();
PlayPauseButton.Icon = PlayImage;
}
else{
Context.ISongPlayer.UnpauseSong();
PlayPauseButton.Icon = PauseImage;
}
}
void PausePlay(bool Newstate){
if (Newstate){
Context.ISongPlayer.PauseSong();
PlayPauseButton.Icon = PlayImage;
}
else{
Context.ISongPlayer.UnpauseSong();
PlayPauseButton.Icon = PauseImage;
}
}
void UpdatePausePlay(bool paused){
if (paused){
PlayPauseButton.Icon = PlayImage;
PlayPauseButton.ButtonPressed = true;
}
else{
PlayPauseButton.Icon = PauseImage;
PlayPauseButton.ButtonPressed = false;
}
}
void UpdatePausePlay(bool paused){
if (paused){
PlayPauseButton.Icon = PlayImage;
PlayPauseButton.ButtonPressed = true;
}
else{
PlayPauseButton.Icon = PauseImage;
PlayPauseButton.ButtonPressed = false;
}
}
public override void _Process(double delta)
{
base._Process(delta);
if (!SliderDragging){
ProgressIndicator.Value = Context.ISongPlayer.GetPosition();
}
}
public override void _Process(double delta)
{
base._Process(delta);
if (!SliderDragging){
ProgressIndicator.Value = Context.ISongPlayer.GetPosition();
}
}
void sliderDrag(){
SliderDragging = true;
}
void sliderDragEnded(bool changed){
SliderDragging = false;
void sliderDrag(){
SliderDragging = true;
}
void sliderDragEnded(bool changed){
SliderDragging = false;
Context.ISongPlayer.SetPosition((float)ProgressIndicator.Value);
}
Context.ISongPlayer.SetPosition((float)ProgressIndicator.Value);
}
}
+13
View File
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="SimplaudioSettings" load_steps=2 format=3 uid="uid://dn1yyh3jwlvf5"]
[ext_resource type="Script" uid="uid://dbelngrrq8x2s" path="res://Scripts/SimplaudioSettings.cs" id="1_by5j6"]
[resource]
script = ExtResource("1_by5j6")
Shuffled = false
Sources = {
"Cogs": true,
"dafdaf": true,
"dfagg": false
}
metadata/_custom_type_script = "uid://dbelngrrq8x2s"