More refactoring (mainly LINQ)
This commit is contained in:
1 parent
181490fa87
commit
b1e28ae7bc
43 files changed
+488
-662
No files matched your search
@@ -19,6 +19,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace VocaluxeLib.Menu.SingNotes
|
||||
{
|
||||
@@ -572,19 +573,8 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
if (_Lines.Count == 0)
|
||||
return 0;
|
||||
|
||||
int startbeat = int.MaxValue;
|
||||
for (int i = 0; i < _Lines.Count; i++)
|
||||
{
|
||||
if (_Lines[i].FirstNoteBeat < startbeat)
|
||||
startbeat = _Lines[i].FirstNoteBeat;
|
||||
}
|
||||
|
||||
int endbeat = int.MinValue;
|
||||
for (int i = 0; i < _Lines.Count; i++)
|
||||
{
|
||||
if (_Lines[i].LastNoteBeat < endbeat)
|
||||
endbeat = _Lines[i].LastNoteBeat;
|
||||
}
|
||||
int startbeat = _Lines.Max(line => line.FirstNoteBeat);
|
||||
int endbeat = _Lines.Min(line => line.LastNoteBeat);
|
||||
|
||||
int result = endbeat - startbeat;
|
||||
if (result > 0)
|
||||
@@ -609,13 +599,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
{
|
||||
get
|
||||
{
|
||||
int num = 0;
|
||||
foreach (CLine line in _Lines)
|
||||
{
|
||||
if (line.Points > 0f)
|
||||
num++;
|
||||
}
|
||||
return num;
|
||||
return _Lines.Count(line => line.Points > 0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -195,13 +195,13 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
public void Reset()
|
||||
{
|
||||
_PlayerNotes.Clear();
|
||||
_ActID = 0;
|
||||
}
|
||||
|
||||
public virtual int AddPlayer(SRectF rect, SColorF color, int playerNr)
|
||||
public int AddPlayer(SRectF rect, SColorF color, int playerNr)
|
||||
{
|
||||
SPlayerNotes notes = new SPlayerNotes
|
||||
{
|
||||
@@ -224,9 +224,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
return notes.ID;
|
||||
}
|
||||
|
||||
public virtual void RemovePlayer(int id) {}
|
||||
|
||||
public virtual void AddLine(int id, CLine[] line, int lineNr, int player)
|
||||
public void AddLine(int id, CLine[] line, int lineNr)
|
||||
{
|
||||
if (line == null)
|
||||
return;
|
||||
@@ -238,11 +236,11 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
if (lineNr == _PlayerNotes[n].LineNr)
|
||||
return;
|
||||
|
||||
SPlayerNotes notes = _PlayerNotes[n];
|
||||
|
||||
if (line.Length <= lineNr)
|
||||
return;
|
||||
|
||||
SPlayerNotes notes = _PlayerNotes[n];
|
||||
|
||||
notes.Lines = line;
|
||||
notes.LineNr = lineNr;
|
||||
notes.GoldenStars.Clear();
|
||||
@@ -253,11 +251,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
_PlayerNotes.Add(notes);
|
||||
}
|
||||
|
||||
public virtual void RemoveLine(int id) {}
|
||||
|
||||
public virtual void AddNote(int id, CNote note) {}
|
||||
|
||||
public virtual void SetAlpha(int id, float alpha)
|
||||
public void SetAlpha(int id, float alpha)
|
||||
{
|
||||
int n = _FindPlayerLine(id);
|
||||
if (n == -1)
|
||||
@@ -268,7 +262,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
_PlayerNotes[n] = pn;
|
||||
}
|
||||
|
||||
public virtual float GetAlpha(int id)
|
||||
public float GetAlpha(int id)
|
||||
{
|
||||
int n = _FindPlayerLine(id);
|
||||
if (n == -1)
|
||||
@@ -277,12 +271,12 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
return _PlayerNotes[n].Alpha;
|
||||
}
|
||||
|
||||
public virtual void Draw(int id, int player)
|
||||
public void Draw(int id, int player)
|
||||
{
|
||||
Draw(id, null, player);
|
||||
}
|
||||
|
||||
public virtual void Draw(int id, List<CLine> singLine, int player)
|
||||
public void Draw(int id, List<CLine> singLine, int player)
|
||||
{
|
||||
int n = _FindPlayerLine(id);
|
||||
if (n == -1)
|
||||
@@ -463,9 +457,6 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
|
||||
private int _FindPlayerLine(int id)
|
||||
{
|
||||
if (id < 0 || id > _PlayerNotes.Count)
|
||||
return -1;
|
||||
|
||||
for (int i = 0; i < _PlayerNotes.Count; i++)
|
||||
{
|
||||
if (_PlayerNotes[i].ID == id)
|
||||
|
||||
Reference in new issue
Block a user