2020-09-07 20:08:48 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-09-07 20:08:48 +08:00
|
|
|
using System;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
|
|
|
namespace osu.Game.Collections
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A collection of beatmaps grouped by a name.
|
|
|
|
/// </summary>
|
|
|
|
public class BeatmapCollection
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Invoked whenever any change occurs on this <see cref="BeatmapCollection"/>.
|
|
|
|
/// </summary>
|
|
|
|
public event Action Changed;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The collection's name.
|
|
|
|
/// </summary>
|
|
|
|
public readonly Bindable<string> Name = new Bindable<string>();
|
|
|
|
|
|
|
|
/// <summary>
|
2022-06-08 17:23:09 +08:00
|
|
|
/// The <see cref="BeatmapInfo.MD5Hash"/>es of beatmaps contained by the collection.
|
2020-09-07 20:08:48 +08:00
|
|
|
/// </summary>
|
2022-06-10 13:03:51 +08:00
|
|
|
public readonly BindableList<string> BeatmapHashes = new BindableList<string>();
|
2020-09-07 20:08:48 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The date when this collection was last modified.
|
|
|
|
/// </summary>
|
|
|
|
public DateTimeOffset LastModifyDate { get; private set; } = DateTimeOffset.UtcNow;
|
|
|
|
|
|
|
|
public BeatmapCollection()
|
|
|
|
{
|
2022-06-10 13:03:51 +08:00
|
|
|
BeatmapHashes.CollectionChanged += (_, __) => onChange();
|
2020-09-07 20:08:48 +08:00
|
|
|
Name.ValueChanged += _ => onChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onChange()
|
|
|
|
{
|
|
|
|
LastModifyDate = DateTimeOffset.Now;
|
|
|
|
Changed?.Invoke();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|