2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// 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-01-10 06:18:47 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Configuration;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-01-10 06:18:47 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
2016-10-27 10:55:55 +08:00
|
|
|
|
{
|
2017-03-17 18:54:51 +08:00
|
|
|
|
public class BeatmapSetHeader : Panel
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
|
|
|
|
public Action<BeatmapSetHeader> GainedSelection;
|
|
|
|
|
private SpriteText title, artist;
|
|
|
|
|
private OsuConfigManager config;
|
|
|
|
|
private Bindable<bool> preferUnicode;
|
|
|
|
|
private WorkingBeatmap beatmap;
|
2017-03-02 02:33:01 +08:00
|
|
|
|
private FillFlowContainer difficultyIcons;
|
2017-01-10 06:18:47 +08:00
|
|
|
|
|
|
|
|
|
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
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,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2017-01-31 17:53:52 +08:00
|
|
|
|
title = new OsuSpriteText
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-BoldItalic",
|
|
|
|
|
Text = beatmap.BeatmapSetInfo.Metadata.Title,
|
|
|
|
|
TextSize = 22,
|
|
|
|
|
Shadow = true,
|
|
|
|
|
},
|
2017-01-31 17:53:52 +08:00
|
|
|
|
artist = new OsuSpriteText
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-SemiBoldItalic",
|
|
|
|
|
Text = beatmap.BeatmapSetInfo.Metadata.Artist,
|
|
|
|
|
TextSize = 17,
|
|
|
|
|
Shadow = true,
|
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
difficultyIcons = new FillFlowContainer
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-11-22 18:48:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Selected()
|
|
|
|
|
{
|
|
|
|
|
base.Selected();
|
|
|
|
|
GainedSelection?.Invoke(this);
|
2017-01-10 06:18:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 18:48:03 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-03-17 17:28:21 +08:00
|
|
|
|
private void load(OsuConfigManager config, OsuGameBase game)
|
2016-11-22 18:48:03 +08:00
|
|
|
|
{
|
|
|
|
|
this.config = config;
|
|
|
|
|
|
|
|
|
|
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
|
|
|
|
|
preferUnicode.ValueChanged += preferUnicode_changed;
|
2017-01-10 06:18:47 +08:00
|
|
|
|
preferUnicode_changed(preferUnicode, null);
|
2017-03-17 17:28:21 +08:00
|
|
|
|
|
|
|
|
|
new PanelBackground(beatmap)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Depth = 1,
|
|
|
|
|
}.LoadAsync(game, b =>
|
|
|
|
|
{
|
|
|
|
|
Add(b);
|
|
|
|
|
b.FadeInFromZero(200);
|
|
|
|
|
});
|
2016-11-22 18:48:03 +08:00
|
|
|
|
}
|
2017-01-10 06:18:47 +08:00
|
|
|
|
|
|
|
|
|
private void preferUnicode_changed(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
title.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Title, beatmap.BeatmapSetInfo.Metadata.TitleUnicode);
|
|
|
|
|
artist.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Artist, beatmap.BeatmapSetInfo.Metadata.ArtistUnicode);
|
2016-11-22 18:48:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
2017-01-10 06:18:47 +08:00
|
|
|
|
{
|
|
|
|
|
if (preferUnicode != null)
|
2016-11-22 18:48:03 +08:00
|
|
|
|
preferUnicode.ValueChanged -= preferUnicode_changed;
|
|
|
|
|
base.Dispose(isDisposing);
|
2017-01-10 06:18:47 +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)
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
// This makes the gradient not be perfectly horizontal, but diagonal at a ~40<34> angle
|
|
|
|
|
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-01-13 05:38:27 +08:00
|
|
|
|
ColourInfo = ColourInfo.GradientHorizontal(
|
|
|
|
|
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-01-13 05:38:27 +08:00
|
|
|
|
ColourInfo = ColourInfo.GradientHorizontal(
|
|
|
|
|
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-01-13 05:38:27 +08:00
|
|
|
|
ColourInfo = ColourInfo.GradientHorizontal(
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
foreach (var p in panels)
|
|
|
|
|
difficultyIcons.Add(new DifficultyIcon(p.Beatmap));
|
|
|
|
|
}
|
2016-10-27 10:55:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|