mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Tidy shit up; reduce number of unnecssesary events being fired.
This commit is contained in:
parent
5dc495e41d
commit
42ad96778e
@ -28,7 +28,7 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
|
||||
private BeatmapGroupState state;
|
||||
|
||||
public IEnumerable<BeatmapPanel> BeatmapPanels;
|
||||
public List<BeatmapPanel> BeatmapPanels;
|
||||
|
||||
public BeatmapGroupState State
|
||||
{
|
||||
@ -43,9 +43,6 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
difficulties.Show();
|
||||
|
||||
header.State = PanelSelectedState.Selected;
|
||||
|
||||
if (SelectedPanel == null)
|
||||
((BeatmapPanel)difficulties.Children.FirstOrDefault()).State = PanelSelectedState.Selected;
|
||||
break;
|
||||
case BeatmapGroupState.Collapsed:
|
||||
FadeTo(0.5f, 250);
|
||||
@ -66,13 +63,13 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
BeatmapPanels = beatmapSet.Beatmaps.Select(b =>
|
||||
new BeatmapPanel(this.beatmapSet, b)
|
||||
new BeatmapPanel(b)
|
||||
{
|
||||
GainedSelection = panelGainedSelection,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
});
|
||||
}).ToList();
|
||||
|
||||
|
||||
Children = new[]
|
||||
@ -117,17 +114,25 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
{
|
||||
State = BeatmapGroupState.Expanded;
|
||||
|
||||
SelectionChanged?.Invoke(this, SelectedPanel.Beatmap);
|
||||
if (SelectedPanel == null)
|
||||
BeatmapPanels.First().State = PanelSelectedState.Selected;
|
||||
}
|
||||
|
||||
private void panelGainedSelection(BeatmapPanel panel)
|
||||
{
|
||||
State = BeatmapGroupState.Expanded;
|
||||
|
||||
if (SelectedPanel != null) SelectedPanel.State = PanelSelectedState.NotSelected;
|
||||
SelectedPanel = panel;
|
||||
try
|
||||
{
|
||||
if (SelectedPanel == panel) return;
|
||||
|
||||
SelectionChanged?.Invoke(this, panel.Beatmap);
|
||||
if (SelectedPanel != null)
|
||||
SelectedPanel.State = PanelSelectedState.NotSelected;
|
||||
SelectedPanel = panel;
|
||||
}
|
||||
finally
|
||||
{
|
||||
State = BeatmapGroupState.Expanded;
|
||||
SelectionChanged?.Invoke(this, panel.Beatmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
GainedSelection?.Invoke(this);
|
||||
}
|
||||
|
||||
public BeatmapPanel(BeatmapSetInfo set, BeatmapInfo beatmap)
|
||||
public BeatmapPanel(BeatmapInfo beatmap)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
Height *= 0.75f;
|
||||
@ -67,7 +67,7 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = $" mapped by {(beatmap.Metadata ?? set.Metadata).Author}",
|
||||
Text = $" mapped by {(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author}",
|
||||
TextSize = 16,
|
||||
},
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ namespace osu.Game.Beatmaps.Drawable
|
||||
set
|
||||
{
|
||||
if (state == value) return;
|
||||
|
||||
state = value;
|
||||
|
||||
switch (state)
|
||||
|
@ -180,8 +180,13 @@ namespace osu.Game.GameModes.Play
|
||||
beatmapSetFlow.Children.Cast<BeatmapGroup>().First(b =>
|
||||
{
|
||||
var panel = b.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||
panel?.TriggerClick();
|
||||
return panel != null;
|
||||
if (panel != null)
|
||||
{
|
||||
panel.State = PanelSelectedState.Selected;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@ -228,8 +233,20 @@ namespace osu.Game.GameModes.Play
|
||||
{
|
||||
var group = new BeatmapGroup(beatmapSet) { SelectionChanged = selectionChanged };
|
||||
beatmapSetFlow.Add(group);
|
||||
if (beatmapSetFlow.Children.Count() == 1)
|
||||
group.State = BeatmapGroupState.Expanded;
|
||||
if (Beatmap == null)
|
||||
{
|
||||
if (beatmapSetFlow.Children.Count() == 1)
|
||||
group.State = BeatmapGroupState.Expanded;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedBeatmapInfo?.Equals(Beatmap.BeatmapInfo) != true)
|
||||
{
|
||||
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(Beatmap.BeatmapInfo));
|
||||
if (panel != null)
|
||||
panel.State = PanelSelectedState.Selected;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user