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