Merge branch 'develop' into challenge
This commit is contained in:
commit
0d8934dea8
7 files changed
+85
-18
No files matched your search
+60
-11
@@ -54,7 +54,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
#region Highscores
|
||||
public static int AddScore(string PlayerName, int Score, int LineNr, long Date, int Medley, int Duet, int Diff,
|
||||
public static int AddScore(string PlayerName, int Score, int LineNr, long Date, int Medley, int Duet, int ShortSong, int Diff,
|
||||
string Artist, string Title, int NumPlayed, string FilePath)
|
||||
{
|
||||
SPlayer player = new SPlayer();
|
||||
@@ -64,6 +64,7 @@ namespace Vocaluxe.Base
|
||||
player.DateTicks = Date;
|
||||
player.Medley = (Medley == 1);
|
||||
player.Duet = (Duet == 1);
|
||||
player.ShortSong = (ShortSong == 1);
|
||||
player.Difficulty = (EGameDifficulty)Diff;
|
||||
|
||||
SQLiteConnection connection = new SQLiteConnection();
|
||||
@@ -134,8 +135,12 @@ namespace Vocaluxe.Base
|
||||
if (player.Duet)
|
||||
Duet = 1;
|
||||
|
||||
int ShortSong = 0;
|
||||
if (player.ShortSong)
|
||||
ShortSong = 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";
|
||||
"LineNr = @LineNr AND Date = @Date AND Medley = @Medley AND Duet = @Duet AND ShortSong = @ShortSong 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);
|
||||
@@ -143,6 +148,7 @@ namespace Vocaluxe.Base
|
||||
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("@ShortSong", System.Data.DbType.Int32, 0).Value = ShortSong;
|
||||
command.Parameters.Add("@Difficulty", System.Data.DbType.Int32, 0).Value = (int)player.Difficulty;
|
||||
|
||||
SQLiteDataReader reader = null;
|
||||
@@ -165,8 +171,8 @@ namespace Vocaluxe.Base
|
||||
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.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty) " +
|
||||
"VALUES (@SongID, @PlayerName, @Score, @LineNr, @Date, @Medley, @Duet, @ShortSong, @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);
|
||||
@@ -174,6 +180,7 @@ namespace Vocaluxe.Base
|
||||
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("@ShortSong", System.Data.DbType.Int32, 0).Value = Duet;
|
||||
command.Parameters.Add("@Difficulty", System.Data.DbType.Int32, 0).Value = (int)player.Difficulty;
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
@@ -232,15 +239,20 @@ namespace Vocaluxe.Base
|
||||
if (player.Duet)
|
||||
Duet = 1;
|
||||
|
||||
int ShortSong = 0;
|
||||
if (player.ShortSong)
|
||||
ShortSong = 1;
|
||||
|
||||
int DataBaseSongID = GetDataBaseSongID(player, command);
|
||||
if (DataBaseSongID >= 0)
|
||||
{
|
||||
command.CommandText = "SELECT PlayerName, Score, Date, Difficulty, LineNr, id FROM Scores " +
|
||||
"WHERE [SongID] = @SongID AND [Medley] = @Medley AND [Duet] = @Duet " +
|
||||
"WHERE [SongID] = @SongID AND [Medley] = @Medley AND [Duet] = @Duet AND [ShortSong] = @ShortSong " +
|
||||
"ORDER BY [Score] DESC";
|
||||
command.Parameters.Add("@SongID", System.Data.DbType.Int32, 0).Value = DataBaseSongID;
|
||||
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("@ShortSong", System.Data.DbType.Int32, 0).Value = ShortSong;
|
||||
|
||||
SQLiteDataReader reader = null;
|
||||
try
|
||||
@@ -495,7 +507,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
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);";
|
||||
"Medley INTEGER NOT NULL, Duet INTEGER NOT NULL, ShortSong INTEGER NOT NULL, Difficulty INTEGER NOT NULL);";
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
command.Dispose();
|
||||
@@ -550,10 +562,11 @@ namespace Vocaluxe.Base
|
||||
else
|
||||
{
|
||||
reader.Read();
|
||||
|
||||
if (reader.GetInt32(0) < CSettings.iDatabaseHighscoreVersion)
|
||||
int CurrentVersion = reader.GetInt32(0);
|
||||
if (CurrentVersion < CSettings.iDatabaseHighscoreVersion)
|
||||
{
|
||||
// update database
|
||||
UpdateDatabase(CurrentVersion, connection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -583,10 +596,16 @@ namespace Vocaluxe.Base
|
||||
|
||||
//Check for USDX 1.1 DB
|
||||
if (version == 1)
|
||||
{
|
||||
ConvertFrom110(FilePath);
|
||||
UpdateDatabase(1, connection);
|
||||
}
|
||||
//Check for USDX 1.01 or CMD Mod DB
|
||||
else if (version == 0 && scoresTableExists)
|
||||
{
|
||||
ConvertFrom101(FilePath);
|
||||
UpdateDatabase(1, connection);
|
||||
}
|
||||
|
||||
command.Dispose();
|
||||
|
||||
@@ -906,6 +925,35 @@ namespace Vocaluxe.Base
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool UpdateDatabase(int CurrentVersion, SQLiteConnection connection)
|
||||
{
|
||||
bool updated = true;
|
||||
if (CurrentVersion < 2)
|
||||
{
|
||||
updated &= ConvertV1toV2(connection);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
private static bool ConvertV1toV2(SQLiteConnection connection)
|
||||
{
|
||||
SQLiteCommand command;
|
||||
|
||||
command = new SQLiteCommand(connection);
|
||||
|
||||
command.CommandText = "ALTER TABLE Scores ADD ShortSong INTEGER";
|
||||
command.ExecuteNonQuery();
|
||||
command.CommandText = "UPDATE Scores SET [ShortSong] = @ShortSong";
|
||||
command.Parameters.Add("@ShortSong", System.Data.DbType.Int32, 0).Value = 0;
|
||||
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
|
||||
@@ -927,7 +975,7 @@ namespace Vocaluxe.Base
|
||||
SQLiteDataReader rSource;
|
||||
|
||||
#region import table scores
|
||||
cmdSource.CommandText = "SELECT SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty FROM Scores";
|
||||
cmdSource.CommandText = "SELECT SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty FROM Scores";
|
||||
rSource = cmdSource.ExecuteReader();
|
||||
if (rSource == null)
|
||||
{
|
||||
@@ -953,13 +1001,14 @@ namespace Vocaluxe.Base
|
||||
long date = rSource.GetInt64(4);
|
||||
int medley = rSource.GetInt32(5);
|
||||
int duet = rSource.GetInt32(6);
|
||||
int diff = rSource.GetInt32(7);
|
||||
int shortsong = rSource.GetInt32(7);
|
||||
int diff = rSource.GetInt32(8);
|
||||
|
||||
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);
|
||||
AddScore(player, score, linenr, date, medley, duet, shortsong, diff, artist, title, numplayed, _HighscoreFilePath);
|
||||
}
|
||||
}
|
||||
#endregion import table scores
|
||||
|
||||
@@ -280,11 +280,17 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
if (Note == lines[Line].NoteCount - 1)
|
||||
{
|
||||
if (notes[Note].EndBeat == beat)
|
||||
if (notes[Note].EndBeat == beat
|
||||
|| (_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat)
|
||||
|| (_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat))
|
||||
_Player[p].SongFinished = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat) ||
|
||||
(_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat))
|
||||
_Player[p].SongFinished = true;
|
||||
|
||||
if (notes[Note].PointsForBeat > 0 && (CSound.RecordToneValid(p) || DEBUG_HIT))
|
||||
{
|
||||
int Tone = notes[Note].Tone;
|
||||
|
||||
@@ -40,11 +40,11 @@ namespace Vocaluxe.Base
|
||||
public const int iVersionMajor = 0;
|
||||
public const int iVersionMinor = 2; // milestones
|
||||
public const int iVersionSub = 0; // patches
|
||||
public const ERevision VersionRevision = ERevision.Beta;
|
||||
public const ERevision VersionRevision = ERevision.RC;
|
||||
|
||||
public const int iBuild = 70; // Increase on every published version! Never Reset!
|
||||
public const int iBuild = 71; // Increase on every published version! Never Reset!
|
||||
|
||||
public const int iDatabaseHighscoreVersion = 1;
|
||||
public const int iDatabaseHighscoreVersion = 2;
|
||||
public const int iDatabaseCoverVersion = 1;
|
||||
public const int iDatabaseCreditsRessourcesVersion = 1;
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
break;
|
||||
|
||||
default:
|
||||
CLog.LogError("(WiiMoteLib) Unknown report type: " + type.ToString("x"));
|
||||
//CLog.LogError("(WiiMoteLib) Unknown report type: " + type.ToString("x"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,6 +178,13 @@ namespace Vocaluxe.Screens
|
||||
Texts[htTexts(TextScore[p])].Style = EStyle.BoldItalic;
|
||||
Texts[htTexts(TextDate[p])].Style = EStyle.BoldItalic;
|
||||
}
|
||||
else
|
||||
{
|
||||
Texts[htTexts(TextNumber[p])].Style = EStyle.Bold;
|
||||
Texts[htTexts(TextName[p])].Style = EStyle.Bold;
|
||||
Texts[htTexts(TextScore[p])].Style = EStyle.Bold;
|
||||
Texts[htTexts(TextDate[p])].Style = EStyle.Bold;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -643,9 +643,12 @@ namespace Vocaluxe.Screens
|
||||
//Otherwise, this is done by CScreenNames
|
||||
if (CGame.GetNumSongs() > 1)
|
||||
{
|
||||
for (int i = 1; i <= CGame.NumPlayer; i = i + 2)
|
||||
for (int i = 0; i < CGame.NumPlayer; i++)
|
||||
{
|
||||
CGame.Player[i].LineNr = 1;
|
||||
if ((i % 2) == 0)
|
||||
CGame.Player[i].LineNr = 1;
|
||||
else
|
||||
CGame.Player[i].LineNr = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -471,6 +471,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
if (CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1)
|
||||
{
|
||||
ToggleSongOptions(ESongOptionsView.None);
|
||||
StartVisibleSong(SongMenus[htSongMenus(SongMenu)].GetActualSelection());
|
||||
return true;
|
||||
}
|
||||
@@ -857,6 +858,7 @@ namespace Vocaluxe.Screens
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
if (CSongs.AllSongs[SongNr].IsDuet)
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
|
||||
CGame.AddSong(SongNr, gm);
|
||||
|
||||
IDs.Remove(SongNr);
|
||||
|
||||
Reference in new issue
Block a user