2017-04-26 19:41:37 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2017-01-10 06:18:47 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2017-01-30 12:35:40 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-08-31 14:49:56 +08:00
|
|
|
|
using System.Linq;
|
2017-04-26 19:41:37 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-01-10 06:18:47 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-12-11 19:49:27 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-01-10 06:18:47 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-08-30 19:41:41 +08:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2017-04-26 19:41:37 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-08-30 19:41:41 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2017-01-10 06:18:47 +08:00
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
2016-10-27 10:55:55 +08:00
|
|
|
|
{
|
2017-08-30 19:41:41 +08:00
|
|
|
|
public class BeatmapSetHeader : Panel, IHasContextMenu
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
|
|
|
|
public Action<BeatmapSetHeader> GainedSelection;
|
2017-08-30 19:41:41 +08:00
|
|
|
|
|
2017-08-30 19:53:33 +08:00
|
|
|
|
public Action<BeatmapSetInfo> DeleteRequested;
|
2017-08-30 19:41:41 +08:00
|
|
|
|
|
2017-08-31 14:49:56 +08:00
|
|
|
|
public Action<BeatmapSetInfo> RestoreHiddenRequested;
|
|
|
|
|
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly WorkingBeatmap beatmap;
|
2017-11-21 21:27:56 +08:00
|
|
|
|
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly FillFlowContainer difficultyIcons;
|
2017-01-10 06:18:47 +08:00
|
|
|
|
|
|
|
|
|
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
2017-11-08 06:15:02 +08:00
|
|
|
|
if (beatmap == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(beatmap));
|
|
|
|
|
|
2017-01-10 06:18:47 +08:00
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
|
|
2017-11-21 21:27:56 +08:00
|
|
|
|
difficultyIcons = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Selected()
|
|
|
|
|
{
|
|
|
|
|
base.Selected();
|
|
|
|
|
GainedSelection?.Invoke(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(LocalisationEngine localisation)
|
|
|
|
|
{
|
|
|
|
|
if (localisation == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(localisation));
|
|
|
|
|
|
2017-01-10 06:18:47 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-11-22 22:46:04 +08:00
|
|
|
|
new DelayedLoadWrapper(
|
2017-04-02 14:56:12 +08:00
|
|
|
|
new PanelBackground(beatmap)
|
2017-03-28 13:35:18 +08:00
|
|
|
|
{
|
2017-04-02 14:56:12 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-07-23 02:50:25 +08:00
|
|
|
|
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
2017-11-23 16:12:23 +08:00
|
|
|
|
}, 300),
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2017-01-10 06:18:47 +08:00
|
|
|
|
Padding = new MarginPadding { Top = 5, Left = 18, Right = 10, Bottom = 10 },
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2017-03-28 13:35:18 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
2017-11-21 21:27:56 +08:00
|
|
|
|
new OsuSpriteText
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-BoldItalic",
|
2017-11-21 21:27:56 +08:00
|
|
|
|
Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title),
|
2017-01-10 06:18:47 +08:00
|
|
|
|
TextSize = 22,
|
|
|
|
|
Shadow = true,
|
|
|
|
|
},
|
2017-11-21 21:27:56 +08:00
|
|
|
|
new OsuSpriteText
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-SemiBoldItalic",
|
2017-11-21 21:27:56 +08:00
|
|
|
|
Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist),
|
2017-01-10 06:18:47 +08:00
|
|
|
|
TextSize = 17,
|
|
|
|
|
Shadow = true,
|
|
|
|
|
},
|
2017-11-21 21:27:56 +08:00
|
|
|
|
difficultyIcons
|
2017-01-10 06:18:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-11-22 18:48:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private class PanelBackground : BufferedContainer
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
|
|
|
|
public PanelBackground(WorkingBeatmap working)
|
|
|
|
|
{
|
|
|
|
|
CacheDrawnFrameBuffer = true;
|
|
|
|
|
|
2017-03-17 17:28:21 +08:00
|
|
|
|
Children = new Drawable[]
|
2016-11-22 20:38:46 +08:00
|
|
|
|
{
|
2017-03-17 17:28:21 +08:00
|
|
|
|
new BeatmapBackgroundSprite(working)
|
|
|
|
|
{
|
2017-06-28 17:24:23 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-03-17 17:28:21 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2016-11-22 20:38:46 +08:00
|
|
|
|
{
|
2016-11-30 03:50:12 +08:00
|
|
|
|
Depth = -1,
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2016-11-22 20:38:46 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-04-26 19:41:37 +08:00
|
|
|
|
// This makes the gradient not be perfectly horizontal, but diagonal at a ~40° angle
|
2016-11-22 20:38:46 +08:00
|
|
|
|
Shear = new Vector2(0.8f, 0),
|
|
|
|
|
Alpha = 0.5f,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
// The left half with no gradient applied
|
2017-01-10 06:18:47 +08:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
Width = 0.4f,
|
2016-11-22 20:38:46 +08:00
|
|
|
|
},
|
|
|
|
|
// Piecewise-linear gradient with 3 segments to make it appear smoother
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-07-23 13:30:50 +08:00
|
|
|
|
Colour = ColourInfo.GradientHorizontal(
|
2017-01-13 05:38:27 +08:00
|
|
|
|
Color4.Black, new Color4(0f, 0f, 0f, 0.9f)),
|
2016-11-22 20:38:46 +08:00
|
|
|
|
Width = 0.05f,
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-07-23 13:30:50 +08:00
|
|
|
|
Colour = ColourInfo.GradientHorizontal(
|
2017-01-13 05:38:27 +08:00
|
|
|
|
new Color4(0f, 0f, 0f, 0.9f), new Color4(0f, 0f, 0f, 0.1f)),
|
2016-11-22 20:38:46 +08:00
|
|
|
|
Width = 0.2f,
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-07-23 13:30:50 +08:00
|
|
|
|
Colour = ColourInfo.GradientHorizontal(
|
2017-01-13 05:38:27 +08:00
|
|
|
|
new Color4(0f, 0f, 0f, 0.1f), new Color4(0, 0, 0, 0)),
|
2016-11-22 20:38:46 +08:00
|
|
|
|
Width = 0.05f,
|
|
|
|
|
},
|
|
|
|
|
}
|
2017-01-10 06:18:47 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
2016-11-22 18:48:03 +08:00
|
|
|
|
}
|
2017-01-10 06:18:47 +08:00
|
|
|
|
}
|
2017-01-30 12:35:40 +08:00
|
|
|
|
|
|
|
|
|
public void AddDifficultyIcons(IEnumerable<BeatmapPanel> panels)
|
|
|
|
|
{
|
2017-11-08 06:15:51 +08:00
|
|
|
|
if (panels == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(panels));
|
|
|
|
|
|
2017-12-11 19:49:27 +08:00
|
|
|
|
difficultyIcons.AddRange(panels.Select(p => new FilterableDifficultyIcon(p)));
|
2017-01-30 12:35:40 +08:00
|
|
|
|
}
|
2017-08-30 19:41:41 +08:00
|
|
|
|
|
|
|
|
|
public MenuItem[] ContextMenuItems
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
List<MenuItem> items = new List<MenuItem>();
|
|
|
|
|
|
|
|
|
|
if (State == PanelSelectedState.NotSelected)
|
|
|
|
|
items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => State = PanelSelectedState.Selected));
|
|
|
|
|
|
2017-08-31 14:49:56 +08:00
|
|
|
|
if (beatmap.BeatmapSetInfo.Beatmaps.Any(b => b.Hidden))
|
|
|
|
|
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => RestoreHiddenRequested?.Invoke(beatmap.BeatmapSetInfo)));
|
|
|
|
|
|
2017-08-30 19:53:33 +08:00
|
|
|
|
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => DeleteRequested?.Invoke(beatmap.BeatmapSetInfo)));
|
2017-08-30 19:41:41 +08:00
|
|
|
|
|
|
|
|
|
return items.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-11 19:49:27 +08:00
|
|
|
|
|
|
|
|
|
public class FilterableDifficultyIcon : DifficultyIcon
|
|
|
|
|
{
|
|
|
|
|
private readonly BindableBool filtered = new BindableBool();
|
|
|
|
|
|
|
|
|
|
public FilterableDifficultyIcon(BeatmapPanel panel)
|
|
|
|
|
: base(panel.Beatmap)
|
|
|
|
|
{
|
|
|
|
|
filtered.BindTo(panel.Filtered);
|
|
|
|
|
filtered.ValueChanged += v => this.FadeTo(v ? 0.1f : 1, 100);
|
|
|
|
|
filtered.TriggerChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-27 10:55:55 +08:00
|
|
|
|
}
|
2017-11-21 23:17:33 +08:00
|
|
|
|
}
|