1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 13:02:54 +08:00

Merge branch 'master' into combo-colour-brightness-limit

This commit is contained in:
Dean Herbert 2022-11-11 18:24:39 +09:00
commit 106f1cf90b
16 changed files with 246 additions and 161 deletions

View File

@ -1,17 +1,12 @@
// 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.
#nullable disable
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects;
using osuTK;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Skinning.Default;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
@ -28,35 +23,15 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
/// </summary>
private const float tracker_width = 2f;
/// <summary>
/// The vertical offset of the triangles from the line tracker.
/// </summary>
private const float triangle_offset = 10f;
/// <summary>
/// The size of the triangles.
/// </summary>
private const float triangle_size = 20f;
/// <summary>
/// The visual line tracker.
/// </summary>
private SkinnableDrawable line;
/// <summary>
/// Container with triangles. Only visible for major lines.
/// </summary>
private Container triangleContainer;
private readonly Bindable<bool> major = new Bindable<bool>();
public readonly Bindable<bool> Major = new Bindable<bool>();
public DrawableBarLine()
: this(null)
{
}
public DrawableBarLine([CanBeNull] BarLine barLine)
: base(barLine)
public DrawableBarLine(BarLine? barLine)
: base(barLine!)
{
}
@ -69,69 +44,23 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
RelativeSizeAxes = Axes.Y;
Width = tracker_width;
AddRangeInternal(new Drawable[]
{
line = new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.BarLine), _ => new Box
{
RelativeSizeAxes = Axes.Both,
EdgeSmoothness = new Vector2(0.5f, 0),
})
AddInternal(new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.BarLine), _ => new DefaultBarLine())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
triangleContainer = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Children = new[]
{
new EquilateralTriangle
{
Name = "Top",
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, -triangle_offset),
Size = new Vector2(-triangle_size),
EdgeSmoothness = new Vector2(1),
},
new EquilateralTriangle
{
Name = "Bottom",
Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, triangle_offset),
Size = new Vector2(triangle_size),
EdgeSmoothness = new Vector2(1),
}
}
}
});
}
protected override void LoadComplete()
{
base.LoadComplete();
major.BindValueChanged(updateMajor, true);
}
private void updateMajor(ValueChangedEvent<bool> major)
{
line.Alpha = major.NewValue ? 1f : 0.75f;
triangleContainer.Alpha = major.NewValue ? 1 : 0;
}
protected override void OnApply()
{
base.OnApply();
major.BindTo(HitObject.MajorBindable);
Major.BindTo(HitObject.MajorBindable);
}
protected override void OnFree()
{
base.OnFree();
major.UnbindFrom(HitObject.MajorBindable);
Major.UnbindFrom(HitObject.MajorBindable);
}
protected override void UpdateHitStateTransforms(ArmedState state)

View File

@ -5,6 +5,7 @@
using System;
using JetBrains.Annotations;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Objects;
@ -16,6 +17,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
public class DrawableDrumRollTick : DrawableTaikoStrongableHitObject<DrumRollTick, DrumRollTick.StrongNestedHit>
{
public BindableBool IsFirstTick = new BindableBool();
/// <summary>
/// The hit type corresponding to the <see cref="TaikoAction"/> that the user pressed to hit this <see cref="DrawableDrumRollTick"/>.
/// </summary>
@ -32,14 +35,17 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
FillMode = FillMode.Fit;
}
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.DrumRollTick),
_ => new TickPiece
{
Filled = HitObject.FirstTick
});
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.DrumRollTick), _ => new TickPiece());
public override double MaximumJudgementOffset => HitObject.HitWindow;
protected override void OnApply()
{
base.OnApply();
IsFirstTick.Value = HitObject.FirstTick;
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (!userTriggered)

View File

@ -0,0 +1,94 @@
// 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.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osuTK;
namespace osu.Game.Rulesets.Taiko.Skinning.Default
{
public class DefaultBarLine : CompositeDrawable
{
/// <summary>
/// The vertical offset of the triangles from the line tracker.
/// </summary>
private const float triangle_offset = 10f;
/// <summary>
/// The size of the triangles.
/// </summary>
private const float triangle_size = 20f;
/// <summary>
/// Container with triangles. Only visible for major lines.
/// </summary>
private Container triangleContainer = null!;
private Bindable<bool> major = null!;
[BackgroundDependencyLoader]
private void load(DrawableHitObject drawableHitObject)
{
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
line = new Box
{
RelativeSizeAxes = Axes.Both,
EdgeSmoothness = new Vector2(0.5f, 0),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
triangleContainer = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Children = new[]
{
new EquilateralTriangle
{
Name = "Top",
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, -triangle_offset),
Size = new Vector2(-triangle_size),
EdgeSmoothness = new Vector2(1),
},
new EquilateralTriangle
{
Name = "Bottom",
Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, triangle_offset),
Size = new Vector2(triangle_size),
EdgeSmoothness = new Vector2(1),
}
}
}
};
major = ((DrawableBarLine)drawableHitObject).Major.GetBoundCopy();
}
protected override void LoadComplete()
{
base.LoadComplete();
major.BindValueChanged(updateMajor, true);
}
private Box line = null!;
private void updateMajor(ValueChangedEvent<bool> major)
{
line.Alpha = major.NewValue ? 1f : 0.75f;
triangleContainer.Alpha = major.NewValue ? 1 : 0;
}
}
}

View File

@ -0,0 +1,35 @@
// 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.Graphics;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Taiko.Skinning.Default
{
public class DefaultJudgementPiece : Rulesets.Judgements.DefaultJudgementPiece
{
public DefaultJudgementPiece(HitResult result)
: base(result)
{
RelativePositionAxes = Axes.Both;
}
public override void PlayAnimation()
{
if (Result != HitResult.Miss)
{
this
.MoveToY(-0.6f)
.MoveToY(-1.5f, 500);
JudgementText
.ScaleTo(0.9f)
.ScaleTo(1, 500, Easing.OutElastic);
this.FadeOutFromOne(800, Easing.OutQuint);
}
else
base.PlayAnimation();
}
}
}

View File

@ -1,9 +1,13 @@
// 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.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osuTK;
using osuTK.Graphics;
@ -22,20 +26,10 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Default
/// </summary>
private const float tick_size = 0.35f;
private bool filled;
public bool Filled
{
get => filled;
set
{
filled = value;
fillBox.Alpha = filled ? 1 : 0;
}
}
private readonly Box fillBox;
private Bindable<bool> isFirstTick = null!;
public TickPiece()
{
Anchor = Anchor.Centre;
@ -62,5 +56,19 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Default
}
};
}
[Resolved]
private DrawableHitObject drawableHitObject { get; set; } = null!;
protected override void LoadComplete()
{
base.LoadComplete();
if (drawableHitObject is DrawableDrumRollTick drumRollTick)
{
isFirstTick = drumRollTick.IsFirstTick.GetBoundCopy();
isFirstTick.BindValueChanged(first => fillBox.Alpha = first.NewValue ? 1 : 0, true);
}
}
}
}

View File

@ -4,6 +4,8 @@
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osuTK;
using DefaultJudgementPiece = osu.Game.Rulesets.Taiko.Skinning.Default.DefaultJudgementPiece;
namespace osu.Game.Rulesets.Taiko.UI
{
@ -12,31 +14,15 @@ namespace osu.Game.Rulesets.Taiko.UI
/// </summary>
public class DrawableTaikoJudgement : DrawableJudgement
{
protected override void ApplyHitAnimations()
public DrawableTaikoJudgement()
{
this.MoveToY(-100, 500);
base.ApplyHitAnimations();
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
Size = Vector2.One;
}
protected override Drawable CreateDefaultJudgement(HitResult result) => new TaikoJudgementPiece(result);
private class TaikoJudgementPiece : DefaultJudgementPiece
{
public TaikoJudgementPiece(HitResult result)
: base(result)
{
}
public override void PlayAnimation()
{
if (Result != HitResult.Miss)
{
JudgementText.ScaleTo(0.9f);
JudgementText.ScaleTo(1, 500, Easing.OutElastic);
}
base.PlayAnimation();
}
}
protected override Drawable CreateDefaultJudgement(HitResult result) => new DefaultJudgementPiece(result);
}
}

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Taiko.UI
JudgedObject = judgedObject;
this.hitType = hitType;
Anchor = Anchor.CentreLeft;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;

View File

@ -145,13 +145,16 @@ namespace osu.Game.Rulesets.Taiko.UI
kiaiExplosionContainer = new Container<KiaiHitExplosion>
{
Name = "Kiai hit explosions",
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
},
judgementContainer = new JudgementContainer<DrawableTaikoJudgement>
{
Name = "Judgements",
RelativeSizeAxes = Axes.Y,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
},
}
},
@ -320,15 +323,7 @@ namespace osu.Game.Rulesets.Taiko.UI
if (!result.Type.IsScorable())
break;
judgementContainer.Add(judgementPools[result.Type].Get(j =>
{
j.Apply(result, judgedObject);
j.Anchor = result.IsHit ? Anchor.TopLeft : Anchor.CentreLeft;
j.Origin = result.IsHit ? Anchor.BottomCentre : Anchor.Centre;
j.RelativePositionAxes = Axes.X;
j.X = result.IsHit ? judgedObject.Position.X : 0;
}));
judgementContainer.Add(judgementPools[result.Type].Get(j => j.Apply(result, judgedObject)));
var type = (judgedObject.HitObject as Hit)?.Type ?? HitType.Centre;
addExplosion(judgedObject, result.Type, type);

View File

@ -35,13 +35,19 @@ namespace osu.Game.Tests.Visual.Settings
State = { Value = Visibility.Visible }
});
});
}
AddStep("reset mouse", () => InputManager.MoveMouseTo(settings));
[Test]
public void TestBasic()
{
AddStep("do nothing", () => { });
}
[Test]
public void TestFiltering([Values] bool beforeLoad)
{
AddStep("reset mouse", () => InputManager.MoveMouseTo(settings));
if (beforeLoad)
AddStep("set filter", () => settings.SectionsContainer.ChildrenOfType<SearchTextBox>().First().Current.Value = "scaling");
@ -67,6 +73,8 @@ namespace osu.Game.Tests.Visual.Settings
[Test]
public void TestFilterAfterLoad()
{
AddStep("reset mouse", () => InputManager.MoveMouseTo(settings));
AddUntilStep("wait for items to load", () => settings.SectionsContainer.ChildrenOfType<IFilterable>().Any());
AddStep("set filter", () => settings.SectionsContainer.ChildrenOfType<SearchTextBox>().First().Current.Value = "scaling");
@ -75,6 +83,8 @@ namespace osu.Game.Tests.Visual.Settings
[Test]
public void ToggleVisibility()
{
AddStep("reset mouse", () => InputManager.MoveMouseTo(settings));
AddWaitStep("wait some", 5);
AddToggleStep("toggle visibility", _ => settings.ToggleVisibility());
}
@ -82,6 +92,8 @@ namespace osu.Game.Tests.Visual.Settings
[Test]
public void TestTextboxFocusAfterNestedPanelBackButton()
{
AddStep("reset mouse", () => InputManager.MoveMouseTo(settings));
AddUntilStep("sections loaded", () => settings.SectionsContainer.Children.Count > 0);
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<FocusedTextBox>().FirstOrDefault()?.HasFocus == true);
@ -107,6 +119,8 @@ namespace osu.Game.Tests.Visual.Settings
[Test]
public void TestTextboxFocusAfterNestedPanelEscape()
{
AddStep("reset mouse", () => InputManager.MoveMouseTo(settings));
AddUntilStep("sections loaded", () => settings.SectionsContainer.Children.Count > 0);
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<FocusedTextBox>().FirstOrDefault()?.HasFocus == true);

View File

@ -58,6 +58,14 @@ namespace osu.Game.Graphics.UserInterface
return base.OnClick(e);
}
public override void PlayHoverSample()
{
if (!Enabled.Value)
return;
base.PlayHoverSample();
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{

View File

@ -27,9 +27,6 @@ namespace osu.Game.Graphics.UserInterface
private const float border_width = 3;
private const double animate_in_duration = 200;
private const double animate_out_duration = 500;
private readonly Box fill;
private readonly Container main;
@ -72,7 +69,7 @@ namespace osu.Game.Graphics.UserInterface
Colour = GlowColour.Opacity(0),
Type = EdgeEffectType.Glow,
Radius = 8,
Roundness = 5,
Roundness = 4,
};
}
@ -94,13 +91,18 @@ namespace osu.Game.Graphics.UserInterface
if (value)
{
main.FadeColour(GlowingAccentColour, animate_in_duration, Easing.OutQuint);
main.FadeEdgeEffectTo(0.2f, animate_in_duration, Easing.OutQuint);
main.FadeColour(GlowingAccentColour.Lighten(0.5f), 40, Easing.OutQuint)
.Then()
.FadeColour(GlowingAccentColour, 800, Easing.OutQuint);
main.FadeEdgeEffectTo(Color4.White.Opacity(0.1f), 40, Easing.OutQuint)
.Then()
.FadeEdgeEffectTo(GlowColour.Opacity(0.1f), 800, Easing.OutQuint);
}
else
{
main.FadeEdgeEffectTo(0, animate_out_duration, Easing.OutQuint);
main.FadeColour(AccentColour, animate_out_duration, Easing.OutQuint);
main.FadeEdgeEffectTo(GlowColour.Opacity(0), 800, Easing.OutQuint);
main.FadeColour(AccentColour, 800, Easing.OutQuint);
}
}
}
@ -163,14 +165,20 @@ namespace osu.Game.Graphics.UserInterface
private void onCurrentValueChanged(ValueChangedEvent<bool> filled)
{
fill.FadeTo(filled.NewValue ? 1 : 0, 200, Easing.OutQuint);
const double duration = 200;
fill.FadeTo(filled.NewValue ? 1 : 0, duration, Easing.OutQuint);
if (filled.NewValue)
main.ResizeWidthTo(1, animate_in_duration, Easing.OutElasticHalf);
{
main.ResizeWidthTo(1, duration, Easing.OutElasticHalf);
main.TransformTo(nameof(BorderThickness), 8.5f, duration, Easing.OutElasticHalf);
}
else
main.ResizeWidthTo(0.9f, animate_out_duration, Easing.OutElastic);
main.TransformTo(nameof(BorderThickness), filled.NewValue ? 8.5f : border_width, 200, Easing.OutQuint);
{
main.ResizeWidthTo(0.75f, duration, Easing.OutQuint);
main.TransformTo(nameof(BorderThickness), border_width, duration, Easing.OutQuint);
}
}
}
}

View File

@ -4,7 +4,6 @@
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -95,7 +94,7 @@ namespace osu.Game.Graphics.UserInterface
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = Color4.White.Opacity(.1f),
Colour = Color4.White,
Blending = BlendingParameters.Additive,
Depth = float.MinValue
},
@ -126,7 +125,7 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnClick(ClickEvent e)
{
if (Enabled.Value)
Background.FlashColour(BackgroundColour.Lighten(0.4f), 200);
Background.FlashColour(Color4.White, 800, Easing.OutQuint);
return base.OnClick(e);
}
@ -134,7 +133,11 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(HoverEvent e)
{
if (Enabled.Value)
Hover.FadeIn(200, Easing.OutQuint);
{
Hover.FadeTo(0.2f, 40, Easing.OutQuint)
.Then()
.FadeTo(0.1f, 800, Easing.OutQuint);
}
return base.OnHover(e);
}
@ -143,7 +146,7 @@ namespace osu.Game.Graphics.UserInterface
{
base.OnHoverLost(e);
Hover.FadeOut(300);
Hover.FadeOut(800, Easing.OutQuint);
}
protected override bool OnMouseDown(MouseDownEvent e)

View File

@ -131,8 +131,6 @@ namespace osu.Game.Graphics.UserInterface
},
hoverClickSounds = new HoverClickSounds()
};
Current.DisabledChanged += disabled => { Alpha = disabled ? 0.3f : 1; };
}
[BackgroundDependencyLoader(true)]
@ -154,7 +152,12 @@ namespace osu.Game.Graphics.UserInterface
{
base.LoadComplete();
CurrentNumber.BindValueChanged(current => TooltipText = getTooltipText(current.NewValue), true);
Current.DisabledChanged += disabled => hoverClickSounds.Enabled.Value = !disabled;
Current.BindDisabledChanged(disabled =>
{
Alpha = disabled ? 0.3f : 1;
hoverClickSounds.Enabled.Value = !disabled;
}, true);
}
protected override bool OnHover(HoverEvent e)
@ -180,7 +183,7 @@ namespace osu.Game.Graphics.UserInterface
private void updateGlow()
{
Nub.Glowing = IsHovered || IsDragged;
Nub.Glowing = !Current.Disabled && (IsHovered || IsDragged);
}
protected override void OnUserChange(T value)

View File

@ -78,7 +78,7 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.F8, GlobalAction.ToggleChat),
new KeyBinding(InputKey.F6, GlobalAction.ToggleNowPlaying),
new KeyBinding(InputKey.F9, GlobalAction.ToggleSocial),
new KeyBinding(new[] { InputKey.Control, InputKey.D }, GlobalAction.ToggleBeatmapListing),
new KeyBinding(new[] { InputKey.Control, InputKey.B }, GlobalAction.ToggleBeatmapListing),
new KeyBinding(new[] { InputKey.Control, InputKey.O }, GlobalAction.ToggleSettings),
new KeyBinding(new[] { InputKey.Control, InputKey.N }, GlobalAction.ToggleNotifications),
};

View File

@ -168,11 +168,7 @@ namespace osu.Game.Rulesets.Judgements
RemoveInternal(JudgementBody, true);
AddInternal(JudgementBody = new SkinnableDrawable(new GameplaySkinComponentLookup<HitResult>(type), _ =>
CreateDefaultJudgement(type), confineMode: ConfineMode.NoScaling)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
CreateDefaultJudgement(type), confineMode: ConfineMode.NoScaling));
JudgementBody.OnSkinChanged += () =>
{

View File

@ -750,7 +750,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
public new TObject HitObject => (TObject)base.HitObject;
protected DrawableHitObject(TObject hitObject)
protected DrawableHitObject([CanBeNull] TObject hitObject)
: base(hitObject)
{
}