Refactor BeatmapSetOverlay to use chained bindables instead of accessors to distribute changes

This commit is contained in:
Jamie Taylor
2019-02-28 18:44:40 +09:00
parent bfe3d5708d
commit b7f7174055
2 changed files with 19 additions and 41 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -25,26 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet
private readonly Box successRateBackground;
private readonly SuccessRate successRate;
private BeatmapSetInfo beatmapSet;
public BeatmapSetInfo BeatmapSet
{
get => beatmapSet;
set
{
if (value == beatmapSet) return;
beatmapSet = value;
updateDisplay();
}
}
private void updateDisplay()
{
source.Text = BeatmapSet?.Metadata.Source ?? string.Empty;
tags.Text = BeatmapSet?.Metadata.Tags ?? string.Empty;
}
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
public BeatmapInfo Beatmap
{
@ -131,14 +113,18 @@ namespace osu.Game.Overlays.BeatmapSet
},
},
};
BeatmapSet.ValueChanged += b =>
{
source.Text = b.NewValue?.Metadata.Source ?? string.Empty;
tags.Text = b.NewValue?.Metadata.Tags ?? string.Empty;
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
successRateBackground.Colour = colours.GrayE;
updateDisplay();
}
private class MetadataSection : FillFlowContainer