1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 12:07:23 +08:00
osu-lazer/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs

113 lines
4.1 KiB
C#
Raw Normal View History

2016-10-27 10:55:55 +08:00
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Game.Database;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Allocation;
2016-11-11 10:35:58 +08:00
using osu.Framework.Configuration;
using osu.Game.Configuration;
2016-10-27 10:55:55 +08:00
namespace osu.Game.Beatmaps.Drawable
{
class BeatmapSetHeader : Panel
2016-10-27 10:55:55 +08:00
{
2016-11-11 10:35:58 +08:00
public Action<BeatmapSetHeader> GainedSelection;
private BeatmapSetInfo beatmapSet;
private SpriteText title, artist;
private OsuConfigManager config;
private Bindable<bool> preferUnicode;
protected override void Selected()
{
base.Selected();
Width = 1;
GainedSelection?.Invoke(this);
}
protected override void Deselected()
{
base.Deselected();
Width = 0.8f;
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
2016-11-11 10:35:58 +08:00
{
this.config = config;
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode.ValueChanged += preferUnicode_changed;
preferUnicode_changed(preferUnicode, null);
2016-11-11 10:35:58 +08:00
}
private void preferUnicode_changed(object sender, EventArgs e)
{
title.Text = config.GetUnicodeString(beatmapSet.Metadata.Title, beatmapSet.Metadata.TitleUnicode);
artist.Text = config.GetUnicodeString(beatmapSet.Metadata.Artist, beatmapSet.Metadata.ArtistUnicode);
}
2016-11-11 10:35:58 +08:00
protected override void Dispose(bool isDisposing)
{
if (preferUnicode != null)
preferUnicode.ValueChanged -= preferUnicode_changed;
base.Dispose(isDisposing);
}
2016-11-05 19:00:14 +08:00
public BeatmapSetHeader(BeatmapSetInfo beatmapSet, WorkingBeatmap working)
2016-10-27 10:55:55 +08:00
{
2016-11-11 10:35:58 +08:00
this.beatmapSet = beatmapSet;
2016-10-27 10:55:55 +08:00
Children = new Framework.Graphics.Drawable[]
{
2016-11-05 19:00:14 +08:00
working.Background == null ? new Box{ RelativeSizeAxes = Axes.Both, Colour = new Color4(20, 20, 20, 255) } : new Sprite
2016-10-27 10:55:55 +08:00
{
2016-11-05 19:00:14 +08:00
Texture = working.Background,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2016-11-06 11:37:41 +08:00
Scale = new Vector2(1366 / working.Background.Width * 0.6f),
2016-11-05 19:00:14 +08:00
Colour = new Color4(200, 200, 200, 255),
},
2016-10-27 10:55:55 +08:00
new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Spacing = new Vector2(0, 2),
Padding = new MarginPadding { Top = 10, Left = 15, Right = 10, Bottom = 10 },
2016-10-27 10:55:55 +08:00
AutoSizeAxes = Axes.Both,
Children = new[]
{
2016-11-11 10:35:58 +08:00
title = new SpriteText
2016-10-27 10:55:55 +08:00
{
Font = @"Exo2.0-SemiBoldItalic",
2016-11-11 10:35:58 +08:00
Text = beatmapSet.Metadata.Title,
TextSize = 22
2016-10-27 10:55:55 +08:00
},
2016-11-11 10:35:58 +08:00
artist = new SpriteText
2016-10-27 10:55:55 +08:00
{
Font = @"Exo2.0-MediumItalic",
2016-11-11 10:35:58 +08:00
Text = beatmapSet.Metadata.Artist,
2016-10-27 10:55:55 +08:00
TextSize = 16
},
new FlowContainer
{
AutoSizeAxes = Axes.Both,
Children = new[]
{
2016-11-07 16:58:32 +08: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 10:55:55 +08:00
}
}
}
}
};
Deselected();
2016-10-27 10:55:55 +08:00
}
}
}