2022-03-02 08:00:37 +01:00
|
|
|
|
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 Favorites
|
|
|
|
|
{
|
|
|
|
|
public void tFavorites() {
|
|
|
|
|
if (!File.Exists("Favorite.json"))
|
|
|
|
|
tSaveFile();
|
|
|
|
|
|
|
|
|
|
tLoadFile();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 02:08:29 +01:00
|
|
|
|
#region [Auxiliary methods]
|
|
|
|
|
|
|
|
|
|
public void tToggleFavorite(string chartID)
|
2022-03-02 08:00:37 +01:00
|
|
|
|
{
|
2022-03-03 02:08:29 +01:00
|
|
|
|
if (tIsFavorite(chartID))
|
|
|
|
|
data.favorites[TJAPlayer3.SaveFile].Remove(chartID);
|
|
|
|
|
else
|
|
|
|
|
data.favorites[TJAPlayer3.SaveFile].Add(chartID);
|
|
|
|
|
|
|
|
|
|
tSaveFile();
|
|
|
|
|
}
|
2022-03-02 08:00:37 +01:00
|
|
|
|
|
2022-03-03 02:08:29 +01:00
|
|
|
|
public bool tIsFavorite(string chartID)
|
|
|
|
|
{
|
|
|
|
|
return (data.favorites[TJAPlayer3.SaveFile].Contains(chartID));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public class Data
|
|
|
|
|
{
|
|
|
|
|
public HashSet<string>[] favorites = new HashSet<string>[2] { new HashSet<string>(), new HashSet<string>() };
|
2022-03-02 08:00:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Data data = new Data();
|
|
|
|
|
|
|
|
|
|
#region [private]
|
|
|
|
|
|
|
|
|
|
private void tSaveFile()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.SaveConfig(data, "Favorite.json");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tLoadFile()
|
|
|
|
|
{
|
|
|
|
|
data = ConfigManager.GetConfig<Data>(@"Favorite.json");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|