1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Add factory method for various card sizes

This commit is contained in:
Bartłomiej Dach 2021-11-27 16:20:51 +01:00
parent 048ca98f4a
commit cd4c1bc678
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
2 changed files with 33 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#nullable enable
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -76,5 +77,23 @@ namespace osu.Game.Beatmaps.Drawables.Cards
IdleContent.FadeTo(showProgress ? 0 : 1, TRANSITION_DURATION, Easing.OutQuint);
DownloadInProgressContent.FadeTo(showProgress ? 1 : 0, TRANSITION_DURATION, Easing.OutQuint);
}
/// <summary>
/// Creates a beatmap card of the given <paramref name="size"/> for the supplied <paramref name="beatmapSet"/>.
/// </summary>
public static BeatmapCard Create(APIBeatmapSet beatmapSet, BeatmapCardSize size, bool allowExpansion = true)
{
switch (size)
{
case BeatmapCardSize.Normal:
return new BeatmapCardNormal(beatmapSet, allowExpansion);
case BeatmapCardSize.Extra:
return new BeatmapCardExtra(beatmapSet, allowExpansion);
default:
throw new ArgumentOutOfRangeException(nameof(size), size, @"Unsupported card size");
}
}
}
}

View File

@ -0,0 +1,14 @@
// 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.
namespace osu.Game.Beatmaps.Drawables.Cards
{
/// <summary>
/// Enumeration for all available sizes of <see cref="BeatmapCard"/>.
/// </summary>
public enum BeatmapCardSize
{
Normal,
Extra
}
}