Saves attached to database
This commit is contained in:
parent
c4f55c04b1
commit
a3b39ebe7f
Binary file not shown.
@ -25,13 +25,25 @@ namespace TJAPlayer3
|
||||
|
||||
tLoadFile();
|
||||
|
||||
tInitSaveFile();
|
||||
}
|
||||
|
||||
public void tInitSaveFile()
|
||||
{
|
||||
data.bestPlays = DBSaves.GetBestPlaysAsDict(data.SaveId);
|
||||
data.tFactorizeBestPlays();
|
||||
}
|
||||
|
||||
public void tLoadUnlockables()
|
||||
{
|
||||
data.UnlockedCharacters = DBSaves.FetchStringUnlockedAsset(data.SaveId, "unlocked_characters");
|
||||
data.UnlockedPuchicharas = DBSaves.FetchStringUnlockedAsset(data.SaveId, "unlocked_puchicharas");
|
||||
data.UnlockedNameplateIds = DBSaves.FetchUnlockedNameplateIds(data.SaveId);
|
||||
data.DanTitles = DBSaves.FetchUnlockedDanTitles(data.SaveId);
|
||||
}
|
||||
|
||||
|
||||
#region [Medals]
|
||||
#region [Medals and PlayCount]
|
||||
|
||||
public void tEarnCoins(int amount)
|
||||
{
|
||||
@ -41,7 +53,8 @@ namespace TJAPlayer3
|
||||
// Small trick here, each actual play (excluding Auto, AI, etc) are worth at least 5 coins for the player, whatever which mode it is (Dan, Tower, Taiko mode, etc)
|
||||
// Earn Coins is also called once per play, so we just add 1 here to the total playcount
|
||||
data.TotalPlaycount += 1;
|
||||
tSaveFile();
|
||||
DBSaves.AlterCoinsAndTotalPlayCount(data.SaveId, amount, 1);
|
||||
//tSaveFile();
|
||||
}
|
||||
|
||||
// Return false if the current amount of coins is to low
|
||||
@ -51,12 +64,17 @@ namespace TJAPlayer3
|
||||
return false;
|
||||
|
||||
data.Medals -= amount;
|
||||
|
||||
tSaveFile();
|
||||
DBSaves.AlterCoinsAndTotalPlayCount(data.SaveId, -amount, 0);
|
||||
//tSaveFile();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void tRegisterAIBattleModePlay(bool IsWon)
|
||||
{
|
||||
DBSaves.RegisterAIBattleModePlay(data.SaveId, IsWon);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region [Dan titles]
|
||||
@ -84,6 +102,7 @@ namespace TJAPlayer3
|
||||
|
||||
if (!this.data.DanTitles.ContainsKey(title) || cs != clearStatus || iG != isGold)
|
||||
{
|
||||
DBSaves.RegisterDanTitle(data.SaveId, title, clearStatus, isGold);
|
||||
changed = true;
|
||||
/*
|
||||
TJAPlayer3.NamePlateConfig.data.Dan[player] = title;
|
||||
@ -97,7 +116,7 @@ namespace TJAPlayer3
|
||||
|
||||
this.data.DanTitles[title] = danTitle;
|
||||
|
||||
tSaveFile();
|
||||
//tSaveFile();
|
||||
|
||||
return changed;
|
||||
}
|
||||
@ -114,6 +133,12 @@ namespace TJAPlayer3
|
||||
clearStatus = cs;
|
||||
}
|
||||
|
||||
public CDanTitle()
|
||||
{
|
||||
isGold = false;
|
||||
clearStatus = 0;
|
||||
}
|
||||
|
||||
[JsonProperty("isGold")]
|
||||
public bool isGold;
|
||||
|
||||
@ -166,7 +191,8 @@ namespace TJAPlayer3
|
||||
|
||||
public void tApplyHeyaChanges()
|
||||
{
|
||||
this.tSaveFile();
|
||||
DBSaves.ApplyChangesFromMyRoom(this);
|
||||
//this.tSaveFile();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -198,14 +224,20 @@ namespace TJAPlayer3
|
||||
public string PuchiChara = "0";
|
||||
|
||||
[JsonProperty("medals")]
|
||||
public int Medals = 0;
|
||||
public Int64 Medals = 0;
|
||||
|
||||
[JsonProperty("totalEarnedMedals")]
|
||||
public int TotalEarnedMedals = 0;
|
||||
[JsonIgnore]
|
||||
public Int64 TotalEarnedMedals = 0;
|
||||
|
||||
[JsonProperty("totalPlaycount")]
|
||||
[JsonIgnore]
|
||||
public int TotalPlaycount = 0;
|
||||
|
||||
[JsonIgnore]
|
||||
public int AIBattleModePlaycount = 0;
|
||||
|
||||
[JsonIgnore]
|
||||
public int AIBattleModeWins = 0;
|
||||
|
||||
[JsonProperty("character")]
|
||||
public int Character = 0;
|
||||
|
||||
@ -215,6 +247,7 @@ namespace TJAPlayer3
|
||||
[JsonProperty("danTitles")]
|
||||
public Dictionary<string, CDanTitle> DanTitles = new Dictionary<string, CDanTitle>();
|
||||
|
||||
// Deprecated
|
||||
[JsonProperty("namePlateTitles")]
|
||||
public Dictionary<string, CNamePlateTitle> NamePlateTitles = new Dictionary<string, CNamePlateTitle>();
|
||||
|
||||
@ -224,6 +257,9 @@ namespace TJAPlayer3
|
||||
[JsonProperty("unlockedPuchicharas")]
|
||||
public List<string> UnlockedPuchicharas = new List<string>();
|
||||
|
||||
[JsonIgnore]
|
||||
public List<int> UnlockedNameplateIds = new List<int>();
|
||||
|
||||
[JsonProperty("activeTriggers")]
|
||||
public HashSet<string> ActiveTriggers = new HashSet<string>();
|
||||
|
||||
@ -243,7 +279,7 @@ namespace TJAPlayer3
|
||||
public Dictionary<string, BestPlayRecords.CSongSelectTableEntry> songSelectTableEntries = new Dictionary<string, BestPlayRecords.CSongSelectTableEntry>();
|
||||
|
||||
[JsonIgnore]
|
||||
public BestPlayRecords.CBestPlayStats bestPlaysStats = new BestPlayRecords.CBestPlayStats ();
|
||||
public BestPlayRecords.CBestPlayStats bestPlaysStats = new BestPlayRecords.CBestPlayStats();
|
||||
|
||||
public BestPlayRecords.CSongSelectTableEntry tGetSongSelectTableEntry(string uniqueId)
|
||||
{
|
||||
|
@ -2599,6 +2599,8 @@ for (int i = 0; i < 3; i++) {
|
||||
|
||||
#region [ Read Config.ini and Database files ]
|
||||
//---------------------
|
||||
|
||||
// Port <= 0.5.4 NamePlate.json to Pre 0.6.0 b1 Saves\
|
||||
NamePlateConfig = new NamePlateConfig();
|
||||
NamePlateConfig.tNamePlateConfig();
|
||||
|
||||
@ -2614,19 +2616,23 @@ for (int i = 0; i < 3; i++) {
|
||||
VisualLogManager = new CVisualLogManager();
|
||||
|
||||
|
||||
// Add a condition here (if old Saves\ format save files exist) to port them to database (?)
|
||||
SaveFileInstances = DBSaves.FetchSaveInstances();
|
||||
/*
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
SaveFileInstances[i] = new SaveFile();
|
||||
SaveFileInstances[i].tSaveFile(TJAPlayer3.ConfigIni.sSaveFile[i]);
|
||||
}
|
||||
// 2012.8.22 Config.iniが無いときに初期値が適用されるよう、この設定行をifブロック外に移動
|
||||
*/
|
||||
|
||||
//---------------------
|
||||
#endregion
|
||||
|
||||
#region [ ログ出力開始 ]
|
||||
//---------------------
|
||||
Trace.AutoFlush = true;
|
||||
//---------------------
|
||||
#endregion
|
||||
|
||||
#region [ ログ出力開始 ]
|
||||
//---------------------
|
||||
Trace.AutoFlush = true;
|
||||
if( ConfigIni.bOutputLogs )
|
||||
{
|
||||
try
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using FFmpeg.AutoGen;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@ -6,7 +7,7 @@ using static TJAPlayer3.DBNameplateUnlockables;
|
||||
|
||||
namespace TJAPlayer3
|
||||
{
|
||||
internal class DBNameplateUnlockables : CSavableT<Dictionary<string, NameplateUnlockable>>
|
||||
internal class DBNameplateUnlockables : CSavableT<Dictionary<Int64, NameplateUnlockable>>
|
||||
{
|
||||
public DBNameplateUnlockables()
|
||||
{
|
||||
@ -51,7 +52,7 @@ namespace TJAPlayer3
|
||||
nu.nameplateInfo.cld.SetString(tr, (string)reader[@$"{tr}_String"]);
|
||||
}
|
||||
|
||||
data[((Int64)reader["NameplateId"]).ToString()] = nu;
|
||||
data[((Int64)reader["NameplateId"])] = nu;
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
@ -71,27 +72,31 @@ namespace TJAPlayer3
|
||||
public void tGetUnlockedItems(int _player, ModalQueue mq)
|
||||
{
|
||||
int player = TJAPlayer3.GetActualPlayer(_player);
|
||||
var _sf = TJAPlayer3.SaveFileInstances[player].data.NamePlateTitles;
|
||||
//var _sf = TJAPlayer3.SaveFileInstances[player].data.NamePlateTitles;
|
||||
var _sf = TJAPlayer3.SaveFileInstances[player].data.UnlockedNameplateIds;
|
||||
bool _edited = false;
|
||||
|
||||
foreach (KeyValuePair<string, NameplateUnlockable> item in data)
|
||||
foreach (KeyValuePair<Int64, NameplateUnlockable> item in data)
|
||||
{
|
||||
var _npvKey = item.Key;
|
||||
if (!_sf.ContainsKey(_npvKey))
|
||||
var _npvKey = (int)item.Key;
|
||||
if (!_sf.Contains(_npvKey))// !_sf.ContainsKey(_npvKey))
|
||||
{
|
||||
var _fulfilled = item.Value.unlockConditions.tConditionMetWrapper(player, DBUnlockables.CUnlockConditions.EScreen.Internal).Item1;
|
||||
|
||||
if (_fulfilled)
|
||||
{
|
||||
_sf.Add(_npvKey, item.Value.nameplateInfo);
|
||||
//_sf.Add(_npvKey, item.Value.nameplateInfo);
|
||||
_sf.Add(_npvKey);
|
||||
_edited = true;
|
||||
mq.tAddModal(
|
||||
new Modal(
|
||||
Modal.EModalType.Title,
|
||||
HRarity.tRarityToModalInt(item.Value.rarity),
|
||||
item.Value.nameplateInfo.cld.GetString(item.Key)
|
||||
item.Value.nameplateInfo.cld.GetString("") // Cannot be null on database
|
||||
),
|
||||
_player);
|
||||
|
||||
DBSaves.RegisterUnlockedNameplate(TJAPlayer3.SaveFileInstances[player].data.SaveId, _npvKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,210 @@ namespace TJAPlayer3
|
||||
return TJAPlayer3.SaveFileInstances[TJAPlayer3.GetActualPlayer(player)].data.SaveId;
|
||||
}
|
||||
|
||||
|
||||
#region [Unlocked Dan Titles]
|
||||
|
||||
public static Dictionary<string, SaveFile.CDanTitle> FetchUnlockedDanTitles(Int64 sid)
|
||||
{
|
||||
Dictionary<string, SaveFile.CDanTitle> _dans = new Dictionary<string, SaveFile.CDanTitle>();
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return _dans;
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @$"SELECT * FROM dan_titles WHERE SaveId={sid};";
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
SaveFile.CDanTitle dt = new SaveFile.CDanTitle();
|
||||
|
||||
string key = (string)reader["DanTitleText"];
|
||||
dt.isGold = Convert.ToBoolean((int)(Int64)reader["DanIsGold"]);
|
||||
dt.clearStatus = (int)(Int64)reader["DanClearStatus"];
|
||||
_dans[key] = dt;
|
||||
}
|
||||
reader.Close();
|
||||
|
||||
return _dans;
|
||||
}
|
||||
|
||||
public static void RegisterDanTitle(Int64 SaveId, string DanTitle, int DanClearStatus, bool DanIsGold)
|
||||
{
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return;
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
|
||||
command.CommandText = $@"INSERT INTO dan_titles(DanTitleText,DanClearStatus,DanIsGold,SaveId)
|
||||
VALUES(
|
||||
'{DanTitle.Replace(@"'", @"''")}',
|
||||
{DanClearStatus},
|
||||
{Convert.ToInt64(DanIsGold)},
|
||||
{SaveId}
|
||||
)
|
||||
ON CONFLICT(DanTitleText) DO UPDATE SET
|
||||
DanClearStatus = MAX(DanClearStatus, EXCLUDED.DanClearStatus),
|
||||
DanIsGold = MAX(DanIsGold, EXCLUDED.DanIsGold),
|
||||
SaveId = EXCLUDED.SaveId
|
||||
;";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region [Unlocked Nameplates]
|
||||
|
||||
public static List<int> FetchUnlockedNameplateIds(Int64 sid)
|
||||
{
|
||||
List<int> _nps = new List<int>();
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return _nps;
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @$"SELECT * FROM nameplate_titles WHERE SaveId={sid};";
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
_nps.Add((int)(Int64)reader["NameplateId"]);
|
||||
}
|
||||
reader.Close();
|
||||
|
||||
return _nps;
|
||||
}
|
||||
|
||||
public static void RegisterUnlockedNameplate(Int64 SaveId, Int64 NameplateId)
|
||||
{
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return;
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @$"INSERT INTO nameplate_titles(NameplateId,SaveId) VALUES({NameplateId}, {SaveId});";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region [Characters and Puchicharas]
|
||||
|
||||
public static List<string> FetchStringUnlockedAsset(Int64 sid, string table)
|
||||
{
|
||||
List<string> _chara = new List<string>();
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return _chara;
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @$"SELECT * FROM {table} WHERE SaveId={sid};";
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
_chara.Add((string)reader["Asset"]);
|
||||
}
|
||||
reader.Close();
|
||||
|
||||
return _chara;
|
||||
}
|
||||
|
||||
public static void RegisterStringUnlockedAsset(Int64 SaveId, string table, string asset)
|
||||
{
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return;
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @$"INSERT INTO {table}(Asset,SaveId) VALUES('{asset.Replace(@"'", @"''")}', {SaveId});";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region [saves Table]
|
||||
|
||||
public static SaveFile[] FetchSaveInstances()
|
||||
{
|
||||
SaveFile[] _instances = new SaveFile[5] { new SaveFile(), new SaveFile(), new SaveFile(), new SaveFile(), new SaveFile() };
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return _instances;
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @$"SELECT * FROM saves WHERE CurrentSlot IS NOT NULL ORDER BY CurrentSlot ASC;";
|
||||
SqliteDataReader reader = command.ExecuteReader();
|
||||
int _file = 0;
|
||||
while (reader.Read())
|
||||
{
|
||||
SaveFile sf = new SaveFile();
|
||||
|
||||
sf.data.SaveId = (Int64)reader["SaveId"];
|
||||
sf.data.Name = (string)reader["PlayerName"];
|
||||
sf.data.Title = (string)reader["PlayerNameplateTitle"];
|
||||
sf.data.Dan = (string)reader["PlayerDanTitle"];
|
||||
sf.data.DanGold = Convert.ToBoolean((Int64)reader["PlayerDanGold"]);
|
||||
sf.data.DanType = (int)(Int64)reader["PlayerDanType"];
|
||||
sf.data.TitleType = (int)(Int64)reader["PlayerNameplateType"];
|
||||
sf.data.PuchiChara = (string)reader["PlayerPuchichara"];
|
||||
sf.data.Character = (int)(Int64)reader["PlayerCharacter"];
|
||||
sf.data.CharacterName = (string)reader["PlayerCharacterName"];
|
||||
sf.data.Medals = (Int64)reader["CurrentMedals"];
|
||||
sf.data.TotalEarnedMedals = (Int64)reader["TotalEarnedMedals"];
|
||||
sf.data.TotalPlaycount = (int)(Int64)reader["TotalPlaycount"];
|
||||
sf.data.AIBattleModePlaycount = (int)(Int64)reader["AIBattleModePlaycount"];
|
||||
sf.data.AIBattleModeWins = (int)(Int64)reader["AIBattleModeWins"];
|
||||
sf.tInitSaveFile();
|
||||
sf.tLoadUnlockables();
|
||||
|
||||
_instances[_file] = sf;
|
||||
_file++;
|
||||
if (_file >= 5) break;
|
||||
}
|
||||
reader.Close();
|
||||
|
||||
return _instances;
|
||||
}
|
||||
|
||||
public static void AlterCoinsAndTotalPlayCount(Int64 SaveId, Int64 CoinsDelta, int PlayCountDelta)
|
||||
{
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return;
|
||||
|
||||
Int64 TotalEarnedCoinsDelta = Math.Max(0, CoinsDelta);
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @$"UPDATE saves SET TotalPlaycount = TotalPlaycount + {PlayCountDelta}, CurrentMedals = CurrentMedals + {CoinsDelta}, TotalEarnedMedals = TotalEarnedMedals + {TotalEarnedCoinsDelta} WHERE SaveId = {SaveId};";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public static void RegisterAIBattleModePlay(Int64 SaveId, bool IsWon)
|
||||
{
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return;
|
||||
|
||||
Int64 AIBattleWinsDelta = (IsWon) ? 1 : 0;
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @$"UPDATE saves SET AIBattleModePlaycount = AIBattleModePlaycount + 1, AIBattleModeWins = AIBattleModeWins + {AIBattleWinsDelta} WHERE SaveId = {SaveId};";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public static void ApplyChangesFromMyRoom(SaveFile File)
|
||||
{
|
||||
SqliteConnection? connection = GetSavesDBConnection();
|
||||
if (connection == null) return;
|
||||
|
||||
SaveFile.Data SaveData = File.data;
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = $@" UPDATE saves SET
|
||||
PlayerName = '{SaveData.Name.Replace(@"'", @"''")}',
|
||||
PlayerNameplateTitle = '{SaveData.Title.Replace(@"'", @"''")}',
|
||||
PlayerDanTitle = '{SaveData.Dan.Replace(@"'", @"''")}',
|
||||
PlayerDanGold = {SaveData.DanGold},
|
||||
PlayerDanType = {SaveData.DanType},
|
||||
PlayerNameplateType = {SaveData.TitleType},
|
||||
PlayerPuchichara = '{SaveData.PuchiChara.Replace(@"'", @"''")}',
|
||||
PlayerCharacter = {SaveData.Character},
|
||||
PlayerCharacterName = '{SaveData.CharacterName.Replace(@"'", @"''")}'
|
||||
WHERE SaveId = {SaveData.SaveId};
|
||||
;";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region [best_plays Table]
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace TJAPlayer3
|
||||
public void tGetUnlockedItems(int _player, ModalQueue mq)
|
||||
{
|
||||
int player = TJAPlayer3.GetActualPlayer(_player);
|
||||
var _sf = TJAPlayer3.SaveFileInstances[player].data.NamePlateTitles;
|
||||
var _sf = TJAPlayer3.SaveFileInstances[player].data.NamePlateTitles; // Placeholder
|
||||
bool _edited = false;
|
||||
|
||||
foreach (KeyValuePair<string, SongUnlockable> item in data)
|
||||
|
@ -113,7 +113,7 @@ namespace TJAPlayer3
|
||||
case "cs":
|
||||
case "cm":
|
||||
if (this.Values.Length == 1)
|
||||
return tConditionMet(new int[] { TJAPlayer3.SaveFileInstances[player].data.Medals }, screen);
|
||||
return tConditionMet(new int[] { (int)TJAPlayer3.SaveFileInstances[player].data.Medals }, screen);
|
||||
else
|
||||
return (false, CLangManager.LangInstance.GetString(90005) + this.Condition + " requires " + this.RequiredArgCount.ToString() + " values.");
|
||||
case "dp":
|
||||
|
@ -740,7 +740,7 @@ namespace TJAPlayer3
|
||||
int p = TJAPlayer3.GetActualPlayer(i);
|
||||
|
||||
if (TJAPlayer3.SaveFileInstances[p].data.Medals >= 0)
|
||||
tBoardNumberDraw(TJAPlayer3.Skin.SongSelect_BoardNumber_X[i][11], TJAPlayer3.Skin.SongSelect_BoardNumber_Y[i][11], TJAPlayer3.SaveFileInstances[p].data.Medals);
|
||||
tBoardNumberDraw(TJAPlayer3.Skin.SongSelect_BoardNumber_X[i][11], TJAPlayer3.Skin.SongSelect_BoardNumber_Y[i][11], (int)TJAPlayer3.SaveFileInstances[p].data.Medals);
|
||||
|
||||
#region [HiScore plate]
|
||||
|
||||
|
@ -586,6 +586,11 @@ namespace TJAPlayer3
|
||||
|
||||
var _sf = TJAPlayer3.SaveFileInstances[TJAPlayer3.GetActualPlayer(i)];
|
||||
|
||||
if (TJAPlayer3.ConfigIni.bAIBattleMode && i == 0)
|
||||
{
|
||||
_sf.tRegisterAIBattleModePlay(bClear[0]);
|
||||
}
|
||||
|
||||
_sf.tEarnCoins(this.nEarnedMedalsCount[i]);
|
||||
|
||||
if (!TJAPlayer3.ConfigIni.bAutoPlay[i]
|
||||
|
@ -88,24 +88,29 @@ namespace TJAPlayer3
|
||||
#region [Plate title]
|
||||
|
||||
amount = 1;
|
||||
if (TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles != null)
|
||||
amount += TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles.Count;
|
||||
if (TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedNameplateIds != null)
|
||||
amount += TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedNameplateIds.Count;
|
||||
|
||||
this.ttkTitles = new TitleTextureKey[amount];
|
||||
this.titlesKeys = new string[amount];
|
||||
this.titlesKeys = new int[amount];
|
||||
|
||||
// Wood shojinsha (default title) always avaliable by default
|
||||
// Wood shoshinsha (default title) always avaliable by default
|
||||
this.ttkTitles[0] = new TitleTextureKey("初心者", this.pfHeyaFont, Color.Black, Color.Transparent, 1000);
|
||||
this.titlesKeys[0] = "初心者";
|
||||
this.titlesKeys[0] = 0; // Regular nameplate unlockable start by 1 (Important)
|
||||
|
||||
idx = 1;
|
||||
if (TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles != null)
|
||||
if (TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedNameplateIds != null)
|
||||
{
|
||||
foreach (var item in TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles)
|
||||
foreach (var _ref in TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedNameplateIds)
|
||||
{
|
||||
this.ttkTitles[idx] = new TitleTextureKey(item.Value.cld.GetString(item.Key), this.pfHeyaFont, Color.Black, Color.Transparent, 1000);
|
||||
this.titlesKeys[idx] = item.Key;
|
||||
idx++;
|
||||
var item = TJAPlayer3.Databases.DBNameplateUnlockables.data?[_ref];
|
||||
if (item != null)
|
||||
{
|
||||
this.ttkTitles[idx] = new TitleTextureKey(item.nameplateInfo.cld.GetString(""), this.pfHeyaFont, Color.Black, Color.Transparent, 1000);
|
||||
this.titlesKeys[idx] = _ref;
|
||||
idx++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,9 +454,13 @@ namespace TJAPlayer3
|
||||
|
||||
int iType = -1;
|
||||
|
||||
if (TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles != null &&
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles.ContainsKey(this.titlesKeys[pos]))
|
||||
iType = TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles[this.titlesKeys[pos]].iType;
|
||||
if (TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedNameplateIds != null &&
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedNameplateIds.Contains(this.titlesKeys[pos]))
|
||||
{
|
||||
var _dc = TJAPlayer3.Databases.DBNameplateUnlockables.data[this.titlesKeys[pos]];
|
||||
iType = _dc.nameplateInfo.iType;
|
||||
//iType = TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles[this.titlesKeys[pos]].iType;
|
||||
}
|
||||
else if (pos == 0)
|
||||
iType = 0;
|
||||
|
||||
@ -601,6 +610,7 @@ namespace TJAPlayer3
|
||||
//TJAPlayer3.NamePlateConfig.data.UnlockedPuchicharas[iPlayer].Add(TJAPlayer3.Skin.Puchicharas_Name[iPuchiCharaCurrent]);
|
||||
//TJAPlayer3.NamePlateConfig.tSpendCoins(TJAPlayer3.Tx.Puchichara[iPuchiCharaCurrent].unlock.Values[0], iPlayer);
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedPuchicharas.Add(TJAPlayer3.Skin.Puchicharas_Name[iPuchiCharaCurrent]);
|
||||
DBSaves.RegisterStringUnlockedAsset(TJAPlayer3.SaveFileInstances[iPlayer].data.SaveId, "unlocked_puchicharas", TJAPlayer3.Skin.Puchicharas_Name[iPuchiCharaCurrent]);
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].tSpendCoins(TJAPlayer3.Tx.Puchichara[iPuchiCharaCurrent].unlock.Values[0]);
|
||||
|
||||
}
|
||||
@ -634,8 +644,8 @@ namespace TJAPlayer3
|
||||
else if (ess == ESelectStatus.SUCCESS)
|
||||
{
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedCharacters.Add(TJAPlayer3.Skin.Characters_DirName[iCharacterCurrent]);
|
||||
DBSaves.RegisterStringUnlockedAsset(TJAPlayer3.SaveFileInstances[iPlayer].data.SaveId, "unlocked_characters", TJAPlayer3.Skin.Characters_DirName[iCharacterCurrent]);
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].tSpendCoins(TJAPlayer3.Tx.Characters[iCharacterCurrent].unlock.Values[0]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -666,9 +676,13 @@ namespace TJAPlayer3
|
||||
{
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].data.Title = this.ttkTitles[iTitleCurrent].str文字;
|
||||
|
||||
if (TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles != null
|
||||
&& TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles.ContainsKey(this.titlesKeys[iTitleCurrent]))
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].data.TitleType = TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles[this.titlesKeys[iTitleCurrent]].iType;
|
||||
if (TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedNameplateIds != null
|
||||
&& TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedNameplateIds.Contains(this.titlesKeys[iTitleCurrent]))
|
||||
{
|
||||
var _dc = TJAPlayer3.Databases.DBNameplateUnlockables.data[this.titlesKeys[iTitleCurrent]];
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].data.TitleType = _dc.nameplateInfo.iType;
|
||||
}
|
||||
|
||||
else if (iTitleCurrent == 0)
|
||||
TJAPlayer3.SaveFileInstances[iPlayer].data.TitleType = 0;
|
||||
else
|
||||
@ -766,15 +780,19 @@ namespace TJAPlayer3
|
||||
private void tResetOpts()
|
||||
{
|
||||
// Retrieve titles if they exist
|
||||
var _titles = TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles;
|
||||
//var _titles = TJAPlayer3.SaveFileInstances[iPlayer].data.NamePlateTitles;
|
||||
var _titles = TJAPlayer3.SaveFileInstances[iPlayer].data.UnlockedNameplateIds;
|
||||
var _title = TJAPlayer3.SaveFileInstances[iPlayer].data.Title;
|
||||
var _dans = TJAPlayer3.SaveFileInstances[iPlayer].data.DanTitles;
|
||||
var _dan = TJAPlayer3.SaveFileInstances[iPlayer].data.Dan;
|
||||
|
||||
iTitleCurrent = 0;
|
||||
|
||||
if (_titles != null && _titles.ContainsKey(_title))
|
||||
// Think of a replacement later
|
||||
/*
|
||||
if (_titles != null && _titles.ContainsKey(_title)) { }
|
||||
iTitleCurrent = _titles.Keys.ToList().IndexOf(_title) + 1;
|
||||
*/
|
||||
|
||||
iDanTitleCurrent = 0;
|
||||
|
||||
@ -962,7 +980,7 @@ namespace TJAPlayer3
|
||||
private TitleTextureKey[] ttkDanTitles;
|
||||
|
||||
private TitleTextureKey[] ttkTitles;
|
||||
private string[] titlesKeys;
|
||||
private int[] titlesKeys;
|
||||
|
||||
private int iPuchiCharaCount;
|
||||
private int iCharacterCount;
|
||||
|
Loading…
x
Reference in New Issue
Block a user