mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Use bindable propagation rather than properties
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Localisation;
|
||||
@ -9,7 +10,7 @@ using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Components
|
||||
{
|
||||
public class BeatmapTitle : FillFlowContainer<OsuSpriteText>
|
||||
public class BeatmapTitle : CompositeDrawable
|
||||
{
|
||||
private readonly OsuSpriteText beatmapTitle, beatmapDash, beatmapArtist;
|
||||
|
||||
@ -18,31 +19,25 @@ namespace osu.Game.Screens.Multi.Components
|
||||
set { beatmapTitle.TextSize = beatmapDash.TextSize = beatmapArtist.TextSize = value; }
|
||||
}
|
||||
|
||||
private BeatmapInfo beatmap;
|
||||
|
||||
public BeatmapInfo Beatmap
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == beatmap) return;
|
||||
beatmap = value;
|
||||
|
||||
if (IsLoaded)
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||
|
||||
public BeatmapTitle()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Direction = FillDirection.Horizontal;
|
||||
|
||||
Children = new[]
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
beatmapTitle = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", },
|
||||
beatmapDash = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", },
|
||||
beatmapArtist = new OsuSpriteText { Font = @"Exo2.0-RegularItalic", },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
beatmapTitle = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", },
|
||||
beatmapDash = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", },
|
||||
beatmapArtist = new OsuSpriteText { Font = @"Exo2.0-RegularItalic", },
|
||||
}
|
||||
};
|
||||
|
||||
Beatmap.BindValueChanged(v => updateText());
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -53,16 +48,19 @@ namespace osu.Game.Screens.Multi.Components
|
||||
|
||||
private void updateText()
|
||||
{
|
||||
if (beatmap == null)
|
||||
if (!IsLoaded)
|
||||
return;
|
||||
|
||||
if (Beatmap.Value == null)
|
||||
{
|
||||
beatmapTitle.Text = "Changing map";
|
||||
beatmapDash.Text = beatmapArtist.Text = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
beatmapTitle.Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title));
|
||||
beatmapTitle.Text = new LocalisedString((Beatmap.Value.Metadata.TitleUnicode, Beatmap.Value.Metadata.Title));
|
||||
beatmapDash.Text = @" - ";
|
||||
beatmapArtist.Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist));
|
||||
beatmapArtist.Text = new LocalisedString((Beatmap.Value.Metadata.ArtistUnicode, Beatmap.Value.Metadata.Artist));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user