2019-01-24 08:43:03 +00:00
|
|
|
|
// 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 09:19:50 +00:00
|
|
|
|
|
2017-03-23 04:19:29 +00:00
|
|
|
|
using System;
|
2020-02-12 10:52:47 +00:00
|
|
|
|
using System.Collections.Generic;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK.Graphics;
|
2017-03-23 03:22:31 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2017-03-23 03:22:31 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2017-06-20 05:54:23 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-23 03:22:31 +00:00
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class BeatmapDetailAreaTabControl : Container
|
|
|
|
|
{
|
2019-11-12 12:07:01 +00:00
|
|
|
|
public const float HEIGHT = 24;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-02-12 10:52:47 +00:00
|
|
|
|
public Bindable<BeatmapDetailAreaTabItem> Current
|
|
|
|
|
{
|
|
|
|
|
get => tabs.Current;
|
|
|
|
|
set => tabs.Current = value;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-16 04:33:52 +00:00
|
|
|
|
public Bindable<bool> CurrentModsFilter
|
|
|
|
|
{
|
|
|
|
|
get => modsCheckbox.Current;
|
|
|
|
|
set => modsCheckbox.Current = value;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 01:31:11 +00:00
|
|
|
|
public Action<BeatmapDetailAreaTabItem, bool> OnFilter; // passed the selected tab and if mods is checked
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-02-12 10:52:47 +00:00
|
|
|
|
public IReadOnlyList<BeatmapDetailAreaTabItem> TabItems
|
|
|
|
|
{
|
|
|
|
|
get => tabs.Items;
|
|
|
|
|
set => tabs.Items = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly OsuTabControlCheckbox modsCheckbox;
|
|
|
|
|
private readonly OsuTabControl<BeatmapDetailAreaTabItem> tabs;
|
|
|
|
|
private readonly Container tabsContainer;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-23 03:22:31 +00:00
|
|
|
|
public BeatmapDetailAreaTabControl()
|
|
|
|
|
{
|
|
|
|
|
Height = HEIGHT;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-23 03:22:31 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 1,
|
|
|
|
|
Colour = Color4.White.Opacity(0.2f),
|
|
|
|
|
},
|
2019-10-07 23:17:58 +00:00
|
|
|
|
tabsContainer = new Container
|
2017-03-23 03:22:31 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-02-12 10:52:47 +00:00
|
|
|
|
Child = tabs = new OsuTabControl<BeatmapDetailAreaTabItem>
|
2019-10-06 17:22:55 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-12-23 03:47:47 +00:00
|
|
|
|
IsSwitchable = true,
|
2019-10-06 17:22:55 +00:00
|
|
|
|
},
|
2017-03-23 03:22:31 +00:00
|
|
|
|
},
|
2017-03-31 08:38:33 +00:00
|
|
|
|
modsCheckbox = new OsuTabControlCheckbox
|
2017-03-23 03:22:31 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
2019-09-19 19:47:32 +00:00
|
|
|
|
Text = @"Selected Mods",
|
2019-07-26 06:51:51 +00:00
|
|
|
|
Alpha = 0,
|
2017-03-23 03:22:31 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-02-22 08:51:39 +00:00
|
|
|
|
tabs.Current.ValueChanged += _ => invokeOnFilter();
|
|
|
|
|
modsCheckbox.Current.ValueChanged += _ => invokeOnFilter();
|
2017-03-23 03:22:31 +00:00
|
|
|
|
}
|
2019-07-26 06:49:21 +00:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 00:06:39 +00:00
|
|
|
|
private void load(OsuColour colour)
|
2019-07-26 06:49:21 +00:00
|
|
|
|
{
|
|
|
|
|
modsCheckbox.AccentColour = tabs.AccentColour = colour.YellowLight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void invokeOnFilter()
|
|
|
|
|
{
|
|
|
|
|
OnFilter?.Invoke(tabs.Current.Value, modsCheckbox.Current.Value);
|
|
|
|
|
|
2020-02-12 10:52:47 +00:00
|
|
|
|
if (tabs.Current.Value.FilterableByMods)
|
|
|
|
|
{
|
|
|
|
|
modsCheckbox.FadeTo(1, 200, Easing.OutQuint);
|
|
|
|
|
tabsContainer.Padding = new MarginPadding { Right = 100 };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
modsCheckbox.FadeTo(0, 200, Easing.OutQuint);
|
|
|
|
|
tabsContainer.Padding = new MarginPadding();
|
|
|
|
|
}
|
2019-07-26 06:49:21 +00:00
|
|
|
|
}
|
2017-03-23 03:22:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|