mirror of
https://github.com/ppy/osu.git
synced 2026-06-05 12:44:05 +08:00
e2681c4163
- Below 20 custom sample sets, they are shown as ternary buttons. - Above 20 custom sample sets, they are shown in a dropdown (yes there are actual cases of this as I've been informed by the NAT; one example being https://osu.ppy.sh/beatmapsets/1018061#osu/2197383) As a bonus, to make determining what the heck is actually changing when adjusting these controls, the full set of applicable sounds now plays on adding/removing additions, changing their banks, as well as changing the custom set (if any). For now there are no user-facing controls to add the samples to the map yourself, you have to know how to name the `.wav`s and edit-externally them in yourself. *For now.*
86 lines
2.5 KiB
C#
86 lines
2.5 KiB
C#
// 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 osu.Framework.Allocation;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Sprites;
|
|
using osu.Game.Audio;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Graphics.Sprites;
|
|
using osu.Game.Graphics.UserInterface;
|
|
using osu.Game.Skinning;
|
|
|
|
namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
|
{
|
|
public partial class SampleSetTernaryButton : DrawableTernaryButton
|
|
{
|
|
public EditorBeatmapSkin.SampleSet SampleSet { get; }
|
|
|
|
public ISampleInfo[] DemoSamples
|
|
{
|
|
get => demoSample.Samples;
|
|
set => demoSample.Samples = value;
|
|
}
|
|
|
|
private readonly SkinnableSound demoSample;
|
|
|
|
public SampleSetTernaryButton(EditorBeatmapSkin.SampleSet sampleSet)
|
|
: base(null)
|
|
{
|
|
SampleSet = sampleSet;
|
|
CreateIcon = () => sampleSet.SampleSetIndex == 0
|
|
? new SpriteIcon { Icon = OsuIcon.SkinA }
|
|
: new Container
|
|
{
|
|
Child = new OsuSpriteText
|
|
{
|
|
Text = sampleSet.SampleSetIndex.ToString(),
|
|
Font = OsuFont.Style.Body.With(weight: FontWeight.Bold),
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
}
|
|
};
|
|
|
|
switch (sampleSet.SampleSetIndex)
|
|
{
|
|
case 0:
|
|
RelativeSizeAxes = Axes.X;
|
|
Width = 1;
|
|
break;
|
|
|
|
default:
|
|
RelativeSizeAxes = Axes.None;
|
|
Width = Height;
|
|
break;
|
|
}
|
|
|
|
demoSample = new SkinnableSound();
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(EditorBeatmap editorBeatmap)
|
|
{
|
|
AddRangeInternal(new Drawable[]
|
|
{
|
|
new HoverSounds(HoverSampleSet.Button),
|
|
new EditorSkinProvidingContainer(editorBeatmap)
|
|
{
|
|
Child = demoSample,
|
|
}
|
|
});
|
|
}
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
|
|
Action = () =>
|
|
{
|
|
OnAction();
|
|
demoSample?.Play();
|
|
};
|
|
}
|
|
}
|
|
}
|