Add a template class 'CSavableT' for database classes
This commit is contained in:
parent
4e1628b4a1
commit
38be006289
43
TJAPlayer3/Common/CSavableT.cs
Normal file
43
TJAPlayer3/Common/CSavableT.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
|
||||||
|
namespace TJAPlayer3
|
||||||
|
{
|
||||||
|
class CSavableT<T> where T : new()
|
||||||
|
{
|
||||||
|
public virtual string _fn
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
protected set;
|
||||||
|
}
|
||||||
|
public void tDBInitSavable()
|
||||||
|
{
|
||||||
|
if (!File.Exists(_fn))
|
||||||
|
tSaveFile();
|
||||||
|
|
||||||
|
tLoadFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T data = new T();
|
||||||
|
|
||||||
|
#region [private]
|
||||||
|
|
||||||
|
private void tSaveFile()
|
||||||
|
{
|
||||||
|
ConfigManager.SaveConfig(data, _fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tLoadFile()
|
||||||
|
{
|
||||||
|
data = ConfigManager.GetConfig<T>(_fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -4,9 +4,15 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace TJAPlayer3
|
namespace TJAPlayer3
|
||||||
{
|
{
|
||||||
class DBCDN
|
class DBCDN : CSavableT<Dictionary<string, DBCDN.CDNData>>
|
||||||
{
|
{
|
||||||
|
public DBCDN()
|
||||||
|
{
|
||||||
|
_fn = @".\Databases\CDN.json";
|
||||||
|
base.tDBInitSavable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public void tDBCDN()
|
public void tDBCDN()
|
||||||
{
|
{
|
||||||
if (!File.Exists(@".\Databases\CDN.json"))
|
if (!File.Exists(@".\Databases\CDN.json"))
|
||||||
@ -14,6 +20,7 @@ namespace TJAPlayer3
|
|||||||
|
|
||||||
tLoadFile();
|
tLoadFile();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
#region [Auxiliary classes]
|
#region [Auxiliary classes]
|
||||||
|
|
||||||
@ -67,8 +74,10 @@ namespace TJAPlayer3
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/*
|
||||||
public Dictionary<string, CDNData> data = new Dictionary<string, CDNData>();
|
public Dictionary<string, CDNData> data = new Dictionary<string, CDNData>();
|
||||||
|
|
||||||
|
|
||||||
#region [private]
|
#region [private]
|
||||||
|
|
||||||
private void tSaveFile()
|
private void tSaveFile()
|
||||||
@ -82,5 +91,6 @@ namespace TJAPlayer3
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
20
TJAPlayer3/Databases/DBEncyclopediaMenus.cs
Normal file
20
TJAPlayer3/Databases/DBEncyclopediaMenus.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace TJAPlayer3
|
||||||
|
{
|
||||||
|
class DBEncyclopediaMenus : CSavableT<Dictionary<int, string>>
|
||||||
|
{
|
||||||
|
public DBEncyclopediaMenus()
|
||||||
|
{
|
||||||
|
_fn = @".\Encyclopedia\Menus.json";
|
||||||
|
base.tDBInitSavable();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -8,8 +8,6 @@ namespace TJAPlayer3
|
|||||||
public void tDatabases()
|
public void tDatabases()
|
||||||
{
|
{
|
||||||
DBCDN = new DBCDN();
|
DBCDN = new DBCDN();
|
||||||
|
|
||||||
DBCDN.tDBCDN();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DBCDN DBCDN;
|
public DBCDN DBCDN;
|
||||||
|
@ -126,6 +126,7 @@
|
|||||||
<Compile Include="Character\CMenuCharacter.cs" />
|
<Compile Include="Character\CMenuCharacter.cs" />
|
||||||
<Compile Include="Common\CCrypto.cs" />
|
<Compile Include="Common\CCrypto.cs" />
|
||||||
<Compile Include="Common\CHitSounds.cs" />
|
<Compile Include="Common\CHitSounds.cs" />
|
||||||
|
<Compile Include="Common\CSavableT.cs" />
|
||||||
<Compile Include="Common\CVersionList.cs" />
|
<Compile Include="Common\CVersionList.cs" />
|
||||||
<Compile Include="Common\RecentlyPlayedSongs.cs" />
|
<Compile Include="Common\RecentlyPlayedSongs.cs" />
|
||||||
<Compile Include="Common\ModalQueue.cs" />
|
<Compile Include="Common\ModalQueue.cs" />
|
||||||
@ -137,6 +138,7 @@
|
|||||||
<Compile Include="Common\Easing.cs" />
|
<Compile Include="Common\Easing.cs" />
|
||||||
<Compile Include="Common\NamePlateConfig.cs" />
|
<Compile Include="Common\NamePlateConfig.cs" />
|
||||||
<Compile Include="Databases\DBCDN.cs" />
|
<Compile Include="Databases\DBCDN.cs" />
|
||||||
|
<Compile Include="Databases\DBEncyclopediaMenus.cs" />
|
||||||
<Compile Include="Databases\DBPuchichara.cs" />
|
<Compile Include="Databases\DBPuchichara.cs" />
|
||||||
<Compile Include="Databases\DBUnlockables.cs" />
|
<Compile Include="Databases\DBUnlockables.cs" />
|
||||||
<Compile Include="Databases\Databases.cs" />
|
<Compile Include="Databases\Databases.cs" />
|
||||||
@ -407,7 +409,9 @@
|
|||||||
<Version>4.5.0</Version>
|
<Version>4.5.0</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<Folder Include="Stages\15.OpenEncyclopedia\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
BIN
Test/Encyclopedia/Images/100.png
Normal file
BIN
Test/Encyclopedia/Images/100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
Test/Encyclopedia/Images/102.png
Normal file
BIN
Test/Encyclopedia/Images/102.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
@ -1,8 +1,21 @@
|
|||||||
{
|
{
|
||||||
"menus": [
|
"menus": [
|
||||||
1: {
|
1: {
|
||||||
|
"menus": [
|
||||||
|
10: {
|
||||||
|
"pages": [
|
||||||
|
100,
|
||||||
|
101,
|
||||||
|
102,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
11: {
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
},
|
},
|
||||||
2: {
|
2: {
|
||||||
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
Test1
|
1
Test/Encyclopedia/Menus/10/en.txt
Normal file
1
Test/Encyclopedia/Menus/10/en.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Test10
|
1
Test/Encyclopedia/Menus/11/en.txt
Normal file
1
Test/Encyclopedia/Menus/11/en.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Test11
|
1
Test/Encyclopedia/Menus/2/en.txt
Normal file
1
Test/Encyclopedia/Menus/2/en.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Test2
|
3
Test/Encyclopedia/Pages/100/en.txt
Normal file
3
Test/Encyclopedia/Pages/100/en.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
This is a test page
|
||||||
|
with the number
|
||||||
|
100
|
3
Test/Encyclopedia/Pages/101/en.txt
Normal file
3
Test/Encyclopedia/Pages/101/en.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
This is a test page
|
||||||
|
with the number
|
||||||
|
101
|
3
Test/Encyclopedia/Pages/102/en.txt
Normal file
3
Test/Encyclopedia/Pages/102/en.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
This is a test page
|
||||||
|
with the number
|
||||||
|
102
|
Loading…
x
Reference in New Issue
Block a user