Handle the case where the selected panel is no longer a valid selection better

This commit is contained in:
Dean Herbert 2017-12-11 21:31:26 +09:00
parent fb92b3551e
commit b10240d7ef
2 changed files with 31 additions and 24 deletions

View File

@ -47,31 +47,34 @@ namespace osu.Game.Beatmaps.Drawables
set
{
state = value;
switch (value)
{
case BeatmapGroupState.Expanded:
Header.State = PanelSelectedState.Selected;
foreach (BeatmapPanel panel in BeatmapPanels)
panel.State = panel == SelectedPanel ? PanelSelectedState.Selected :
!panel.Filtered ? PanelSelectedState.NotSelected : PanelSelectedState.Hidden;
break;
case BeatmapGroupState.Collapsed:
Header.State = PanelSelectedState.NotSelected;
foreach (BeatmapPanel panel in BeatmapPanels)
panel.State = PanelSelectedState.Hidden;
break;
case BeatmapGroupState.Hidden:
Header.State = PanelSelectedState.Hidden;
foreach (BeatmapPanel panel in BeatmapPanels)
panel.State = PanelSelectedState.Hidden;
break;
}
UpdateState();
StateChanged?.Invoke(state);
}
}
public void UpdateState()
{
switch (state)
{
case BeatmapGroupState.Expanded:
Header.State = PanelSelectedState.Selected;
foreach (BeatmapPanel panel in BeatmapPanels)
panel.State = panel == SelectedPanel ? PanelSelectedState.Selected :
!panel.Filtered ? PanelSelectedState.NotSelected : PanelSelectedState.Hidden;
break;
case BeatmapGroupState.Collapsed:
Header.State = PanelSelectedState.NotSelected;
foreach (BeatmapPanel panel in BeatmapPanels)
panel.State = PanelSelectedState.Hidden;
break;
case BeatmapGroupState.Hidden:
Header.State = PanelSelectedState.Hidden;
foreach (BeatmapPanel panel in BeatmapPanels)
panel.State = PanelSelectedState.Hidden;
break;
}
}
public BeatmapGroup(BeatmapSetInfo beatmapSet, BeatmapManager manager)
{
if (beatmapSet == null)

View File

@ -327,6 +327,8 @@ namespace osu.Game.Screens.Select
computeYPositions();
selectedGroup?.UpdateState();
if (selectedGroup == null || selectedGroup.State == BeatmapGroupState.Hidden)
SelectNext();
else
@ -441,11 +443,13 @@ namespace osu.Game.Screens.Select
panel.MoveToX(-50, 500, Easing.OutExpo);
bool isHidden = panel.State == PanelSelectedState.Hidden;
//on first display we want to begin hidden under our group's header.
if (panel.Filtered || panel.Alpha == 0)
if (isHidden || panel.Alpha == 0)
panel.MoveToY(headerY);
movePanel(panel, !panel.Filtered, animated, ref currentY);
movePanel(panel, !isHidden, animated, ref currentY);
}
}
else
@ -479,7 +483,7 @@ namespace osu.Game.Screens.Select
{
try
{
if (panel == null)
if (panel == null || panel.Filtered == true)
panel = group.BeatmapPanels.First(p => !p.Filtered);
if (selectedPanel == panel) return;