More refactoring (mainly LINQ)

This commit is contained in:
Flamefire committed 2013-04-24 00:41:08 +02:00
1 parent 181490fa87
commit b1e28ae7bc
43 files changed
+488 -662

No files matched your search

+57 -57
View File
@@ -45,17 +45,17 @@ namespace VocaluxeLib.Menu
public SColorF Color;
public SColorF SelColor;
public bool IsSelText;
public CText Text;
public CText SelText;
private bool _IsSelText;
public readonly CText Text;
private readonly CText _SelText;
public bool Reflection;
public float ReflectionSpace;
public float ReflectionHeight;
private bool _Reflection;
private float _ReflectionSpace;
private float _ReflectionHeight;
public bool SelReflection;
public float SelReflectionSpace;
public float SelReflectionHeight;
private bool _SelReflection;
private float _SelReflectionSpace;
private float _SelReflectionHeight;
public bool Pressed;
@@ -65,7 +65,7 @@ namespace VocaluxeLib.Menu
set
{
Text.EditMode = value;
SelText.EditMode = value;
_SelText.EditMode = value;
}
}
@@ -97,21 +97,21 @@ namespace VocaluxeLib.Menu
Texture = new STexture(-1);
SelTexture = new STexture(-1);
IsSelText = false;
_IsSelText = false;
Text = new CText(_PartyModeID);
SelText = new CText(_PartyModeID);
_SelText = new CText(_PartyModeID);
Selected = false;
Visible = true;
EditMode = false;
Enabled = true;
Reflection = false;
ReflectionSpace = 0f;
ReflectionHeight = 0f;
_Reflection = false;
_ReflectionSpace = 0f;
_ReflectionHeight = 0f;
SelReflection = false;
SelReflectionSpace = 0f;
SelReflectionHeight = 0f;
_SelReflection = false;
_SelReflectionSpace = 0f;
_SelReflectionHeight = 0f;
}
public CButton(CButton button)
@@ -131,22 +131,22 @@ namespace VocaluxeLib.Menu
Texture = button.Texture;
SelTexture = button.SelTexture;
IsSelText = false;
_IsSelText = false;
Text = new CText(button.Text);
SelText = new CText(button.SelText);
_SelText = new CText(button._SelText);
Selected = false;
Visible = true;
EditMode = false;
_ThemeLoaded = false;
Enabled = button.Enabled;
Reflection = button.Reflection;
ReflectionHeight = button.ReflectionHeight;
ReflectionSpace = button.ReflectionSpace;
_Reflection = button._Reflection;
_ReflectionHeight = button._ReflectionHeight;
_ReflectionSpace = button._ReflectionSpace;
SelReflection = button.SelReflection;
SelReflectionHeight = button.SelReflectionHeight;
SelReflectionSpace = button.SelReflectionSpace;
_SelReflection = button._SelReflection;
_SelReflectionHeight = button._SelReflectionHeight;
_SelReflectionSpace = button._SelReflectionSpace;
}
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
@@ -187,30 +187,30 @@ namespace VocaluxeLib.Menu
Text.Z = Rect.Z;
if (xmlReader.ItemExists(item + "/SText"))
{
IsSelText = true;
_ThemeLoaded &= SelText.LoadTheme(item, "SText", xmlReader, skinIndex, true);
SelText.Z = Rect.Z;
_IsSelText = true;
_ThemeLoaded &= _SelText.LoadTheme(item, "SText", xmlReader, skinIndex, true);
_SelText.Z = Rect.Z;
}
//Reflections
if (xmlReader.ItemExists(item + "/Reflection"))
{
Reflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref ReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref ReflectionHeight);
_Reflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
}
else
Reflection = false;
_Reflection = false;
if (xmlReader.ItemExists(item + "/SReflection"))
{
SelReflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Space", ref SelReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Height", ref SelReflectionHeight);
_SelReflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Space", ref _SelReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Height", ref _SelReflectionHeight);
}
else
SelReflection = false;
_SelReflection = false;
if (_ThemeLoaded)
{
@@ -264,28 +264,28 @@ namespace VocaluxeLib.Menu
}
Text.SaveTheme(writer);
if (IsSelText)
SelText.SaveTheme(writer);
if (_IsSelText)
_SelText.SaveTheme(writer);
writer.WriteComment("<Reflection> If exists:");
writer.WriteComment(" <Space>: Reflection Space");
writer.WriteComment(" <Height>: Reflection Height");
if (Reflection)
if (_Reflection)
{
writer.WriteStartElement("Reflection");
writer.WriteElementString("Space", ReflectionSpace.ToString("#0"));
writer.WriteElementString("Height", ReflectionHeight.ToString("#0"));
writer.WriteElementString("Space", _ReflectionSpace.ToString("#0"));
writer.WriteElementString("Height", _ReflectionHeight.ToString("#0"));
writer.WriteEndElement();
}
writer.WriteComment("<SReflection> If exists:");
writer.WriteComment(" <Space>: Reflection Space of selected button");
writer.WriteComment(" <Height>: Reflection Height of selected button");
if (SelReflection)
if (_SelReflection)
{
writer.WriteStartElement("SReflection");
writer.WriteElementString("Space", ReflectionSpace.ToString("#0"));
writer.WriteElementString("Height", ReflectionHeight.ToString("#0"));
writer.WriteElementString("Space", _ReflectionSpace.ToString("#0"));
writer.WriteElementString("Height", _ReflectionHeight.ToString("#0"));
writer.WriteEndElement();
}
@@ -309,41 +309,41 @@ namespace VocaluxeLib.Menu
CBase.Drawing.DrawTexture(texture, Rect, Color);
if (Reflection)
if (_Reflection)
{
CBase.Drawing.DrawTextureReflection(texture, Rect, Color, Rect, ReflectionSpace, ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, ReflectionSpace, ReflectionHeight, Rect.H);
CBase.Drawing.DrawTextureReflection(texture, Rect, Color, Rect, _ReflectionSpace, _ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, _ReflectionSpace, _ReflectionHeight, Rect.H);
}
else
Text.DrawRelative(Rect.X, Rect.Y);
}
else if (!IsSelText)
else if (!_IsSelText)
{
texture = Texture.Index != -1 ? Texture : CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID);
CBase.Drawing.DrawTexture(texture, Rect, SelColor);
if (Reflection)
if (_Reflection)
{
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, ReflectionSpace, ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, ReflectionSpace, ReflectionHeight, Rect.H);
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, _ReflectionSpace, _ReflectionHeight, Rect.H);
}
else
Text.DrawRelative(Rect.X, Rect.Y);
}
else if (IsSelText)
else if (_IsSelText)
{
texture = SelTexture.Index != -1 ? SelTexture : CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID);
CBase.Drawing.DrawTexture(texture, Rect, SelColor);
if (Reflection)
if (_Reflection)
{
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, ReflectionSpace, ReflectionHeight);
SelText.DrawRelative(Rect.X, Rect.Y, ReflectionSpace, ReflectionHeight, Rect.H);
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
_SelText.DrawRelative(Rect.X, Rect.Y, _ReflectionSpace, _ReflectionHeight, Rect.H);
}
else
SelText.DrawRelative(Rect.X, Rect.Y);
_SelText.DrawRelative(Rect.X, Rect.Y);
}
}
+225 -220
View File
@@ -500,56 +500,141 @@ namespace VocaluxeLib.Menu
{
if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode))
_Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text + keyEvent.Unicode;
else if (keyEvent.Key == Keys.Enter)
else switch (keyEvent.Key)
{
CBase.Playlist.SetPlaylistName(ActivePlaylistID, _Theme.ButtonPlaylistName.Text.Text);
CBase.Playlist.SavePlaylist(ActivePlaylistID);
EditMode = EEditMode.None;
_Theme.ButtonPlaylistName.EditMode = false;
}
else if (keyEvent.Key == Keys.Escape)
{
_Theme.ButtonPlaylistName.Text.Text = CBase.Playlist.GetPlaylistName(ActivePlaylistID);
EditMode = EEditMode.None;
_Theme.ButtonPlaylistName.EditMode = false;
}
else if (keyEvent.Key == Keys.Back || keyEvent.Key == Keys.Delete)
{
if (_Theme.ButtonPlaylistName.Text.Text != "")
_Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text.Remove(_Theme.ButtonPlaylistName.Text.Text.Length - 1);
case Keys.Enter:
CBase.Playlist.SetPlaylistName(ActivePlaylistID, _Theme.ButtonPlaylistName.Text.Text);
CBase.Playlist.SavePlaylist(ActivePlaylistID);
EditMode = EEditMode.None;
_Theme.ButtonPlaylistName.EditMode = false;
break;
case Keys.Escape:
_Theme.ButtonPlaylistName.Text.Text = CBase.Playlist.GetPlaylistName(ActivePlaylistID);
EditMode = EEditMode.None;
_Theme.ButtonPlaylistName.EditMode = false;
break;
case Keys.Delete:
case Keys.Back:
if (_Theme.ButtonPlaylistName.Text.Text != "")
_Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text.Remove(_Theme.ButtonPlaylistName.Text.Text.Length - 1);
break;
}
return true;
}
else
if (CurrentPlaylistElement == -1 || _PlaylistElementContents.Count == 0)
{
if (CurrentPlaylistElement == -1 || _PlaylistElementContents.Count == 0)
{
//no song is selected
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
//no song is selected
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
if (CurrentPlaylistElement != -1)
return true;
}
else if (CurrentPlaylistElement != -1)
{
//a song is selected
int scrollLimit = _PlaylistElements.Count / 2;
if (CurrentPlaylistElement != -1)
return true;
}
else if (CurrentPlaylistElement != -1)
{
//a song is selected
int scrollLimit = _PlaylistElements.Count / 2;
//special actions if a song is selected
switch (keyEvent.Key)
{
case Keys.Up:
if (keyEvent.ModShift)
//special actions if a song is selected
switch (keyEvent.Key)
{
case Keys.Up:
if (keyEvent.ModShift)
{
_Interactions.SetInteractionToSelectSlide(_PlaylistElements[0].SelectSlide);
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
else if (CurrentPlaylistElement > scrollLimit || _PlaylistElementContents.Count == 0)
{
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
else if (CurrentPlaylistElement <= scrollLimit)
{
if (Offset > 0)
{
Offset--;
Update();
}
else
{
_Interactions.SetInteractionToSelectSlide(_PlaylistElements[0].SelectSlide);
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
else if (CurrentPlaylistElement > scrollLimit || _PlaylistElementContents.Count == 0)
}
break;
case Keys.Down:
if (keyEvent.ModShift)
{
for (int i = _PlaylistElements.Count - 1; i >= 0; i--)
{
if (_PlaylistElements[i].SelectSlide.Visible)
{
_Interactions.SetInteractionToSelectSlide(_PlaylistElements[0].SelectSlide);
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
}
}
else if (CurrentPlaylistElement >= scrollLimit)
{
if (Offset < _PlaylistElementContents.Count - _PlaylistElements.Count)
{
Offset++;
Update();
}
else
{
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
}
else if (CurrentPlaylistElement < scrollLimit)
{
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
break;
case Keys.Delete:
CBase.Playlist.DeletePlaylistSong(ActivePlaylistID, _PlaylistElements[CurrentPlaylistElement].Content);
UpdatePlaylist();
if (Offset > 0)
Offset--;
Update();
if (_PlaylistElementContents.Count - 1 < CurrentPlaylistElement)
CurrentPlaylistElement = _PlaylistElementContents.Count - 1;
if (CurrentPlaylistElement != -1)
_Interactions.SetInteractionToSelectSlide(_PlaylistElements[CurrentPlaylistElement].SelectSlide);
break;
case Keys.Back:
ClosePlaylist(); //really? or better global?
break;
case Keys.Enter:
_StartPlaylistSong(CurrentPlaylistElement);
break;
case Keys.Add: //move the selected song up
if (_PlaylistElementContents.Count > 1 && (CurrentPlaylistElement > 0 || Offset > 0))
{
CBase.Playlist.MovePlaylistSongUp(ActivePlaylistID, CurrentPlaylistElement + Offset);
UpdatePlaylist();
SKeyEvent key = new SKeyEvent {Key = Keys.Up};
if (CurrentPlaylistElement > scrollLimit)
{
_Interactions.HandleInput(key);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
else if (CurrentPlaylistElement <= scrollLimit)
{
if (Offset > 0)
@@ -559,26 +644,22 @@ namespace VocaluxeLib.Menu
}
else
{
_Interactions.HandleInput(keyEvent);
_Interactions.HandleInput(key);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
}
break;
}
break;
case Keys.Down:
if (keyEvent.ModShift)
{
for (int i = _PlaylistElements.Count - 1; i >= 0; i--)
{
if (_PlaylistElements[i].SelectSlide.Visible)
{
_Interactions.SetInteractionToSelectSlide(_PlaylistElements[0].SelectSlide);
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
}
}
else if (CurrentPlaylistElement >= scrollLimit)
case Keys.Subtract: //move the selected song down
if (_PlaylistElementContents.Count > 1 && CurrentPlaylistElement + Offset < _PlaylistElementContents.Count - 1)
{
CBase.Playlist.MovePlaylistSongDown(ActivePlaylistID, CurrentPlaylistElement + Offset);
UpdatePlaylist();
SKeyEvent key = new SKeyEvent {Key = Keys.Down};
if (CurrentPlaylistElement >= scrollLimit)
{
if (Offset < _PlaylistElementContents.Count - _PlaylistElements.Count)
{
@@ -587,203 +668,127 @@ namespace VocaluxeLib.Menu
}
else
{
_Interactions.HandleInput(keyEvent);
_Interactions.HandleInput(key);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
}
else if (CurrentPlaylistElement < scrollLimit)
{
_Interactions.HandleInput(keyEvent);
_Interactions.HandleInput(key);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
break;
}
break;
case Keys.Delete:
CBase.Playlist.DeletePlaylistSong(ActivePlaylistID, _PlaylistElements[CurrentPlaylistElement].Content);
UpdatePlaylist();
case Keys.PageUp: //scroll up
if (_PlaylistElementContents.Count > 0)
{
Offset -= _PlaylistElements.Count;
if (Offset > 0)
Offset--;
if (Offset < 0)
Offset = 0;
Update();
CurrentPlaylistElement = 0;
}
break;
case Keys.PageDown: //scroll down
if (_PlaylistElementContents.Count > 0)
{
Offset += _PlaylistElements.Count;
if (Offset > _PlaylistElementContents.Count - _PlaylistElements.Count)
Offset = _PlaylistElementContents.Count - _PlaylistElements.Count;
if (Offset < 0)
Offset = 0;
Update();
if (_PlaylistElementContents.Count - 1 < CurrentPlaylistElement)
CurrentPlaylistElement = _PlaylistElementContents.Count - 1;
if (CurrentPlaylistElement != -1)
_Interactions.SetInteractionToSelectSlide(_PlaylistElements[CurrentPlaylistElement].SelectSlide);
break;
case Keys.Back:
ClosePlaylist(); //really? or better global?
break;
case Keys.Enter:
_StartPlaylistSong(CurrentPlaylistElement);
break;
case Keys.Add: //move the selected song up
if (_PlaylistElementContents.Count > 1 && (CurrentPlaylistElement > 0 || Offset > 0))
for (int i = _PlaylistElements.Count - 1; i >= 0; i--)
{
CBase.Playlist.MovePlaylistSongUp(ActivePlaylistID, CurrentPlaylistElement + Offset);
UpdatePlaylist();
SKeyEvent key = new SKeyEvent {Key = Keys.Up};
if (CurrentPlaylistElement > scrollLimit)
if (_PlaylistElements[i].SelectSlide.Visible)
{
_Interactions.HandleInput(key);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
else if (CurrentPlaylistElement <= scrollLimit)
{
if (Offset > 0)
{
Offset--;
Update();
}
else
{
_Interactions.HandleInput(key);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
CurrentPlaylistElement = i;
break;
}
}
break;
}
break;
case Keys.Subtract: //move the selected song down
if (_PlaylistElementContents.Count > 1 && CurrentPlaylistElement + Offset < _PlaylistElementContents.Count - 1)
{
CBase.Playlist.MovePlaylistSongDown(ActivePlaylistID, CurrentPlaylistElement + Offset);
UpdatePlaylist();
case Keys.Left:
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
SKeyEvent key = new SKeyEvent {Key = Keys.Down};
if (CurrentPlaylistElement != -1)
{
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode =
_PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[_PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
UpdatePlaylist();
}
break;
if (CurrentPlaylistElement >= scrollLimit)
{
if (Offset < _PlaylistElementContents.Count - _PlaylistElements.Count)
{
Offset++;
Update();
}
else
{
_Interactions.HandleInput(key);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
}
else if (CurrentPlaylistElement < scrollLimit)
{
_Interactions.HandleInput(key);
CurrentPlaylistElement = _GetSelectedSelectionNr();
}
}
break;
case Keys.Right:
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
case Keys.PageUp: //scroll up
if (_PlaylistElementContents.Count > 0)
{
Offset -= _PlaylistElements.Count;
if (Offset < 0)
Offset = 0;
Update();
CurrentPlaylistElement = 0;
}
break;
case Keys.PageDown: //scroll down
if (_PlaylistElementContents.Count > 0)
{
Offset += _PlaylistElements.Count;
if (Offset > _PlaylistElementContents.Count - _PlaylistElements.Count)
Offset = _PlaylistElementContents.Count - _PlaylistElements.Count;
if (Offset < 0)
Offset = 0;
Update();
for (int i = _PlaylistElements.Count - 1; i >= 0; i--)
{
if (_PlaylistElements[i].SelectSlide.Visible)
{
CurrentPlaylistElement = i;
break;
}
}
}
break;
case Keys.Left:
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
if (CurrentPlaylistElement != -1)
{
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode =
_PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[_PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
UpdatePlaylist();
}
break;
case Keys.Right:
_Interactions.HandleInput(keyEvent);
CurrentPlaylistElement = _GetSelectedSelectionNr();
if (CurrentPlaylistElement != -1)
{
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode =
_PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[_PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
UpdatePlaylist();
}
break;
}
return true;
if (CurrentPlaylistElement != -1)
{
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode =
_PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[_PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
UpdatePlaylist();
}
break;
}
return true;
}
//default actions
switch (keyEvent.Key)
{
case Keys.Back:
if (_Theme.ButtonPlaylistName.Selected)
//default actions
switch (keyEvent.Key)
{
case Keys.Back:
if (_Theme.ButtonPlaylistName.Selected)
{
EditMode = EEditMode.PlaylistName;
_Theme.ButtonPlaylistName.EditMode = true;
}
else
ClosePlaylist();
break;
case Keys.Enter:
if (_Theme.ButtonPlaylistClose.Selected)
ClosePlaylist();
else if (_Theme.ButtonPlaylistSing.Selected)
_StartPlaylistSongs();
else if (_Theme.ButtonPlaylistSave.Selected)
CBase.Playlist.SavePlaylist(ActivePlaylistID);
else if (_Theme.ButtonPlaylistDelete.Selected)
{
CBase.Playlist.DeletePlaylist(ActivePlaylistID);
ClosePlaylist();
}
else if (_Theme.ButtonPlaylistName.Selected)
{
if (EditMode != EEditMode.PlaylistName)
{
EditMode = EEditMode.PlaylistName;
_Theme.ButtonPlaylistName.EditMode = true;
}
else
ClosePlaylist();
break;
case Keys.Enter:
if (_Theme.ButtonPlaylistClose.Selected)
ClosePlaylist();
else if (_Theme.ButtonPlaylistSing.Selected)
_StartPlaylistSongs();
else if (_Theme.ButtonPlaylistSave.Selected)
CBase.Playlist.SavePlaylist(ActivePlaylistID);
else if (_Theme.ButtonPlaylistDelete.Selected)
{
CBase.Playlist.DeletePlaylist(ActivePlaylistID);
ClosePlaylist();
EditMode = EEditMode.None;
_Theme.ButtonPlaylistName.EditMode = false;
}
else if (_Theme.ButtonPlaylistName.Selected)
{
if (EditMode != EEditMode.PlaylistName)
{
EditMode = EEditMode.PlaylistName;
_Theme.ButtonPlaylistName.EditMode = true;
}
else
{
EditMode = EEditMode.None;
_Theme.ButtonPlaylistName.EditMode = false;
}
}
break;
}
}
break;
case Keys.PageDown:
_SetSelectionToLastEntry();
break;
case Keys.PageUp:
_SetSelectionToFirstEntry();
break;
}
}
return true;
+1 -1
View File
@@ -115,7 +115,7 @@ namespace VocaluxeLib.Menu
private readonly List<SRectF> _ValueBounds = new List<SRectF>();
public bool WithTextures;
public readonly bool WithTextures;
private int _Selection = -1;
public int Selection
+6 -6
View File
@@ -40,13 +40,13 @@ namespace VocaluxeLib.Menu
public float Width;
public float Height;
public STextPosition(int dummy)
public STextPosition(float initVal)
{
X = 0f;
Y = 0f;
TextHeight = 0f;
Width = 0f;
Height = 0f;
X = initVal;
Y = initVal;
TextHeight = initVal;
Width = initVal;
Height = initVal;
}
}
+10
View File
@@ -95,10 +95,12 @@ namespace VocaluxeLib.Menu
public enum EColorDepth
{
// ReSharper disable UnusedMember.Global
Bit8 = 8,
Bit16 = 16,
Bit24 = 24,
Bit32 = 32
// ReSharper restore UnusedMember.Global
}
public enum ETextureQuality
@@ -339,4 +341,12 @@ namespace VocaluxeLib.Menu
ScreenNull = -1
}
public enum EPopupScreens
{
PopupPlayerControl = 0,
PopupVolumeControl = 1,
NoPopup = -1
}
}
+4 -20
View File
@@ -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);
}
}
+9 -18
View File
@@ -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)
+6 -4
View File
@@ -47,7 +47,7 @@ namespace VocaluxeLib.Menu.SongMenu
public class CCategory
{
public string Name = String.Empty;
public readonly string Name;
private STexture _CoverTextureSmall = new STexture(-1);
private STexture _CoverTextureBig = new STexture(-1);
private bool _CoverBigLoaded;
@@ -100,7 +100,9 @@ namespace VocaluxeLib.Menu.SongMenu
public float FadeInTime;
public float FadeOutTime;
// ReSharper disable UnusedParameter.Local
public SMedley(int dummy)
// ReSharper restore UnusedParameter.Local
{
Source = EMedleySource.None;
StartBeat = 0;
@@ -210,11 +212,11 @@ namespace VocaluxeLib.Menu.SongMenu
get { return Notes.Lines.Length > 1; }
}
public List<string> Edition = new List<string>();
public List<string> Genre = new List<string>();
public readonly List<string> Edition = new List<string>();
public readonly List<string> Genre = new List<string>();
public string Year = "";
public List<string> Language = new List<string>();
public readonly List<string> Language = new List<string>();
// Notes
public readonly CNotes Notes = new CNotes();
@@ -95,7 +95,7 @@ namespace VocaluxeLib.Menu.SongMenu
abstract class CSongMenuFramework : ISongMenu
{
protected int _PartyModeID;
protected readonly int _PartyModeID;
protected SThemeSongMenu _Theme;
private bool _ThemeLoaded;
@@ -164,7 +164,7 @@ namespace VocaluxeLib.Menu.SongMenu
}
}
protected virtual void _SetSelectedNow()
protected void _SetSelectedNow()
{
_Timer.Stop();
_Timer.Reset();
@@ -425,7 +425,7 @@ namespace VocaluxeLib.Menu.SongMenu
_Initialized = true;
}
public virtual void UpdateRect(SRectF rect)
public void UpdateRect(SRectF rect)
{
_Rect = rect;
Init();
@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using VocaluxeLib.PartyModes;
@@ -180,15 +181,7 @@ namespace VocaluxeLib.Menu.SongMenu
keyEvent.Key == Keys.PageDown || keyEvent.Key == Keys.PageUp))
return;
bool sel = false;
foreach (CStatic tile in _Tiles)
{
if (tile.Selected)
{
sel = true;
break;
}
}
bool sel = _Tiles.Any(tile => tile.Selected);
if ((_Locked == -1 || !sel) &&
(keyEvent.Key != Keys.Escape && keyEvent.Key != Keys.Back && keyEvent.Key != Keys.PageUp && keyEvent.Key != Keys.PageDown))
@@ -500,15 +493,7 @@ namespace VocaluxeLib.Menu.SongMenu
protected void _SetSelectedTile(int itemNr)
{
bool sel = false;
foreach (CStatic tile in _Tiles)
{
if (tile.Selected)
{
sel = true;
break;
}
}
bool sel = _Tiles.Any(tile => tile.Selected);
if (_Locked == -1 || !sel)
{
+25 -45
View File
@@ -137,15 +137,15 @@ namespace VocaluxeLib.Menu
#region Inputs
public struct SKeyEvent
{
public ESender Sender;
public bool ModAlt;
public bool ModShift;
public bool ModCtrl;
public bool KeyPressed;
public readonly ESender Sender;
public readonly bool ModAlt;
public readonly bool ModShift;
public readonly bool ModCtrl;
public readonly bool KeyPressed;
public bool Handled;
public Keys Key;
public Char Unicode;
public EModifier Mod;
public readonly Char Unicode;
public readonly EModifier Mod;
public SKeyEvent(ESender sender, bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key)
{
@@ -171,27 +171,25 @@ namespace VocaluxeLib.Menu
public struct SMouseEvent
{
public ESender Sender;
public readonly ESender Sender;
public bool Handled;
public int X;
public int Y;
public bool LB; //left button click
public bool LD; //left button double click
public bool RB; //right button click
public bool MB; //middle button click
public readonly int X;
public readonly int Y;
public readonly bool LB; //left button click
public readonly bool LD; //left button double click
public readonly bool RB; //right button click
public readonly bool MB; //middle button click
public bool LBH; //left button hold (when moving)
public bool RBH; //right button hold (when moving)
public bool MBH; //middle button hold (when moving)
public readonly bool LBH; //left button hold (when moving)
// ReSharper disable MemberCanBePrivate.Global
public readonly bool RBH; //right button hold (when moving)
public readonly bool MBH; //middle button hold (when moving)
// ReSharper restore MemberCanBePrivate.Global
public bool ModAlt;
public bool ModShift;
public bool ModCtrl;
public readonly EModifier Mod;
public readonly int Wheel;
public EModifier Mod;
public int Wheel;
public SMouseEvent(ESender sender, bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
public SMouseEvent(ESender sender, EModifier mod, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
{
Sender = sender;
Handled = false;
@@ -206,27 +204,7 @@ namespace VocaluxeLib.Menu
RBH = rbh;
MBH = mbh;
ModAlt = alt;
ModShift = shift;
ModCtrl = ctrl;
EModifier mAlt = EModifier.None;
EModifier mShift = EModifier.None;
EModifier mCtrl = EModifier.None;
if (alt)
mAlt = EModifier.Alt;
if (shift)
mShift = EModifier.Shift;
if (ctrl)
mCtrl = EModifier.Ctrl;
if (!alt && !shift && !ctrl)
Mod = EModifier.None;
else
Mod = mAlt | mShift | mCtrl;
Mod = mod;
Wheel = wheel;
}
@@ -250,7 +228,9 @@ namespace VocaluxeLib.Menu
public string FileName;
public STexture Texture;
// ReSharper disable UnusedParameter.Local
public SAvatar(int dummy)
// ReSharper restore UnusedParameter.Local
{
FileName = String.Empty;
Texture = new STexture(-1);