1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 20:32:55 +08:00
osu-lazer/osu.Game/Screens/Select/BeatmapDetailArea.cs

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
2018-04-13 17:19:50 +08:00
using System;
2020-02-12 18:52:47 +08:00
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
namespace osu.Game.Screens.Select
{
2022-11-24 13:32:20 +08:00
public abstract partial class BeatmapDetailArea : Container
2018-04-13 17:19:50 +08:00
{
private const float details_padding = 10;
private WorkingBeatmap beatmap;
2019-02-28 12:31:40 +08:00
2020-02-12 18:52:47 +08:00
public virtual WorkingBeatmap Beatmap
2018-04-13 17:19:50 +08:00
{
get => beatmap;
2018-04-13 17:19:50 +08:00
set
{
beatmap = value;
2020-02-12 18:52:47 +08:00
2021-10-02 23:55:29 +08:00
Details.BeatmapInfo = value?.BeatmapInfo;
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()
2018-04-13 17:19:50 +08:00
{
AddRangeInternal(new Drawable[]
{
content = new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT },
2020-02-12 18:52:47 +08:00
Child = Details = new BeatmapDetails
2018-04-13 17:19:50 +08:00
{
2020-02-12 18:52:47 +08:00
RelativeSizeAxes = Axes.X,
Alpha = 0,
Margin = new MarginPadding { Top = details_padding },
}
2018-04-13 17:19:50 +08:00
},
2020-02-12 18:52:47 +08:00
tabControl = new BeatmapDetailAreaTabControl
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.X,
2020-02-12 18:52:47 +08:00
TabItems = CreateTabItems(),
OnFilter = OnTabChanged,
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()
{
}
2018-04-13 17:19:50 +08:00
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
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(),
};
2018-04-13 17:19:50 +08:00
}
}