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
+142 -170

No files matched your search

+1 -1
View File
@@ -310,7 +310,7 @@ namespace VocaluxeLib.Menu
public interface IPlaylist
{
string GetPlaylistName(int playlistID);
string[] GetPlaylistNames();
List<string> GetPlaylistNames();
void SetPlaylistName(int playlistID, string name);
void DeletePlaylist(int playlistID);
+30 -39
View File
@@ -25,73 +25,73 @@ namespace VocaluxeLib.Menu.SingNotes
{
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 int LinesCount
{
get { return _Lines.Count; }
get { return _Voices.Count; }
}
public CNotes(CNotes notes)
{
foreach (CLines lines in notes._Lines)
_Lines.Add(new CLines(lines));
foreach (CVoice voice in notes._Voices)
_Voices.Add(new CVoice(voice));
}
public CLines GetLines(int index)
public CVoice GetVoice(int index)
{
while (index >= _Lines.Count)
_Lines.Add(new CLines());
while (index >= _Voices.Count)
_Voices.Add(new CVoice());
return _Lines[index];
return _Voices[index];
}
public int GetPoints(int index)
{
if (index >= _Lines.Count)
if (index >= _Voices.Count)
return 0;
return _Lines[index].Points;
return _Voices[index].Points;
}
public int GetNumLinesWithPoints(int index)
{
if (index >= _Lines.Count)
if (index >= _Voices.Count)
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;
_Lines[index] = lines;
_Voices[index] = voice;
return true;
}
public void Reset()
{
_Lines.Clear();
_Voices.Clear();
}
public void SetMedley(int startBeat, int endBeat)
{
foreach (CLines lines in _Lines)
lines.SetMedley(startBeat, endBeat);
foreach (CVoice voice in _Voices)
voice.SetMedley(startBeat, endBeat);
}
}
@@ -542,23 +542,23 @@ namespace VocaluxeLib.Menu.SingNotes
#endregion Methods
}
public class CLines
public class CVoice
{
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));
}
public CLine[] Line
public CLine[] Lines
{
get { return _Lines.ToArray(); }
}
public int LineCount
public int NumLines
{
get { return _Lines.Count; }
}
@@ -577,22 +577,13 @@ namespace VocaluxeLib.Menu.SingNotes
int endbeat = _Lines.Min(line => line.LastNoteBeat);
int result = endbeat - startbeat;
if (result > 0)
return result;
return 0;
return result > 0 ? result : 0;
}
}
public int Points
{
get
{
int points = 0;
foreach (CLine line in _Lines)
points += line.Points;
return points;
}
get { return _Lines.Sum(line => line.Points); }
}
public int NumLinesWithPoints
+12 -12
View File
@@ -224,24 +224,24 @@ namespace VocaluxeLib.Menu.SingNotes
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;
int n = _FindPlayerLine(id);
int n = _FindPlayerNotes(id);
if (n == -1)
return;
if (lineNr == _PlayerNotes[n].LineNr)
return;
if (line.Length <= lineNr)
if (lines.Length <= lineNr)
return;
SPlayerNotes notes = _PlayerNotes[n];
notes.Lines = line;
notes.Lines = lines;
notes.LineNr = lineNr;
notes.GoldenStars.Clear();
notes.Flares.Clear();
@@ -253,7 +253,7 @@ namespace VocaluxeLib.Menu.SingNotes
public void SetAlpha(int id, float alpha)
{
int n = _FindPlayerLine(id);
int n = _FindPlayerNotes(id);
if (n == -1)
return;
@@ -264,7 +264,7 @@ namespace VocaluxeLib.Menu.SingNotes
public float GetAlpha(int id)
{
int n = _FindPlayerLine(id);
int n = _FindPlayerNotes(id);
if (n == -1)
return 0f;
@@ -276,9 +276,9 @@ namespace VocaluxeLib.Menu.SingNotes
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)
return;
@@ -357,7 +357,7 @@ namespace VocaluxeLib.Menu.SingNotes
foreach (CParticleEffect perfline in _PlayerNotes[n].PerfectLineTwinkle)
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)
{
@@ -367,7 +367,7 @@ namespace VocaluxeLib.Menu.SingNotes
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)
{
@@ -456,7 +456,7 @@ namespace VocaluxeLib.Menu.SingNotes
LoadTextures();
}
private int _FindPlayerLine(int id)
private int _FindPlayerNotes(int id)
{
for (int i = 0; i < _PlayerNotes.Count; i++)
{
+29 -29
View File
@@ -209,7 +209,7 @@ namespace VocaluxeLib.Menu.SongMenu
private readonly bool _Selected;
public bool IsDuet
{
get { return Notes.Lines.Length > 1; }
get { return Notes.Voices.Length > 1; }
}
public readonly List<string> Edition = new List<string>();
@@ -769,8 +769,8 @@ namespace VocaluxeLib.Menu.SongMenu
fileLineNo++;
} while (!sr.EndOfStream && (tempC != 'E'));
foreach (CLines lines in Notes.Lines)
lines.UpdateTimings();
foreach (CVoice voice in Notes.Voices)
voice.UpdateTimings();
}
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)
{
CNote note = new CNote(start, length, tone, text, noteType);
CLines lines = Notes.GetLines(player);
return lines.AddNote(note);
CVoice voice = Notes.GetVoice(player);
return voice.AddNote(note);
}
private void _NewSentence(int player, int start)
{
CLines lines = Notes.GetLines(player);
CVoice voice = Notes.GetVoice(player);
CLine line = new CLine {StartBeat = start};
lines.AddLine(line);
voice.AddLine(line);
}
public void LoadSmallCover()
@@ -875,29 +875,29 @@ namespace VocaluxeLib.Menu.SongMenu
private List<SSeries> _GetSeries()
{
CLines lines = Notes.GetLines(0);
CVoice voice = Notes.GetVoice(0);
if (lines.LineCount == 0)
if (voice.NumLines == 0)
return null;
// build sentences list
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);
// find equal sentences series
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] == "")
continue;
SSeries tempSeries = new SSeries {Start = i, End = i};
int max;
if (j + j - i > lines.LineCount)
max = lines.LineCount - 1 - j;
if (j + j - i > voice.NumLines)
max = voice.NumLines - 1 - j;
else
max = j - i - 1;
@@ -942,13 +942,13 @@ namespace VocaluxeLib.Menu.SongMenu
longest = i;
}
CLines lines = Notes.GetLines(0);
CVoice voice = Notes.GetVoice(0);
// set medley vars
if (series.Count > 0 && series[longest].Length > CBase.Settings.GetMedleyMinSeriesLength())
{
Medley.StartBeat = lines.Line[series[longest].Start].FirstNoteBeat;
Medley.EndBeat = lines.Line[series[longest].End].LastNoteBeat;
Medley.StartBeat = voice.Lines[series[longest].Start].FirstNoteBeat;
Medley.EndBeat = voice.Lines[series[longest].End].LastNoteBeat;
bool foundEnd = CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM) + CBase.Settings.GetMedleyMinDuration() >
CBase.Game.GetTimeFromBeats(Medley.EndBeat, BPM);
@@ -957,13 +957,13 @@ namespace VocaluxeLib.Menu.SongMenu
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() >
CBase.Game.GetTimeFromBeats(lines.Line[i].LastNoteBeat, BPM))
CBase.Game.GetTimeFromBeats(voice.Lines[i].LastNoteBeat, BPM))
{
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)
return;
CLines lines = Notes.GetLines(0);
CVoice voice = Notes.GetVoice(0);
//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
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;
}
ShortEnd = lines.Line[series[i].End].LastNote.EndBeat;
ShortEnd = voice.Lines[series[i].End].LastNote.EndBeat;
return;
}
}
//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;
}
}