Renamed ambiguous Notes classes

This commit is contained in:
Flamefire committed 2013-04-26 17:47:26 +02:00
1 parent 63c0688886
commit f43817efd0
14 files changed
+133 -161

No files matched your search

@@ -18,6 +18,7 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -198,9 +199,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_SelectSlides[_SelectSlideSongSource].Clear(); _SelectSlides[_SelectSlideSongSource].Clear();
_SelectSlides[_SelectSlideSongSource].SetValues<ESongSource>((int)_Data.ScreenConfig.SongSource); _SelectSlides[_SelectSlideSongSource].SetValues<ESongSource>((int)_Data.ScreenConfig.SongSource);
string[] playlists = CBase.Playlist.GetPlaylistNames(); List<string> playlists = CBase.Playlist.GetPlaylistNames();
_SelectSlides[_SelectSlidePlaylist].Clear(); _SelectSlides[_SelectSlidePlaylist].Clear();
for (int i = 0; i < playlists.Length; i++) for (int i = 0; i < playlists.Count; i++)
{ {
string value = playlists[i] + " (" + CBase.Playlist.GetPlaylistSongCount(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")"; string value = playlists[i] + " (" + CBase.Playlist.GetPlaylistSongCount(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")";
_SelectSlides[_SelectSlidePlaylist].AddValue(value); _SelectSlides[_SelectSlidePlaylist].AddValue(value);
-1
View File
@@ -1194,7 +1194,6 @@ namespace Vocaluxe.Base
bmp.UnlockBits(bmpData); bmp.UnlockBits(bmpData);
bmp.Save(fileName); bmp.Save(fileName);
}*/ }*/
} }
} }
+6 -6
View File
@@ -229,7 +229,7 @@ namespace Vocaluxe.Base
(_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat)) (_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat))
Players[p].SongFinished = true; Players[p].SongFinished = true;
CLine[] lines = song.Notes.GetLines(Players[p].LineNr).Line; CLine[] lines = song.Notes.GetVoice(Players[p].LineNr).Lines;
int line = -1; int line = -1;
for (int j = 0; j < lines.Length; j++) for (int j = 0; j < lines.Length; j++)
@@ -293,7 +293,7 @@ namespace Vocaluxe.Base
// valid // valid
//CSound.RecordSetTone(p, Tone); //CSound.RecordSetTone(p, Tone);
double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat / double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat /
song.Notes.GetLines(Players[p].LineNr).Points; song.Notes.GetVoice(Players[p].LineNr).Points;
if (notes[note].NoteType == ENoteType.Golden) if (notes[note].NoteType == ENoteType.Golden)
Players[p].PointsGoldenNotes += points; Players[p].PointsGoldenNotes += points;
@@ -302,8 +302,8 @@ namespace Vocaluxe.Base
// update player notes (sung notes) // update player notes (sung notes)
if (Players[p].SingLine[line].NoteCount > 0) if (Players[p].SingLine[line].NoteCount > 0)
{ {
CNote nt = Players[p].SingLine[line].LastNote; CNote lastNote = Players[p].SingLine[line].LastNote;
if (notes[note].StartBeat == beat || nt.EndBeat + 1 != beat || nt.Tone != tone || !nt.Hit) if (notes[note].StartBeat == beat || lastNote.EndBeat + 1 != beat || lastNote.Tone != tone || !lastNote.Hit)
Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType));
else else
Players[p].SingLine[line].IncLastNoteLength(); Players[p].SingLine[line].IncLastNoteLength();
@@ -318,8 +318,8 @@ namespace Vocaluxe.Base
{ {
if (Players[p].SingLine[line].NoteCount > 0) if (Players[p].SingLine[line].NoteCount > 0)
{ {
CNote nt = Players[p].SingLine[line].LastNote; CNote lastNote = Players[p].SingLine[line].LastNote;
if (nt.Tone == tonePlayer && nt.EndBeat + 1 == beat && !nt.Hit) if (lastNote.Tone == tonePlayer && lastNote.EndBeat + 1 == beat && !lastNote.Hit)
Players[p].SingLine[line].IncLastNoteLength(); Players[p].SingLine[line].IncLastNoteLength();
else else
Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle));
+2 -2
View File
@@ -778,9 +778,9 @@ namespace Vocaluxe.Base
CPlaylists.SetPlaylistName(playlistID, name); CPlaylists.SetPlaylistName(playlistID, name);
} }
public string[] GetPlaylistNames() public List<string> GetPlaylistNames()
{ {
return CPlaylists.GetPlaylistNames(); return CPlaylists.PlaylistNames;
} }
public string GetPlaylistName(int playlistID) public string GetPlaylistName(int playlistID)
+1 -1
View File
@@ -26,7 +26,7 @@ namespace Vocaluxe.Base
public event EventHandler ObjectChanged = delegate { }; public event EventHandler ObjectChanged = delegate { };
protected bool _Changed = true; protected bool _Changed = true;
protected void _NotifyObservers() private void _NotifyObservers()
{ {
ObjectChanged.Invoke(this, null); ObjectChanged.Invoke(this, null);
} }
+2 -12
View File
@@ -36,14 +36,14 @@ namespace Vocaluxe.Base
get { return _Playlists.ToArray(); } get { return _Playlists.ToArray(); }
} }
public static IEnumerable<string> PlaylistNames public static List<string> PlaylistNames
{ {
get get
{ {
List<string> names = new List<string>(); List<string> names = new List<string>();
for (int i = 0; i < _Playlists.Count; i++) for (int i = 0; i < _Playlists.Count; i++)
names.Add(_Playlists[i].PlaylistName); names.Add(_Playlists[i].PlaylistName);
return names.ToArray(); return names;
} }
} }
@@ -94,16 +94,6 @@ namespace Vocaluxe.Base
return _Playlists[playlistID].PlaylistName; return _Playlists[playlistID].PlaylistName;
} }
public static string[] GetPlaylistNames()
{
List<string> result = new List<string>();
foreach (CPlaylistFile playlist in _Playlists)
result.Add(playlist.PlaylistName);
return result.ToArray();
}
public static void SetPlaylistName(int playlistID, string name) public static void SetPlaylistName(int playlistID, string name)
{ {
if (playlistID >= _Playlists.Count || playlistID < 0) if (playlistID >= _Playlists.Count || playlistID < 0)
+2 -5
View File
@@ -19,6 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -97,11 +98,7 @@ namespace Vocaluxe.Base
{ {
string search = song.Title.ToUpper() + " " + song.Artist.ToUpper() + " " + song.FolderName.ToUpper() + " " + song.FileName.ToUpper(); string search = song.Title.ToUpper() + " " + song.Artist.ToUpper() + " " + song.FolderName.ToUpper() + " " + song.FileName.ToUpper();
bool contains = true; if (searchStrings.All(search.Contains))
foreach (string str in searchStrings)
contains &= search.Contains(str);
if (contains)
_FilteredSongs.Add(song); _FilteredSongs.Add(song);
} }
} }
+1 -3
View File
@@ -64,14 +64,12 @@ namespace Vocaluxe.Base
return 0f; return 0f;
} }
public static float CalculateFPS() public static void CalculateFPS()
{ {
float ms = GetMilliseconds(); float ms = GetMilliseconds();
if (ms > 0) if (ms > 0)
_Fps = 1 / ms; _Fps = 1 / ms;
return _Fps * 1000f;
} }
public static double GetFPS() public static double GetFPS()
+1 -1
View File
@@ -199,7 +199,7 @@ namespace Vocaluxe.GameModes
song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap; song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap;
// set lines to medley mode // set lines to medley mode
song.Notes.SetMedley(song.Notes.GetLines(0).Line[0].FirstNoteBeat, song.ShortEnd); song.Notes.SetMedley(song.Notes.GetVoice(0).Lines[0].FirstNoteBeat, song.ShortEnd);
break; break;
} }
+43 -47
View File
@@ -22,6 +22,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -665,7 +666,7 @@ namespace Vocaluxe.Screens
_TimerDuetText2.Stop(); _TimerDuetText2.Stop();
_TimerDuetText2.Reset(); _TimerDuetText2.Reset();
if (song.Notes.Lines.Length != 2) if (song.Notes.Voices.Length != 2)
_TimerSongText.Start(); _TimerSongText.Start();
_StartSong(); _StartSong();
@@ -719,21 +720,21 @@ namespace Vocaluxe.Screens
CWebcam.Close(); CWebcam.Close();
} }
private int _FindCurrentLine(CLines lines, CLine[] line, CSong song) private int _FindCurrentLine(CVoice voice, CLine[] lines, CSong song)
{ {
float currentTime = _CurrentTime - song.Gap; float currentTime = _CurrentTime - song.Gap;
//We are only interested in the last matching line, so either do not check further after line[j].StartBeat > _CurrentBeat or go backwards! //We are only interested in the last matching line, so either do not check further after line[j].StartBeat > _CurrentBeat or go backwards!
int j = lines.FindPreviousLine(_CurrentBeat); int j = voice.FindPreviousLine(_CurrentBeat);
for (; j >= 0; j--) for (; j >= 0; j--)
{ {
float firstNoteTime = CGame.GetTimeFromBeats(line[j].FirstNoteBeat, song.BPM); float firstNoteTime = CGame.GetTimeFromBeats(lines[j].FirstNoteBeat, song.BPM);
//Earlist possible line break is 10s before first note //Earlist possible line break is 10s before first note
if (firstNoteTime <= currentTime + 10f) if (firstNoteTime <= currentTime + 10f)
{ {
//First line has no predecessor or line has to be shown //First line has no predecessor or line has to be shown
if (j == 0 || firstNoteTime - CConfig.MinLineBreakTime <= currentTime) if (j == 0 || firstNoteTime - CConfig.MinLineBreakTime <= currentTime)
return j; return j;
float lastNoteTime = CGame.GetTimeFromBeats(line[j - 1].LastNoteBeat, song.BPM); float lastNoteTime = CGame.GetTimeFromBeats(lines[j - 1].LastNoteBeat, song.BPM);
//No line break if last line is not fully evaluated (with 50% tolerance -> tested so notes are drawn) //No line break if last line is not fully evaluated (with 50% tolerance -> tested so notes are drawn)
if (lastNoteTime + CConfig.MicDelay / 1000f * 1.5f >= currentTime) if (lastNoteTime + CConfig.MicDelay / 1000f * 1.5f >= currentTime)
return j - 1; return j - 1;
@@ -760,31 +761,31 @@ namespace Vocaluxe.Screens
if (i > 1) if (i > 1)
break; // for later break; // for later
CLines lines = song.Notes.GetLines(i); CVoice voice = song.Notes.GetVoice(i);
CLine[] line = lines.Line; CLine[] lines = voice.Lines;
// find current line // find current line
int nr = _FindCurrentLine(lines, line, song); int nr = _FindCurrentLine(voice, lines, song);
if (nr != -1) if (nr != -1)
{ {
for (int j = 0; j < CGame.NumPlayer; j++) for (int j = 0; j < CGame.NumPlayer; j++)
{ {
if (CGame.Players[j].LineNr == i) if (CGame.Players[j].LineNr == i)
_SingNotes[_SingBars].AddLine(_NoteLines[j], line, nr); _SingNotes[_SingBars].SetLines(_NoteLines[j], lines, nr);
} }
if (i == 0 && !song.IsDuet || i == 1 && song.IsDuet) if (i == 0 && !song.IsDuet || i == 1 && song.IsDuet)
{ {
_Lyrics[_LyricMain].SetLine(line[nr]); _Lyrics[_LyricMain].SetLine(lines[nr]);
_Lyrics[_LyricMainTop].SetLine(line[nr]); _Lyrics[_LyricMainTop].SetLine(lines[nr]);
_TimeToFirstNote = CGame.GetTimeFromBeats(line[nr].FirstNoteBeat - line[nr].StartBeat, song.BPM); _TimeToFirstNote = CGame.GetTimeFromBeats(lines[nr].FirstNoteBeat - lines[nr].StartBeat, song.BPM);
_RemainingTimeToFirstNote = CGame.GetTimeFromBeats(line[nr].FirstNoteBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM); _RemainingTimeToFirstNote = CGame.GetTimeFromBeats(lines[nr].FirstNoteBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM);
if (line.Length >= nr + 2) if (lines.Length >= nr + 2)
{ {
_Lyrics[_LyricSub].SetLine(line[nr + 1]); _Lyrics[_LyricSub].SetLine(lines[nr + 1]);
_Lyrics[_LyricSubTop].SetLine(line[nr + 1]); _Lyrics[_LyricSubTop].SetLine(lines[nr + 1]);
} }
else else
{ {
@@ -794,12 +795,12 @@ namespace Vocaluxe.Screens
} }
if (i == 0 && song.IsDuet) if (i == 0 && song.IsDuet)
{ {
_Lyrics[_LyricMainDuet].SetLine(line[nr]); _Lyrics[_LyricMainDuet].SetLine(lines[nr]);
_TimeToFirstNoteDuet = CGame.GetTimeFromBeats(line[nr].FirstNoteBeat - line[nr].StartBeat, song.BPM); _TimeToFirstNoteDuet = CGame.GetTimeFromBeats(lines[nr].FirstNoteBeat - lines[nr].StartBeat, song.BPM);
_RemainingTimeToFirstNoteDuet = CGame.GetTimeFromBeats(line[nr].FirstNoteBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM); _RemainingTimeToFirstNoteDuet = CGame.GetTimeFromBeats(lines[nr].FirstNoteBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM);
if (line.Length >= nr + 2) if (lines.Length >= nr + 2)
_Lyrics[_LyricSubDuet].SetLine(line[nr + 1]); _Lyrics[_LyricSubDuet].SetLine(lines[nr + 1]);
else else
_Lyrics[_LyricSubDuet].Clear(); _Lyrics[_LyricSubDuet].Clear();
} }
@@ -1061,22 +1062,22 @@ namespace Vocaluxe.Screens
if (song == null || !song.NotesLoaded) if (song == null || !song.NotesLoaded)
return null; return null;
float[] alpha = new float[song.Notes.Lines.Length * 2]; float[] alpha = new float[song.Notes.Voices.Length * 2];
float currentTime = _CurrentTime - song.Gap; float currentTime = _CurrentTime - song.Gap;
for (int i = 0; i < song.Notes.LinesCount; i++) for (int i = 0; i < song.Notes.LinesCount; i++)
{ {
CLines lines = song.Notes.GetLines(i); CVoice voice = song.Notes.GetVoice(i);
CLine[] line = lines.Line; CLine[] lines = voice.Lines;
// find current line for lyric sub fading // find current line for lyric sub fading
int currentLineSub = _FindCurrentLine(lines, line, song); int currentLineSub = _FindCurrentLine(voice, lines, song);
// find current line for lyric main fading // find current line for lyric main fading
int currentLine = 0; int currentLine = 0;
for (int j = 0; j < line.Length; j++) for (int j = 0; j < lines.Length; j++)
{ {
if (line[j].FirstNoteBeat <= _CurrentBeat) if (lines[j].FirstNoteBeat <= _CurrentBeat)
currentLine = j; currentLine = j;
} }
@@ -1085,31 +1086,31 @@ namespace Vocaluxe.Screens
alpha[i * 2 + 1] = 1f; alpha[i * 2 + 1] = 1f;
// main line alpha // main line alpha
if (currentLine == 0 && currentTime < CGame.GetTimeFromBeats(line[currentLine].FirstNoteBeat, song.BPM)) if (currentLine == 0 && currentTime < CGame.GetTimeFromBeats(lines[currentLine].FirstNoteBeat, song.BPM))
{ {
// first main line and fist note is not reached // first main line and fist note is not reached
// => fade in // => fade in
float diff = CGame.GetTimeFromBeats(line[currentLine].FirstNoteBeat, song.BPM) - currentTime; float diff = CGame.GetTimeFromBeats(lines[currentLine].FirstNoteBeat, song.BPM) - currentTime;
if (diff > dt) if (diff > dt)
alpha[i * 2] = 1f - (diff - dt) / rt; alpha[i * 2] = 1f - (diff - dt) / rt;
} }
else if (currentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[currentLine].LastNoteBeat, song.BPM) < currentTime && else if (currentLine < lines.Length - 1 && CGame.GetTimeFromBeats(lines[currentLine].LastNoteBeat, song.BPM) < currentTime &&
CGame.GetTimeFromBeats(line[currentLine + 1].FirstNoteBeat, song.BPM) > currentTime) CGame.GetTimeFromBeats(lines[currentLine + 1].FirstNoteBeat, song.BPM) > currentTime)
{ {
// current position is between two lines // current position is between two lines
// time between the to lines // time between the to lines
float diff = CGame.GetTimeFromBeats(line[currentLine + 1].FirstNoteBeat, song.BPM) - float diff = CGame.GetTimeFromBeats(lines[currentLine + 1].FirstNoteBeat, song.BPM) -
CGame.GetTimeFromBeats(line[currentLine].LastNoteBeat, song.BPM); CGame.GetTimeFromBeats(lines[currentLine].LastNoteBeat, song.BPM);
// fade only if there is enough time for fading // fade only if there is enough time for fading
if (diff > 3.3f * dt) if (diff > 3.3f * dt)
{ {
// time elapsed since last line // time elapsed since last line
float last = currentTime - CGame.GetTimeFromBeats(line[currentLine].LastNoteBeat, song.BPM); float last = currentTime - CGame.GetTimeFromBeats(lines[currentLine].LastNoteBeat, song.BPM);
// time to next line // time to next line
float next = CGame.GetTimeFromBeats(line[currentLine + 1].FirstNoteBeat, song.BPM) - currentTime; float next = CGame.GetTimeFromBeats(lines[currentLine + 1].FirstNoteBeat, song.BPM) - currentTime;
if (last < next) if (last < next)
{ {
@@ -1124,18 +1125,18 @@ namespace Vocaluxe.Screens
} }
} }
} }
else if (currentLine == line.Length - 1 && CGame.GetTimeFromBeats(line[currentLine].LastNoteBeat, song.BPM) < currentTime) else if (currentLine == lines.Length - 1 && CGame.GetTimeFromBeats(lines[currentLine].LastNoteBeat, song.BPM) < currentTime)
{ {
// last main line and last note was reached // last main line and last note was reached
// => fade out // => fade out
float diff = currentTime - CGame.GetTimeFromBeats(line[currentLine].LastNoteBeat, song.BPM); float diff = currentTime - CGame.GetTimeFromBeats(lines[currentLine].LastNoteBeat, song.BPM);
alpha[i * 2] = 1f - diff / rt; alpha[i * 2] = 1f - diff / rt;
} }
// sub // sub
if (currentLineSub < line.Length - 2) if (currentLineSub < lines.Length - 2)
{ {
float diff = CGame.GetTimeFromBeats(line[currentLineSub + 1].FirstNoteBeat, song.BPM) - currentTime; float diff = CGame.GetTimeFromBeats(lines[currentLineSub + 1].FirstNoteBeat, song.BPM) - currentTime;
if (diff > dt) if (diff > dt)
alpha[i * 2 + 1] = 1f - (diff - dt) / rt; alpha[i * 2 + 1] = 1f - (diff - dt) / rt;
@@ -1338,15 +1339,11 @@ namespace Vocaluxe.Screens
if (totalTime <= 0f) if (totalTime <= 0f)
return; return;
CLines[] partLines = song.Notes.Lines; foreach (CVoice voice in song.Notes.Voices)
foreach (CLines partLine in partLines)
{ {
CLine[] line = partLine.Line; foreach (CLine line in voice.Lines.Where(line => line.VisibleInTimeLine))
for (int j = 0; j < line.Length; j++)
{ {
if (line[j].VisibleInTimeLine) STimeRect trect = new STimeRect {StartBeat = line.FirstNoteBeat, EndBeat = line.EndBeat};
{
STimeRect trect = new STimeRect {StartBeat = line[j].FirstNoteBeat, EndBeat = line[j].EndBeat};
trect.Rect = GetNewStatic(new STexture(-1), trect.Rect = GetNewStatic(new STexture(-1),
new SColorF(1f, 1f, 1f, 1f), new SColorF(1f, 1f, 1f, 1f),
new SRectF( new SRectF(
@@ -1359,7 +1356,6 @@ namespace Vocaluxe.Screens
_TimeRects.Add(trect); _TimeRects.Add(trect);
} }
} }
}
break; break;
} }
} }
+1 -1
View File
@@ -310,7 +310,7 @@ namespace VocaluxeLib.Menu
public interface IPlaylist public interface IPlaylist
{ {
string GetPlaylistName(int playlistID); string GetPlaylistName(int playlistID);
string[] GetPlaylistNames(); List<string> GetPlaylistNames();
void SetPlaylistName(int playlistID, string name); void SetPlaylistName(int playlistID, string name);
void DeletePlaylist(int playlistID); void DeletePlaylist(int playlistID);
+30 -39
View File
@@ -25,73 +25,73 @@ namespace VocaluxeLib.Menu.SingNotes
{ {
public class CNotes public class CNotes
{ {
private readonly List<CLines> _Lines = new List<CLines>(); private readonly List<CVoice> _Voices = new List<CVoice>();
public CLines[] Lines public CVoice[] Voices
{ {
get { return _Lines.ToArray(); } get { return _Voices.ToArray(); }
} }
public CNotes() {} public CNotes() {}
public int LinesCount public int LinesCount
{ {
get { return _Lines.Count; } get { return _Voices.Count; }
} }
public CNotes(CNotes notes) public CNotes(CNotes notes)
{ {
foreach (CLines lines in notes._Lines) foreach (CVoice voice in notes._Voices)
_Lines.Add(new CLines(lines)); _Voices.Add(new CVoice(voice));
} }
public CLines GetLines(int index) public CVoice GetVoice(int index)
{ {
while (index >= _Lines.Count) while (index >= _Voices.Count)
_Lines.Add(new CLines()); _Voices.Add(new CVoice());
return _Lines[index]; return _Voices[index];
} }
public int GetPoints(int index) public int GetPoints(int index)
{ {
if (index >= _Lines.Count) if (index >= _Voices.Count)
return 0; return 0;
return _Lines[index].Points; return _Voices[index].Points;
} }
public int GetNumLinesWithPoints(int index) public int GetNumLinesWithPoints(int index)
{ {
if (index >= _Lines.Count) if (index >= _Voices.Count)
return 0; return 0;
return _Lines[index].NumLinesWithPoints; return _Voices[index].NumLinesWithPoints;
} }
public void AddLines(CLines lines) public void AddVoice(CVoice voice)
{ {
_Lines.Add(lines); _Voices.Add(voice);
} }
public bool ReplaceLinesAt(int index, CLines lines) public bool ReplaceVoiceAt(int index, CVoice voice)
{ {
if (index >= _Lines.Count) if (index >= _Voices.Count)
return false; return false;
_Lines[index] = lines; _Voices[index] = voice;
return true; return true;
} }
public void Reset() public void Reset()
{ {
_Lines.Clear(); _Voices.Clear();
} }
public void SetMedley(int startBeat, int endBeat) public void SetMedley(int startBeat, int endBeat)
{ {
foreach (CLines lines in _Lines) foreach (CVoice voice in _Voices)
lines.SetMedley(startBeat, endBeat); voice.SetMedley(startBeat, endBeat);
} }
} }
@@ -542,23 +542,23 @@ namespace VocaluxeLib.Menu.SingNotes
#endregion Methods #endregion Methods
} }
public class CLines public class CVoice
{ {
private readonly List<CLine> _Lines = new List<CLine>(); private readonly List<CLine> _Lines = new List<CLine>();
public CLines() {} public CVoice() {}
public CLines(CLines lines) public CVoice(CVoice voice)
{ {
foreach (CLine line in lines._Lines) foreach (CLine line in voice._Lines)
_Lines.Add(new CLine(line)); _Lines.Add(new CLine(line));
} }
public CLine[] Line public CLine[] Lines
{ {
get { return _Lines.ToArray(); } get { return _Lines.ToArray(); }
} }
public int LineCount public int NumLines
{ {
get { return _Lines.Count; } get { return _Lines.Count; }
} }
@@ -577,22 +577,13 @@ namespace VocaluxeLib.Menu.SingNotes
int endbeat = _Lines.Min(line => line.LastNoteBeat); int endbeat = _Lines.Min(line => line.LastNoteBeat);
int result = endbeat - startbeat; int result = endbeat - startbeat;
if (result > 0) return result > 0 ? result : 0;
return result;
return 0;
} }
} }
public int Points public int Points
{ {
get get { return _Lines.Sum(line => line.Points); }
{
int points = 0;
foreach (CLine line in _Lines)
points += line.Points;
return points;
}
} }
public int NumLinesWithPoints public int NumLinesWithPoints
+12 -12
View File
@@ -224,24 +224,24 @@ namespace VocaluxeLib.Menu.SingNotes
return notes.ID; return notes.ID;
} }
public void AddLine(int id, CLine[] line, int lineNr) public void SetLines(int id, CLine[] lines, int lineNr)
{ {
if (line == null) if (lines == null)
return; return;
int n = _FindPlayerLine(id); int n = _FindPlayerNotes(id);
if (n == -1) if (n == -1)
return; return;
if (lineNr == _PlayerNotes[n].LineNr) if (lineNr == _PlayerNotes[n].LineNr)
return; return;
if (line.Length <= lineNr) if (lines.Length <= lineNr)
return; return;
SPlayerNotes notes = _PlayerNotes[n]; SPlayerNotes notes = _PlayerNotes[n];
notes.Lines = line; notes.Lines = lines;
notes.LineNr = lineNr; notes.LineNr = lineNr;
notes.GoldenStars.Clear(); notes.GoldenStars.Clear();
notes.Flares.Clear(); notes.Flares.Clear();
@@ -253,7 +253,7 @@ namespace VocaluxeLib.Menu.SingNotes
public void SetAlpha(int id, float alpha) public void SetAlpha(int id, float alpha)
{ {
int n = _FindPlayerLine(id); int n = _FindPlayerNotes(id);
if (n == -1) if (n == -1)
return; return;
@@ -264,7 +264,7 @@ namespace VocaluxeLib.Menu.SingNotes
public float GetAlpha(int id) public float GetAlpha(int id)
{ {
int n = _FindPlayerLine(id); int n = _FindPlayerNotes(id);
if (n == -1) if (n == -1)
return 0f; return 0f;
@@ -276,9 +276,9 @@ namespace VocaluxeLib.Menu.SingNotes
Draw(id, null, player); Draw(id, null, player);
} }
public void Draw(int id, List<CLine> singLine, int player) public void Draw(int id, List<CLine> singLines, int player)
{ {
int n = _FindPlayerLine(id); int n = _FindPlayerNotes(id);
if (n == -1) if (n == -1)
return; return;
@@ -357,7 +357,7 @@ namespace VocaluxeLib.Menu.SingNotes
foreach (CParticleEffect perfline in _PlayerNotes[n].PerfectLineTwinkle) foreach (CParticleEffect perfline in _PlayerNotes[n].PerfectLineTwinkle)
perfline.Draw(); perfline.Draw();
if (singLine == null || singLine.Count == 0 || CBase.Game.GetPlayers()[player].CurrentLine == -1 || singLine.Count <= CBase.Game.GetPlayers()[player].CurrentLine) if (singLines == null || singLines.Count == 0 || CBase.Game.GetPlayers()[player].CurrentLine == -1 || singLines.Count <= CBase.Game.GetPlayers()[player].CurrentLine)
{ {
foreach (CParticleEffect stars in _PlayerNotes[n].GoldenStars) foreach (CParticleEffect stars in _PlayerNotes[n].GoldenStars)
{ {
@@ -367,7 +367,7 @@ namespace VocaluxeLib.Menu.SingNotes
return; return;
} }
foreach (CNote note in singLine[CBase.Game.GetPlayers()[player].CurrentLine].Notes) foreach (CNote note in singLines[CBase.Game.GetPlayers()[player].CurrentLine].Notes)
{ {
if (note.StartBeat >= line.FirstNoteBeat && note.EndBeat <= line.LastNoteBeat) if (note.StartBeat >= line.FirstNoteBeat && note.EndBeat <= line.LastNoteBeat)
{ {
@@ -456,7 +456,7 @@ namespace VocaluxeLib.Menu.SingNotes
LoadTextures(); LoadTextures();
} }
private int _FindPlayerLine(int id) private int _FindPlayerNotes(int id)
{ {
for (int i = 0; i < _PlayerNotes.Count; i++) for (int i = 0; i < _PlayerNotes.Count; i++)
{ {
+29 -29
View File
@@ -209,7 +209,7 @@ namespace VocaluxeLib.Menu.SongMenu
private readonly bool _Selected; private readonly bool _Selected;
public bool IsDuet public bool IsDuet
{ {
get { return Notes.Lines.Length > 1; } get { return Notes.Voices.Length > 1; }
} }
public readonly List<string> Edition = new List<string>(); public readonly List<string> Edition = new List<string>();
@@ -769,8 +769,8 @@ namespace VocaluxeLib.Menu.SongMenu
fileLineNo++; fileLineNo++;
} while (!sr.EndOfStream && (tempC != 'E')); } while (!sr.EndOfStream && (tempC != 'E'));
foreach (CLines lines in Notes.Lines) foreach (CVoice voice in Notes.Voices)
lines.UpdateTimings(); voice.UpdateTimings();
} }
catch (Exception e) catch (Exception e)
{ {
@@ -799,15 +799,15 @@ namespace VocaluxeLib.Menu.SongMenu
private bool _ParseNote(int player, ENoteType noteType, int start, int length, int tone, string text) private bool _ParseNote(int player, ENoteType noteType, int start, int length, int tone, string text)
{ {
CNote note = new CNote(start, length, tone, text, noteType); CNote note = new CNote(start, length, tone, text, noteType);
CLines lines = Notes.GetLines(player); CVoice voice = Notes.GetVoice(player);
return lines.AddNote(note); return voice.AddNote(note);
} }
private void _NewSentence(int player, int start) private void _NewSentence(int player, int start)
{ {
CLines lines = Notes.GetLines(player); CVoice voice = Notes.GetVoice(player);
CLine line = new CLine {StartBeat = start}; CLine line = new CLine {StartBeat = start};
lines.AddLine(line); voice.AddLine(line);
} }
public void LoadSmallCover() public void LoadSmallCover()
@@ -875,29 +875,29 @@ namespace VocaluxeLib.Menu.SongMenu
private List<SSeries> _GetSeries() private List<SSeries> _GetSeries()
{ {
CLines lines = Notes.GetLines(0); CVoice voice = Notes.GetVoice(0);
if (lines.LineCount == 0) if (voice.NumLines == 0)
return null; return null;
// build sentences list // build sentences list
List<string> sentences = new List<string>(); List<string> sentences = new List<string>();
foreach (CLine line in lines.Line) foreach (CLine line in voice.Lines)
sentences.Add(line.Points != 0 ? line.Lyrics : String.Empty); sentences.Add(line.Points != 0 ? line.Lyrics : String.Empty);
// find equal sentences series // find equal sentences series
List<SSeries> series = new List<SSeries>(); List<SSeries> series = new List<SSeries>();
for (int i = 0; i < lines.LineCount - 1; i++) for (int i = 0; i < voice.NumLines - 1; i++)
{ {
for (int j = i + 1; j < lines.LineCount; j++) for (int j = i + 1; j < voice.NumLines; j++)
{ {
if (sentences[i] != sentences[j] || sentences[i] == "") if (sentences[i] != sentences[j] || sentences[i] == "")
continue; continue;
SSeries tempSeries = new SSeries {Start = i, End = i}; SSeries tempSeries = new SSeries {Start = i, End = i};
int max; int max;
if (j + j - i > lines.LineCount) if (j + j - i > voice.NumLines)
max = lines.LineCount - 1 - j; max = voice.NumLines - 1 - j;
else else
max = j - i - 1; max = j - i - 1;
@@ -942,13 +942,13 @@ namespace VocaluxeLib.Menu.SongMenu
longest = i; longest = i;
} }
CLines lines = Notes.GetLines(0); CVoice voice = Notes.GetVoice(0);
// set medley vars // set medley vars
if (series.Count > 0 && series[longest].Length > CBase.Settings.GetMedleyMinSeriesLength()) if (series.Count > 0 && series[longest].Length > CBase.Settings.GetMedleyMinSeriesLength())
{ {
Medley.StartBeat = lines.Line[series[longest].Start].FirstNoteBeat; Medley.StartBeat = voice.Lines[series[longest].Start].FirstNoteBeat;
Medley.EndBeat = lines.Line[series[longest].End].LastNoteBeat; Medley.EndBeat = voice.Lines[series[longest].End].LastNoteBeat;
bool foundEnd = CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM) + CBase.Settings.GetMedleyMinDuration() > bool foundEnd = CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM) + CBase.Settings.GetMedleyMinDuration() >
CBase.Game.GetTimeFromBeats(Medley.EndBeat, BPM); CBase.Game.GetTimeFromBeats(Medley.EndBeat, BPM);
@@ -957,13 +957,13 @@ namespace VocaluxeLib.Menu.SongMenu
if (!foundEnd) if (!foundEnd)
{ {
for (int i = series[longest].Start + 1; i < lines.LineCount - 1; i++) for (int i = series[longest].Start + 1; i < voice.NumLines - 1; i++)
{ {
if (CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM) + CBase.Settings.GetMedleyMinDuration() > if (CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM) + CBase.Settings.GetMedleyMinDuration() >
CBase.Game.GetTimeFromBeats(lines.Line[i].LastNoteBeat, BPM)) CBase.Game.GetTimeFromBeats(voice.Lines[i].LastNoteBeat, BPM))
{ {
foundEnd = true; foundEnd = true;
Medley.EndBeat = lines.Line[i].LastNoteBeat; Medley.EndBeat = voice.Lines[i].LastNoteBeat;
} }
} }
} }
@@ -989,32 +989,32 @@ namespace VocaluxeLib.Menu.SongMenu
if (series == null) if (series == null)
return; return;
CLines lines = Notes.GetLines(0); CVoice voice = Notes.GetVoice(0);
//Calculate length of singing //Calculate length of singing
int stop = (lines.Line[lines.Line.Length - 1].LastNoteBeat - lines.Line[0].FirstNote.StartBeat) / 2 + lines.Line[0].FirstNote.StartBeat; 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 //Check if stop is in series
for (int i = 0; i < series.Count; i++) for (int i = 0; i < series.Count; i++)
{ {
if (lines.Line[series[i].Start].FirstNoteBeat < stop && lines.Line[series[i].End].LastNoteBeat > stop) if (voice.Lines[series[i].Start].FirstNoteBeat < stop && voice.Lines[series[i].End].LastNoteBeat > stop)
{ {
if (stop < (lines.Line[series[i].Start].FirstNoteBeat + ((lines.Line[series[i].End].LastNoteBeat - lines.Line[series[i].Start].FirstNoteBeat) / 2))) if (stop < (voice.Lines[series[i].Start].FirstNoteBeat + ((voice.Lines[series[i].End].LastNoteBeat - voice.Lines[series[i].Start].FirstNoteBeat) / 2)))
{ {
ShortEnd = lines.Line[series[i].Start - 1].LastNote.EndBeat; ShortEnd = voice.Lines[series[i].Start - 1].LastNote.EndBeat;
return; return;
} }
ShortEnd = lines.Line[series[i].End].LastNote.EndBeat; ShortEnd = voice.Lines[series[i].End].LastNote.EndBeat;
return; return;
} }
} }
//Check if stop is in line //Check if stop is in line
for (int i = 0; i < lines.Line.Length; i++) foreach (CLine line in voice.Lines)
{ {
if (lines.Line[i].FirstNoteBeat < stop && lines.Line[i].LastNoteBeat > stop) if (line.FirstNoteBeat < stop && line.LastNoteBeat > stop)
{ {
ShortEnd = lines.Line[i].LastNoteBeat; ShortEnd = line.LastNoteBeat;
return; return;
} }
} }