1
0
mirror of synced 2024-11-13 18:40:47 +01:00

Permanant Recently played songs folder

This commit is contained in:
0aubsq 2022-03-14 23:47:03 +01:00
parent 3d39ecfa5e
commit 3041f6604b
7 changed files with 128 additions and 18 deletions

1
.gitignore vendored
View File

@ -18,6 +18,7 @@
/Test/dll/FDK.dll
/Test/NamePlate.json
/Test/Favorite.json
/Test/RecentlyPlayedSongs.json
/Test/SongsIgnored/*
/Test/xadec.dll
/Test/SoundDecoder.dll

View File

@ -106,6 +106,29 @@ namespace TJAPlayer3
return songList;
}
private static C曲リストード tReadaptChildNote(C曲リストード parent, C曲リストード node)
{
if (node != null)
{
node.r親ード = parent;
node.isChangedBgType = parent.isChangedBgType;
node.isChangedBgColor = parent.isChangedBgColor;
node.isChangedBoxType = parent.isChangedBoxType;
node.isChangedBoxColor = parent.isChangedBoxColor;
node.ForeColor = parent.ForeColor;
node.BackColor = parent.BackColor;
node.BoxColor = parent.BoxColor;
node.BgColor = parent.BgColor;
node.BgType = parent.BgType;
node.BoxType = parent.BoxType;
return node;
}
return null;
}
// Generate the favorite folder content
public static List<C曲リストード> tFetchFavoriteFolder(C曲リストード parent)
{
@ -113,22 +136,9 @@ namespace TJAPlayer3
foreach (string id in TJAPlayer3.Favorites.data.favorites[TJAPlayer3.SaveFile])
{
var node = tGetNodeFromID(id);
var node = tReadaptChildNote(parent, tGetNodeFromID(id));
if (node != null)
{
node.r親ード = parent;
node.isChangedBgType = parent.isChangedBgType;
node.isChangedBgColor = parent.isChangedBgColor;
node.isChangedBoxType = parent.isChangedBoxType;
node.isChangedBoxColor = parent.isChangedBoxColor;
node.ForeColor = parent.ForeColor;
node.BackColor = parent.BackColor;
node.BoxColor = parent.BoxColor;
node.BgColor = parent.BgColor;
node.BgType = parent.BgType;
node.BoxType = parent.BoxType;
childList.Add(node);
}
@ -143,6 +153,29 @@ namespace TJAPlayer3
return childList;
}
public static List<C曲リストード> tFetchRecentlyPlayedSongsFolder(C曲リストード parent)
{
List<C曲リストード> childList = new List<C曲リストード>();
foreach (string id in TJAPlayer3.RecentlyPlayedSongs.data.recentlyplayedsongs[TJAPlayer3.SaveFile])
{
var node = tReadaptChildNote(parent, tGetNodeFromID(id));
if (node != null)
{
childList.Add(node);
}
}
// Generate back buttons
string favPath = "./" + parent.strタイトル + "/";
tReinsertBackButtons(parent, childList, favPath);
return childList;
}
#endregion
}

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace TJAPlayer3
{
internal class RecentlyPlayedSongs
{
public void tRecentlyPlayedSongs() {
if (!File.Exists("RecentlyPlayedSongs.json"))
tSaveFile();
tLoadFile();
}
#region [Auxiliary methods]
public void tAddChart(string chartID)
{
if (!data.recentlyplayedsongs[TJAPlayer3.SaveFile].Contains(chartID))
data.recentlyplayedsongs[TJAPlayer3.SaveFile].Enqueue(chartID);
while (data.recentlyplayedsongs[TJAPlayer3.SaveFile].Count > 6) // Replace the 6 by a value defined in the settings later
data.recentlyplayedsongs[TJAPlayer3.SaveFile].Dequeue();
tSaveFile();
}
#endregion
public class Data
{
public Queue<string>[] recentlyplayedsongs = new Queue<string>[2] { new Queue<string>(), new Queue<string>() };
}
public Data data = new Data();
#region [private]
private void tSaveFile()
{
ConfigManager.SaveConfig(data, "RecentlyPlayedSongs.json");
}
private void tLoadFile()
{
data = ConfigManager.GetConfig<Data>(@"RecentlyPlayedSongs.json");
}
#endregion
}
}

View File

@ -274,6 +274,12 @@ namespace TJAPlayer3
private set;
}
public static RecentlyPlayedSongs RecentlyPlayedSongs
{
get;
private set;
}
public static Databases Databases
{
get;
@ -2060,6 +2066,9 @@ for (int i = 0; i < 3; i++) {
Favorites = new Favorites();
Favorites.tFavorites();
RecentlyPlayedSongs = new RecentlyPlayedSongs();
RecentlyPlayedSongs.tRecentlyPlayedSongs();
Databases = new Databases();
Databases.tDatabases();

View File

@ -664,6 +664,10 @@ namespace TJAPlayer3
{
this.act曲リスト.r現在選択中の曲.list子リスト = CSongDict.tFetchFavoriteFolder(this.act曲リスト.r現在選択中の曲);
}
else if (this.act曲リスト.r現在選択中の曲.strジャンル == "最近遊んだ曲")
{
this.act曲リスト.r現在選択中の曲.list子リスト = CSongDict.tFetchRecentlyPlayedSongsFolder(this.act曲リスト.r現在選択中の曲);
}
CSongSelectSongManager.disable();

View File

@ -1741,12 +1741,15 @@ namespace TJAPlayer3
#endregion
}
}
//---------------------
}
//---------------------
#endregion
// Song added to recently added songs here
TJAPlayer3.RecentlyPlayedSongs.tAddChart(TJAPlayer3.stage選曲.r確定された曲.uniqueId.data.id);
// Song added to recently added songs here
/*
foreach (var song in TJAPlayer3.Songs管理.list曲ルート)
{
if (song.strジャンル == "最近遊んだ曲" && song.eード種別 == C曲リストード.Eード種別.BOX)
@ -1796,6 +1799,8 @@ namespace TJAPlayer3
}
}
*/
b最近遊んだ曲追加済み = true;
}

View File

@ -121,6 +121,7 @@
<Compile Include="Animations\IAnimatable.cs" />
<Compile Include="Animations\Linear.cs" />
<Compile Include="Common\CCrypto.cs" />
<Compile Include="Common\RecentlyPlayedSongs.cs" />
<Compile Include="Common\ModalQueue.cs" />
<Compile Include="Common\Modal.cs" />
<Compile Include="Common\CSongDict.cs" />