mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 19:22:56 +08:00
Change panel selection logic to avoid looping.
This commit is contained in:
parent
ba5b2f2d73
commit
ce73ae792f
@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
private const float collapsedAlpha = 0.5f;
|
||||
private const float collapsedWidth = 0.8f;
|
||||
|
||||
private BeatmapInfo selectedBeatmap;
|
||||
private BeatmapPanel selectedPanel;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when one of our difficulties was selected. Will fire on first expand.
|
||||
@ -53,9 +53,9 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
header.GlowRadius = 5;
|
||||
header.BorderColour = new Color4(header.BorderColour.R, header.BorderColour.G, header.BorderColour.B, 255);
|
||||
|
||||
if (selectedBeatmap == null)
|
||||
if (selectedPanel == null)
|
||||
(difficulties.Children.FirstOrDefault() as BeatmapPanel).Selected = true;
|
||||
SelectionChanged?.Invoke(this, selectedBeatmap);
|
||||
SelectionChanged?.Invoke(this, selectedPanel?.Beatmap);
|
||||
break;
|
||||
case GroupState.Collapsed:
|
||||
FadeTo(collapsedAlpha, 250);
|
||||
@ -122,14 +122,12 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
State = GroupState.Collapsed;
|
||||
}
|
||||
|
||||
private void panelGainedSelection(BeatmapInfo map)
|
||||
private void panelGainedSelection(BeatmapPanel panel)
|
||||
{
|
||||
selectedBeatmap = map;
|
||||
|
||||
foreach (BeatmapPanel panel in difficulties.Children)
|
||||
if (panel.Beatmap != map) panel.Selected = false;
|
||||
if (selectedPanel != null) selectedPanel.Selected = false;
|
||||
selectedPanel = panel;
|
||||
|
||||
SelectionChanged?.Invoke(this, map);
|
||||
SelectionChanged?.Invoke(this, panel.Beatmap);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
{
|
||||
public BeatmapInfo Beatmap;
|
||||
|
||||
public Action<BeatmapInfo> GainedSelection;
|
||||
public Action<BeatmapPanel> GainedSelection;
|
||||
|
||||
private bool selected;
|
||||
|
||||
@ -38,7 +38,7 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
selected ? 255 : 0);
|
||||
GlowRadius = selected ? 3 : 0;
|
||||
|
||||
if (selected) GainedSelection?.Invoke(Beatmap);
|
||||
if (selected) GainedSelection?.Invoke(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user