diff --git a/Output/CreditsRessourcesDB.sqlite b/Output/CreditsRessourcesDB.sqlite
index 72b14a9b..93088563 100644
Binary files a/Output/CreditsRessourcesDB.sqlite and b/Output/CreditsRessourcesDB.sqlite differ
diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs
index cb687cad..31de25ef 100644
--- a/Vocaluxe/Base/CDataBase.cs
+++ b/Vocaluxe/Base/CDataBase.cs
@@ -37,50 +37,23 @@ namespace Vocaluxe.Base
InitHighscoreDB();
InitCoverDB();
- InitCreditsRessourcesDB();
+ InitCreditsRessourcesDB();
+/**
+ AddImageToCreditsDB("C:\\Users\\Florian\\Desktop\\Credit-Ressources\\brunzel.png");
+ AddImageToCreditsDB("C:\\Users\\Florian\\Desktop\\Credit-Ressources\\bohning.png");
+ AddImageToCreditsDB("C:\\Users\\Florian\\Desktop\\Credit-Ressources\\babene03.png");
+ AddImageToCreditsDB("C:\\Users\\Florian\\Desktop\\Credit-Ressources\\Darkice.png");
+ AddImageToCreditsDB("C:\\Users\\Florian\\Desktop\\Credit-Ressources\\flokuep.png");
+ AddImageToCreditsDB("C:\\Users\\Florian\\Desktop\\Credit-Ressources\\mesand.png");
+ */
}
#region Highscores
- public static int AddScore(string PlayerName, int Score, int LineNr, long Date, int Medley, int Duet, int Diff,
- string Artist, string Title, int NumPlayed, string FilePath)
- {
- SPlayer player = new SPlayer();
- player.Name = PlayerName;
- player.Points = Score;
- player.LineNr = LineNr;
- player.DateTicks = Date;
- player.Medley = (Medley == 1);
- player.Duet = (Duet == 1);
- player.Difficulty = (EGameDifficulty)Diff;
-
- SQLiteConnection connection = new SQLiteConnection();
- connection.ConnectionString = "Data Source=" + FilePath;
- SQLiteCommand command;
-
- try
- {
- connection.Open();
- }
- catch (Exception)
- {
- return -1;
- }
-
- command = new SQLiteCommand(connection);
-
- int DataBaseSongID = GetDataBaseSongID(Artist, Title, NumPlayed, command);
- int result = AddScore(player, command, DataBaseSongID);
-
- command.Dispose();
- connection.Close();
- connection.Dispose();
-
- return result;
- }
-
public static int AddScore(SPlayer player)
{
+ int lastInsertID = -1;
+
SQLiteConnection connection = new SQLiteConnection();
connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
SQLiteCommand command;
@@ -97,18 +70,6 @@ namespace Vocaluxe.Base
command = new SQLiteCommand(connection);
int DataBaseSongID = GetDataBaseSongID(player, command);
- int result = AddScore(player, command, DataBaseSongID);
-
- connection.Close();
- connection.Dispose();
-
- return result;
- }
-
- private static int AddScore(SPlayer player, SQLiteCommand command, int DataBaseSongID)
- {
- int lastInsertID = -1;
-
if (DataBaseSongID >= 0)
{
@@ -119,38 +80,7 @@ namespace Vocaluxe.Base
int Duet = 0;
if (player.Duet)
Duet = 1;
-
- command.CommandText = "SELECT id FROM Scores WHERE SongID = @SongID AND PlayerName = @PlayerName AND Score = @Score AND " +
- "LineNr = @LineNr AND Date = @Date AND Medley = @Medley AND Duet = @Duet AND Difficulty = @Difficulty";
- command.Parameters.Add("@SongID", System.Data.DbType.Int32, 0).Value = DataBaseSongID;
- command.Parameters.Add("@PlayerName", System.Data.DbType.String, 0).Value = player.Name;
- command.Parameters.Add("@Score", System.Data.DbType.Int32, 0).Value = (int)Math.Round(player.Points);
- command.Parameters.Add("@LineNr", System.Data.DbType.Int32, 0).Value = (int)player.LineNr;
- command.Parameters.Add("@Date", System.Data.DbType.Int64, 0).Value = player.DateTicks;
- command.Parameters.Add("@Medley", System.Data.DbType.Int32, 0).Value = Medley;
- command.Parameters.Add("@Duet", System.Data.DbType.Int32, 0).Value = Duet;
- command.Parameters.Add("@Difficulty", System.Data.DbType.Int32, 0).Value = (int)player.Difficulty;
- SQLiteDataReader reader = null;
- try
- {
- reader = command.ExecuteReader();
- }
- catch (Exception)
- {
- ;
- }
-
- if (reader != null && reader.HasRows)
- {
- if (reader.Read())
- return reader.GetInt32(0);
- }
-
- if (reader != null)
- reader.Close();
-
-
command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) " +
"VALUES (@SongID, @PlayerName, @Score, @LineNr, @Date, @Medley, @Duet, @Difficulty)";
command.Parameters.Add("@SongID", System.Data.DbType.Int32, 0).Value = DataBaseSongID;
@@ -166,7 +96,7 @@ namespace Vocaluxe.Base
//Read last insert line
command.CommandText = "SELECT id FROM Scores ORDER BY Date DESC LIMIT 0, 1";
- reader = null;
+ SQLiteDataReader reader = null;
try
{
reader = command.ExecuteReader();
@@ -188,6 +118,10 @@ namespace Vocaluxe.Base
}
}
+ command.Dispose();
+ connection.Close();
+ connection.Dispose();
+
return lastInsertID;
}
@@ -272,38 +206,9 @@ namespace Vocaluxe.Base
if (song == null)
return -1;
- return GetDataBaseSongID(song.Artist, song.Title, 0, command);
- }
-
- private static int GetDataBaseSongID(string Artist, string Title, string FilePath, int DefNumPlayed)
- {
- SQLiteConnection connection = new SQLiteConnection();
- connection.ConnectionString = "Data Source=" + FilePath;
- SQLiteCommand command;
-
- try
- {
- connection.Open();
- }
- catch (Exception)
- {
- return -1;
- }
-
- command = new SQLiteCommand(connection);
- int id = GetDataBaseSongID(Artist, Title, DefNumPlayed, command);
- command.Dispose();
- connection.Close();
- connection.Dispose();
-
- return id;
- }
-
- private static int GetDataBaseSongID(string Artist, string Title, int DefNumPlayed, SQLiteCommand command)
- {
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
- 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("@title", System.Data.DbType.String, 0).Value = song.Title;
+ command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = song.Artist;
SQLiteDataReader reader = null;
try
@@ -329,15 +234,14 @@ namespace Vocaluxe.Base
reader.Close();
command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " +
- "VALUES (@title, @artist, @numplayed)";
- 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;
+ "VALUES (@title, @artist, 0)";
+ command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = song.Title;
+ command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = song.Artist;
command.ExecuteNonQuery();
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
- 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("@title", System.Data.DbType.String, 0).Value = song.Title;
+ command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = song.Artist;
reader = null;
try
@@ -368,136 +272,24 @@ namespace Vocaluxe.Base
return -1;
}
- private static bool GetDataBaseSongInfos(int SongID, out string Artist, out string Title, out int NumPlayed, string FilePath)
- {
- Artist = String.Empty;
- Title = String.Empty;
- NumPlayed = 0;
-
- SQLiteConnection connection = new SQLiteConnection();
- connection.ConnectionString = "Data Source=" + FilePath;
- SQLiteCommand command;
-
- try
- {
- connection.Open();
- }
- catch (Exception)
- {
- return false;
- }
-
- command = new SQLiteCommand(connection);
- command.CommandText = "SELECT Artist, Title, NumPlayed FROM Songs WHERE [id] = @id";
- command.Parameters.Add("@id", System.Data.DbType.String, 0).Value = SongID;
-
- SQLiteDataReader reader = null;
- try
- {
- reader = command.ExecuteReader();
- }
- catch (Exception)
- {
- return false;
- }
-
- if (reader != null && reader.HasRows)
- {
- reader.Read();
- Artist = reader.GetString(0);
- Title = reader.GetString(1);
- NumPlayed = reader.GetInt32(2);
- reader.Close();
- reader.Dispose();
-
- command.Dispose();
- connection.Close();
- connection.Dispose();
- return true;
- }
- else
- {
- if (reader != null)
- reader.Close();
- }
-
- command.Dispose();
- connection.Close();
- connection.Dispose();
-
- return false;
- }
-
- private static void InitHighscoreDB()
+ private static bool InitHighscoreDB()
{
string OldDBFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.sFileOldHighscoreDB);
if (File.Exists(OldDBFilePath))
{
if (File.Exists(_HighscoreFilePath))
{
- CreateOrConvert(OldDBFilePath);
- CreateOrConvert(_HighscoreFilePath);
- ImportData(OldDBFilePath, _HighscoreFilePath);
-
- File.Delete(OldDBFilePath);
+ CLog.LogError("Found old Highscore DB (" + OldDBFilePath + "). If you want to import it just delete the new one (" + _HighscoreFilePath + ")");
}
else
{
File.Copy(OldDBFilePath, _HighscoreFilePath);
- CreateOrConvert(_HighscoreFilePath);
- File.Delete(OldDBFilePath);
+ File.Move(OldDBFilePath, OldDBFilePath + ".old");
}
}
- else
- CreateOrConvert(_HighscoreFilePath);
- }
- private static void CreateHighscoreDB(string FilePath)
- {
SQLiteConnection connection = new SQLiteConnection();
- connection.ConnectionString = "Data Source=" + FilePath;
- SQLiteCommand command;
-
- try
- {
- connection.Open();
- }
- catch (Exception)
- {
- return;
- }
-
- command = new SQLiteCommand(connection);
-
- command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);";
- command.ExecuteNonQuery();
-
- command.CommandText = "INSERT INTO Version (id, Value) VALUES(NULL, " + CSettings.iDatabaseHighscoreVersion.ToString() + ")";
- command.ExecuteNonQuery();
-
- command.CommandText = "CREATE TABLE IF NOT EXISTS Songs ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
- "Artist TEXT NOT NULL, Title TEXT NOT NULL, NumPlayed INTEGER);";
- command.ExecuteNonQuery();
-
- command.CommandText = "CREATE TABLE IF NOT EXISTS Scores ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
- "SongID INTEGER NOT NULL, PlayerName TEXT NOT NULL, Score INTEGER NOT NULL, LineNr INTEGER NOT NULL, Date BIGINT NOT NULL, " +
- "Medley INTEGER NOT NULL, Duet INTEGER NOT NULL, Difficulty INTEGER NOT NULL);";
- command.ExecuteNonQuery();
-
- command.Dispose();
- connection.Close();
- connection.Dispose();
- }
-
- ///
- /// Creates a new Vocaluxe Database if no file exists. Converts an existing old Ultrastar Deluxe highscore database into vocaluxe format.
- ///
- /// Database file path
- ///
- private static bool CreateOrConvert(string FilePath)
- {
- SQLiteConnection connection = new SQLiteConnection();
- connection.ConnectionString = "Data Source=" + FilePath;
+ connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
SQLiteCommand command;
try
@@ -526,12 +318,12 @@ namespace Vocaluxe.Base
if (reader == null)
{
// create new database/tables
- CreateHighscoreDB(FilePath);
+ CreateHighscoreDB();
}
else if (reader.FieldCount == 0)
{
// create new database/tables
- CreateHighscoreDB(FilePath);
+ CreateHighscoreDB();
}
else
{
@@ -569,10 +361,10 @@ namespace Vocaluxe.Base
//Check for USDX 1.1 DB
if (version == 1)
- ConvertFrom110(FilePath);
+ ConvertFrom110();
//Check for USDX 1.01 or CMD Mod DB
else if (version == 0 && scoresTableExists)
- ConvertFrom101(FilePath);
+ ConvertFrom101();
command.Dispose();
@@ -582,15 +374,61 @@ namespace Vocaluxe.Base
return true;
}
+ private static void CreateHighscoreDB()
+ {
+ SQLiteConnection connection = new SQLiteConnection();
+ connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
+ SQLiteCommand command;
+
+ try
+ {
+ connection.Open();
+ }
+ catch (Exception)
+ {
+ return;
+ }
+
+ command = new SQLiteCommand(connection);
+
+ command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);";
+ command.ExecuteNonQuery();
+
+ command.CommandText = "INSERT INTO Version (id, Value) VALUES(NULL, " + CSettings.iDatabaseHighscoreVersion.ToString() + ")";
+ command.ExecuteNonQuery();
+
+ command.CommandText = "CREATE TABLE IF NOT EXISTS Songs ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
+ "Artist TEXT NOT NULL, Title TEXT NOT NULL, NumPlayed INTEGER);";
+ command.ExecuteNonQuery();
+
+ command.CommandText = "CREATE TABLE IF NOT EXISTS Scores ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
+ "SongID INTEGER NOT NULL, PlayerName TEXT NOT NULL, Score INTEGER NOT NULL, LineNr INTEGER NOT NULL, Date BIGINT NOT NULL, " +
+ "Medley INTEGER NOT NULL, Duet INTEGER NOT NULL, Difficulty INTEGER NOT NULL);";
+ command.ExecuteNonQuery();
+
+ command.Dispose();
+ connection.Close();
+ connection.Dispose();
+
+ /*
+ // Auslesen des zuletzt eingefügten Datensatzes.
+ command.CommandText = "SELECT id, name FROM beispiel ORDER BY id DESC LIMIT 0, 1";
+
+ while (reader.Read())
+ {
+ Console.WriteLine("Dies ist der {0}. eingefügte Datensatz mit dem Wert: \"{1}\"", reader[0].ToString(), reader[1].ToString());
+ }
+ */
+ }
+
///
/// Converts a USDX 1.1 database into the Vocaluxe format
///
- /// Database file path
/// True if succeeded
- private static bool ConvertFrom110(string FilePath)
+ private static bool ConvertFrom110()
{
SQLiteConnection connection = new SQLiteConnection();
- connection.ConnectionString = "Data Source=" + FilePath;
+ connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
SQLiteCommand command;
try
@@ -708,12 +546,11 @@ namespace Vocaluxe.Base
///
/// Converts a USDX 1.01 or CMD 1.01 database to Vocaluxe format
///
- /// Database file path
/// True if succeeded
- private static bool ConvertFrom101(string FilePath)
+ private static bool ConvertFrom101()
{
SQLiteConnection connection = new SQLiteConnection();
- connection.ConnectionString = "Data Source=" + FilePath;
+ connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
SQLiteCommand command;
SQLiteDataReader reader = null;
@@ -766,11 +603,11 @@ namespace Vocaluxe.Base
List songs = new List();
Sqlite3.sqlite3 OldDB;
- int res = Sqlite3.sqlite3_open(FilePath, out OldDB);
+ int res = Sqlite3.sqlite3_open(_HighscoreFilePath, out OldDB);
if (res != Sqlite3.SQLITE_OK)
{
- CLog.LogError("Error opening Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
+ CLog.LogError("Error opening Database: " + _HighscoreFilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
}
else
{
@@ -779,11 +616,11 @@ namespace Vocaluxe.Base
if (res != Sqlite3.SQLITE_OK)
{
- CLog.LogError("Error query Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
+ CLog.LogError("Error query Database: " + _HighscoreFilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
}
else
{
- //Sqlite3.sqlite3_step(Stmt);
+ Sqlite3.sqlite3_step(Stmt);
Encoding UTF8 = Encoding.UTF8;
Encoding CP1252 = Encoding.GetEncoding(1252);
@@ -814,11 +651,11 @@ namespace Vocaluxe.Base
if (res != Sqlite3.SQLITE_OK)
{
- CLog.LogError("Error query Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
+ CLog.LogError("Error query Database: " + _HighscoreFilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
}
else
{
- //Sqlite3.sqlite3_step(Stmt);
+ Sqlite3.sqlite3_step(Stmt);
Encoding UTF8 = Encoding.UTF8;
Encoding CP1252 = Encoding.GetEncoding(1252);
@@ -882,71 +719,6 @@ namespace Vocaluxe.Base
return true;
}
-
- private static bool ImportData(string SourceDBPath, string DestinationDBPath)
- {
- #region open db
- SQLiteConnection connSource = new SQLiteConnection();
- connSource.ConnectionString = "Data Source=" + SourceDBPath;
-
- try
- {
- connSource.Open();
- }
- catch (Exception e)
- {
- CLog.LogError("Error on import high score data. Can't open source database \"" + SourceDBPath + "\" (" + e.Message + ")");
- return false;
- }
- #endregion open db
-
- SQLiteCommand cmdSource = new SQLiteCommand(connSource);
- SQLiteDataReader rSource;
-
- #region import table scores
- cmdSource.CommandText = "SELECT SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty FROM Scores";
- rSource = cmdSource.ExecuteReader();
- if (rSource == null)
- {
- cmdSource.Dispose();
- connSource.Close();
- return false;
- }
-
- if (rSource.FieldCount == 0)
- {
- rSource.Close();
- cmdSource.Dispose();
- connSource.Close();
- return true;
- }
-
- while (rSource.Read())
- {
- int songid = rSource.GetInt32(0);
- string player = rSource.GetString(1);
- int score = rSource.GetInt32(2);
- int linenr = rSource.GetInt32(3);
- long date = rSource.GetInt64(4);
- int medley = rSource.GetInt32(5);
- int duet = rSource.GetInt32(6);
- int diff = rSource.GetInt32(7);
-
- string artist, title;
- int numplayed;
- if (GetDataBaseSongInfos(songid, out artist, out title, out numplayed, SourceDBPath))
- {
- AddScore(player, score, linenr, date, medley, duet, diff, artist, title, numplayed, _HighscoreFilePath);
- }
- }
- #endregion import table scores
-
- rSource.Close();
- cmdSource.Dispose();
- connSource.Close();
-
- return true;
- }
#endregion Highscores
#region Cover
diff --git a/Vocaluxe/Screens/CScreenCredits.cs b/Vocaluxe/Screens/CScreenCredits.cs
index ed3b8dd7..beb14379 100644
--- a/Vocaluxe/Screens/CScreenCredits.cs
+++ b/Vocaluxe/Screens/CScreenCredits.cs
@@ -187,6 +187,26 @@ namespace Vocaluxe.Screens
CreditEntryBabene03.direction = EDirection.Right;
_CreditNames.Add(CreditEntryBabene03);
+ //pantero
+ CDataBase.GetCreditsRessource("pantero.png", ref tex);
+ CCreditName CreditEntrypantero = new CCreditName();
+ CreditEntrypantero.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4));
+ CreditEntrypantero.particleRect = new SRectF(CreditEntrypantero.image.Rect.X + 140, CreditEntrypantero.image.Rect.Y + 15, 10, 10, -5);
+ CreditEntrypantero.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntrypantero.particleRect, particleTex, 25, EParticeType.Star);
+ CreditEntrypantero.active = true;
+ CreditEntrypantero.direction = EDirection.Left;
+ _CreditNames.Add(CreditEntrypantero);
+
+ //Pinky007
+ CDataBase.GetCreditsRessource("Pinky007.png", ref tex);
+ CCreditName CreditEntryPinky007 = new CCreditName();
+ CreditEntryPinky007.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
+ CreditEntryPinky007.particleRect = new SRectF(CreditEntryPinky007.image.Rect.X + 42, CreditEntryPinky007.image.Rect.Y + 15, 10, 10, -5);
+ CreditEntryPinky007.particle = new CParticleEffect(4, new SColorF(0, 0, 1, 1), CreditEntryPinky007.particleRect, particleTex, 25, EParticeType.Star);
+ CreditEntryPinky007.active = true;
+ CreditEntryPinky007.direction = EDirection.Right;
+ _CreditNames.Add(CreditEntryPinky007);
+
//CreditEntry.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(0, 0, 350, 110, -4));