Merge pull request #17 from Vocaluxe/release-0.1

merge Release 0.1 branch changes into develop branch
This commit is contained in:
Alexander Eckart committed 2012-03-04 09:02:18 -08:00
commit 339dd6bdaa
10 files changed
+583 -101

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 65 KiB

+126
View File
@@ -0,0 +1,126 @@
Vocaluxe 0.1 README
----------------------------
=================================
= 1. About =
= 2. Release Notes =
= 3. Command-Line Parameters =
= 4. Controls =
= 5. Help & Support =
= 6. Source Code =
=================================
=================================
= 1. About =
=================================
Vocaluxe is a free and open source singing game. It allows up to three players (currently) to sing
along with music using microphones in order to score points, depending on the pitch of the voice
and the rhythm of singing.
Vocaluxe is an entirely new development in C#, inspired by the original UltraStar (developed by corvus5)
and the great Ultrastar Deluxe project.
Supported Operating Systems / Requirements:
- WinXP, Vista, Windows 7 with .NET 2.0
- 1 GHz CPU, 512 MB RAM, Graphics card with OpenGL 2.1 or DirectX 9.0 support
=================================
= 2. Release Notes =
=================================
- The program supports 32bit and 64bit (Vocaluxe_x64.exe) operating systems.
- The program uses OpenGL as the default renderer. If your graphics card driver does not or not
properly support OpenGL, you can try the Direct3D renderer by editing your Config.xml in the
application's main directory:
<Graphics>
<!--Renderer: TR_CONFIG_SOFTWARE, TR_CONFIG_OPENGL, TR_CONFIG_DIRECT3D-->
<Renderer>TR_CONFIG_DIRECT3D</Renderer>
- To add your existing song collection to Vocaluxe, put your songs into the 'Songs' subfolder.
Alternatively, you can add multiple song paths to Vocaluxe by editing your Config.xml:
<Game>
<!--SongFolder: SongFolder1, SongFolder2, SongFolder3, ...-->
<SongFolder1>C:\Vocaluxe\Songs</SongFolder1>
<SongFolder2>D:\EvenMore\Songs</SongFolder2>
- To use your highscore database from UltraStar deluxe 1.0.1, UltraStar deluxe CMD Mod or
UltraStar deluxe 1.1, simply copy your Ultrastar.db (rename if necessary) into the main
directory. Your highscore database will be imported into the HighscoreDB.sqlite file when
Vocaluxe is started. Upon successful import, the old database is deleted.
- To add your own player avatars, simply add some picture files to the 'Profiles' subfolder.
Supported file types: png, jpg (jpeg), bmp.
Images should have square proportions, e.g. 400x400 px.
=================================
= 3. Command-Line Parameters =
=================================
The following command-line parameters may be passed to the game when starting it through a shortcut
or from the console:
-ConfigFile [Path\File]: Use [Path\File] as configuration file instead of Config.xml in the main folder.
The path to the file has to exist and needs to be an absolute path.
If only a filename is specified, the file is assumed to be in the current directory.
Examples: Vocaluxe.exe -ConfigFile MyConfig.xml
Vocaluxe.exe -ConfigFile C:\Vocaluxe\Configs\MyConfig.xml
-ScoreFile [Path\File] : Use [File] as score database instead of HighscoreDB.sqlite in the application's
main folder. The path to the file has to exist and needs to be an absolute path.
If only a filename is specified, the file is assumed to be in the current directory.
Examples: Vocaluxe.exe -ScoreFile MyHighscoreDB.sqlite
Vocaluxe.exe -Scorefile C:\Vocaluxe\Highscores\MyHighscoreDB.sqlite
-SongFolder [Path] : Use [Path] as song folder. The path has to exist and needs to be an absolute path.
Note that any song folders set in the config file will be ignored.
This parameter may be used multiple times to use different song folders.
Examples: Vocaluxe.exe -SongFolder D:\MySongCollection
Vocaluxe.exe -SongFolder D:\MySongCollection -SongFolder E:\MoreSongs
-SongPath [Path] : Deprecated, see SongFolder [Path]. This alias is provided for convenience.
Complete example:
Vocaluxe.exe -ConfigFile MyConfig.xml -ScoreFile C:\Vocaluxe\Highscores\MyHighscoreDB.sqlite -SongFolder D:\MySongCollection
=================================
= 4. Controls =
=================================
[Mouse] to navigate through the screens: Left button: select/manipulate elements,
Right button: go to previous screen.
[Cursor] to navigate through the screens.
[Enter] to confirm
[Escape] or [Back] to go to the previous screen.
[ALT] + [P] to take a ScreenShot. Screenshots are saved in the directory "Screenshots".
[ALT] + [ENTER] to toggle full screen mode.
[SHIFT] + [F1] to toggle theme edit mode. The theme edit mode is experimental. It allows you
to change the size and position of the element on the screens. You can save
your changes with [S] before leaving the theme edit mode.
[TAB] to open the background music controls (not on all screens).
Songscreen
[R] to select a random song
[F3] or [CTRL]+[F] to open/close the song search menu
[A] to sing all songs from a category
=================================
= 5. Help & Suppport =
=================================
Support Forum (German): http://www.ultra-star.de
Song-DataBase (USDB): http://usdb.animux.de/
=================================
= 6. Source Code =
=================================
Source Code (GitHub): https://github.com/Vocaluxe/Vocaluxe
SF.Net Page: http://sourceforge.net/projects/vocaluxe/
+327 -77
View File
@@ -38,10 +38,45 @@ namespace Vocaluxe.Base
} }
#region Highscores #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) public static int AddScore(SPlayer player)
{ {
int lastInsertID = -1;
SQLiteConnection connection = new SQLiteConnection(); SQLiteConnection connection = new SQLiteConnection();
connection.ConnectionString = "Data Source=" + _HighscoreFilePath; connection.ConnectionString = "Data Source=" + _HighscoreFilePath;
SQLiteCommand command; SQLiteCommand command;
@@ -58,6 +93,18 @@ namespace Vocaluxe.Base
command = new SQLiteCommand(connection); command = new SQLiteCommand(connection);
int DataBaseSongID = GetDataBaseSongID(player, command); 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) if (DataBaseSongID >= 0)
{ {
@@ -69,6 +116,37 @@ namespace Vocaluxe.Base
if (player.Duet) if (player.Duet)
Duet = 1; 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) " + command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) " +
"VALUES (@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; command.Parameters.Add("@SongID", System.Data.DbType.Int32, 0).Value = DataBaseSongID;
@@ -84,7 +162,7 @@ namespace Vocaluxe.Base
//Read last insert line //Read last insert line
command.CommandText = "SELECT id FROM Scores ORDER BY Date DESC LIMIT 0, 1"; command.CommandText = "SELECT id FROM Scores ORDER BY Date DESC LIMIT 0, 1";
SQLiteDataReader reader = null; reader = null;
try try
{ {
reader = command.ExecuteReader(); reader = command.ExecuteReader();
@@ -106,10 +184,6 @@ namespace Vocaluxe.Base
} }
} }
command.Dispose();
connection.Close();
connection.Dispose();
return lastInsertID; return lastInsertID;
} }
@@ -194,9 +268,38 @@ namespace Vocaluxe.Base
if (song == null) if (song == null)
return -1; 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.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = song.Title; command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = Title;
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = song.Artist; command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = Artist;
SQLiteDataReader reader = null; SQLiteDataReader reader = null;
try try
@@ -222,14 +325,15 @@ namespace Vocaluxe.Base
reader.Close(); reader.Close();
command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " + command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " +
"VALUES (@title, @artist, 0)"; "VALUES (@title, @artist, @numplayed)";
command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = song.Title; command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = Title;
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = song.Artist; command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = Artist;
command.Parameters.Add("@numplayed", System.Data.DbType.Int32, 0).Value = DefNumPlayed;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist"; command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = song.Title; command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = Title;
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = song.Artist; command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = Artist;
reader = null; reader = null;
try try
@@ -260,10 +364,136 @@ namespace Vocaluxe.Base
return -1; return -1;
} }
private static bool InitHighscoreDB() 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()
{
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);
}
else
{
File.Copy(OldDBFilePath, _HighscoreFilePath);
CreateOrConvert(_HighscoreFilePath);
File.Delete(OldDBFilePath);
}
}
else
CreateOrConvert(_HighscoreFilePath);
}
private static void CreateHighscoreDB(string FilePath)
{ {
SQLiteConnection connection = new SQLiteConnection(); SQLiteConnection connection = new SQLiteConnection();
connection.ConnectionString = "Data Source=" + _HighscoreFilePath; 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();
}
/// <summary>
/// Creates a new Vocaluxe Database if no file exists. Converts an existing old Ultrastar Deluxe highscore database into vocaluxe format.
/// </summary>
/// <param name="FilePath">Database file path</param>
/// <returns></returns>
private static bool CreateOrConvert(string FilePath)
{
SQLiteConnection connection = new SQLiteConnection();
connection.ConnectionString = "Data Source=" + FilePath;
SQLiteCommand command; SQLiteCommand command;
try try
@@ -292,12 +522,12 @@ namespace Vocaluxe.Base
if (reader == null) if (reader == null)
{ {
// create new database/tables // create new database/tables
CreateHighscoreDB(); CreateHighscoreDB(FilePath);
} }
else if (reader.FieldCount == 0) else if (reader.FieldCount == 0)
{ {
// create new database/tables // create new database/tables
CreateHighscoreDB(); CreateHighscoreDB(FilePath);
} }
else else
{ {
@@ -335,10 +565,10 @@ namespace Vocaluxe.Base
//Check for USDX 1.1 DB //Check for USDX 1.1 DB
if (version == 1) if (version == 1)
ConvertFrom110(); ConvertFrom110(FilePath);
//Check for USDX 1.01 or CMD Mod DB //Check for USDX 1.01 or CMD Mod DB
else if (version == 0 && scoresTableExists) else if (version == 0 && scoresTableExists)
ConvertFrom101(); ConvertFrom101(FilePath);
command.Dispose(); command.Dispose();
@@ -348,61 +578,15 @@ namespace Vocaluxe.Base
return true; 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());
}
*/
}
/// <summary> /// <summary>
/// Converts a USDX 1.1 database into the Vocaluxe format /// Converts a USDX 1.1 database into the Vocaluxe format
/// </summary> /// </summary>
/// <param name="FilePath">Database file path</param>
/// <returns>True if succeeded</returns> /// <returns>True if succeeded</returns>
private static bool ConvertFrom110() private static bool ConvertFrom110(string FilePath)
{ {
SQLiteConnection connection = new SQLiteConnection(); SQLiteConnection connection = new SQLiteConnection();
connection.ConnectionString = "Data Source=" + _HighscoreFilePath; connection.ConnectionString = "Data Source=" + FilePath;
SQLiteCommand command; SQLiteCommand command;
try try
@@ -520,11 +704,12 @@ namespace Vocaluxe.Base
/// <summary> /// <summary>
/// Converts a USDX 1.01 or CMD 1.01 database to Vocaluxe format /// Converts a USDX 1.01 or CMD 1.01 database to Vocaluxe format
/// </summary> /// </summary>
/// <param name="FilePath">Database file path</param>
/// <returns>True if succeeded</returns> /// <returns>True if succeeded</returns>
private static bool ConvertFrom101() private static bool ConvertFrom101(string FilePath)
{ {
SQLiteConnection connection = new SQLiteConnection(); SQLiteConnection connection = new SQLiteConnection();
connection.ConnectionString = "Data Source=" + _HighscoreFilePath; connection.ConnectionString = "Data Source=" + FilePath;
SQLiteCommand command; SQLiteCommand command;
SQLiteDataReader reader = null; SQLiteDataReader reader = null;
@@ -577,11 +762,11 @@ namespace Vocaluxe.Base
List<SData> songs = new List<SData>(); List<SData> songs = new List<SData>();
Sqlite3.sqlite3 OldDB; Sqlite3.sqlite3 OldDB;
int res = Sqlite3.sqlite3_open(_HighscoreFilePath, out OldDB); int res = Sqlite3.sqlite3_open(FilePath, out OldDB);
if (res != Sqlite3.SQLITE_OK) if (res != Sqlite3.SQLITE_OK)
{ {
CLog.LogError("Error opening Database: " + _HighscoreFilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")"); CLog.LogError("Error opening Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
} }
else else
{ {
@@ -590,11 +775,11 @@ namespace Vocaluxe.Base
if (res != Sqlite3.SQLITE_OK) if (res != Sqlite3.SQLITE_OK)
{ {
CLog.LogError("Error query Database: " + _HighscoreFilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")"); CLog.LogError("Error query Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
} }
else else
{ {
Sqlite3.sqlite3_step(Stmt); //Sqlite3.sqlite3_step(Stmt);
Encoding UTF8 = Encoding.UTF8; Encoding UTF8 = Encoding.UTF8;
Encoding CP1252 = Encoding.GetEncoding(1252); Encoding CP1252 = Encoding.GetEncoding(1252);
@@ -625,11 +810,11 @@ namespace Vocaluxe.Base
if (res != Sqlite3.SQLITE_OK) if (res != Sqlite3.SQLITE_OK)
{ {
CLog.LogError("Error query Database: " + _HighscoreFilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")"); CLog.LogError("Error query Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
} }
else else
{ {
Sqlite3.sqlite3_step(Stmt); //Sqlite3.sqlite3_step(Stmt);
Encoding UTF8 = Encoding.UTF8; Encoding UTF8 = Encoding.UTF8;
Encoding CP1252 = Encoding.GetEncoding(1252); Encoding CP1252 = Encoding.GetEncoding(1252);
@@ -693,6 +878,71 @@ namespace Vocaluxe.Base
return true; 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 #endregion Highscores
#region Cover #region Cover
+62 -1
View File
@@ -319,6 +319,7 @@ namespace Vocaluxe.Base
{ {
#region private vars #region private vars
private string _TextureName; private string _TextureName;
private STexture _Texture;
private SRectF _Rect; private SRectF _Rect;
private float _Size; private float _Size;
private SColorF _Color; private SColorF _Color;
@@ -386,6 +387,7 @@ namespace Vocaluxe.Base
public CParticle(string textureName, SColorF color, float x, float y, float size, float maxage, float z, float vx, float vy, float vr, float vsize, EParticeType type) public CParticle(string textureName, SColorF color, float x, float y, float size, float maxage, float z, float vx, float vy, float vr, float vsize, EParticeType type)
{ {
_TextureName = textureName; _TextureName = textureName;
_Texture = new STexture(-1);
_Color = color; _Color = color;
_Rect = new SRectF(x, y, size, size, z); _Rect = new SRectF(x, y, size, size, z);
_Size = size; _Size = size;
@@ -403,6 +405,29 @@ namespace Vocaluxe.Base
_MaxAge = maxage; _MaxAge = maxage;
_Rotation = (float)(CGame.Rand.NextDouble() * 360.0); _Rotation = (float)(CGame.Rand.NextDouble() * 360.0);
} }
public CParticle(STexture texture, SColorF color, float x, float y, float size, float maxage, float z, float vx, float vy, float vr, float vsize, EParticeType type)
{
_TextureName = String.Empty;
_Texture = texture;
_Color = color;
_Rect = new SRectF(x, y, size, size, z);
_Size = size;
_Alpha = 1f;
_Angle = 0f;
_Vx = vx;
_Vy = vy;
_Vr = vr;
_Vsize = vsize;
_LastTime = 0f;
_Type = type;
_Timer = new Stopwatch();
_Age = 0f;
_MaxAge = maxage;
_Rotation = (float)(CGame.Rand.NextDouble() * 360.0);
}
#endregion Constructors #endregion Constructors
public void Update() public void Update()
@@ -553,7 +578,10 @@ namespace Vocaluxe.Base
public void Draw() public void Draw()
{ {
if (_TextureName != String.Empty)
CDraw.DrawTexture(CTheme.GetSkinTexture(_TextureName), _Rect, new SColorF(_Color.R, _Color.G, _Color.B, _Color.A * Alpha2 * _Alpha)); CDraw.DrawTexture(CTheme.GetSkinTexture(_TextureName), _Rect, new SColorF(_Color.R, _Color.G, _Color.B, _Color.A * Alpha2 * _Alpha));
else
CDraw.DrawTexture(_Texture, _Rect, new SColorF(_Color.R, _Color.G, _Color.B, _Color.A * Alpha2 * _Alpha));
} }
} }
@@ -561,6 +589,7 @@ namespace Vocaluxe.Base
{ {
private List<CParticle> _Stars; private List<CParticle> _Stars;
private string _TextureName; private string _TextureName;
private STexture _Texture;
private int _MaxNumber; private int _MaxNumber;
private SRectF _Area; private SRectF _Area;
private SColorF _Color; private SColorF _Color;
@@ -579,12 +608,33 @@ namespace Vocaluxe.Base
} }
} }
public SRectF Area
{
get { return _Area; }
set { _Area = value; }
}
public CParticleEffect(int MaxNumber, SColorF Color, SRectF Area, string TextureName, float Size, EParticeType Type) public CParticleEffect(int MaxNumber, SColorF Color, SRectF Area, string TextureName, float Size, EParticeType Type)
{ {
_Stars = new List<CParticle>(); _Stars = new List<CParticle>();
_Area = Area; _Area = Area;
_Color = Color; _Color = Color;
_TextureName = TextureName; _TextureName = TextureName;
_Texture = new STexture(-1);
_MaxNumber = MaxNumber;
_Size = Size;
_Type = Type;
_SpawnTimer = new Stopwatch();
_NextSpawnTime = 0f;
}
public CParticleEffect(int MaxNumber, SColorF Color, SRectF Area, STexture texture, float Size, EParticeType Type)
{
_Stars = new List<CParticle>();
_Area = Area;
_Color = Color;
_TextureName = String.Empty;
_Texture = texture;
_MaxNumber = MaxNumber; _MaxNumber = MaxNumber;
_Size = Size; _Size = Size;
_Type = Type; _Type = Type;
@@ -682,10 +732,21 @@ namespace Vocaluxe.Base
if (h < 0) if (h < 0)
h = 0; h = 0;
CParticle star = new CParticle(_TextureName, _Color, CParticle star;
if (_TextureName != String.Empty)
{
star = new CParticle(_TextureName, _Color,
CGame.Rand.Next(w) + _Area.X - size / 4f, CGame.Rand.Next(w) + _Area.X - size / 4f,
CGame.Rand.Next(h) + _Area.Y - size / 4f, CGame.Rand.Next(h) + _Area.Y - size / 4f,
size, lifetime, _Area.Z, vx, vy, vr, vsize, _Type); size, lifetime, _Area.Z, vx, vy, vr, vsize, _Type);
}
else
{
star = new CParticle(_Texture, _Color,
CGame.Rand.Next(w) + _Area.X - size / 4f,
CGame.Rand.Next(h) + _Area.Y - size / 4f,
size, lifetime, _Area.Z, vx, vy, vr, vsize, _Type);
}
_Stars.Add(star); _Stars.Add(star);
} }
+4 -16
View File
@@ -247,10 +247,7 @@ namespace Vocaluxe.Base
for (int p = 0; p < _NumPlayer; p++) for (int p = 0; p < _NumPlayer; p++)
{ {
CSound.AnalyzeBuffer(p);
if (CSound.RecordToneValid(p) || DEBUG_HIT)
{
for (int beat = _OldBeatD + 1; beat <= _CurrentBeatD; beat++) for (int beat = _OldBeatD + 1; beat <= _CurrentBeatD; beat++)
{ {
CLine[] lines = song.Notes.GetLines(_Player[p].LineNr).Line; CLine[] lines = song.Notes.GetLines(_Player[p].LineNr).Line;
@@ -283,24 +280,12 @@ namespace Vocaluxe.Base
{ {
if (beat >= notes[j].StartBeat && beat <= notes[j].EndBeat) if (beat >= notes[j].StartBeat && beat <= notes[j].EndBeat)
{ {
if (notes[j].PointsForBeat > 0)
Note = j; Note = j;
break; break;
} }
} }
if (Note >= 0) if (Note >= 0)
{
if (Line == lines.Length - 1)
{
if (Note == lines[Line].NoteCount - 1)
{
_Player[p].SongFinished = true;
}
}
}
if (Note >= 0 && notes[Note].PointsForBeat > 0)
{ {
_Player[p].CurrentNote = Note; _Player[p].CurrentNote = Note;
@@ -313,6 +298,9 @@ namespace Vocaluxe.Base
} }
} }
CSound.AnalyzeBuffer(p);
if (notes[Note].PointsForBeat > 0 && (CSound.RecordToneValid(p) || DEBUG_HIT))
{
int Tone = notes[Note].Tone; int Tone = notes[Note].Tone;
int TonePlayer = CSound.RecordGetTone(p); int TonePlayer = CSound.RecordGetTone(p);
@@ -383,8 +371,8 @@ namespace Vocaluxe.Base
} }
} }
} }
} }
} }
} }
_OldBeatD = _CurrentBeatD; _OldBeatD = _CurrentBeatD;
+1
View File
@@ -69,6 +69,7 @@ namespace Vocaluxe.Base
public const string sFileCover = "Cover.xml"; public const string sFileCover = "Cover.xml";
public const string sFileFonts = "Fonts.xml"; public const string sFileFonts = "Fonts.xml";
public const string sFileOldHighscoreDB = "Ultrastar.db";
public static string sFileHighscoreDB = "HighscoreDB.sqlite"; public static string sFileHighscoreDB = "HighscoreDB.sqlite";
public const string sFileCoverDB = "CoverDB.sqlite"; public const string sFileCoverDB = "CoverDB.sqlite";
public const string sFilePerformanceLog = "Performance.log"; public const string sFilePerformanceLog = "Performance.log";
+2 -1
View File
@@ -79,7 +79,8 @@
+ v0.2.0: + v0.2.0:
- Medley - Medley
- WiiMote Support - WiiMote Support
- Jukebox light - Jukebox light (bg music controls)
- Show Avatars and Player Name in Sing Screen (and perhaps some other screens)
+ v0.3.0: + v0.3.0:
- Song Editor - Song Editor
+8
View File
@@ -237,6 +237,11 @@ namespace Vocaluxe.Lib.Song
this.MP3FileName = Value; this.MP3FileName = Value;
HeaderFlags |= EHeaderFlags.MP3; HeaderFlags |= EHeaderFlags.MP3;
} }
else
{
CLog.LogError("Can't find audio file: " + Path.Combine(this.Folder, Value));
return false;
}
break; break;
case "BPM": case "BPM":
if (CHelper.TryParse(Value, out this.BPM)) if (CHelper.TryParse(Value, out this.BPM))
@@ -283,6 +288,9 @@ namespace Vocaluxe.Lib.Song
case "VIDEO": case "VIDEO":
if (File.Exists(Path.Combine(this.Folder, Value))) if (File.Exists(Path.Combine(this.Folder, Value)))
this.VideoFileName = Value; this.VideoFileName = Value;
else
CLog.LogError("Can't find video file: " + Path.Combine(this.Folder, Value));
break; break;
case "VIDEOGAP": case "VIDEOGAP":
CHelper.TryParse(Value, out this.VideoGap); CHelper.TryParse(Value, out this.VideoGap);
+20 -3
View File
@@ -141,7 +141,7 @@ namespace Vocaluxe
CLog.StopBenchmark(0, "Init Game"); CLog.StopBenchmark(0, "Init Game");
Application.DoEvents(); Application.DoEvents();
System.Threading.Thread.Sleep(10000);
// Start Main Loop // Start Main Loop
_SplashScreen.Close(); _SplashScreen.Close();
CDraw.MainLoop(); CDraw.MainLoop();
@@ -192,6 +192,8 @@ namespace Vocaluxe
class SplashScreen : Form class SplashScreen : Form
{ {
Bitmap logo;
public SplashScreen() public SplashScreen()
{ {
string path = Path.Combine(Environment.CurrentDirectory, Path.Combine(CSettings.sFolderGraphics, CSettings.sLogo)); string path = Path.Combine(Environment.CurrentDirectory, Path.Combine(CSettings.sFolderGraphics, CSettings.sLogo));
@@ -199,9 +201,8 @@ namespace Vocaluxe
{ {
try try
{ {
Bitmap logo = new Bitmap(path); logo = new Bitmap(path);
this.ClientSize = new Size(logo.Width, logo.Height); this.ClientSize = new Size(logo.Width, logo.Height);
this.BackgroundImage = logo;
} }
catch (Exception e) catch (Exception e)
{ {
@@ -227,10 +228,26 @@ namespace Vocaluxe
else else
CLog.LogError("Can't find " + path); CLog.LogError("Can't find " + path);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Text = CSettings.sProgramName; this.Text = CSettings.sProgramName;
this.CenterToScreen(); this.CenterToScreen();
this.Show(); this.Show();
} }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
}
protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs e)
{
if (logo == null)
return;
Graphics g = e.Graphics;
g.DrawImage(logo, new Rectangle(0, 0, this.Width, this.Height));
}
} }
} }
+33 -3
View File
@@ -582,6 +582,7 @@ namespace Vocaluxe.Screens
lines[i] = song.Notes.GetLines(i); lines[i] = song.Notes.GetLines(i);
CLine[] line = lines[i].Line; CLine[] line = lines[i].Line;
// find current line (it must be the same as in CalcFadingAlpha)
int nr = -1; int nr = -1;
for (int j = 0; j < line.Length; j++) for (int j = 0; j < line.Length; j++)
{ {
@@ -850,6 +851,20 @@ namespace Vocaluxe.Screens
lines[i] = Song.Notes.GetLines(i); lines[i] = Song.Notes.GetLines(i);
CLine[] line = lines[i].Line; CLine[] line = lines[i].Line;
// find current line for lyric sub fading (it must be the same as in UpdateLyrics)
int CurrentLineSub = 0;
for (int j = 0; j < line.Length; j++)
{
if (line[j].StartBeat <= _CurrentBeat)
{
if (CGame.GetTimeFromBeats(line[j].FirstBeat, Song.BPM) <= _CurrentTime - Song.Gap + 10f)
{
CurrentLineSub = j;
}
}
}
// find current line for lyric main fading
int CurrentLine = 0; int CurrentLine = 0;
for (int j = 0; j < line.Length; j++) for (int j = 0; j < line.Length; j++)
{ {
@@ -863,9 +878,11 @@ namespace Vocaluxe.Screens
Alpha[i * 2] = 1f; Alpha[i * 2] = 1f;
Alpha[i * 2 + 1] = 1f; Alpha[i * 2 + 1] = 1f;
// main // main line alpha
if (CurrentLine == 0 && CurrentTime < CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM)) if (CurrentLine == 0 && CurrentTime < CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM))
{ {
// first main line and fist note is not reached
// => fade in
float diff = CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM) - CurrentTime; float diff = CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM) - CurrentTime;
if (diff > dt) if (diff > dt)
{ {
@@ -875,20 +892,29 @@ namespace Vocaluxe.Screens
else if (CurrentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime && else if (CurrentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime &&
CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) > CurrentTime) CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) > CurrentTime)
{ {
// current position is between two lines
// time between the to lines
float diff = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - float diff = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) -
CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM); CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM);
// fade only if there is enough time for fading
if (diff > 3.3f * dt) if (diff > 3.3f * dt)
{ {
// time elapsed since last line
float last = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM); float last = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM);
// time to next line
float next = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - CurrentTime; float next = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - CurrentTime;
if (last < next) if (last < next)
{ {
// fade out
Alpha[i * 2] = 1f - last / rt; Alpha[i * 2] = 1f - last / rt;
} }
else else
{ {
// fade in if it is time for
if (next > dt) if (next > dt)
Alpha[i * 2] = 1f - (next - dt) / rt; Alpha[i * 2] = 1f - (next - dt) / rt;
} }
@@ -896,14 +922,18 @@ namespace Vocaluxe.Screens
} }
else if (CurrentLine == line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime) else if (CurrentLine == line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime)
{ {
// last main line and last note was reached
// => fade out
float diff = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM); float diff = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM);
Alpha[i * 2] = 1f - diff / rt; Alpha[i * 2] = 1f - diff / rt;
} }
// sub // sub
if (CurrentLine < line.Length - 2) if (CurrentLineSub < line.Length - 2)
{ {
float diff = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) - CurrentTime; float diff = 0f;
diff = CGame.GetTimeFromBeats(line[CurrentLineSub + 1].FirstBeat, Song.BPM) - CurrentTime;
if (diff > dt) if (diff > dt)
{ {
Alpha[i * 2 + 1] = 1f - (diff - dt) / rt; Alpha[i * 2 + 1] = 1f - (diff - dt) / rt;