From 1083311f8ca53aa53cf689113c46e35d9e6648db Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Fri, 21 Dec 2012 12:10:49 +0100 Subject: [PATCH 01/10] Add function to update db to v3 --- Vocaluxe/Base/CDataBase.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 8cd56939..4806773b 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -1005,6 +1005,25 @@ namespace Vocaluxe.Base return true; } + private static bool ConvertV2toV3(SQLiteConnection connection) + { + SQLiteCommand command; + + command = new SQLiteCommand(connection); + + command.CommandText = "ALTER TABLE Songs ADD DateAdded BIGINT"; + command.ExecuteNonQuery(); + command.CommandText = "UPDATE Songs SET [DateAdded] = @DateAdded"; + command.Parameters.Add("@DateAdded",System.Data.DbType.Int64, 0).Value = DateTime.Now.Ticks; + command.ExecuteNonQuery(); + command.CommandText = "UPDATE Version SET [Value] = @version"; + command.Parameters.Add("@version", System.Data.DbType.Int32, 0).Value = 2; + command.ExecuteNonQuery(); + command.Dispose(); + + return true; + } + private static bool ImportData(string SourceDBPath, string DestinationDBPath) { #region open db From 51f7ce1cc03ea1b7a16c691f919c3b2f8d76c77e Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Fri, 21 Dec 2012 15:45:16 +0100 Subject: [PATCH 02/10] Read and set date added. TODO: Insert when reading song. --- Vocaluxe/Base/CDataBase.cs | 25 ++++++++++++++++++------- Vocaluxe/Base/CSettings.cs | 2 +- VocaluxeLib/Menu/SongMenu/CSong.cs | 3 +++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index ac00fa6f..73ee6401 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -354,11 +354,12 @@ namespace Vocaluxe.Base if (reader != null) reader.Close(); - command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " + - "VALUES (@title, @artist, @numplayed)"; + command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed, DateAdded) " + + "VALUES (@title, @artist, @numplayed, @dateadded)"; command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = Title; command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = Artist; command.Parameters.Add("@numplayed", System.Data.DbType.Int32, 0).Value = DefNumPlayed; + command.Parameters.Add("@dateadded", System.Data.DbType.Int64, 0).Value = DateTime.Now.Ticks; command.ExecuteNonQuery(); command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist"; @@ -394,11 +395,12 @@ namespace Vocaluxe.Base return -1; } - private static bool GetDataBaseSongInfos(int SongID, out string Artist, out string Title, out int NumPlayed, string FilePath) + private static bool GetDataBaseSongInfos(int SongID, out string Artist, out string Title, out int NumPlayed, out string DateAdded, string FilePath) { Artist = String.Empty; Title = String.Empty; NumPlayed = 0; + DateAdded = String.Empty; SQLiteConnection connection = new SQLiteConnection(); connection.ConnectionString = "Data Source=" + FilePath; @@ -414,7 +416,7 @@ namespace Vocaluxe.Base } command = new SQLiteCommand(connection); - command.CommandText = "SELECT Artist, Title, NumPlayed FROM Songs WHERE [id] = @id"; + command.CommandText = "SELECT Artist, Title, NumPlayed, DateAdded FROM Songs WHERE [id] = @id"; command.Parameters.Add("@id", System.Data.DbType.String, 0).Value = SongID; SQLiteDataReader reader = null; @@ -433,6 +435,7 @@ namespace Vocaluxe.Base Artist = reader.GetString(0); Title = reader.GetString(1); NumPlayed = reader.GetInt32(2); + DateAdded = reader.GetInt64(3).ToString("dd/MM/yyyy"); reader.Close(); reader.Dispose(); @@ -613,12 +616,14 @@ namespace Vocaluxe.Base CreateHighscoreDBV1(FilePath); ConvertFrom110(FilePath); UpdateDatabase(1, connection); + UpdateDatabase(2, connection); } else if (version == 0 && scoresTableExists) //Check for USDX 1.01 or CMD Mod DB { CreateHighscoreDBV1(FilePath); ConvertFrom101(FilePath); UpdateDatabase(1, connection); + UpdateDatabase(2, connection); } else CreateHighscoreDB(FilePath); @@ -631,12 +636,14 @@ namespace Vocaluxe.Base CreateHighscoreDBV1(FilePath); ConvertFrom110(FilePath); UpdateDatabase(1, connection); + UpdateDatabase(2, connection); } else if (version == 0 && scoresTableExists) //Check for USDX 1.01 or CMD Mod DB { CreateHighscoreDBV1(FilePath); ConvertFrom101(FilePath); UpdateDatabase(1, connection); + UpdateDatabase(2, connection); } else CreateHighscoreDB(FilePath); @@ -983,6 +990,10 @@ namespace Vocaluxe.Base { updated &= ConvertV1toV2(connection); } + if (CurrentVersion < 3) + { + updated &= ConvertV2toV3(connection); + } return updated; } @@ -1017,7 +1028,7 @@ namespace Vocaluxe.Base command.Parameters.Add("@DateAdded",System.Data.DbType.Int64, 0).Value = DateTime.Now.Ticks; command.ExecuteNonQuery(); command.CommandText = "UPDATE Version SET [Value] = @version"; - command.Parameters.Add("@version", System.Data.DbType.Int32, 0).Value = 2; + command.Parameters.Add("@version", System.Data.DbType.Int32, 0).Value = 3; command.ExecuteNonQuery(); command.Dispose(); @@ -1074,9 +1085,9 @@ namespace Vocaluxe.Base int shortsong = rSource.GetInt32(7); int diff = rSource.GetInt32(8); - string artist, title; + string artist, title, dateadded; int numplayed; - if (GetDataBaseSongInfos(songid, out artist, out title, out numplayed, SourceDBPath)) + if (GetDataBaseSongInfos(songid, out artist, out title, out numplayed, out dateadded, SourceDBPath)) { AddScore(player, score, linenr, date, medley, duet, shortsong, diff, artist, title, numplayed, _HighscoreFilePath); } diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 27c65435..3fc56354 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -44,7 +44,7 @@ namespace Vocaluxe.Base public const int iBuild = 72; // Increase on every published version! Never Reset! - public const int iDatabaseHighscoreVersion = 2; + public const int iDatabaseHighscoreVersion = 3; public const int iDatabaseCoverVersion = 1; public const int iDatabaseCreditsRessourcesVersion = 1; diff --git a/VocaluxeLib/Menu/SongMenu/CSong.cs b/VocaluxeLib/Menu/SongMenu/CSong.cs index daeffcee..0056aab1 100644 --- a/VocaluxeLib/Menu/SongMenu/CSong.cs +++ b/VocaluxeLib/Menu/SongMenu/CSong.cs @@ -173,6 +173,7 @@ namespace Vocaluxe.Menu.SongMenu public List Genre = new List(); public string Year = "0000"; public List Language = new List(); + public string DateAdded; // Notes public CNotes Notes = new CNotes(); @@ -277,6 +278,8 @@ namespace Vocaluxe.Menu.SongMenu } this.Notes = new CNotes(song.Notes); + + this.DateAdded = song.DateAdded; } public string GetMP3() From 127f9edfdc8d2d21cc2956becb56ac550246c6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 5 Aug 2013 13:16:44 +0200 Subject: [PATCH 03/10] Some checks for _CurrentStream (Darkice) --- Vocaluxe/Screens/CScreenSing.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 9e9d4ebd..57a4825b 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -546,12 +546,14 @@ namespace Vocaluxe.Screens public override void ApplyVolume() { - CSound.SetStreamVolumeMax(_CurrentStream, CConfig.GameMusicVolume); + if(_CurrentStream > -1) + CSound.SetStreamVolumeMax(_CurrentStream, CConfig.GameMusicVolume); } private void _CloseSong() { - CSound.FadeAndStop(_CurrentStream, 0f, 0.5f); + if(_CurrentStream > -1) + CSound.FadeAndStop(_CurrentStream, 0f, 0.5f); CSound.RecordStop(); if (_CurrentVideo != -1) { From 27e880f9e9318aacd5c14ecd84566a6bc8c4eae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Thu, 8 Aug 2013 12:58:10 +0200 Subject: [PATCH 04/10] Fix crash when starting vocaluxe without avatars. --- Vocaluxe/Screens/CScreenProfiles.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Vocaluxe/Screens/CScreenProfiles.cs b/Vocaluxe/Screens/CScreenProfiles.cs index 08e37d59..a5991bd3 100644 --- a/Vocaluxe/Screens/CScreenProfiles.cs +++ b/Vocaluxe/Screens/CScreenProfiles.cs @@ -446,13 +446,16 @@ namespace Vocaluxe.Screens int selectedAvatarID = _SelectSlides[_SelectSlideAvatars].ValueIndex; _SelectSlides[_SelectSlideAvatars].Clear(); IEnumerable avatars = CProfiles.GetAvatars(); - foreach (CAvatar avatar in avatars) + if (avatars != null) { - _SelectSlides[_SelectSlideAvatars].AddValue( - Path.GetFileName(avatar.FileName), - null, - avatar.ID, - -1); + foreach (CAvatar avatar in avatars) + { + _SelectSlides[_SelectSlideAvatars].AddValue( + Path.GetFileName(avatar.FileName), + null, + avatar.ID, + -1); + } } if (keep) From 4a91f39743566d2b593b471bee04422eb8ed4e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 12 Aug 2013 10:56:32 +0200 Subject: [PATCH 05/10] Read #DUETSINGERP1 and #DUETSINGERP2 from texts for better compatibility (performous uses this tags). --- VocaluxeLib/Songs/CSong.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index adf7f34d..d78614d6 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -353,10 +353,12 @@ namespace VocaluxeLib.Songs if (value != "") ArtistSorting = value; break; + case "DUETSINGERP1": case "P1": if (value != "") DuetPart1 = value; break; + case "DUETSINGERP2": case "P2": if (value != "") DuetPart2 = value; From de1b7161dacc92d4089e254aa245ecc35923e27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Tue, 20 Aug 2013 23:22:06 +0200 Subject: [PATCH 06/10] Added saving number of played times of a song. ATTENTION: This is not very fast. Maybe someone has a better solution. --- Vocaluxe/Base/CDataBase.cs | 51 ++++++++++++++++++++++++++++++++ Vocaluxe/Screens/CScreenScore.cs | 19 ++++++++++++ 2 files changed, 70 insertions(+) diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 2e9c4b65..89b32fb4 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -71,6 +71,50 @@ namespace Vocaluxe.Base } #region Highscores + + public static void IncreaseSongCounter(SPlayer player) + { + using (SQLiteConnection connection = new SQLiteConnection()) + { + connection.ConnectionString = "Data Source=" + _HighscoreFilePath; + + try + { + connection.Open(); + } + catch (Exception) + { + } + + using (SQLiteCommand command = new SQLiteCommand(connection)) + { + int dataBaseSongID = _GetDataBaseSongID(player, command); + _IncreaseSongCounter(dataBaseSongID, command); + } + } + } + + public static void IncreaseSongCounter(int dataBaseSongID) + { + using (SQLiteConnection connection = new SQLiteConnection()) + { + connection.ConnectionString = "Data Source=" + _HighscoreFilePath; + + try + { + connection.Open(); + } + catch (Exception) + { + } + + using (SQLiteCommand command = new SQLiteCommand(connection)) + { + _IncreaseSongCounter(dataBaseSongID, command); + } + } + } + public static int AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int difficulty, string artist, string title, int numPlayed, string filePath) { @@ -250,6 +294,13 @@ namespace Vocaluxe.Base } } + private static void _IncreaseSongCounter(int dataBaseSongID, SQLiteCommand command) + { + command.CommandText = "UPDATE Songs SET NumPlayed = NumPlayed + 1 WHERE [id] = @id"; + command.Parameters.Add("@id", DbType.Int32, 0).Value = dataBaseSongID; + command.ExecuteNonQuery(); + } + private static int _GetDataBaseSongID(SPlayer player, SQLiteCommand command) { CSong song = CSongs.GetSong(player.SongID); diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index 94838312..d35396ee 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -123,6 +123,8 @@ namespace Vocaluxe.Screens _Round = CGame.NumRounds > 1 ? 0 : 1; _Points = CGame.GetPoints(); + _SavePlayedSongs(); + _SetVisibility(); _UpdateRatings(); } @@ -389,6 +391,23 @@ namespace Vocaluxe.Screens } } + private void _SavePlayedSongs() + { + for (int round = 0; round < _Points.NumRounds; round++) + { + SPlayer[] players = _Points.GetPlayer(round, CGame.NumPlayer); + + for (int p = 0; p < players.Length; p++) + { + //if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished) + //{ + CDataBase.IncreaseSongCounter(players[p]); + break; + //} + } + } + } + private void _LeaveScreen() { CParty.LeavingScore(); From 07dbff85be40bfbbbb0f5ad8796bbd1e6f525dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Wed, 21 Aug 2013 19:26:04 +0200 Subject: [PATCH 07/10] Forget to remove test-stuff. --- Vocaluxe/Screens/CScreenScore.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index d35396ee..1d457e62 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -399,11 +399,11 @@ namespace Vocaluxe.Screens for (int p = 0; p < players.Length; p++) { - //if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished) - //{ + if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished) + { CDataBase.IncreaseSongCounter(players[p]); break; - //} + } } } } From f0ab780a877db51695d466ceea8f34fde17351ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Wed, 21 Aug 2013 20:18:52 +0200 Subject: [PATCH 08/10] Add songs to highscore.db at start, save date to db, read date and numplayed to song-infos. --- Vocaluxe/Base/CDataBase.cs | 27 ++++++++++++++++++++++++++- Vocaluxe/Base/CMain.cs | 5 +++++ VocaluxeLib/IBasic.cs | 1 + VocaluxeLib/Songs/CSong.cs | 3 +++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 3c2867a2..77d1fc32 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -72,6 +72,31 @@ namespace Vocaluxe.Base #region Highscores + public static bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded) + { + string sArtist = string.Empty; + string sTitle = string.Empty; + int songID = -1; + using (SQLiteConnection connection = new SQLiteConnection()) + { + connection.ConnectionString = "Data Source=" + _HighscoreFilePath; + + try + { + connection.Open(); + } + catch (Exception) + { + } + + using (SQLiteCommand command = new SQLiteCommand(connection)) + { + songID = _GetDataBaseSongID(artist, title, 0, command); + } + } + return _GetDataBaseSongInfos(songID, out sArtist, out sTitle, out numPlayed, out dateAdded, _HighscoreFilePath); + } + public static void IncreaseSongCounter(SPlayer player) { using (SQLiteConnection connection = new SQLiteConnection()) @@ -330,7 +355,7 @@ namespace Vocaluxe.Base if (reader != null) reader.Close(); - command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayedm DateAdded) " + + command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed, DateAdded) " + "VALUES (@title, @artist, @numplayed, @dateadded)"; command.Parameters.Add("@title", DbType.String, 0).Value = title; command.Parameters.Add("@artist", DbType.String, 0).Value = artist; diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 61a997ea..cd9fb657 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -782,6 +782,11 @@ namespace Vocaluxe.Base { return CDataBase.GetCover(fileName, ref texture, coverSize); } + + public bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded) + { + return CDataBase.GetDataBaseSongInfos(artist, title, out numPlayed, out dateAdded); + } } class CBcontrollers : IControllers diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index 2c85ba9d..703dc18d 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -262,6 +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); } public interface IControllers diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index 9af33523..9b13585b 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -148,6 +148,7 @@ namespace VocaluxeLib.Songs public readonly List Language = new List(); public string DateAdded = ""; + public int NumPlayed = 0; // Notes public readonly CNotes Notes = new CNotes(); @@ -534,6 +535,8 @@ namespace VocaluxeLib.Songs sr.Dispose(); _CheckFiles(); + CBase.DataBase.GetDataBaseSongInfos(Artist, Title, out NumPlayed, out DateAdded); + //Before saving this tags to .txt: Check, if ArtistSorting and Artist are equal, then don't save this tag. if (ArtistSorting == "") ArtistSorting = Artist; From bb8166351f3b404c6904d68155e72a49a2bd46dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Wed, 21 Aug 2013 20:20:20 +0200 Subject: [PATCH 09/10] Increase NumPlayer-attribute at saving to db. --- Vocaluxe/Screens/CScreenScore.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index 1d457e62..076f16db 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -402,6 +402,7 @@ namespace Vocaluxe.Screens if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished) { CDataBase.IncreaseSongCounter(players[p]); + CSongs.GetSong(players[p].SongID).NumPlayed++; break; } } 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 10/10] 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 == "")