From fb9476d1cf1bea5154b789553f157ecdc4311acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Wed, 21 Aug 2013 20:55:49 +0200 Subject: [PATCH] Save DatabaseSongID to CSong for (should be) faster saving of NumPlayed and Scores. --- Vocaluxe/Base/CDataBase.cs | 5 +++-- Vocaluxe/Base/CMain.cs | 4 ++-- Vocaluxe/Screens/CScreenScore.cs | 5 +++-- VocaluxeLib/IBasic.cs | 2 +- VocaluxeLib/Songs/CSong.cs | 5 ++++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 77d1fc32..17c88bfc 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -72,7 +72,7 @@ namespace Vocaluxe.Base #region Highscores - public static bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded) + public static bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded, out int highscoreID) { string sArtist = string.Empty; string sTitle = string.Empty; @@ -92,6 +92,7 @@ namespace Vocaluxe.Base using (SQLiteCommand command = new SQLiteCommand(connection)) { songID = _GetDataBaseSongID(artist, title, 0, command); + highscoreID = songID; } } return _GetDataBaseSongInfos(songID, out sArtist, out sTitle, out numPlayed, out dateAdded, _HighscoreFilePath); @@ -182,7 +183,7 @@ namespace Vocaluxe.Base using (SQLiteCommand command = new SQLiteCommand(connection)) { - int dataBaseSongID = _GetDataBaseSongID(player, command); + int dataBaseSongID = CSongs.GetSong(player.SongID).DataBaseSongID; return _AddScore(CProfiles.GetPlayerName(player.ProfileID), (int)Math.Round(player.Points), player.LineNr, player.DateTicks, player.Medley ? 1 : 0, player.Duet ? 1 : 0, player.ShortSong ? 1 : 0, (int)CProfiles.GetDifficulty(player.ProfileID), dataBaseSongID, command); } diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index cd9fb657..fdf8a305 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -783,9 +783,9 @@ namespace Vocaluxe.Base return CDataBase.GetCover(fileName, ref texture, coverSize); } - public bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded) + public bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded, out int highscoreID) { - return CDataBase.GetDataBaseSongInfos(artist, title, out numPlayed, out dateAdded); + return CDataBase.GetDataBaseSongInfos(artist, title, out numPlayed, out dateAdded, out highscoreID); } } diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index 076f16db..bbed2113 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -401,8 +401,9 @@ namespace Vocaluxe.Screens { if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished) { - CDataBase.IncreaseSongCounter(players[p]); - CSongs.GetSong(players[p].SongID).NumPlayed++; + CSong song = CSongs.GetSong(players[p].SongID); + CDataBase.IncreaseSongCounter(song.DataBaseSongID); + song.NumPlayed++; break; } } diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index 703dc18d..afbbf8d4 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -262,7 +262,7 @@ namespace VocaluxeLib public interface IDataBase { bool GetCover(string fileName, ref CTexture texture, int coverSize); - bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded); + bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded, out int highscoreID); } public interface IControllers diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index 9b13585b..d999f5c4 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -147,6 +147,7 @@ namespace VocaluxeLib.Songs public readonly List Language = new List(); + public int DataBaseSongID = -1; public string DateAdded = ""; public int NumPlayed = 0; @@ -243,7 +244,9 @@ namespace VocaluxeLib.Songs foreach (string value in song.Language) Language.Add(value); + DataBaseSongID = song.DataBaseSongID; DateAdded = song.DateAdded; + NumPlayed = song.NumPlayed; Notes = new CNotes(song.Notes); } @@ -535,7 +538,7 @@ namespace VocaluxeLib.Songs sr.Dispose(); _CheckFiles(); - CBase.DataBase.GetDataBaseSongInfos(Artist, Title, out NumPlayed, out DateAdded); + CBase.DataBase.GetDataBaseSongInfos(Artist, Title, out NumPlayed, out DateAdded, out DataBaseSongID); //Before saving this tags to .txt: Check, if ArtistSorting and Artist are equal, then don't save this tag. if (ArtistSorting == "")