1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 15:22:55 +08:00

Merge branch 'master' into daily-challenge-intro-screen-part-2

This commit is contained in:
Dean Herbert 2024-08-08 14:08:14 +09:00
commit 1ee5522a25
No known key found for this signature in database
12 changed files with 250 additions and 69 deletions

View File

@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
}); });
moveMouseToHitObject(1); moveMouseToHitObject(1);
AddAssert("merge option available", () => selectionHandler.ContextMenuItems?.Any(o => o.Text.Value == "Merge selection") == true); AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection"));
mergeSelection(); mergeSelection();
@ -198,7 +198,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
}); });
moveMouseToHitObject(1); moveMouseToHitObject(1);
AddAssert("merge option not available", () => selectionHandler.ContextMenuItems?.Length > 0 && selectionHandler.ContextMenuItems.All(o => o.Text.Value != "Merge selection")); AddAssert("merge option not available", () => selectionHandler.ContextMenuItems.Length > 0 && selectionHandler.ContextMenuItems.All(o => o.Text.Value != "Merge selection"));
mergeSelection(); mergeSelection();
AddAssert("circles not merged", () => circle1 is not null && circle2 is not null AddAssert("circles not merged", () => circle1 is not null && circle2 is not null
&& EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2)); && EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2));
@ -222,7 +222,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
}); });
moveMouseToHitObject(1); moveMouseToHitObject(1);
AddAssert("merge option available", () => selectionHandler.ContextMenuItems?.Any(o => o.Text.Value == "Merge selection") == true); AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection"));
mergeSelection(); mergeSelection();

View File

@ -52,10 +52,7 @@ namespace osu.Game.Tests.Editing
[SetUp] [SetUp]
public void Setup() => Schedule(() => public void Setup() => Schedule(() =>
{ {
Children = new Drawable[] Child = composer = new TestHitObjectComposer();
{
composer = new TestHitObjectComposer()
};
BeatDivisor.Value = 1; BeatDivisor.Value = 1;

View File

@ -61,7 +61,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("select difficulty adjust", () => freeModSelectOverlay.SelectedMods.Value = new[] { new OsuModDifficultyAdjust() }); AddStep("select difficulty adjust", () => freeModSelectOverlay.SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
AddWaitStep("wait some", 3); AddWaitStep("wait some", 3);
AddAssert("customisation area not expanded", () => !this.ChildrenOfType<ModCustomisationPanel>().Single().Expanded.Value); AddAssert("customisation area not expanded",
() => this.ChildrenOfType<ModCustomisationPanel>().Single().ExpandedState.Value,
() => Is.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed));
} }
[Test] [Test]

View File

@ -2,6 +2,7 @@
// 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 System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -10,6 +11,8 @@ using osu.Game.Overlays;
using osu.Game.Overlays.Mods; using osu.Game.Overlays.Mods;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osuTK;
using osuTK.Input;
namespace osu.Game.Tests.Visual.UserInterface namespace osu.Game.Tests.Visual.UserInterface
{ {
@ -19,10 +22,15 @@ namespace osu.Game.Tests.Visual.UserInterface
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
private ModCustomisationPanel panel = null!; private ModCustomisationPanel panel = null!;
private ModCustomisationHeader header = null!;
private Container content = null!;
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
SelectedMods.Value = Array.Empty<Mod>();
InputManager.MoveMouseTo(Vector2.One);
Child = new Container Child = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -36,6 +44,9 @@ namespace osu.Game.Tests.Visual.UserInterface
SelectedMods = { BindTarget = SelectedMods }, SelectedMods = { BindTarget = SelectedMods },
} }
}; };
header = panel.Children.OfType<ModCustomisationHeader>().First();
content = panel.Children.OfType<Container>().First();
}); });
[Test] [Test]
@ -44,23 +55,112 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("set DT", () => AddStep("set DT", () =>
{ {
SelectedMods.Value = new[] { new OsuModDoubleTime() }; SelectedMods.Value = new[] { new OsuModDoubleTime() };
panel.Enabled.Value = panel.Expanded.Value = true; panel.Enabled.Value = true;
panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded;
}); });
AddStep("set DA", () => AddStep("set DA", () =>
{ {
SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() }; SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() };
panel.Enabled.Value = panel.Expanded.Value = true; panel.Enabled.Value = true;
panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded;
}); });
AddStep("set FL+WU+DA+AD", () => AddStep("set FL+WU+DA+AD", () =>
{ {
SelectedMods.Value = new Mod[] { new OsuModFlashlight(), new ModWindUp(), new OsuModDifficultyAdjust(), new OsuModApproachDifferent() }; SelectedMods.Value = new Mod[] { new OsuModFlashlight(), new ModWindUp(), new OsuModDifficultyAdjust(), new OsuModApproachDifferent() };
panel.Enabled.Value = panel.Expanded.Value = true; panel.Enabled.Value = true;
panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded;
}); });
AddStep("set empty", () => AddStep("set empty", () =>
{ {
SelectedMods.Value = Array.Empty<Mod>(); SelectedMods.Value = Array.Empty<Mod>();
panel.Enabled.Value = panel.Expanded.Value = false; panel.Enabled.Value = false;
panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Collapsed;
}); });
} }
[Test]
public void TestHoverDoesNotExpandWhenNoCustomisableMods()
{
AddStep("hover header", () => InputManager.MoveMouseTo(header));
checkExpanded(false);
AddStep("hover content", () => InputManager.MoveMouseTo(content));
checkExpanded(false);
AddStep("left from content", () => InputManager.MoveMouseTo(Vector2.One));
}
[Test]
public void TestHoverExpandsWithCustomisableMods()
{
AddStep("add customisable mod", () =>
{
SelectedMods.Value = new[] { new OsuModDoubleTime() };
panel.Enabled.Value = true;
});
AddStep("hover header", () => InputManager.MoveMouseTo(header));
checkExpanded(true);
AddStep("move to content", () => InputManager.MoveMouseTo(content));
checkExpanded(true);
AddStep("move away", () => InputManager.MoveMouseTo(Vector2.One));
checkExpanded(false);
AddStep("hover header", () => InputManager.MoveMouseTo(header));
checkExpanded(true);
AddStep("move away", () => InputManager.MoveMouseTo(Vector2.One));
checkExpanded(false);
}
[Test]
public void TestExpandedStatePersistsWhenClicked()
{
AddStep("add customisable mod", () =>
{
SelectedMods.Value = new[] { new OsuModDoubleTime() };
panel.Enabled.Value = true;
});
AddStep("hover header", () => InputManager.MoveMouseTo(header));
checkExpanded(true);
AddStep("click", () => InputManager.Click(MouseButton.Left));
checkExpanded(false);
AddStep("click", () => InputManager.Click(MouseButton.Left));
checkExpanded(true);
AddStep("move away", () => InputManager.MoveMouseTo(Vector2.One));
checkExpanded(true);
AddStep("click", () => InputManager.Click(MouseButton.Left));
checkExpanded(false);
}
[Test]
public void TestHoverExpandsAndCollapsesWhenHeaderClicked()
{
AddStep("add customisable mod", () =>
{
SelectedMods.Value = new[] { new OsuModDoubleTime() };
panel.Enabled.Value = true;
});
AddStep("hover header", () => InputManager.MoveMouseTo(header));
checkExpanded(true);
AddStep("click", () => InputManager.Click(MouseButton.Left));
checkExpanded(false);
}
private void checkExpanded(bool expanded)
{
AddUntilStep(expanded ? "is expanded" : "not expanded", () => panel.ExpandedState.Value,
() => expanded ? Is.Not.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed) : Is.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed));
}
} }
} }

View File

@ -57,6 +57,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("reset ruleset", () => Ruleset.Value = rulesetStore.GetRuleset(0)); AddStep("reset ruleset", () => Ruleset.Value = rulesetStore.GetRuleset(0));
AddStep("reset mods", () => SelectedMods.SetDefault()); AddStep("reset mods", () => SelectedMods.SetDefault());
AddStep("reset config", () => configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, true)); AddStep("reset config", () => configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, true));
AddStep("reset mouse", () => InputManager.MoveMouseTo(Vector2.One));
AddStep("set beatmap", () => Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo)); AddStep("set beatmap", () => Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo));
AddStep("set up presets", () => AddStep("set up presets", () =>
{ {
@ -998,7 +999,9 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("press mouse", () => InputManager.PressButton(MouseButton.Left)); AddStep("press mouse", () => InputManager.PressButton(MouseButton.Left));
AddAssert("search still not focused", () => !this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus); AddAssert("search still not focused", () => !this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
AddStep("release mouse", () => InputManager.ReleaseButton(MouseButton.Left)); AddStep("release mouse", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("customisation panel closed by click", () => !this.ChildrenOfType<ModCustomisationPanel>().Single().Expanded.Value); AddAssert("customisation panel closed by click",
() => this.ChildrenOfType<ModCustomisationPanel>().Single().ExpandedState.Value,
() => Is.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed));
if (textSearchStartsActive) if (textSearchStartsActive)
AddAssert("search focused", () => this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus); AddAssert("search focused", () => this.ChildrenOfType<ShearedSearchTextBox>().Single().HasFocus);
@ -1021,7 +1024,9 @@ namespace osu.Game.Tests.Visual.UserInterface
private void assertCustomisationToggleState(bool disabled, bool active) private void assertCustomisationToggleState(bool disabled, bool active)
{ {
AddUntilStep($"customisation panel is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Enabled.Value == !disabled); AddUntilStep($"customisation panel is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Enabled.Value == !disabled);
AddAssert($"customisation panel is {(active ? "" : "not ")}active", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Expanded.Value == active); AddAssert($"customisation panel is {(active ? "" : "not ")}active",
() => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().ExpandedState.Value,
() => active ? Is.Not.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed) : Is.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed));
} }
private T getSelectedMod<T>() where T : Mod => SelectedMods.Value.OfType<T>().Single(); private T getSelectedMod<T>() where T : Mod => SelectedMods.Value.OfType<T>().Single();

View File

@ -67,13 +67,7 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.Username, string.Empty); SetDefault(OsuSetting.Username, string.Empty);
SetDefault(OsuSetting.Token, string.Empty); SetDefault(OsuSetting.Token, string.Empty);
#pragma warning disable CS0618 // Type or member is obsolete SetDefault(OsuSetting.AutomaticallyDownloadMissingBeatmaps, true);
// this default set MUST remain despite the setting being deprecated, because `SetDefault()` calls are implicitly used to declare the type returned for the lookup.
// if this is removed, the setting will be interpreted as a string, and `Migrate()` will fail due to cast failure.
// can be removed 20240618
SetDefault(OsuSetting.AutomaticallyDownloadWhenSpectating, false);
#pragma warning restore CS0618 // Type or member is obsolete
SetDefault(OsuSetting.AutomaticallyDownloadMissingBeatmaps, false);
SetDefault(OsuSetting.SavePassword, true).ValueChanged += enabled => SetDefault(OsuSetting.SavePassword, true).ValueChanged += enabled =>
{ {
@ -244,12 +238,6 @@ namespace osu.Game.Configuration
// migrations can be added here using a condition like: // migrations can be added here using a condition like:
// if (combined < 20220103) { performMigration() } // if (combined < 20220103) { performMigration() }
if (combined < 20230918)
{
#pragma warning disable CS0618 // Type or member is obsolete
SetValue(OsuSetting.AutomaticallyDownloadMissingBeatmaps, Get<bool>(OsuSetting.AutomaticallyDownloadWhenSpectating)); // can be removed 20240618
#pragma warning restore CS0618 // Type or member is obsolete
}
} }
public override TrackedSettings CreateTrackedSettings() public override TrackedSettings CreateTrackedSettings()
@ -424,9 +412,6 @@ namespace osu.Game.Configuration
EditorAutoSeekOnPlacement, EditorAutoSeekOnPlacement,
DiscordRichPresence, DiscordRichPresence,
[Obsolete($"Use {nameof(AutomaticallyDownloadMissingBeatmaps)} instead.")] // can be removed 20240318
AutomaticallyDownloadWhenSpectating,
ShowOnlineExplicitContent, ShowOnlineExplicitContent,
LastProcessedMetadataId, LastProcessedMetadataId,
SafeAreaConsiderations, SafeAreaConsiderations,

View File

@ -8,16 +8,24 @@ using osu.Game.Graphics.UserInterface;
namespace osu.Game.Graphics.Cursor namespace osu.Game.Graphics.Cursor
{ {
[Cached(typeof(OsuContextMenuContainer))]
public partial class OsuContextMenuContainer : ContextMenuContainer public partial class OsuContextMenuContainer : ContextMenuContainer
{ {
[Cached] [Cached]
private OsuContextMenuSamples samples = new OsuContextMenuSamples(); private OsuContextMenuSamples samples = new OsuContextMenuSamples();
private OsuContextMenu menu = null!;
public OsuContextMenuContainer() public OsuContextMenuContainer()
{ {
AddInternal(samples); AddInternal(samples);
} }
protected override Menu CreateMenu() => new OsuContextMenu(true); protected override Menu CreateMenu() => menu = new OsuContextMenu(true);
public void CloseMenu()
{
menu.Close();
}
} }
} }

View File

@ -9,12 +9,14 @@ 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.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Localisation; using osu.Game.Localisation;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using static osu.Game.Overlays.Mods.ModCustomisationPanel;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {
@ -29,11 +31,13 @@ namespace osu.Game.Overlays.Mods
protected override IEnumerable<Drawable> EffectTargets => new[] { background }; protected override IEnumerable<Drawable> EffectTargets => new[] { background };
public readonly BindableBool Expanded = new BindableBool(); public readonly Bindable<ModCustomisationPanelState> ExpandedState = new Bindable<ModCustomisationPanelState>(ModCustomisationPanelState.Collapsed);
public ModCustomisationHeader() private readonly ModCustomisationPanel panel;
public ModCustomisationHeader(ModCustomisationPanel panel)
{ {
Action = Expanded.Toggle; this.panel = panel;
Enabled.Value = false; Enabled.Value = false;
} }
@ -102,10 +106,48 @@ namespace osu.Game.Overlays.Mods
} }
}, true); }, true);
Expanded.BindValueChanged(v => ExpandedState.BindValueChanged(v =>
{ {
icon.ScaleTo(v.NewValue ? new Vector2(1, -1) : Vector2.One, 300, Easing.OutQuint); icon.ScaleTo(v.NewValue > ModCustomisationPanelState.Collapsed ? new Vector2(1, -1) : Vector2.One, 300, Easing.OutQuint);
}, true); }, true);
} }
protected override bool OnClick(ClickEvent e)
{
if (Enabled.Value)
{
ExpandedState.Value = ExpandedState.Value switch
{
ModCustomisationPanelState.Collapsed => ModCustomisationPanelState.Expanded,
_ => ModCustomisationPanelState.Collapsed
};
}
return base.OnClick(e);
}
private bool touchedThisFrame;
protected override bool OnTouchDown(TouchDownEvent e)
{
if (Enabled.Value)
{
touchedThisFrame = true;
Schedule(() => touchedThisFrame = false);
}
return base.OnTouchDown(e);
}
protected override bool OnHover(HoverEvent e)
{
if (Enabled.Value)
{
if (!touchedThisFrame && panel.ExpandedState.Value == ModCustomisationPanelState.Collapsed)
panel.ExpandedState.Value = ModCustomisationPanelState.ExpandedByHover;
}
return base.OnHover(e);
}
} }
} }

View File

@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Mods
public readonly BindableBool Enabled = new BindableBool(); public readonly BindableBool Enabled = new BindableBool();
public readonly BindableBool Expanded = new BindableBool(); public readonly Bindable<ModCustomisationPanelState> ExpandedState = new Bindable<ModCustomisationPanelState>();
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>()); public Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
@ -46,9 +46,9 @@ namespace osu.Game.Overlays.Mods
// Handle{Non}PositionalInput controls whether the panel should act as a blocking layer on the screen. only block when the panel is expanded. // Handle{Non}PositionalInput controls whether the panel should act as a blocking layer on the screen. only block when the panel is expanded.
// These properties are used because they correctly handle blocking/unblocking hover when mouse is pointing at a drawable outside // These properties are used because they correctly handle blocking/unblocking hover when mouse is pointing at a drawable outside
// (returning Expanded.Value to OnHover or overriding Block{Non}PositionalInput doesn't work). // (handling OnHover or overriding Block{Non}PositionalInput doesn't work).
public override bool HandlePositionalInput => Expanded.Value; public override bool HandlePositionalInput => ExpandedState.Value != ModCustomisationPanelState.Collapsed;
public override bool HandleNonPositionalInput => Expanded.Value; public override bool HandleNonPositionalInput => ExpandedState.Value != ModCustomisationPanelState.Collapsed;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
@ -57,15 +57,15 @@ namespace osu.Game.Overlays.Mods
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new ModCustomisationHeader new ModCustomisationHeader(this)
{ {
Depth = float.MinValue, Depth = float.MinValue,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = header_height, Height = header_height,
Enabled = { BindTarget = Enabled }, Enabled = { BindTarget = Enabled },
Expanded = { BindTarget = Expanded }, ExpandedState = { BindTarget = ExpandedState },
}, },
content = new FocusGrabbingContainer content = new FocusGrabbingContainer(this)
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
BorderColour = colourProvider.Dark3, BorderColour = colourProvider.Dark3,
@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Mods
Roundness = 5f, Roundness = 5f,
Colour = Color4.Black.Opacity(0.25f), Colour = Color4.Black.Opacity(0.25f),
}, },
Expanded = { BindTarget = Expanded }, ExpandedState = { BindTarget = ExpandedState },
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
@ -122,7 +122,7 @@ namespace osu.Game.Overlays.Mods
this.FadeColour(OsuColour.Gray(e.NewValue ? 1f : 0.6f), 300, Easing.OutQuint); this.FadeColour(OsuColour.Gray(e.NewValue ? 1f : 0.6f), 300, Easing.OutQuint);
}, true); }, true);
Expanded.BindValueChanged(_ => updateDisplay(), true); ExpandedState.BindValueChanged(_ => updateDisplay(), true);
SelectedMods.BindValueChanged(_ => updateMods(), true); SelectedMods.BindValueChanged(_ => updateMods(), true);
FinishTransforms(true); FinishTransforms(true);
@ -134,7 +134,7 @@ namespace osu.Game.Overlays.Mods
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
Expanded.Value = false; ExpandedState.Value = ModCustomisationPanelState.Collapsed;
return base.OnClick(e); return base.OnClick(e);
} }
@ -147,7 +147,7 @@ namespace osu.Game.Overlays.Mods
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.Back: case GlobalAction.Back:
Expanded.Value = false; ExpandedState.Value = ModCustomisationPanelState.Collapsed;
return true; return true;
} }
@ -162,7 +162,7 @@ namespace osu.Game.Overlays.Mods
{ {
content.ClearTransforms(); content.ClearTransforms();
if (Expanded.Value) if (ExpandedState.Value != ModCustomisationPanelState.Collapsed)
{ {
content.AutoSizeDuration = 400; content.AutoSizeDuration = 400;
content.AutoSizeEasing = Easing.OutQuint; content.AutoSizeEasing = Easing.OutQuint;
@ -179,7 +179,7 @@ namespace osu.Game.Overlays.Mods
private void updateMods() private void updateMods()
{ {
Expanded.Value = false; ExpandedState.Value = ModCustomisationPanelState.Collapsed;
sectionsFlow.Clear(); sectionsFlow.Clear();
// Importantly, the selected mods bindable is already ordered by the mod select overlay (following the order of mod columns and panels). // Importantly, the selected mods bindable is already ordered by the mod select overlay (following the order of mod columns and panels).
@ -202,10 +202,35 @@ namespace osu.Game.Overlays.Mods
private partial class FocusGrabbingContainer : InputBlockingContainer private partial class FocusGrabbingContainer : InputBlockingContainer
{ {
public IBindable<bool> Expanded { get; } = new BindableBool(); public readonly Bindable<ModCustomisationPanelState> ExpandedState = new Bindable<ModCustomisationPanelState>();
public override bool RequestsFocus => Expanded.Value; public override bool RequestsFocus => panel.ExpandedState.Value != ModCustomisationPanelState.Collapsed;
public override bool AcceptsFocus => Expanded.Value; public override bool AcceptsFocus => panel.ExpandedState.Value != ModCustomisationPanelState.Collapsed;
private readonly ModCustomisationPanel panel;
public FocusGrabbingContainer(ModCustomisationPanel panel)
{
this.panel = panel;
}
protected override void OnHoverLost(HoverLostEvent e)
{
if (ExpandedState.Value is ModCustomisationPanelState.ExpandedByHover
&& !ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
{
ExpandedState.Value = ModCustomisationPanelState.Collapsed;
}
base.OnHoverLost(e);
}
}
public enum ModCustomisationPanelState
{
Collapsed = 0,
ExpandedByHover = 1,
Expanded = 2,
} }
} }
} }

View File

@ -237,7 +237,7 @@ namespace osu.Game.Overlays.Mods
ActiveMods.Value = ComputeActiveMods(); ActiveMods.Value = ComputeActiveMods();
}, true); }, true);
customisationPanel.Expanded.BindValueChanged(_ => updateCustomisationVisualState(), true); customisationPanel.ExpandedState.BindValueChanged(_ => updateCustomisationVisualState(), true);
SearchTextBox.Current.BindValueChanged(query => SearchTextBox.Current.BindValueChanged(query =>
{ {
@ -368,18 +368,18 @@ namespace osu.Game.Overlays.Mods
customisationPanel.Enabled.Value = true; customisationPanel.Enabled.Value = true;
if (anyModPendingConfiguration) if (anyModPendingConfiguration)
customisationPanel.Expanded.Value = true; customisationPanel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded;
} }
else else
{ {
customisationPanel.Expanded.Value = false; customisationPanel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Collapsed;
customisationPanel.Enabled.Value = false; customisationPanel.Enabled.Value = false;
} }
} }
private void updateCustomisationVisualState() private void updateCustomisationVisualState()
{ {
if (customisationPanel.Expanded.Value) if (customisationPanel.ExpandedState.Value != ModCustomisationPanel.ModCustomisationPanelState.Collapsed)
{ {
columnScroll.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint); columnScroll.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint);
SearchTextBox.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint); SearchTextBox.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint);
@ -544,7 +544,7 @@ namespace osu.Game.Overlays.Mods
nonFilteredColumnCount += 1; nonFilteredColumnCount += 1;
} }
customisationPanel.Expanded.Value = false; customisationPanel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Collapsed;
} }
#endregion #endregion
@ -571,7 +571,7 @@ namespace osu.Game.Overlays.Mods
// wherein activating the binding will both change the contents of the search text box and deselect all mods. // wherein activating the binding will both change the contents of the search text box and deselect all mods.
case GlobalAction.DeselectAllMods: case GlobalAction.DeselectAllMods:
{ {
if (!SearchTextBox.HasFocus && !customisationPanel.Expanded.Value) if (!SearchTextBox.HasFocus && customisationPanel.ExpandedState.Value == ModCustomisationPanel.ModCustomisationPanelState.Collapsed)
{ {
DisplayedFooterContent?.DeselectAllModsButton?.TriggerClick(); DisplayedFooterContent?.DeselectAllModsButton?.TriggerClick();
return true; return true;
@ -637,7 +637,7 @@ namespace osu.Game.Overlays.Mods
if (e.Repeat || e.Key != Key.Tab) if (e.Repeat || e.Key != Key.Tab)
return false; return false;
if (customisationPanel.Expanded.Value) if (customisationPanel.ExpandedState.Value != ModCustomisationPanel.ModCustomisationPanelState.Collapsed)
return true; return true;
// TODO: should probably eventually support typical platform search shortcuts (`Ctrl-F`, `/`) // TODO: should probably eventually support typical platform search shortcuts (`Ctrl-F`, `/`)

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -16,6 +14,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
@ -50,14 +49,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
private readonly List<SelectionBlueprint<T>> selectedBlueprints; private readonly List<SelectionBlueprint<T>> selectedBlueprints;
protected SelectionBox SelectionBox { get; private set; } protected SelectionBox SelectionBox { get; private set; } = null!;
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
protected IEditorChangeHandler ChangeHandler { get; private set; } protected IEditorChangeHandler? ChangeHandler { get; private set; }
public SelectionRotationHandler RotationHandler { get; private set; } public SelectionRotationHandler RotationHandler { get; private set; } = null!;
public SelectionScaleHandler ScaleHandler { get; private set; } public SelectionScaleHandler ScaleHandler { get; private set; } = null!;
[Resolved(CanBeNull = true)]
protected OsuContextMenuContainer? ContextMenuContainer { get; private set; }
protected SelectionHandler() protected SelectionHandler()
{ {
@ -230,7 +232,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary> /// <summary>
/// Deselect all selected items. /// Deselect all selected items.
/// </summary> /// </summary>
protected void DeselectAll() => SelectedItems.Clear(); protected void DeselectAll()
{
SelectedItems.Clear();
ContextMenuContainer?.CloseMenu();
}
/// <summary> /// <summary>
/// Handle a blueprint becoming selected. /// Handle a blueprint becoming selected.
@ -243,6 +249,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
SelectedItems.Add(blueprint.Item); SelectedItems.Add(blueprint.Item);
selectedBlueprints.Add(blueprint); selectedBlueprints.Add(blueprint);
ContextMenuContainer?.CloseMenu();
} }
/// <summary> /// <summary>

View File

@ -6,6 +6,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework; using osu.Framework;
@ -159,7 +160,7 @@ namespace osu.Game.Screens.Edit
private string lastSavedHash; private string lastSavedHash;
private Container<EditorScreen> screenContainer; private ScreenContainer screenContainer;
[CanBeNull] [CanBeNull]
private readonly EditorLoader loader; private readonly EditorLoader loader;
@ -329,7 +330,7 @@ namespace osu.Game.Screens.Edit
Name = "Screen container", Name = "Screen container",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 40, Bottom = 50 }, Padding = new MarginPadding { Top = 40, Bottom = 50 },
Child = screenContainer = new Container<EditorScreen> Child = screenContainer = new ScreenContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
} }
@ -422,6 +423,7 @@ namespace osu.Game.Screens.Edit
MutationTracker, MutationTracker,
} }
}); });
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true); changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true); changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
@ -1007,7 +1009,7 @@ namespace osu.Game.Screens.Edit
throw new InvalidOperationException("Editor menu bar switched to an unsupported mode"); throw new InvalidOperationException("Editor menu bar switched to an unsupported mode");
} }
LoadComponentAsync(currentScreen, newScreen => screenContainer.LoadComponentAsync(currentScreen, newScreen =>
{ {
if (newScreen == currentScreen) if (newScreen == currentScreen)
{ {
@ -1385,5 +1387,12 @@ namespace osu.Game.Screens.Edit
{ {
} }
} }
private partial class ScreenContainer : Container<EditorScreen>
{
public new Task LoadComponentAsync<TLoadable>([NotNull] TLoadable component, Action<TLoadable> onLoaded = null, CancellationToken cancellation = default, Scheduler scheduler = null)
where TLoadable : Drawable
=> base.LoadComponentAsync(component, onLoaded, cancellation, scheduler);
}
} }
} }