mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:12:56 +08:00
Disable beatmap options button when none selected
This commit is contained in:
parent
0e46614c57
commit
039ab83a46
@ -37,7 +37,6 @@ using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Carousel;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Screens.Select.Options;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.SongSelect
|
||||
@ -1057,14 +1056,15 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapOptionsButtonDisable()
|
||||
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()
|
||||
@ -1154,12 +1154,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
public new BeatmapCarousel Carousel => base.Carousel;
|
||||
public new ModSelectOverlay ModSelect => base.ModSelect;
|
||||
|
||||
public new BeatmapOptionsButton DeleteOptionButton => base.DeleteOptionButton;
|
||||
|
||||
public new BeatmapOptionsButton ClearOptionButton => base.ClearOptionButton;
|
||||
|
||||
public new BeatmapOptionsButton? EditOptionButton => base.EditOptionButton;
|
||||
|
||||
public new void PresentScore(ScoreInfo score) => base.PresentScore(score);
|
||||
|
||||
protected override bool OnStart()
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Select.Options;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Utils;
|
||||
using osuTK.Input;
|
||||
|
@ -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();
|
||||
@ -738,6 +740,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