SongMenu refactoring

New Shortcuts
Readme update
This commit is contained in:
Flamefire committed 2013-02-26 21:12:32 +01:00
1 parent 835af557d2
commit 30841c5758
4 files changed
+131 -254

No files matched your search

+5 -3
View File
@@ -125,11 +125,13 @@ Vocaluxe.exe -ConfigFile MyConfig.xml -ScoreFile C:\Vocaluxe\Highscores\MyHighsc
[SHIFT] + [-] to decrease volume [SHIFT] + [-] to decrease volume
Song screen Song screen
[CTRL] + [R] to select a random song
[F3] to open/close the song search menu [F3] to open/close the song search menu
[A] to sing all songs
[SHIFT] + [A] to sing all songs from a category
[SPACE] to open/close the song menu [SPACE] to open/close the song menu
[CTRL] + [R] to select a random song
[CTRL] + [A] to sing all songs
[CTRL] + [V] to sing all songs from a category
[NUM_1]..[NUM_6] to use a Joker for team 1..6
[A]..[Z] to jump to category/song title starting with that letter
Name selection screen Name selection screen
[1]..[6] to activate player selection. [1]..[6] to activate player selection.
+67 -70
View File
@@ -187,12 +187,11 @@ namespace Vocaluxe.Screens
{ {
if (_SearchActive) if (_SearchActive)
ApplyNewSearchFilter(_SearchText + KeyEvent.Unicode); ApplyNewSearchFilter(_SearchText + KeyEvent.Unicode);
/* else
else if (!Char.IsControl(KeyEvent.Unicode))
{ {
JumpTo(KeyEvent.Unicode); JumpTo(KeyEvent.Unicode);
return true; return true;
} */ }
} }
else else
{ {
@@ -254,7 +253,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.Back: case Keys.Back:
if (_SearchText.Length > 0) if (_SearchActive && _SearchText.Length > 0)
{ {
ApplyNewSearchFilter(_SearchText.Remove(_SearchText.Length - 1)); ApplyNewSearchFilter(_SearchText.Remove(_SearchText.Length - 1));
} }
@@ -266,11 +265,6 @@ namespace Vocaluxe.Screens
break; break;
case Keys.Space:
if (!_SearchActive && !_sso.Selection.PartyMode)
ToggleSongOptions(ESongOptionsView.General);
break;
case Keys.F3: case Keys.F3:
if (_SearchActive) if (_SearchActive)
{ {
@@ -279,52 +273,34 @@ namespace Vocaluxe.Screens
ApplyNewSearchFilter(_SearchText); ApplyNewSearchFilter(_SearchText);
} }
else if (!_sso.Selection.PartyMode) else if (!_sso.Selection.PartyMode)
{
_SearchActive = true; _SearchActive = true;
break;
} }
if(!_SearchActive){
switch (KeyEvent.Key)
{
case Keys.Space:
if (!_sso.Selection.PartyMode)
ToggleSongOptions(ESongOptionsView.General);
break; break;
//TODO: Delete it! ??? Shouldn't we keep this as shortcut?
case Keys.A: case Keys.A:
if (!_SearchActive && KeyEvent.Mod == EModifier.None && !_sso.Selection.PartyMode)
{
StartRandomAllSongs();
}
if (KeyEvent.Mod == EModifier.Ctrl && !_sso.Selection.PartyMode) if (KeyEvent.Mod == EModifier.Ctrl && !_sso.Selection.PartyMode)
{ StartRandomAllSongs();
break;
case Keys.V:
if (KeyEvent.Mod == EModifier.Ctrl && !_sso.Selection.PartyMode)
StartRandomVisibleSongs(); StartRandomVisibleSongs();
}
break; break;
//TODO: Delete that from here and from wiki!
case Keys.F:
if (KeyEvent.Mod == EModifier.Ctrl)
{
if (_SearchActive)
{
_SearchActive = false;
_SearchText = String.Empty;
ApplyNewSearchFilter(_SearchText);
}
else if (!_sso.Selection.PartyMode)
{
_SearchActive = true;
}
}
break;
//TODO: We need another key for random!
case Keys.R: case Keys.R:
if (KeyEvent.Mod == EModifier.Ctrl && !_sso.Selection.RandomOnly) if (KeyEvent.Mod == EModifier.Ctrl && !_sso.Selection.RandomOnly)
SelectNextRandom(-1); SelectNextRandom(-1);
break; break;
//TODO: Delete that!
case Keys.S: case Keys.S:
if (!_SearchActive && CSongs.NumVisibleSongs > 0 && !_sso.Selection.PartyMode) if (KeyEvent.Mod == EModifier.Ctrl && CSongs.NumVisibleSongs > 0 && !_sso.Selection.PartyMode)
{
StartMedleySong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); StartMedleySong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong());
}
break; break;
case Keys.D1: case Keys.D1:
@@ -350,7 +326,7 @@ namespace Vocaluxe.Screens
case Keys.D6: case Keys.D6:
SelectNextRandom(5); SelectNextRandom(5);
break; break;
}
} }
} }
} }
@@ -377,17 +353,10 @@ namespace Vocaluxe.Screens
else if (Buttons[htButtons(ButtonOptionsRandom)].Selected) else if (Buttons[htButtons(ButtonOptionsRandom)].Selected)
{ {
if (CSongs.Category != -1) if (CSongs.Category != -1)
{
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong());
} else
}
else if (Buttons[htButtons(ButtonOptionsRandom)].Selected)
{
if (CSongs.Category == -1)
{
SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory()); SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory());
} }
}
else if (Buttons[htButtons(ButtonOptionsSingAll)].Selected) else if (Buttons[htButtons(ButtonOptionsSingAll)].Selected)
{ {
StartRandomAllSongs(); StartRandomAllSongs();
@@ -1075,19 +1044,39 @@ namespace Vocaluxe.Screens
private void JumpTo(char Letter) private void JumpTo(char Letter)
{ {
int song = SongMenus[htSongMenus(SongMenu)].GetSelectedSong(); int start = 0;
int id = -1; if (CSongs.Category < 0)
if (song > -1 && song < CSongs.NumVisibleSongs)
{ {
id = CSongs.VisibleSongs[song].ID; int curSelected = SongMenus[htSongMenus(SongMenu)].GetSelectedCategory();
CCategory[] Categories = CSongs.Categories;
int ct = Categories.Length;
if (curSelected >= 0 && curSelected < ct - 1 && Categories[curSelected].Name.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
int visibleID = Array.FindIndex<CCategory>(Categories, start, ct - start, element => element.Name.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
if (visibleID < 0 && start > 1)
visibleID = Array.FindIndex<CCategory>(Categories, 0, start - 1, element => element.Name.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
if (visibleID > -1)
SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(visibleID);
}
else
{
//TODO: Check and use sorting method
int curSelected = SongMenus[htSongMenus(SongMenu)].GetSelectedSong();
CSong[] Songs = CSongs.VisibleSongs;
int ct = Songs.Length;
if (curSelected >= 0 && curSelected < ct - 1)
{
CSong CurrentSong = CSongs.GetVisibleSongByIndex(curSelected);
if (CurrentSong != null && CurrentSong.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
}
int visibleID = Array.FindIndex<CSong>(Songs, start, ct - start, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
if(visibleID < 0 && start > 1)
visibleID = Array.FindIndex<CSong>(Songs, 0, start - 1, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
if (visibleID > -1)
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(visibleID);
} }
int visibleID = Array.FindIndex<CSong>(CSongs.VisibleSongs, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
if (visibleID > -1)
{
id = visibleID;
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(id);
}
} }
private void ApplyNewSearchFilter(string NewFilterString) private void ApplyNewSearchFilter(string NewFilterString)
@@ -1119,7 +1108,7 @@ namespace Vocaluxe.Screens
CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, NewFilterString, _sso.Sorting.ShowDuetSongs); CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, NewFilterString, _sso.Sorting.ShowDuetSongs);
if (SongID == -1 || CSongs.NumVisibleSongs == 0 || CSongs.NumVisibleSongs <= SongIndex || CSongs.VisibleSongs[SongIndex].ID != SongID) if (SongID == -1 || CSongs.NumVisibleSongs == 0 || CSongs.NumVisibleSongs <= SongIndex || CSongs.GetVisibleSongByIndex(SongIndex).ID != SongID)
refresh = true; refresh = true;
if (refresh) if (refresh)
@@ -1130,8 +1119,6 @@ namespace Vocaluxe.Screens
private void ToggleSongOptions(ESongOptionsView view) private void ToggleSongOptions(ESongOptionsView view)
{ {
_SongOptionsActive = view != ESongOptionsView.None;
SelectSlides[htSelectSlides(SelectSlideOptionsMode)].Visible = false; SelectSlides[htSelectSlides(SelectSlideOptionsMode)].Visible = false;
SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Visible = false; SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Visible = false;
SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistOpen)].Visible = false; SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistOpen)].Visible = false;
@@ -1150,9 +1137,24 @@ namespace Vocaluxe.Screens
Statics[htStatics(StaticOptionsBG)].Visible = false; Statics[htStatics(StaticOptionsBG)].Visible = false;
Buttons[htButtons(ButtonOpenOptions)].Visible = true; Buttons[htButtons(ButtonOpenOptions)].Visible = true;
_SongOptionsActive = view != ESongOptionsView.None;
if (_SongOptionsActive) if (_SongOptionsActive)
{ {
Texts[htTexts(TextOptionsTitle)].Visible = true;
Buttons[htButtons(ButtonOptionsClose)].Visible = true;
Statics[htStatics(StaticOptionsBG)].Visible = true;
Buttons[htButtons(ButtonOpenOptions)].Visible = false;
if (view == ESongOptionsView.Song) if (view == ESongOptionsView.Song)
_ShowSongOptionsSong();
else if (view == ESongOptionsView.General)
_ShowSongOptionsGeneral();
else if (view == ESongOptionsView.Medley)
_ShowSongOptionsMedley();
}
}
private void _ShowSongOptionsSong()
{ {
EGameMode LastMode = EGameMode.TR_GAMEMODE_NORMAL; EGameMode LastMode = EGameMode.TR_GAMEMODE_NORMAL;
if (_AvailableGameModes.Count > 0) if (_AvailableGameModes.Count > 0)
@@ -1189,7 +1191,8 @@ namespace Vocaluxe.Screens
Buttons[htButtons(ButtonOptionsPlaylist)].Visible = true; Buttons[htButtons(ButtonOptionsPlaylist)].Visible = true;
SetInteractionToButton(Buttons[htButtons(ButtonOptionsSing)]); SetInteractionToButton(Buttons[htButtons(ButtonOptionsSing)]);
} }
else if (view == ESongOptionsView.General)
private void _ShowSongOptionsGeneral()
{ {
Buttons[htButtons(ButtonOptionsRandom)].Visible = CSongs.Category != -1; Buttons[htButtons(ButtonOptionsRandom)].Visible = CSongs.Category != -1;
Buttons[htButtons(ButtonOptionsRandomCategory)].Visible = CSongs.Category == -1; Buttons[htButtons(ButtonOptionsRandomCategory)].Visible = CSongs.Category == -1;
@@ -1218,7 +1221,8 @@ namespace Vocaluxe.Screens
else else
SetInteractionToButton(Buttons[htButtons(ButtonOptionsRandomCategory)]); SetInteractionToButton(Buttons[htButtons(ButtonOptionsRandomCategory)]);
} }
else if (view == ESongOptionsView.Medley)
private void _ShowSongOptionsMedley()
{ {
Buttons[htButtons(ButtonOptionsStartMedley)].Visible = true; Buttons[htButtons(ButtonOptionsStartMedley)].Visible = true;
SelectSlides[htSelectSlides(SelectSlideOptionsNumMedleySongs)].Visible = true; SelectSlides[htSelectSlides(SelectSlideOptionsNumMedleySongs)].Visible = true;
@@ -1242,13 +1246,6 @@ namespace Vocaluxe.Screens
else else
SelectSlides[htSelectSlides(SelectSlideOptionsNumMedleySongs)].SetSelectionByValueIndex(SelectSlides[htSelectSlides(SelectSlideOptionsNumMedleySongs)].NumValues - 1); SelectSlides[htSelectSlides(SelectSlideOptionsNumMedleySongs)].SetSelectionByValueIndex(SelectSlides[htSelectSlides(SelectSlideOptionsNumMedleySongs)].NumValues - 1);
SetInteractionToButton(Buttons[htButtons(ButtonOptionsStartMedley)]); SetInteractionToButton(Buttons[htButtons(ButtonOptionsStartMedley)]);
}
Texts[htTexts(TextOptionsTitle)].Visible = true;
Buttons[htButtons(ButtonOptionsClose)].Visible = true;
Statics[htStatics(StaticOptionsBG)].Visible = true;
Buttons[htButtons(ButtonOpenOptions)].Visible = false;
}
} }
#region Playlist Actions #region Playlist Actions
+8 -17
View File
@@ -324,10 +324,10 @@ namespace Vocaluxe.Menu
[Flags] [Flags]
public enum EModifier public enum EModifier
{ {
None, None = 0,
Shift, Shift = 1,
Alt, Alt = 2,
Ctrl Ctrl = 4
} }
public enum ESender public enum ESender
@@ -361,23 +361,14 @@ namespace Vocaluxe.Menu
Key = key; Key = key;
Handled = false; Handled = false;
EModifier mALT = EModifier.None; Mod = EModifier.None;
EModifier mSHIFT = EModifier.None;
EModifier mCTRL = EModifier.None;
if (alt) if (alt)
mALT = EModifier.Alt; Mod |= EModifier.Alt;
if (shift) if (shift)
mSHIFT = EModifier.Shift; Mod |= EModifier.Shift;
if (ctrl) if (ctrl)
mCTRL = EModifier.Ctrl; Mod |= EModifier.Ctrl;
if (!alt && !shift && !ctrl)
Mod = EModifier.None;
else
Mod = mALT | mSHIFT | mCTRL;
} }
} }
+51 -164
View File
@@ -36,7 +36,7 @@ namespace Vocaluxe.Menu.SongMenu
private int _TileW; private int _TileW;
private int _TileH; private int _TileH;
private int _Offset = 0; private int _Offset = -1;
private int _actualSelection = -1; private int _actualSelection = -1;
private bool _SmallView = false; private bool _SmallView = false;
@@ -123,7 +123,7 @@ namespace Vocaluxe.Menu.SongMenu
_actualSelection = -1; _actualSelection = -1;
_Locked = -1; _Locked = -1;
_PreviewSelected = -1; _PreviewSelected = -1;
UpdateList(0); UpdateList(0, true);
//AfterCategoryChange(); //AfterCategoryChange();
SetSelectedSong(_ActSong); SetSelectedSong(_ActSong);
AfterCategoryChange(); AfterCategoryChange();
@@ -197,7 +197,7 @@ namespace Vocaluxe.Menu.SongMenu
_actualSelection = 0; _actualSelection = 0;
_PreviewSelected = 0; _PreviewSelected = 0;
SetSelectedNow(); SetSelectedNow();
UpdateList(0); UpdateList(0, true);
} }
} }
else else
@@ -247,9 +247,7 @@ namespace Vocaluxe.Menu.SongMenu
if (_Locked > 0 && (!SongOptions.Selection.RandomOnly || SongOptions.Selection.CategoryChangeAllowed && CBase.Songs.GetCurrentCategoryIndex() < 0)) if (_Locked > 0 && (!SongOptions.Selection.RandomOnly || SongOptions.Selection.CategoryChangeAllowed && CBase.Songs.GetCurrentCategoryIndex() < 0))
{ {
_Locked--; _Locked--;
if (CBase.Songs.GetCurrentCategoryIndex() < 0 && _Locked < CBase.Songs.GetNumCategories() - _NumW || UpdateList();
CBase.Songs.GetCurrentCategoryIndex() >= 0 && _Locked < CBase.Songs.GetNumVisibleSongs() - _NumW)
UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2)));
} }
break; break;
@@ -259,8 +257,7 @@ namespace Vocaluxe.Menu.SongMenu
if (_Locked < CBase.Songs.GetNumCategories() - 1) if (_Locked < CBase.Songs.GetNumCategories() - 1)
{ {
_Locked++; _Locked++;
if (_Locked < CBase.Songs.GetNumCategories() - _NumW) UpdateList();
UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2)));
} }
} }
@@ -269,8 +266,7 @@ namespace Vocaluxe.Menu.SongMenu
if (CBase.Songs.GetCurrentCategoryIndex() != -1 && _Locked < CBase.Songs.GetNumVisibleSongs() - 1 && !SongOptions.Selection.RandomOnly) if (CBase.Songs.GetCurrentCategoryIndex() != -1 && _Locked < CBase.Songs.GetNumVisibleSongs() - 1 && !SongOptions.Selection.RandomOnly)
{ {
_Locked++; _Locked++;
if (_Locked < CBase.Songs.GetNumVisibleSongs() - _NumW) UpdateList();
UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2)));
} }
} }
break; break;
@@ -285,7 +281,7 @@ namespace Vocaluxe.Menu.SongMenu
if (_Locked > _NumW - 1 && (!SongOptions.Selection.RandomOnly || SongOptions.Selection.CategoryChangeAllowed && CBase.Songs.GetCurrentCategoryIndex() < 0)) if (_Locked > _NumW - 1 && (!SongOptions.Selection.RandomOnly || SongOptions.Selection.CategoryChangeAllowed && CBase.Songs.GetCurrentCategoryIndex() < 0))
{ {
_Locked -= _NumW; _Locked -= _NumW;
UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2))); UpdateList();
} }
break; break;
@@ -301,19 +297,14 @@ namespace Vocaluxe.Menu.SongMenu
if (_Locked < CBase.Songs.GetNumCategories() - _NumW) if (_Locked < CBase.Songs.GetNumCategories() - _NumW)
{ {
_Locked += _NumW; _Locked += _NumW;
if (_Locked < CBase.Songs.GetNumCategories() - _NumW) UpdateList();
UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2)));
} }
} }
else else if (_Locked < CBase.Songs.GetNumVisibleSongs() - _NumW && !SongOptions.Selection.RandomOnly)
{
if (_Locked < CBase.Songs.GetNumVisibleSongs() - _NumW && !SongOptions.Selection.RandomOnly)
{ {
_Locked += _NumW; _Locked += _NumW;
if (_Locked < CBase.Songs.GetNumVisibleSongs() - _NumW) UpdateList();
UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2)));
}
} }
break; break;
@@ -407,30 +398,9 @@ namespace Vocaluxe.Menu.SongMenu
} }
} }
if (MouseEvent.Wheel > 0) if (MouseEvent.Wheel != 0 && CHelper.IsInBounds(_ScrollRect, MouseEvent) && (!SongOptions.Selection.RandomOnly || CBase.Songs.GetCurrentCategoryIndex() < 0 && SongOptions.Selection.CategoryChangeAllowed))
{ {
if (CHelper.IsInBounds(_ScrollRect, MouseEvent) && (!SongOptions.Selection.RandomOnly || CBase.Songs.GetCurrentCategoryIndex() < 0 && SongOptions.Selection.CategoryChangeAllowed)) UpdateList(_Offset + _NumW * MouseEvent.Wheel);
{
if (CBase.Songs.GetCurrentCategoryIndex() >= 0 && CBase.Songs.GetNumVisibleSongs() > _Offset + _NumW * MouseEvent.Wheel + _NumW * (_NumH - 1) ||
CBase.Songs.GetCurrentCategoryIndex() < 0 && CBase.Songs.GetNumCategories() > _Offset + _NumW * MouseEvent.Wheel + _NumW * (_NumH - 1))
{
_Offset += _NumW * MouseEvent.Wheel;
UpdateList(_Offset);
}
}
}
if (MouseEvent.Wheel < 0)
{
if (CHelper.IsInBounds(_ScrollRect, MouseEvent) && (!SongOptions.Selection.RandomOnly || CBase.Songs.GetCurrentCategoryIndex() < 0 && SongOptions.Selection.CategoryChangeAllowed))
{
_Offset += _NumW * MouseEvent.Wheel;
if (_Offset < 0)
{
_Offset = 0;
}
UpdateList(_Offset);
}
} }
} }
@@ -511,7 +481,8 @@ namespace Vocaluxe.Menu.SongMenu
CBase.Drawing.DrawTexture(_vidtex, vidRect, _vidtex.color, vidRectBounds, false); CBase.Drawing.DrawTexture(_vidtex, vidRect, _vidtex.color, vidRectBounds, false);
CBase.Drawing.DrawTextureReflection(_vidtex, vidRect, _vidtex.color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); CBase.Drawing.DrawTextureReflection(_vidtex, vidRect, _vidtex.color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight);
}else }
else
_CoverBig.Draw(1f, EAspect.Crop); _CoverBig.Draw(1f, EAspect.Crop);
@@ -541,14 +512,7 @@ namespace Vocaluxe.Menu.SongMenu
return new CStatic(_PartyModeID); return new CStatic(_PartyModeID);
} }
public override void SetSelectedSong(int VisibleSongNr) protected void SetSelectedTile(int itemNr)
{
base.SetSelectedSong(VisibleSongNr);
if (VisibleSongNr < 0)
return;
if (CBase.Songs.GetNumVisibleSongs() > VisibleSongNr)
{ {
bool sel = false; bool sel = false;
foreach (CStatic tile in _Tiles) foreach (CStatic tile in _Tiles)
@@ -572,7 +536,7 @@ namespace Vocaluxe.Menu.SongMenu
_actualSelection = 0; _actualSelection = 0;
_PreviewSelected = 0; _PreviewSelected = 0;
SetSelectedNow(); SetSelectedNow();
UpdateList(0); UpdateList(0, true);
} }
} }
@@ -581,77 +545,33 @@ namespace Vocaluxe.Menu.SongMenu
tile.Selected = false; tile.Selected = false;
} }
_PreviewSelected = VisibleSongNr; _PreviewSelected = itemNr;
SetSelectedNow(); SetSelectedNow();
_Locked = VisibleSongNr; _Locked = itemNr;
UpdateList((VisibleSongNr / _NumW) * _NumW - (_NumW * (_NumH - 2))); UpdateList(true);
_PreviewSelected = _Locked; _PreviewSelected = _Locked;
_actualSelection = _Locked; _actualSelection = _Locked;
for (int i = 0; i < _Tiles.Count; i++) if (_Locked - _Offset >= 0)
{ _Tiles[_Locked - _Offset].Selected = true;
_Tiles[i].Selected = _Locked == i + _Offset;
}
} }
public override void SetSelectedSong(int VisibleSongNr)
{
base.SetSelectedSong(VisibleSongNr);
if (VisibleSongNr >= 0 && VisibleSongNr < CBase.Songs.GetNumVisibleSongs())
SetSelectedTile(VisibleSongNr);
} }
public override void SetSelectedCategory(int CategoryNr) public override void SetSelectedCategory(int CategoryNr)
{ {
base.SetSelectedCategory(CategoryNr); base.SetSelectedCategory(CategoryNr);
if (CategoryNr < 0) if (CategoryNr >= 0 && CategoryNr < CBase.Songs.GetNumCategories())
return; SetSelectedTile(CategoryNr);
if (CBase.Songs.GetNumCategories() > CategoryNr)
{
bool sel = false;
foreach (CStatic tile in _Tiles)
{
if (tile.Selected)
{
sel = true;
break;
}
}
if (_Locked == -1 || !sel)
{
if (_PreviewSelected > -1)
{
_Locked = _PreviewSelected;
}
else
{
_Locked = 0;
_actualSelection = 0;
_PreviewSelected = 0;
SetSelectedNow();
UpdateList(0);
}
}
foreach (CStatic tile in _Tiles)
{
tile.Selected = false;
}
_PreviewSelected = CategoryNr;
SetSelectedNow();
_Locked = CategoryNr;
UpdateList((CategoryNr / _NumW) * _NumW - (_NumW * (_NumH - 2)));
_PreviewSelected = _Locked;
_actualSelection = _Locked;
for (int i = 0; i < _Tiles.Count; i++)
{
_Tiles[i].Selected = _Locked == i + _Offset;
}
}
} }
protected override void EnterCategory(int cat) protected override void EnterCategory(int cat)
@@ -712,46 +632,36 @@ namespace Vocaluxe.Menu.SongMenu
_LastKnownCategory = CBase.Songs.GetCurrentCategoryIndex(); _LastKnownCategory = CBase.Songs.GetCurrentCategoryIndex();
_LastKnownNumSongs = CBase.Songs.GetNumVisibleSongs(); _LastKnownNumSongs = CBase.Songs.GetNumVisibleSongs();
UpdateList(0); UpdateList(0, true);
CBase.Songs.UpdateRandomSongList(); CBase.Songs.UpdateRandomSongList();
} }
private void UpdateList(int offset) private void UpdateList(bool force = false)
{ {
if (CBase.Songs.GetCurrentCategoryIndex() > -1) UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2)), force);
{
if (offset >= (CBase.Songs.GetNumVisibleSongs() / _NumW) * _NumW - (_NumW * (_NumH - 1)))
offset = (CBase.Songs.GetNumVisibleSongs() / _NumW) * _NumW - (_NumW * (_NumH - 1));
} }
else
private void UpdateList(int offset, bool force = false)
{ {
if (offset >= (CBase.Songs.GetNumCategories() / _NumW) * _NumW - (_NumW * (_NumH - 1))) bool isInCategory = CBase.Songs.GetCurrentCategoryIndex() >= 0;
offset = (CBase.Songs.GetNumCategories() / _NumW) * _NumW - (_NumW * (_NumH - 1)); int itemCount = (isInCategory) ? CBase.Songs.GetNumVisibleSongs() : CBase.Songs.GetNumCategories();
}
if (offset >= (itemCount / _NumW) * _NumW - (_NumW * (_NumH - 1)))
offset = (itemCount / _NumW) * _NumW - (_NumW * (_NumH - 1));
if (offset < 0) if (offset < 0)
offset = 0; offset = 0;
if (offset == _Offset && !force)
return;
for (int i = 0; i < _Tiles.Count; i++) for (int i = 0; i < _Tiles.Count; i++)
{ {
if (CBase.Songs.GetCurrentCategoryIndex() >= 0) if (itemCount > i + offset)
{
if (CBase.Songs.GetNumVisibleSongs() > i + offset)
{ {
if (isInCategory)
_Tiles[i].Texture = CBase.Songs.GetVisibleSong(i + offset).CoverTextureSmall; _Tiles[i].Texture = CBase.Songs.GetVisibleSong(i + offset).CoverTextureSmall;
_Tiles[i].Color = new SColorF(1f, 1f, 1f, 1f);
}
else else
{
_Tiles[i].Texture = _CoverTexture;
_Tiles[i].Color = _Color;
}
}
if (CBase.Songs.GetCurrentCategoryIndex() == -1)
{
if (CBase.Songs.GetNumCategories() > i + offset)
{
_Tiles[i].Texture = CBase.Songs.GetCategory(i + offset).CoverTextureSmall; _Tiles[i].Texture = CBase.Songs.GetCategory(i + offset).CoverTextureSmall;
_Tiles[i].Color = new SColorF(1f, 1f, 1f, 1f); _Tiles[i].Color = new SColorF(1f, 1f, 1f, 1f);
} }
@@ -761,7 +671,6 @@ namespace Vocaluxe.Menu.SongMenu
_Tiles[i].Color = _Color; _Tiles[i].Color = _Color;
} }
} }
}
_Offset = offset; _Offset = offset;
} }
@@ -775,35 +684,17 @@ namespace Vocaluxe.Menu.SongMenu
{ {
_NumH = _Theme.songMenuTileBoard.numHsmall; _NumH = _Theme.songMenuTileBoard.numHsmall;
_NumW = _Theme.songMenuTileBoard.numWsmall; _NumW = _Theme.songMenuTileBoard.numWsmall;
_TileW = (int)((_Theme.songMenuTileBoard.TileRectSmall.W - _SpaceW * (_NumW - 1)) / _NumW);
_TileH = (int)((_Theme.songMenuTileBoard.TileRectSmall.H - _SpaceH * (_NumH - 1)) / _NumH);
_CoverTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBackgroundName, _PartyModeID);
_CoverBigTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBigBackgroundName, _PartyModeID);
_Tiles = new List<CStatic>();
for (int i = 0; i < _NumH; i++)
{
for (int j = 0; j < _NumW; j++)
{
SRectF rect = new SRectF(_Theme.songMenuTileBoard.TileRectSmall.X + j * (_TileW + _SpaceW),
_Theme.songMenuTileBoard.TileRectSmall.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
_Tiles.Add(tile);
}
}
_Rect = _Theme.songMenuTileBoard.TileRectSmall; _Rect = _Theme.songMenuTileBoard.TileRectSmall;
_ScrollRect = new SRectF(0, 0, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), _Theme.songMenuTileBoard.TileRectSmall.Z);
} }
else else
{ {
_NumH = _Theme.songMenuTileBoard.numH; _NumH = _Theme.songMenuTileBoard.numH;
_NumW = _Theme.songMenuTileBoard.numW; _NumW = _Theme.songMenuTileBoard.numW;
_Rect = _Theme.songMenuTileBoard.TileRect;
}
_TileW = (int)((_Theme.songMenuTileBoard.TileRect.W - _SpaceW * (_NumW - 1)) / _NumW); _TileW = (int)((_Rect.W - _SpaceW * (_NumW - 1)) / _NumW);
_TileH = (int)((_Theme.songMenuTileBoard.TileRect.H - _SpaceH * (_NumH - 1)) / _NumH); _TileH = (int)((_Rect.H - _SpaceH * (_NumH - 1)) / _NumH);
_CoverTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBackgroundName, _PartyModeID); _CoverTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBackgroundName, _PartyModeID);
_CoverBigTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBigBackgroundName, _PartyModeID); _CoverBigTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBigBackgroundName, _PartyModeID);
@@ -813,18 +704,14 @@ namespace Vocaluxe.Menu.SongMenu
{ {
for (int j = 0; j < _NumW; j++) for (int j = 0; j < _NumW; j++)
{ {
SRectF rect = new SRectF(_Theme.songMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW), SRectF rect = new SRectF(_Rect.X + j * (_TileW + _SpaceW), _Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
_Theme.songMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect); CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
_Tiles.Add(tile); _Tiles.Add(tile);
} }
} }
_Rect = _Theme.songMenuTileBoard.TileRect; _ScrollRect = new SRectF(0, 0, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), _Rect.Z);
_ScrollRect = new SRectF(0, 0, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), _Theme.songMenuTileBoard.TileRect.Z); UpdateList(true);
}
UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2)));
} }
public override bool IsSmallView() public override bool IsSmallView()