Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "argon" variant of song progress display #22144

Merged
merged 37 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0f1fe1d
refactor(hud/gameplay/SongProgress): Add interface to designate `Song…
ItsShamed Jan 9, 2023
f626519
feat(hud/gameplay): Add Argon variant of `SongProgressBar`
ItsShamed Jan 9, 2023
28d2d76
refactor(hud/gameplay/SongProgressInfo): minor changes to text positi…
ItsShamed Jan 9, 2023
5952cd0
feat(hud/gameplay): implement Argon song progress density graph (Segm…
ItsShamed Jan 9, 2023
91cde5f
feat(hud/gameplay): implement Argon variant of `SongProgress`
ItsShamed Jan 9, 2023
48deef4
test: adapt and create tests to cover new components
ItsShamed Jan 9, 2023
eac8e9f
test: make test not actually test anything
ItsShamed Jan 9, 2023
d2309fe
Merge branch 'master' into skin/argon-song-progress-cleaner
peppy Jan 12, 2023
4439698
Update osu.Game/Screens/Play/HUD/ArgonSongProgress.cs
ItsShamed Jan 12, 2023
65bd2e7
Merge branch 'master' into skin/argon-song-progress-cleaner
peppy Jan 17, 2023
b62b571
Fix `TierColours` assignment
peppy Jan 17, 2023
66441d4
test: remove test for ArgonSongProgressGraph
ItsShamed Jan 17, 2023
d91aa34
refactor(ArgonSongProgress): reorder layering and make density graph …
ItsShamed Jan 17, 2023
f1989ba
quality: remove unused `Darken` bindable boolean
ItsShamed Jan 17, 2023
45c5bd8
Simplify HUD test to not require casting to specific `ProgressBar` type
peppy Jan 18, 2023
afc12e0
Tidy up `ISongProgressBar` interface
peppy Jan 18, 2023
5429979
Combine common code into `SongProgress` base class
peppy Jan 18, 2023
f9dd3f6
Switch test to specifically target the argon verison of the progress bar
peppy Jan 18, 2023
e8770b8
Remove no longer necessary interface type
peppy Jan 18, 2023
742a026
Add comment mentioning why reference clock fallback logic is required
peppy Jan 18, 2023
5a272b4
Merge branch 'master' into skin/argon-song-progress-cleaner
peppy Jan 18, 2023
7266d8e
Move "show difficulty graph" settings back to respective implementati…
peppy Jan 18, 2023
1e5dd91
Adjust `SkinnableTestScene` to give more breathing room to `RelativeS…
peppy Jan 18, 2023
04c0a5d
Update `TestSceneSongProgress` to properly work with new implementation
peppy Jan 18, 2023
bfb7573
Prefix subclasses of `DefaultSongProgress` with `Default`
peppy Jan 18, 2023
8bfd853
Fix missing comment
peppy Jan 18, 2023
8030194
Use actual beatmap's hitobjects in test to better display density
peppy Jan 18, 2023
5ead85f
Limit catch-up speed in test to emulate gameplay
peppy Jan 18, 2023
42e9b2b
Tidy up clock logic in all `SongProgress` classes
peppy Jan 18, 2023
17c35cf
Merge branch 'frame-stable-cache' into skin/argon-song-progress-cleaner
peppy Jan 18, 2023
f3677ab
Simplify depth change logic
peppy Jan 18, 2023
01558a9
Tidy up height logic and allow hovering above bar for easier interaction
peppy Jan 18, 2023
67b40dd
Adjust the seek effect to feel better
peppy Jan 18, 2023
4cfb059
Merge branch 'frame-stable-cache' into skin/argon-song-progress-cleaner
peppy Jan 18, 2023
d4f2cd2
Fix broken test step
peppy Jan 18, 2023
b8b7442
Make `SongProgressInfo.ShowProgress` init-only (and remove duplicate …
bdach Jan 18, 2023
b62ff8d
Merge branch 'master' into skin/argon-song-progress-cleaner
bdach Jan 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
2 changes: 2 additions & 0 deletions osu.Game.Tests/Skins/SkinDeserialisationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class SkinDeserialisationTest
"Archives/modified-default-20220818.osk",
// Covers longest combo counter
"Archives/modified-default-20221012.osk",
// Covers Argon variant of song progress bar
"Archives/modified-argon-20221024.osk",
// Covers TextElement and BeatmapInfoDrawable
"Archives/modified-default-20221102.osk",
// Covers BPM counter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public void SetUp() => Schedule(() =>
{
var implementation = skin is LegacySkin
? CreateLegacyImplementation()
: CreateDefaultImplementation();
: skin is ArgonSkin
? CreateArgonImplementation()
: CreateDefaultImplementation();

implementation.Anchor = Anchor.Centre;
implementation.Origin = Anchor.Centre;
Expand All @@ -29,6 +31,7 @@ public void SetUp() => Schedule(() =>
});

protected abstract Drawable CreateDefaultImplementation();
protected virtual Drawable CreateArgonImplementation() => CreateDefaultImplementation();
protected abstract Drawable CreateLegacyImplementation();
}
}
69 changes: 69 additions & 0 deletions osu.Game.Tests/Visual/Gameplay/TestSceneArgonSongProgressGraph.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// 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.Collections.Generic;
using System.Diagnostics;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Play.HUD;

namespace osu.Game.Tests.Visual.Gameplay
{
[TestFixture]
public partial class TestSceneArgonSongProgressGraph : OsuTestScene
{
private TestArgonSongProgressGraph? graph;

[SetUpSteps]
public void SetupSteps()
{
AddStep("add new big graph", () =>
{
if (graph != null)
{
graph.Expire();
graph = null;
}

Add(graph = new TestArgonSongProgressGraph
{
RelativeSizeAxes = Axes.X,
Height = 200,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
});
});
}

[Test]
public void Test()
{
AddAssert("ensure not created", () => graph!.CreationCount == 0);
AddStep("display values", displayRandomValues);
}

private void displayRandomValues()
{
Debug.Assert(graph != null);
var objects = new List<HitObject>();
for (double i = 0; i < 5000; i += RNG.NextDouble() * 10 + i / 1000)
objects.Add(new HitObject { StartTime = i });

graph.Objects = objects;
}

private partial class TestArgonSongProgressGraph : ArgonSongProgressGraph
{
public int CreationCount { get; private set; }

protected override void RecreateGraph()
{
base.RecreateGraph();
CreationCount++;
}
}
}
}
16 changes: 13 additions & 3 deletions osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void TestHoldForMenuDoesWorkWhenHidden()
[Test]
public void TestInputDoesntWorkWhenHUDHidden()
{
SongProgressBar? getSongProgress() => hudOverlay.ChildrenOfType<SongProgressBar>().SingleOrDefault();
ISongProgressBar? getSongProgress() => hudOverlay.ChildrenOfType<ISongProgressBar>().SingleOrDefault();

bool seeked = false;

Expand All @@ -204,7 +204,7 @@ public void TestInputDoesntWorkWhenHUDHidden()

Debug.Assert(progress != null);

progress.ShowHandle = true;
progress.Interactive = true;
progress.OnSeek += _ => seeked = true;
});

Expand All @@ -213,7 +213,17 @@ public void TestInputDoesntWorkWhenHUDHidden()

AddStep("attempt seek", () =>
{
InputManager.MoveMouseTo(getSongProgress());
switch (getSongProgress())
{
case SongProgressBar defaultBar:
InputManager.MoveMouseTo(defaultBar);
break;

case ArgonSongProgressBar argonBar:
InputManager.MoveMouseTo(argonBar);
break;
}

InputManager.Click(MouseButton.Left);
});

Expand Down
2 changes: 2 additions & 0 deletions osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ private void setHitObjects()

protected override Drawable CreateDefaultImplementation() => new DefaultSongProgress();

protected override Drawable CreateArgonImplementation() => new ArgonSongProgress();

protected override Drawable CreateLegacyImplementation() => new LegacySongProgress();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void TestSpectatorPlayerInteractiveElementsHidden()
AddUntilStep("all interactive elements removed", () => this.ChildrenOfType<Player>().All(p =>
!p.ChildrenOfType<PlayerSettingsOverlay>().Any() &&
!p.ChildrenOfType<HoldForMenuButton>().Any() &&
p.ChildrenOfType<SongProgressBar>().SingleOrDefault()?.ShowHandle == false));
p.ChildrenOfType<ISongProgressBar>().SingleOrDefault()?.Interactive == false));

AddStep("restore config hud visibility", () => config.SetValue(OsuSetting.HUDVisibilityMode, originalConfigValue));
}
Expand Down
139 changes: 139 additions & 0 deletions osu.Game/Screens/Play/HUD/ArgonSongProgress.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// 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.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Timing;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI;

namespace osu.Game.Screens.Play.HUD
{
public partial class ArgonSongProgress : SongProgress
{
private readonly SongProgressInfo info;
private readonly ArgonSongProgressGraph graph;
private readonly ArgonSongProgressBar bar;

private const float bar_height = 10;

public readonly Bindable<bool> AllowSeeking = new BindableBool();

[SettingSource("Show difficulty graph", "Whether a graph displaying difficulty throughout the beatmap should be shown")]
public Bindable<bool> ShowGraph { get; } = new BindableBool(true);

[Resolved]
private DrawableRuleset? drawableRuleset { get; set; }

private IClock referenceClock => drawableRuleset?.FrameStableClock ?? GameplayClock;

[Resolved]
private Player? player { get; set; }

public ArgonSongProgress()
{
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
Children = new Drawable[]
{
info = new SongProgressInfo
{
Origin = Anchor.TopLeft,
Name = "Info",
Anchor = Anchor.TopLeft,
RelativeSizeAxes = Axes.X,
ShowProgress = false
},
graph = new ArgonSongProgressGraph
{
Name = "Difficulty graph",
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Masking = true,
CornerRadius = 5,
},
ItsShamed marked this conversation as resolved.
Show resolved Hide resolved
bar = new ArgonSongProgressBar(bar_height)
{
Name = "Seek bar",
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
OnSeek = time => player?.Seek(time),
}
};
RelativeSizeAxes = Axes.X;
}

[BackgroundDependencyLoader]
private void load()
{
base.LoadComplete();

if (drawableRuleset != null)
{
if (player?.Configuration.AllowUserInteraction == true)
((IBindable<bool>)AllowSeeking).BindTo(drawableRuleset.HasReplayLoaded);
}

info.ShowProgress = false;
info.TextColour = Colour4.White;
info.Font = OsuFont.Torus.With(size: 18, weight: FontWeight.Bold);
}

protected override void LoadComplete()
{
AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true);
ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true);
}

protected override void UpdateObjects(IEnumerable<HitObject> objects)
{
graph.Objects = objects;

info.StartTime = bar.StartTime = FirstHitTime;
info.EndTime = bar.EndTime = LastHitTime;
}

private void updateBarVisibility()
{
bar.Interactive = AllowSeeking.Value;
}

private void updateGraphVisibility()
{
graph.FadeTo(ShowGraph.Value ? 1 : 0, 200, Easing.In);
bar.ShowBackground = !ShowGraph.Value;
}

protected override void Update()
{
base.Update();
Height = bar.Height + bar_height + info.Height;
graph.Height = bar.Height;
}

protected override void PopIn()
{
this.FadeIn(500, Easing.OutQuint);
}

protected override void PopOut()
{
this.FadeOut(100);
}

protected override void UpdateProgress(double progress, bool isIntro)
{
bar.ReferenceTime = GameplayClock.CurrentTime;

if (isIntro)
bar.CurrentTime = 0;
else
bar.CurrentTime = referenceClock.CurrentTime;
}
}
}
Loading