Merge branch 'develop' of github.com:Flamefire/Vocaluxe into develop
Conflicts: Vocaluxe/Base/CPlaylists.cs Vocaluxe/Base/CProfiles.cs Vocaluxe/Base/CSettings.cs
This commit is contained in:
commit
0400a02bc1
89 files changed
+1500
-1354
No files matched your search
@@ -69,7 +69,7 @@ namespace VocaluxeLib
|
||||
public static int TryReadInt(StreamReader sr)
|
||||
{
|
||||
string value = String.Empty;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
int tmp = sr.Peek();
|
||||
@@ -79,7 +79,7 @@ namespace VocaluxeLib
|
||||
if (sr.EndOfStream)
|
||||
break;
|
||||
|
||||
char chr = (char)sr.Read();
|
||||
var chr = (char)sr.Read();
|
||||
value += chr.ToString();
|
||||
tmp = sr.Peek();
|
||||
}
|
||||
@@ -141,8 +141,8 @@ namespace VocaluxeLib
|
||||
|
||||
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);
|
||||
var files = new List<string>();
|
||||
var dir = new DirectoryInfo(path);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace VocaluxeLib
|
||||
private CXMLReader(string uri)
|
||||
{
|
||||
_FileName = uri;
|
||||
XPathDocument xmlDoc = new XPathDocument(uri);
|
||||
var xmlDoc = new XPathDocument(uri);
|
||||
_Navigator = xmlDoc.CreateNavigator();
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace VocaluxeLib
|
||||
|
||||
public List<string> GetValues(string cast)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
var values = new List<string>();
|
||||
|
||||
_Navigator.MoveToRoot();
|
||||
_Navigator.MoveToFirstChild();
|
||||
@@ -143,7 +143,7 @@ namespace VocaluxeLib
|
||||
|
||||
public IEnumerable<string> GetAttributes(string cast, string attribute)
|
||||
{
|
||||
List<string> values = new List<string>();
|
||||
var values = new List<string>();
|
||||
|
||||
_Navigator.MoveToRoot();
|
||||
_Navigator.MoveToFirstChild();
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace VocaluxeLib.Game
|
||||
for (int player = 0; player < players.Length; player++)
|
||||
{
|
||||
_Rounds[round, player].SongID = songID;
|
||||
_Rounds[round, player].LineNr = players[player].LineNr;
|
||||
_Rounds[round, player].VoiceNr = players[player].VoiceNr;
|
||||
_Rounds[round, player].Points = players[player].Points;
|
||||
_Rounds[round, player].PointsGoldenNotes = players[player].PointsGoldenNotes;
|
||||
_Rounds[round, player].PointsLineBonus = players[player].PointsLineBonus;
|
||||
@@ -80,7 +80,7 @@ namespace VocaluxeLib.Game
|
||||
if (round >= NumRounds)
|
||||
return new SPlayer[1];
|
||||
|
||||
SPlayer[] players = new SPlayer[numPlayer];
|
||||
var players = new SPlayer[numPlayer];
|
||||
|
||||
for (int p = 0; p < players.Length; p++)
|
||||
{
|
||||
@@ -88,7 +88,7 @@ namespace VocaluxeLib.Game
|
||||
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].VoiceNr = _Rounds[round, p].VoiceNr;
|
||||
players[p].Medley = _Rounds[round, p].Medley;
|
||||
players[p].Duet = _Rounds[round, p].Duet;
|
||||
players[p].ShortSong = _Rounds[round, p].ShortSong;
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace VocaluxeLib.Menu
|
||||
#region internal
|
||||
private void _DrawColor()
|
||||
{
|
||||
SRectF bounds = new SRectF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), CBase.Settings.GetZFar() / 4);
|
||||
var bounds = new SRectF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), CBase.Settings.GetZFar() / 4);
|
||||
|
||||
CBase.Drawing.DrawColor(Color, bounds);
|
||||
}
|
||||
@@ -206,7 +206,7 @@ namespace VocaluxeLib.Menu
|
||||
CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
|
||||
if (texture != null)
|
||||
{
|
||||
RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
|
||||
var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
|
||||
RectangleF rect;
|
||||
CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop);
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace VocaluxeLib.Menu
|
||||
CTexture videoTexture = CBase.Theme.GetSkinVideoTexture(_Theme.VideoName, _PartyModeID);
|
||||
if (videoTexture != null)
|
||||
{
|
||||
RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
|
||||
var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
|
||||
RectangleF rect;
|
||||
CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop);
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace VocaluxeLib.Menu
|
||||
CTexture videoTexture = CBase.BackgroundMusic.GetVideoTexture();
|
||||
if (videoTexture != null)
|
||||
{
|
||||
RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
|
||||
var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
|
||||
RectangleF rect;
|
||||
CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop);
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
for (int i = 0; i < _Bars.Length; i++)
|
||||
{
|
||||
SRectF bar = new SRectF(Rect.X + dx * i, Rect.Y + Rect.H - _Bars[i] * Rect.H, dx - Space, _Bars[i] * Rect.H, Rect.Z);
|
||||
var 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;
|
||||
if (i == max)
|
||||
color = MaxColor;
|
||||
|
||||
@@ -201,14 +201,14 @@ namespace VocaluxeLib.Menu
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetLine(CLine line)
|
||||
public void SetLine(CSongLine line)
|
||||
{
|
||||
_Notes.Clear();
|
||||
|
||||
_Width = 0f;
|
||||
foreach (CNote note in line.Notes)
|
||||
foreach (CSongNote note in line.Notes)
|
||||
{
|
||||
SNote n = new SNote {Text = note.Text, StartBeat = note.StartBeat, EndBeat = note.EndBeat, Duration = note.Duration, Type = note.NoteType};
|
||||
var n = new SNote {Text = note.Text, StartBeat = note.StartBeat, EndBeat = note.EndBeat, Duration = note.Duration, Type = note.NoteType};
|
||||
|
||||
_Text.Text = note.Text;
|
||||
_Text.Style = EStyle.Bold;
|
||||
|
||||
+21
-21
@@ -151,7 +151,7 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
foreach (string elName in elements)
|
||||
{
|
||||
T element = (T)Activator.CreateInstance(typeof(T), _PartyModeID);
|
||||
var element = (T)Activator.CreateInstance(typeof(T), _PartyModeID);
|
||||
if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader, skinIndex))
|
||||
addElementHandler(element, elName);
|
||||
else
|
||||
@@ -198,7 +198,7 @@ namespace VocaluxeLib.Menu
|
||||
if (_ThemePath == "")
|
||||
return;
|
||||
|
||||
XmlWriterSettings settings = new XmlWriterSettings {Indent = true, Encoding = Encoding.UTF8, ConformanceLevel = ConformanceLevel.Document};
|
||||
var settings = new XmlWriterSettings {Indent = true, Encoding = Encoding.UTF8, ConformanceLevel = ConformanceLevel.Document};
|
||||
|
||||
string file = Path.Combine(_ThemePath, ThemeName + ".xml");
|
||||
using (XmlWriter writer = XmlWriter.Create(file, settings))
|
||||
@@ -770,7 +770,7 @@ namespace VocaluxeLib.Menu
|
||||
if (_Interactions.Count <= 0)
|
||||
return;
|
||||
|
||||
List<SZSort> items = new List<SZSort>();
|
||||
var items = new List<SZSort>();
|
||||
|
||||
for (int i = 0; i < _Interactions.Count; i++)
|
||||
{
|
||||
@@ -779,7 +779,7 @@ namespace VocaluxeLib.Menu
|
||||
_Interactions[i].Type != EType.NameSelection && _Interactions[i].Type != EType.Text && _Interactions[i].Type != EType.SongMenu &&
|
||||
_Interactions[i].Type != EType.Equalizer && _Interactions[i].Type != EType.Playlist && _Interactions[i].Type != EType.ParticleEffect))
|
||||
continue;
|
||||
SZSort zs = new SZSort {ID = i, Z = _GetZValue(i)};
|
||||
var zs = new SZSort {ID = i, Z = _GetZValue(i)};
|
||||
items.Add(zs);
|
||||
}
|
||||
|
||||
@@ -1105,10 +1105,10 @@ namespace VocaluxeLib.Menu
|
||||
/// <returns></returns>
|
||||
private bool _NextInteraction(SKeyEvent key)
|
||||
{
|
||||
SKeyEvent[] directions = new SKeyEvent[4];
|
||||
float[] distances = new float[4];
|
||||
int[] stages = new int[4];
|
||||
int[] elements = new int[4];
|
||||
var directions = new SKeyEvent[4];
|
||||
var distances = new float[4];
|
||||
var stages = new int[4];
|
||||
var elements = new int[4];
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
directions[i] = new SKeyEvent();
|
||||
@@ -1248,11 +1248,11 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
private float _GetDistanceDirect(SKeyEvent key, SRectF actualRect, SRectF targetRect)
|
||||
{
|
||||
PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f);
|
||||
PointF dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f);
|
||||
var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f);
|
||||
var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f);
|
||||
|
||||
PointF vector = new PointF(dest.X - source.X, dest.Y - source.Y);
|
||||
float distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
|
||||
var vector = new PointF(dest.X - source.X, dest.Y - source.Y);
|
||||
var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
|
||||
bool inDirection = false;
|
||||
switch (key.Key)
|
||||
{
|
||||
@@ -1281,11 +1281,11 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect)
|
||||
{
|
||||
PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f);
|
||||
PointF dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f);
|
||||
var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f);
|
||||
var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f);
|
||||
|
||||
PointF vector = new PointF(dest.X - source.X, dest.Y - source.Y);
|
||||
float distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
|
||||
var vector = new PointF(dest.X - source.X, dest.Y - source.Y);
|
||||
var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
|
||||
bool inDirection = false;
|
||||
switch (key.Key)
|
||||
{
|
||||
@@ -1584,7 +1584,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
private SRectF _GetRect(CInteraction interaction)
|
||||
{
|
||||
SRectF result = new SRectF();
|
||||
var result = new SRectF();
|
||||
switch (interaction.Type)
|
||||
{
|
||||
case EType.Button:
|
||||
@@ -1808,7 +1808,7 @@ namespace VocaluxeLib.Menu
|
||||
private void _LoadThemeBasics(CXMLReader xmlReader, int skinIndex)
|
||||
{
|
||||
// Backgrounds
|
||||
CBackground background = new CBackground(_PartyModeID);
|
||||
var background = new CBackground(_PartyModeID);
|
||||
int i = 1;
|
||||
while (background.LoadTheme("//root/" + ThemeName, "Background" + i, xmlReader, skinIndex))
|
||||
{
|
||||
@@ -1818,7 +1818,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
// Statics
|
||||
CStatic stat = new CStatic(_PartyModeID);
|
||||
var stat = new CStatic(_PartyModeID);
|
||||
i = 1;
|
||||
while (stat.LoadTheme("//root/" + ThemeName, "Static" + i, xmlReader, skinIndex))
|
||||
{
|
||||
@@ -1828,7 +1828,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
// Texts
|
||||
CText text = new CText(_PartyModeID);
|
||||
var text = new CText(_PartyModeID);
|
||||
i = 1;
|
||||
while (text.LoadTheme("//root/" + ThemeName, "Text" + i, xmlReader, skinIndex))
|
||||
{
|
||||
@@ -1838,7 +1838,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
// ParticleEffects
|
||||
CParticleEffect partef = new CParticleEffect(_PartyModeID);
|
||||
var partef = new CParticleEffect(_PartyModeID);
|
||||
i = 1;
|
||||
while (partef.LoadTheme("//root/" + ThemeName, "ParticleEffect" + i, xmlReader, skinIndex))
|
||||
{
|
||||
|
||||
@@ -487,10 +487,10 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
for (int j = 0; j < _NumW; j++)
|
||||
{
|
||||
SRectF rect = new SRectF(Rect.X + j * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, Rect.Z);
|
||||
CStatic tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, ColorEmptyTile, rect) {Aspect = EAspect.Crop};
|
||||
CText tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.NameSpace, rect.Z, _Theme.NameHeight, rect.W, EAlignment.Center, _Theme.NameStyle,
|
||||
_Theme.NameFont, _Theme.NameColor, "");
|
||||
var rect = new SRectF(Rect.X + j * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, Rect.Z);
|
||||
var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, ColorEmptyTile, rect) {Aspect = EAspect.Crop};
|
||||
var tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.NameSpace, rect.Z, _Theme.NameHeight, rect.W, EAlignment.Center, _Theme.NameStyle,
|
||||
_Theme.NameFont, _Theme.NameColor, "");
|
||||
_Tiles.Add(new CTile(tileStatic, tileText, -1));
|
||||
}
|
||||
}
|
||||
@@ -501,21 +501,21 @@ namespace VocaluxeLib.Menu
|
||||
_VisibleProfiles.Clear();
|
||||
CProfile[] profiles = CBase.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < profiles.Length; i++)
|
||||
foreach (CProfile profile in profiles)
|
||||
{
|
||||
bool visible = profiles[i].Active == EOffOn.TR_CONFIG_ON;
|
||||
bool visible = profile.Active == EOffOn.TR_CONFIG_ON;
|
||||
if (visible)
|
||||
{
|
||||
//Show profile only if active
|
||||
for (int p = 0; p < CBase.Game.GetNumPlayer(); p++)
|
||||
{
|
||||
//Don't show profile if is selected, but if selected and guest
|
||||
if (CBase.Game.GetPlayers()[p].ProfileID == profiles[i].ID && profiles[i].GuestProfile == EOffOn.TR_CONFIG_OFF)
|
||||
if (CBase.Game.GetPlayers()[p].ProfileID == profile.ID && profile.GuestProfile == EOffOn.TR_CONFIG_OFF)
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
if (visible)
|
||||
_VisibleProfiles.Add(profiles[i].ID);
|
||||
_VisibleProfiles.Add(profile.ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace VocaluxeLib.Menu
|
||||
if (_Interactions.Count <= 0)
|
||||
return;
|
||||
|
||||
List<SZSort> items = new List<SZSort>();
|
||||
var items = new List<SZSort>();
|
||||
|
||||
for (int i = 0; i < _Interactions.Count; i++)
|
||||
{
|
||||
@@ -320,7 +320,7 @@ namespace VocaluxeLib.Menu
|
||||
_Interactions[i].Type == EType.SongMenu ||
|
||||
_Interactions[i].Type == EType.Equalizer))
|
||||
{
|
||||
SZSort zs = new SZSort {ID = i, Z = _GetZValue(i)};
|
||||
var zs = new SZSort {ID = i, Z = _GetZValue(i)};
|
||||
items.Add(zs);
|
||||
}
|
||||
}
|
||||
@@ -613,10 +613,10 @@ namespace VocaluxeLib.Menu
|
||||
/// <returns></returns>
|
||||
private bool _NextInteraction(SKeyEvent key)
|
||||
{
|
||||
SKeyEvent[] directions = new SKeyEvent[4];
|
||||
float[] distances = new float[4];
|
||||
int[] stages = new int[4];
|
||||
int[] elements = new int[4];
|
||||
var directions = new SKeyEvent[4];
|
||||
var distances = new float[4];
|
||||
var stages = new int[4];
|
||||
var elements = new int[4];
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
directions[i] = new SKeyEvent();
|
||||
@@ -756,11 +756,11 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
private float _GetDistanceDirect(SKeyEvent key, SRectF actualRect, SRectF targetRect)
|
||||
{
|
||||
PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f);
|
||||
PointF dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f);
|
||||
var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f);
|
||||
var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f);
|
||||
|
||||
PointF vector = new PointF(dest.X - source.X, dest.Y - source.Y);
|
||||
float distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
|
||||
var vector = new PointF(dest.X - source.X, dest.Y - source.Y);
|
||||
var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
|
||||
bool inDirection = false;
|
||||
switch (key.Key)
|
||||
{
|
||||
@@ -789,11 +789,11 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect)
|
||||
{
|
||||
PointF source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f);
|
||||
PointF dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f);
|
||||
var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f);
|
||||
var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f);
|
||||
|
||||
PointF vector = new PointF(dest.X - source.X, dest.Y - source.Y);
|
||||
float distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
|
||||
var vector = new PointF(dest.X - source.X, dest.Y - source.Y);
|
||||
var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
|
||||
bool inDirection = false;
|
||||
switch (key.Key)
|
||||
{
|
||||
@@ -1002,7 +1002,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
private SRectF _GetRect(int interaction)
|
||||
{
|
||||
SRectF result = new SRectF();
|
||||
var result = new SRectF();
|
||||
switch (_Interactions[interaction].Type)
|
||||
{
|
||||
case EType.Button:
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace VocaluxeLib.Menu
|
||||
break;
|
||||
|
||||
case EParticleType.Snow:
|
||||
int maxy = (int)Math.Round(CBase.Settings.GetRenderH() - _Size * 0.4f);
|
||||
var maxy = (int)Math.Round(CBase.Settings.GetRenderH() - _Size * 0.4f);
|
||||
|
||||
if (Math.Round(Y) < maxy)
|
||||
{
|
||||
@@ -525,8 +525,8 @@ namespace VocaluxeLib.Menu
|
||||
break;
|
||||
}
|
||||
|
||||
int w = (int)(Rect.W - size / 4f);
|
||||
int h = (int)(Rect.H - size / 4f);
|
||||
var w = (int)(Rect.W - size / 4f);
|
||||
var h = (int)(Rect.H - size / 4f);
|
||||
|
||||
if (w < 0)
|
||||
w = 0;
|
||||
|
||||
@@ -631,7 +631,7 @@ namespace VocaluxeLib.Menu
|
||||
CBase.Playlist.MovePlaylistSongUp(ActivePlaylistID, CurrentPlaylistElement + Offset);
|
||||
UpdatePlaylist();
|
||||
|
||||
SKeyEvent key = new SKeyEvent {Key = Keys.Up};
|
||||
var key = new SKeyEvent {Key = Keys.Up};
|
||||
|
||||
if (CurrentPlaylistElement > scrollLimit)
|
||||
{
|
||||
@@ -660,7 +660,7 @@ namespace VocaluxeLib.Menu
|
||||
CBase.Playlist.MovePlaylistSongDown(ActivePlaylistID, CurrentPlaylistElement + Offset);
|
||||
UpdatePlaylist();
|
||||
|
||||
SKeyEvent key = new SKeyEvent {Key = Keys.Down};
|
||||
var key = new SKeyEvent {Key = Keys.Down};
|
||||
|
||||
if (CurrentPlaylistElement >= scrollLimit)
|
||||
{
|
||||
@@ -973,7 +973,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (!mouseEvent.LBH && DragAndDropSongID != -1)
|
||||
{
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
var gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
CSong song = CBase.Songs.GetSongByID(DragAndDropSongID);
|
||||
|
||||
if (song != null)
|
||||
@@ -1102,7 +1102,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
for (int i = 0; i < Math.Floor(Rect.H / _Theme.EntryHeight); i++)
|
||||
{
|
||||
CPlaylistElement en = new CPlaylistElement
|
||||
var en = new CPlaylistElement
|
||||
{
|
||||
Background = new CStatic(_PartyModeID, _Theme.TextureBackgroundName, BackgroundColor,
|
||||
new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z)),
|
||||
@@ -1143,7 +1143,7 @@ namespace VocaluxeLib.Menu
|
||||
_PlaylistElementContents.Clear();
|
||||
for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(ActivePlaylistID); i++)
|
||||
{
|
||||
CPlaylistElementContent pec = new CPlaylistElementContent
|
||||
var pec = new CPlaylistElementContent
|
||||
{
|
||||
SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID,
|
||||
Modes = CBase.Songs.GetSongByID(CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID).AvailableGameModes,
|
||||
@@ -1162,7 +1162,7 @@ namespace VocaluxeLib.Menu
|
||||
_PlaylistElementContents.Clear();
|
||||
for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(ActivePlaylistID); i++)
|
||||
{
|
||||
CPlaylistElementContent pec = new CPlaylistElementContent {SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID};
|
||||
var pec = new CPlaylistElementContent {SongID = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID};
|
||||
pec.Modes = CBase.Songs.GetSongByID(pec.SongID).AvailableGameModes;
|
||||
pec.Mode = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).GameMode;
|
||||
_PlaylistElementContents.Add(pec);
|
||||
|
||||
@@ -750,10 +750,10 @@ namespace VocaluxeLib.Menu
|
||||
_ValueBounds.Clear();
|
||||
for (int i = 0; i < numvis; i++)
|
||||
{
|
||||
CText text = new CText(0, 0, 0, TextH, MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, TextColor, _ValueNames[i + offset],
|
||||
_ValuePartyModeIDs[i + offset]);
|
||||
var text = new CText(0, 0, 0, TextH, MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, TextColor, _ValueNames[i + offset],
|
||||
_ValuePartyModeIDs[i + offset]);
|
||||
|
||||
SColorF alpha = new SColorF(1f, 1f, 1f, 0.35f);
|
||||
var alpha = new SColorF(1f, 1f, 1f, 0.35f);
|
||||
if (i + offset == _Selection)
|
||||
{
|
||||
text.Color = SelTextColor;
|
||||
@@ -774,7 +774,7 @@ namespace VocaluxeLib.Menu
|
||||
if (WithTextures)
|
||||
{
|
||||
float dh = text.Y - Rect.Y - Rect.H * 0.1f;
|
||||
SRectF rect = new SRectF(text.X - dh / 2, Rect.Y + Rect.H * 0.05f, dh, dh, Rect.Z);
|
||||
var rect = new SRectF(text.X - dh / 2, Rect.Y + Rect.H * 0.05f, dh, dh, Rect.Z);
|
||||
CBase.Drawing.DrawTexture(_Textures[i + offset], rect, alpha);
|
||||
_ValueBounds.Add(rect);
|
||||
}
|
||||
|
||||
@@ -205,11 +205,9 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void Draw(float scale, float z, EAspect aspect, bool forceDraw = false)
|
||||
{
|
||||
CTexture texture = Texture;
|
||||
if (texture == null)
|
||||
texture = new CTexture((int)Rect.W, (int)Rect.H);
|
||||
CTexture texture = Texture ?? new CTexture((int)Rect.W, (int)Rect.H);
|
||||
|
||||
SRectF bounds = new SRectF(
|
||||
var bounds = new SRectF(
|
||||
Rect.X - Rect.W * (scale - 1f),
|
||||
Rect.Y - Rect.H * (scale - 1f),
|
||||
Rect.W + 2 * Rect.W * (scale - 1f),
|
||||
@@ -220,7 +218,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (aspect != EAspect.Stretch)
|
||||
{
|
||||
RectangleF bounds2 = new RectangleF(bounds.X, bounds.Y, bounds.W, bounds.H);
|
||||
var bounds2 = new RectangleF(bounds.X, bounds.Y, bounds.W, bounds.H);
|
||||
RectangleF rect2;
|
||||
CHelper.SetRect(bounds2, out rect2, texture.OrigAspect, aspect);
|
||||
|
||||
@@ -230,7 +228,7 @@ namespace VocaluxeLib.Menu
|
||||
rect.H = rect2.Height;
|
||||
}
|
||||
|
||||
SColorF color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha);
|
||||
var color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha);
|
||||
if (Visible || forceDraw || (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
||||
{
|
||||
CBase.Drawing.DrawTexture(texture, rect, color, bounds);
|
||||
|
||||
@@ -469,7 +469,7 @@ namespace VocaluxeLib.Menu
|
||||
CBase.Fonts.SetStyle(Style);
|
||||
|
||||
SColorF currentColor = (Selected) ? SelColor : Color;
|
||||
SColorF color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
|
||||
var color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
|
||||
|
||||
CBase.Fonts.DrawText(_Text, Rect.H, Rect.X, Rect.Y, Z, color);
|
||||
|
||||
@@ -486,7 +486,7 @@ namespace VocaluxeLib.Menu
|
||||
CBase.Fonts.SetStyle(Style);
|
||||
|
||||
SColorF currentColor = (Selected) ? SelColor : Color;
|
||||
SColorF color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
|
||||
var color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
|
||||
|
||||
CBase.Fonts.DrawText(Text, Rect.H, Rect.X, Rect.Y, Z, color, begin, end);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
public SRectF Rect;
|
||||
public SColorF Color;
|
||||
public float Alpha;
|
||||
public CLine[] Lines;
|
||||
public CSongLine[] Lines;
|
||||
public int LineNr;
|
||||
public Stopwatch Timer;
|
||||
public List<CParticleEffect> GoldenStars;
|
||||
@@ -205,7 +205,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
|
||||
public int AddPlayer(SRectF rect, SColorF color, int playerNr)
|
||||
{
|
||||
SPlayerNotes notes = new SPlayerNotes
|
||||
var notes = new SPlayerNotes
|
||||
{
|
||||
Rect = rect,
|
||||
Color = color,
|
||||
@@ -226,7 +226,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
return notes.ID;
|
||||
}
|
||||
|
||||
public void SetLines(int id, CLine[] lines, int lineNr)
|
||||
public void SetLines(int id, CSongLine[] lines, int lineNr)
|
||||
{
|
||||
if (lines == null)
|
||||
return;
|
||||
@@ -278,7 +278,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
Draw(id, null, player);
|
||||
}
|
||||
|
||||
public void Draw(int id, List<CLine> singLines, int player)
|
||||
public void Draw(int id, List<CSungLine> sungLines, int player)
|
||||
{
|
||||
int n = _FindPlayerNotes(id);
|
||||
if (n == -1)
|
||||
@@ -293,7 +293,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
if (_PlayerNotes[n].Lines.Length <= _PlayerNotes[n].LineNr)
|
||||
return;
|
||||
|
||||
CLine line = _PlayerNotes[n].Lines[_PlayerNotes[n].LineNr];
|
||||
CSongLine line = _PlayerNotes[n].Lines[_PlayerNotes[n].LineNr];
|
||||
|
||||
if (CBase.Config.GetDrawNoteLines() == EOffOn.TR_CONFIG_ON)
|
||||
_DrawNoteLines(_PlayerNotes[n].Rect, new SColorF(0.5f, 0.5f, 0.5f, 0.5f * _PlayerNotes[n].Alpha));
|
||||
@@ -311,7 +311,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
if (beats < 1)
|
||||
return;
|
||||
|
||||
SColorF color = new SColorF(
|
||||
var color = new SColorF(
|
||||
_PlayerNotes[n].Color.R,
|
||||
_PlayerNotes[n].Color.G,
|
||||
_PlayerNotes[n].Color.B,
|
||||
@@ -319,13 +319,13 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
|
||||
float baseLine = line.BaseLine;
|
||||
int nr = 1;
|
||||
foreach (CNote note in line.Notes)
|
||||
foreach (CSongNote note in line.Notes)
|
||||
{
|
||||
if (note.NoteType != ENoteType.Freestyle)
|
||||
{
|
||||
float width = note.Duration / beats * w;
|
||||
|
||||
SRectF rect = new SRectF(
|
||||
var rect = new SRectF(
|
||||
_PlayerNotes[n].Rect.X + (note.StartBeat - line.FirstNoteBeat) / beats * w,
|
||||
_PlayerNotes[n].Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - baseLine) / 2) / CBase.Settings.GetNumNoteLines() * h - dh,
|
||||
width,
|
||||
@@ -359,7 +359,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
foreach (CParticleEffect perfline in _PlayerNotes[n].PerfectLineTwinkle)
|
||||
perfline.Draw();
|
||||
|
||||
if (singLines == null || singLines.Count == 0 || CBase.Game.GetPlayers()[player].CurrentLine == -1 || singLines.Count <= CBase.Game.GetPlayers()[player].CurrentLine)
|
||||
if (sungLines == null || sungLines.Count == 0 || CBase.Game.GetPlayers()[player].CurrentLine == -1 || sungLines.Count <= CBase.Game.GetPlayers()[player].CurrentLine)
|
||||
{
|
||||
foreach (CParticleEffect stars in _PlayerNotes[n].GoldenStars)
|
||||
{
|
||||
@@ -369,48 +369,45 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (CNote note in singLines[CBase.Game.GetPlayers()[player].CurrentLine].Notes)
|
||||
foreach (CSungNote note in sungLines[CBase.Game.GetPlayers()[player].CurrentLine].Notes)
|
||||
{
|
||||
if (note.StartBeat >= line.FirstNoteBeat && note.EndBeat <= line.LastNoteBeat)
|
||||
float width = note.Duration / beats * w;
|
||||
|
||||
if (note.EndBeat == CBase.Game.GetCurrentBeatD())
|
||||
width -= (1 - (CBase.Game.GetMidBeatD() - CBase.Game.GetCurrentBeatD())) / beats * w;
|
||||
|
||||
var rect = new SRectF(
|
||||
_PlayerNotes[n].Rect.X + (note.StartBeat - line.FirstNoteBeat) / beats * w,
|
||||
_PlayerNotes[n].Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - baseLine) / 2) / CBase.Settings.GetNumNoteLines() * h - dh,
|
||||
width,
|
||||
h / CBase.Settings.GetNumNoteLines() + 2 * dh,
|
||||
_PlayerNotes[n].Rect.Z
|
||||
);
|
||||
|
||||
float f = (note.Hit) ? 0.7f : 0.4f;
|
||||
|
||||
_DrawNote(rect, color, f);
|
||||
|
||||
if (note.EndBeat >= CBase.Game.GetCurrentBeatD() && note.Hit && note.HitNote.NoteType == ENoteType.Golden)
|
||||
{
|
||||
float width = note.Duration / beats * w;
|
||||
var re = new SRectF(rect) {W = (CBase.Game.GetMidBeatD() - note.StartBeat) / beats * w};
|
||||
_AddFlare(re, n);
|
||||
}
|
||||
|
||||
if (note.EndBeat == CBase.Game.GetCurrentBeatD())
|
||||
width -= (1 - (CBase.Game.GetMidBeatD() - CBase.Game.GetCurrentBeatD())) / beats * w;
|
||||
|
||||
SRectF rect = new SRectF(
|
||||
_PlayerNotes[n].Rect.X + (note.StartBeat - line.FirstNoteBeat) / beats * w,
|
||||
_PlayerNotes[n].Rect.Y + (CBase.Settings.GetNumNoteLines() - 1 - (note.Tone - baseLine) / 2) / CBase.Settings.GetNumNoteLines() * h - dh,
|
||||
width,
|
||||
h / CBase.Settings.GetNumNoteLines() + 2 * dh,
|
||||
_PlayerNotes[n].Rect.Z
|
||||
);
|
||||
|
||||
float f = (note.Hit) ? 0.7f : 0.4f;
|
||||
|
||||
_DrawNote(rect, color, f);
|
||||
|
||||
if (note.EndBeat >= CBase.Game.GetCurrentBeatD() && note.Hit && note.NoteType == ENoteType.Golden)
|
||||
{
|
||||
SRectF re = new SRectF(rect) {W = (CBase.Game.GetMidBeatD() - note.StartBeat) / beats * w};
|
||||
_AddFlare(re, n);
|
||||
}
|
||||
|
||||
if (note.Perfect && note.EndBeat < CBase.Game.GetCurrentBeatD())
|
||||
{
|
||||
_AddPerfectNote(rect, n);
|
||||
note.Perfect = false;
|
||||
}
|
||||
if (note.Perfect && note.EndBeat < CBase.Game.GetCurrentBeatD())
|
||||
{
|
||||
_AddPerfectNote(rect, n);
|
||||
note.Perfect = false;
|
||||
}
|
||||
}
|
||||
|
||||
int currentLine = CBase.Game.GetPlayers()[player].SingLine.Count - 1;
|
||||
int currentLine = CBase.Game.GetPlayers()[player].SungLines.Count - 1;
|
||||
if (currentLine > 0)
|
||||
{
|
||||
if (CBase.Game.GetPlayers()[player].SingLine[currentLine - 1].PerfectLine)
|
||||
if (CBase.Game.GetPlayers()[player].SungLines[currentLine - 1].PerfectLine)
|
||||
{
|
||||
_AddPerfectLine(n);
|
||||
CBase.Game.GetPlayers()[player].SingLine[currentLine - 1].PerfectLine = false;
|
||||
CBase.Game.GetPlayers()[player].SungLines[currentLine - 1].PerfectLine = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,7 +472,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
float dh = (1f - factor) * rect.H / 2;
|
||||
float dw = Math.Min(dh, rect.W / 2);
|
||||
|
||||
SRectF noteRect = new SRectF(rect.X + dw, rect.Y + dh, rect.W - 2 * dw, rect.H - 2 * dh, rect.Z);
|
||||
var noteRect = new SRectF(rect.X + dw, rect.Y + dh, rect.W - 2 * dw, rect.H - 2 * dh, rect.Z);
|
||||
|
||||
CTexture noteBegin = CBase.Theme.GetSkinTexture(_Theme.SkinLeftName, _PartyModeID);
|
||||
CTexture noteMiddle = CBase.Theme.GetSkinTexture(_Theme.SkinMiddleName, _PartyModeID);
|
||||
@@ -487,7 +484,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
|
||||
CBase.Drawing.DrawTexture(noteBegin, new SRectF(noteRect.X, noteRect.Y, endsW, noteRect.H, noteRect.Z), color);
|
||||
|
||||
SRectF middleRect = new SRectF(noteRect.X + endsW, noteRect.Y, noteRect.W - 2 * endsW, noteRect.H, noteRect.Z);
|
||||
var middleRect = new SRectF(noteRect.X + endsW, noteRect.Y, noteRect.W - 2 * endsW, noteRect.H, noteRect.Z);
|
||||
if (noteRect.W >= 4 * endsW)
|
||||
CBase.Drawing.DrawTexture(noteMiddle, middleRect, color);
|
||||
else
|
||||
@@ -516,7 +513,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
if (2 * dw > rect.W)
|
||||
dw = rect.W / 2;
|
||||
|
||||
SRectF r = new SRectF(
|
||||
var r = new SRectF(
|
||||
rect.X + dw + spacing,
|
||||
rect.Y + d + spacing,
|
||||
rect.W - 2 * dw - 2 * spacing,
|
||||
@@ -532,7 +529,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
if (2 * dx > r.W)
|
||||
dx = r.W / 2;
|
||||
|
||||
SColorF col = new SColorF(color.R, color.G, color.B, color.A * alpha);
|
||||
var col = new SColorF(color.R, color.G, color.B, color.A * alpha);
|
||||
|
||||
CBase.Drawing.DrawTexture(noteBackgroundBegin, new SRectF(r.X, r.Y, dx, r.H, r.Z), col);
|
||||
|
||||
@@ -565,7 +562,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
if (2 * dw > rect.W)
|
||||
dw = rect.W / 2;
|
||||
|
||||
SRectF r = new SRectF(
|
||||
var r = new SRectF(
|
||||
rect.X + dw + spacing,
|
||||
rect.Y + d + spacing,
|
||||
rect.W - 2 * dw - 2 * spacing,
|
||||
@@ -573,8 +570,8 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
rect.Z
|
||||
);
|
||||
|
||||
int numstars = (int)(r.W * 0.25f);
|
||||
CParticleEffect stars = new CParticleEffect(_PartyModeID, numstars, new SColorF(1f, 1f, 0f, 1f), r, _Theme.SkinGoldenStarName, 20, EParticleType.Star);
|
||||
var numstars = (int)(r.W * 0.25f);
|
||||
var stars = new CParticleEffect(_PartyModeID, numstars, new SColorF(1f, 1f, 0f, 1f), r, _Theme.SkinGoldenStarName, 20, EParticleType.Star);
|
||||
_PlayerNotes[n].GoldenStars.Add(stars);
|
||||
}
|
||||
}
|
||||
@@ -589,7 +586,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
if (2 * dw > rect.W)
|
||||
dw = rect.W / 2;
|
||||
|
||||
SRectF r = new SRectF(
|
||||
var r = new SRectF(
|
||||
rect.X + dw + spacing + rect.W - 2 * dw - 2 * spacing,
|
||||
rect.Y + d + spacing,
|
||||
0f,
|
||||
@@ -597,7 +594,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
rect.Z
|
||||
);
|
||||
|
||||
CParticleEffect flares = new CParticleEffect(_PartyModeID, 15, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinGoldenStarName, 20, EParticleType.Flare);
|
||||
var flares = new CParticleEffect(_PartyModeID, 15, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinGoldenStarName, 20, EParticleType.Flare);
|
||||
_PlayerNotes[n].Flares.Add(flares);
|
||||
}
|
||||
|
||||
@@ -611,7 +608,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
if (2 * dw > rect.W)
|
||||
dw = rect.W / 2;
|
||||
|
||||
SRectF r = new SRectF(
|
||||
var r = new SRectF(
|
||||
rect.X + dw + spacing,
|
||||
rect.Y + d + spacing,
|
||||
rect.W - 2 * dw - 2 * spacing,
|
||||
@@ -632,14 +629,14 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
rect.Z
|
||||
);
|
||||
|
||||
CParticleEffect stars = new CParticleEffect(_PartyModeID, CBase.Game.GetRandom(2) + 1, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinPerfectNoteStarName, 35,
|
||||
EParticleType.PerfNoteStar);
|
||||
var stars = new CParticleEffect(_PartyModeID, CBase.Game.GetRandom(2) + 1, new SColorF(1f, 1f, 1f, 1f), r, _Theme.SkinPerfectNoteStarName, 35,
|
||||
EParticleType.PerfNoteStar);
|
||||
_PlayerNotes[n].PerfectNoteEffect.Add(stars);
|
||||
}
|
||||
|
||||
private void _AddPerfectLine(int n)
|
||||
{
|
||||
CParticleEffect twinkle = new CParticleEffect(_PartyModeID, 200, _PlayerNotes[n].Color, _PlayerNotes[n].Rect, _Theme.SkinGoldenStarName, 25, EParticleType.Twinkle);
|
||||
var twinkle = new CParticleEffect(_PartyModeID, 200, _PlayerNotes[n].Color, _PlayerNotes[n].Rect, _Theme.SkinGoldenStarName, 25, EParticleType.Twinkle);
|
||||
_PlayerNotes[n].PerfectLineTwinkle.Add(twinkle);
|
||||
}
|
||||
|
||||
@@ -662,7 +659,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
offsetX = noteBounds.W;
|
||||
|
||||
float dy = noteBounds.H / CBase.Settings.GetNumNoteLines();
|
||||
SRectF drawRect = new SRectF(
|
||||
var drawRect = new SRectF(
|
||||
noteBounds.X - dy + offsetX,
|
||||
noteBounds.Y + dy * (CBase.Settings.GetNumNoteLines() - 1 - (tonePlayer - baseLine) / 2f),
|
||||
dy,
|
||||
@@ -670,7 +667,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
noteBounds.Z
|
||||
);
|
||||
|
||||
SColorF color = new SColorF(
|
||||
var color = new SColorF(
|
||||
_PlayerNotes[n].Color.R,
|
||||
_PlayerNotes[n].Color.G,
|
||||
_PlayerNotes[n].Color.B,
|
||||
|
||||
@@ -518,7 +518,10 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
_Active = active;
|
||||
}
|
||||
|
||||
public virtual bool IsMouseOverActualSelection(SMouseEvent mEvent) { return false; }
|
||||
public virtual bool IsMouseOverActualSelection(SMouseEvent mEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual int GetSelectedSong()
|
||||
{
|
||||
|
||||
@@ -92,9 +92,9 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
for (int j = 0; j < _NumW; j++)
|
||||
{
|
||||
SRectF rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW),
|
||||
_Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
|
||||
CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
|
||||
var rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW),
|
||||
_Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
|
||||
var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
|
||||
_Tiles.Add(tile);
|
||||
}
|
||||
}
|
||||
@@ -423,8 +423,8 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
time = song.Finish;
|
||||
|
||||
time -= song.Start;
|
||||
int min = (int)Math.Floor(time / 60f);
|
||||
int sec = (int)(time - min * 60f);
|
||||
var min = (int)Math.Floor(time / 60f);
|
||||
var sec = (int)(time - min * 60f);
|
||||
_SongLength.Text = min.ToString("00") + ":" + sec.ToString("00");
|
||||
}
|
||||
}
|
||||
@@ -458,11 +458,11 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
if (_Vidtex.Color.A < 1)
|
||||
_CoverBig.Draw(1f, EAspect.Crop);
|
||||
RectangleF bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H);
|
||||
var bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H);
|
||||
RectangleF rect;
|
||||
CHelper.SetRect(bounds, out rect, _Vidtex.OrigAspect, EAspect.Crop);
|
||||
SRectF vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z);
|
||||
SRectF vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f);
|
||||
var vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z);
|
||||
var vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f);
|
||||
|
||||
CBase.Drawing.DrawTexture(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds);
|
||||
CBase.Drawing.DrawTextureReflection(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight);
|
||||
@@ -490,7 +490,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
CStatic selCov = GetSelectedSongCover();
|
||||
if (selCov.Texture == null)
|
||||
return false;
|
||||
SRectF rect = new SRectF(selCov.Rect.X - selCov.Rect.W*0.2f, selCov.Rect.Y - selCov.Rect.H*0.2f, selCov.Rect.W*1.2f, selCov.Rect.H*1.2f, selCov.Rect.Z);
|
||||
var rect = new SRectF(selCov.Rect.X - selCov.Rect.W * 0.2f, selCov.Rect.Y - selCov.Rect.H * 0.2f, selCov.Rect.W * 1.2f, selCov.Rect.H * 1.2f, selCov.Rect.Z);
|
||||
return CHelper.IsInBounds(rect, mEvent);
|
||||
}
|
||||
|
||||
@@ -679,8 +679,8 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
for (int j = 0; j < _NumW; j++)
|
||||
{
|
||||
SRectF rect = new SRectF(_Rect.X + j * (_TileW + _SpaceW), _Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
|
||||
CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
|
||||
var rect = new SRectF(_Rect.X + j * (_TileW + _SpaceW), _Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
|
||||
var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
|
||||
_Tiles.Add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace VocaluxeLib.PartyModes
|
||||
{
|
||||
public abstract class CPartyMode : IPartyMode
|
||||
{
|
||||
protected string _Folder;
|
||||
private string _Folder;
|
||||
protected SScreenSongOptions _ScreenSongOptions;
|
||||
protected readonly Dictionary<string, CMenuParty> _Screens;
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#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.Songs
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for all note types
|
||||
/// </summary>
|
||||
public abstract class CBaseNote
|
||||
{
|
||||
private int _Duration = 1;
|
||||
private int _Tone;
|
||||
|
||||
#region Contructors
|
||||
protected CBaseNote(CBaseNote note)
|
||||
{
|
||||
StartBeat = note.StartBeat;
|
||||
_Duration = note._Duration;
|
||||
_Tone = note._Tone;
|
||||
}
|
||||
|
||||
protected CBaseNote(int startBeat, int duration, int tone)
|
||||
{
|
||||
StartBeat = startBeat;
|
||||
Duration = duration;
|
||||
Tone = tone;
|
||||
}
|
||||
#endregion Constructors
|
||||
|
||||
#region Properties
|
||||
public int StartBeat { get; set; }
|
||||
|
||||
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 int Points
|
||||
{
|
||||
get { return PointsForBeat * Duration; }
|
||||
}
|
||||
|
||||
public abstract int PointsForBeat { get; }
|
||||
#endregion Properties
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
#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;
|
||||
using System.Linq;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
public class CLineBase<T> where T : CBaseNote
|
||||
{
|
||||
protected readonly List<T> _Notes = new List<T>();
|
||||
|
||||
#region Properties
|
||||
public int FirstNoteBeat
|
||||
{
|
||||
get { return (_Notes.Count == 0) ? int.MaxValue : _Notes[0].StartBeat; }
|
||||
}
|
||||
|
||||
public int LastNoteBeat
|
||||
{
|
||||
get { return (_Notes.Count == 0) ? int.MinValue : _Notes[_Notes.Count - 1].EndBeat; }
|
||||
}
|
||||
|
||||
public int NoteCount
|
||||
{
|
||||
get { return _Notes.Count; }
|
||||
}
|
||||
|
||||
public T[] Notes
|
||||
{
|
||||
get { return _Notes.ToArray(); }
|
||||
}
|
||||
|
||||
public T FirstNote
|
||||
{
|
||||
get { return _Notes.Count > 0 ? _Notes[0] : null; }
|
||||
}
|
||||
|
||||
public T LastNote
|
||||
{
|
||||
get { return _Notes.Count > 0 ? _Notes[_Notes.Count - 1] : null; }
|
||||
}
|
||||
|
||||
public int Points
|
||||
{
|
||||
get { return _Notes.Sum(note => note.Points); }
|
||||
}
|
||||
public int BaseLine
|
||||
{
|
||||
get
|
||||
{
|
||||
int min = int.MaxValue;
|
||||
int max = int.MinValue;
|
||||
foreach (T 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
|
||||
//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 virtual bool AddNote(T note)
|
||||
{
|
||||
if (_Notes.Count == 0)
|
||||
_Notes.Add(note);
|
||||
else
|
||||
{
|
||||
int insPos = FindPreviousNote(note.StartBeat);
|
||||
_Notes.Insert(insPos + 1, note);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DeleteNote(int index)
|
||||
{
|
||||
if (_Notes.Count > index)
|
||||
{
|
||||
_Notes.RemoveAt(index);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ReplaceNote(int index, T 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++;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DeleteAllNotes()
|
||||
{
|
||||
_Notes.Clear();
|
||||
}
|
||||
#endregion Methods
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,7 @@
|
||||
// */
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
@@ -94,629 +92,4 @@ namespace VocaluxeLib.Songs
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
public int DataBaseSongID = -1;
|
||||
public string DateAdded = "";
|
||||
public int NumPlayed = 0;
|
||||
public int NumPlayed;
|
||||
|
||||
// Notes
|
||||
public readonly CNotes Notes = new CNotes();
|
||||
@@ -158,7 +158,7 @@ namespace VocaluxeLib.Songs
|
||||
{
|
||||
get
|
||||
{
|
||||
List<EGameMode> gms = new List<EGameMode> {IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL};
|
||||
var 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);
|
||||
@@ -172,7 +172,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
public static CSong LoadSong(string filePath)
|
||||
{
|
||||
CSong song = new CSong();
|
||||
var song = new CSong();
|
||||
return song.ReadHeader(filePath) ? song : null;
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
FileName = Path.GetFileName(filePath);
|
||||
|
||||
EHeaderFlags headerFlags = new EHeaderFlags();
|
||||
var headerFlags = new EHeaderFlags();
|
||||
StreamReader sr = null;
|
||||
try
|
||||
{
|
||||
@@ -737,7 +737,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
private bool _ParseNote(int player, ENoteType noteType, int start, int length, int tone, string text)
|
||||
{
|
||||
CNote note = new CNote(start, length, tone, text, noteType);
|
||||
var note = new CSongNote(start, length, tone, text, noteType);
|
||||
CVoice voice = Notes.GetVoice(player);
|
||||
return voice.AddNote(note);
|
||||
}
|
||||
@@ -745,7 +745,7 @@ namespace VocaluxeLib.Songs
|
||||
private void _NewSentence(int player, int start)
|
||||
{
|
||||
CVoice voice = Notes.GetVoice(player);
|
||||
CLine line = new CLine {StartBeat = start};
|
||||
var line = new CSongLine {StartBeat = start};
|
||||
voice.AddLine(line);
|
||||
}
|
||||
|
||||
@@ -821,14 +821,14 @@ namespace VocaluxeLib.Songs
|
||||
List<string> sentences = voice.Lines.Select(line => line.Points != 0 ? line.Lyrics : String.Empty).ToList();
|
||||
|
||||
// find equal sentences series
|
||||
List<SSeries> series = new List<SSeries>();
|
||||
var 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};
|
||||
var tempSeries = new SSeries {Start = i, End = i};
|
||||
|
||||
int max;
|
||||
if (j + j - i > voice.NumLines)
|
||||
@@ -945,7 +945,7 @@ namespace VocaluxeLib.Songs
|
||||
}
|
||||
|
||||
//Check if stop is in line
|
||||
foreach (CLine line in voice.Lines)
|
||||
foreach (CSongLine line in voice.Lines)
|
||||
{
|
||||
if (line.FirstNoteBeat < stop && line.LastNoteBeat > stop)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
#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.Linq;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
public class CSongLine : CLineBase<CSongNote>
|
||||
{
|
||||
private int _StartBeat = int.MinValue;
|
||||
private int _EndBeat = int.MinValue;
|
||||
|
||||
#region Constructors
|
||||
public CSongLine()
|
||||
{
|
||||
VisibleInTimeLine = true;
|
||||
}
|
||||
|
||||
public CSongLine(CSongLine line)
|
||||
{
|
||||
foreach (CSongNote note in line._Notes)
|
||||
_Notes.Add(new CSongNote(note));
|
||||
_StartBeat = line._StartBeat;
|
||||
_EndBeat = line._EndBeat;
|
||||
VisibleInTimeLine = line.VisibleInTimeLine;
|
||||
}
|
||||
#endregion Constructors
|
||||
|
||||
#region Properties
|
||||
public bool VisibleInTimeLine { get; set; }
|
||||
|
||||
public int StartBeat
|
||||
{
|
||||
get { return _StartBeat; }
|
||||
set
|
||||
{
|
||||
if (value <= FirstNoteBeat)
|
||||
_StartBeat = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int EndBeat
|
||||
{
|
||||
get { return _EndBeat; }
|
||||
set
|
||||
{
|
||||
if (value >= LastNoteBeat)
|
||||
_EndBeat = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Lyrics
|
||||
{
|
||||
get { return _Notes.Aggregate(String.Empty, (current, note) => current + note.Text); }
|
||||
}
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
public override bool AddNote(CSongNote note)
|
||||
{
|
||||
if (_Notes.Count == 0)
|
||||
_Notes.Add(note);
|
||||
else
|
||||
{
|
||||
int insPos = FindPreviousNote(note.StartBeat);
|
||||
//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);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetMedley(int startBeat, int endBeat)
|
||||
{
|
||||
foreach (CSongNote note in _Notes)
|
||||
{
|
||||
if (note.StartBeat < startBeat || note.EndBeat > endBeat)
|
||||
note.NoteType = ENoteType.Freestyle;
|
||||
}
|
||||
|
||||
VisibleInTimeLine = FirstNoteBeat >= startBeat && LastNoteBeat <= endBeat;
|
||||
}
|
||||
#endregion Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#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.Songs
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to represent a note in a song
|
||||
/// </summary>
|
||||
public class CSongNote : CBaseNote
|
||||
{
|
||||
#region Contructors
|
||||
public CSongNote(CSongNote note) : base(note)
|
||||
{
|
||||
NoteType = note.NoteType;
|
||||
Text = note.Text;
|
||||
}
|
||||
|
||||
public CSongNote(int startBeat, int duration, int tone, string text, ENoteType noteType)
|
||||
: base(startBeat, duration, tone)
|
||||
{
|
||||
NoteType = noteType;
|
||||
Text = text;
|
||||
}
|
||||
#endregion Constructors
|
||||
|
||||
#region Properties
|
||||
public ENoteType NoteType { get; set; }
|
||||
|
||||
public string Text { get; set; }
|
||||
|
||||
public override 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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#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.Linq;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
public class CSungLine : CLineBase<CSungNote>
|
||||
{
|
||||
// for drawing perfect line effect
|
||||
public bool PerfectLine { get; set; }
|
||||
|
||||
public bool IsPerfect(CSongLine compareLine)
|
||||
{
|
||||
PerfectLine = _Notes.Count > 0;
|
||||
PerfectLine &= _Notes.Count == compareLine.NoteCount;
|
||||
PerfectLine &= _Notes.All(note => note.Perfect);
|
||||
return PerfectLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
#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.Songs
|
||||
{
|
||||
/// <summary>
|
||||
/// Note that was sung by a player
|
||||
/// </summary>
|
||||
public class CSungNote : CBaseNote
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for a sung note that was not hit
|
||||
/// </summary>
|
||||
/// <param name="startBeat"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="tone"></param>
|
||||
public CSungNote(int startBeat, int duration, int tone) : base(startBeat, duration, tone)
|
||||
{
|
||||
Perfect = false;
|
||||
HitNote = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for a sung note that hit the given note
|
||||
/// </summary>
|
||||
/// <param name="startBeat"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="tone"></param>
|
||||
/// <param name="hitNote"></param>
|
||||
public CSungNote(int startBeat, int duration, int tone, CSongNote hitNote) : this(startBeat, duration, tone)
|
||||
{
|
||||
HitNote = hitNote;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
// for drawing player notes
|
||||
public bool Hit
|
||||
{
|
||||
get { return HitNote != null; }
|
||||
}
|
||||
public CSongNote HitNote { get; private set; }
|
||||
// for drawing perfect note effect
|
||||
public bool Perfect { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public void CheckPerfect()
|
||||
{
|
||||
bool result = HitNote != null;
|
||||
if (result)
|
||||
{
|
||||
result = (StartBeat == HitNote.StartBeat);
|
||||
result &= (EndBeat == HitNote.EndBeat);
|
||||
result &= (Tone == HitNote.Tone);
|
||||
}
|
||||
|
||||
Perfect = result;
|
||||
}
|
||||
#endregion Methods
|
||||
|
||||
public override int PointsForBeat
|
||||
{
|
||||
get { return (HitNote == null) ? 0 : HitNote.PointsForBeat; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
#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;
|
||||
using System.Linq;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
public class CVoice
|
||||
{
|
||||
private readonly List<CSongLine> _Lines = new List<CSongLine>();
|
||||
|
||||
public CVoice() {}
|
||||
|
||||
public CVoice(CVoice voice)
|
||||
{
|
||||
foreach (CSongLine line in voice._Lines)
|
||||
_Lines.Add(new CSongLine(line));
|
||||
}
|
||||
|
||||
public CSongLine[] 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 result = _Lines[_Lines.Count - 1].EndBeat - _Lines[0].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(CSongLine 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(CSongNote note, bool updateTimings = false)
|
||||
{
|
||||
int lineIndex = FindPreviousLine(note.StartBeat);
|
||||
if (lineIndex < 0)
|
||||
{
|
||||
//Note is before ALL lines
|
||||
var line = new CSongLine {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(CSongNote 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()
|
||||
{
|
||||
CSongNote lastNote;
|
||||
|
||||
if (_Lines.Count > 0)
|
||||
_Lines[0].StartBeat = -10000;
|
||||
|
||||
for (int i = 1; i < _Lines.Count; i++)
|
||||
{
|
||||
lastNote = _Lines[i - 1].LastNote;
|
||||
CSongNote 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 (CSongLine line in _Lines)
|
||||
line.SetMedley(startBeat, endBeat);
|
||||
}
|
||||
#endregion Methods
|
||||
}
|
||||
}
|
||||
@@ -186,8 +186,8 @@ namespace VocaluxeLib
|
||||
public double PointsLineBonus;
|
||||
public double PointsGoldenNotes;
|
||||
public int NoteDiff;
|
||||
public int LineNr;
|
||||
public List<CLine> SingLine;
|
||||
public int VoiceNr;
|
||||
public List<CSungLine> SungLines;
|
||||
public int CurrentLine;
|
||||
public int CurrentNote;
|
||||
|
||||
|
||||
@@ -158,6 +158,10 @@
|
||||
<Compile Include="Menu\IMenuElement.cs" />
|
||||
<Compile Include="Profile\CAvatar.cs" />
|
||||
<Compile Include="Profile\CProfile.cs" />
|
||||
<Compile Include="Songs\CLineBase.cs" />
|
||||
<Compile Include="Songs\CBaseNote.cs" />
|
||||
<Compile Include="Songs\CSongLine.cs" />
|
||||
<Compile Include="Songs\CSongNote.cs" />
|
||||
<Compile Include="Songs\CNotes.cs" />
|
||||
<Compile Include="Menu\SingNotes\CSingNotes.cs" />
|
||||
<Compile Include="Menu\SingNotes\CSingNotesClassic.cs" />
|
||||
@@ -170,6 +174,9 @@
|
||||
<Compile Include="Menu\SongMenu\CSongMenuList.cs" />
|
||||
<Compile Include="Menu\SongMenu\CSongMenuTileBoard.cs" />
|
||||
<Compile Include="Menu\SongMenu\ISongMenu.cs" />
|
||||
<Compile Include="Songs\CSungLine.cs" />
|
||||
<Compile Include="Songs\CSungNote.cs" />
|
||||
<Compile Include="Songs\CVoice.cs" />
|
||||
<Compile Include="Structs.cs" />
|
||||
<Compile Include="PartyModes\CPartyMode.cs" />
|
||||
<Compile Include="PartyModes\CPartyModeNone.cs" />
|
||||
|
||||
Reference in new issue
Block a user