mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
Merge pull request #21244 from nanashi-1/beatmapoptions-disabled
Disable certain beatmap option buttons when there are no beatmaps selected
This commit is contained in:
commit
1ff1738988
@ -1055,6 +1055,18 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddUntilStep("mod overlay hidden", () => songSelect!.ModSelect.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapOptionsDisabled()
|
||||
{
|
||||
createSongSelect();
|
||||
|
||||
addRulesetImportStep(0);
|
||||
|
||||
AddAssert("options enabled", () => songSelect.ChildrenOfType<FooterButtonOptions>().Single().Enabled.Value);
|
||||
AddStep("delete all beatmaps", () => manager.Delete());
|
||||
AddAssert("options disabled", () => !songSelect.ChildrenOfType<FooterButtonOptions>().Single().Enabled.Value);
|
||||
}
|
||||
|
||||
private void waitForInitialSelection()
|
||||
{
|
||||
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
|
||||
|
@ -3,8 +3,10 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Screens.Select;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
@ -43,6 +45,12 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
InputManager.MoveMouseTo(Vector2.Zero);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestState()
|
||||
{
|
||||
AddRepeatStep("toggle options state", () => this.ChildrenOfType<FooterButton>().Last().Enabled.Toggle(), 20);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFooterRandom()
|
||||
{
|
||||
|
@ -57,7 +57,18 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
private void updateModeLight()
|
||||
{
|
||||
var selectedButton = buttons.FirstOrDefault(b => b.Enabled.Value && b.IsHovered);
|
||||
|
||||
if (selectedButton != null)
|
||||
{
|
||||
modeLight.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
|
||||
modeLight.FadeColour(selectedButton.SelectedColour, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
modeLight.FadeOut(TRANSITION_LENGTH, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public Footer()
|
||||
{
|
||||
@ -78,6 +89,7 @@ namespace osu.Game.Screens.Select
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 3,
|
||||
Position = new Vector2(0, -3),
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
|
@ -120,10 +120,18 @@ namespace osu.Game.Screens.Select
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Enabled.BindValueChanged(_ => updateDisplay(), true);
|
||||
}
|
||||
|
||||
public Action Hovered;
|
||||
public Action HoverLost;
|
||||
public GlobalAction? Hotkey;
|
||||
|
||||
private bool mouseDown;
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
@ -140,32 +148,38 @@ namespace osu.Game.Screens.Select
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
Hovered?.Invoke();
|
||||
light.ScaleTo(new Vector2(1, 2), Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
light.FadeColour(SelectedColour, Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
updateDisplay();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
HoverLost?.Invoke();
|
||||
light.ScaleTo(new Vector2(1, 1), Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
light.FadeColour(DeselectedColour, Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
box.FadeTo(0.3f, Footer.TRANSITION_LENGTH * 2, Easing.OutQuint);
|
||||
if (!Enabled.Value)
|
||||
return true;
|
||||
|
||||
mouseDown = true;
|
||||
updateDisplay();
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
box.FadeOut(Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
mouseDown = false;
|
||||
updateDisplay();
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (!Enabled.Value)
|
||||
return true;
|
||||
|
||||
box.ClearTransforms();
|
||||
box.Alpha = 1;
|
||||
box.FadeOut(Footer.TRANSITION_LENGTH * 3, Easing.OutQuint);
|
||||
@ -184,5 +198,20 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
public virtual void OnReleased(KeyBindingReleaseEvent<GlobalAction> e) { }
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
this.FadeTo(Enabled.Value ? 1 : 0.25f, Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
|
||||
light.ScaleTo(Enabled.Value && IsHovered ? new Vector2(1, 2) : new Vector2(1), Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
light.FadeColour(Enabled.Value && IsHovered ? SelectedColour : DeselectedColour, Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
|
||||
box.FadeTo(Enabled.Value & mouseDown ? 0.3f : 0f, Footer.TRANSITION_LENGTH * 2, Easing.OutQuint);
|
||||
|
||||
if (Enabled.Value && IsHovered)
|
||||
Hovered?.Invoke();
|
||||
else
|
||||
HoverLost?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +112,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
protected BeatmapDetailArea BeatmapDetails { get; private set; }
|
||||
|
||||
private FooterButtonOptions beatmapOptionsButton;
|
||||
|
||||
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private double audioFeedbackLastPlaybackTime;
|
||||
@ -314,7 +316,7 @@ namespace osu.Game.Screens.Select
|
||||
NextRandom = () => Carousel.SelectNextRandom(),
|
||||
PreviousRandom = Carousel.SelectPreviousRandom
|
||||
}, null),
|
||||
(new FooterButtonOptions(), BeatmapOptions)
|
||||
(beatmapOptionsButton = new FooterButtonOptions(), BeatmapOptions)
|
||||
};
|
||||
|
||||
protected virtual ModSelectOverlay CreateModSelectOverlay() => new SoloModSelectOverlay();
|
||||
@ -739,6 +741,16 @@ namespace osu.Game.Screens.Select
|
||||
beatmapInfoWedge.Beatmap = beatmap;
|
||||
|
||||
BeatmapDetails.Beatmap = beatmap;
|
||||
|
||||
bool beatmapSelected = beatmap is not DummyWorkingBeatmap;
|
||||
|
||||
if (beatmapSelected)
|
||||
beatmapOptionsButton.Enabled.Value = true;
|
||||
else
|
||||
{
|
||||
beatmapOptionsButton.Enabled.Value = false;
|
||||
BeatmapOptions.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly WeakReference<ITrack> lastTrack = new WeakReference<ITrack>(null);
|
||||
|
Loading…
Reference in New Issue
Block a user