2020-03-31 14:10:15 +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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
using osu.Framework.Allocation;
|
2020-03-31 17:08:05 +08:00
|
|
|
using osu.Framework.Bindables;
|
2020-03-31 14:10:15 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
2020-03-31 17:08:05 +08:00
|
|
|
using osu.Game.Skinning;
|
2020-03-31 14:10:15 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A <see cref="CompositeDrawable"/> which is placed somewhere within a <see cref="Column"/>.
|
|
|
|
/// </summary>
|
|
|
|
public class LegacyManiaColumnElement : CompositeDrawable
|
|
|
|
{
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
[CanBeNull]
|
|
|
|
protected ManiaStage Stage { get; private set; }
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
protected Column Column { get; private set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The column index to use for texture lookups, in the case of no user-provided configuration.
|
|
|
|
/// </summary>
|
|
|
|
protected int FallbackColumnIndex { get; private set; }
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
if (Stage == null)
|
|
|
|
FallbackColumnIndex = Column.Index % 2 + 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int dist = Math.Min(Column.Index, Stage.Columns.Count - Column.Index - 1);
|
|
|
|
FallbackColumnIndex = dist % 2 + 1;
|
|
|
|
}
|
|
|
|
}
|
2020-03-31 17:08:05 +08:00
|
|
|
|
2020-03-31 17:18:53 +08:00
|
|
|
/// <summary>
|
2020-03-31 17:48:37 +08:00
|
|
|
/// Retrieve a per-column-count skin configuration.
|
2020-03-31 17:18:53 +08:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="skin">The skin from which configuration is retrieved.</param>
|
|
|
|
/// <param name="lookup">The value to retrieve.</param>
|
2020-03-31 17:48:37 +08:00
|
|
|
/// <param name="index">If not null, denotes the index of the column to which the entry applies.</param>
|
2020-03-31 17:32:05 +08:00
|
|
|
protected IBindable<T> GetManiaSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup, int? index = null)
|
2020-03-31 17:08:05 +08:00
|
|
|
=> skin.GetConfig<LegacyManiaSkinConfigurationLookup, T>(
|
2020-03-31 17:48:37 +08:00
|
|
|
new LegacyManiaSkinConfigurationLookup(Stage?.Columns.Count ?? 4, lookup, index));
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieve a per-column skin configuration.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="skin">The skin from which configuration is retrieved.</param>
|
|
|
|
/// <param name="lookup">The value to retrieve.</param>
|
|
|
|
/// <param name="index">The index of the column to which the entry applies. Defaults to the column index.</param>
|
|
|
|
protected IBindable<T> GetPerColumnSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup, int? index = null)
|
|
|
|
=> GetManiaSkinConfig<T>(skin, lookup, index ?? Column.Index);
|
2020-03-31 14:10:15 +08:00
|
|
|
}
|
|
|
|
}
|