Many cleanups according to ReSharper suggestions (Mostly redundant code)
Minor Bug fixes
This commit is contained in:
1 parent
9aa81b7ba2
commit
dcbbc5caf3
96 files changed
+2702
-3322
No files matched your search
+74
-100
@@ -58,7 +58,6 @@ namespace VocaluxeLib.Menu
|
||||
private float _H;
|
||||
|
||||
private float _Width;
|
||||
private ELyricStyle _Style;
|
||||
|
||||
private float _Alpha = 1f;
|
||||
|
||||
@@ -70,7 +69,7 @@ namespace VocaluxeLib.Menu
|
||||
public SRectF Rect
|
||||
{
|
||||
get { return new SRectF(_X, _Y, _MaxW, _H, _Z); }
|
||||
set
|
||||
private set
|
||||
{
|
||||
_X = value.X;
|
||||
_Y = value.Y;
|
||||
@@ -80,8 +79,8 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
}
|
||||
|
||||
public SColorF Color;
|
||||
public SColorF ColorProcessed;
|
||||
private SColorF _Color;
|
||||
private SColorF _ColorProcessed;
|
||||
|
||||
public bool Selected;
|
||||
public bool Visible = true;
|
||||
@@ -96,19 +95,15 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
}
|
||||
|
||||
public ELyricStyle LyricStyle
|
||||
{
|
||||
get { return _Style; }
|
||||
set { _Style = value; }
|
||||
}
|
||||
public ELyricStyle LyricStyle { get; set; }
|
||||
|
||||
public CLyric(int partyModeID)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_Theme = new SThemeLyrics();
|
||||
_ThemeLoaded = false;
|
||||
Color = new SColorF();
|
||||
ColorProcessed = new SColorF();
|
||||
_Color = new SColorF();
|
||||
_ColorProcessed = new SColorF();
|
||||
|
||||
_X = 0f;
|
||||
_Y = 0f;
|
||||
@@ -119,7 +114,7 @@ namespace VocaluxeLib.Menu
|
||||
_Notes = new List<SNote>();
|
||||
_Text = new CText(_PartyModeID);
|
||||
|
||||
_Style = ELyricStyle.Fill;
|
||||
LyricStyle = ELyricStyle.Fill;
|
||||
}
|
||||
|
||||
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
|
||||
@@ -133,31 +128,31 @@ namespace VocaluxeLib.Menu
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _MaxW);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _H);
|
||||
|
||||
if (xmlReader.GetValue(item + "/Color", ref _Theme.ColorName, String.Empty))
|
||||
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, skinIndex, out Color);
|
||||
if (xmlReader.GetValue(item + "/Color", out _Theme.ColorName, String.Empty))
|
||||
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorName, skinIndex, out _Color);
|
||||
else
|
||||
{
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _Color.R);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _Color.G);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _Color.B);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _Color.A);
|
||||
}
|
||||
|
||||
if (xmlReader.GetValue(item + "/SColor", ref _Theme.SelColorName, String.Empty))
|
||||
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.SelColorName, skinIndex, out ColorProcessed);
|
||||
if (xmlReader.GetValue(item + "/SColor", out _Theme.SelColorName, String.Empty))
|
||||
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.SelColorName, skinIndex, out _ColorProcessed);
|
||||
else
|
||||
{
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref ColorProcessed.R);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref ColorProcessed.G);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref ColorProcessed.B);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref ColorProcessed.A);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref _ColorProcessed.R);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref _ColorProcessed.G);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref _ColorProcessed.B);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref _ColorProcessed.A);
|
||||
}
|
||||
|
||||
if (_ThemeLoaded)
|
||||
{
|
||||
_Theme.Name = elementName;
|
||||
LoadTextures();
|
||||
_Text = new CText(_X, _Y, _Z, _H, _MaxW, EAlignment.Left, EStyle.Bold, "Normal", Color, String.Empty);
|
||||
_Text = new CText(_X, _Y, _Z, _H, _MaxW, EAlignment.Left, EStyle.Bold, "Normal", _Color, String.Empty);
|
||||
}
|
||||
return _ThemeLoaded;
|
||||
}
|
||||
@@ -181,10 +176,10 @@ namespace VocaluxeLib.Menu
|
||||
writer.WriteElementString("Color", _Theme.ColorName);
|
||||
else
|
||||
{
|
||||
writer.WriteElementString("R", Color.R.ToString("#0.00"));
|
||||
writer.WriteElementString("G", Color.G.ToString("#0.00"));
|
||||
writer.WriteElementString("B", Color.B.ToString("#0.00"));
|
||||
writer.WriteElementString("A", Color.A.ToString("#0.00"));
|
||||
writer.WriteElementString("R", _Color.R.ToString("#0.00"));
|
||||
writer.WriteElementString("G", _Color.G.ToString("#0.00"));
|
||||
writer.WriteElementString("B", _Color.B.ToString("#0.00"));
|
||||
writer.WriteElementString("A", _Color.A.ToString("#0.00"));
|
||||
}
|
||||
|
||||
writer.WriteComment("<SColor>: Highlighted lyric color from ColorScheme (high priority)");
|
||||
@@ -193,10 +188,10 @@ namespace VocaluxeLib.Menu
|
||||
writer.WriteElementString("SColor", _Theme.SelColorName);
|
||||
else
|
||||
{
|
||||
writer.WriteElementString("SR", ColorProcessed.R.ToString("#0.00"));
|
||||
writer.WriteElementString("SG", ColorProcessed.G.ToString("#0.00"));
|
||||
writer.WriteElementString("SB", ColorProcessed.B.ToString("#0.00"));
|
||||
writer.WriteElementString("SA", ColorProcessed.A.ToString("#0.00"));
|
||||
writer.WriteElementString("SR", _ColorProcessed.R.ToString("#0.00"));
|
||||
writer.WriteElementString("SG", _ColorProcessed.G.ToString("#0.00"));
|
||||
writer.WriteElementString("SB", _ColorProcessed.B.ToString("#0.00"));
|
||||
writer.WriteElementString("SA", _ColorProcessed.A.ToString("#0.00"));
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
@@ -213,13 +208,7 @@ namespace VocaluxeLib.Menu
|
||||
_Width = 0f;
|
||||
foreach (CNote note in line.Notes)
|
||||
{
|
||||
SNote n = new SNote();
|
||||
|
||||
n.Text = note.Text;
|
||||
n.StartBeat = note.StartBeat;
|
||||
n.EndBeat = note.EndBeat;
|
||||
n.Duration = note.Duration;
|
||||
n.Type = note.NoteType;
|
||||
SNote 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;
|
||||
@@ -248,7 +237,7 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
if (Visible || CBase.Settings.GetGameState() == EGameState.EditTheme)
|
||||
{
|
||||
switch (_Style)
|
||||
switch (LyricStyle)
|
||||
{
|
||||
case ELyricStyle.Fill:
|
||||
_DrawFill(actualBeat);
|
||||
@@ -287,28 +276,28 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
if (currentBeat <= note.EndBeat)
|
||||
{
|
||||
_Text.Color = ColorProcessed;
|
||||
_Text.Color = _ColorProcessed;
|
||||
|
||||
|
||||
float diff = note.EndBeat - note.StartBeat;
|
||||
if (diff == 0)
|
||||
if (Math.Abs(diff) < float.Epsilon)
|
||||
_Text.Draw(0f, 1f);
|
||||
else
|
||||
{
|
||||
_Text.Draw(0f, (currentBeat - note.StartBeat) / diff);
|
||||
_Text.Color = Color;
|
||||
_Text.Color = _Color;
|
||||
_Text.Draw((currentBeat - note.StartBeat) / diff, 1f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_Text.Color = ColorProcessed;
|
||||
_Text.Color = _ColorProcessed;
|
||||
_Text.Draw();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_Text.Color = Color;
|
||||
_Text.Color = _Color;
|
||||
_Text.Draw();
|
||||
}
|
||||
|
||||
@@ -344,7 +333,6 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (currentBeat >= _Notes[note].StartBeat)
|
||||
{
|
||||
bool last = note == _Notes.Count - 1;
|
||||
int endbeat = _Notes[note].EndBeat;
|
||||
if (note < _Notes.Count - 1)
|
||||
endbeat = _Notes[note + 1].StartBeat - 1;
|
||||
@@ -358,10 +346,7 @@ namespace VocaluxeLib.Menu
|
||||
else
|
||||
{
|
||||
// already passed
|
||||
if (note == lastNote)
|
||||
_Text.Color = ColorProcessed;
|
||||
else
|
||||
_Text.Color = Color;
|
||||
_Text.Color = note == lastNote ? _ColorProcessed : _Color;
|
||||
|
||||
_Text.Draw();
|
||||
}
|
||||
@@ -369,7 +354,7 @@ namespace VocaluxeLib.Menu
|
||||
else
|
||||
{
|
||||
// not passed
|
||||
_Text.Color = Color;
|
||||
_Text.Color = _Color;
|
||||
_Text.Draw();
|
||||
}
|
||||
|
||||
@@ -383,7 +368,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
_Text.X = zoomx;
|
||||
_Text.Text = _Notes[zoomNote].Text;
|
||||
_Text.Color = ColorProcessed;
|
||||
_Text.Color = _ColorProcessed;
|
||||
_Text.Style = EStyle.Bold;
|
||||
|
||||
if (_Notes[zoomNote].Type == ENoteType.Freestyle)
|
||||
@@ -437,13 +422,13 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (currentBeat >= note.StartBeat)
|
||||
{
|
||||
_Text.Color = ColorProcessed;
|
||||
_Text.Color = _ColorProcessed;
|
||||
_Text.Draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
// not passed
|
||||
_Text.Color = Color;
|
||||
_Text.Color = _Color;
|
||||
_Text.Draw();
|
||||
}
|
||||
|
||||
@@ -464,7 +449,6 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
int jumpNote = -1;
|
||||
int endBeat = -1;
|
||||
float jumpx = 0f;
|
||||
|
||||
for (int note = 0; note < _Notes.Count; note++)
|
||||
@@ -479,24 +463,15 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (currentBeat >= _Notes[note].StartBeat)
|
||||
{
|
||||
bool last = note == _Notes.Count - 1;
|
||||
int endbeat = _Notes[note].EndBeat;
|
||||
if (note < _Notes.Count - 1)
|
||||
endbeat = _Notes[note + 1].StartBeat - 1;
|
||||
|
||||
if (currentBeat <= _Notes[note].EndBeat)
|
||||
{
|
||||
jumpNote = note;
|
||||
endBeat = endbeat;
|
||||
jumpx = _Text.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
// already passed
|
||||
if (note == lastNote)
|
||||
_Text.Color = ColorProcessed;
|
||||
else
|
||||
_Text.Color = Color;
|
||||
_Text.Color = note == lastNote ? _ColorProcessed : _Color;
|
||||
|
||||
_Text.Draw();
|
||||
}
|
||||
@@ -504,45 +479,44 @@ namespace VocaluxeLib.Menu
|
||||
else
|
||||
{
|
||||
// not passed
|
||||
_Text.Color = Color;
|
||||
_Text.Color = _Color;
|
||||
_Text.Draw();
|
||||
}
|
||||
|
||||
x += rect.Width;
|
||||
}
|
||||
|
||||
if (jumpNote > -1)
|
||||
if (jumpNote < 0)
|
||||
return;
|
||||
if (_Notes[jumpNote].Duration == 0)
|
||||
return;
|
||||
|
||||
_Text.X = jumpx;
|
||||
_Text.Text = _Notes[jumpNote].Text;
|
||||
_Text.Color = _ColorProcessed;
|
||||
_Text.Style = EStyle.Bold;
|
||||
|
||||
if (_Notes[jumpNote].Type == ENoteType.Freestyle)
|
||||
_Text.Style = EStyle.BoldItalic;
|
||||
|
||||
float diff = _Notes[jumpNote].EndBeat - _Notes[jumpNote].StartBeat;
|
||||
if (diff <= 0f)
|
||||
diff = 1f;
|
||||
|
||||
float p = (currentBeat - _Notes[jumpNote].StartBeat) / diff;
|
||||
if (p > 1f)
|
||||
p = 1f;
|
||||
|
||||
p = 1f - p;
|
||||
|
||||
if (Math.Abs(diff - 1) < float.Epsilon)
|
||||
_Text.Draw();
|
||||
else
|
||||
{
|
||||
if (_Notes[jumpNote].Duration == 0)
|
||||
return;
|
||||
|
||||
_Text.X = jumpx;
|
||||
_Text.Text = _Notes[jumpNote].Text;
|
||||
_Text.Color = ColorProcessed;
|
||||
_Text.Style = EStyle.Bold;
|
||||
|
||||
if (_Notes[jumpNote].Type == ENoteType.Freestyle)
|
||||
_Text.Style = EStyle.BoldItalic;
|
||||
|
||||
float diff = _Notes[jumpNote].EndBeat - _Notes[jumpNote].StartBeat;
|
||||
if (diff <= 0f)
|
||||
diff = 1f;
|
||||
|
||||
float p = (currentBeat - _Notes[jumpNote].StartBeat) / diff;
|
||||
if (p > 1f)
|
||||
p = 1f;
|
||||
|
||||
p = 1f - p;
|
||||
|
||||
if (diff == 1)
|
||||
_Text.Draw();
|
||||
else
|
||||
{
|
||||
float y = _Text.Y;
|
||||
_Text.Y -= _Text.Height * 0.1f * p;
|
||||
_Text.Draw();
|
||||
_Text.Y = y;
|
||||
}
|
||||
float y = _Text.Y;
|
||||
_Text.Y -= _Text.Height * 0.1f * p;
|
||||
_Text.Draw();
|
||||
_Text.Y = y;
|
||||
}
|
||||
}
|
||||
#endregion draw
|
||||
@@ -552,10 +526,10 @@ namespace VocaluxeLib.Menu
|
||||
public void LoadTextures()
|
||||
{
|
||||
if (_Theme.ColorName.Length > 0)
|
||||
Color = CBase.Theme.GetColor(_Theme.ColorName, _PartyModeID);
|
||||
_Color = CBase.Theme.GetColor(_Theme.ColorName, _PartyModeID);
|
||||
|
||||
if (_Theme.SelColorName.Length > 0)
|
||||
ColorProcessed = CBase.Theme.GetColor(_Theme.SelColorName, _PartyModeID);
|
||||
_ColorProcessed = CBase.Theme.GetColor(_Theme.SelColorName, _PartyModeID);
|
||||
}
|
||||
|
||||
public void ReloadTextures()
|
||||
|
||||
Reference in new issue
Block a user