mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 03:52:54 +08:00
parent
1e5dc7aac6
commit
bc3b7233ab
@ -3,14 +3,19 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects
|
namespace osu.Game.Rulesets.Taiko.Objects
|
||||||
{
|
{
|
||||||
public class Hit : TaikoStrongableHitObject
|
public class Hit : TaikoStrongableHitObject, IHasDisplayColour
|
||||||
{
|
{
|
||||||
public readonly Bindable<HitType> TypeBindable = new Bindable<HitType>();
|
public readonly Bindable<HitType> TypeBindable = new Bindable<HitType>();
|
||||||
|
|
||||||
|
public Bindable<Color4> DisplayColour { get; } = new Bindable<Color4>(colour_centre);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="HitType"/> that actuates this <see cref="Hit"/>.
|
/// The <see cref="HitType"/> that actuates this <see cref="Hit"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -20,9 +25,17 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
set => TypeBindable.Value = value;
|
set => TypeBindable.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Color4 colour_centre = Color4Extensions.FromHex(@"bb1177");
|
||||||
|
private static readonly Color4 colour_rim = Color4Extensions.FromHex(@"2299bb");
|
||||||
|
|
||||||
public Hit()
|
public Hit()
|
||||||
{
|
{
|
||||||
TypeBindable.BindValueChanged(_ => updateSamplesFromType());
|
TypeBindable.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
updateSamplesFromType();
|
||||||
|
DisplayColour.Value = Type == HitType.Centre ? colour_centre : colour_rim;
|
||||||
|
});
|
||||||
|
|
||||||
SamplesBindable.BindCollectionChanged((_, __) => updateTypeFromSamples());
|
SamplesBindable.BindCollectionChanged((_, __) => updateTypeFromSamples());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
osu.Game/Rulesets/Objects/Types/IHasAccentColour.cs
Normal file
19
osu.Game/Rulesets/Objects/Types/IHasAccentColour.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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.Bindables;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Objects.Types
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A HitObject which has a preferred display colour. Will be used for editor timeline display.
|
||||||
|
/// </summary>
|
||||||
|
public interface IHasDisplayColour
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The current display colour of this hit object.
|
||||||
|
/// </summary>
|
||||||
|
Bindable<Color4> DisplayColour { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -39,6 +39,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
private Bindable<int> indexInCurrentComboBindable;
|
private Bindable<int> indexInCurrentComboBindable;
|
||||||
private Bindable<int> comboIndexBindable;
|
private Bindable<int> comboIndexBindable;
|
||||||
|
private Bindable<Color4> displayColourBindable;
|
||||||
|
|
||||||
private readonly ExtendableCircle circle;
|
private readonly ExtendableCircle circle;
|
||||||
private readonly Border border;
|
private readonly Border border;
|
||||||
@ -108,44 +109,64 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
if (Item is IHasComboInformation comboInfo)
|
switch (Item)
|
||||||
{
|
{
|
||||||
indexInCurrentComboBindable = comboInfo.IndexInCurrentComboBindable.GetBoundCopy();
|
case IHasDisplayColour displayColour:
|
||||||
indexInCurrentComboBindable.BindValueChanged(_ => updateComboIndex(), true);
|
displayColourBindable = displayColour.DisplayColour.GetBoundCopy();
|
||||||
|
displayColourBindable.BindValueChanged(_ => updateColour(), true);
|
||||||
|
break;
|
||||||
|
|
||||||
comboIndexBindable = comboInfo.ComboIndexBindable.GetBoundCopy();
|
case IHasComboInformation comboInfo:
|
||||||
comboIndexBindable.BindValueChanged(_ => updateComboColour(), true);
|
indexInCurrentComboBindable = comboInfo.IndexInCurrentComboBindable.GetBoundCopy();
|
||||||
|
indexInCurrentComboBindable.BindValueChanged(_ => updateComboIndex(), true);
|
||||||
|
|
||||||
skin.SourceChanged += updateComboColour;
|
comboIndexBindable = comboInfo.ComboIndexBindable.GetBoundCopy();
|
||||||
|
comboIndexBindable.BindValueChanged(_ => updateColour(), true);
|
||||||
|
|
||||||
|
skin.SourceChanged += updateColour;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSelected()
|
protected override void OnSelected()
|
||||||
{
|
{
|
||||||
// base logic hides selected blueprints when not selected, but timeline doesn't do that.
|
// base logic hides selected blueprints when not selected, but timeline doesn't do that.
|
||||||
updateComboColour();
|
updateColour();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDeselected()
|
protected override void OnDeselected()
|
||||||
{
|
{
|
||||||
// base logic hides selected blueprints when not selected, but timeline doesn't do that.
|
// base logic hides selected blueprints when not selected, but timeline doesn't do that.
|
||||||
updateComboColour();
|
updateColour();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateComboIndex() => comboIndexText.Text = (indexInCurrentComboBindable.Value + 1).ToString();
|
private void updateComboIndex() => comboIndexText.Text = (indexInCurrentComboBindable.Value + 1).ToString();
|
||||||
|
|
||||||
private void updateComboColour()
|
private void updateColour()
|
||||||
{
|
{
|
||||||
if (!(Item is IHasComboInformation combo))
|
Color4 colour;
|
||||||
return;
|
|
||||||
|
|
||||||
var comboColours = skin.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value ?? Array.Empty<Color4>();
|
switch (Item)
|
||||||
var comboColour = combo.GetComboColour(comboColours);
|
{
|
||||||
|
case IHasDisplayColour displayColour:
|
||||||
|
colour = displayColour.DisplayColour.Value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IHasComboInformation combo:
|
||||||
|
{
|
||||||
|
var comboColours = skin.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value ?? Array.Empty<Color4>();
|
||||||
|
colour = combo.GetComboColour(comboColours);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsSelected)
|
if (IsSelected)
|
||||||
{
|
{
|
||||||
border.Show();
|
border.Show();
|
||||||
comboColour = comboColour.Lighten(0.3f);
|
colour = colour.Lighten(0.3f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -153,9 +174,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Item is IHasDuration duration && duration.Duration > 0)
|
if (Item is IHasDuration duration && duration.Duration > 0)
|
||||||
circle.Colour = ColourInfo.GradientHorizontal(comboColour, comboColour.Lighten(0.4f));
|
circle.Colour = ColourInfo.GradientHorizontal(colour, colour.Lighten(0.4f));
|
||||||
else
|
else
|
||||||
circle.Colour = comboColour;
|
circle.Colour = colour;
|
||||||
|
|
||||||
var col = circle.Colour.TopLeft.Linear;
|
var col = circle.Colour.TopLeft.Linear;
|
||||||
colouredComponents.Colour = OsuColour.ForegroundTextColourFor(col);
|
colouredComponents.Colour = OsuColour.ForegroundTextColourFor(col);
|
||||||
|
Loading…
Reference in New Issue
Block a user