added sort by mouse to playlists

This commit is contained in:
Alexander Eckart committed 2012-12-02 19:21:37 +01:00
1 parent 3a3baf6f4c
commit 193116f669
7 files changed
+230 -75

No files matched your search

+18 -2
View File
@@ -27,6 +27,12 @@ namespace Vocaluxe.Lib.Playlist
{ {
GameMode = EGameMode.TR_GAMEMODE_NORMAL; GameMode = EGameMode.TR_GAMEMODE_NORMAL;
} }
public CPlaylistSong(CPlaylistSong ps)
{
SongID = ps.SongID;
GameMode = ps.GameMode;
}
} }
public class CPlaylistFile public class CPlaylistFile
@@ -236,7 +242,7 @@ namespace Vocaluxe.Lib.Playlist
public void SongUp(int SongNr) public void SongUp(int SongNr)
{ {
if (SongNr != 0) if (SongNr < Songs.Count - 1 && SongNr > 0)
{ {
Songs.Reverse(SongNr - 1, 2); Songs.Reverse(SongNr - 1, 2);
} }
@@ -244,10 +250,20 @@ namespace Vocaluxe.Lib.Playlist
public void SongDown(int SongNr) public void SongDown(int SongNr)
{ {
if (SongNr < Songs.Count - 1) if (SongNr < Songs.Count - 1 && SongNr >= 0)
{ {
Songs.Reverse(SongNr, 2); Songs.Reverse(SongNr, 2);
} }
} }
public void SongMove(int SourceNr, int DestNr)
{
if (SourceNr < 0 || DestNr < 0 || SourceNr == DestNr || SourceNr > Songs.Count - 1 || DestNr > Songs.Count - 1)
return;
CPlaylistSong ps = new CPlaylistSong(Songs[SourceNr]);
Songs.RemoveAt(SourceNr);
Songs.Insert(DestNr, ps);
}
} }
} }
+151 -67
View File
@@ -63,6 +63,51 @@ namespace Vocaluxe.Menu
public CText Text1; public CText Text1;
public CSelectSlide SelectSlide; public CSelectSlide SelectSlide;
public int Content; public int Content;
public PlaylistElement()
{
}
public PlaylistElement(PlaylistElement pe)
{
Cover = new CStatic(pe.Cover);
Background = new CStatic(pe.Background);
Text1 = new CText(pe.Text1);
SelectSlide = new CSelectSlide(pe.SelectSlide);
Content = pe.Content;
}
public void Draw()
{
Background.Draw();
SelectSlide.Draw();
Cover.Draw();
Text1.Draw();
}
public void MouseMove(int PosX, int PosY, int OldPosX, int OldPosY)
{
int diffX = PosX - OldPosX;
int diffY = PosY - OldPosY;
Cover.Rect.X += diffX;
Cover.Rect.Y += diffY;
Background.Rect.X += diffX;
Background.Rect.Y += diffY;
SelectSlide.Rect.X += diffX;
SelectSlide.Rect.Y += diffY;
SelectSlide.RectArrowLeft.X += diffX;
SelectSlide.RectArrowLeft.Y += diffY;
SelectSlide.RectArrowRight.X += diffX;
SelectSlide.RectArrowRight.Y += diffY;
Text1.X += diffX;
Text1.Y += diffY;
}
} }
private SThemePlaylist _Theme; private SThemePlaylist _Theme;
@@ -93,17 +138,25 @@ namespace Vocaluxe.Menu
{ {
_Selected = value; _Selected = value;
_Interactions.Active = value; _Interactions.Active = value;
if (CurrentPlaylistElement == -1 && _Selected && PlaylistElementContents.Count > 0) CurrentPlaylistElement = GetSelectedSelectionNr();
if (!value)
{ {
CurrentPlaylistElement = 0; ChangeOrderSource = -1;
_EditMode = EEditMode.None;
} }
} }
} }
public EEditMode _EditMode; public EEditMode _EditMode;
public int ActivePlaylistID = -1; public int ActivePlaylistID;
public int Offset = 0; public int Offset;
public int CurrentPlaylistElement = -1; public int CurrentPlaylistElement;
private PlaylistElement ChangeOrderElement;
private int ChangeOrderSource;
private int OldMousePosX;
private int OldMousePosY;
public CPlaylist() public CPlaylist()
{ {
@@ -145,6 +198,15 @@ namespace Vocaluxe.Menu
_Interactions.AddButton(_Theme.ButtonPlaylistDelete); _Interactions.AddButton(_Theme.ButtonPlaylistDelete);
_Interactions.AddButton(_Theme.ButtonPlaylistSave); _Interactions.AddButton(_Theme.ButtonPlaylistSave);
_Interactions.AddButton(_Theme.ButtonPlaylistSing); _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) public bool LoadTheme(string XmlPath, string ElementName, XPathNavigator navigator, int SkinIndex)
@@ -355,8 +417,10 @@ namespace Vocaluxe.Menu
PlaylistElements[i].Background.Color = BackgroundColor; PlaylistElements[i].Background.Color = BackgroundColor;
} }
} }
_Interactions.Draw(); _Interactions.Draw();
if (_EditMode == EEditMode.ChangeOrder)
ChangeOrderElement.Draw();
} }
public bool IsMouseOver(MouseEvent MouseEvent) public bool IsMouseOver(MouseEvent MouseEvent)
@@ -755,31 +819,55 @@ namespace Vocaluxe.Menu
if (CHelper.IsInBounds(CompleteRect, MouseEvent) && Visible) if (CHelper.IsInBounds(CompleteRect, MouseEvent) && Visible)
{ {
//Scroll
if (MouseEvent.Wheel > 0)
{
if (PlaylistElements.Count + Offset + MouseEvent.Wheel <= PlaylistElementContents.Count)
{
Offset += MouseEvent.Wheel;
Update();
}
return true;
}
else if (MouseEvent.Wheel < 0)
{
if (Offset + MouseEvent.Wheel >= 0)
{
Offset += MouseEvent.Wheel;
Update();
}
return true;
}
bool hover_set = false;
for (int i = 0; i < PlaylistElements.Count; i++)
{
//Hover for playlist-element
if (PlaylistElementContents.Count - 1 >= i && CHelper.IsInBounds(PlaylistElements[i].Background.Rect, MouseEvent))
{
hover_set = true;
CurrentPlaylistElement = i;
_Interactions.SetInteractionToSelectSlide(PlaylistElements[CurrentPlaylistElement].SelectSlide);
}
//Delete Entry with RB
if (CHelper.IsInBounds(PlaylistElements[i].Background.Rect, MouseEvent) && MouseEvent.RB && PlaylistElements[i].Content != -1)
{
CPlaylists.Playlists[ActivePlaylistID].DeleteSong(PlaylistElements[i].Content);
UpdatePlaylist();
return true;
}
}
if (!hover_set)
{
CurrentPlaylistElement = -1;
}
switch (_EditMode) switch (_EditMode)
{ {
//Normal mode //Normal mode
case EEditMode.None: case EEditMode.None:
//Scroll
if (MouseEvent.Wheel > 0)
{
if (PlaylistElements.Count + Offset + MouseEvent.Wheel <= PlaylistElementContents.Count)
{
Offset += MouseEvent.Wheel;
Update();
return true;
}
return true;
}
else if (MouseEvent.Wheel < 0)
{
if (Offset + MouseEvent.Wheel >= 0)
{
Offset += MouseEvent.Wheel;
Update();
return true;
}
return true;
}
//LB actions //LB actions
if (MouseEvent.LB) if (MouseEvent.LB)
{ {
@@ -816,30 +904,34 @@ namespace Vocaluxe.Menu
return true; return true;
} }
} }
//Actions according to playlist-element
bool hover_set = false;
for (int i = 0; i < PlaylistElements.Count; i++)
{
//Hover for playlist-element
if (PlaylistElementContents.Count - 1 >= i && CHelper.IsInBounds(PlaylistElements[i].Background.Rect, MouseEvent))
{
hover_set = true;
CurrentPlaylistElement = i;
_Interactions.SetInteractionToSelectSlide(PlaylistElements[CurrentPlaylistElement].SelectSlide);
}
//Delete Entry with RB //Change order with holding LB
if (CHelper.IsInBounds(PlaylistElements[i].Background.Rect, MouseEvent) && MouseEvent.RB && PlaylistElements[i].Content != -1) if (MouseEvent.LBH && CurrentPlaylistElement != -1 && PlaylistElementContents.Count > 1)
{
CPlaylists.Playlists[ActivePlaylistID].DeleteSong(PlaylistElements[i].Content);
UpdatePlaylist();
return true;
}
}
if(!hover_set)
{ {
CurrentPlaylistElement = -1;
ChangeOrderSource = CurrentPlaylistElement + Offset;
//Update of Drag/Drop-Texture
if (ChangeOrderSource >= PlaylistElementContents.Count)
return true;
ChangeOrderElement = new PlaylistElement(PlaylistElements[CurrentPlaylistElement]);
ChangeOrderElement.Background.Rect.Z = CSettings.zNear;
ChangeOrderElement.Cover.Rect.Z = CSettings.zNear;
ChangeOrderElement.SelectSlide.Rect.Z = CSettings.zNear;
ChangeOrderElement.SelectSlide.RectArrowLeft.Z = CSettings.zNear;
ChangeOrderElement.SelectSlide.RectArrowRight.Z = CSettings.zNear;
ChangeOrderElement.Text1.Z = CSettings.zNear;
ChangeOrderElement.Background.Texture = CTheme.GetSkinTexture(_Theme.TextureBackgroundName);
ChangeOrderElement.Background.Color = BackgroundColor;
OldMousePosX = MouseEvent.X;
OldMousePosY = MouseEvent.Y;
_EditMode = EEditMode.ChangeOrder;
} }
break; break;
case EEditMode.PlaylistName: case EEditMode.PlaylistName:
@@ -869,28 +961,20 @@ namespace Vocaluxe.Menu
case EEditMode.ChangeOrder: case EEditMode.ChangeOrder:
//Actions according to playlist-element //Actions according to playlist-element
for (int i = 0; i < PlaylistElements.Count; i++)
//Update coords for Drag/Drop-Texture
ChangeOrderElement.MouseMove(MouseEvent.X, MouseEvent.Y, OldMousePosX, OldMousePosY);
OldMousePosX = MouseEvent.X;
OldMousePosY = MouseEvent.Y;
if (!MouseEvent.LBH)
{ {
//Change order with holding LB if (CurrentPlaylistElement != -1 && CurrentPlaylistElement + Offset != ChangeOrderSource)
if (CHelper.IsInBounds(PlaylistElements[i].Background.Rect, MouseEvent) && MouseEvent.LBH && PlaylistElements[i].Content != -1 && _EditMode != EEditMode.ChangeOrder)
{ {
_EditMode = EEditMode.ChangeOrder; CPlaylists.Playlists[ActivePlaylistID].SongMove(ChangeOrderSource, CurrentPlaylistElement + Offset);
CurrentPlaylistElement = i; UpdatePlaylist();
}
else if (CHelper.IsInBounds(PlaylistElements[i].Background.Rect, MouseEvent) && MouseEvent.LBH && PlaylistElements[i].Content != -1 && _EditMode == EEditMode.ChangeOrder)
{
/*
if (PlaylistElements.Count < CurrentPlaylistElement + 1)
{
}
else if (PlaylistElementContents.Count < CurrentPlaylistElement + 1 + Offset)
{
}
if (mevent.Y < PlaylistElements[CurrentPlaylistElement + 1].Background.Rect.Y)
{
}
*/
} }
_EditMode = EEditMode.None;
} }
break; break;
} }
+9 -4
View File
@@ -207,11 +207,16 @@ namespace Vocaluxe.Menu
TextH = slide.TextH; TextH = slide.TextH;
MaxW = slide.MaxW; MaxW = slide.MaxW;
_Selected = false; _Selected = slide._Selected;
_Textures = new List<STexture>(); _Textures = new List<STexture>(slide._Textures);
_ValueIndexes = new List<int>(); _ValueIndexes = new List<int>(slide._ValueIndexes);
_ValueNames = new List<string>(); _ValueNames = new List<string>(slide._ValueNames);
_ValueBounds = new List<SRectF>(slide._ValueBounds);
_Selection = slide._Selection;
_NumVisible = slide._NumVisible; _NumVisible = slide._NumVisible;
WithTextures = slide.WithTextures;
Visible = slide.Visible;
} }
public bool LoadTheme(string XmlPath, string ElementName, XPathNavigator navigator, int SkinIndex) public bool LoadTheme(string XmlPath, string ElementName, XPathNavigator navigator, int SkinIndex)
+17
View File
@@ -70,6 +70,23 @@ namespace Vocaluxe.Menu
Visible = true; Visible = true;
} }
public CStatic(CStatic s)
{
_Theme = new SThemeStatic();
_ThemeLoaded = false;
_Texture = s.Texture;
Color = new SColorF(s.Color);
Rect = new SRectF(s.Rect);
Reflection = s.Reflection;
ReflectionSpace = s.ReflectionHeight;
ReflectionHeight = s.ReflectionSpace;
Selected = s.Selected;
Alpha = s.Alpha;
Visible = s.Visible;
}
public CStatic(STexture texture, SColorF color, SRectF rect) public CStatic(STexture texture, SColorF color, SRectF rect)
{ {
_Theme = new SThemeStatic(); _Theme = new SThemeStatic();
+31
View File
@@ -250,6 +250,37 @@ namespace Vocaluxe.Menu
Alpha = 1f; Alpha = 1f;
} }
public CText(CText text)
{
_Theme = new SThemeText();
_ThemeLoaded = false;
_ButtonText = false;
X = text._X;
Y = text._Y;
Z = text._Z;
Height = text._Height;
MaxWidth = text._MaxWidth;
Bounds = new SRectF(text._Bounds);
Align = text._Align;
HAlign = text._HAlign;
Style = text._Style;
Fon = text._Fon;
Color = new SColorF(text.Color);
SColor = new SColorF(text.SColor);
Reflection = text.Reflection;
ReflectionSpace = text.ReflectionSpace;
ReflectionHeight = text.ReflectionHeight;
Text = text._Text;
Selected = text.Selected;
Visible = text.Visible;
Alpha = text.Alpha;
EditMode = text.EditMode;
}
public CText(float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text, float rspace, float rheight) public CText(float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text, float rspace, float rheight)
{ {
_Theme = new SThemeText(); _Theme = new SThemeText();
+1 -1
View File
@@ -450,7 +450,7 @@ namespace Vocaluxe.Screens
CStatic SelectedPlayer = NameSelections[htNameSelections(NameSelection)].TilePlayerAvatar(MouseEvent); CStatic SelectedPlayer = NameSelections[htNameSelections(NameSelection)].TilePlayerAvatar(MouseEvent);
chooseAvatarStatic.Visible = true; chooseAvatarStatic.Visible = true;
chooseAvatarStatic.Rect = SelectedPlayer.Rect; chooseAvatarStatic.Rect = SelectedPlayer.Rect;
chooseAvatarStatic.Rect.Z = CSettings.zNear + 1; chooseAvatarStatic.Rect.Z = CSettings.zNear;
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1); chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
chooseAvatarStatic.Texture = SelectedPlayer.Texture; chooseAvatarStatic.Texture = SelectedPlayer.Texture;
} }
+3 -1
View File
@@ -95,6 +95,8 @@ namespace Vocaluxe.Screens
Texts[htTexts(TextOptionsTitle)].Visible = false; Texts[htTexts(TextOptionsTitle)].Visible = false;
Statics[htStatics(StaticOptionsBG)].Visible = false; Statics[htStatics(StaticOptionsBG)].Visible = false;
Playlists[htPlaylists(Playlist)].Visible = false; Playlists[htPlaylists(Playlist)].Visible = false;
Playlists[htPlaylists(Playlist)].Init();
} }
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
@@ -395,7 +397,7 @@ namespace Vocaluxe.Screens
CGame.EnterNormalGame(); CGame.EnterNormalGame();
SongMenus[htSongMenus(SongMenu)].OnShow(); SongMenus[htSongMenus(SongMenu)].OnShow();
SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive); SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive);
Playlists[htPlaylists(Playlist)].Init();
if (Playlists[htPlaylists(Playlist)].ActivePlaylistID != -1) if (Playlists[htPlaylists(Playlist)].ActivePlaylistID != -1)
Playlists[htPlaylists(Playlist)].LoadPlaylist(Playlists[htPlaylists(Playlist)].ActivePlaylistID); Playlists[htPlaylists(Playlist)].LoadPlaylist(Playlists[htPlaylists(Playlist)].ActivePlaylistID);
UpdatePlaylistNames(); UpdatePlaylistNames();