1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 20:33:37 +08:00
osu-lazer/osu.Game/Screens/Select/BeatmapDetailArea.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

109 lines
3.3 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
using System;
2020-02-12 18:52:47 +08:00
using osu.Framework.Bindables;
2017-03-23 11:22:31 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-03-23 12:19:29 +08:00
using osu.Game.Beatmaps;
2018-04-13 17:19:50 +08:00
2017-03-23 11:22:31 +08:00
namespace osu.Game.Screens.Select
{
2020-02-12 18:52:47 +08:00
public abstract class BeatmapDetailArea : Container
2017-03-23 11:22:31 +08:00
{
private const float details_padding = 10;
2018-04-13 17:19:50 +08:00
private WorkingBeatmap beatmap;
2019-02-28 12:31:40 +08:00
2020-02-12 18:52:47 +08:00
public virtual WorkingBeatmap Beatmap
2017-03-23 12:19:29 +08:00
{
get => beatmap;
set
{
beatmap = value;
2020-02-12 18:52:47 +08:00
2021-10-02 23:55:29 +08:00
Details.BeatmapInfo = value?.BeatmapInfo;
}
2017-03-23 12:19:29 +08:00
}
2018-04-13 17:19:50 +08:00
2020-02-12 18:52:47 +08:00
public readonly BeatmapDetails Details;
2020-02-14 16:50:53 +08:00
protected Bindable<BeatmapDetailAreaTabItem> CurrentTab => tabControl.Current;
2020-02-12 18:52:47 +08:00
protected Bindable<bool> CurrentModsFilter => tabControl.CurrentModsFilter;
2020-02-12 18:52:47 +08:00
private readonly Container content;
protected override Container<Drawable> Content => content;
private readonly BeatmapDetailAreaTabControl tabControl;
protected BeatmapDetailArea()
2017-03-23 11:22:31 +08:00
{
2017-07-11 21:58:06 +08:00
AddRangeInternal(new Drawable[]
2017-03-23 11:22:31 +08:00
{
content = new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT },
2020-02-12 18:52:47 +08:00
Child = Details = new BeatmapDetails
2017-03-23 12:19:29 +08:00
{
2020-02-12 18:52:47 +08:00
RelativeSizeAxes = Axes.X,
Alpha = 0,
Margin = new MarginPadding { Top = details_padding },
}
2017-03-23 11:22:31 +08:00
},
2020-02-12 18:52:47 +08:00
tabControl = new BeatmapDetailAreaTabControl
2017-03-23 12:19:29 +08:00
{
RelativeSizeAxes = Axes.X,
2020-02-12 18:52:47 +08:00
TabItems = CreateTabItems(),
OnFilter = OnTabChanged,
2017-03-23 12:19:29 +08:00
},
});
}
2018-04-13 17:19:50 +08:00
2020-02-12 18:52:47 +08:00
/// <summary>
/// Refreshes the currently-displayed details.
/// </summary>
public virtual void Refresh()
{
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
2018-04-13 17:19:50 +08:00
2017-09-08 02:38:23 +08:00
Details.Height = Math.Min(DrawHeight - details_padding * 3 - BeatmapDetailAreaTabControl.HEIGHT, 450);
}
2020-02-12 18:52:47 +08:00
/// <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)
{
2022-06-24 20:25:23 +08:00
case BeatmapDetailAreaDetailTabItem:
2020-02-12 18:52:47 +08:00
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(),
};
2017-03-23 11:22:31 +08:00
}
}