mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Make beatmap detail area abstractable
This commit is contained in:
@ -2,37 +2,44 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class BeatmapDetailArea : Container
|
||||
public abstract class BeatmapDetailArea : Container
|
||||
{
|
||||
private const float details_padding = 10;
|
||||
|
||||
private readonly Container content;
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
public readonly BeatmapDetails Details;
|
||||
public readonly BeatmapLeaderboard Leaderboard;
|
||||
|
||||
private WorkingBeatmap beatmap;
|
||||
|
||||
public WorkingBeatmap Beatmap
|
||||
public virtual WorkingBeatmap Beatmap
|
||||
{
|
||||
get => beatmap;
|
||||
set
|
||||
{
|
||||
beatmap = value;
|
||||
Details.Beatmap = beatmap?.BeatmapInfo;
|
||||
Leaderboard.Beatmap = beatmap is DummyWorkingBeatmap ? null : beatmap?.BeatmapInfo;
|
||||
|
||||
Details.Beatmap = value?.BeatmapInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapDetailArea()
|
||||
public readonly BeatmapDetails Details;
|
||||
|
||||
protected Bindable<BeatmapDetailAreaTabItem> CurrentTab
|
||||
{
|
||||
get => tabControl.Current;
|
||||
set => tabControl.Current = value;
|
||||
}
|
||||
|
||||
private readonly Container content;
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private readonly BeatmapDetailAreaTabControl tabControl;
|
||||
|
||||
protected BeatmapDetailArea()
|
||||
{
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
@ -40,51 +47,62 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT },
|
||||
},
|
||||
new BeatmapDetailAreaTabControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
OnFilter = (tab, mods) =>
|
||||
Child = Details = new BeatmapDetails
|
||||
{
|
||||
Leaderboard.FilterMods = mods;
|
||||
|
||||
switch (tab)
|
||||
{
|
||||
case BeatmapDetailTab.Details:
|
||||
Details.Show();
|
||||
Leaderboard.Hide();
|
||||
break;
|
||||
|
||||
default:
|
||||
Details.Hide();
|
||||
Leaderboard.Scope = (BeatmapLeaderboardScope)tab - 1;
|
||||
Leaderboard.Show();
|
||||
break;
|
||||
}
|
||||
},
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Alpha = 0,
|
||||
Margin = new MarginPadding { Top = details_padding },
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
Details = new BeatmapDetails
|
||||
tabControl = new BeatmapDetailAreaTabControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Alpha = 0,
|
||||
Margin = new MarginPadding { Top = details_padding },
|
||||
TabItems = CreateTabItems(),
|
||||
OnFilter = OnTabChanged,
|
||||
},
|
||||
Leaderboard = new BeatmapLeaderboard
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the currently-displayed details.
|
||||
/// </summary>
|
||||
public virtual void Refresh()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
Details.Height = Math.Min(DrawHeight - details_padding * 3 - BeatmapDetailAreaTabControl.HEIGHT, 450);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a new tab is selected.
|
||||
/// </summary>
|
||||
/// <param name="tab">The tab that was selected.</param>
|
||||
/// <param name="selectedMods">Whether the currently-selected mods should be considered.</param>
|
||||
protected virtual void OnTabChanged(BeatmapDetailAreaTabItem tab, bool selectedMods)
|
||||
{
|
||||
switch (tab)
|
||||
{
|
||||
case BeatmapDetailAreaDetailTabItem _:
|
||||
Details.Show();
|
||||
break;
|
||||
|
||||
default:
|
||||
Details.Hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the tabs to be displayed.
|
||||
/// </summary>
|
||||
/// <returns>The tabs.</returns>
|
||||
protected virtual BeatmapDetailAreaTabItem[] CreateTabItems() => new BeatmapDetailAreaTabItem[]
|
||||
{
|
||||
new BeatmapDetailAreaDetailTabItem(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user