From a3b39ebe7fd5da5eac7c96c84c2f72cb2b4a19e9 Mon Sep 17 00:00:00 2001 From: 0auBSQ <58159635+0auBSQ@users.noreply.github.com> Date: Fri, 21 Jun 2024 09:42:25 +0900 Subject: [PATCH] Saves attached to database --- OpenTaiko/Saves.db3 | Bin 86016 -> 106496 bytes OpenTaiko/src/Common/SaveFile.cs | 58 ++++- OpenTaiko/src/Common/TJAPlayer3.cs | 18 +- .../src/Databases/DBNameplateUnlockables.cs | 21 +- OpenTaiko/src/Databases/DBSaves.cs | 205 +++++++++++++++++- OpenTaiko/src/Databases/DBSongUnlockables.cs | 2 +- OpenTaiko/src/Databases/DBUnlockables.cs | 2 +- .../src/Stages/05.SongSelect/CStage選曲.cs | 2 +- OpenTaiko/src/Stages/08.Result/CStage結果.cs | 5 + OpenTaiko/src/Stages/11.Heya/CStageHeya.cs | 58 +++-- 10 files changed, 322 insertions(+), 49 deletions(-) diff --git a/OpenTaiko/Saves.db3 b/OpenTaiko/Saves.db3 index a31f0b194ea8028a501d00051b6c60abc97f5c7b..2471c01299b827195db69aabbb5fe9f10dd44654 100644 GIT binary patch delta 1913 zcmb7_Z)h839LJyMp3CL#lH9K;wMiP%HBHhcZC$SU2Q7-lS+rA2wH6hHTdP5~#>_RD z;v3Tm?$wai6Ayi(xHrBKbPFtVZ#qzPf>8FVFpEr(ir|}x8zS54^IY@ib~mP8c%FN5 z_qpHm`+e_uzPI{`YxSbA7WM}bLVdJ_Xd|?Zua9MM@XVo)0f){`@dI80TL`Yf7VN;q zdUW6m$N=o10InP>Eos%_tFLL*#ideFD+oTBM8%gE%UbntwN$J~9zvd;V<|Dey2)bg)4Rc)Hg8XA{Yw->s>C^^E~SbVLitYB1wdZ;@K&WTKBA7uf2DO z?{+IU5c~+|U=5DIBM?z;P_3^jwM1KMxQEtiqAj)+vm|Zitj61Fw=k#LDj#pl4YlT^ zPPtVQZ|mI&X4hNgVr{`&lv8ju)>ga)H5DJREGX6I89^QrLEa7NJNY-|D`my^tn`++ z;tP5oBaue`0N&*qtCM)a)mTa5^BnK<f)36AAnSXK2G% z6z5BF4xL*_8<*2KsBgQv!Z|Hte=--MP{ji6%W2~dNTARQY{8{s`X&sD8M;H|9Qjbc z3`1dhlavF206z8nUbbxanp@b_C?{}+({C$J82w4?HLefi=gj1K=1WJbgVN0GGt-Yw zKRvK8JM+}Sv~e(rlRTYjzpn+dB|J^$w$I{BPNRL~f zeR*fXdG`4bX+x=@_R=a=LUJ8Xk*;nxT)CUWJ;0po-yM#5q#L#o{7gS1ZJ(qb`7KQH z1Yv=7_i)IT$I>t?O%DEspWsjWJ^LCSG@swIRcJXXLbiY$M;~JcJF`XX+Oujig~WeK Jf$Fde{{W%-?EC-# delta 672 zcmZoTz}B#Ub%L}Y9|Hq}C=d$)F(VMmP1G@F6TWwadUji5WwU35FUb3^m3W zY8WxpxEo<8V!%*jh^~eU?3pJ_{D1g=@PFWc#s388nM?dytjvszEG!_BnHfYfF)=VO zGjnn>Gjni&0)UDC83X?_{*U|@fa(wNEAoG25aTE=%t?wbNzE;YFG)!g zPAp3;W}W=eUVJl$z#sX=ECLFfSsMQIPYmE@7eumi@`HE@C7{tPyu5-8JggxMJo~w| zc)B=`bG_u-$ydZ1&RNG%#4E8~PJ!`1)8zZyywe+07;QGEF~4KvYLgaW7Z(?2>=E58 z&AXU!`UV?D{^=8J7$;0lW|Wvd!Hkh(`bjg!-pMQYRks&uFz#U5ti}DDal4={<3}bT zKL%D#J_i1)oY%P;I2Up9aZUmHNsJ|s%a1inTwkAYN-fws7{0?0;BgLebqsM;2yt}s zaaB;lke{s0balI)3gbTJ>DiWyC#QSpFqX3beQY%Sygs7>Usr-8JJ`N_kbT=_l^H`> TnKVTwpXb+P DanTitles = new Dictionary(); + // Deprecated [JsonProperty("namePlateTitles")] public Dictionary NamePlateTitles = new Dictionary(); @@ -224,6 +257,9 @@ namespace TJAPlayer3 [JsonProperty("unlockedPuchicharas")] public List UnlockedPuchicharas = new List(); + [JsonIgnore] + public List UnlockedNameplateIds = new List(); + [JsonProperty("activeTriggers")] public HashSet ActiveTriggers = new HashSet(); @@ -243,7 +279,7 @@ namespace TJAPlayer3 public Dictionary songSelectTableEntries = new Dictionary(); [JsonIgnore] - public BestPlayRecords.CBestPlayStats bestPlaysStats = new BestPlayRecords.CBestPlayStats (); + public BestPlayRecords.CBestPlayStats bestPlaysStats = new BestPlayRecords.CBestPlayStats(); public BestPlayRecords.CSongSelectTableEntry tGetSongSelectTableEntry(string uniqueId) { diff --git a/OpenTaiko/src/Common/TJAPlayer3.cs b/OpenTaiko/src/Common/TJAPlayer3.cs index 2861c0e1..a85cd27f 100644 --- a/OpenTaiko/src/Common/TJAPlayer3.cs +++ b/OpenTaiko/src/Common/TJAPlayer3.cs @@ -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 diff --git a/OpenTaiko/src/Databases/DBNameplateUnlockables.cs b/OpenTaiko/src/Databases/DBNameplateUnlockables.cs index 85b68336..6ca935b3 100644 --- a/OpenTaiko/src/Databases/DBNameplateUnlockables.cs +++ b/OpenTaiko/src/Databases/DBNameplateUnlockables.cs @@ -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> + internal class DBNameplateUnlockables : CSavableT> { 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 item in data) + foreach (KeyValuePair 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); } } } diff --git a/OpenTaiko/src/Databases/DBSaves.cs b/OpenTaiko/src/Databases/DBSaves.cs index 747aebda..2b2a9718 100644 --- a/OpenTaiko/src/Databases/DBSaves.cs +++ b/OpenTaiko/src/Databases/DBSaves.cs @@ -36,7 +36,210 @@ namespace TJAPlayer3 return TJAPlayer3.SaveFileInstances[TJAPlayer3.GetActualPlayer(player)].data.SaveId; } - + #region [Unlocked Dan Titles] + + public static Dictionary FetchUnlockedDanTitles(Int64 sid) + { + Dictionary _dans = new Dictionary(); + 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 FetchUnlockedNameplateIds(Int64 sid) + { + List _nps = new List(); + 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 FetchStringUnlockedAsset(Int64 sid, string table) + { + List _chara = new List(); + 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] diff --git a/OpenTaiko/src/Databases/DBSongUnlockables.cs b/OpenTaiko/src/Databases/DBSongUnlockables.cs index 9b84b5f5..705d46ef 100644 --- a/OpenTaiko/src/Databases/DBSongUnlockables.cs +++ b/OpenTaiko/src/Databases/DBSongUnlockables.cs @@ -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 item in data) diff --git a/OpenTaiko/src/Databases/DBUnlockables.cs b/OpenTaiko/src/Databases/DBUnlockables.cs index 5f671a2b..af000e1d 100644 --- a/OpenTaiko/src/Databases/DBUnlockables.cs +++ b/OpenTaiko/src/Databases/DBUnlockables.cs @@ -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": diff --git a/OpenTaiko/src/Stages/05.SongSelect/CStage選曲.cs b/OpenTaiko/src/Stages/05.SongSelect/CStage選曲.cs index 6fc1bed3..0efb3bfb 100644 --- a/OpenTaiko/src/Stages/05.SongSelect/CStage選曲.cs +++ b/OpenTaiko/src/Stages/05.SongSelect/CStage選曲.cs @@ -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] diff --git a/OpenTaiko/src/Stages/08.Result/CStage結果.cs b/OpenTaiko/src/Stages/08.Result/CStage結果.cs index f3319c4e..5bc9a470 100644 --- a/OpenTaiko/src/Stages/08.Result/CStage結果.cs +++ b/OpenTaiko/src/Stages/08.Result/CStage結果.cs @@ -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] diff --git a/OpenTaiko/src/Stages/11.Heya/CStageHeya.cs b/OpenTaiko/src/Stages/11.Heya/CStageHeya.cs index b7c198ca..ca64dbfb 100644 --- a/OpenTaiko/src/Stages/11.Heya/CStageHeya.cs +++ b/OpenTaiko/src/Stages/11.Heya/CStageHeya.cs @@ -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;