Auto cleanup of VocaluxeLib
This commit is contained in:
1 parent
b497b58740
commit
efab579188
37 files changed
+642
-1155
No files matched your search
@@ -21,7 +21,7 @@ namespace VocaluxeLib.Menu
|
||||
public CPlaylistSong(int SongID, EGameMode gm)
|
||||
{
|
||||
this.SongID = SongID;
|
||||
this.GameMode = gm;
|
||||
GameMode = gm;
|
||||
}
|
||||
|
||||
public CPlaylistSong()
|
||||
@@ -65,14 +65,14 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public class CPlaylist : IMenuElement
|
||||
{
|
||||
class PlaylistElementContent
|
||||
private class PlaylistElementContent
|
||||
{
|
||||
public EGameMode[] Modes;
|
||||
public int SongID;
|
||||
public EGameMode Mode;
|
||||
}
|
||||
|
||||
class PlaylistElement
|
||||
private class PlaylistElement
|
||||
{
|
||||
public CStatic Cover;
|
||||
public CStatic Background;
|
||||
@@ -80,9 +80,7 @@ namespace VocaluxeLib.Menu
|
||||
public CSelectSlide SelectSlide;
|
||||
public int Content;
|
||||
|
||||
public PlaylistElement()
|
||||
{
|
||||
}
|
||||
public PlaylistElement() {}
|
||||
|
||||
public PlaylistElement(PlaylistElement pe)
|
||||
{
|
||||
@@ -125,7 +123,8 @@ namespace VocaluxeLib.Menu
|
||||
Text1.Y += diffY;
|
||||
}
|
||||
}
|
||||
private int _PartyModeID;
|
||||
|
||||
private readonly int _PartyModeID;
|
||||
private SThemePlaylist _Theme;
|
||||
private bool _ThemeLoaded;
|
||||
|
||||
@@ -134,10 +133,10 @@ namespace VocaluxeLib.Menu
|
||||
return _Theme.Name;
|
||||
}
|
||||
|
||||
private CObjectInteractions _Interactions;
|
||||
private readonly CObjectInteractions _Interactions;
|
||||
|
||||
private List<PlaylistElement> PlaylistElements;
|
||||
private List<PlaylistElementContent> PlaylistElementContents;
|
||||
private readonly List<PlaylistElement> PlaylistElements;
|
||||
private readonly List<PlaylistElementContent> PlaylistElementContents;
|
||||
|
||||
public SRectF CompleteRect;
|
||||
public SRectF Rect;
|
||||
@@ -161,7 +160,7 @@ namespace VocaluxeLib.Menu
|
||||
if (_EditMode == EEditMode.ChangeOrder && ChangeOrderSource != -1 && PlaylistElements.Count > ChangeOrderSource)
|
||||
{
|
||||
CBase.Playlist.DeletePlaylistSong(ActivePlaylistID, PlaylistElements[ChangeOrderSource].Content);
|
||||
UpdatePlaylist();
|
||||
UpdatePlaylist();
|
||||
}
|
||||
ChangeOrderSource = -1;
|
||||
_EditMode = EEditMode.None;
|
||||
@@ -176,8 +175,8 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
private PlaylistElement ChangeOrderElement;
|
||||
private int ChangeOrderSource = -1;
|
||||
private int OldMousePosX = 0;
|
||||
private int OldMousePosY = 0;
|
||||
private int OldMousePosX;
|
||||
private int OldMousePosY;
|
||||
|
||||
public int DragAndDropSongID = -1;
|
||||
|
||||
@@ -210,7 +209,7 @@ namespace VocaluxeLib.Menu
|
||||
ChangeOrderElement = new PlaylistElement();
|
||||
|
||||
Visible = false;
|
||||
Selected = false;
|
||||
Selected = false;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
@@ -241,9 +240,7 @@ namespace VocaluxeLib.Menu
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref Rect.W);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref Rect.H);
|
||||
if (xmlReader.GetValue(item + "/ColorBackground", ref _Theme.ColorBackgroundName, String.Empty))
|
||||
{
|
||||
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.ColorBackgroundName, SkinIndex, out BackgroundColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundR", ref BackgroundColor.R);
|
||||
@@ -252,9 +249,7 @@ namespace VocaluxeLib.Menu
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundA", ref BackgroundColor.A);
|
||||
}
|
||||
if (xmlReader.GetValue(item + "/SColorBackground", ref _Theme.SColorBackgroundName, String.Empty))
|
||||
{
|
||||
_ThemeLoaded &= CBase.Theme.GetColor(_Theme.SColorBackgroundName, SkinIndex, out BackgroundSColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundR", ref BackgroundSColor.R);
|
||||
@@ -358,9 +353,7 @@ namespace VocaluxeLib.Menu
|
||||
writer.WriteComment("<ColorBackground>: Button color from ColorScheme (high priority)");
|
||||
writer.WriteComment("or <BackgroundR>, <BackgroundG>, <BackgroundB>, <BackgroundA> (lower priority)");
|
||||
if (_Theme.ColorBackgroundName.Length > 0)
|
||||
{
|
||||
writer.WriteElementString("ColorBackground", _Theme.ColorBackgroundName);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteElementString("BackgroundR", BackgroundColor.R.ToString("#0.00"));
|
||||
@@ -372,9 +365,7 @@ namespace VocaluxeLib.Menu
|
||||
writer.WriteComment("<SColorBackground>: Selected paylist-entry color from ColorScheme (high priority)");
|
||||
writer.WriteComment("or <SBackgroundR>, <SBackgroundG>, <SBackgroundB>, <SBackgroundA> (lower priority)");
|
||||
if (_Theme.SColorBackgroundName.Length > 0)
|
||||
{
|
||||
writer.WriteElementString("SColorBackground", _Theme.SColorBackgroundName);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteElementString("SBackgroundR", BackgroundSColor.R.ToString("#0.00"));
|
||||
@@ -394,7 +385,7 @@ namespace VocaluxeLib.Menu
|
||||
_Theme.ButtonPlaylistClose.SaveTheme(writer);
|
||||
_Theme.ButtonPlaylistDelete.SaveTheme(writer);
|
||||
_Theme.ButtonPlaylistSave.SaveTheme(writer);
|
||||
_Theme.ButtonPlaylistSing.SaveTheme(writer);
|
||||
_Theme.ButtonPlaylistSing.SaveTheme(writer);
|
||||
|
||||
writer.WriteEndElement();
|
||||
|
||||
@@ -416,13 +407,11 @@ namespace VocaluxeLib.Menu
|
||||
public void Draw(bool ForceDraw)
|
||||
{
|
||||
if (PlaylistElements.Count <= 0)
|
||||
{
|
||||
LoadPlaylist(0);
|
||||
}
|
||||
if (!Visible && CBase.Settings.GetGameState() != EGameState.EditTheme && !ForceDraw)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < PlaylistElements.Count; i++ )
|
||||
for (int i = 0; i < PlaylistElements.Count; i++)
|
||||
{
|
||||
if (i == CurrentPlaylistElement && _Selected)
|
||||
{
|
||||
@@ -500,9 +489,7 @@ namespace VocaluxeLib.Menu
|
||||
if (_EditMode == EEditMode.PlaylistName)
|
||||
{
|
||||
if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode))
|
||||
{
|
||||
_Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text + KeyEvent.Unicode;
|
||||
}
|
||||
else if (KeyEvent.Key == Keys.Enter)
|
||||
{
|
||||
CBase.Playlist.SetPlaylistName(ActivePlaylistID, _Theme.ButtonPlaylistName.Text.Text);
|
||||
@@ -524,7 +511,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CurrentPlaylistElement == -1 || PlaylistElementContents.Count == 0) //no song is selected
|
||||
if (CurrentPlaylistElement == -1 || PlaylistElementContents.Count == 0) //no song is selected
|
||||
{
|
||||
_Interactions.HandleInput(KeyEvent);
|
||||
CurrentPlaylistElement = GetSelectedSelectionNr();
|
||||
@@ -532,7 +519,7 @@ namespace VocaluxeLib.Menu
|
||||
if (CurrentPlaylistElement != -1)
|
||||
return true;
|
||||
}
|
||||
else if (CurrentPlaylistElement != -1) //a song is selected
|
||||
else if (CurrentPlaylistElement != -1) //a song is selected
|
||||
{
|
||||
int ScrollLimit = PlaylistElements.Count / 2;
|
||||
|
||||
@@ -609,9 +596,7 @@ namespace VocaluxeLib.Menu
|
||||
Update();
|
||||
|
||||
if (PlaylistElementContents.Count - 1 < CurrentPlaylistElement)
|
||||
{
|
||||
CurrentPlaylistElement = PlaylistElementContents.Count - 1;
|
||||
}
|
||||
|
||||
if (CurrentPlaylistElement != -1)
|
||||
_Interactions.SetInteractionToSelectSlide(PlaylistElements[CurrentPlaylistElement].SelectSlide);
|
||||
@@ -625,7 +610,7 @@ namespace VocaluxeLib.Menu
|
||||
StartPlaylistSong(CurrentPlaylistElement);
|
||||
break;
|
||||
|
||||
case Keys.Add: //move the selected song up
|
||||
case Keys.Add: //move the selected song up
|
||||
if (PlaylistElementContents.Count > 1 && (CurrentPlaylistElement > 0 || Offset > 0))
|
||||
{
|
||||
CBase.Playlist.MovePlaylistSongUp(ActivePlaylistID, CurrentPlaylistElement + Offset);
|
||||
@@ -685,7 +670,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
break;
|
||||
|
||||
case Keys.PageUp: //scroll up
|
||||
case Keys.PageUp: //scroll up
|
||||
if (PlaylistElementContents.Count > 0)
|
||||
{
|
||||
Offset -= PlaylistElements.Count;
|
||||
@@ -697,7 +682,7 @@ namespace VocaluxeLib.Menu
|
||||
CurrentPlaylistElement = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Keys.PageDown: //scroll down
|
||||
if (PlaylistElementContents.Count > 0)
|
||||
{
|
||||
@@ -728,7 +713,8 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (CurrentPlaylistElement != -1)
|
||||
{
|
||||
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode = PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
|
||||
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode =
|
||||
PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
|
||||
UpdatePlaylist();
|
||||
}
|
||||
break;
|
||||
@@ -739,14 +725,15 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (CurrentPlaylistElement != -1)
|
||||
{
|
||||
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode = PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
|
||||
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode =
|
||||
PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
|
||||
UpdatePlaylist();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//default actions
|
||||
switch (KeyEvent.Key)
|
||||
{
|
||||
@@ -762,17 +749,11 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
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);
|
||||
@@ -903,13 +884,11 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
}
|
||||
if (!hover_set)
|
||||
{
|
||||
CurrentPlaylistElement = -1;
|
||||
}
|
||||
|
||||
switch (_EditMode)
|
||||
{
|
||||
//Normal mode
|
||||
//Normal mode
|
||||
case EEditMode.None:
|
||||
|
||||
//LB actions
|
||||
@@ -917,7 +896,8 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
if (CurrentPlaylistElement != -1)
|
||||
{
|
||||
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode = PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
|
||||
CBase.Playlist.GetPlaylistSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode =
|
||||
PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection];
|
||||
UpdatePlaylist();
|
||||
}
|
||||
if (_Theme.ButtonPlaylistClose.Selected)
|
||||
@@ -951,14 +931,11 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
//Start selected song with double click
|
||||
if (MouseEvent.LD && CurrentPlaylistElement != -1)
|
||||
{
|
||||
StartPlaylistSong(CurrentPlaylistElement);
|
||||
}
|
||||
|
||||
//Change order with holding LB
|
||||
if (MouseEvent.LBH && CurrentPlaylistElement != -1 && PlaylistElementContents.Count > 0 && DragAndDropSongID == -1)
|
||||
{
|
||||
|
||||
ChangeOrderSource = CurrentPlaylistElement + Offset;
|
||||
|
||||
//Update of Drag/Drop-Texture
|
||||
@@ -1077,9 +1054,7 @@ namespace VocaluxeLib.Menu
|
||||
else if (CurrentPlaylistElement == -1)
|
||||
{
|
||||
if (MouseEvent.Y < PlaylistElements[0].Background.Rect.Y && Offset == 0)
|
||||
{
|
||||
CBase.Playlist.MovePlaylistSong(ActivePlaylistID, ChangeOrderSource, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlaylistElements.Count + Offset >= PlaylistElementContents.Count)
|
||||
@@ -1095,9 +1070,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
if (MouseEvent.Y > min)
|
||||
{
|
||||
CBase.Playlist.MovePlaylistSong(ActivePlaylistID, ChangeOrderSource, PlaylistElementContents.Count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1114,12 +1087,13 @@ namespace VocaluxeLib.Menu
|
||||
private void PrepareList()
|
||||
{
|
||||
PlaylistElements.Clear();
|
||||
|
||||
|
||||
for (int i = 0; i < Math.Floor(Rect.H / _Theme.EntryHeight); i++)
|
||||
{
|
||||
PlaylistElement en = new PlaylistElement();
|
||||
|
||||
en.Background = new CStatic(_PartyModeID, _Theme.TextureBackgroundName, BackgroundColor, new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z));
|
||||
en.Background = new CStatic(_PartyModeID, _Theme.TextureBackgroundName, BackgroundColor,
|
||||
new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z));
|
||||
|
||||
en.Cover = new CStatic(_Theme.StaticCover);
|
||||
en.Cover.Rect.Y += Rect.Y + (i * _Theme.EntryHeight);
|
||||
@@ -1147,7 +1121,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
}
|
||||
|
||||
public bool LoadPlaylist(int PlaylistID)
|
||||
public bool LoadPlaylist(int PlaylistID)
|
||||
{
|
||||
if (PlaylistID > -1 && PlaylistID < CBase.Playlist.GetNumPlaylists())
|
||||
{
|
||||
@@ -1180,11 +1154,10 @@ namespace VocaluxeLib.Menu
|
||||
pec.Mode = CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).GameMode;
|
||||
PlaylistElementContents.Add(pec);
|
||||
}
|
||||
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
public void ClosePlaylist()
|
||||
{
|
||||
Visible = false;
|
||||
@@ -1192,7 +1165,6 @@ namespace VocaluxeLib.Menu
|
||||
ActivePlaylistID = -1;
|
||||
}
|
||||
|
||||
|
||||
private void StartPlaylistSongs()
|
||||
{
|
||||
CBase.Game.Reset();
|
||||
@@ -1201,11 +1173,9 @@ namespace VocaluxeLib.Menu
|
||||
if (ActivePlaylistID > -1 && ActivePlaylistID < CBase.Playlist.GetNumPlaylists())
|
||||
{
|
||||
for (int i = 0; i < CBase.Playlist.GetPlaylistSongCount(ActivePlaylistID); i++)
|
||||
{
|
||||
CBase.Game.AddSong(CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).SongID, CBase.Playlist.GetPlaylistSong(ActivePlaylistID, i).GameMode);
|
||||
}
|
||||
if (CBase.Game.GetNumSongs() > 0)
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenNames); //TODO: What is if someone uses that in PartyMode?
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenNames); //TODO: What is if someone uses that in PartyMode?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1217,14 +1187,14 @@ namespace VocaluxeLib.Menu
|
||||
CBase.Game.AddSong(CBase.Playlist.GetPlaylistSong(ActivePlaylistID, selected).SongID, CBase.Playlist.GetPlaylistSong(ActivePlaylistID, selected).GameMode);
|
||||
|
||||
if (CBase.Game.GetNumSongs() > 0)
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenNames);
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenNames);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (ActivePlaylistID > -1 && ActivePlaylistID < CBase.Playlist.GetNumPlaylists())
|
||||
{
|
||||
for (int i = 0; i < PlaylistElements.Count; i++ )
|
||||
for (int i = 0; i < PlaylistElements.Count; i++)
|
||||
{
|
||||
if (Offset + i < PlaylistElementContents.Count)
|
||||
{
|
||||
@@ -1237,14 +1207,14 @@ namespace VocaluxeLib.Menu
|
||||
CSong song = CBase.Songs.GetSongByID(pec.SongID);
|
||||
PlaylistElements[i].Cover.Texture = song.CoverTextureSmall;
|
||||
string t1 = _Theme.Text1.Text.Replace("%a", song.Artist).Replace("%t", song.Title);
|
||||
PlaylistElements[i].Text1.Text = /*(Offset + i + 1).ToString() + ") " + */song.Artist + " - " + song.Title; //TODO: Add text field for the number
|
||||
PlaylistElements[i].Text1.Text = /*(Offset + i + 1).ToString() + ") " + */ song.Artist + " - " + song.Title; //TODO: Add text field for the number
|
||||
PlaylistElements[i].SelectSlide.Clear();
|
||||
for (int g = 0; g < pec.Modes.Length; g++)
|
||||
{
|
||||
PlaylistElements[i].SelectSlide.AddValue(Enum.GetName(typeof(EGameMode), pec.Modes[g]));
|
||||
if (pec.Modes[g] == pec.Mode)
|
||||
PlaylistElements[i].SelectSlide.SetSelectionByValueIndex(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1277,4 +1247,4 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
#endregion ThemeEdit
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user