diff --git a/Vocaluxe/Menu/CPlaylist.cs b/Vocaluxe/Menu/CPlaylist.cs index f08574be..bea2e06d 100644 --- a/Vocaluxe/Menu/CPlaylist.cs +++ b/Vocaluxe/Menu/CPlaylist.cs @@ -149,14 +149,18 @@ namespace Vocaluxe.Menu } public EEditMode _EditMode; - public int ActivePlaylistID; - public int Offset; - public int CurrentPlaylistElement; + public int ActivePlaylistID = -1; + public int Offset = 0; + public int CurrentPlaylistElement = -1; - private PlaylistElement ChangeOrderElement; - private int ChangeOrderSource; - private int OldMousePosX; - private int OldMousePosY; + private PlaylistElement ChangeOrderElement = new PlaylistElement(); + private int ChangeOrderSource = -1; + private int OldMousePosX = 0; + private int OldMousePosY = 0; + + public int DragAndDropSongID = -1; + + //private static public CPlaylist() { @@ -198,15 +202,6 @@ namespace Vocaluxe.Menu _Interactions.AddButton(_Theme.ButtonPlaylistDelete); _Interactions.AddButton(_Theme.ButtonPlaylistSave); _Interactions.AddButton(_Theme.ButtonPlaylistSing); - - ActivePlaylistID = -1; - Offset = 0; - CurrentPlaylistElement = -1; - - ChangeOrderElement = new PlaylistElement(); - OldMousePosX = 0; - OldMousePosY = 0; - ChangeOrderSource = -1; } public bool LoadTheme(string XmlPath, string ElementName, XPathNavigator navigator, int SkinIndex) @@ -430,17 +425,42 @@ namespace Vocaluxe.Menu public void UnloadTextures() { + _Theme.Text1.UnloadTextures(); + _Theme.ButtonPlaylistClose.UnloadTextures(); + _Theme.ButtonPlaylistDelete.UnloadTextures(); + _Theme.ButtonPlaylistName.UnloadTextures(); + _Theme.ButtonPlaylistSave.UnloadTextures(); + _Theme.ButtonPlaylistSing.UnloadTextures(); + + _Theme.StaticCover.UnloadTextures(); + _Theme.StaticPlaylistFooter.UnloadTextures(); + _Theme.StaticPlaylistHeader.UnloadTextures(); + + _Theme.SelectSlideGameMode.UnloadTextures(); } public void LoadTextures() { - _Theme.Text1.LoadTextures(); - if (_Theme.ColorBackgroundName != String.Empty) BackgroundColor = CTheme.GetColor(_Theme.ColorBackgroundName); if (_Theme.SColorBackgroundName != String.Empty) BackgroundSColor = CTheme.GetColor(_Theme.SColorBackgroundName); + + _Theme.Text1.LoadTextures(); + _Theme.ButtonPlaylistClose.LoadTextures(); + _Theme.ButtonPlaylistDelete.LoadTextures(); + _Theme.ButtonPlaylistName.LoadTextures(); + _Theme.ButtonPlaylistSave.LoadTextures(); + _Theme.ButtonPlaylistSing.LoadTextures(); + + _Theme.StaticCover.LoadTextures(); + _Theme.StaticPlaylistFooter.LoadTextures(); + _Theme.StaticPlaylistHeader.LoadTextures(); + + _Theme.SelectSlideGameMode.LoadTextures(); + + Init(); } public void ReloadTextures() @@ -906,7 +926,7 @@ namespace Vocaluxe.Menu } //Change order with holding LB - if (MouseEvent.LBH && CurrentPlaylistElement != -1 && PlaylistElementContents.Count > 1) + if (MouseEvent.LBH && CurrentPlaylistElement != -1 && PlaylistElementContents.Count > 1 && DragAndDropSongID == -1) { ChangeOrderSource = CurrentPlaylistElement + Offset; @@ -932,6 +952,56 @@ namespace Vocaluxe.Menu _EditMode = EEditMode.ChangeOrder; } + if (!MouseEvent.LBH && DragAndDropSongID != -1) + { + EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; + CSong song = CSongs.GetSong(DragAndDropSongID); + + if (song != null) + { + if (song.IsDuet) + gm = EGameMode.TR_GAMEMODE_DUET; + + if (CurrentPlaylistElement != -1) + { + CPlaylists.Playlists[ActivePlaylistID].SongInsert(CurrentPlaylistElement, DragAndDropSongID, gm); + UpdatePlaylist(); + } + else + { + if (MouseEvent.Y < PlaylistElements[0].Background.Rect.Y && Offset == 0) + { + CPlaylists.Playlists[ActivePlaylistID].SongInsert(0, DragAndDropSongID, gm); + UpdatePlaylist(); + } + else + { + if (PlaylistElements.Count + Offset >= PlaylistElementContents.Count) + { + float min = 0f; + for (int i = PlaylistElements.Count - 1; i >= 0; i--) + { + if (PlaylistElements[i].SelectSlide.Visible) + { + min = PlaylistElements[i].SelectSlide.Rect.Y + PlaylistElements[i].SelectSlide.Rect.H; + break; + } + } + + if (MouseEvent.Y > min) + { + CPlaylists.Playlists[ActivePlaylistID].AddSong(DragAndDropSongID, gm); + UpdatePlaylist(); + ScrollToBottom(); + } + } + } + DragAndDropSongID = -1; + UpdatePlaylist(); + } + } + } + break; case EEditMode.PlaylistName: diff --git a/Vocaluxe/Menu/SongMenu/CSongMenu.cs b/Vocaluxe/Menu/SongMenu/CSongMenu.cs index 7f437ab0..ee16ee9c 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenu.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenu.cs @@ -88,6 +88,11 @@ namespace Vocaluxe.Menu.SongMenu return _SongMenu.GetSelectedSong(); } + public CStatic GetSelectedSongCover() + { + return _SongMenu.GetSelectedSongCover(); + } + public void SetSelectedSong(int VisibleSongNr) { _SongMenu.SetSelectedSong(VisibleSongNr); diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs index 5dbfe865..75cdcd9c 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs @@ -525,6 +525,11 @@ namespace Vocaluxe.Menu.SongMenu return -1; } + public virtual CStatic GetSelectedSongCover() + { + return new CStatic(); + } + public virtual int GetSelectedCategory() { return -1; diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs index 10a86dbb..dc5c4d4f 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs @@ -499,6 +499,16 @@ namespace Vocaluxe.Menu.SongMenu return _Locked; } + public override CStatic GetSelectedSongCover() + { + foreach (CStatic tile in _Tiles) + { + if (tile.Selected) + return new CStatic(tile); + } + return new CStatic(); + } + public override void SetSelectedSong(int VisibleSongNr) { base.SetSelectedSong(VisibleSongNr); diff --git a/Vocaluxe/Menu/SongMenu/ISongMenu.cs b/Vocaluxe/Menu/SongMenu/ISongMenu.cs index a859e84b..edb1142d 100644 --- a/Vocaluxe/Menu/SongMenu/ISongMenu.cs +++ b/Vocaluxe/Menu/SongMenu/ISongMenu.cs @@ -18,6 +18,7 @@ namespace Vocaluxe.Menu.SongMenu void Draw(); int GetSelectedSong(); + CStatic GetSelectedSongCover(); void SetSelectedSong(int VisibleSongNr); bool IsActive(); diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index b559b027..58ca96ad 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -58,6 +58,11 @@ namespace Vocaluxe.Screens private bool _PlaylistActive = false; private List _AvailableGameModes; + private CStatic DragAndDropCover; + private bool DragAndDropActive; + private int OldMousePosX; + private int OldMousePosY; + public CScreenSong() { Init(); @@ -96,6 +101,8 @@ namespace Vocaluxe.Screens Statics[htStatics(StaticOptionsBG)].Visible = false; Playlists[htPlaylists(Playlist)].Visible = false; + DragAndDropCover = new CStatic(); + Playlists[htPlaylists(Playlist)].Init(); } @@ -294,6 +301,14 @@ namespace Vocaluxe.Screens { base.HandleMouse(MouseEvent); + if (DragAndDropActive) + { + DragAndDropCover.Rect.X += MouseEvent.X - OldMousePosX; + DragAndDropCover.Rect.Y += MouseEvent.Y - OldMousePosY; + } + OldMousePosX = MouseEvent.X; + OldMousePosY = MouseEvent.Y; + if (Playlists[htPlaylists(Playlist)].Visible && Playlists[htPlaylists(Playlist)].IsMouseOver(MouseEvent)) { _PlaylistActive = true; @@ -327,7 +342,14 @@ namespace Vocaluxe.Screens else SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent); - if (MouseEvent.LB && CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) + if (MouseEvent.LBH && !DragAndDropActive && Playlists[htPlaylists(Playlist)].Visible && CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) + { + DragAndDropCover = SongMenus[htSongMenus(SongMenu)].GetSelectedSongCover(); + DragAndDropCover.Rect.Z = CSettings.zNear; + Playlists[htPlaylists(Playlist)].DragAndDropSongID = CSongs.VisibleSongs[SongMenus[htSongMenus(SongMenu)].GetActualSelection()].ID; + DragAndDropActive = true; + } + else if (MouseEvent.LB && CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) { if (SongMenus[htSongMenus(SongMenu)].GetSelectedSong() != -1 && !_SongOptionsActive) { @@ -342,7 +364,6 @@ namespace Vocaluxe.Screens } } } - else { if (MouseEvent.LB && IsMouseOver(MouseEvent)) @@ -388,6 +409,12 @@ namespace Vocaluxe.Screens } } + if (!MouseEvent.LBH && DragAndDropActive) + { + DragAndDropActive = false; + Playlists[htPlaylists(Playlist)].DragAndDropSongID = -1; + } + return true; } @@ -397,10 +424,14 @@ namespace Vocaluxe.Screens CGame.EnterNormalGame(); SongMenus[htSongMenus(SongMenu)].OnShow(); SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive); - + SongMenus[htSongMenus(SongMenu)].SetSmallView(Playlists[htPlaylists(Playlist)].Visible); + if (Playlists[htPlaylists(Playlist)].ActivePlaylistID != -1) Playlists[htPlaylists(Playlist)].LoadPlaylist(Playlists[htPlaylists(Playlist)].ActivePlaylistID); UpdatePlaylistNames(); + + DragAndDropActive = false; + Playlists[htPlaylists(Playlist)].DragAndDropSongID = -1; } public override bool UpdateGame() @@ -451,6 +482,10 @@ namespace Vocaluxe.Screens public override bool Draw() { base.Draw(); + + if (DragAndDropActive) + DragAndDropCover.Draw(); + return true; }