moved some files
This commit is contained in:
1 parent
036cc3b4bd
commit
685bc019fd
9 files changed
No files matched your search
@@ -1,69 +0,0 @@
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
namespace VocaluxeLib.Menu
|
||||
{
|
||||
public static class CBase
|
||||
{
|
||||
public static IConfig Config;
|
||||
public static ISettings Settings;
|
||||
public static ITheme Theme;
|
||||
public static ILog Log;
|
||||
public static IBackgroundMusic BackgroundMusic;
|
||||
public static IDrawing Drawing;
|
||||
public static IGraphics Graphics;
|
||||
public static IFonts Fonts;
|
||||
public static ILanguage Language;
|
||||
public static IGame Game;
|
||||
public static IProfiles Profiles;
|
||||
public static IRecording Record;
|
||||
public static ISongs Songs;
|
||||
public static IVideo Video;
|
||||
public static ISound Sound;
|
||||
public static ICover Cover;
|
||||
public static IDataBase DataBase;
|
||||
public static IControllers Controller;
|
||||
public static IPlaylist Playlist;
|
||||
|
||||
public static void Assign(IConfig config, ISettings settings, ITheme theme, ILog log, IBackgroundMusic backgroundMusic,
|
||||
IDrawing draw, IGraphics graphics, IFonts fonts, ILanguage language, IGame game, IProfiles profiles, IRecording record,
|
||||
ISongs songs, IVideo video, ISound sound, ICover cover, IDataBase dataBase, IControllers controller, IPlaylist playlist)
|
||||
{
|
||||
Config = config;
|
||||
Settings = settings;
|
||||
Theme = theme;
|
||||
Log = log;
|
||||
BackgroundMusic = backgroundMusic;
|
||||
Drawing = draw;
|
||||
Graphics = graphics;
|
||||
Fonts = fonts;
|
||||
Language = language;
|
||||
Game = game;
|
||||
Profiles = profiles;
|
||||
Record = record;
|
||||
Songs = songs;
|
||||
Video = video;
|
||||
Sound = sound;
|
||||
Cover = cover;
|
||||
DataBase = dataBase;
|
||||
Controller = controller;
|
||||
Playlist = playlist;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,234 +0,0 @@
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace VocaluxeLib.Menu
|
||||
{
|
||||
public static class CHelper
|
||||
{
|
||||
public static int CombinationCount(int n, int k)
|
||||
{
|
||||
if (k > n)
|
||||
return 0;
|
||||
|
||||
if (k == 0 || k == n)
|
||||
return 1;
|
||||
|
||||
if (k < 0 || n <= 0)
|
||||
return 0; //is not defined
|
||||
|
||||
if (k * 2 > n)
|
||||
k = n - k;
|
||||
|
||||
long result = n;
|
||||
|
||||
for (long i = 1; i <= k - 1; i++)
|
||||
result = result * (n - i) / (i + 1);
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Concat strings into one string with ", " as separator.
|
||||
/// </summary>
|
||||
public static string ListStrings(string[] str)
|
||||
{
|
||||
string result = string.Empty;
|
||||
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
result += str[i];
|
||||
if (i < str.Length - 1)
|
||||
result += ", ";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int TryReadInt(StreamReader sr)
|
||||
{
|
||||
string value = String.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
int tmp = sr.Peek();
|
||||
//Check for ' ', ?, ?, \n, \r
|
||||
while (tmp != 32 && tmp != 19 && tmp != 16 && tmp != 13 && tmp != 10)
|
||||
{
|
||||
char chr = (char)sr.Read();
|
||||
value += chr.ToString();
|
||||
tmp = sr.Peek();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int result;
|
||||
return int.TryParse(value, out result) ? result : 0;
|
||||
}
|
||||
|
||||
public static void SetRect(RectangleF bounds, out RectangleF rect, float rectAspect, EAspect aspect)
|
||||
{
|
||||
float rW = bounds.Right - bounds.Left;
|
||||
float rH = bounds.Bottom - bounds.Top;
|
||||
float rA = rW / rH;
|
||||
|
||||
float scaledWidth;
|
||||
float scaledHeight;
|
||||
|
||||
switch (aspect)
|
||||
{
|
||||
case EAspect.Crop:
|
||||
if (rA >= rectAspect)
|
||||
{
|
||||
scaledWidth = rW;
|
||||
scaledHeight = rH * rA / rectAspect;
|
||||
}
|
||||
else
|
||||
{
|
||||
scaledHeight = rH;
|
||||
scaledWidth = rW * rectAspect / rA;
|
||||
}
|
||||
break;
|
||||
case EAspect.LetterBox:
|
||||
if (rectAspect >= 1)
|
||||
{
|
||||
scaledWidth = rW;
|
||||
scaledHeight = rH * rA / rectAspect;
|
||||
}
|
||||
else
|
||||
{
|
||||
scaledHeight = rH;
|
||||
scaledWidth = rW * rectAspect / rA;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
scaledWidth = rW;
|
||||
scaledHeight = rH;
|
||||
break;
|
||||
}
|
||||
|
||||
float left = (rW - scaledWidth) / 2 + bounds.Left;
|
||||
float rigth = left + scaledWidth;
|
||||
|
||||
float upper = (rH - scaledHeight) / 2 + bounds.Top;
|
||||
float lower = upper + scaledHeight;
|
||||
|
||||
rect = new RectangleF(left, upper, rigth - left, lower - upper);
|
||||
}
|
||||
|
||||
public static List<string> ListFiles(string path, string cast, bool recursive = false, bool fullpath = false)
|
||||
{
|
||||
List<string> files = new List<string>();
|
||||
DirectoryInfo dir = new DirectoryInfo(path);
|
||||
|
||||
try
|
||||
{
|
||||
foreach (FileInfo file in dir.GetFiles(cast))
|
||||
files.Add(!fullpath ? file.Name : file.FullName);
|
||||
|
||||
if (recursive)
|
||||
{
|
||||
foreach (DirectoryInfo di in dir.GetDirectories())
|
||||
files.AddRange(ListFiles(di.FullName, cast, true, fullpath));
|
||||
}
|
||||
}
|
||||
catch (Exception) {}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
public static bool TryParse<T>(string value, out T result)
|
||||
where T : struct
|
||||
{
|
||||
return TryParse(value, out result, false);
|
||||
}
|
||||
|
||||
public static bool TryParse<T>(string value, out T result, bool ignoreCase)
|
||||
where T : struct
|
||||
{
|
||||
result = default(T);
|
||||
try
|
||||
{
|
||||
result = (T)Enum.Parse(typeof(T), value, ignoreCase);
|
||||
return true;
|
||||
}
|
||||
catch {}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool TryParse(string value, out float result)
|
||||
{
|
||||
value = value.Replace(',', '.');
|
||||
return float.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, NumberFormatInfo.InvariantInfo, out result);
|
||||
}
|
||||
|
||||
public static bool IsInBounds(SRectF bounds, SMouseEvent mouseEvent)
|
||||
{
|
||||
return IsInBounds(bounds, mouseEvent.X, mouseEvent.Y);
|
||||
}
|
||||
|
||||
public static bool IsInBounds(SRectF bounds, int x, int y)
|
||||
{
|
||||
return (bounds.X <= x) && (bounds.X + bounds.W >= x) && (bounds.Y <= y) && (bounds.Y + bounds.H >= y);
|
||||
}
|
||||
}
|
||||
|
||||
static class CEncoding
|
||||
{
|
||||
public static Encoding GetEncoding(string encodingName)
|
||||
{
|
||||
switch (encodingName)
|
||||
{
|
||||
case "AUTO":
|
||||
return Encoding.Default;
|
||||
case "CP1250":
|
||||
return Encoding.GetEncoding(1250);
|
||||
case "CP1252":
|
||||
return Encoding.GetEncoding(1252);
|
||||
case "LOCALE":
|
||||
return Encoding.Default;
|
||||
case "UTF8":
|
||||
return Encoding.UTF8;
|
||||
default:
|
||||
return Encoding.UTF8;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetEncodingName(Encoding enc)
|
||||
{
|
||||
string result = "UTF8";
|
||||
|
||||
if (enc.CodePage == 1250)
|
||||
result = "CP1250";
|
||||
|
||||
if (enc.CodePage == 1252)
|
||||
result = "CP1252";
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace VocaluxeLib.Menu
|
||||
{
|
||||
public class CPoints
|
||||
{
|
||||
private readonly SPlayer[,] _Rounds;
|
||||
|
||||
public CPoints(int numRounds, SPlayer[] players)
|
||||
{
|
||||
_Rounds = new SPlayer[numRounds,players.Length];
|
||||
|
||||
for (int round = 0; round < numRounds; round++)
|
||||
{
|
||||
for (int player = 0; player < players.Length; player++)
|
||||
{
|
||||
_Rounds[round, player].ProfileID = players[player].ProfileID;
|
||||
_Rounds[round, player].Points = 0f;
|
||||
_Rounds[round, player].PointsGoldenNotes = 0f;
|
||||
_Rounds[round, player].PointsLineBonus = 0f;
|
||||
_Rounds[round, player].Medley = false;
|
||||
_Rounds[round, player].Duet = false;
|
||||
_Rounds[round, player].ShortSong = false;
|
||||
_Rounds[round, player].SongFinished = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPoints(int round, int songID, SPlayer[] players, bool medley, bool duet, bool shortSong)
|
||||
{
|
||||
long dateTicks = DateTime.Now.Ticks;
|
||||
for (int player = 0; player < players.Length; player++)
|
||||
{
|
||||
_Rounds[round, player].SongID = songID;
|
||||
_Rounds[round, player].LineNr = players[player].LineNr;
|
||||
_Rounds[round, player].Points = players[player].Points;
|
||||
_Rounds[round, player].PointsGoldenNotes = players[player].PointsGoldenNotes;
|
||||
_Rounds[round, player].PointsLineBonus = players[player].PointsLineBonus;
|
||||
_Rounds[round, player].Medley = medley;
|
||||
_Rounds[round, player].Duet = duet;
|
||||
_Rounds[round, player].ShortSong = shortSong;
|
||||
_Rounds[round, player].DateTicks = dateTicks;
|
||||
_Rounds[round, player].SongFinished = players[player].SongFinished;
|
||||
}
|
||||
}
|
||||
|
||||
public int NumRounds
|
||||
{
|
||||
get { return _Rounds.GetLength(0); }
|
||||
}
|
||||
|
||||
public int NumPlayer
|
||||
{
|
||||
get { return _Rounds.GetLength(1); }
|
||||
}
|
||||
|
||||
public SPlayer[] GetPlayer(int round, int numPlayer)
|
||||
{
|
||||
if (NumPlayer == 0)
|
||||
return new SPlayer[1];
|
||||
if (round >= NumRounds)
|
||||
return new SPlayer[1];
|
||||
|
||||
SPlayer[] players = new SPlayer[numPlayer];
|
||||
|
||||
for (int p = 0; p < players.Length; p++)
|
||||
{
|
||||
players[p].Points = _Rounds[round, p].Points;
|
||||
players[p].PointsGoldenNotes = _Rounds[round, p].PointsGoldenNotes;
|
||||
players[p].PointsLineBonus = _Rounds[round, p].PointsLineBonus;
|
||||
players[p].SongID = _Rounds[round, p].SongID;
|
||||
players[p].LineNr = _Rounds[round, p].LineNr;
|
||||
players[p].Medley = _Rounds[round, p].Medley;
|
||||
players[p].Duet = _Rounds[round, p].Duet;
|
||||
players[p].ShortSong = _Rounds[round, p].ShortSong;
|
||||
players[p].DateTicks = _Rounds[round, p].DateTicks;
|
||||
players[p].SongFinished = _Rounds[round, p].SongFinished;
|
||||
players[p].ProfileID = _Rounds[round, p].ProfileID;
|
||||
}
|
||||
return players;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.XPath;
|
||||
|
||||
namespace VocaluxeLib.Menu
|
||||
{
|
||||
public class CXMLReader
|
||||
{
|
||||
private readonly XPathNavigator _Navigator;
|
||||
private readonly String _FileName;
|
||||
|
||||
public string FileName
|
||||
{
|
||||
get { return _FileName; }
|
||||
}
|
||||
|
||||
//Private method. Use OpenFile factory method to get an instance
|
||||
private CXMLReader(string uri)
|
||||
{
|
||||
_FileName = uri;
|
||||
XPathDocument xmlDoc = new XPathDocument(uri);
|
||||
_Navigator = xmlDoc.CreateNavigator();
|
||||
}
|
||||
|
||||
public XPathNavigator Navigator
|
||||
{
|
||||
get { return _Navigator; }
|
||||
}
|
||||
|
||||
public static CXMLReader OpenFile(string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new CXMLReader(fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Can't open XML file: " + fileName + ": " + e.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetEnumValue<T>(string cast, ref T value)
|
||||
where T : struct
|
||||
{
|
||||
string val;
|
||||
if (GetValue(cast, out val, Enum.GetName(typeof(T), value)))
|
||||
{
|
||||
CHelper.TryParse(val, out value, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetIntValue(string cast, ref int value)
|
||||
{
|
||||
string val;
|
||||
if (GetValue(cast, out val, value.ToString()))
|
||||
return int.TryParse(val, out value);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetIntValueRange(string cast, ref int value, int min = 0, int max = 100)
|
||||
{
|
||||
bool result = TryGetIntValue(cast, ref value);
|
||||
if (result)
|
||||
{
|
||||
if (value < min)
|
||||
value = min;
|
||||
else if (value > max)
|
||||
value = max;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool TryGetFloatValue(string cast, ref float value)
|
||||
{
|
||||
string val;
|
||||
return GetValue(cast, out val, value.ToString()) && CHelper.TryParse(val, out value);
|
||||
}
|
||||
|
||||
public bool GetValue(string cast, out string value, string defaultValue)
|
||||
{
|
||||
int resultCt = 0;
|
||||
string val = string.Empty;
|
||||
|
||||
_Navigator.MoveToFirstChild();
|
||||
XPathNodeIterator iterator = _Navigator.Select(cast);
|
||||
|
||||
while (iterator.MoveNext())
|
||||
{
|
||||
val = iterator.Current.Value;
|
||||
resultCt++;
|
||||
}
|
||||
|
||||
if (resultCt != 1)
|
||||
{
|
||||
value = defaultValue;
|
||||
return false;
|
||||
}
|
||||
value = val;
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<string> GetValues(string cast)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
|
||||
_Navigator.MoveToRoot();
|
||||
_Navigator.MoveToFirstChild();
|
||||
_Navigator.MoveToFirstChild();
|
||||
|
||||
while (_Navigator.Name != cast)
|
||||
_Navigator.MoveToNext();
|
||||
|
||||
_Navigator.MoveToFirstChild();
|
||||
|
||||
values.Add(_Navigator.LocalName);
|
||||
while (_Navigator.MoveToNext())
|
||||
values.Add(_Navigator.LocalName);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAttributes(string cast, string attribute)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
|
||||
_Navigator.MoveToRoot();
|
||||
_Navigator.MoveToFirstChild();
|
||||
|
||||
while (_Navigator.Name != cast)
|
||||
_Navigator.MoveToNext();
|
||||
|
||||
_Navigator.MoveToFirstChild();
|
||||
|
||||
values.Add(_Navigator.LocalName);
|
||||
while (_Navigator.MoveToNext())
|
||||
values.Add(_Navigator.GetAttribute(attribute, ""));
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
public bool GetInnerValues(string cast, ref List<string> values)
|
||||
{
|
||||
_Navigator.MoveToRoot();
|
||||
_Navigator.MoveToFirstChild();
|
||||
_Navigator.MoveToFirstChild();
|
||||
|
||||
while (_Navigator.Name != cast)
|
||||
_Navigator.MoveToNext();
|
||||
|
||||
_Navigator.MoveToFirstChild();
|
||||
|
||||
values.Add(_Navigator.Value);
|
||||
while (_Navigator.MoveToNext())
|
||||
values.Add(_Navigator.Value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ItemExists(string cast)
|
||||
{
|
||||
int results = 0;
|
||||
|
||||
_Navigator.MoveToFirstChild();
|
||||
XPathNodeIterator iterator = _Navigator.Select(cast);
|
||||
|
||||
while (iterator.MoveNext())
|
||||
results++;
|
||||
|
||||
if (results == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,352 +0,0 @@
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace VocaluxeLib.Menu
|
||||
{
|
||||
|
||||
#region Inputs
|
||||
[Flags]
|
||||
public enum EModifier
|
||||
{
|
||||
None = 0,
|
||||
Shift = 1,
|
||||
Alt = 2,
|
||||
Ctrl = 4
|
||||
}
|
||||
|
||||
public enum ESender
|
||||
{
|
||||
Mouse,
|
||||
Keyboard,
|
||||
WiiMote
|
||||
}
|
||||
#endregion Inputs
|
||||
|
||||
#region Fonts
|
||||
public enum EAspect
|
||||
{
|
||||
Crop,
|
||||
LetterBox,
|
||||
Stretch
|
||||
}
|
||||
|
||||
public enum EAlignment
|
||||
{
|
||||
Left,
|
||||
Center,
|
||||
Right
|
||||
}
|
||||
|
||||
public enum EHAlignment
|
||||
{
|
||||
Top,
|
||||
Center,
|
||||
Bottom
|
||||
}
|
||||
|
||||
public enum EStyle
|
||||
{
|
||||
Normal,
|
||||
Italic,
|
||||
Bold,
|
||||
BoldItalic
|
||||
}
|
||||
#endregion Fonts
|
||||
|
||||
#region Config
|
||||
public enum ERenderer
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
#if WIN
|
||||
TR_CONFIG_DIRECT3D,
|
||||
#endif
|
||||
TR_CONFIG_OPENGL,
|
||||
TR_CONFIG_SOFTWARE
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EAntiAliasingModes
|
||||
{
|
||||
X0 = 0,
|
||||
X2 = 2,
|
||||
X4 = 4,
|
||||
X8 = 8,
|
||||
X16 = 16,
|
||||
X32 = 32
|
||||
}
|
||||
|
||||
public enum ETextureQuality
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_CONFIG_TEXTURE_LOWEST,
|
||||
TR_CONFIG_TEXTURE_LOW,
|
||||
TR_CONFIG_TEXTURE_MEDIUM,
|
||||
TR_CONFIG_TEXTURE_HIGH,
|
||||
TR_CONFIG_TEXTURE_HIGHEST
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EOffOn
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_CONFIG_OFF,
|
||||
TR_CONFIG_ON
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EDebugLevel
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
// don't change the order!
|
||||
TR_CONFIG_OFF, //no debug infos
|
||||
// ReSharper disable UnusedMember.Global
|
||||
TR_CONFIG_ONLY_FPS,
|
||||
// ReSharper restore UnusedMember.Global
|
||||
TR_CONFIG_LEVEL1,
|
||||
TR_CONFIG_LEVEL2,
|
||||
TR_CONFIG_LEVEL3,
|
||||
TR_CONFIG_LEVEL_MAX //all debug infos
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EBufferSize
|
||||
{
|
||||
// ReSharper disable UnusedMember.Global
|
||||
B0 = 0,
|
||||
B512 = 512,
|
||||
B1024 = 1024,
|
||||
B1536 = 1536,
|
||||
B2048 = 2048,
|
||||
B2560 = 2560,
|
||||
B3072 = 3072,
|
||||
B3584 = 3584,
|
||||
B4096 = 4096
|
||||
// ReSharper restore UnusedMember.Global
|
||||
}
|
||||
|
||||
public enum EPlaybackLib
|
||||
{
|
||||
PortAudio,
|
||||
OpenAL,
|
||||
Gstreamer
|
||||
}
|
||||
|
||||
public enum EWebcamLib
|
||||
{
|
||||
OpenCV,
|
||||
AForgeNet
|
||||
}
|
||||
|
||||
public enum ERecordLib
|
||||
{
|
||||
#if WIN
|
||||
DirectSound,
|
||||
#endif
|
||||
PortAudio
|
||||
}
|
||||
|
||||
public enum EVideoDecoder
|
||||
{
|
||||
FFmpeg,
|
||||
Gstreamer
|
||||
}
|
||||
|
||||
public enum ESongMenu
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
//TR_CONFIG_LIST, //a simple list
|
||||
//TR_CONFIG_DREIDEL, //as in ultrastar deluxe
|
||||
TR_CONFIG_TILE_BOARD, //chessboard like
|
||||
//TR_CONFIG_BOOK //for playlists
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EDuetOptions
|
||||
{
|
||||
All,
|
||||
Duets,
|
||||
NoDuets
|
||||
}
|
||||
|
||||
public enum ESongSorting
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_CONFIG_NONE,
|
||||
//TR_CONFIG_RANDOM,
|
||||
TR_CONFIG_FOLDER,
|
||||
TR_CONFIG_ARTIST,
|
||||
TR_CONFIG_ARTIST_LETTER,
|
||||
TR_CONFIG_TITLE_LETTER,
|
||||
TR_CONFIG_EDITION,
|
||||
TR_CONFIG_GENRE,
|
||||
TR_CONFIG_LANGUAGE,
|
||||
TR_CONFIG_YEAR,
|
||||
TR_CONFIG_DECADE
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum ECoverLoading
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
TR_CONFIG_COVERLOADING_ONDEMAND,
|
||||
// ReSharper restore UnusedMember.Global
|
||||
TR_CONFIG_COVERLOADING_ATSTART,
|
||||
TR_CONFIG_COVERLOADING_DYNAMIC
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EGameDifficulty
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
TR_CONFIG_EASY,
|
||||
TR_CONFIG_NORMAL,
|
||||
TR_CONFIG_HARD
|
||||
// ReSharper restore UnusedMember.Global
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum ETimerMode
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_CONFIG_TIMERMODE_CURRENT,
|
||||
TR_CONFIG_TIMERMODE_REMAINING,
|
||||
TR_CONFIG_TIMERMODE_TOTAL
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum ETimerLook
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_CONFIG_TIMERLOOK_NORMAL,
|
||||
TR_CONFIG_TIMERLOOK_EXPANDED
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EBackgroundMusicSource
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_CONFIG_NO_OWN_MUSIC,
|
||||
TR_CONFIG_OWN_MUSIC,
|
||||
TR_CONFIG_ONLY_OWN_MUSIC
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EPlayerInfo
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_CONFIG_PLAYERINFO_BOTH,
|
||||
TR_CONFIG_PLAYERINFO_NAME,
|
||||
TR_CONFIG_PLAYERINFO_AVATAR,
|
||||
// ReSharper disable UnusedMember.Global
|
||||
TR_CONFIG_PLAYERINFO_OFF
|
||||
// ReSharper restore UnusedMember.Global
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum EFadePlayerInfo
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_CONFIG_FADEPLAYERINFO_ALL,
|
||||
TR_CONFIG_FADEPLAYERINFO_INFO,
|
||||
TR_CONFIG_FADEPLAYERINFO_OFF
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum ELyricsPosition
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_CONFIG_LYRICSPOSITION_BOTTOM,
|
||||
TR_CONFIG_LYRICSPOSITION_TOP,
|
||||
TR_CONFIG_LYRICSPOSITION_BOTH,
|
||||
TR_CONFIG_LYRICSPOSITION_DYNAMIC
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum ELyricStyle
|
||||
{
|
||||
Fill,
|
||||
Jump,
|
||||
Slide,
|
||||
Zoom
|
||||
}
|
||||
#endregion Config
|
||||
|
||||
public enum EGameState
|
||||
{
|
||||
Start,
|
||||
Normal,
|
||||
EditTheme
|
||||
}
|
||||
|
||||
public enum EGameMode
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
TR_GAMEMODE_NORMAL,
|
||||
TR_GAMEMODE_MEDLEY,
|
||||
TR_GAMEMODE_DUET,
|
||||
TR_GAMEMODE_SHORTSONG
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
public enum ENoteType
|
||||
{
|
||||
Normal,
|
||||
Golden,
|
||||
Freestyle
|
||||
}
|
||||
|
||||
public enum EScreens
|
||||
{
|
||||
ScreenTest = 0,
|
||||
ScreenLoad = 1,
|
||||
ScreenMain = 2,
|
||||
ScreenSong = 3,
|
||||
ScreenOptions = 4,
|
||||
ScreenSing = 5,
|
||||
ScreenProfiles = 6,
|
||||
ScreenScore = 7,
|
||||
ScreenHighscore = 8,
|
||||
|
||||
ScreenOptionsGame = 9,
|
||||
ScreenOptionsSound = 10,
|
||||
ScreenOptionsRecord = 11,
|
||||
ScreenOptionsVideo = 12,
|
||||
ScreenOptionsLyrics = 13,
|
||||
ScreenOptionsTheme = 14,
|
||||
|
||||
ScreenNames = 15,
|
||||
ScreenCredits = 16,
|
||||
ScreenParty = 17,
|
||||
ScreenPartyDummy = 18,
|
||||
|
||||
ScreenNull = -1
|
||||
}
|
||||
|
||||
public enum EPopupScreens
|
||||
{
|
||||
PopupPlayerControl = 0,
|
||||
PopupVolumeControl = 1,
|
||||
|
||||
NoPopup = -1
|
||||
}
|
||||
}
|
||||
@@ -1,722 +0,0 @@
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace VocaluxeLib.Menu.SingNotes
|
||||
{
|
||||
public class CNotes
|
||||
{
|
||||
private readonly List<CVoice> _Voices = new List<CVoice>();
|
||||
|
||||
public CVoice[] Voices
|
||||
{
|
||||
get { return _Voices.ToArray(); }
|
||||
}
|
||||
|
||||
public CNotes() {}
|
||||
|
||||
public int LinesCount
|
||||
{
|
||||
get { return _Voices.Count; }
|
||||
}
|
||||
|
||||
public CNotes(CNotes notes)
|
||||
{
|
||||
foreach (CVoice voice in notes._Voices)
|
||||
_Voices.Add(new CVoice(voice));
|
||||
}
|
||||
|
||||
public CVoice GetVoice(int index)
|
||||
{
|
||||
while (index >= _Voices.Count)
|
||||
_Voices.Add(new CVoice());
|
||||
|
||||
return _Voices[index];
|
||||
}
|
||||
|
||||
public int GetPoints(int index)
|
||||
{
|
||||
if (index >= _Voices.Count)
|
||||
return 0;
|
||||
|
||||
return _Voices[index].Points;
|
||||
}
|
||||
|
||||
public int GetNumLinesWithPoints(int index)
|
||||
{
|
||||
if (index >= _Voices.Count)
|
||||
return 0;
|
||||
|
||||
return _Voices[index].NumLinesWithPoints;
|
||||
}
|
||||
|
||||
public void AddVoice(CVoice voice)
|
||||
{
|
||||
_Voices.Add(voice);
|
||||
}
|
||||
|
||||
public bool ReplaceVoiceAt(int index, CVoice voice)
|
||||
{
|
||||
if (index >= _Voices.Count)
|
||||
return false;
|
||||
|
||||
_Voices[index] = voice;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_Voices.Clear();
|
||||
}
|
||||
|
||||
public void SetMedley(int startBeat, int endBeat)
|
||||
{
|
||||
foreach (CVoice voice in _Voices)
|
||||
voice.SetMedley(startBeat, endBeat);
|
||||
}
|
||||
}
|
||||
|
||||
public class CNote
|
||||
{
|
||||
private int _StartBeat;
|
||||
private int _Duration;
|
||||
private int _Tone;
|
||||
private ENoteType _NoteType;
|
||||
private string _Text;
|
||||
private bool _Hit; // for drawing player notes
|
||||
private bool _Perfect; // for drawing perfect note effect
|
||||
|
||||
#region Contructors
|
||||
public CNote()
|
||||
{
|
||||
StartBeat = 0;
|
||||
Duration = 1;
|
||||
Tone = 0;
|
||||
NoteType = ENoteType.Normal;
|
||||
Text = String.Empty;
|
||||
_Hit = false;
|
||||
_Perfect = false;
|
||||
}
|
||||
|
||||
public CNote(CNote note)
|
||||
{
|
||||
_StartBeat = note._StartBeat;
|
||||
_Duration = note._Duration;
|
||||
_Tone = note._Tone;
|
||||
_NoteType = note._NoteType;
|
||||
_Text = note._Text;
|
||||
_Hit = note._Hit;
|
||||
_Perfect = note._Perfect;
|
||||
}
|
||||
|
||||
public CNote(int startBeat, int duration, int tone, string text)
|
||||
: this()
|
||||
{
|
||||
StartBeat = startBeat;
|
||||
Duration = duration;
|
||||
Tone = tone;
|
||||
NoteType = ENoteType.Normal;
|
||||
Text = text;
|
||||
}
|
||||
|
||||
public CNote(int startBeat, int duration, int tone, string text, bool hit)
|
||||
: this()
|
||||
{
|
||||
StartBeat = startBeat;
|
||||
Duration = duration;
|
||||
Tone = tone;
|
||||
NoteType = ENoteType.Normal;
|
||||
Text = text;
|
||||
Hit = hit;
|
||||
}
|
||||
|
||||
public CNote(int startBeat, int duration, int tone, string text, ENoteType noteType)
|
||||
: this(startBeat, duration, tone, text)
|
||||
{
|
||||
NoteType = noteType;
|
||||
}
|
||||
|
||||
public CNote(int startBeat, int duration, int tone, string text, bool hit, ENoteType noteType)
|
||||
: this(startBeat, duration, tone, text)
|
||||
{
|
||||
NoteType = noteType;
|
||||
Hit = hit;
|
||||
}
|
||||
#endregion Constructors
|
||||
|
||||
#region Properties
|
||||
public bool Hit
|
||||
{
|
||||
get { return _Hit; }
|
||||
set { _Hit = value; }
|
||||
}
|
||||
|
||||
public bool Perfect
|
||||
{
|
||||
get { return _Perfect; }
|
||||
set { _Perfect = value; }
|
||||
}
|
||||
|
||||
public int StartBeat
|
||||
{
|
||||
get { return _StartBeat; }
|
||||
set { _StartBeat = value; }
|
||||
}
|
||||
|
||||
public int EndBeat
|
||||
{
|
||||
get { return _StartBeat + _Duration - 1; }
|
||||
}
|
||||
|
||||
public int Duration
|
||||
{
|
||||
get { return _Duration; }
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
_Duration = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Tone
|
||||
{
|
||||
get { return _Tone; }
|
||||
set
|
||||
{
|
||||
if ((value >= CBase.Settings.GetToneMin()) && (value <= CBase.Settings.GetToneMax()))
|
||||
_Tone = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ENoteType NoteType
|
||||
{
|
||||
get { return _NoteType; }
|
||||
set { _NoteType = value; }
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return _Text; }
|
||||
set { _Text = value; }
|
||||
}
|
||||
|
||||
public int Points
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_NoteType)
|
||||
{
|
||||
case ENoteType.Normal:
|
||||
return _Duration;
|
||||
case ENoteType.Golden:
|
||||
return _Duration * 2;
|
||||
case ENoteType.Freestyle:
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int PointsForBeat
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_NoteType)
|
||||
{
|
||||
case ENoteType.Normal:
|
||||
return 1;
|
||||
case ENoteType.Golden:
|
||||
return 2;
|
||||
case ENoteType.Freestyle:
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
public bool IsPerfect(CNote compareNote)
|
||||
{
|
||||
bool result = Hit;
|
||||
|
||||
if (StartBeat != compareNote.StartBeat)
|
||||
result = false;
|
||||
|
||||
if (EndBeat != compareNote.EndBeat)
|
||||
result = false;
|
||||
|
||||
if (Tone != compareNote.Tone)
|
||||
result = false;
|
||||
|
||||
Perfect = result;
|
||||
return result;
|
||||
}
|
||||
#endregion Methods
|
||||
}
|
||||
|
||||
public class CLine
|
||||
{
|
||||
private int _StartBeat = int.MinValue;
|
||||
private int _EndBeat = int.MinValue;
|
||||
private bool _PerfectLine; // for drawing perfect line effect
|
||||
private bool _VisibleInTimeLine = true;
|
||||
|
||||
private int _MinBeat = int.MaxValue;
|
||||
private int _MaxBeat = int.MinValue;
|
||||
private readonly List<CNote> _Notes = new List<CNote>();
|
||||
|
||||
#region Constructors
|
||||
public CLine() {}
|
||||
|
||||
public CLine(CLine line)
|
||||
{
|
||||
foreach (CNote note in line._Notes)
|
||||
_Notes.Add(new CNote(note));
|
||||
_StartBeat = line._StartBeat;
|
||||
_EndBeat = line._EndBeat;
|
||||
_PerfectLine = line._PerfectLine;
|
||||
_MinBeat = line._MinBeat;
|
||||
_MaxBeat = line._MaxBeat;
|
||||
_VisibleInTimeLine = line._VisibleInTimeLine;
|
||||
}
|
||||
#endregion Constructors
|
||||
|
||||
#region Properties
|
||||
public bool VisibleInTimeLine
|
||||
{
|
||||
get { return _VisibleInTimeLine; }
|
||||
set { _VisibleInTimeLine = value; }
|
||||
}
|
||||
|
||||
public int StartBeat
|
||||
{
|
||||
get { return _StartBeat; }
|
||||
set
|
||||
{
|
||||
if (value <= _MinBeat)
|
||||
_StartBeat = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int EndBeat
|
||||
{
|
||||
get { return _EndBeat; }
|
||||
set
|
||||
{
|
||||
if (value >= _MaxBeat)
|
||||
_EndBeat = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool PerfectLine
|
||||
{
|
||||
get { return _PerfectLine; }
|
||||
set { _PerfectLine = value; }
|
||||
}
|
||||
|
||||
public int FirstNoteBeat
|
||||
{
|
||||
get { return _MinBeat; }
|
||||
}
|
||||
|
||||
public int LastNoteBeat
|
||||
{
|
||||
get { return _MaxBeat; }
|
||||
}
|
||||
|
||||
public string Lyrics
|
||||
{
|
||||
get { return _Notes.Aggregate(String.Empty, (current, note) => current + note.Text); }
|
||||
}
|
||||
|
||||
public int NoteCount
|
||||
{
|
||||
get { return _Notes.Count; }
|
||||
}
|
||||
|
||||
public int Points
|
||||
{
|
||||
get { return _Notes.Sum(note => note.Points); }
|
||||
}
|
||||
|
||||
public CNote[] Notes
|
||||
{
|
||||
get { return _Notes.ToArray(); }
|
||||
}
|
||||
|
||||
public CNote FirstNote
|
||||
{
|
||||
get { return _Notes.Count > 0 ? _Notes[0] : null; }
|
||||
}
|
||||
|
||||
public CNote LastNote
|
||||
{
|
||||
get { return _Notes.Count > 0 ? _Notes[_Notes.Count - 1] : null; }
|
||||
}
|
||||
|
||||
public int BaseLine
|
||||
{
|
||||
get
|
||||
{
|
||||
int min = int.MaxValue;
|
||||
int max = int.MinValue;
|
||||
foreach (CNote note in _Notes)
|
||||
{
|
||||
if (note.Tone < min)
|
||||
min = note.Tone;
|
||||
if (note.Tone > max)
|
||||
max = note.Tone;
|
||||
}
|
||||
|
||||
return min - (max - min) / 4;
|
||||
}
|
||||
}
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
public bool IsPerfect(CLine compareLine)
|
||||
{
|
||||
if (_Notes.Count == 0)
|
||||
return false;
|
||||
|
||||
if (_Notes.Count != compareLine.NoteCount)
|
||||
return false;
|
||||
|
||||
if (compareLine.Points == 0)
|
||||
return false;
|
||||
|
||||
_PerfectLine = Points == compareLine.Points;
|
||||
return _PerfectLine;
|
||||
}
|
||||
|
||||
//Find last note with StartBeat<=Beat
|
||||
public int FindPreviousNote(int beat)
|
||||
{
|
||||
//If no notes -> No previous note
|
||||
if (_Notes.Count == 0)
|
||||
return -1;
|
||||
int start = 0;
|
||||
int end = _Notes.Count - 1;
|
||||
//Ensure that start.StartBeat<=Beat && end.StartBeat>Beat
|
||||
if (_Notes[0].StartBeat > beat)
|
||||
return -1;
|
||||
if (_Notes[end].StartBeat <= beat)
|
||||
return end;
|
||||
//Binary search
|
||||
while (end - start > 1)
|
||||
{
|
||||
int mid = (start + end) / 2;
|
||||
if (_Notes[mid].StartBeat <= beat)
|
||||
start = mid;
|
||||
else
|
||||
end = mid;
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
public bool AddNote(CNote note)
|
||||
{
|
||||
if (_Notes.Count == 0)
|
||||
_Notes.Add(note);
|
||||
else
|
||||
{
|
||||
int insPos = FindPreviousNote(note.StartBeat);
|
||||
//Flamefire: May be a performance hit as notes are also used for sung notes
|
||||
//But for song loading this might be very helpful!
|
||||
//Check for overlapping notes
|
||||
/*if (insPos >= 0 && _Notes[insPos].EndBeat > Note.StartBeat)
|
||||
return false;
|
||||
if (insPos < _Notes.Count - 1 && _Notes[insPos+1].StartBeat > Note.EndBeat)
|
||||
return false;
|
||||
* */
|
||||
_Notes.Insert(insPos + 1, note);
|
||||
}
|
||||
_UpdateMinMaxBeat(note);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DeleteNote(int index)
|
||||
{
|
||||
if (_Notes.Count > index)
|
||||
{
|
||||
_Notes.RemoveAt(index);
|
||||
if (index == 0 || index == _Notes.Count - 1)
|
||||
_UpdateMinMaxBeat();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ReplaceNote(int index, CNote note)
|
||||
{
|
||||
if (_Notes.Count > index)
|
||||
{
|
||||
_Notes.RemoveAt(index);
|
||||
return AddNote(note);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IncLastNoteLength()
|
||||
{
|
||||
if (_Notes.Count > 0)
|
||||
{
|
||||
_Notes[_Notes.Count - 1].Duration++;
|
||||
_MaxBeat++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DeleteAllNotes()
|
||||
{
|
||||
_Notes.Clear();
|
||||
_UpdateMinMaxBeat();
|
||||
}
|
||||
|
||||
public void SetMedley(int startBeat, int endBeat)
|
||||
{
|
||||
foreach (CNote note in _Notes)
|
||||
{
|
||||
if (note.StartBeat < startBeat || note.EndBeat > endBeat)
|
||||
note.NoteType = ENoteType.Freestyle;
|
||||
}
|
||||
|
||||
_VisibleInTimeLine = _MinBeat >= startBeat && _MaxBeat <= endBeat;
|
||||
}
|
||||
|
||||
private void _UpdateMinMaxBeat(CNote note)
|
||||
{
|
||||
if (note.StartBeat < _MinBeat)
|
||||
_MinBeat = note.StartBeat;
|
||||
|
||||
if (note.EndBeat > _MaxBeat)
|
||||
_MaxBeat = note.EndBeat;
|
||||
}
|
||||
|
||||
private void _UpdateMinMaxBeat()
|
||||
{
|
||||
if (_Notes.Count > 0)
|
||||
{
|
||||
_MinBeat = _Notes[0].StartBeat;
|
||||
_MaxBeat = _Notes[_Notes.Count - 1].EndBeat;
|
||||
}
|
||||
else
|
||||
{
|
||||
_MinBeat = int.MaxValue;
|
||||
_MaxBeat = int.MinValue;
|
||||
}
|
||||
}
|
||||
#endregion Methods
|
||||
}
|
||||
|
||||
public class CVoice
|
||||
{
|
||||
private readonly List<CLine> _Lines = new List<CLine>();
|
||||
|
||||
public CVoice() {}
|
||||
|
||||
public CVoice(CVoice voice)
|
||||
{
|
||||
foreach (CLine line in voice._Lines)
|
||||
_Lines.Add(new CLine(line));
|
||||
}
|
||||
|
||||
public CLine[] Lines
|
||||
{
|
||||
get { return _Lines.ToArray(); }
|
||||
}
|
||||
public int NumLines
|
||||
{
|
||||
get { return _Lines.Count; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Total song length in beats
|
||||
/// </summary>
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Lines.Count == 0)
|
||||
return 0;
|
||||
|
||||
int startbeat = _Lines.Max(line => line.FirstNoteBeat);
|
||||
int endbeat = _Lines.Min(line => line.LastNoteBeat);
|
||||
|
||||
int result = endbeat - startbeat;
|
||||
return result > 0 ? result : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int Points
|
||||
{
|
||||
get { return _Lines.Sum(line => line.Points); }
|
||||
}
|
||||
|
||||
public int NumLinesWithPoints
|
||||
{
|
||||
get { return _Lines.Count(line => line.Points > 0f); }
|
||||
}
|
||||
|
||||
#region Methods
|
||||
//Find last line with StartBeat<=Beat
|
||||
public int FindPreviousLine(int beat)
|
||||
{
|
||||
//If no line -> No previous line
|
||||
if (_Lines.Count == 0)
|
||||
return -1;
|
||||
int start = 0;
|
||||
int end = _Lines.Count - 1;
|
||||
//Ensure that start.StartBeat<=Beat && end.StartBeat>Beat
|
||||
if (_Lines[0].StartBeat > beat)
|
||||
return -1;
|
||||
if (_Lines[end].StartBeat <= beat)
|
||||
return end;
|
||||
//Binary search
|
||||
while (end - start > 1)
|
||||
{
|
||||
int mid = (start + end) / 2;
|
||||
if (_Lines[mid].StartBeat <= beat)
|
||||
start = mid;
|
||||
else
|
||||
end = mid;
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
public void AddLine(CLine line)
|
||||
{
|
||||
if (_Lines.Count == 0)
|
||||
_Lines.Add(line);
|
||||
else
|
||||
{
|
||||
int insPos = FindPreviousLine(line.StartBeat);
|
||||
_Lines.Insert(insPos + 1, line);
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteLine(int index)
|
||||
{
|
||||
if (_Lines.Count > index)
|
||||
{
|
||||
_Lines.RemoveAt(index);
|
||||
UpdateTimings();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DeleteAllLines()
|
||||
{
|
||||
_Lines.Clear();
|
||||
}
|
||||
|
||||
public bool AddNote(CNote note, bool updateTimings = false)
|
||||
{
|
||||
int lineIndex = FindPreviousLine(note.StartBeat);
|
||||
if (lineIndex < 0)
|
||||
{
|
||||
//Note is before ALL lines
|
||||
CLine line = new CLine {StartBeat = note.StartBeat};
|
||||
line.AddNote(note);
|
||||
_Lines.Insert(0, line);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_Lines[lineIndex].AddNote(note))
|
||||
return false;
|
||||
}
|
||||
if (updateTimings)
|
||||
UpdateTimings();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool InsertNote(CNote note, int lineIndex, bool updateTimings = false)
|
||||
{
|
||||
if (_Lines.Count > lineIndex && _Lines[lineIndex].StartBeat <= note.StartBeat)
|
||||
{
|
||||
_Lines[lineIndex].AddNote(note);
|
||||
if (updateTimings)
|
||||
UpdateTimings();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void UpdateTimings()
|
||||
{
|
||||
CNote lastNote;
|
||||
|
||||
if (_Lines.Count > 0)
|
||||
_Lines[0].StartBeat = -10000;
|
||||
|
||||
for (int i = 1; i < _Lines.Count; i++)
|
||||
{
|
||||
lastNote = _Lines[i - 1].LastNote;
|
||||
CNote firstNote = _Lines[i].FirstNote;
|
||||
|
||||
if ((lastNote != null) && (firstNote != null))
|
||||
{
|
||||
int min = lastNote.EndBeat;
|
||||
int max = firstNote.StartBeat;
|
||||
|
||||
int s;
|
||||
switch (max - min)
|
||||
{
|
||||
case 0:
|
||||
s = max;
|
||||
break;
|
||||
case 1:
|
||||
s = max;
|
||||
break;
|
||||
case 2:
|
||||
s = max - 1;
|
||||
break;
|
||||
case 3:
|
||||
s = max - 2;
|
||||
break;
|
||||
default:
|
||||
s = min + 2;
|
||||
break;
|
||||
}
|
||||
|
||||
_Lines[i].StartBeat = s;
|
||||
_Lines[i - 1].EndBeat = min;
|
||||
}
|
||||
}
|
||||
|
||||
lastNote = _Lines[_Lines.Count - 1].LastNote;
|
||||
if (lastNote != null)
|
||||
_Lines[_Lines.Count - 1].EndBeat = lastNote.EndBeat;
|
||||
}
|
||||
|
||||
public void SetMedley(int startBeat, int endBeat)
|
||||
{
|
||||
foreach (CLine line in _Lines)
|
||||
line.SetMedley(startBeat, endBeat);
|
||||
}
|
||||
#endregion Methods
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
public class CCategory
|
||||
{
|
||||
public readonly string Name;
|
||||
private STexture _CoverTextureSmall = new STexture(-1);
|
||||
private STexture _CoverTextureBig = new STexture(-1);
|
||||
private bool _CoverBigLoaded;
|
||||
public readonly List<CSongPointer> Songs = new List<CSongPointer>();
|
||||
|
||||
public CCategory(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public STexture CoverTextureSmall
|
||||
{
|
||||
get { return _CoverTextureSmall; }
|
||||
|
||||
set { _CoverTextureSmall = value; }
|
||||
}
|
||||
|
||||
public STexture CoverTextureBig
|
||||
{
|
||||
get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; }
|
||||
set
|
||||
{
|
||||
if (value.Index == -1)
|
||||
return;
|
||||
_CoverTextureBig = value;
|
||||
_CoverBigLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public CCategory(string name, STexture coverSmall, STexture coverBig)
|
||||
{
|
||||
Name = name;
|
||||
CoverTextureSmall = coverSmall;
|
||||
CoverTextureBig = coverBig;
|
||||
}
|
||||
|
||||
public CCategory(CCategory cat)
|
||||
{
|
||||
Name = cat.Name;
|
||||
CoverTextureSmall = cat.CoverTextureSmall;
|
||||
CoverTextureBig = cat.CoverTextureBig;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,963 +0,0 @@
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using VocaluxeLib.Menu.SingNotes;
|
||||
|
||||
namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
public class CSongPointer
|
||||
{
|
||||
public readonly int SongID;
|
||||
public string SortString;
|
||||
public bool IsSung;
|
||||
|
||||
public CSongPointer(int id, string sortString)
|
||||
{
|
||||
SongID = id;
|
||||
SortString = sortString;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
enum EHeaderFlags
|
||||
{
|
||||
Title = 1,
|
||||
Artist = 2,
|
||||
MP3 = 4,
|
||||
BPM = 8,
|
||||
PreviewStart = 16,
|
||||
MedleyStartBeat = 32,
|
||||
MedleyEndBeat = 64
|
||||
}
|
||||
|
||||
public enum EMedleySource
|
||||
{
|
||||
None = 0,
|
||||
Calculated,
|
||||
Tag
|
||||
}
|
||||
|
||||
public struct SMedley
|
||||
{
|
||||
public EMedleySource Source;
|
||||
public int StartBeat;
|
||||
public int EndBeat;
|
||||
public float FadeInTime;
|
||||
public float FadeOutTime;
|
||||
}
|
||||
|
||||
public class CSong
|
||||
{
|
||||
private bool _CoverSmallLoaded;
|
||||
private bool _CoverBigLoaded;
|
||||
private STexture _CoverTextureSmall = new STexture(-1);
|
||||
private STexture _CoverTextureBig = new STexture(-1);
|
||||
|
||||
public SMedley Medley;
|
||||
|
||||
public bool CalculateMedley = true;
|
||||
public float PreviewStart;
|
||||
|
||||
public int ShortEnd;
|
||||
|
||||
public Encoding Encoding = Encoding.Default;
|
||||
public string Folder = String.Empty;
|
||||
public string FolderName = String.Empty;
|
||||
public string FileName = String.Empty;
|
||||
public EOffOn Relative = EOffOn.TR_CONFIG_OFF;
|
||||
|
||||
public string MP3FileName = String.Empty;
|
||||
public string CoverFileName = String.Empty;
|
||||
public string BackgroundFileName = String.Empty;
|
||||
public string VideoFileName = String.Empty;
|
||||
|
||||
public EAspect VideoAspect = EAspect.Crop;
|
||||
|
||||
public bool NotesLoaded { get; private set; }
|
||||
|
||||
public STexture CoverTextureSmall
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_CoverSmallLoaded)
|
||||
LoadSmallCover();
|
||||
return _CoverTextureSmall;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_CoverTextureSmall = value;
|
||||
_CoverSmallLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public STexture CoverTextureBig
|
||||
{
|
||||
get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; }
|
||||
set
|
||||
{
|
||||
_CoverTextureBig = value;
|
||||
_CoverBigLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Title = String.Empty;
|
||||
public string Artist = String.Empty;
|
||||
|
||||
public string TitleSorting = String.Empty;
|
||||
public string ArtistSorting = String.Empty;
|
||||
|
||||
public float Start;
|
||||
public float Finish;
|
||||
|
||||
public float BPM = 1f;
|
||||
public float Gap;
|
||||
public float VideoGap;
|
||||
|
||||
public string DuetPart1 = String.Empty;
|
||||
public string DuetPart2 = String.Empty;
|
||||
|
||||
private readonly List<string> _Comment = new List<string>();
|
||||
|
||||
// Sorting
|
||||
public int ID;
|
||||
private readonly bool _Visible = true;
|
||||
private readonly int _CatIndex = -1;
|
||||
private readonly bool _Selected;
|
||||
public bool IsDuet
|
||||
{
|
||||
get { return Notes.Voices.Length > 1; }
|
||||
}
|
||||
|
||||
public readonly List<string> Edition = new List<string>();
|
||||
public readonly List<string> Genre = new List<string>();
|
||||
public string Year = "";
|
||||
|
||||
public readonly List<string> Language = new List<string>();
|
||||
|
||||
// Notes
|
||||
public readonly CNotes Notes = new CNotes();
|
||||
|
||||
public EGameMode[] AvailableGameModes
|
||||
{
|
||||
get
|
||||
{
|
||||
List<EGameMode> gms = new List<EGameMode> {IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL};
|
||||
if (Medley.Source != EMedleySource.None)
|
||||
gms.Add(EGameMode.TR_GAMEMODE_MEDLEY);
|
||||
gms.Add(EGameMode.TR_GAMEMODE_SHORTSONG);
|
||||
|
||||
return gms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
//No point creating a song without a text file --> Use factory method LoadSong
|
||||
private CSong() {}
|
||||
|
||||
public static CSong LoadSong(string filePath)
|
||||
{
|
||||
CSong song = new CSong();
|
||||
return song.ReadHeader(filePath) ? song : null;
|
||||
}
|
||||
|
||||
public CSong(CSong song)
|
||||
{
|
||||
_CoverTextureSmall = song._CoverTextureSmall;
|
||||
_CoverTextureBig = song._CoverTextureBig;
|
||||
|
||||
Medley = new SMedley
|
||||
{
|
||||
Source = song.Medley.Source,
|
||||
StartBeat = song.Medley.StartBeat,
|
||||
EndBeat = song.Medley.EndBeat,
|
||||
FadeInTime = song.Medley.FadeInTime,
|
||||
FadeOutTime = song.Medley.FadeOutTime
|
||||
};
|
||||
|
||||
CalculateMedley = song.CalculateMedley;
|
||||
PreviewStart = song.PreviewStart;
|
||||
|
||||
ShortEnd = song.ShortEnd;
|
||||
DuetPart1 = song.DuetPart1;
|
||||
DuetPart2 = song.DuetPart2;
|
||||
|
||||
Encoding = song.Encoding;
|
||||
Folder = song.Folder;
|
||||
FolderName = song.FolderName;
|
||||
FileName = song.FileName;
|
||||
Relative = song.Relative;
|
||||
|
||||
MP3FileName = song.MP3FileName;
|
||||
CoverFileName = song.CoverFileName;
|
||||
BackgroundFileName = song.BackgroundFileName;
|
||||
VideoFileName = song.VideoFileName;
|
||||
|
||||
VideoAspect = song.VideoAspect;
|
||||
_CoverSmallLoaded = song._CoverSmallLoaded;
|
||||
_CoverBigLoaded = song._CoverBigLoaded;
|
||||
NotesLoaded = song.NotesLoaded;
|
||||
|
||||
Artist = song.Artist;
|
||||
Title = song.Title;
|
||||
|
||||
Start = song.Start;
|
||||
Finish = song.Finish;
|
||||
|
||||
BPM = song.BPM;
|
||||
Gap = song.Gap;
|
||||
VideoGap = song.VideoGap;
|
||||
|
||||
_Comment = new List<string>();
|
||||
foreach (string value in song._Comment)
|
||||
_Comment.Add(value);
|
||||
|
||||
ID = song.ID;
|
||||
_Visible = song._Visible;
|
||||
_CatIndex = song._CatIndex;
|
||||
_Selected = song._Selected;
|
||||
|
||||
Edition = new List<string>();
|
||||
foreach (string value in song.Edition)
|
||||
Edition.Add(value);
|
||||
|
||||
Genre = new List<string>();
|
||||
foreach (string value in song.Genre)
|
||||
Genre.Add(value);
|
||||
|
||||
Year = song.Year;
|
||||
|
||||
Language = new List<string>();
|
||||
foreach (string value in song.Language)
|
||||
Language.Add(value);
|
||||
|
||||
Notes = new CNotes(song.Notes);
|
||||
}
|
||||
|
||||
public string GetMP3()
|
||||
{
|
||||
return Path.Combine(Folder, MP3FileName);
|
||||
}
|
||||
|
||||
public string GetVideo()
|
||||
{
|
||||
return Path.Combine(Folder, VideoFileName);
|
||||
}
|
||||
|
||||
public bool ReadHeader(string filePath)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
return false;
|
||||
|
||||
Folder = Path.GetDirectoryName(filePath);
|
||||
if (Folder == null)
|
||||
return false;
|
||||
|
||||
foreach (string folder in CBase.Config.GetSongFolder())
|
||||
{
|
||||
if (!Folder.Contains(folder))
|
||||
continue;
|
||||
if (Folder.Length == folder.Length)
|
||||
FolderName = "Songs";
|
||||
else
|
||||
{
|
||||
FolderName = Folder.Substring(folder.Length + 1, Folder.Length - folder.Length - 1);
|
||||
|
||||
int pos = FolderName.IndexOf("\\", StringComparison.Ordinal);
|
||||
if (pos >= 0)
|
||||
FolderName = FolderName.Substring(0, pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
FileName = Path.GetFileName(filePath);
|
||||
|
||||
EHeaderFlags headerFlags = new EHeaderFlags();
|
||||
StreamReader sr = null;
|
||||
try
|
||||
{
|
||||
sr = new StreamReader(filePath, Encoding.Default, true);
|
||||
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
string line = sr.ReadLine();
|
||||
if (line == "")
|
||||
continue;
|
||||
if (!line[0].ToString().Equals("#"))
|
||||
break;
|
||||
|
||||
int pos = line.IndexOf(":", StringComparison.Ordinal);
|
||||
|
||||
if (pos <= 0)
|
||||
continue;
|
||||
string identifier = line.Substring(1, pos - 1).Trim().ToUpper();
|
||||
string value = line.Substring(pos + 1, line.Length - pos - 1).Trim();
|
||||
|
||||
if (value != "")
|
||||
{
|
||||
switch (identifier)
|
||||
{
|
||||
case "ENCODING":
|
||||
Encoding = CEncoding.GetEncoding(value);
|
||||
sr.Dispose();
|
||||
sr = null;
|
||||
sr = new StreamReader(filePath, Encoding);
|
||||
|
||||
//Scip everything till encoding
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
line = sr.ReadLine();
|
||||
if (line == "")
|
||||
continue;
|
||||
if (!line[0].ToString().Equals("#"))
|
||||
break;
|
||||
|
||||
pos = line.IndexOf(":", StringComparison.Ordinal);
|
||||
|
||||
if (pos > 0)
|
||||
{
|
||||
identifier = line.Substring(1, pos - 1).Trim().ToUpper();
|
||||
if (identifier == "ENCODING")
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "TITLE":
|
||||
if (value != "")
|
||||
{
|
||||
Title = value;
|
||||
headerFlags |= EHeaderFlags.Title;
|
||||
}
|
||||
break;
|
||||
case "ARTIST":
|
||||
if (value != "")
|
||||
{
|
||||
Artist = value;
|
||||
headerFlags |= EHeaderFlags.Artist;
|
||||
}
|
||||
break;
|
||||
case "TITLE-ON-SORTING":
|
||||
if (value != "")
|
||||
TitleSorting = value;
|
||||
break;
|
||||
case "ARTIST-ON-SORTING":
|
||||
if (value != "")
|
||||
ArtistSorting = value;
|
||||
break;
|
||||
case "P1":
|
||||
if (value != "")
|
||||
DuetPart1 = value;
|
||||
break;
|
||||
case "P2":
|
||||
if (value != "")
|
||||
DuetPart2 = value;
|
||||
break;
|
||||
case "MP3":
|
||||
if (File.Exists(Path.Combine(Folder, value)))
|
||||
{
|
||||
MP3FileName = value;
|
||||
headerFlags |= EHeaderFlags.MP3;
|
||||
}
|
||||
else
|
||||
{
|
||||
CBase.Log.LogError("Can't find audio file: " + Path.Combine(Folder, value));
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "BPM":
|
||||
if (CHelper.TryParse(value, out BPM))
|
||||
{
|
||||
BPM *= 4;
|
||||
headerFlags |= EHeaderFlags.BPM;
|
||||
}
|
||||
break;
|
||||
case "EDITION":
|
||||
if (value.Length > 1)
|
||||
Edition.Add(value);
|
||||
break;
|
||||
case "GENRE":
|
||||
if (value.Length > 1)
|
||||
Genre.Add(value);
|
||||
break;
|
||||
case "YEAR":
|
||||
int num;
|
||||
if (value.Length == 4 && int.TryParse(value, out num) && num != 0)
|
||||
Year = value;
|
||||
break;
|
||||
case "LANGUAGE":
|
||||
if (value.Length > 1)
|
||||
Language.Add(value);
|
||||
break;
|
||||
case "COMMENT":
|
||||
if (value.Length > 1)
|
||||
_Comment.Add(value);
|
||||
break;
|
||||
case "GAP":
|
||||
if (CHelper.TryParse(value, out Gap))
|
||||
Gap /= 1000f;
|
||||
break;
|
||||
case "COVER":
|
||||
if (File.Exists(Path.Combine(Folder, value)))
|
||||
CoverFileName = value;
|
||||
break;
|
||||
case "BACKGROUND":
|
||||
if (File.Exists(Path.Combine(Folder, value)))
|
||||
BackgroundFileName = value;
|
||||
break;
|
||||
case "VIDEO":
|
||||
if (File.Exists(Path.Combine(Folder, value)))
|
||||
VideoFileName = value;
|
||||
else
|
||||
CBase.Log.LogError("Can't find video file: " + Path.Combine(Folder, value));
|
||||
break;
|
||||
case "VIDEOGAP":
|
||||
CHelper.TryParse(value, out VideoGap);
|
||||
break;
|
||||
case "VIDEOASPECT":
|
||||
CHelper.TryParse(value, out VideoAspect, true);
|
||||
break;
|
||||
case "START":
|
||||
CHelper.TryParse(value, out Start);
|
||||
break;
|
||||
case "END":
|
||||
if (CHelper.TryParse(value, out Finish))
|
||||
Finish /= 1000f;
|
||||
break;
|
||||
case "PREVIEWSTART":
|
||||
if (CHelper.TryParse(value, out PreviewStart))
|
||||
{
|
||||
if (PreviewStart < 0f)
|
||||
PreviewStart = 0f;
|
||||
else
|
||||
headerFlags |= EHeaderFlags.PreviewStart;
|
||||
}
|
||||
break;
|
||||
case "MEDLEYSTARTBEAT":
|
||||
if (int.TryParse(value, out Medley.StartBeat))
|
||||
headerFlags |= EHeaderFlags.MedleyStartBeat;
|
||||
break;
|
||||
case "MEDLEYENDBEAT":
|
||||
if (int.TryParse(value, out Medley.EndBeat))
|
||||
headerFlags |= EHeaderFlags.MedleyEndBeat;
|
||||
break;
|
||||
case "CALCMEDLEY":
|
||||
if (value.ToUpper() == "OFF")
|
||||
CalculateMedley = false;
|
||||
break;
|
||||
case "RELATIVE":
|
||||
if (value.ToUpper() == "YES" && value.ToUpper() != "NO")
|
||||
Relative = EOffOn.TR_CONFIG_ON;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} //end of while
|
||||
|
||||
if (sr.EndOfStream)
|
||||
{
|
||||
//No other data then header
|
||||
CBase.Log.LogError("Lyrics/Notes missing: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.Title) == 0)
|
||||
{
|
||||
CBase.Log.LogError("Title tag missing: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.Artist) == 0)
|
||||
{
|
||||
CBase.Log.LogError("Artist tag missing: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.MP3) == 0)
|
||||
{
|
||||
CBase.Log.LogError("MP3 tag missing: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.BPM) == 0)
|
||||
{
|
||||
CBase.Log.LogError("BPM tag missing: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
#region check medley tags
|
||||
if ((headerFlags & EHeaderFlags.MedleyStartBeat) != 0 && (headerFlags & EHeaderFlags.MedleyEndBeat) != 0)
|
||||
{
|
||||
if (Medley.StartBeat > Medley.EndBeat)
|
||||
{
|
||||
CBase.Log.LogError("MedleyStartBeat is bigger than MedleyEndBeat in file: " + filePath);
|
||||
headerFlags = headerFlags - EHeaderFlags.MedleyStartBeat - EHeaderFlags.MedleyEndBeat;
|
||||
}
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.PreviewStart) == 0 || Math.Abs(PreviewStart) < float.Epsilon)
|
||||
{
|
||||
//PreviewStart is not set or <=0
|
||||
PreviewStart = (headerFlags & EHeaderFlags.MedleyStartBeat) != 0 ? CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM) : 0f;
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.MedleyStartBeat) != 0 && (headerFlags & EHeaderFlags.MedleyEndBeat) != 0)
|
||||
{
|
||||
Medley.Source = EMedleySource.Tag;
|
||||
Medley.FadeInTime = CBase.Settings.GetDefaultMedleyFadeInTime();
|
||||
Medley.FadeOutTime = CBase.Settings.GetDefaultMedleyFadeOutTime();
|
||||
}
|
||||
#endregion check medley tags
|
||||
|
||||
Encoding = sr.CurrentEncoding;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (sr != null)
|
||||
sr.Dispose();
|
||||
CBase.Log.LogError("Error reading txt header in file \"" + filePath + "\": " + e.Message);
|
||||
return false;
|
||||
}
|
||||
sr.Dispose();
|
||||
_CheckFiles();
|
||||
|
||||
//Before saving this tags to .txt: Check, if ArtistSorting and Artist are equal, then don't save this tag.
|
||||
if (ArtistSorting == "")
|
||||
ArtistSorting = Artist;
|
||||
|
||||
if (TitleSorting == "")
|
||||
TitleSorting = Title;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ReadNotes()
|
||||
{
|
||||
return _ReadNotes(Path.Combine(Folder, FileName));
|
||||
}
|
||||
|
||||
private bool _ReadNotes(string filePath, bool forceReload = false)
|
||||
{
|
||||
//Skip loading if already done and no reload is forced
|
||||
if (NotesLoaded && !forceReload)
|
||||
return true;
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
CBase.Log.LogError("Error loading song. The file does not exist: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
char tempC = char.MinValue;
|
||||
int currentPos = 0;
|
||||
bool isNewSentence = false;
|
||||
|
||||
int player = 0;
|
||||
int fileLineNo = 0;
|
||||
|
||||
StreamReader sr = null;
|
||||
try
|
||||
{
|
||||
sr = new StreamReader(filePath, Encoding, true);
|
||||
|
||||
Notes.Reset();
|
||||
|
||||
//Search for Note Beginning
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
sr.ReadLine();
|
||||
fileLineNo++;
|
||||
|
||||
tempC = (char)sr.Peek();
|
||||
if ((tempC == '#') || (tempC == '\r') || (tempC == '\n'))
|
||||
continue;
|
||||
if ((tempC == ':') || (tempC == 'F') || (tempC == '*') || (tempC == 'P'))
|
||||
{
|
||||
tempC = (char)sr.Read();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sr.EndOfStream)
|
||||
{
|
||||
CBase.Log.LogError("Error loading song. Line No.: " + fileLineNo + ". No lyrics/notes found: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
int param2;
|
||||
int param1;
|
||||
switch (tempC)
|
||||
{
|
||||
case 'P':
|
||||
char chr;
|
||||
while ((chr = (char)sr.Read()) == ' ') {}
|
||||
|
||||
int.TryParse(chr.ToString(), out param1);
|
||||
if (param1 == 1)
|
||||
player = 0;
|
||||
else if (param1 == 2)
|
||||
player = 1;
|
||||
else if (param1 == 3)
|
||||
player = 2;
|
||||
else
|
||||
{
|
||||
CBase.Log.LogError("Error loading song. Line No.: " + fileLineNo + ". Wrong or missing number after \"P\": " + filePath);
|
||||
return false;
|
||||
}
|
||||
sr.ReadLine();
|
||||
break;
|
||||
case ':':
|
||||
case '*':
|
||||
case 'F':
|
||||
sr.Read();
|
||||
param1 = CHelper.TryReadInt(sr);
|
||||
|
||||
sr.Read();
|
||||
param2 = CHelper.TryReadInt(sr);
|
||||
|
||||
sr.Read();
|
||||
int param3 = CHelper.TryReadInt(sr);
|
||||
|
||||
sr.Read();
|
||||
string paramS = sr.ReadLine();
|
||||
|
||||
ENoteType noteType;
|
||||
|
||||
if (tempC.CompareTo('*') == 0)
|
||||
noteType = ENoteType.Golden;
|
||||
else if (tempC.CompareTo('F') == 0)
|
||||
noteType = ENoteType.Freestyle;
|
||||
else
|
||||
noteType = ENoteType.Normal;
|
||||
|
||||
if (Relative == EOffOn.TR_CONFIG_ON)
|
||||
param1 += currentPos;
|
||||
|
||||
if (player != 2)
|
||||
// one singer
|
||||
_ParseNote(player, noteType, param1, param2, param3, paramS);
|
||||
else
|
||||
{
|
||||
// both singer
|
||||
_ParseNote(0, noteType, param1, param2, param3, paramS);
|
||||
_ParseNote(1, noteType, param1, param2, param3, paramS);
|
||||
}
|
||||
isNewSentence = false;
|
||||
break;
|
||||
case '-':
|
||||
if (isNewSentence)
|
||||
{
|
||||
CBase.Log.LogError("Error loading song. Line No.: " + fileLineNo + ". Double sentence break: " + filePath);
|
||||
return false;
|
||||
}
|
||||
sr.Read();
|
||||
param1 = CHelper.TryReadInt(sr);
|
||||
|
||||
if (Relative == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
param1 += currentPos;
|
||||
sr.Read();
|
||||
param2 = CHelper.TryReadInt(sr);
|
||||
currentPos += param2;
|
||||
}
|
||||
|
||||
if (player != 2)
|
||||
// one singer
|
||||
_NewSentence(player, param1);
|
||||
else
|
||||
{
|
||||
// both singer
|
||||
_NewSentence(0, param1);
|
||||
_NewSentence(1, param1);
|
||||
}
|
||||
|
||||
isNewSentence = true;
|
||||
sr.ReadLine();
|
||||
break;
|
||||
default:
|
||||
CBase.Log.LogError("Error loading song. Line No.: " + fileLineNo + ". Unexpected or missing character (" + tempC + "): " + filePath);
|
||||
return false;
|
||||
}
|
||||
int c;
|
||||
do
|
||||
{
|
||||
c = sr.Read();
|
||||
} while (!sr.EndOfStream && (c == 19 || c == 16 || c == 13 || c == 10));
|
||||
tempC = (char)c;
|
||||
fileLineNo++;
|
||||
} while (!sr.EndOfStream && (tempC != 'E'));
|
||||
|
||||
foreach (CVoice voice in Notes.Voices)
|
||||
voice.UpdateTimings();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error loading song. Line No.: " + fileLineNo + ". An unhandled exception occured (" + e.Message + "): " + filePath);
|
||||
if (sr != null)
|
||||
sr.Dispose();
|
||||
return false;
|
||||
}
|
||||
sr.Dispose();
|
||||
try
|
||||
{
|
||||
_FindRefrain();
|
||||
_FindShortEnd();
|
||||
NotesLoaded = true;
|
||||
if (IsDuet)
|
||||
_CheckDuet();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error loading song. An unhandled exception occured (" + e.Message + "): " + filePath);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool _ParseNote(int player, ENoteType noteType, int start, int length, int tone, string text)
|
||||
{
|
||||
CNote note = new CNote(start, length, tone, text, noteType);
|
||||
CVoice voice = Notes.GetVoice(player);
|
||||
return voice.AddNote(note);
|
||||
}
|
||||
|
||||
private void _NewSentence(int player, int start)
|
||||
{
|
||||
CVoice voice = Notes.GetVoice(player);
|
||||
CLine line = new CLine {StartBeat = start};
|
||||
voice.AddLine(line);
|
||||
}
|
||||
|
||||
public void LoadSmallCover()
|
||||
{
|
||||
if (_CoverSmallLoaded)
|
||||
return;
|
||||
if (CoverFileName != "")
|
||||
{
|
||||
if (!CBase.DataBase.GetCover(Path.Combine(Folder, CoverFileName), ref _CoverTextureSmall, CBase.Config.GetCoverSize()))
|
||||
_CoverTextureSmall = CBase.Cover.GetNoCover();
|
||||
}
|
||||
else
|
||||
_CoverTextureSmall = CBase.Cover.GetNoCover();
|
||||
|
||||
_CoverSmallLoaded = true;
|
||||
}
|
||||
|
||||
private void _CheckFiles()
|
||||
{
|
||||
if (CoverFileName == "")
|
||||
{
|
||||
List<string> files = CHelper.ListFiles(Folder, "*.jpg");
|
||||
files.AddRange(CHelper.ListFiles(Folder, "*.png"));
|
||||
foreach (String file in files)
|
||||
{
|
||||
if (Regex.IsMatch(file, @".[CO].", RegexOptions.IgnoreCase) &&
|
||||
(Regex.IsMatch(file, @"" + Regex.Escape(Title), RegexOptions.IgnoreCase) || Regex.IsMatch(file, @"" + Regex.Escape(Artist), RegexOptions.IgnoreCase)))
|
||||
CoverFileName = file;
|
||||
}
|
||||
}
|
||||
|
||||
if (BackgroundFileName == "")
|
||||
{
|
||||
List<string> files = CHelper.ListFiles(Folder, "*.jpg");
|
||||
files.AddRange(CHelper.ListFiles(Folder, "*.png"));
|
||||
foreach (String file in files)
|
||||
{
|
||||
if (Regex.IsMatch(file, @".[BG].", RegexOptions.IgnoreCase) &&
|
||||
(Regex.IsMatch(file, @"" + Regex.Escape(Title), RegexOptions.IgnoreCase) || Regex.IsMatch(file, @"" + Regex.Escape(Artist), RegexOptions.IgnoreCase)))
|
||||
BackgroundFileName = file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void _CheckDuet()
|
||||
{
|
||||
if (DuetPart1 == "")
|
||||
{
|
||||
DuetPart1 = "Part 1";
|
||||
CBase.Log.LogError("Warning: Can't find #P1-tag for duets in \"" + Artist + " - " + Title + "\".");
|
||||
}
|
||||
if (DuetPart2 == "")
|
||||
{
|
||||
DuetPart2 = "Part 2";
|
||||
CBase.Log.LogError("Warning: Can't find #P2-tag for duets in \"" + Artist + " - " + Title + "\".");
|
||||
}
|
||||
}
|
||||
|
||||
private struct SSeries
|
||||
{
|
||||
public int Start;
|
||||
public int End;
|
||||
public int Length;
|
||||
}
|
||||
|
||||
private List<SSeries> _GetSeries()
|
||||
{
|
||||
CVoice voice = Notes.GetVoice(0);
|
||||
|
||||
if (voice.NumLines == 0)
|
||||
return null;
|
||||
|
||||
// build sentences list
|
||||
List<string> sentences = new List<string>();
|
||||
foreach (CLine line in voice.Lines)
|
||||
sentences.Add(line.Points != 0 ? line.Lyrics : String.Empty);
|
||||
|
||||
// find equal sentences series
|
||||
List<SSeries> series = new List<SSeries>();
|
||||
for (int i = 0; i < voice.NumLines - 1; i++)
|
||||
{
|
||||
for (int j = i + 1; j < voice.NumLines; j++)
|
||||
{
|
||||
if (sentences[i] != sentences[j] || sentences[i] == "")
|
||||
continue;
|
||||
SSeries tempSeries = new SSeries {Start = i, End = i};
|
||||
|
||||
int max;
|
||||
if (j + j - i > voice.NumLines)
|
||||
max = voice.NumLines - 1 - j;
|
||||
else
|
||||
max = j - i - 1;
|
||||
|
||||
for (int k = 1; k <= max; k++)
|
||||
{
|
||||
if (sentences[i + k] == sentences[j + k] && sentences[i + k] != "")
|
||||
tempSeries.End = i + k;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
tempSeries.Length = tempSeries.End - tempSeries.Start + 1;
|
||||
series.Add(tempSeries);
|
||||
}
|
||||
}
|
||||
return series;
|
||||
}
|
||||
|
||||
private void _FindRefrain()
|
||||
{
|
||||
if (IsDuet)
|
||||
{
|
||||
Medley.Source = EMedleySource.None;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Medley.Source == EMedleySource.Tag)
|
||||
return;
|
||||
|
||||
if (!CalculateMedley)
|
||||
return;
|
||||
|
||||
List<SSeries> series = _GetSeries();
|
||||
if (series == null)
|
||||
return;
|
||||
|
||||
// search for longest series
|
||||
int longest = 0;
|
||||
for (int i = 0; i < series.Count; i++)
|
||||
{
|
||||
if (series[i].Length > series[longest].Length)
|
||||
longest = i;
|
||||
}
|
||||
|
||||
CVoice voice = Notes.GetVoice(0);
|
||||
|
||||
// set medley vars
|
||||
if (series.Count > 0 && series[longest].Length > CBase.Settings.GetMedleyMinSeriesLength())
|
||||
{
|
||||
Medley.StartBeat = voice.Lines[series[longest].Start].FirstNoteBeat;
|
||||
Medley.EndBeat = voice.Lines[series[longest].End].LastNoteBeat;
|
||||
|
||||
bool foundEnd = CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM) + CBase.Settings.GetMedleyMinDuration() >
|
||||
CBase.Game.GetTimeFromBeats(Medley.EndBeat, BPM);
|
||||
|
||||
// set end if duration > MedleyMinDuration
|
||||
|
||||
if (!foundEnd)
|
||||
{
|
||||
for (int i = series[longest].Start + 1; i < voice.NumLines - 1; i++)
|
||||
{
|
||||
if (CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM) + CBase.Settings.GetMedleyMinDuration() >
|
||||
CBase.Game.GetTimeFromBeats(voice.Lines[i].LastNoteBeat, BPM))
|
||||
{
|
||||
foundEnd = true;
|
||||
Medley.EndBeat = voice.Lines[i].LastNoteBeat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundEnd)
|
||||
{
|
||||
Medley.Source = EMedleySource.Calculated;
|
||||
Medley.FadeInTime = CBase.Settings.GetDefaultMedleyFadeInTime();
|
||||
Medley.FadeOutTime = CBase.Settings.GetDefaultMedleyFadeOutTime();
|
||||
}
|
||||
}
|
||||
|
||||
if (Math.Abs(PreviewStart) < 0.001)
|
||||
{
|
||||
if (Medley.Source == EMedleySource.Calculated)
|
||||
PreviewStart = CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM);
|
||||
}
|
||||
}
|
||||
|
||||
private void _FindShortEnd()
|
||||
{
|
||||
List<SSeries> series = _GetSeries();
|
||||
if (series == null)
|
||||
return;
|
||||
|
||||
CVoice voice = Notes.GetVoice(0);
|
||||
|
||||
//Calculate length of singing
|
||||
int stop = (voice.Lines[voice.Lines.Length - 1].LastNoteBeat - voice.Lines[0].FirstNote.StartBeat) / 2 + voice.Lines[0].FirstNote.StartBeat;
|
||||
|
||||
//Check if stop is in series
|
||||
for (int i = 0; i < series.Count; i++)
|
||||
{
|
||||
if (voice.Lines[series[i].Start].FirstNoteBeat < stop && voice.Lines[series[i].End].LastNoteBeat > stop)
|
||||
{
|
||||
if (stop < (voice.Lines[series[i].Start].FirstNoteBeat + ((voice.Lines[series[i].End].LastNoteBeat - voice.Lines[series[i].Start].FirstNoteBeat) / 2)))
|
||||
{
|
||||
ShortEnd = voice.Lines[series[i].Start - 1].LastNote.EndBeat;
|
||||
return;
|
||||
}
|
||||
ShortEnd = voice.Lines[series[i].End].LastNote.EndBeat;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Check if stop is in line
|
||||
foreach (CLine line in voice.Lines)
|
||||
{
|
||||
if (line.FirstNoteBeat < stop && line.LastNoteBeat > stop)
|
||||
{
|
||||
ShortEnd = line.LastNoteBeat;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ShortEnd = stop;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
#region license
|
||||
// /*
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu.SingNotes;
|
||||
|
||||
namespace VocaluxeLib.Menu
|
||||
{
|
||||
|
||||
#region Drawing
|
||||
public struct SColorF
|
||||
{
|
||||
public float R;
|
||||
public float G;
|
||||
public float B;
|
||||
public float A;
|
||||
|
||||
public SColorF(float r, float g, float b, float a)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
B = b;
|
||||
A = a;
|
||||
}
|
||||
|
||||
public SColorF(SColorF color)
|
||||
{
|
||||
R = color.R;
|
||||
G = color.G;
|
||||
B = color.B;
|
||||
A = color.A;
|
||||
}
|
||||
}
|
||||
|
||||
public struct SRectF
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float W;
|
||||
public float H;
|
||||
public float Z;
|
||||
public float Rotation; //0..360°
|
||||
|
||||
public SRectF(float x, float y, float w, float h, float z)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
W = w;
|
||||
H = h;
|
||||
Z = z;
|
||||
Rotation = 0f;
|
||||
}
|
||||
|
||||
public SRectF(SRectF rect)
|
||||
{
|
||||
X = rect.X;
|
||||
Y = rect.Y;
|
||||
W = rect.W;
|
||||
H = rect.H;
|
||||
Z = rect.Z;
|
||||
Rotation = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public struct SPoint3F
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
}
|
||||
|
||||
public struct SPoint3
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
public int Z;
|
||||
}
|
||||
|
||||
public struct STexture
|
||||
{
|
||||
public int Index;
|
||||
public int PBO;
|
||||
public int ID;
|
||||
|
||||
public string TexturePath;
|
||||
|
||||
public float Width;
|
||||
public float Height;
|
||||
public SRectF Rect;
|
||||
|
||||
public float W2; //power of 2 width
|
||||
public float H2; //power of 2 height
|
||||
public float WidthRatio;
|
||||
public float HeightRatio;
|
||||
|
||||
public SColorF Color;
|
||||
|
||||
public STexture(int index)
|
||||
{
|
||||
Index = index;
|
||||
PBO = 0;
|
||||
ID = -1;
|
||||
TexturePath = String.Empty;
|
||||
|
||||
Width = 1f;
|
||||
Height = 1f;
|
||||
Rect = new SRectF(0f, 0f, 1f, 1f, 0f);
|
||||
|
||||
W2 = 2f;
|
||||
H2 = 2f;
|
||||
WidthRatio = 0.5f;
|
||||
HeightRatio = 0.5f;
|
||||
|
||||
Color = new SColorF(1f, 1f, 1f, 1f);
|
||||
}
|
||||
}
|
||||
#endregion Drawing
|
||||
|
||||
#region Inputs
|
||||
public struct SKeyEvent
|
||||
{
|
||||
public readonly ESender Sender;
|
||||
public readonly bool ModAlt;
|
||||
public readonly bool ModShift;
|
||||
public readonly bool ModCtrl;
|
||||
public readonly bool KeyPressed;
|
||||
public bool Handled;
|
||||
public Keys Key;
|
||||
public readonly Char Unicode;
|
||||
public readonly EModifier Mod;
|
||||
|
||||
public SKeyEvent(ESender sender, bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key)
|
||||
{
|
||||
Sender = sender;
|
||||
ModAlt = alt;
|
||||
ModShift = shift;
|
||||
ModCtrl = ctrl;
|
||||
KeyPressed = pressed;
|
||||
Unicode = unicode;
|
||||
Key = key;
|
||||
Handled = false;
|
||||
|
||||
Mod = EModifier.None;
|
||||
|
||||
if (alt)
|
||||
Mod |= EModifier.Alt;
|
||||
if (shift)
|
||||
Mod |= EModifier.Shift;
|
||||
if (ctrl)
|
||||
Mod |= EModifier.Ctrl;
|
||||
}
|
||||
}
|
||||
|
||||
public struct SMouseEvent
|
||||
{
|
||||
public readonly ESender Sender;
|
||||
public bool Handled;
|
||||
public readonly int X;
|
||||
public readonly int Y;
|
||||
public readonly bool LB; //left button click
|
||||
public readonly bool LD; //left button double click
|
||||
public readonly bool RB; //right button click
|
||||
public readonly bool MB; //middle button click
|
||||
|
||||
public readonly bool LBH; //left button hold (when moving)
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
public readonly bool RBH; //right button hold (when moving)
|
||||
public readonly bool MBH; //middle button hold (when moving)
|
||||
// ReSharper restore MemberCanBePrivate.Global
|
||||
|
||||
public readonly EModifier Mod;
|
||||
public readonly int Wheel;
|
||||
|
||||
public SMouseEvent(ESender sender, EModifier mod, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
|
||||
{
|
||||
Sender = sender;
|
||||
Handled = false;
|
||||
X = x;
|
||||
Y = y;
|
||||
LB = lb;
|
||||
LD = ld;
|
||||
RB = rb;
|
||||
MB = mb;
|
||||
|
||||
LBH = lbh;
|
||||
RBH = rbh;
|
||||
MBH = mbh;
|
||||
|
||||
Mod = mod;
|
||||
|
||||
Wheel = wheel;
|
||||
}
|
||||
}
|
||||
#endregion Inputs
|
||||
|
||||
#region Profiles
|
||||
public struct SProfile
|
||||
{
|
||||
public string PlayerName;
|
||||
public string ProfileFile;
|
||||
|
||||
public EGameDifficulty Difficulty;
|
||||
public SAvatar Avatar;
|
||||
public EOffOn GuestProfile;
|
||||
public EOffOn Active;
|
||||
}
|
||||
|
||||
public struct SAvatar
|
||||
{
|
||||
public string FileName;
|
||||
public STexture Texture;
|
||||
|
||||
// ReSharper disable UnusedParameter.Local
|
||||
public SAvatar(int dummy)
|
||||
// ReSharper restore UnusedParameter.Local
|
||||
{
|
||||
FileName = String.Empty;
|
||||
Texture = new STexture(-1);
|
||||
}
|
||||
}
|
||||
#endregion Profiles
|
||||
|
||||
#region Game
|
||||
public struct SPlayer
|
||||
{
|
||||
public int ProfileID;
|
||||
public double Points;
|
||||
public double PointsLineBonus;
|
||||
public double PointsGoldenNotes;
|
||||
public int NoteDiff;
|
||||
public int LineNr;
|
||||
public List<CLine> SingLine;
|
||||
public int CurrentLine;
|
||||
public int CurrentNote;
|
||||
|
||||
public int SongID;
|
||||
public bool Medley;
|
||||
public bool Duet;
|
||||
public bool ShortSong;
|
||||
public long DateTicks;
|
||||
public bool SongFinished;
|
||||
}
|
||||
|
||||
public struct SScores
|
||||
{
|
||||
public string Name;
|
||||
public int Score;
|
||||
public string Date;
|
||||
public EGameDifficulty Difficulty;
|
||||
public int LineNr;
|
||||
public int ID;
|
||||
}
|
||||
|
||||
public struct SPartyModeInfos
|
||||
{
|
||||
public int PartyModeID;
|
||||
public string Name;
|
||||
public string Description;
|
||||
public string TargetAudience;
|
||||
public int MaxPlayers;
|
||||
public int MinPlayers;
|
||||
public int MaxTeams;
|
||||
public int MinTeams;
|
||||
|
||||
public string Author;
|
||||
public bool Playable;
|
||||
public int VersionMajor;
|
||||
public int VersionMinor;
|
||||
}
|
||||
#endregion Game
|
||||
}
|
||||
Reference in new issue
Block a user