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:
parent
048ca98f4a
commit
cd4c1bc678
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
osu.Game/Beatmaps/Drawables/Cards/BeatmapCardSize.cs
Normal file
14
osu.Game/Beatmaps/Drawables/Cards/BeatmapCardSize.cs
Normal 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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user