mirror of
https://github.com/ppy/osu.git
synced 2025-03-22 22:17:46 +08:00
Move collapsed bindable back to BeatmapAttributesDisplay
for now
Better to have it only in one place that needs it, rather than have it not work as expected when someone inherits `ModFooterInformationDisplay`.
This commit is contained in:
parent
44461b4eff
commit
94cdcfd7ce
@ -16,6 +16,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osuTK;
|
||||
using System.Threading;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Configuration;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
@ -39,6 +40,8 @@ namespace osu.Game.Overlays.Mods
|
||||
[Resolved]
|
||||
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||
|
||||
public BindableBool Collapsed { get; } = new BindableBool(true);
|
||||
|
||||
private ModSettingChangeTracker? modSettingChangeTracker;
|
||||
|
||||
[Resolved]
|
||||
@ -47,10 +50,7 @@ namespace osu.Game.Overlays.Mods
|
||||
private CancellationTokenSource? cancellationSource;
|
||||
private IBindable<StarDifficulty?> starDifficulty = null!;
|
||||
|
||||
public BeatmapAttributesDisplay()
|
||||
{
|
||||
Collapsed.Value = true;
|
||||
}
|
||||
private const float transition_duration = 250;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
@ -75,6 +75,7 @@ namespace osu.Game.Overlays.Mods
|
||||
}
|
||||
});
|
||||
|
||||
RightContent.Alpha = 0;
|
||||
RightContent.AddRange(new Drawable[]
|
||||
{
|
||||
circleSizeDisplay = new VerticalAttributeDisplay("CS") { Shear = new Vector2(-shear, 0), },
|
||||
@ -98,6 +99,43 @@ namespace osu.Game.Overlays.Mods
|
||||
}, true);
|
||||
|
||||
BeatmapInfo.BindValueChanged(_ => updateValues(), true);
|
||||
|
||||
Collapsed.BindValueChanged(_ =>
|
||||
{
|
||||
// Only start autosize animations on first collapse toggle. This avoids an ugly initial presentation.
|
||||
startAnimating();
|
||||
updateCollapsedState();
|
||||
});
|
||||
|
||||
updateCollapsedState();
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
startAnimating();
|
||||
updateCollapsedState();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
updateCollapsedState();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||
|
||||
protected override bool OnClick(ClickEvent e) => true;
|
||||
|
||||
private void startAnimating()
|
||||
{
|
||||
Content.AutoSizeEasing = Easing.OutQuint;
|
||||
Content.AutoSizeDuration = transition_duration;
|
||||
}
|
||||
|
||||
private void updateCollapsedState()
|
||||
{
|
||||
RightContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void updateValues() => Scheduler.AddOnce(() =>
|
||||
|
@ -2,12 +2,10 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -20,8 +18,6 @@ namespace osu.Game.Overlays.Mods
|
||||
protected FillFlowContainer RightContent { get; private set; } = null!;
|
||||
protected Container Content { get; private set; } = null!;
|
||||
|
||||
public BindableBool Collapsed { get; } = new BindableBool();
|
||||
|
||||
private Container innerContent = null!;
|
||||
|
||||
protected Box MainBackground { get; private set; } = null!;
|
||||
@ -30,8 +26,6 @@ namespace osu.Game.Overlays.Mods
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
private const float transition_duration = 250;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -88,7 +82,6 @@ namespace osu.Game.Overlays.Mods
|
||||
},
|
||||
RightContent = new FillFlowContainer
|
||||
{
|
||||
Alpha = 0,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.X,
|
||||
@ -111,43 +104,6 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
Content.BorderColour = ColourInfo.GradientVertical(MainBackground.Colour, glowColour);
|
||||
innerContent.BorderColour = ColourInfo.GradientVertical(FrontBackground.Colour, glowColour);
|
||||
|
||||
Collapsed.BindValueChanged(_ =>
|
||||
{
|
||||
// Only start autosize animations on first collapse toggle. This avoids an ugly initial presentation.
|
||||
startAnimating();
|
||||
updateCollapsedState();
|
||||
});
|
||||
|
||||
updateCollapsedState();
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
startAnimating();
|
||||
updateCollapsedState();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
updateCollapsedState();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||
|
||||
protected override bool OnClick(ClickEvent e) => true;
|
||||
|
||||
private void startAnimating()
|
||||
{
|
||||
Content.AutoSizeEasing = Easing.OutQuint;
|
||||
Content.AutoSizeDuration = transition_duration;
|
||||
}
|
||||
|
||||
private void updateCollapsedState()
|
||||
{
|
||||
RightContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user