1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:22:56 +08:00

Merge branch 'master' into quick-import-only-on-batch

This commit is contained in:
Dean Herbert 2022-06-15 15:27:06 +09:00
commit 19543685ff
11 changed files with 262 additions and 58 deletions

View File

@ -9,6 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.Online.API; using osu.Game.Online.API;
@ -99,6 +100,22 @@ namespace osu.Desktop
{ {
presence.State = truncate(activity.Value.Status); presence.State = truncate(activity.Value.Status);
presence.Details = truncate(getDetails(activity.Value)); presence.Details = truncate(getDetails(activity.Value));
if (getBeatmap(activity.Value) is IBeatmapInfo beatmap && beatmap.OnlineID > 0)
{
presence.Buttons = new[]
{
new Button
{
Label = "View beatmap",
Url = $@"{api.WebsiteRootUrl}/beatmapsets/{beatmap.BeatmapSet?.OnlineID}#{ruleset.Value.ShortName}/{beatmap.OnlineID}"
}
};
}
else
{
presence.Buttons = null;
}
} }
else else
{ {
@ -145,6 +162,20 @@ namespace osu.Desktop
}); });
} }
private IBeatmapInfo getBeatmap(UserActivity activity)
{
switch (activity)
{
case UserActivity.InGame game:
return game.BeatmapInfo;
case UserActivity.Editing edit:
return edit.BeatmapInfo;
}
return null;
}
private string getDetails(UserActivity activity) private string getDetails(UserActivity activity)
{ {
switch (activity) switch (activity)

View File

@ -78,6 +78,21 @@ namespace osu.Game.Tests.Visual.Editing
AddAssert("Inner container width matches scroll container", () => innerBox.DrawWidth == scrollContainer.DrawWidth); AddAssert("Inner container width matches scroll container", () => innerBox.DrawWidth == scrollContainer.DrawWidth);
} }
[Test]
public void TestZoomRangeUpdate()
{
AddStep("set zoom to 2", () => scrollContainer.Zoom = 2);
AddStep("set min zoom to 5", () => scrollContainer.MinZoom = 5);
AddAssert("zoom = 5", () => scrollContainer.Zoom == 5);
AddStep("set max zoom to 10", () => scrollContainer.MaxZoom = 10);
AddAssert("zoom = 5", () => scrollContainer.Zoom == 5);
AddStep("set min zoom to 20", () => scrollContainer.MinZoom = 20);
AddStep("set max zoom to 40", () => scrollContainer.MaxZoom = 40);
AddAssert("zoom = 20", () => scrollContainer.Zoom == 20);
}
[Test] [Test]
public void TestZoom0() public void TestZoom0()
{ {

View File

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Gameplay; using osu.Game.Tests.Gameplay;
using osuTK.Input; using osuTK.Input;
@ -145,6 +146,26 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent); AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent);
} }
[Test]
public void TestHiddenHUDDoesntBlockComponentUpdates()
{
int updateCount = 0;
AddStep("set hud to never show", () => localConfig.SetValue(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.Never));
createNew();
AddUntilStep("wait for hud load", () => hudOverlay.IsLoaded);
AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().Alpha == 0);
AddStep("bind on update", () =>
{
hudOverlay.ChildrenOfType<BarHitErrorMeter>().First().OnUpdate += _ => updateCount++;
});
AddUntilStep("wait for updates", () => updateCount > 0);
}
[Test] [Test]
public void TestHiddenHUDDoesntBlockSkinnableComponentsLoad() public void TestHiddenHUDDoesntBlockSkinnableComponentsLoad()
{ {
@ -153,7 +174,7 @@ namespace osu.Game.Tests.Visual.Gameplay
createNew(); createNew();
AddUntilStep("wait for hud load", () => hudOverlay.IsLoaded); AddUntilStep("wait for hud load", () => hudOverlay.IsLoaded);
AddUntilStep("wait for components to be hidden", () => !hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().IsPresent); AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().Alpha == 0);
AddStep("reload components", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().Reload()); AddStep("reload components", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().Reload());
AddUntilStep("skinnable components loaded", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().ComponentsLoaded); AddUntilStep("skinnable components loaded", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().ComponentsLoaded);

View File

@ -142,6 +142,36 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("no circle added", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any()); AddAssert("no circle added", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
} }
[Test]
public void TestProcessingWhileHidden()
{
AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
AddStep("hide displays", () =>
{
foreach (var hitErrorMeter in this.ChildrenOfType<HitErrorMeter>())
hitErrorMeter.Hide();
});
AddRepeatStep("hit", () => newJudgement(), ColourHitErrorMeter.MAX_DISPLAYED_JUDGEMENTS * 2);
AddAssert("bars added", () => this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
AddAssert("circle added", () => this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
AddUntilStep("wait for bars to disappear", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
AddUntilStep("ensure max circles not exceeded", () =>
{
return this.ChildrenOfType<ColourHitErrorMeter>()
.All(m => m.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Count() <= ColourHitErrorMeter.MAX_DISPLAYED_JUDGEMENTS);
});
AddStep("show displays", () =>
{
foreach (var hitErrorMeter in this.ChildrenOfType<HitErrorMeter>())
hitErrorMeter.Show();
});
}
[Test] [Test]
public void TestClear() public void TestClear()
{ {

View File

@ -6,11 +6,16 @@ using Moq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Toolbar; using osu.Game.Overlays.Toolbar;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osuTK.Graphics;
using osuTK.Input; using osuTK.Input;
namespace osu.Game.Tests.Visual.Menus namespace osu.Game.Tests.Visual.Menus
@ -95,6 +100,28 @@ namespace osu.Game.Tests.Visual.Menus
AddAssert("toolbar is visible", () => toolbar.State.Value == Visibility.Visible); AddAssert("toolbar is visible", () => toolbar.State.Value == Visibility.Visible);
} }
[Test]
public void TestScrollInput()
{
OsuScrollContainer scroll = null;
AddStep("add scroll layer", () => Add(scroll = new OsuScrollContainer
{
Depth = 1f,
RelativeSizeAxes = Axes.Both,
Child = new Box
{
RelativeSizeAxes = Axes.X,
Height = DrawHeight * 2,
Colour = ColourInfo.GradientVertical(Color4.Gray, Color4.DarkGray),
}
}));
AddStep("hover toolbar", () => InputManager.MoveMouseTo(toolbar));
AddStep("perform scroll", () => InputManager.ScrollVerticalBy(500));
AddAssert("not scrolled", () => scroll.Current == 0);
}
public class TestToolbar : Toolbar public class TestToolbar : Toolbar
{ {
public new Bindable<OverlayActivation> OverlayActivationMode => base.OverlayActivationMode as Bindable<OverlayActivation>; public new Bindable<OverlayActivation> OverlayActivationMode => base.OverlayActivationMode as Bindable<OverlayActivation>;

View File

@ -14,6 +14,7 @@ using osu.Framework.Bindables;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
@ -41,8 +42,6 @@ namespace osu.Game.Overlays.Toolbar
// Toolbar and its components need keyboard input even when hidden. // Toolbar and its components need keyboard input even when hidden.
public override bool PropagateNonPositionalInputSubTree => true; public override bool PropagateNonPositionalInputSubTree => true;
protected override bool BlockScrollInput => false;
public Toolbar() public Toolbar()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -67,6 +66,32 @@ namespace osu.Game.Overlays.Toolbar
Children = new Drawable[] Children = new Drawable[]
{ {
new ToolbarBackground(), new ToolbarBackground(),
new GridContainer
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension(),
new Dimension(GridSizeMode.AutoSize)
},
Content = new[]
{
new Drawable[]
{
new Container
{
Name = "Left buttons",
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Depth = float.MinValue,
Children = new Drawable[]
{
new Box
{
Colour = OsuColour.Gray(0.1f),
RelativeSizeAxes = Axes.Both,
},
new FillFlowContainer new FillFlowContainer
{ {
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
@ -79,9 +104,48 @@ namespace osu.Game.Overlays.Toolbar
{ {
Action = () => OnHome?.Invoke() Action = () => OnHome?.Invoke()
}, },
},
},
}
},
new Container
{
Name = "Ruleset selector",
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new OsuScrollContainer(Direction.Horizontal)
{
ScrollbarVisible = false,
RelativeSizeAxes = Axes.Both,
Masking = false,
Children = new Drawable[]
{
rulesetSelector = new ToolbarRulesetSelector() rulesetSelector = new ToolbarRulesetSelector()
} }
}, },
new Box
{
Colour = ColourInfo.GradientHorizontal(OsuColour.Gray(0.1f).Opacity(0), OsuColour.Gray(0.1f)),
Width = 50,
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
},
}
},
new Container
{
Name = "Right buttons",
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Children = new Drawable[]
{
new Box
{
Colour = OsuColour.Gray(0.1f),
RelativeSizeAxes = Axes.Both,
},
new FillFlowContainer new FillFlowContainer
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
@ -107,6 +171,11 @@ namespace osu.Game.Overlays.Toolbar
new ToolbarClock(), new ToolbarClock(),
new ToolbarNotificationButton(), new ToolbarNotificationButton(),
} }
},
}
},
},
}
} }
}; };

View File

@ -161,7 +161,7 @@ namespace osu.Game.Overlays.Toolbar
}; };
} }
protected override bool OnMouseDown(MouseDownEvent e) => true; protected override bool OnMouseDown(MouseDownEvent e) => false;
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {

View File

@ -66,8 +66,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
minZoom = value; minZoom = value;
if (Zoom < value) // ensure zoom range is in valid state before updating zoom.
Zoom = value; if (MinZoom < MaxZoom)
updateZoom();
} }
} }
@ -86,8 +87,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
maxZoom = value; maxZoom = value;
if (Zoom > value) // ensure zoom range is in valid state before updating zoom.
Zoom = value; if (MaxZoom > MinZoom)
updateZoom();
} }
} }
@ -97,15 +99,17 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
public float Zoom public float Zoom
{ {
get => zoomTarget; get => zoomTarget;
set set => updateZoom(value);
}
private void updateZoom(float? value = null)
{ {
value = Math.Clamp(value, MinZoom, MaxZoom); float newZoom = Math.Clamp(value ?? Zoom, MinZoom, MaxZoom);
if (IsLoaded) if (IsLoaded)
setZoomTarget(value, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X); setZoomTarget(newZoom, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X);
else else
currentZoom = zoomTarget = value; currentZoom = zoomTarget = newZoom;
}
} }
protected override void Update() protected override void Update()

View File

@ -15,7 +15,11 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{ {
public class ColourHitErrorMeter : HitErrorMeter public class ColourHitErrorMeter : HitErrorMeter
{ {
internal const int MAX_DISPLAYED_JUDGEMENTS = 20;
private const int animation_duration = 200; private const int animation_duration = 200;
private const int drawable_judgement_size = 8;
private const int spacing = 2;
private readonly JudgementFlow judgementsFlow; private readonly JudgementFlow judgementsFlow;
@ -37,16 +41,12 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
private class JudgementFlow : FillFlowContainer<HitErrorCircle> private class JudgementFlow : FillFlowContainer<HitErrorCircle>
{ {
private const int max_available_judgements = 20;
private const int drawable_judgement_size = 8;
private const int spacing = 2;
public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse(); public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
public JudgementFlow() public JudgementFlow()
{ {
AutoSizeAxes = Axes.X; AutoSizeAxes = Axes.X;
Height = max_available_judgements * (drawable_judgement_size + spacing) - spacing; Height = MAX_DISPLAYED_JUDGEMENTS * (drawable_judgement_size + spacing) - spacing;
Spacing = new Vector2(0, spacing); Spacing = new Vector2(0, spacing);
Direction = FillDirection.Vertical; Direction = FillDirection.Vertical;
LayoutDuration = animation_duration; LayoutDuration = animation_duration;
@ -57,7 +57,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{ {
Add(new HitErrorCircle(colour, drawable_judgement_size)); Add(new HitErrorCircle(colour, drawable_judgement_size));
if (Children.Count > max_available_judgements) if (Children.Count > MAX_DISPLAYED_JUDGEMENTS)
Children.FirstOrDefault(c => !c.IsRemoved)?.Remove(); Children.FirstOrDefault(c => !c.IsRemoved)?.Remove();
} }
} }

View File

@ -31,6 +31,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
private void load(DrawableRuleset drawableRuleset) private void load(DrawableRuleset drawableRuleset)
{ {
HitWindows = drawableRuleset?.FirstAvailableHitWindows ?? HitWindows.Empty; HitWindows = drawableRuleset?.FirstAvailableHitWindows ?? HitWindows.Empty;
// This is to allow the visual state to be correct after HUD comes visible after being hidden.
AlwaysPresent = true;
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -86,11 +86,15 @@ namespace osu.Game.Screens.Play
Children = new Drawable[] Children = new Drawable[]
{ {
CreateFailingLayer(), CreateFailingLayer(),
mainComponents = new MainComponentsContainer(), mainComponents = new MainComponentsContainer
{
AlwaysPresent = true,
},
topRightElements = new FillFlowContainer topRightElements = new FillFlowContainer
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
AlwaysPresent = true,
Margin = new MarginPadding(10), Margin = new MarginPadding(10),
Spacing = new Vector2(10), Spacing = new Vector2(10),
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,