mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 08:22:56 +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);
|
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()
|
private void waitForInitialSelection()
|
||||||
{
|
{
|
||||||
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
|
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -43,6 +45,12 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
InputManager.MoveMouseTo(Vector2.Zero);
|
InputManager.MoveMouseTo(Vector2.Zero);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestState()
|
||||||
|
{
|
||||||
|
AddRepeatStep("toggle options state", () => this.ChildrenOfType<FooterButton>().Last().Enabled.Toggle(), 20);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestFooterRandom()
|
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()
|
public Footer()
|
||||||
{
|
{
|
||||||
@ -78,6 +89,7 @@ namespace osu.Game.Screens.Select
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 3,
|
Height = 3,
|
||||||
Position = new Vector2(0, -3),
|
Position = new Vector2(0, -3),
|
||||||
|
Colour = Color4.Black,
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
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 Hovered;
|
||||||
public Action HoverLost;
|
public Action HoverLost;
|
||||||
public GlobalAction? Hotkey;
|
public GlobalAction? Hotkey;
|
||||||
|
|
||||||
|
private bool mouseDown;
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
@ -140,32 +148,38 @@ namespace osu.Game.Screens.Select
|
|||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
Hovered?.Invoke();
|
Hovered?.Invoke();
|
||||||
light.ScaleTo(new Vector2(1, 2), Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
updateDisplay();
|
||||||
light.FadeColour(SelectedColour, Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
HoverLost?.Invoke();
|
HoverLost?.Invoke();
|
||||||
light.ScaleTo(new Vector2(1, 1), Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
updateDisplay();
|
||||||
light.FadeColour(DeselectedColour, Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
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);
|
return base.OnMouseDown(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnMouseUp(MouseUpEvent e)
|
protected override void OnMouseUp(MouseUpEvent e)
|
||||||
{
|
{
|
||||||
box.FadeOut(Footer.TRANSITION_LENGTH, Easing.OutQuint);
|
mouseDown = false;
|
||||||
|
updateDisplay();
|
||||||
base.OnMouseUp(e);
|
base.OnMouseUp(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
|
if (!Enabled.Value)
|
||||||
|
return true;
|
||||||
|
|
||||||
box.ClearTransforms();
|
box.ClearTransforms();
|
||||||
box.Alpha = 1;
|
box.Alpha = 1;
|
||||||
box.FadeOut(Footer.TRANSITION_LENGTH * 3, Easing.OutQuint);
|
box.FadeOut(Footer.TRANSITION_LENGTH * 3, Easing.OutQuint);
|
||||||
@ -184,5 +198,20 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnReleased(KeyBindingReleaseEvent<GlobalAction> e) { }
|
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; }
|
protected BeatmapDetailArea BeatmapDetails { get; private set; }
|
||||||
|
|
||||||
|
private FooterButtonOptions beatmapOptionsButton;
|
||||||
|
|
||||||
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
private double audioFeedbackLastPlaybackTime;
|
private double audioFeedbackLastPlaybackTime;
|
||||||
@ -314,7 +316,7 @@ namespace osu.Game.Screens.Select
|
|||||||
NextRandom = () => Carousel.SelectNextRandom(),
|
NextRandom = () => Carousel.SelectNextRandom(),
|
||||||
PreviousRandom = Carousel.SelectPreviousRandom
|
PreviousRandom = Carousel.SelectPreviousRandom
|
||||||
}, null),
|
}, null),
|
||||||
(new FooterButtonOptions(), BeatmapOptions)
|
(beatmapOptionsButton = new FooterButtonOptions(), BeatmapOptions)
|
||||||
};
|
};
|
||||||
|
|
||||||
protected virtual ModSelectOverlay CreateModSelectOverlay() => new SoloModSelectOverlay();
|
protected virtual ModSelectOverlay CreateModSelectOverlay() => new SoloModSelectOverlay();
|
||||||
@ -739,6 +741,16 @@ namespace osu.Game.Screens.Select
|
|||||||
beatmapInfoWedge.Beatmap = beatmap;
|
beatmapInfoWedge.Beatmap = beatmap;
|
||||||
|
|
||||||
BeatmapDetails.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);
|
private readonly WeakReference<ITrack> lastTrack = new WeakReference<ITrack>(null);
|
||||||
|
Loading…
Reference in New Issue
Block a user