Code Formating

This commit is contained in:
Flamefire committed 2013-03-20 00:13:17 +01:00
1 parent 71d5b2ce76
commit 21a7ea257e
4 files changed
+180 -241

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Cleanup/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Cleanup"&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;DISABLED&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;ALWAYS_EXPLICIT&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;ALWAYS_EXPLICIT&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;False&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">Cleanup</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AROUND_FIELD/@EntryValue">0</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_INSIDE_REGION/@EntryValue">0</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EXPLICIT_INTERNAL_MODIFIER/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_ATTRIBUTE_STYLE/@EntryValue">JOIN</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FIXED_BRACES_STYLE/@EntryValue">ONLY_FOR_MULTILINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOR_BRACES_STYLE/@EntryValue">ONLY_FOR_MULTILINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_FOREACH_BRACES_STYLE/@EntryValue">ONLY_FOR_MULTILINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_IFELSE_BRACES_STYLE/@EntryValue">ONLY_FOR_MULTILINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_USING_BRACES_STYLE/@EntryValue">ONLY_FOR_MULTILINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ONLY_FOR_MULTILINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_COMPLEX_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_MULTIPLICATIVE_OP/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_SIZEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_FOR_STMT_HEADER_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">180</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_DECLARATION_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_TERNARY_EXPR_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AllowAlias/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=27c8359b_002D97bf_002D4e1d_002Db126_002D4f613028bcc5/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public" Description="Enums"&gt;&lt;ElementKinds&gt;&lt;Kind Name="ENUM" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="E" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=8cff90ce_002Def0d_002D436d_002Db8f2_002D5b5bdb923d3b/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public" Description="Classes"&gt;&lt;ElementKinds&gt;&lt;Kind Name="CLASS" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="C" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String></wpf:ResourceDictionary>
+104 -155
View File
@@ -6,7 +6,6 @@ using System.Drawing.Imaging;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.IO; using System.IO;
using System.Text; using System.Text;
#if WIN #if WIN
using System.Data.SQLite; using System.Data.SQLite;
#else #else
@@ -16,9 +15,7 @@ using SQLiteTransaction = Mono.Data.Sqlite.SqliteTransaction;
using SQLiteCommand = Mono.Data.Sqlite.SqliteCommand; using SQLiteCommand = Mono.Data.Sqlite.SqliteCommand;
using SQLiteDataReader = Mono.Data.Sqlite.SqliteDataReader; using SQLiteDataReader = Mono.Data.Sqlite.SqliteDataReader;
#endif #endif
using Community.CsharpSqlite; using Community.CsharpSqlite;
using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu; using Vocaluxe.Menu;
using Vocaluxe.Menu.SongMenu; using Vocaluxe.Menu.SongMenu;
@@ -27,7 +24,7 @@ namespace Vocaluxe.Base
{ {
static class CDataBase static class CDataBase
{ {
struct SData private struct SData
{ {
public int id; public int id;
public long ticks; public long ticks;
@@ -39,14 +36,14 @@ namespace Vocaluxe.Base
private static string _CoverFilePath; private static string _CoverFilePath;
private static string _CreditsRessourcesFilePath; private static string _CreditsRessourcesFilePath;
private static SQLiteConnection _ConnectionCover = null; private static SQLiteConnection _ConnectionCover;
private static SQLiteTransaction _TransactionCover = null; private static SQLiteTransaction _TransactionCover;
public static void Init() public static void Init()
{ {
_HighscoreFilePath = Path.Combine(System.Environment.CurrentDirectory, CSettings.sFileHighscoreDB); _HighscoreFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.sFileHighscoreDB);
_CoverFilePath = Path.Combine(System.Environment.CurrentDirectory, CSettings.sFileCoverDB); _CoverFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.sFileCoverDB);
_CreditsRessourcesFilePath = Path.Combine(System.Environment.CurrentDirectory, CSettings.sFileCreditsRessourcesDB); _CreditsRessourcesFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.sFileCreditsRessourcesDB);
InitHighscoreDB(); InitHighscoreDB();
InitCoverDB(); InitCoverDB();
@@ -56,7 +53,7 @@ namespace Vocaluxe.Base
#region Highscores #region Highscores
public static int AddScore(string PlayerName, int Score, int LineNr, long Date, int Medley, int Duet, int ShortSong, 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) string Artist, string Title, int NumPlayed, string FilePath)
{ {
SPlayer player = new SPlayer(); SPlayer player = new SPlayer();
player.Name = PlayerName; player.Name = PlayerName;
@@ -83,13 +80,11 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
int DataBaseSongID = GetDataBaseSongID(Artist, Title, NumPlayed, command); int DataBaseSongID = GetDataBaseSongID(Artist, Title, NumPlayed, command);
int result = AddScore(player, command, DataBaseSongID); int result = AddScore(player, command, DataBaseSongID);
return result; return result;
} }
} }
} }
public static int AddScore(SPlayer player) public static int AddScore(SPlayer player)
@@ -109,13 +104,12 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
int DataBaseSongID = GetDataBaseSongID(player, command); int DataBaseSongID = GetDataBaseSongID(player, command);
int result = AddScore(player, command, DataBaseSongID); int result = AddScore(player, command, DataBaseSongID);
return result; return result;
} }
} }
} }
private static int AddScore(SPlayer player, SQLiteCommand command, int DataBaseSongID) private static int AddScore(SPlayer player, SQLiteCommand command, int DataBaseSongID)
@@ -124,7 +118,6 @@ namespace Vocaluxe.Base
if (DataBaseSongID >= 0) if (DataBaseSongID >= 0)
{ {
int Medley = 0; int Medley = 0;
if (player.Medley) if (player.Medley)
Medley = 1; Medley = 1;
@@ -138,25 +131,23 @@ namespace Vocaluxe.Base
ShortSong = 1; ShortSong = 1;
command.CommandText = "SELECT id FROM Scores WHERE SongID = @SongID AND PlayerName = @PlayerName AND Score = @Score AND " + 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 ShortSong = @ShortSong 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("@SongID", DbType.Int32, 0).Value = DataBaseSongID;
command.Parameters.Add("@PlayerName", System.Data.DbType.String, 0).Value = player.Name; command.Parameters.Add("@PlayerName", DbType.String, 0).Value = player.Name;
command.Parameters.Add("@Score", System.Data.DbType.Int32, 0).Value = (int)Math.Round(player.Points); command.Parameters.Add("@Score", 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("@LineNr", DbType.Int32, 0).Value = player.LineNr;
command.Parameters.Add("@Date", System.Data.DbType.Int64, 0).Value = player.DateTicks; command.Parameters.Add("@Date", DbType.Int64, 0).Value = player.DateTicks;
command.Parameters.Add("@Medley", System.Data.DbType.Int32, 0).Value = Medley; command.Parameters.Add("@Medley", DbType.Int32, 0).Value = Medley;
command.Parameters.Add("@Duet", System.Data.DbType.Int32, 0).Value = Duet; command.Parameters.Add("@Duet", DbType.Int32, 0).Value = Duet;
command.Parameters.Add("@ShortSong", System.Data.DbType.Int32, 0).Value = ShortSong; command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = ShortSong;
command.Parameters.Add("@Difficulty", System.Data.DbType.Int32, 0).Value = (int)player.Difficulty; command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = (int)player.Difficulty;
SQLiteDataReader reader = null; SQLiteDataReader reader = null;
try try
{ {
reader = command.ExecuteReader(); reader = command.ExecuteReader();
} }
catch (Exception) catch (Exception) {}
{
}
if (reader != null && reader.HasRows) if (reader != null && reader.HasRows)
{ {
@@ -171,16 +162,16 @@ namespace Vocaluxe.Base
} }
command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, 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)"; "VALUES (@SongID, @PlayerName, @Score, @LineNr, @Date, @Medley, @Duet, @ShortSong, @Difficulty)";
command.Parameters.Add("@SongID", System.Data.DbType.Int32, 0).Value = DataBaseSongID; command.Parameters.Add("@SongID", DbType.Int32, 0).Value = DataBaseSongID;
command.Parameters.Add("@PlayerName", System.Data.DbType.String, 0).Value = player.Name; command.Parameters.Add("@PlayerName", DbType.String, 0).Value = player.Name;
command.Parameters.Add("@Score", System.Data.DbType.Int32, 0).Value = (int)Math.Round(player.Points); command.Parameters.Add("@Score", 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("@LineNr", DbType.Int32, 0).Value = player.LineNr;
command.Parameters.Add("@Date", System.Data.DbType.Int64, 0).Value = player.DateTicks; command.Parameters.Add("@Date", DbType.Int64, 0).Value = player.DateTicks;
command.Parameters.Add("@Medley", System.Data.DbType.Int32, 0).Value = Medley; command.Parameters.Add("@Medley", DbType.Int32, 0).Value = Medley;
command.Parameters.Add("@Duet", System.Data.DbType.Int32, 0).Value = Duet; command.Parameters.Add("@Duet", DbType.Int32, 0).Value = Duet;
command.Parameters.Add("@ShortSong", System.Data.DbType.Int32, 0).Value = ShortSong; command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = ShortSong;
command.Parameters.Add("@Difficulty", System.Data.DbType.Int32, 0).Value = (int)player.Difficulty; command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = (int)player.Difficulty;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
//Read last insert line //Read last insert line
@@ -191,9 +182,7 @@ namespace Vocaluxe.Base
if (reader != null && reader.HasRows) if (reader != null && reader.HasRows)
{ {
while (reader.Read()) while (reader.Read())
{
lastInsertID = reader.GetInt32(0); lastInsertID = reader.GetInt32(0);
}
reader.Dispose(); reader.Dispose();
} }
} }
@@ -220,7 +209,6 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
int Medley = 0; int Medley = 0;
if (player.Medley) if (player.Medley)
Medley = 1; Medley = 1;
@@ -237,12 +225,12 @@ namespace Vocaluxe.Base
if (DataBaseSongID >= 0) if (DataBaseSongID >= 0)
{ {
command.CommandText = "SELECT PlayerName, Score, Date, Difficulty, LineNr, id FROM Scores " + command.CommandText = "SELECT PlayerName, Score, Date, Difficulty, LineNr, id FROM Scores " +
"WHERE [SongID] = @SongID AND [Medley] = @Medley AND [Duet] = @Duet AND [ShortSong] = @ShortSong " + "WHERE [SongID] = @SongID AND [Medley] = @Medley AND [Duet] = @Duet AND [ShortSong] = @ShortSong " +
"ORDER BY [Score] DESC"; "ORDER BY [Score] DESC";
command.Parameters.Add("@SongID", System.Data.DbType.Int32, 0).Value = DataBaseSongID; command.Parameters.Add("@SongID", DbType.Int32, 0).Value = DataBaseSongID;
command.Parameters.Add("@Medley", System.Data.DbType.Int32, 0).Value = Medley; command.Parameters.Add("@Medley", DbType.Int32, 0).Value = Medley;
command.Parameters.Add("@Duet", System.Data.DbType.Int32, 0).Value = Duet; command.Parameters.Add("@Duet", DbType.Int32, 0).Value = Duet;
command.Parameters.Add("@ShortSong", System.Data.DbType.Int32, 0).Value = ShortSong; command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = ShortSong;
SQLiteDataReader reader = command.ExecuteReader(); SQLiteDataReader reader = command.ExecuteReader();
if (reader != null && reader.HasRows) if (reader != null && reader.HasRows)
@@ -261,10 +249,7 @@ namespace Vocaluxe.Base
} }
reader.Dispose(); reader.Dispose();
} }
} }
} }
} }
} }
@@ -295,18 +280,15 @@ namespace Vocaluxe.Base
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{
return GetDataBaseSongID(Artist, Title, DefNumPlayed, command); return GetDataBaseSongID(Artist, Title, DefNumPlayed, command);
}
} }
} }
private static int GetDataBaseSongID(string Artist, string Title, int DefNumPlayed, SQLiteCommand command) 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 = Title; command.Parameters.Add("@title", DbType.String, 0).Value = Title;
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = Artist; command.Parameters.Add("@artist", DbType.String, 0).Value = Artist;
SQLiteDataReader reader = command.ExecuteReader(); SQLiteDataReader reader = command.ExecuteReader();
@@ -323,15 +305,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, @numplayed)"; "VALUES (@title, @artist, @numplayed)";
command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = Title; command.Parameters.Add("@title", DbType.String, 0).Value = Title;
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = Artist; command.Parameters.Add("@artist", DbType.String, 0).Value = Artist;
command.Parameters.Add("@numplayed", System.Data.DbType.Int32, 0).Value = DefNumPlayed; command.Parameters.Add("@numplayed", 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 = Title; command.Parameters.Add("@title", DbType.String, 0).Value = Title;
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = Artist; command.Parameters.Add("@artist", DbType.String, 0).Value = Artist;
reader = command.ExecuteReader(); reader = command.ExecuteReader();
@@ -372,7 +354,7 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "SELECT Artist, Title, NumPlayed FROM Songs WHERE [id] = @id"; command.CommandText = "SELECT Artist, Title, NumPlayed FROM Songs WHERE [id] = @id";
command.Parameters.Add("@id", System.Data.DbType.String, 0).Value = SongID; command.Parameters.Add("@id", DbType.String, 0).Value = SongID;
SQLiteDataReader reader = null; SQLiteDataReader reader = null;
try try
@@ -442,23 +424,21 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);"; command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "INSERT INTO Version (id, Value) VALUES(NULL, @Value)"; command.CommandText = "INSERT INTO Version (id, Value) VALUES(NULL, @Value)";
command.Parameters.Add("@Value",DbType.Int32).Value = CSettings.iDatabaseHighscoreVersion; command.Parameters.Add("@Value", DbType.Int32).Value = CSettings.iDatabaseHighscoreVersion;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE IF NOT EXISTS Songs ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + 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);"; "Artist TEXT NOT NULL, Title TEXT NOT NULL, NumPlayed INTEGER);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE IF NOT EXISTS Scores ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + 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, " + "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, ShortSong 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.ExecuteNonQuery();
} }
} }
} }
@@ -480,7 +460,6 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);"; command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
@@ -488,20 +467,19 @@ namespace Vocaluxe.Base
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE IF NOT EXISTS Songs ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + 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);"; "Artist TEXT NOT NULL, Title TEXT NOT NULL, NumPlayed INTEGER);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE IF NOT EXISTS Scores ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + 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, " + "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, Difficulty INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }
} }
/// <summary> /// <summary>
/// Creates a new Vocaluxe Database if no file exists. Converts an existing old Ultrastar Deluxe highscore database into vocaluxe format. /// Creates a new Vocaluxe Database if no file exists. Converts an existing old Ultrastar Deluxe highscore database into vocaluxe format.
/// </summary> /// </summary>
/// <param name="FilePath">Database file path</param> /// <param name="FilePath">Database file path</param>
/// <returns></returns> /// <returns></returns>
@@ -523,7 +501,6 @@ namespace Vocaluxe.Base
SQLiteDataReader reader = null; SQLiteDataReader reader = null;
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "PRAGMA user_version"; command.CommandText = "PRAGMA user_version";
reader = command.ExecuteReader(); reader = command.ExecuteReader();
reader.Read(); reader.Read();
@@ -547,9 +524,7 @@ namespace Vocaluxe.Base
{ {
reader = command.ExecuteReader(); reader = command.ExecuteReader();
} }
catch (Exception) catch (Exception) {}
{
}
if (reader == null) if (reader == null)
{ {
@@ -607,7 +582,7 @@ namespace Vocaluxe.Base
} }
/// <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> /// <param name="FilePath">Database file path</param>
/// <returns>True if succeeded</returns> /// <returns>True if succeeded</returns>
@@ -628,9 +603,9 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
//The USDX database has no column for LineNr, Medley and Duet so just fill 0 in there //The USDX database has no column for LineNr, Medley and Duet so just fill 0 in there
command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores"; command.CommandText =
"INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs"; command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs";
@@ -663,7 +638,7 @@ namespace Vocaluxe.Base
{ {
ticks = reader.GetInt64(2); ticks = reader.GetInt64(2);
} }
catch { } catch {}
data.ticks = UnixTimeToTicks((int)ticks); data.ticks = UnixTimeToTicks((int)ticks);
@@ -688,7 +663,7 @@ namespace Vocaluxe.Base
} }
} }
if(reader != null) if (reader != null)
reader.Dispose(); reader.Dispose();
SQLiteTransaction _Transaction = connection.BeginTransaction(); SQLiteTransaction _Transaction = connection.BeginTransaction();
@@ -696,9 +671,9 @@ namespace Vocaluxe.Base
foreach (SData data in songs) foreach (SData data in songs)
{ {
command.CommandText = "UPDATE Songs SET [Artist] = @artist, [Title] = @title WHERE [ID] = @id"; command.CommandText = "UPDATE Songs SET [Artist] = @artist, [Title] = @title WHERE [ID] = @id";
command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = data.str2; command.Parameters.Add("@title", DbType.String, 0).Value = data.str2;
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = data.str1; command.Parameters.Add("@artist", DbType.String, 0).Value = data.str1;
command.Parameters.Add("@id", System.Data.DbType.Int32, 0).Value = data.id; command.Parameters.Add("@id", DbType.Int32, 0).Value = data.id;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
@@ -706,9 +681,9 @@ namespace Vocaluxe.Base
foreach (SData data in scores) foreach (SData data in scores)
{ {
command.CommandText = "UPDATE Scores SET [PlayerName] = @player, [Date] = @date WHERE [id] = @id"; command.CommandText = "UPDATE Scores SET [PlayerName] = @player, [Date] = @date WHERE [id] = @id";
command.Parameters.Add("@player", System.Data.DbType.String, 0).Value = data.str1; command.Parameters.Add("@player", DbType.String, 0).Value = data.str1;
command.Parameters.Add("@date", System.Data.DbType.Int64, 0).Value = data.ticks; command.Parameters.Add("@date", DbType.Int64, 0).Value = data.ticks;
command.Parameters.Add("@id", System.Data.DbType.Int32, 0).Value = data.id; command.Parameters.Add("@id", DbType.Int32, 0).Value = data.id;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
_Transaction.Commit(); _Transaction.Commit();
@@ -726,7 +701,6 @@ namespace Vocaluxe.Base
//This versioning is not used in Vocaluxe so reset it to 0 //This versioning is not used in Vocaluxe so reset it to 0
command.CommandText = "PRAGMA user_version = 0"; command.CommandText = "PRAGMA user_version = 0";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }
@@ -734,7 +708,7 @@ 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> /// <param name="FilePath">Database file path</param>
/// <returns>True if succeeded</returns> /// <returns>True if succeeded</returns>
@@ -755,7 +729,6 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "PRAGMA table_info(US_Scores);"; command.CommandText = "PRAGMA table_info(US_Scores);";
bool dateExists = false; bool dateExists = false;
using (SQLiteDataReader reader = command.ExecuteReader()) using (SQLiteDataReader reader = command.ExecuteReader())
@@ -773,14 +746,19 @@ namespace Vocaluxe.Base
} }
} }
} }
} }
//This is a USDX 1.01 DB //This is a USDX 1.01 DB
if (!dateExists) if (!dateExists)
command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', '0', '0', '0', Difficulty from US_Scores"; {
command.CommandText =
"INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', '0', '0', '0', Difficulty from US_Scores";
}
else // This is a CMD 1.01 DB else // This is a CMD 1.01 DB
command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores"; {
command.CommandText =
"INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores";
}
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs"; command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs";
@@ -794,18 +772,14 @@ namespace Vocaluxe.Base
int res = Sqlite3.sqlite3_open(FilePath, 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: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")"); CLog.LogError("Error opening Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
}
else else
{ {
Sqlite3.Vdbe Stmt = new Sqlite3.Vdbe(); Sqlite3.Vdbe Stmt = new Sqlite3.Vdbe();
res = Sqlite3.sqlite3_prepare_v2(OldDB, "SELECT id, Artist, Title FROM Songs", -1, ref Stmt, 0); res = Sqlite3.sqlite3_prepare_v2(OldDB, "SELECT id, Artist, Title FROM Songs", -1, ref Stmt, 0);
if (res != Sqlite3.SQLITE_OK) if (res != Sqlite3.SQLITE_OK)
{
CLog.LogError("Error query Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")"); CLog.LogError("Error query Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
}
else else
{ {
//Sqlite3.sqlite3_step(Stmt); //Sqlite3.sqlite3_step(Stmt);
@@ -844,9 +818,7 @@ namespace Vocaluxe.Base
res = Sqlite3.sqlite3_prepare_v2(OldDB, "SELECT id, PlayerName, Date FROM Scores", -1, ref Stmt, 0); res = Sqlite3.sqlite3_prepare_v2(OldDB, "SELECT id, PlayerName, Date FROM Scores", -1, ref Stmt, 0);
if (res != Sqlite3.SQLITE_OK) if (res != Sqlite3.SQLITE_OK)
{
CLog.LogError("Error query Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")"); CLog.LogError("Error query Database: " + FilePath + " (" + Sqlite3.sqlite3_errmsg(OldDB) + ")");
}
else else
{ {
//Sqlite3.sqlite3_step(Stmt); //Sqlite3.sqlite3_step(Stmt);
@@ -882,9 +854,9 @@ namespace Vocaluxe.Base
foreach (SData data in songs) foreach (SData data in songs)
{ {
command.CommandText = "UPDATE Songs SET [Artist] = @artist, [Title] = @title WHERE [ID] = @id"; command.CommandText = "UPDATE Songs SET [Artist] = @artist, [Title] = @title WHERE [ID] = @id";
command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = data.str2; command.Parameters.Add("@title", DbType.String, 0).Value = data.str2;
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = data.str1; command.Parameters.Add("@artist", DbType.String, 0).Value = data.str1;
command.Parameters.Add("@id", System.Data.DbType.Int32, 0).Value = data.id; command.Parameters.Add("@id", DbType.Int32, 0).Value = data.id;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
@@ -896,10 +868,10 @@ namespace Vocaluxe.Base
else else
{ {
command.CommandText = "UPDATE Scores SET [PlayerName] = @player, [Date] = @date WHERE [id] = @id"; command.CommandText = "UPDATE Scores SET [PlayerName] = @player, [Date] = @date WHERE [id] = @id";
command.Parameters.Add("@date", System.Data.DbType.Int64, 0).Value = data.ticks; command.Parameters.Add("@date", DbType.Int64, 0).Value = data.ticks;
} }
command.Parameters.Add("@player", System.Data.DbType.String, 0).Value = data.str1; command.Parameters.Add("@player", DbType.String, 0).Value = data.str1;
command.Parameters.Add("@id", System.Data.DbType.Int32, 0).Value = data.id; command.Parameters.Add("@id", DbType.Int32, 0).Value = data.id;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
_Transaction.Commit(); _Transaction.Commit();
@@ -920,25 +892,21 @@ namespace Vocaluxe.Base
{ {
bool updated = true; bool updated = true;
if (CurrentVersion < 2) if (CurrentVersion < 2)
{
updated &= ConvertV1toV2(connection); updated &= ConvertV1toV2(connection);
}
return updated; return updated;
} }
private static bool ConvertV1toV2(SQLiteConnection connection) private static bool ConvertV1toV2(SQLiteConnection connection)
{ {
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "ALTER TABLE Scores ADD ShortSong INTEGER"; command.CommandText = "ALTER TABLE Scores ADD ShortSong INTEGER";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "UPDATE Scores SET [ShortSong] = @ShortSong"; command.CommandText = "UPDATE Scores SET [ShortSong] = @ShortSong";
command.Parameters.Add("@ShortSong", System.Data.DbType.Int32, 0).Value = 0; command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = 0;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "UPDATE Version SET [Value] = @version"; command.CommandText = "UPDATE Version SET [Value] = @version";
command.Parameters.Add("@version", System.Data.DbType.Int32, 0).Value = 2; command.Parameters.Add("@version", DbType.Int32, 0).Value = 2;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
@@ -961,7 +929,7 @@ namespace Vocaluxe.Base
CLog.LogError("Error on import high score data. Can't open source database \"" + SourceDBPath + "\" (" + e.Message + ")"); CLog.LogError("Error on import high score data. Can't open source database \"" + SourceDBPath + "\" (" + e.Message + ")");
return false; return false;
} }
#endregion open db #endregion open db
using (SQLiteCommand cmdSource = new SQLiteCommand(connSource)) using (SQLiteCommand cmdSource = new SQLiteCommand(connSource))
{ {
@@ -994,9 +962,7 @@ namespace Vocaluxe.Base
string artist, title; string artist, title;
int numplayed; int numplayed;
if (GetDataBaseSongInfos(songid, out artist, out title, out numplayed, SourceDBPath)) if (GetDataBaseSongInfos(songid, out artist, out title, out numplayed, SourceDBPath))
{
AddScore(player, score, linenr, date, medley, duet, shortsong, diff, artist, title, numplayed, _HighscoreFilePath); AddScore(player, score, linenr, date, medley, duet, shortsong, diff, artist, title, numplayed, _HighscoreFilePath);
}
} }
#endregion import table scores #endregion import table scores
@@ -1026,9 +992,8 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(_ConnectionCover)) using (SQLiteCommand command = new SQLiteCommand(_ConnectionCover))
{ {
command.CommandText = "SELECT id, width, height FROM Cover WHERE [Path] = @path"; command.CommandText = "SELECT id, width, height FROM Cover WHERE [Path] = @path";
command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = CoverPath; command.Parameters.Add("@path", DbType.String, 0).Value = CoverPath;
SQLiteDataReader reader = command.ExecuteReader(); SQLiteDataReader reader = command.ExecuteReader();
@@ -1041,7 +1006,7 @@ namespace Vocaluxe.Base
reader.Close(); reader.Close();
command.CommandText = "SELECT Data FROM CoverData WHERE CoverID = @id"; command.CommandText = "SELECT Data FROM CoverData WHERE CoverID = @id";
command.Parameters.Add("@id",DbType.Int32).Value=id; command.Parameters.Add("@id", DbType.Int32).Value = id;
reader = command.ExecuteReader(); reader = command.ExecuteReader();
if (reader.HasRows) if (reader.HasRows)
@@ -1059,9 +1024,7 @@ namespace Vocaluxe.Base
reader.Close(); reader.Close();
if (_TransactionCover == null) if (_TransactionCover == null)
{
_TransactionCover = _ConnectionCover.BeginTransaction(); _TransactionCover = _ConnectionCover.BeginTransaction();
}
Bitmap origin; Bitmap origin;
try try
@@ -1088,12 +1051,10 @@ namespace Vocaluxe.Base
using (Bitmap bmp = new Bitmap(w, h)) using (Bitmap bmp = new Bitmap(w, h))
{ {
using (Graphics g = Graphics.FromImage(bmp)) using (Graphics g = Graphics.FromImage(bmp))
{
g.DrawImage(origin, new Rectangle(0, 0, w, h)); g.DrawImage(origin, new Rectangle(0, 0, w, h));
}
data = new byte[w * h * 4]; data = new byte[w * h * 4];
BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(bmp_data.Scan0, data, 0, w * h * 4); Marshal.Copy(bmp_data.Scan0, data, 0, w * h * 4);
bmp.UnlockBits(bmp_data); bmp.UnlockBits(bmp_data);
} }
@@ -1107,12 +1068,12 @@ namespace Vocaluxe.Base
command.CommandText = "INSERT INTO Cover (Path, width, height) VALUES (@path, @w, @h)"; command.CommandText = "INSERT INTO Cover (Path, width, height) VALUES (@path, @w, @h)";
command.Parameters.Add("@w", DbType.Int32).Value = w; command.Parameters.Add("@w", DbType.Int32).Value = w;
command.Parameters.Add("@h", DbType.Int32).Value = h; command.Parameters.Add("@h", DbType.Int32).Value = h;
command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = CoverPath; command.Parameters.Add("@path", DbType.String, 0).Value = CoverPath;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "SELECT id FROM Cover WHERE [Path] = @path"; command.CommandText = "SELECT id FROM Cover WHERE [Path] = @path";
command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = CoverPath; command.Parameters.Add("@path", DbType.String, 0).Value = CoverPath;
reader = command.ExecuteReader(); reader = command.ExecuteReader();
if (reader != null) if (reader != null)
@@ -1122,7 +1083,7 @@ namespace Vocaluxe.Base
reader.Dispose(); reader.Dispose();
command.CommandText = "INSERT INTO CoverData (CoverID, Data) VALUES (@id, @data)"; command.CommandText = "INSERT INTO CoverData (CoverID, Data) VALUES (@id, @data)";
command.Parameters.Add("@id", DbType.Int32).Value = id; command.Parameters.Add("@id", DbType.Int32).Value = id;
command.Parameters.Add("@data", System.Data.DbType.Binary, 20).Value = data; command.Parameters.Add("@data", DbType.Binary, 20).Value = data;
command.ExecuteReader(); command.ExecuteReader();
return true; return true;
} }
@@ -1179,9 +1140,7 @@ namespace Vocaluxe.Base
{ {
reader = command.ExecuteReader(); reader = command.ExecuteReader();
} }
catch (Exception) catch (Exception) {}
{
}
if (reader == null) if (reader == null)
{ {
@@ -1226,7 +1185,6 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);"; command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
@@ -1235,13 +1193,12 @@ namespace Vocaluxe.Base
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE IF NOT EXISTS Cover ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + command.CommandText = "CREATE TABLE IF NOT EXISTS Cover ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
"Path TEXT NOT NULL, width INTEGER NOT NULL, height INTEGER NOT NULL);"; "Path TEXT NOT NULL, width INTEGER NOT NULL, height INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE IF NOT EXISTS CoverData ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + command.CommandText = "CREATE TABLE IF NOT EXISTS CoverData ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
"CoverID INTEGER NOT NULL, Data BLOB NOT NULL);"; "CoverID INTEGER NOT NULL, Data BLOB NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }
} }
@@ -1265,9 +1222,8 @@ namespace Vocaluxe.Base
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "SELECT id, width, height FROM Images WHERE [Path] = @path"; command.CommandText = "SELECT id, width, height FROM Images WHERE [Path] = @path";
command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = FileName; command.Parameters.Add("@path", DbType.String, 0).Value = FileName;
SQLiteDataReader reader = command.ExecuteReader(); SQLiteDataReader reader = command.ExecuteReader();
@@ -1280,7 +1236,7 @@ namespace Vocaluxe.Base
reader.Close(); reader.Close();
command.CommandText = "SELECT Data FROM ImageData WHERE ImageID = @id"; command.CommandText = "SELECT Data FROM ImageData WHERE ImageID = @id";
command.Parameters.Add("@id",DbType.Int32).Value=id; command.Parameters.Add("@id", DbType.Int32).Value = id;
reader = command.ExecuteReader(); reader = command.ExecuteReader();
if (reader.HasRows) if (reader.HasRows)
@@ -1307,7 +1263,6 @@ namespace Vocaluxe.Base
if (File.Exists(ImagePath)) if (File.Exists(ImagePath))
{ {
using (SQLiteConnection connection = new SQLiteConnection()) using (SQLiteConnection connection = new SQLiteConnection())
{ {
connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath; connection.ConnectionString = "Data Source=" + _CreditsRessourcesFilePath;
@@ -1321,7 +1276,6 @@ namespace Vocaluxe.Base
} }
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
Bitmap origin; Bitmap origin;
try try
{ {
@@ -1340,18 +1294,18 @@ namespace Vocaluxe.Base
{ {
data = new byte[w * h * 4]; data = new byte[w * h * 4];
BitmapData bmp_data = origin.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); BitmapData bmp_data = origin.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(bmp_data.Scan0, data, 0, w * h * 4); Marshal.Copy(bmp_data.Scan0, data, 0, w * h * 4);
origin.UnlockBits(bmp_data); origin.UnlockBits(bmp_data);
command.CommandText = "INSERT INTO Images (Path, width, height) VALUES (@path, @w, @h)"; command.CommandText = "INSERT INTO Images (Path, width, height) VALUES (@path, @w, @h)";
command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = Path.GetFileName(ImagePath); command.Parameters.Add("@path", DbType.String, 0).Value = Path.GetFileName(ImagePath);
command.Parameters.Add("@w", System.Data.DbType.Int32, 0).Value = w; command.Parameters.Add("@w", DbType.Int32, 0).Value = w;
command.Parameters.Add("@h", System.Data.DbType.Int32, 0).Value = h; command.Parameters.Add("@h", DbType.Int32, 0).Value = h;
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "SELECT id FROM Images WHERE [Path] = @path"; command.CommandText = "SELECT id FROM Images WHERE [Path] = @path";
command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = Path.GetFileName(ImagePath); command.Parameters.Add("@path", DbType.String, 0).Value = Path.GetFileName(ImagePath);
SQLiteDataReader reader = command.ExecuteReader(); SQLiteDataReader reader = command.ExecuteReader();
if (reader != null) if (reader != null)
@@ -1360,8 +1314,8 @@ namespace Vocaluxe.Base
int id = reader.GetInt32(0); int id = reader.GetInt32(0);
reader.Close(); reader.Close();
command.CommandText = "INSERT INTO ImageData (ImageID, Data) VALUES (@id, @data)"; command.CommandText = "INSERT INTO ImageData (ImageID, Data) VALUES (@id, @data)";
command.Parameters.Add("@id", System.Data.DbType.Int32, 20).Value = id; command.Parameters.Add("@id", DbType.Int32, 20).Value = id;
command.Parameters.Add("@data", System.Data.DbType.Binary, 20).Value = data; command.Parameters.Add("@data", DbType.Binary, 20).Value = data;
command.ExecuteReader(); command.ExecuteReader();
result = true; result = true;
} }
@@ -1370,7 +1324,6 @@ namespace Vocaluxe.Base
{ {
origin.Dispose(); origin.Dispose();
} }
} }
} }
} }
@@ -1403,9 +1356,7 @@ namespace Vocaluxe.Base
{ {
reader = command.ExecuteReader(); reader = command.ExecuteReader();
} }
catch (Exception) catch (Exception) {}
{
}
if (reader == null) if (reader == null)
{ {
@@ -1451,7 +1402,6 @@ namespace Vocaluxe.Base
using (SQLiteCommand command = new SQLiteCommand(connection)) using (SQLiteCommand command = new SQLiteCommand(connection))
{ {
command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);"; command.CommandText = "CREATE TABLE IF NOT EXISTS Version ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Value INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
@@ -1460,13 +1410,12 @@ namespace Vocaluxe.Base
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE IF NOT EXISTS Images ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + command.CommandText = "CREATE TABLE IF NOT EXISTS Images ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
"Path TEXT NOT NULL, width INTEGER NOT NULL, height INTEGER NOT NULL);"; "Path TEXT NOT NULL, width INTEGER NOT NULL, height INTEGER NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE IF NOT EXISTS ImageData ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + command.CommandText = "CREATE TABLE IF NOT EXISTS ImageData ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
"ImageID INTEGER NOT NULL, Data BLOB NOT NULL);"; "ImageID INTEGER NOT NULL, Data BLOB NOT NULL);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
} }
} }
+9 -24
View File
@@ -6,7 +6,7 @@ using System.Xml;
namespace Vocaluxe.Menu namespace Vocaluxe.Menu
{ {
enum EEqualizerStyle enum EEqualizerStyle
{ {
Collums Collums
} }
@@ -27,7 +27,7 @@ namespace Vocaluxe.Menu
public class CEqualizer : IMenuElement public class CEqualizer : IMenuElement
{ {
private int _PartyModeID; private readonly int _PartyModeID;
private SThemeEqualizer _Theme; private SThemeEqualizer _Theme;
private bool _ThemeLoaded; private bool _ThemeLoaded;
@@ -87,14 +87,12 @@ namespace Vocaluxe.Menu
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Space", ref Space); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Space", ref Space);
_ThemeLoaded &= xmlReader.TryGetEnumValue<EEqualizerStyle>(item + "/Style", ref _Theme.Style); _ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Theme.Style);
_ThemeLoaded &= xmlReader.TryGetEnumValue<EOffOn>(item + "/DrawNegative", ref _Theme.DrawNegative); _ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/DrawNegative", ref _Theme.DrawNegative);
if (xmlReader.GetValue(item + "/Color", ref _Theme.ColorName, String.Empty)) if (xmlReader.GetValue(item + "/Color", ref _Theme.ColorName, String.Empty))
{
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, SkinIndex, out Color); _ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, SkinIndex, out Color);
}
else else
{ {
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
@@ -104,9 +102,7 @@ namespace Vocaluxe.Menu
} }
if (xmlReader.GetValue(item + "/MaxColor", ref _Theme.MaxColorName, String.Empty)) if (xmlReader.GetValue(item + "/MaxColor", ref _Theme.MaxColorName, String.Empty))
{
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, SkinIndex, out Color); _ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, SkinIndex, out Color);
}
else else
{ {
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxR", ref MaxColor.R); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxR", ref MaxColor.R);
@@ -130,9 +126,7 @@ namespace Vocaluxe.Menu
_Theme.Name = ElementName; _Theme.Name = ElementName;
_Bars = new float[_Theme.NumBars]; _Bars = new float[_Theme.NumBars];
for (int i = 0; i < _Bars.Length; i++) for (int i = 0; i < _Bars.Length; i++)
{
_Bars[i] = 0f; _Bars[i] = 0f;
}
LoadTextures(); LoadTextures();
} }
return _ThemeLoaded; return _ThemeLoaded;
@@ -166,9 +160,7 @@ namespace Vocaluxe.Menu
writer.WriteComment("<Color>: Equalizer color from ColorScheme (high priority)"); writer.WriteComment("<Color>: Equalizer color from ColorScheme (high priority)");
writer.WriteComment("or <R>, <G>, <B>, <A> (lower priority)"); writer.WriteComment("or <R>, <G>, <B>, <A> (lower priority)");
if (_Theme.ColorName.Length > 0) if (_Theme.ColorName.Length > 0)
{
writer.WriteElementString("Color", _Theme.ColorName); writer.WriteElementString("Color", _Theme.ColorName);
}
else else
{ {
writer.WriteElementString("R", Color.R.ToString("#0.00")); writer.WriteElementString("R", Color.R.ToString("#0.00"));
@@ -179,9 +171,7 @@ namespace Vocaluxe.Menu
writer.WriteComment("<MaxColor>: Equalizer color for maximal volume from ColorScheme (high priority)"); writer.WriteComment("<MaxColor>: Equalizer color for maximal volume from ColorScheme (high priority)");
writer.WriteComment("or <MaxR>, <MaxG>, <MaxB>, <MaxA> (lower priority)"); writer.WriteComment("or <MaxR>, <MaxG>, <MaxB>, <MaxA> (lower priority)");
if (_Theme.ColorName.Length > 0) if (_Theme.ColorName.Length > 0)
{
writer.WriteElementString("MaxColor", _Theme.ColorName); writer.WriteElementString("MaxColor", _Theme.ColorName);
}
else else
{ {
writer.WriteElementString("MaxR", Color.R.ToString("#0.00")); writer.WriteElementString("MaxR", Color.R.ToString("#0.00"));
@@ -213,7 +203,8 @@ namespace Vocaluxe.Menu
return; return;
for (int i = 0; i < _Bars.Length; i++) for (int i = 0; i < _Bars.Length; i++)
{ {
if (weights.Length > i){ if (weights.Length > i)
{
_Bars[i] = 1f - weights[i]; _Bars[i] = 1f - weights[i];
if (_Theme.DrawNegative == EOffOn.TR_CONFIG_OFF && weights[i] < 0) if (_Theme.DrawNegative == EOffOn.TR_CONFIG_OFF && weights[i] < 0)
_Bars[i] = (1f + weights[i]); _Bars[i] = (1f + weights[i]);
@@ -229,9 +220,7 @@ namespace Vocaluxe.Menu
return; return;
for (int i = 0; i < _Bars.Length; i++) for (int i = 0; i < _Bars.Length; i++)
{
_Bars[i] = 0f; _Bars[i] = 0f;
}
} }
public void Draw() public void Draw()
@@ -239,7 +228,7 @@ namespace Vocaluxe.Menu
if (_Bars == null) if (_Bars == null)
return; return;
float dx = (Rect.W ) / _Bars.Length; float dx = (Rect.W) / _Bars.Length;
int max = _Bars.Length - 1; int max = _Bars.Length - 1;
float maxB = _Bars[max]; float maxB = _Bars[max];
for (int i = 0; i < _Bars.Length - 1; i++) for (int i = 0; i < _Bars.Length - 1; i++)
@@ -256,9 +245,7 @@ namespace Vocaluxe.Menu
SRectF bar = new SRectF(Rect.X + dx * i, Rect.Y + Rect.H - _Bars[i] * Rect.H, dx - Space, _Bars[i] * Rect.H, Rect.Z); SRectF bar = new SRectF(Rect.X + dx * i, Rect.Y + Rect.H - _Bars[i] * Rect.H, dx - Space, _Bars[i] * Rect.H, Rect.Z);
SColorF color = Color; SColorF color = Color;
if (i == max) if (i == max)
{
color = MaxColor; color = MaxColor;
}
CBase.Drawing.DrawColor(color, bar); CBase.Drawing.DrawColor(color, bar);
@@ -267,9 +254,7 @@ namespace Vocaluxe.Menu
} }
} }
public void UnloadTextures() public void UnloadTextures() {}
{
}
public void LoadTextures() public void LoadTextures()
{ {
@@ -305,4 +290,4 @@ namespace Vocaluxe.Menu
} }
#endregion ThemeEdit #endregion ThemeEdit
} }
} }
+33 -62
View File
@@ -36,21 +36,21 @@ namespace Vocaluxe.Menu
public class CText : IMenuElement public class CText : IMenuElement
{ {
private SThemeText _Theme; private SThemeText _Theme;
private bool _ThemeLoaded=false; private bool _ThemeLoaded;
private int _PartyModeID=-1; private readonly int _PartyModeID = -1;
private int _TranslationID=-1; private int _TranslationID = -1;
public string GetThemeName() public string GetThemeName()
{ {
return _Theme.Name; return _Theme.Name;
} }
private bool _ButtonText=false; private bool _ButtonText;
private bool _PositionNeedsUpdate = true; private bool _PositionNeedsUpdate = true;
private STextPosition _DrawPosition = new STextPosition(0); private STextPosition _DrawPosition = new STextPosition(0);
private float _X = 0f; private float _X;
public float X //left public float X //left
{ {
get { return _X; } get { return _X; }
@@ -64,7 +64,7 @@ namespace Vocaluxe.Menu
} }
} }
private float _Y = 0f; private float _Y;
public float Y //higher public float Y //higher
{ {
get { return _Y; } get { return _Y; }
@@ -78,14 +78,14 @@ namespace Vocaluxe.Menu
} }
} }
private float _Z = 0f; private float _Z;
public float Z public float Z
{ {
get { return _Z; } get { return _Z; }
set { _Z = value; } set { _Z = value; }
} }
private float _Height = 0f; private float _Height;
public float Height public float Height
{ {
get { return _Height; } get { return _Height; }
@@ -99,7 +99,7 @@ namespace Vocaluxe.Menu
} }
} }
private float _MaxWidth = 0f; private float _MaxWidth;
public float MaxWidth public float MaxWidth
{ {
get { return _MaxWidth; } get { return _MaxWidth; }
@@ -118,7 +118,7 @@ namespace Vocaluxe.Menu
} }
} }
private SRectF _Bounds = new SRectF(); private SRectF _Bounds;
public SRectF Bounds public SRectF Bounds
{ {
get { return _Bounds; } get { return _Bounds; }
@@ -187,11 +187,11 @@ namespace Vocaluxe.Menu
} }
} }
} }
public SColorF Color; //normal Color
public SColorF SColor; //selected Color for Buttons
public bool Reflection=false; public SColorF Color; //normal Color
public SColorF SColor; //selected Color for Buttons
public bool Reflection = false;
public float ReflectionSpace; public float ReflectionSpace;
public float ReflectionHeight; public float ReflectionHeight;
@@ -206,7 +206,7 @@ namespace Vocaluxe.Menu
{ {
_Theme.Text = value; _Theme.Text = value;
_Text = translation; _Text = translation;
_PositionNeedsUpdate = true; _PositionNeedsUpdate = true;
} }
} }
} }
@@ -230,9 +230,9 @@ namespace Vocaluxe.Menu
} }
} }
public bool Selected=false; public bool Selected = false;
public bool Visible = true; public bool Visible = true;
private bool _EditMode = false; private bool _EditMode;
public bool EditMode public bool EditMode
{ {
get { return _EditMode; } get { return _EditMode; }
@@ -286,7 +286,8 @@ namespace Vocaluxe.Menu
_EditMode = text._EditMode; _EditMode = text._EditMode;
} }
public CText(float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text, float rspace, float rheight) public CText(float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text, float rspace,
float rheight)
{ {
_Theme = new SThemeText(); _Theme = new SThemeText();
_ThemeLoaded = false; _ThemeLoaded = false;
@@ -306,19 +307,15 @@ namespace Vocaluxe.Menu
Color = new SColorF(r, g, b, a); Color = new SColorF(r, g, b, a);
SColor = new SColorF(r, g, b, a); SColor = new SColorF(r, g, b, a);
Text = text; Text = text;
Selected = false; Selected = false;
if (MaxWidth > 0) if (MaxWidth > 0)
{
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f);
}
else else
{
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f);
}
Reflection = true; Reflection = true;
ReflectionSpace = rspace; ReflectionSpace = rspace;
@@ -351,13 +348,9 @@ namespace Vocaluxe.Menu
Selected = false; Selected = false;
if (MaxWidth > 0) if (MaxWidth > 0)
{
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f);
}
else else
{
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f);
}
Reflection = false; Reflection = false;
} }
@@ -382,19 +375,15 @@ namespace Vocaluxe.Menu
Color = col; Color = col;
SColor = new SColorF(col); SColor = new SColorF(col);
Text = text; Text = text;
Selected = false; Selected = false;
if (MaxWidth > 0) if (MaxWidth > 0)
{
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f);
}
else else
{
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f);
}
Reflection = true; Reflection = true;
ReflectionSpace = rspace; ReflectionSpace = rspace;
@@ -427,13 +416,9 @@ namespace Vocaluxe.Menu
Selected = false; Selected = false;
if (MaxWidth > 0) if (MaxWidth > 0)
{
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f);
}
else else
{
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f);
}
Reflection = false; Reflection = false;
} }
@@ -458,9 +443,7 @@ namespace Vocaluxe.Menu
xmlReader.TryGetFloatValue(item + "/MaxW", ref _MaxWidth); xmlReader.TryGetFloatValue(item + "/MaxW", ref _MaxWidth);
if (xmlReader.GetValue(item + "/Color", ref _Theme.ColorName, String.Empty)) if (xmlReader.GetValue(item + "/Color", ref _Theme.ColorName, String.Empty))
{
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, SkinIndex, out Color); _ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, SkinIndex, out Color);
}
else else
{ {
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
@@ -470,9 +453,7 @@ namespace Vocaluxe.Menu
} }
if (xmlReader.GetValue(item + "/SColor", ref _Theme.SColorName, String.Empty)) if (xmlReader.GetValue(item + "/SColor", ref _Theme.SColorName, String.Empty))
{
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.SColorName, SkinIndex, out SColor); _ThemeLoaded &= CBase.Theme.GetColor(_Theme.SColorName, SkinIndex, out SColor);
}
else else
{ {
if (xmlReader.TryGetFloatValue(item + "/SR", ref SColor.R)) if (xmlReader.TryGetFloatValue(item + "/SR", ref SColor.R))
@@ -483,9 +464,9 @@ namespace Vocaluxe.Menu
} }
} }
_ThemeLoaded &= xmlReader.TryGetEnumValue<EAlignment>(item + "/Align", ref _Align); _ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Align", ref _Align);
xmlReader.TryGetEnumValue<EHAlignment>(item + "/HAlign", ref _HAlign); xmlReader.TryGetEnumValue(item + "/HAlign", ref _HAlign);
_ThemeLoaded &= xmlReader.TryGetEnumValue<EStyle>(item + "/Style", ref _Style); _ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Style);
_ThemeLoaded &= xmlReader.GetValue(item + "/Font", ref _Font, "Normal"); _ThemeLoaded &= xmlReader.GetValue(item + "/Font", ref _Font, "Normal");
_ThemeLoaded &= xmlReader.GetValue(item + "/Text", ref _Theme.Text, String.Empty); _ThemeLoaded &= xmlReader.GetValue(item + "/Text", ref _Theme.Text, String.Empty);
@@ -511,7 +492,7 @@ namespace Vocaluxe.Menu
if (MaxWidth > 0) if (MaxWidth > 0)
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), MaxWidth, 3f * CBase.Settings.GetRenderH(), 0f);
else else
Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f); Bounds = new SRectF(-CBase.Settings.GetRenderW(), -CBase.Settings.GetRenderH(), 3f * CBase.Settings.GetRenderW(), 3f * CBase.Settings.GetRenderH(), 0f);
} }
return _ThemeLoaded; return _ThemeLoaded;
} }
@@ -542,9 +523,7 @@ namespace Vocaluxe.Menu
writer.WriteComment("<Color>: Text color from ColorScheme (high priority)"); writer.WriteComment("<Color>: Text color from ColorScheme (high priority)");
writer.WriteComment("or <R>, <G>, <B>, <A> (lower priority)"); writer.WriteComment("or <R>, <G>, <B>, <A> (lower priority)");
if (_Theme.ColorName.Length > 0) if (_Theme.ColorName.Length > 0)
{
writer.WriteElementString("Color", _Theme.ColorName); writer.WriteElementString("Color", _Theme.ColorName);
}
else else
{ {
writer.WriteElementString("R", Color.R.ToString("#0.00")); writer.WriteElementString("R", Color.R.ToString("#0.00"));
@@ -556,9 +535,7 @@ namespace Vocaluxe.Menu
writer.WriteComment("<SColor>: Selected Text color from ColorScheme (high priority)"); writer.WriteComment("<SColor>: Selected Text color from ColorScheme (high priority)");
writer.WriteComment("or <SR>, <SG>, <SB>, <SA> (lower priority)"); writer.WriteComment("or <SR>, <SG>, <SB>, <SA> (lower priority)");
if (_Theme.SColorName.Length > 0) if (_Theme.SColorName.Length > 0)
{
writer.WriteElementString("SColor", _Theme.SColorName); writer.WriteElementString("SColor", _Theme.SColorName);
}
else else
{ {
writer.WriteElementString("SR", SColor.R.ToString("#0.00")); writer.WriteElementString("SR", SColor.R.ToString("#0.00"));
@@ -663,7 +640,7 @@ namespace Vocaluxe.Menu
public void Draw(float begin, float end) public void Draw(float begin, float end)
{ {
RectangleF bounds = CBase.Fonts.GetTextBounds(this, this.Height); RectangleF bounds = CBase.Fonts.GetTextBounds(this, Height);
float x = X; float x = X;
switch (Align) switch (Align)
@@ -693,9 +670,7 @@ namespace Vocaluxe.Menu
} }
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme)) if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
{
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(x, Y, bounds.Width, bounds.Height, Z)); CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(x, Y, bounds.Width, bounds.Height, Z));
}
} }
public void DrawRelative(float x, float y) public void DrawRelative(float x, float y)
@@ -721,7 +696,7 @@ namespace Vocaluxe.Menu
CBase.Fonts.SetFont(Font); CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style); CBase.Fonts.SetStyle(Style);
RectangleF bounds = CBase.Fonts.GetTextBounds(this, this.Height); RectangleF bounds = CBase.Fonts.GetTextBounds(this, Height);
if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f) if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f)
{ {
@@ -753,7 +728,7 @@ namespace Vocaluxe.Menu
x = x - bounds.Width; x = x - bounds.Width;
break; break;
} }
SColorF CurrentColor = new SColorF(Color); SColorF CurrentColor = new SColorF(Color);
if (Selected) if (Selected)
@@ -763,7 +738,7 @@ namespace Vocaluxe.Menu
CBase.Fonts.SetFont(Font); CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style); CBase.Fonts.SetStyle(Style);
CBase.Fonts.DrawText(_Text, h, x, y, Z, color); CBase.Fonts.DrawText(_Text, h, x, y, Z, color);
if (reflection) if (reflection)
@@ -775,14 +750,10 @@ namespace Vocaluxe.Menu
} }
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme)) if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
{
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f * CBase.Graphics.GetGlobalAlpha()), new SRectF(x, y, bounds.Width, bounds.Height, Z)); CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f * CBase.Graphics.GetGlobalAlpha()), new SRectF(x, y, bounds.Width, bounds.Height, Z));
}
} }
public void UnloadTextures() public void UnloadTextures() {}
{
}
public void LoadTextures() public void LoadTextures()
{ {
@@ -824,13 +795,13 @@ namespace Vocaluxe.Menu
float h = Height; float h = Height;
float y = Y; float y = Y;
RectangleF bounds = CBase.Fonts.GetTextBounds(this, this.Height); RectangleF bounds = CBase.Fonts.GetTextBounds(this, Height);
if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f) if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f)
{ {
float factor = Bounds.W / bounds.Width; float factor = Bounds.W / bounds.Width;
float step = h * (1 - factor); float step = h * (1 - factor);
h *= factor ; h *= factor;
switch (HAlign) switch (HAlign)
{ {
case EHAlignment.Top: case EHAlignment.Top:
@@ -867,4 +838,4 @@ namespace Vocaluxe.Menu
_PositionNeedsUpdate = false; _PositionNeedsUpdate = false;
} }
} }
} }