mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 01:47:33 +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 osu.Game.Rulesets.Mods;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
@ -39,6 +40,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||||
|
|
||||||
|
public BindableBool Collapsed { get; } = new BindableBool(true);
|
||||||
|
|
||||||
private ModSettingChangeTracker? modSettingChangeTracker;
|
private ModSettingChangeTracker? modSettingChangeTracker;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -47,10 +50,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
private CancellationTokenSource? cancellationSource;
|
private CancellationTokenSource? cancellationSource;
|
||||||
private IBindable<StarDifficulty?> starDifficulty = null!;
|
private IBindable<StarDifficulty?> starDifficulty = null!;
|
||||||
|
|
||||||
public BeatmapAttributesDisplay()
|
private const float transition_duration = 250;
|
||||||
{
|
|
||||||
Collapsed.Value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -75,6 +75,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RightContent.Alpha = 0;
|
||||||
RightContent.AddRange(new Drawable[]
|
RightContent.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
circleSizeDisplay = new VerticalAttributeDisplay("CS") { Shear = new Vector2(-shear, 0), },
|
circleSizeDisplay = new VerticalAttributeDisplay("CS") { Shear = new Vector2(-shear, 0), },
|
||||||
@ -98,6 +99,43 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
BeatmapInfo.BindValueChanged(_ => updateValues(), 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(() =>
|
private void updateValues() => Scheduler.AddOnce(() =>
|
||||||
|
@ -2,12 +2,10 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -20,8 +18,6 @@ namespace osu.Game.Overlays.Mods
|
|||||||
protected FillFlowContainer RightContent { get; private set; } = null!;
|
protected FillFlowContainer RightContent { get; private set; } = null!;
|
||||||
protected Container Content { get; private set; } = null!;
|
protected Container Content { get; private set; } = null!;
|
||||||
|
|
||||||
public BindableBool Collapsed { get; } = new BindableBool();
|
|
||||||
|
|
||||||
private Container innerContent = null!;
|
private Container innerContent = null!;
|
||||||
|
|
||||||
protected Box MainBackground { get; private set; } = null!;
|
protected Box MainBackground { get; private set; } = null!;
|
||||||
@ -30,8 +26,6 @@ namespace osu.Game.Overlays.Mods
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
private const float transition_duration = 250;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -88,7 +82,6 @@ namespace osu.Game.Overlays.Mods
|
|||||||
},
|
},
|
||||||
RightContent = new FillFlowContainer
|
RightContent = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
AutoSizeAxes = Axes.X,
|
AutoSizeAxes = Axes.X,
|
||||||
@ -111,43 +104,6 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
Content.BorderColour = ColourInfo.GradientVertical(MainBackground.Colour, glowColour);
|
Content.BorderColour = ColourInfo.GradientVertical(MainBackground.Colour, glowColour);
|
||||||
innerContent.BorderColour = ColourInfo.GradientVertical(FrontBackground.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