2016-10-27 02:55:55 +00:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2016-10-27 10:52:48 +00:00
|
|
|
|
using System;
|
2016-11-23 02:59:50 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Configuration;
|
2016-11-12 10:44:16 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-11-23 02:59:50 +00:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2016-11-12 10:44:16 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-11-23 02:59:50 +00:00
|
|
|
|
using osu.Game.Configuration;
|
2016-11-12 10:44:16 +00:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2016-11-23 02:59:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
2016-10-27 02:55:55 +00:00
|
|
|
|
{
|
2016-10-27 10:52:48 +00:00
|
|
|
|
class BeatmapSetHeader : Panel
|
2016-10-27 02:55:55 +00:00
|
|
|
|
{
|
2016-11-11 02:35:58 +00:00
|
|
|
|
public Action<BeatmapSetHeader> GainedSelection;
|
|
|
|
|
private SpriteText title, artist;
|
|
|
|
|
private OsuConfigManager config;
|
2016-11-22 13:07:15 +00:00
|
|
|
|
private Bindable<bool> preferUnicode;
|
|
|
|
|
private WorkingBeatmap beatmap;
|
|
|
|
|
|
|
|
|
|
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
2016-10-27 02:55:55 +00:00
|
|
|
|
{
|
2016-11-22 13:07:15 +00:00
|
|
|
|
this.beatmap = beatmap;
|
2016-11-22 20:40:47 +00:00
|
|
|
|
Hidden = false;
|
2016-11-22 13:07:15 +00:00
|
|
|
|
|
2016-11-23 02:59:50 +00:00
|
|
|
|
Children = new Drawable[]
|
2016-10-27 02:55:55 +00:00
|
|
|
|
{
|
2016-11-22 13:07:15 +00:00
|
|
|
|
new PanelBackground(beatmap)
|
2016-11-20 19:34:16 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2016-11-05 11:00:14 +00:00
|
|
|
|
},
|
2016-10-27 02:55:55 +00:00
|
|
|
|
new FlowContainer
|
|
|
|
|
{
|
|
|
|
|
Direction = FlowDirection.VerticalOnly,
|
2016-11-20 19:34:16 +00:00
|
|
|
|
Padding = new MarginPadding { Top = 5, Left = 18, Right = 10, Bottom = 10 },
|
2016-10-27 02:55:55 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2016-11-11 02:35:58 +00:00
|
|
|
|
title = new SpriteText
|
2016-10-27 02:55:55 +00:00
|
|
|
|
{
|
2016-11-20 19:34:16 +00:00
|
|
|
|
Font = @"Exo2.0-BoldItalic",
|
2016-11-22 13:07:15 +00:00
|
|
|
|
Text = beatmap.BeatmapSetInfo.Metadata.Title,
|
2016-11-20 19:34:16 +00:00
|
|
|
|
TextSize = 22,
|
|
|
|
|
Shadow = true,
|
2016-10-27 02:55:55 +00:00
|
|
|
|
},
|
2016-11-11 02:35:58 +00:00
|
|
|
|
artist = new SpriteText
|
2016-10-27 02:55:55 +00:00
|
|
|
|
{
|
2016-11-20 19:34:16 +00:00
|
|
|
|
Margin = new MarginPadding { Top = -1 },
|
|
|
|
|
Font = @"Exo2.0-SemiBoldItalic",
|
2016-11-22 13:07:15 +00:00
|
|
|
|
Text = beatmap.BeatmapSetInfo.Metadata.Artist,
|
2016-11-20 19:34:16 +00:00
|
|
|
|
TextSize = 17,
|
|
|
|
|
Shadow = true,
|
2016-10-27 02:55:55 +00:00
|
|
|
|
},
|
|
|
|
|
new FlowContainer
|
|
|
|
|
{
|
2016-11-20 19:34:16 +00:00
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
2016-10-27 02:55:55 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2016-11-07 08:58:32 +00:00
|
|
|
|
new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)),
|
|
|
|
|
new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(246, 101, 166, 255)),
|
2016-10-27 02:55:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-11-22 10:48:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Selected()
|
|
|
|
|
{
|
|
|
|
|
base.Selected();
|
|
|
|
|
GainedSelection?.Invoke(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuConfigManager config)
|
|
|
|
|
{
|
|
|
|
|
this.config = config;
|
|
|
|
|
|
|
|
|
|
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
|
|
|
|
|
preferUnicode.ValueChanged += preferUnicode_changed;
|
|
|
|
|
preferUnicode_changed(preferUnicode, null);
|
|
|
|
|
}
|
|
|
|
|
private void preferUnicode_changed(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-11-22 13:07:15 +00:00
|
|
|
|
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 10:48:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
if (preferUnicode != null)
|
|
|
|
|
preferUnicode.ValueChanged -= preferUnicode_changed;
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 12:38:46 +00:00
|
|
|
|
class PanelBackground : BufferedContainer
|
2016-11-22 10:48:03 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly WorkingBeatmap working;
|
|
|
|
|
|
|
|
|
|
public PanelBackground(WorkingBeatmap working)
|
|
|
|
|
{
|
|
|
|
|
this.working = working;
|
2016-11-22 12:38:46 +00:00
|
|
|
|
|
|
|
|
|
CacheDrawnFrameBuffer = true;
|
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new FlowContainer
|
|
|
|
|
{
|
|
|
|
|
Depth = 1,
|
|
|
|
|
Direction = FlowDirection.HorizontalOnly,
|
|
|
|
|
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
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
Width = 0.4f,
|
|
|
|
|
},
|
|
|
|
|
// Piecewise-linear gradient with 3 segments to make it appear smoother
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColourInfo = ColourInfo.GradientHorizontal(Color4.Black, new Color4(0f, 0f, 0f, 0.9f)),
|
|
|
|
|
Width = 0.05f,
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColourInfo = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.9f), new Color4(0f, 0f, 0f, 0.1f)),
|
|
|
|
|
Width = 0.2f,
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColourInfo = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.1f), new Color4(0, 0, 0, 0)),
|
|
|
|
|
Width = 0.05f,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
2016-11-22 10:48:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuGameBase game)
|
|
|
|
|
{
|
2016-11-22 12:38:46 +00:00
|
|
|
|
new BeatmapBackground(working)
|
2016-11-22 10:48:03 +00:00
|
|
|
|
{
|
2016-11-22 12:38:46 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
}.Preload(game, (bg) =>
|
|
|
|
|
{
|
|
|
|
|
Add(bg);
|
|
|
|
|
ForceRedraw();
|
|
|
|
|
});
|
2016-11-22 10:48:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 12:38:46 +00:00
|
|
|
|
class BeatmapBackground : Sprite
|
2016-11-22 10:48:03 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly WorkingBeatmap working;
|
|
|
|
|
|
2016-11-22 12:38:46 +00:00
|
|
|
|
public BeatmapBackground(WorkingBeatmap working)
|
2016-11-22 10:48:03 +00:00
|
|
|
|
{
|
|
|
|
|
this.working = working;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuGameBase game)
|
|
|
|
|
{
|
|
|
|
|
Texture = working.Background;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
Scale = new Vector2(1366 / (Texture?.Width ?? 1) * 0.6f);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-27 02:55:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|