Merge branch 'master' into fix-transform-mutation-display-settings

This commit is contained in:
Bartłomiej Dach 2021-01-06 10:09:14 +01:00 committed by GitHub
commit 6572bb18de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 436 additions and 433 deletions

View File

@ -5,6 +5,7 @@ using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osuTK; using osuTK;
@ -14,8 +15,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{ {
public class TestSceneLoadingLayer : OsuTestScene public class TestSceneLoadingLayer : OsuTestScene
{ {
private Drawable dimContent; private TestLoadingLayer overlay;
private LoadingLayer overlay;
private Container content; private Container content;
@ -29,14 +29,14 @@ namespace osu.Game.Tests.Visual.UserInterface
Size = new Vector2(300), Size = new Vector2(300),
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Children = new[] Children = new Drawable[]
{ {
new Box new Box
{ {
Colour = Color4.SlateGray, Colour = Color4.SlateGray,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
dimContent = new FillFlowContainer new FillFlowContainer
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -51,7 +51,7 @@ namespace osu.Game.Tests.Visual.UserInterface
new TriangleButton { Text = "puush me", Width = 200, Action = () => { } }, new TriangleButton { Text = "puush me", Width = 200, Action = () => { } },
} }
}, },
overlay = new LoadingLayer(dimContent), overlay = new TestLoadingLayer(true),
} }
}, },
}; };
@ -64,25 +64,11 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("show", () => overlay.Show()); AddStep("show", () => overlay.Show());
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White); AddUntilStep("wait for content dim", () => overlay.BackgroundDimLayer.Alpha > 0);
AddStep("hide", () => overlay.Hide()); AddStep("hide", () => overlay.Hide());
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White); AddUntilStep("wait for content restore", () => Precision.AlmostEquals(overlay.BackgroundDimLayer.Alpha, 0));
}
[Test]
public void TestContentRestoreOnDispose()
{
AddAssert("not visible", () => !overlay.IsPresent);
AddStep("show", () => overlay.Show());
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White);
AddStep("expire", () => overlay.Expire());
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
} }
[Test] [Test]
@ -98,5 +84,15 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("hide", () => overlay.Hide()); AddStep("hide", () => overlay.Hide());
} }
private class TestLoadingLayer : LoadingLayer
{
public new Box BackgroundDimLayer => base.BackgroundDimLayer;
public TestLoadingLayer(bool dimBackground = false, bool withBox = true)
: base(dimBackground, withBox)
{
}
}
} }
} }

View File

@ -2,8 +2,9 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using JetBrains.Annotations;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -17,22 +18,32 @@ namespace osu.Game.Graphics.UserInterface
/// </summary> /// </summary>
public class LoadingLayer : LoadingSpinner public class LoadingLayer : LoadingSpinner
{ {
private readonly Drawable dimTarget; [CanBeNull]
protected Box BackgroundDimLayer { get; }
/// <summary> /// <summary>
/// Constuct a new loading spinner. /// Construct a new loading spinner.
/// </summary> /// </summary>
/// <param name="dimTarget">An optional target to dim when displayed.</param> /// <param name="dimBackground">Whether the full background area should be dimmed while loading.</param>
/// <param name="withBox">Whether the spinner should have a surrounding black box for visibility.</param> /// <param name="withBox">Whether the spinner should have a surrounding black box for visibility.</param>
public LoadingLayer(Drawable dimTarget = null, bool withBox = true) public LoadingLayer(bool dimBackground = false, bool withBox = true)
: base(withBox) : base(withBox)
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Size = new Vector2(1); Size = new Vector2(1);
this.dimTarget = dimTarget;
MainContents.RelativeSizeAxes = Axes.None; MainContents.RelativeSizeAxes = Axes.None;
if (dimBackground)
{
AddInternal(BackgroundDimLayer = new Box
{
Depth = float.MaxValue,
Colour = Color4.Black,
Alpha = 0,
RelativeSizeAxes = Axes.Both,
});
}
} }
public override bool HandleNonPositionalInput => false; public override bool HandleNonPositionalInput => false;
@ -56,31 +67,21 @@ namespace osu.Game.Graphics.UserInterface
protected override void PopIn() protected override void PopIn()
{ {
dimTarget?.FadeColour(OsuColour.Gray(0.5f), TRANSITION_DURATION, Easing.OutQuint); BackgroundDimLayer?.FadeTo(0.5f, TRANSITION_DURATION * 2, Easing.OutQuint);
base.PopIn(); base.PopIn();
} }
protected override void PopOut() protected override void PopOut()
{ {
dimTarget?.FadeColour(Color4.White, TRANSITION_DURATION, Easing.OutQuint); BackgroundDimLayer?.FadeOut(TRANSITION_DURATION, Easing.OutQuint);
base.PopOut(); base.PopOut();
} }
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
MainContents.Size = new Vector2(Math.Clamp(Math.Min(DrawWidth, DrawHeight) * 0.25f, 30, 100)); MainContents.Size = new Vector2(Math.Clamp(Math.Min(DrawWidth, DrawHeight) * 0.25f, 30, 100));
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (State.Value == Visibility.Visible)
{
// ensure we don't leave the target in a bad state.
dimTarget?.FadeColour(Color4.White, TRANSITION_DURATION, Easing.OutQuint);
}
}
} }
} }

View File

@ -151,11 +151,11 @@ namespace osu.Game
updateBlockingOverlayFade(); updateBlockingOverlayFade();
} }
public void RemoveBlockingOverlay(OverlayContainer overlay) public void RemoveBlockingOverlay(OverlayContainer overlay) => Schedule(() =>
{ {
visibleBlockingOverlays.Remove(overlay); visibleBlockingOverlays.Remove(overlay);
updateBlockingOverlayFade(); updateBlockingOverlayFade();
} });
/// <summary> /// <summary>
/// Close all game-wide overlays. /// Close all game-wide overlays.

View File

@ -48,11 +48,9 @@ namespace osu.Game.Overlays.AccountCreation
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
FillFlowContainer mainContent;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
mainContent = new FillFlowContainer new FillFlowContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
@ -124,7 +122,7 @@ namespace osu.Game.Overlays.AccountCreation
}, },
}, },
}, },
loadingLayer = new LoadingLayer(mainContent) loadingLayer = new LoadingLayer(true)
}; };
textboxes = new[] { usernameTextBox, emailTextBox, passwordTextBox }; textboxes = new[] { usernameTextBox, emailTextBox, passwordTextBox };

View File

@ -92,14 +92,14 @@ namespace osu.Game.Overlays
{ {
foundContent = new FillFlowContainer<BeatmapPanel>(), foundContent = new FillFlowContainer<BeatmapPanel>(),
notFoundContent = new NotFoundDrawable(), notFoundContent = new NotFoundDrawable(),
loadingLayer = new LoadingLayer(panelTarget)
}
} }
} }
}, },
},
} }
} },
} },
loadingLayer = new LoadingLayer(true)
}; };
} }

View File

@ -53,7 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
Size = new Vector2(18), Size = new Vector2(18),
Shadow = false, Shadow = false,
}, },
loading = new LoadingLayer(icon, false), loading = new LoadingLayer(true, false),
}); });
Action = () => Action = () =>

View File

@ -157,11 +157,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
} }
} }
}, },
}
}
},
},
loading = new LoadingLayer() loading = new LoadingLayer()
}
}
}
}
}); });
} }
@ -228,7 +228,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
Scores = null; Scores = null;
notSupporterPlaceholder.Show(); notSupporterPlaceholder.Show();
loading.Hide(); loading.Hide();
loading.FinishTransforms();
return; return;
} }
@ -241,6 +243,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
getScoresRequest.Success += scores => getScoresRequest.Success += scores =>
{ {
loading.Hide(); loading.Hide();
loading.FinishTransforms();
Scores = scores; Scores = scores;
if (!scores.Scores.Any()) if (!scores.Scores.Any())

View File

@ -128,7 +128,7 @@ namespace osu.Game.Overlays.Dashboard.Friends
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = 50 } Padding = new MarginPadding { Horizontal = 50 }
}, },
loading = new LoadingLayer(itemsPlaceholder) loading = new LoadingLayer(true)
} }
} }
} }

View File

@ -68,7 +68,7 @@ namespace osu.Game.Overlays
} }
} }
}, },
loading = new LoadingLayer(content), loading = new LoadingLayer(true),
}; };
} }

View File

@ -59,7 +59,7 @@ namespace osu.Game.Overlays
}, },
}, },
}, },
loading = new LoadingLayer(content), loading = new LoadingLayer(true),
}; };
} }

View File

@ -45,6 +45,7 @@ namespace osu.Game.Overlays.Rankings
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
InternalChild = new ReverseChildIDFillFlowContainer<Drawable> InternalChild = new ReverseChildIDFillFlowContainer<Drawable>
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -68,7 +69,7 @@ namespace osu.Game.Overlays.Rankings
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Vertical = 10 } Margin = new MarginPadding { Vertical = 10 }
}, },
loading = new LoadingLayer(content) loading = new LoadingLayer(true)
} }
} }
} }

View File

@ -42,6 +42,8 @@ namespace osu.Game.Overlays
Depth = -float.MaxValue Depth = -float.MaxValue
}) })
{ {
loading = new LoadingLayer(true);
Children = new Drawable[] Children = new Drawable[]
{ {
background = new Box background = new Box
@ -74,12 +76,12 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Margin = new MarginPadding { Bottom = 10 } Margin = new MarginPadding { Bottom = 10 }
}, },
loading = new LoadingLayer(contentContainer),
}
} }
} }
} }
} }
},
loading
}; };
} }

View File

@ -65,7 +65,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
Padding = new MarginPadding(10), Padding = new MarginPadding(10),
Child = roomsContainer = new RoomsContainer { JoinRequested = joinRequested } Child = roomsContainer = new RoomsContainer { JoinRequested = joinRequested }
}, },
loadingLayer = new LoadingLayer(roomsContainer), loadingLayer = new LoadingLayer(true),
} }
}, },
new RoomInspector new RoomInspector

View File

@ -71,14 +71,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
Container dimContent;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{
dimContent = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{ {
new Box new Box
{ {
@ -263,9 +256,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
} }
} }
}, },
} loadingLayer = new LoadingLayer(true)
},
loadingLayer = new LoadingLayer(dimContent)
}; };
TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue?.Name ?? string.Empty, true); TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue?.Name ?? string.Empty, true);

View File

@ -47,7 +47,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
AddInternal(loadingLayer = new LoadingLayer(Carousel)); AddInternal(loadingLayer = new LoadingLayer(true));
initialBeatmap = Beatmap.Value; initialBeatmap = Beatmap.Value;
initialRuleset = Ruleset.Value; initialRuleset = Ruleset.Value;
initialMods = Mods.Value.ToList(); initialMods = Mods.Value.ToList();

View File

@ -62,7 +62,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
// todo: this should be implemented via a custom HUD implementation, and correctly masked to the main content area. // todo: this should be implemented via a custom HUD implementation, and correctly masked to the main content area.
LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(ScoreProcessor, userIds), HUDOverlay.Add); LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(ScoreProcessor, userIds), HUDOverlay.Add);
HUDOverlay.Add(loadingDisplay = new LoadingLayer(DrawableRuleset) { Depth = float.MaxValue }); HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
if (Token == null) if (Token == null)
return; // Todo: Somehow handle token retrieval failure. return; // Todo: Somehow handle token retrieval failure.

View File

@ -64,14 +64,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
Container dimContent;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{
dimContent = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{ {
new Box new Box
{ {
@ -298,9 +291,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
} }
} }
}, },
} loadingLayer = new LoadingLayer(true)
},
loadingLayer = new LoadingLayer(dimContent)
}; };
TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue?.Name ?? string.Empty, true); TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue?.Name ?? string.Empty, true);

View File

@ -53,7 +53,6 @@ namespace osu.Game.Screens.Play
private readonly Bindable<IReadOnlyList<Mod>> mods; private readonly Bindable<IReadOnlyList<Mod>> mods;
private readonly Drawable facade; private readonly Drawable facade;
private LoadingSpinner loading; private LoadingSpinner loading;
private Sprite backgroundSprite;
public IBindable<IReadOnlyList<Mod>> Mods => mods; public IBindable<IReadOnlyList<Mod>> Mods => mods;
@ -123,7 +122,7 @@ namespace osu.Game.Screens.Play
Masking = true, Masking = true,
Children = new Drawable[] Children = new Drawable[]
{ {
backgroundSprite = new Sprite new Sprite
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Texture = beatmap?.Background, Texture = beatmap?.Background,
@ -131,7 +130,7 @@ namespace osu.Game.Screens.Play
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
FillMode = FillMode.Fill, FillMode = FillMode.Fill,
}, },
loading = new LoadingLayer(backgroundSprite) loading = new LoadingLayer(true)
} }
}, },
new OsuSpriteText new OsuSpriteText

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Pooling;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Layout;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -124,6 +125,8 @@ namespace osu.Game.Screens.Select
{ {
BeatmapSetsChanged?.Invoke(); BeatmapSetsChanged?.Invoke();
BeatmapSetsLoaded = true; BeatmapSetsLoaded = true;
itemsCache.Invalidate();
}); });
} }
@ -567,6 +570,15 @@ namespace osu.Game.Screens.Select
#endregion #endregion
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
{
// handles the vertical size of the carousel changing (ie. on window resize when aspect ratio has changed).
if ((invalidation & Invalidation.Layout) > 0)
itemsCache.Invalidate();
return base.OnInvalidate(invalidation, source);
}
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
@ -777,13 +789,19 @@ namespace osu.Game.Screens.Select
Scroll.ScrollContent.Height = currentY; Scroll.ScrollContent.Height = currentY;
if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected)) itemsCache.Validate();
// update and let external consumers know about selection loss.
if (BeatmapSetsLoaded)
{
bool selectionLost = selectedBeatmapSet != null && selectedBeatmapSet.State.Value != CarouselItemState.Selected;
if (selectionLost)
{ {
selectedBeatmapSet = null; selectedBeatmapSet = null;
SelectionChanged?.Invoke(null); SelectionChanged?.Invoke(null);
} }
}
itemsCache.Validate();
} }
private bool firstScroll = true; private bool firstScroll = true;
@ -806,14 +824,13 @@ namespace osu.Game.Screens.Select
break; break;
case PendingScrollOperation.Immediate: case PendingScrollOperation.Immediate:
// in order to simplify animation logic, rather than using the animated version of ScrollTo, // in order to simplify animation logic, rather than using the animated version of ScrollTo,
// we take the difference in scroll height and apply to all visible panels. // we take the difference in scroll height and apply to all visible panels.
// this avoids edge cases like when the visible panels is reduced suddenly, causing ScrollContainer // this avoids edge cases like when the visible panels is reduced suddenly, causing ScrollContainer
// to enter clamp-special-case mode where it animates completely differently to normal. // to enter clamp-special-case mode where it animates completely differently to normal.
float scrollChange = scrollTarget.Value - Scroll.Current; float scrollChange = scrollTarget.Value - Scroll.Current;
Scroll.ScrollTo(scrollTarget.Value, false); Scroll.ScrollTo(scrollTarget.Value, false);
foreach (var i in Scroll.Children) foreach (var i in Scroll.Children)
i.Y += scrollChange; i.Y += scrollChange;
break; break;

View File

@ -63,8 +63,6 @@ namespace osu.Game.Screens.Select
public BeatmapDetails() public BeatmapDetails()
{ {
Container content;
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
@ -72,7 +70,7 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f), Colour = Color4.Black.Opacity(0.5f),
}, },
content = new Container new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Horizontal = spacing }, Padding = new MarginPadding { Horizontal = spacing },
@ -159,7 +157,7 @@ namespace osu.Game.Screens.Select
}, },
}, },
}, },
loading = new LoadingLayer(content), loading = new LoadingLayer(true),
}; };
} }

View File

@ -428,16 +428,21 @@ namespace osu.Game.Screens.Select
private void updateSelectedBeatmap(BeatmapInfo beatmap) private void updateSelectedBeatmap(BeatmapInfo beatmap)
{ {
if (beatmap == null && beatmapNoDebounce == null)
return;
if (beatmap?.Equals(beatmapNoDebounce) == true) if (beatmap?.Equals(beatmapNoDebounce) == true)
return; return;
beatmapNoDebounce = beatmap; beatmapNoDebounce = beatmap;
performUpdateSelected(); performUpdateSelected();
} }
private void updateSelectedRuleset(RulesetInfo ruleset) private void updateSelectedRuleset(RulesetInfo ruleset)
{ {
if (ruleset == null && rulesetNoDebounce == null)
return;
if (ruleset?.Equals(rulesetNoDebounce) == true) if (ruleset?.Equals(rulesetNoDebounce) == true)
return; return;