modified songmenu playlist handling

This commit is contained in:
Alexander Eckart committed 2012-08-12 16:53:34 +02:00
1 parent bd93617566
commit d63fb099a4
8 files changed
+144 -29

No files matched your search

+2 -1
View File
@@ -45,7 +45,8 @@ namespace Vocaluxe.Menu
_Type == EType.TSongMenu || _Type == EType.TSongMenu ||
_Type == EType.TLyric || _Type == EType.TLyric ||
_Type == EType.TSingNote || _Type == EType.TSingNote ||
_Type == EType.TEqualizer); _Type == EType.TEqualizer ||
_Type == EType.TPlaylist);
} }
} }
+52 -16
View File
@@ -878,22 +878,24 @@ namespace Vocaluxe.Menu
if (KeyEvent.Key == Keys.Left) if (KeyEvent.Key == Keys.Left)
{ {
if (_Interactions.Count > 0 && _Interactions[_Selection].Type == EType.TSelectSlide && KeyEvent.Mod != Modifier.Shift) if (_Interactions.Count > 0 && _Interactions[_Selection].Type == EType.TSelectSlide && KeyEvent.Mod != Modifier.Shift)
PrevElement(); KeyEvent.Handled = PrevElement();
else
_NextInteraction(KeyEvent); if (!KeyEvent.Handled)
KeyEvent.Handled = _NextInteraction(KeyEvent);
} }
if (KeyEvent.Key == Keys.Right) if (KeyEvent.Key == Keys.Right)
{ {
if (_Interactions.Count > 0 && _Interactions[_Selection].Type == EType.TSelectSlide && KeyEvent.Mod != Modifier.Shift) if (_Interactions.Count > 0 && _Interactions[_Selection].Type == EType.TSelectSlide && KeyEvent.Mod != Modifier.Shift)
NextElement(); KeyEvent.Handled = NextElement();
else
_NextInteraction(KeyEvent); if (!KeyEvent.Handled)
KeyEvent.Handled = _NextInteraction(KeyEvent);
} }
if (KeyEvent.Key == Keys.Up || KeyEvent.Key == Keys.Down) if (KeyEvent.Key == Keys.Up || KeyEvent.Key == Keys.Down)
{ {
_NextInteraction(KeyEvent); KeyEvent.Handled = _NextInteraction(KeyEvent);
} }
} }
else else
@@ -1242,16 +1244,28 @@ namespace Vocaluxe.Menu
_PrevInteraction(); _PrevInteraction();
} }
public void NextElement() /// <summary>
/// Selects the next element in a menu interaction.
/// </summary>
/// <returns>True if the next element is selected. False if either there is no next element or the interaction does not provide such a method.</returns>
public bool NextElement()
{ {
if (_Interactions.Count > 0) if (_Interactions.Count > 0)
_NextElement(); return _NextElement();
return false;
} }
public void PrevElement() /// <summary>
/// Selects the previous element in a menu interaction.
/// </summary>
/// <returns>True if the previous element is selected. False if either there is no next element or the interaction does not provide such a method.</returns>
public bool PrevElement()
{ {
if (_Interactions.Count > 0) if (_Interactions.Count > 0)
_PrevElement(); return _PrevElement();
return false;
} }
public bool SetInteractionToButton(CButton button) public bool SetInteractionToButton(CButton button)
@@ -1502,7 +1516,12 @@ namespace Vocaluxe.Menu
_SetSelected(); _SetSelected();
} }
private void _NextInteraction(KeyEvent Key) /// <summary>
/// Selects the next best interaction in a menu.
/// </summary>
/// <param name="Key"></param>
/// <returns></returns>
private bool _NextInteraction(KeyEvent Key)
{ {
KeyEvent[] Directions = new KeyEvent[4]; KeyEvent[] Directions = new KeyEvent[4];
float[] Distances = new float[4]; float[] Distances = new float[4];
@@ -1568,8 +1587,11 @@ namespace Vocaluxe.Menu
_Selection = element; _Selection = element;
_SetSelected(); _SetSelected();
_SetHighlighted(_Selection); _SetHighlighted(_Selection);
return true;
} }
} }
return false;
} }
private int _GetNextElement(KeyEvent Key, out float Distance, out int Stage) private int _GetNextElement(KeyEvent Key, out float Distance, out int Stage)
@@ -1728,16 +1750,30 @@ namespace Vocaluxe.Menu
return distance; return distance;
} }
private void _NextElement() /// <summary>
/// Selects the next element in a menu interaction.
/// </summary>
/// <returns>True if the next element is selected. False if either there is no next element or the interaction does not provide such a method.</returns>
private bool _NextElement()
{ {
if (_Interactions[_Selection].Type == EType.TSelectSlide) if (_Interactions[_Selection].Type == EType.TSelectSlide)
_SelectSlides[_Interactions[_Selection].Num].NextValue(); return _SelectSlides[_Interactions[_Selection].Num].NextValue();
return false;
} }
private void _PrevElement() /// <summary>
/// Selects the previous element in a menu interaction.
/// </summary>
/// <returns>
/// True if the previous element is selected. False if either there is no previous element or the interaction does not provide such a method.
/// </returns>
private bool _PrevElement()
{ {
if (_Interactions[_Selection].Type == EType.TSelectSlide) if (_Interactions[_Selection].Type == EType.TSelectSlide)
_SelectSlides[_Interactions[_Selection].Num].PrevValue(); return _SelectSlides[_Interactions[_Selection].Num].PrevValue();
return false;
} }
private void _SetSelected() private void _SetSelected()
+17 -4
View File
@@ -77,7 +77,21 @@ namespace Vocaluxe.Menu
public SColorF BackgroundSColor; public SColorF BackgroundSColor;
public bool Visible; public bool Visible;
public bool Selected;
private bool _Selected;
public bool Selected
{
get { return _Selected; }
set
{
_Selected = value;
if (CurrentPlaylistElement == -1 && _Selected)
{
CurrentPlaylistElement = 0;
ActiveHover = CurrentPlaylistElement;
}
}
}
public bool changeOrder = false; public bool changeOrder = false;
public int ActivePlaylistID = -1; public int ActivePlaylistID = -1;
@@ -266,7 +280,7 @@ namespace Vocaluxe.Menu
for (int i = 0; i < PlaylistElements.Count; i++ ) for (int i = 0; i < PlaylistElements.Count; i++ )
{ {
if (i == ActiveHover) if (i == ActiveHover && _Selected)
{ {
PlaylistElements[i].Background.Texture = CTheme.GetSkinTexture(_Theme.STextureBackgroundName); PlaylistElements[i].Background.Texture = CTheme.GetSkinTexture(_Theme.STextureBackgroundName);
PlaylistElements[i].Background.Color = BackgroundSColor; PlaylistElements[i].Background.Color = BackgroundSColor;
@@ -484,7 +498,7 @@ namespace Vocaluxe.Menu
for (int i = 0; i < PlaylistElements.Count; i++) for (int i = 0; i < PlaylistElements.Count; i++)
{ {
//Hover for playlist-element //Hover for playlist-element
if (CHelper.IsInBounds(PlaylistElements[i].Background.Rect, mevent)) if (PlaylistElementContents.Count - 1 >= i && CHelper.IsInBounds(PlaylistElements[i].Background.Rect, mevent))
{ {
PlaylistElements[i].Background.Texture = CTheme.GetSkinTexture(_Theme.STextureBackgroundName); PlaylistElements[i].Background.Texture = CTheme.GetSkinTexture(_Theme.STextureBackgroundName);
PlaylistElements[i].Background.Color = BackgroundSColor; PlaylistElements[i].Background.Color = BackgroundSColor;
@@ -638,7 +652,6 @@ namespace Vocaluxe.Menu
} }
} }
private void ClosePlaylist() private void ClosePlaylist()
{ {
Visible = false; Visible = false;
+10
View File
@@ -73,6 +73,16 @@ namespace Vocaluxe.Menu.SongMenu
_SongMenu.Draw(); _SongMenu.Draw();
} }
public bool IsActive()
{
return _SongMenu.IsActive();
}
public void SetActive(bool Active)
{
_SongMenu.SetActive(Active);
}
public int GetSelectedSong() public int GetSelectedSong()
{ {
return _SongMenu.GetSelectedSong(); return _SongMenu.GetSelectedSong();
@@ -115,6 +115,7 @@ namespace Vocaluxe.Menu.SongMenu
protected long _PendingTime = 500L; protected long _PendingTime = 500L;
private int _LockedInternal = -1; private int _LockedInternal = -1;
protected bool _Active = false;
protected int _PreviewSelected //for preview only protected int _PreviewSelected //for preview only
{ {
@@ -217,6 +218,7 @@ namespace Vocaluxe.Menu.SongMenu
public void SetSelected(bool Selected) public void SetSelected(bool Selected)
{ {
_Selected = Selected; _Selected = Selected;
SetActive(Selected);
} }
public bool IsVisible() public bool IsVisible()
@@ -516,6 +518,16 @@ namespace Vocaluxe.Menu.SongMenu
} }
public virtual bool IsActive()
{
return _Active;
}
public virtual void SetActive(bool Active)
{
_Active = Active;
}
public virtual int GetSelectedSong() public virtual int GetSelectedSong()
{ {
return -1; return -1;
+6 -1
View File
@@ -148,6 +148,11 @@ namespace Vocaluxe.Menu.SongMenu
} }
else else
{ {
if (!(KeyEvent.Key == Keys.Left || KeyEvent.Key == Keys.Right || KeyEvent.Key == Keys.Up || KeyEvent.Key == Keys.Down ||
KeyEvent.Key == Keys.Escape || KeyEvent.Key == Keys.Back || KeyEvent.Key == Keys.Enter ||
KeyEvent.Key == Keys.PageDown || KeyEvent.Key == Keys.PageUp))
return;
bool sel = false; bool sel = false;
foreach (CStatic tile in _Tiles) foreach (CStatic tile in _Tiles)
{ {
@@ -400,7 +405,7 @@ namespace Vocaluxe.Menu.SongMenu
{ {
foreach (CStatic tile in _Tiles) foreach (CStatic tile in _Tiles)
{ {
if (tile.Selected) if (tile.Selected && _Active)
tile.Draw(1.2f, tile.Rect.Z - 0.1f, true, false); tile.Draw(1.2f, tile.Rect.Z - 0.1f, true, false);
else else
{ {
+3
View File
@@ -20,6 +20,9 @@ namespace Vocaluxe.Menu.SongMenu
int GetSelectedSong(); int GetSelectedSong();
void SetSelectedSong(int VisibleSongNr); void SetSelectedSong(int VisibleSongNr);
bool IsActive();
void SetActive(bool Active);
int GetSelectedCategory(); int GetSelectedCategory();
int GetActualSelection(); int GetActualSelection();
+42 -7
View File
@@ -42,6 +42,7 @@ namespace Vocaluxe.Screens
private bool _SearchActive = false; private bool _SearchActive = false;
private bool _SongOptionsActive = false; private bool _SongOptionsActive = false;
private bool _PlaylistActive = false;
private List<GameModes.EGameMode> _AvailableGameModes; private List<GameModes.EGameMode> _AvailableGameModes;
public CScreenSong() public CScreenSong()
@@ -80,14 +81,24 @@ namespace Vocaluxe.Screens
public override bool HandleInput(KeyEvent KeyEvent) public override bool HandleInput(KeyEvent KeyEvent)
{ {
KeyEvent.Handled = Playlists[htPlaylists(Playlist)].HandleInput(KeyEvent);
if (KeyEvent.Handled)
return true;
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.Handled) if (KeyEvent.Handled)
return true; return true;
if (_PlaylistActive)
{
if (!KeyEvent.KeyPressed && KeyEvent.Key == Keys.Tab)
{
_PlaylistActive = !_PlaylistActive;
Playlists[htPlaylists(Playlist)].Selected = _PlaylistActive;
SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive);
return true;
}
Playlists[htPlaylists(Playlist)].HandleInput(KeyEvent);
return true;
}
if (!_SongOptionsActive) if (!_SongOptionsActive)
{ {
if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode))
@@ -104,7 +115,6 @@ namespace Vocaluxe.Screens
else else
{ {
SongMenus[htSongMenus(SongMenu)].HandleInput(ref KeyEvent); SongMenus[htSongMenus(SongMenu)].HandleInput(ref KeyEvent);
if (KeyEvent.Handled) if (KeyEvent.Handled)
return true; return true;
@@ -123,6 +133,15 @@ namespace Vocaluxe.Screens
} }
break; break;
case Keys.Tab:
if (Playlists[htPlaylists(Playlist)].Visible)
{
_PlaylistActive = !_PlaylistActive;
Playlists[htPlaylists(Playlist)].Selected = _PlaylistActive;
SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive);
}
break;
case Keys.Back: case Keys.Back:
if (_SearchText.Length > 0) if (_SearchText.Length > 0)
{ {
@@ -147,6 +166,7 @@ namespace Vocaluxe.Screens
} }
break; break;
//TODO: Move that to the new menu and delete it!
case Keys.A: case Keys.A:
if (!_SearchActive && KeyEvent.Mod == Modifier.None) if (!_SearchActive && KeyEvent.Mod == Modifier.None)
{ {
@@ -158,6 +178,7 @@ namespace Vocaluxe.Screens
} }
break; break;
//TODO: Delete that from here and from wiki!
case Keys.F: case Keys.F:
if (KeyEvent.Mod == Modifier.Ctrl) if (KeyEvent.Mod == Modifier.Ctrl)
{ {
@@ -174,6 +195,7 @@ namespace Vocaluxe.Screens
} }
break; break;
//TODO: We need another key for random!
case Keys.R: case Keys.R:
if (CSongs.Category != -1 && KeyEvent.Mod == Modifier.Ctrl) if (CSongs.Category != -1 && KeyEvent.Mod == Modifier.Ctrl)
{ {
@@ -181,6 +203,7 @@ namespace Vocaluxe.Screens
} }
break; break;
//TODO: Delete that!
case Keys.S: case Keys.S:
if (CSongs.NumVisibleSongs > 0) if (CSongs.NumVisibleSongs > 0)
StartMedleySong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); StartMedleySong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong());
@@ -246,10 +269,21 @@ namespace Vocaluxe.Screens
{ {
base.HandleMouse(MouseEvent); base.HandleMouse(MouseEvent);
if (Playlists[htPlaylists(Playlist)].HandleMouse(MouseEvent)) if (CHelper.IsInBounds(Playlists[htPlaylists(Playlist)].Rect, MouseEvent.X, MouseEvent.Y))
{ {
return true; _PlaylistActive = true;
Playlists[htPlaylists(Playlist)].Selected = _PlaylistActive;
SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive);
} }
else if (CHelper.IsInBounds(SongMenus[htSongMenus(SongMenu)].Rect, MouseEvent.X, MouseEvent.Y))
{
_PlaylistActive = false;
Playlists[htPlaylists(Playlist)].Selected = _PlaylistActive;
SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive);
}
if (Playlists[htPlaylists(Playlist)].HandleMouse(MouseEvent))
return true;
if (!_SongOptionsActive) if (!_SongOptionsActive)
{ {
@@ -333,6 +367,7 @@ namespace Vocaluxe.Screens
base.OnShow(); base.OnShow();
CGame.EnterNormalGame(); CGame.EnterNormalGame();
SongMenus[htSongMenus(SongMenu)].OnShow(); SongMenus[htSongMenus(SongMenu)].OnShow();
SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive);
Playlists[htPlaylists(Playlist)].Init(); 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);