1
0
mirror of synced 2024-11-28 09:20:53 +01:00

Add CSongUniqueID class (not integrated yet)

This commit is contained in:
0aubsq 2022-03-02 08:00:37 +01:00
parent 3bced7fdc0
commit 7a37f669ff
8 changed files with 156 additions and 34 deletions

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
namespace TJAPlayer3
{
internal class CCrypto
{
internal static readonly char[] chars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
public static string GetUniqueKey(int size)
{
byte[] data = new byte[4 * size];
using (var crypto = RandomNumberGenerator.Create())
{
crypto.GetBytes(data);
}
StringBuilder result = new StringBuilder(size);
for (int i = 0; i < size; i++)
{
var rnd = BitConverter.ToUInt32(data, i * 4);
var idx = rnd % chars.Length;
result.Append(chars[idx]);
}
return result.ToString();
}
}
}

View File

@ -0,0 +1,42 @@
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();
}
public class Data
{
}
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
}
}

View File

@ -268,6 +268,12 @@ namespace TJAPlayer3
private set;
}
public static Favorites Favorites
{
get;
private set;
}
public static Databases Databases
{
get;
@ -2046,11 +2052,14 @@ for (int i = 0; i < 3; i++) {
//-----------------
#endregion
#region [ Config.ini ]
#region [ Read Config.ini and Database files ]
//---------------------
NamePlateConfig = new NamePlateConfig();
NamePlateConfig.tNamePlateConfig();
Favorites = new Favorites();
Favorites.tFavorites();
Databases = new Databases();
Databases.tDatabases();

View File

@ -37,6 +37,7 @@ namespace TJAPlayer3
public int HistoryCount;
public string[] History;
public int BGMAdjust;
}
// 演奏記録セクション9種類

View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
namespace TJAPlayer3
{
internal class CSongUniqueID
{
public CSongUniqueID(string path)
{
filePath = path;
tGenerateUniqueID();
tSongUniqueID();
}
public void tSongUniqueID()
{
if (!File.Exists(filePath))
tSaveFile();
tLoadFile();
}
#region [Auxiliary methods]
public void tAttachOnlineAddress(string url)
{
data.url = url;
}
public void tGenerateUniqueID()
{
data.id = CCrypto.GetUniqueKey(64);
}
#endregion
public class Data
{
public string id = "";
public string url = "";
}
public Data data = new Data();
public string filePath;
#region [private]
private void tSaveFile()
{
ConfigManager.SaveConfig(data, filePath);
}
private void tLoadFile()
{
data = ConfigManager.GetConfig<Data>(filePath);
}
#endregion
}
}

View File

@ -120,6 +120,7 @@
<Compile Include="Animations\FadeOut.cs" />
<Compile Include="Animations\IAnimatable.cs" />
<Compile Include="Animations\Linear.cs" />
<Compile Include="Common\Favorites.cs" />
<Compile Include="Common\ConfigManager.cs" />
<Compile Include="Common\Discord.cs" />
<Compile Include="Common\Easing.cs" />

View File

@ -1,6 +1,5 @@
;Included file
;あとは通常通り設定できます
; TJAPlayer3-Develop-ReWriteで追加したSkinConfig
SongSelect_BoxExplanation_X=0
SongSelect_BoxExplanation_Y=0
@ -8,7 +7,6 @@ SongSelect_Title_X=0
SongSelect_Title_Y=0
SongSelect_BoxExplanation_Interval=30
;GenreName deprecated
SongSelect_GenreName=ポップス,アニメ,ゲームバラエティ,ナムコオリジナル,クラシック,バラエティ,キッズ,ボーカロイド,最近遊んだ曲
SongSelect_GenreName=
Game_DanC_Dan_Plate=1120,535

View File

@ -1,30 +0,0 @@
Folders done :
Graphics :
2_Config
4_SongLoading
5_Game :
- 1_Chara (Empty)
- 2_Dancer (Empty)
- 3_Mob (Empty)
- 6_Taiko
- 7_Gauge
- 8_Footer
- 12_Lane
- 13_GENRE
- 14_GameMode
- 18_PuchiChara (Blank)
7_Exit
8_TowerResult
9_NamePlateEffect
10_Heya
11_Characters (Blank)
Sounds :
Combo_1P (Empty)
Tower_Combo (Empty)
Taiko