1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Merge branch 'master' into fix-rewind-bug

This commit is contained in:
Salman Ahmed 2023-06-15 10:59:15 +03:00
commit cabb4dfaa8
4 changed files with 49 additions and 34 deletions

View File

@ -7,12 +7,15 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
using osu.Game.Skinning;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Gameplay
{
@ -21,6 +24,8 @@ namespace osu.Game.Tests.Visual.Gameplay
{
private GameplayClockContainer gameplayClockContainer = null!;
private Box background = null!;
private const double skip_target_time = -2000;
[BackgroundDependencyLoader]
@ -30,11 +35,20 @@ namespace osu.Game.Tests.Visual.Gameplay
FrameStabilityContainer frameStabilityContainer;
Add(gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time)
AddRange(new Drawable[]
{
Child = frameStabilityContainer = new FrameStabilityContainer
background = new Box
{
MaxCatchUpFrames = 1
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue
},
gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time)
{
Child = frameStabilityContainer = new FrameStabilityContainer
{
MaxCatchUpFrames = 1
}
}
});
@ -71,9 +85,20 @@ namespace osu.Game.Tests.Visual.Gameplay
applyToArgonProgress(s => s.ShowGraph.Value = b);
});
AddStep("set white background", () => background.FadeColour(Color4.White, 200, Easing.OutQuint));
AddStep("randomise background colour", () => background.FadeColour(new Colour4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1), 200, Easing.OutQuint));
AddStep("stop", gameplayClockContainer.Stop);
}
[Test]
public void TestSeekToKnownTime()
{
AddStep("seek to known time", () => gameplayClockContainer.Seek(60000));
AddWaitStep("wait some for seek", 15);
AddStep("stop", () => gameplayClockContainer.Stop());
}
private void applyToArgonProgress(Action<ArgonSongProgress> action) =>
this.ChildrenOfType<ArgonSongProgress>().ForEach(action);

View File

@ -95,7 +95,6 @@ namespace osu.Game.Screens.Play.HUD
private void updateGraphVisibility()
{
graph.FadeTo(ShowGraph.Value ? 1 : 0, 200, Easing.In);
bar.ShowBackground = !ShowGraph.Value;
}
protected override void Update()

View File

@ -14,7 +14,6 @@ using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Graphics;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD
{
@ -32,18 +31,8 @@ namespace osu.Game.Screens.Play.HUD
private readonly Box background;
private readonly BindableBool showBackground = new BindableBool();
private readonly ColourInfo mainColour;
private readonly ColourInfo mainColourDarkened;
private ColourInfo catchUpColour;
private ColourInfo catchUpColourDarkened;
public bool ShowBackground
{
get => showBackground.Value;
set => showBackground.Value = value;
}
public double StartTime
{
@ -95,7 +84,7 @@ namespace osu.Game.Screens.Play.HUD
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Colour = Colour4.White.Darken(1 + 1 / 4f)
Colour = OsuColour.Gray(0.2f),
},
catchupBar = new RoundedBar
{
@ -112,12 +101,10 @@ namespace osu.Game.Screens.Play.HUD
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
CornerRadius = 5,
AccentColour = mainColour = Color4.White,
AccentColour = mainColour = OsuColour.Gray(0.9f),
RelativeSizeAxes = Axes.Both
},
};
mainColourDarkened = Colour4.White.Darken(1 / 3f);
}
private void setupAlternateValue()
@ -141,16 +128,15 @@ namespace osu.Game.Screens.Play.HUD
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
catchUpColour = colours.BlueLight;
catchUpColourDarkened = colours.BlueDark;
showBackground.BindValueChanged(_ => updateBackground(), true);
catchUpColour = colours.BlueDark;
}
private void updateBackground()
protected override void LoadComplete()
{
background.FadeTo(showBackground.Value ? 1 / 4f : 0, 200, Easing.In);
playfieldBar.TransformTo(nameof(playfieldBar.AccentColour), ShowBackground ? mainColour : mainColourDarkened, 200, Easing.In);
base.LoadComplete();
background.FadeTo(0.3f, 200, Easing.In);
playfieldBar.TransformTo(nameof(playfieldBar.AccentColour), mainColour, 200, Easing.In);
}
protected override bool OnHover(HoverEvent e)
@ -190,8 +176,8 @@ namespace osu.Game.Screens.Play.HUD
catchupBar.AccentColour = Interpolation.ValueAt(
Math.Min(timeDelta, colour_transition_threshold),
ShowBackground ? mainColour : mainColourDarkened,
ShowBackground ? catchUpColour : catchUpColourDarkened,
mainColour,
catchUpColour,
0, colour_transition_threshold,
Easing.OutQuint);

View File

@ -4,8 +4,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects;
using osu.Game.Graphics.UserInterface;
@ -13,6 +15,10 @@ namespace osu.Game.Screens.Play.HUD
{
public partial class ArgonSongProgressGraph : SegmentedGraph<int>
{
private const int tier_count = 5;
private const int display_granularity = 200;
private IEnumerable<HitObject>? objects;
public IEnumerable<HitObject> Objects
@ -21,8 +27,7 @@ namespace osu.Game.Screens.Play.HUD
{
objects = value;
const int granularity = 200;
int[] values = new int[granularity];
int[] values = new int[display_granularity];
if (!objects.Any())
return;
@ -32,7 +37,7 @@ namespace osu.Game.Screens.Play.HUD
if (lastHit == 0)
lastHit = objects.Last().StartTime;
double interval = (lastHit - firstHit + 1) / granularity;
double interval = (lastHit - firstHit + 1) / display_granularity;
foreach (var h in objects)
{
@ -51,12 +56,12 @@ namespace osu.Game.Screens.Play.HUD
}
public ArgonSongProgressGraph()
: base(5)
: base(tier_count)
{
var colours = new List<Colour4>();
for (int i = 0; i < 5; i++)
colours.Add(Colour4.White.Darken(1 + 1 / 5f).Opacity(1 / 5f));
for (int i = 0; i < tier_count; i++)
colours.Add(OsuColour.Gray(0.2f).Opacity(0.1f));
TierColours = colours;
}