mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:52:54 +08:00
Merge branch 'master' into path-control-point-bindable-removal
This commit is contained in:
commit
a28bc9f6b2
@ -0,0 +1,64 @@
|
||||
// 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 System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
{
|
||||
public class TestSceneManiaComposeScreen : EditorClockTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private SkinManager skins { get; set; }
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("setup compose screen", () =>
|
||||
{
|
||||
var editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 }))
|
||||
{
|
||||
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
|
||||
};
|
||||
|
||||
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
||||
|
||||
Child = new DependencyProvidingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CachedDependencies = new (Type, object)[]
|
||||
{
|
||||
(typeof(EditorBeatmap), editorBeatmap),
|
||||
(typeof(IBeatSnapProvider), editorBeatmap),
|
||||
},
|
||||
Child = new ComposeScreen { State = { Value = Visibility.Visible } },
|
||||
};
|
||||
});
|
||||
|
||||
AddUntilStep("wait for composer", () => this.ChildrenOfType<HitObjectComposer>().SingleOrDefault()?.IsLoaded == true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDefaultSkin()
|
||||
{
|
||||
AddStep("set default skin", () => skins.CurrentSkinInfo.Value = SkinInfo.Default);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLegacySkin()
|
||||
{
|
||||
AddStep("set legacy skin", () => skins.CurrentSkinInfo.Value = DefaultLegacySkin.Info);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Performance;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -20,8 +21,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
{
|
||||
Start = start;
|
||||
LifetimeStart = Start.StartTime;
|
||||
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
private OsuHitObject? end;
|
||||
@ -41,31 +40,39 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
}
|
||||
}
|
||||
|
||||
private bool wasBound;
|
||||
|
||||
private void bindEvents()
|
||||
{
|
||||
UnbindEvents();
|
||||
|
||||
if (End == null)
|
||||
return;
|
||||
|
||||
// Note: Positions are bound for instantaneous feedback from positional changes from the editor, before ApplyDefaults() is called on hitobjects.
|
||||
Start.DefaultsApplied += onDefaultsApplied;
|
||||
Start.PositionBindable.ValueChanged += onPositionChanged;
|
||||
|
||||
if (End != null)
|
||||
{
|
||||
End.DefaultsApplied += onDefaultsApplied;
|
||||
End.PositionBindable.ValueChanged += onPositionChanged;
|
||||
}
|
||||
End.DefaultsApplied += onDefaultsApplied;
|
||||
End.PositionBindable.ValueChanged += onPositionChanged;
|
||||
|
||||
wasBound = true;
|
||||
}
|
||||
|
||||
public void UnbindEvents()
|
||||
{
|
||||
if (!wasBound)
|
||||
return;
|
||||
|
||||
Debug.Assert(End != null);
|
||||
|
||||
Start.DefaultsApplied -= onDefaultsApplied;
|
||||
Start.PositionBindable.ValueChanged -= onPositionChanged;
|
||||
|
||||
if (End != null)
|
||||
{
|
||||
End.DefaultsApplied -= onDefaultsApplied;
|
||||
End.PositionBindable.ValueChanged -= onPositionChanged;
|
||||
}
|
||||
End.DefaultsApplied -= onDefaultsApplied;
|
||||
End.PositionBindable.ValueChanged -= onPositionChanged;
|
||||
|
||||
wasBound = false;
|
||||
}
|
||||
|
||||
private void onDefaultsApplied(HitObject obj) => refreshLifetimes();
|
||||
|
@ -42,9 +42,24 @@ namespace osu.Game.Input.Handlers
|
||||
if (!(state is RulesetInputManagerInputState<T> inputState))
|
||||
throw new InvalidOperationException($"{nameof(ReplayState<T>)} should only be applied to a {nameof(RulesetInputManagerInputState<T>)}");
|
||||
|
||||
var lastPressed = inputState.LastReplayState?.PressedActions ?? new List<T>();
|
||||
var released = lastPressed.Except(PressedActions).ToArray();
|
||||
var pressed = PressedActions.Except(lastPressed).ToArray();
|
||||
T[] released = Array.Empty<T>();
|
||||
T[] pressed = Array.Empty<T>();
|
||||
|
||||
var lastPressed = inputState.LastReplayState?.PressedActions;
|
||||
|
||||
if (lastPressed == null || lastPressed.Count == 0)
|
||||
{
|
||||
pressed = PressedActions.ToArray();
|
||||
}
|
||||
else if (PressedActions.Count == 0)
|
||||
{
|
||||
released = lastPressed.ToArray();
|
||||
}
|
||||
else if (!lastPressed.SequenceEqual(PressedActions))
|
||||
{
|
||||
released = lastPressed.Except(PressedActions).ToArray();
|
||||
pressed = PressedActions.Except(lastPressed).ToArray();
|
||||
}
|
||||
|
||||
inputState.LastReplayState = this;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -91,7 +92,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
// This is required as SettingsItem relies heavily on this bindable for internal use.
|
||||
// The actual update flow is done via the bindable provided in the constructor.
|
||||
private readonly BindableWithCurrent<float?> current = new BindableWithCurrent<float?>();
|
||||
private readonly DifficultyBindableWithCurrent current = new DifficultyBindableWithCurrent();
|
||||
|
||||
public Bindable<float?> Current
|
||||
{
|
||||
@ -114,5 +115,30 @@ namespace osu.Game.Rulesets.Mods
|
||||
RelativeSizeAxes = Axes.X;
|
||||
}
|
||||
}
|
||||
|
||||
private class DifficultyBindableWithCurrent : DifficultyBindable, IHasCurrentValue<float?>
|
||||
{
|
||||
private Bindable<float?> currentBound;
|
||||
|
||||
public Bindable<float?> Current
|
||||
{
|
||||
get => this;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
|
||||
if (currentBound != null) UnbindFrom(currentBound);
|
||||
BindTo(currentBound = value);
|
||||
}
|
||||
}
|
||||
|
||||
public DifficultyBindableWithCurrent(float? defaultValue = default)
|
||||
: base(defaultValue)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Bindable<float?> CreateInstance() => new DifficultyBindableWithCurrent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
// 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 System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Utils;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
@ -171,6 +173,11 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// </summary>
|
||||
public static bool IsScorable(this HitResult result) => result >= HitResult.Miss && result < HitResult.IgnoreMiss;
|
||||
|
||||
/// <summary>
|
||||
/// An array of all scorable <see cref="HitResult"/>s.
|
||||
/// </summary>
|
||||
public static readonly HitResult[] SCORABLE_TYPES = ((HitResult[])Enum.GetValues(typeof(HitResult))).Where(r => r.IsScorable()).ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Whether a <see cref="HitResult"/> is valid within a given <see cref="HitResult"/> range.
|
||||
/// </summary>
|
||||
|
@ -339,7 +339,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
score.Accuracy = Accuracy.Value;
|
||||
score.Rank = Rank.Value;
|
||||
|
||||
foreach (var result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.IsScorable()))
|
||||
foreach (var result in HitResultExtensions.SCORABLE_TYPES)
|
||||
score.Statistics[result] = GetStatistic(result);
|
||||
|
||||
score.HitEvents = hitEvents;
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Screens.Edit
|
||||
private readonly EditorBeatmapSkin? beatmapSkin;
|
||||
|
||||
public EditorSkinProvidingContainer(EditorBeatmap editorBeatmap)
|
||||
: base(editorBeatmap.PlayableBeatmap.BeatmapInfo.Ruleset.CreateInstance(), editorBeatmap, editorBeatmap.BeatmapSkin)
|
||||
: base(editorBeatmap.PlayableBeatmap.BeatmapInfo.Ruleset.CreateInstance(), editorBeatmap.PlayableBeatmap, editorBeatmap.BeatmapSkin)
|
||||
{
|
||||
beatmapSkin = editorBeatmap.BeatmapSkin;
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -37,6 +36,8 @@ namespace osu.Game.Screens.Play
|
||||
private FadeContainer fadeContainer;
|
||||
private double displayTime;
|
||||
|
||||
private bool isClickable;
|
||||
|
||||
[Resolved]
|
||||
private GameplayClock gameplayClock { get; set; }
|
||||
|
||||
@ -101,7 +102,7 @@ namespace osu.Game.Screens.Play
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
fadeContainer.Show();
|
||||
fadeContainer.TriggerShow();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -118,24 +119,27 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
button.Action = () => RequestSkip?.Invoke();
|
||||
displayTime = gameplayClock.CurrentTime;
|
||||
|
||||
fadeContainer.TriggerShow();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
var progress = fadeOutBeginTime <= displayTime ? 1 : Math.Max(0, 1 - (gameplayClock.CurrentTime - displayTime) / (fadeOutBeginTime - displayTime));
|
||||
double progress = fadeOutBeginTime <= displayTime ? 1 : Math.Max(0, 1 - (gameplayClock.CurrentTime - displayTime) / (fadeOutBeginTime - displayTime));
|
||||
|
||||
remainingTimeBox.Width = (float)Interpolation.Lerp(remainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
||||
|
||||
button.Enabled.Value = progress > 0;
|
||||
buttonContainer.State.Value = progress > 0 ? Visibility.Visible : Visibility.Hidden;
|
||||
isClickable = progress > 0;
|
||||
button.Enabled.Value = isClickable;
|
||||
buttonContainer.State.Value = isClickable ? Visibility.Visible : Visibility.Hidden;
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
if (!e.HasAnyButtonPressed)
|
||||
fadeContainer.Show();
|
||||
if (isClickable && !e.HasAnyButtonPressed)
|
||||
fadeContainer.TriggerShow();
|
||||
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
@ -164,34 +168,45 @@ namespace osu.Game.Screens.Play
|
||||
public event Action<Visibility> StateChanged;
|
||||
|
||||
private Visibility state;
|
||||
private ScheduledDelegate scheduledHide;
|
||||
private double? nextHideTime;
|
||||
|
||||
public override bool IsPresent => true;
|
||||
|
||||
public void TriggerShow()
|
||||
{
|
||||
Show();
|
||||
|
||||
if (!IsHovered && !IsDragged)
|
||||
nextHideTime = Time.Current + 1000;
|
||||
else
|
||||
nextHideTime = null;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (nextHideTime != null && nextHideTime <= Time.Current)
|
||||
{
|
||||
Hide();
|
||||
nextHideTime = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Visibility State
|
||||
{
|
||||
get => state;
|
||||
set
|
||||
{
|
||||
bool stateChanged = value != state;
|
||||
if (value == state)
|
||||
return;
|
||||
|
||||
state = value;
|
||||
|
||||
scheduledHide?.Cancel();
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case Visibility.Visible:
|
||||
// we may be triggered to become visible multiple times but we only want to transform once.
|
||||
if (stateChanged)
|
||||
this.FadeIn(500, Easing.OutExpo);
|
||||
|
||||
if (!IsHovered && !IsDragged)
|
||||
{
|
||||
using (BeginDelayedSequence(1000))
|
||||
scheduledHide = Schedule(Hide);
|
||||
}
|
||||
|
||||
this.FadeIn(500, Easing.OutExpo);
|
||||
break;
|
||||
|
||||
case Visibility.Hidden:
|
||||
@ -212,7 +227,7 @@ namespace osu.Game.Screens.Play
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
Show();
|
||||
scheduledHide?.Cancel();
|
||||
nextHideTime = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user