Fix categories not showing on start

This commit is contained in:
Flamefire committed 2014-08-09 15:05:34 +02:00
1 parent 62675821ed
commit 09d36ccf60
1 file changed
+17 -15
+17 -15
View File
@@ -57,8 +57,8 @@ namespace VocaluxeLib.Menu.SongMenu
private int _Offset;
private float _Length = -1f;
private int _LastKnownNumSongs;
private int _LastKnownCategory = -1;
private int _LastKnownElements;
private int _LastKnownCategory;
private bool _MouseWasInRect;
@@ -263,17 +263,18 @@ namespace VocaluxeLib.Menu.SongMenu
public override void OnShow()
{
if (CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && CBase.Songs.GetNumCategories() > 0 && !CBase.Songs.IsInCategory())
_EnterCategory(0);
else
_LastKnownElements = -1; //Force refresh of list
if (!CBase.Songs.IsInCategory())
{
if (CBase.Songs.IsInCategory())
SetSelectedSong(_SelectionNr < 0 ? 0 : _SelectionNr);
else
SetSelectedCategory(_SelectionNr < 0 ? 0 : _SelectionNr);
if ((CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && CBase.Songs.GetNumCategories() > 0) || CBase.Songs.GetNumCategories() == 1)
_EnterCategory(0);
}
if (CBase.Songs.IsInCategory())
SetSelectedSong(_SelectionNr < 0 ? 0 : _SelectionNr);
else
SetSelectedCategory(_SelectionNr < 0 ? 0 : _SelectionNr);
_PreviewNr = _SelectionNr;
_AfterCategoryChange();
_UpdateListIfRequired();
}
public override bool HandleInput(ref SKeyEvent keyEvent, SScreenSongOptions options)
@@ -499,7 +500,7 @@ namespace VocaluxeLib.Menu.SongMenu
_PreviewNr = 0;
SetSelectedSong(0);
_AfterCategoryChange();
_UpdateListIfRequired();
}
protected override void _LeaveCategory()
@@ -508,7 +509,7 @@ namespace VocaluxeLib.Menu.SongMenu
_PreviewNr = 0;
SetSelectedCategory(0);
_AfterCategoryChange();
_UpdateListIfRequired();
}
private void _NextCategory()
@@ -529,13 +530,14 @@ namespace VocaluxeLib.Menu.SongMenu
}
}
private void _AfterCategoryChange()
private void _UpdateListIfRequired()
{
if ((_LastKnownNumSongs == CBase.Songs.GetNumSongsVisible()) && (_LastKnownCategory == CBase.Songs.GetCurrentCategoryIndex()))
int curElements = CBase.Songs.IsInCategory() ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories();
if ((_LastKnownElements == curElements) && (_LastKnownCategory == CBase.Songs.GetCurrentCategoryIndex()))
return;
_LastKnownCategory = CBase.Songs.GetCurrentCategoryIndex();
_LastKnownNumSongs = CBase.Songs.GetNumSongsVisible();
_LastKnownElements = curElements;
CBase.Songs.UpdateRandomSongList();
_UpdateList(true);
}