mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Merge pull request #11105 from Joehuu/mod-settings-fade-in/out
Add fade in/out animations to mod settings container
This commit is contained in:
commit
a5e2509d52
@ -50,7 +50,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddAssert("button enabled", () => modSelect.CustomiseButton.Enabled.Value);
|
||||
AddStep("open Customisation", () => modSelect.CustomiseButton.Click());
|
||||
AddStep("deselect mod", () => modSelect.SelectMod(testCustomisableMod));
|
||||
AddAssert("controls hidden", () => modSelect.ModSettingsContainer.Alpha == 0);
|
||||
AddAssert("controls hidden", () => modSelect.ModSettingsContainer.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -72,11 +72,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
createModSelect();
|
||||
openModSelect();
|
||||
|
||||
AddAssert("Customisation closed", () => modSelect.ModSettingsContainer.Alpha == 0);
|
||||
AddAssert("Customisation closed", () => modSelect.ModSettingsContainer.State.Value == Visibility.Hidden);
|
||||
AddStep("select mod", () => modSelect.SelectMod(testCustomisableAutoOpenMod));
|
||||
AddAssert("Customisation opened", () => modSelect.ModSettingsContainer.Alpha == 1);
|
||||
AddAssert("Customisation opened", () => modSelect.ModSettingsContainer.State.Value == Visibility.Visible);
|
||||
AddStep("deselect mod", () => modSelect.SelectMod(testCustomisableAutoOpenMod));
|
||||
AddAssert("Customisation closed", () => modSelect.ModSettingsContainer.Alpha == 0);
|
||||
AddAssert("Customisation closed", () => modSelect.ModSettingsContainer.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -123,7 +123,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddStep("change mod settings menu width to full screen", () => modSelect.SetModSettingsWidth(1.0f));
|
||||
AddStep("select cm2", () => modSelect.SelectMod(testCustomisableAutoOpenMod));
|
||||
AddAssert("Customisation opened", () => modSelect.ModSettingsContainer.Alpha == 1);
|
||||
AddAssert("Customisation opened", () => modSelect.ModSettingsContainer.State.Value == Visibility.Visible);
|
||||
AddStep("hover over mod behind settings menu", () => InputManager.MoveMouseTo(modSelect.GetModButton(testCustomisableMod)));
|
||||
AddAssert("Mod is not considered hovered over", () => !modSelect.GetModButton(testCustomisableMod).IsHovered);
|
||||
AddStep("left click mod", () => InputManager.Click(MouseButton.Left));
|
||||
@ -153,7 +153,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private class TestModSelectOverlay : ModSelectOverlay
|
||||
{
|
||||
public new Container ModSettingsContainer => base.ModSettingsContainer;
|
||||
public new VisibilityContainer ModSettingsContainer => base.ModSettingsContainer;
|
||||
public new TriangleButton CustomiseButton => base.CustomiseButton;
|
||||
|
||||
public bool ButtonsLoaded => ModSectionsContainer.Children.All(c => c.ModIconsLoaded);
|
||||
|
@ -157,6 +157,11 @@ namespace osu.Game.Overlays.Mods
|
||||
},
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
// Body
|
||||
new OsuScrollContainer
|
||||
@ -170,7 +175,9 @@ namespace osu.Game.Overlays.Mods
|
||||
Vertical = 10,
|
||||
Horizontal = OsuScreen.HORIZONTAL_OVERFLOW_PADDING
|
||||
},
|
||||
Child = ModSectionsContainer = new FillFlowContainer<ModSection>
|
||||
Children = new Drawable[]
|
||||
{
|
||||
ModSectionsContainer = new FillFlowContainer<ModSection>
|
||||
{
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -189,6 +196,19 @@ namespace osu.Game.Overlays.Mods
|
||||
new FunSection { Action = modButtonPressed },
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
ModSettingsContainer = new ModSettingsContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Width = 0.3f,
|
||||
Alpha = 0,
|
||||
Padding = new MarginPadding(30),
|
||||
SelectedMods = { BindTarget = SelectedMods },
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
new Drawable[]
|
||||
@ -237,7 +257,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
Width = 180,
|
||||
Text = "Customisation",
|
||||
Action = () => ModSettingsContainer.Alpha = ModSettingsContainer.Alpha == 1 ? 0 : 1,
|
||||
Action = () => ModSettingsContainer.ToggleVisibility(),
|
||||
Enabled = { Value = false },
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
@ -281,16 +301,6 @@ namespace osu.Game.Overlays.Mods
|
||||
},
|
||||
},
|
||||
},
|
||||
ModSettingsContainer = new ModSettingsContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Width = 0.25f,
|
||||
Alpha = 0,
|
||||
X = -100,
|
||||
SelectedMods = { BindTarget = SelectedMods },
|
||||
}
|
||||
};
|
||||
|
||||
((IBindable<bool>)CustomiseButton.Enabled).BindTo(ModSettingsContainer.HasSettingsForSelection);
|
||||
@ -430,7 +440,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
DeselectTypes(selectedMod.IncompatibleMods, true);
|
||||
|
||||
if (selectedMod.RequiresConfiguration) ModSettingsContainer.Alpha = 1;
|
||||
if (selectedMod.RequiresConfiguration) ModSettingsContainer.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public class ModSettingsContainer : Container
|
||||
public class ModSettingsContainer : VisibilityContainer
|
||||
{
|
||||
public readonly IBindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
@ -27,8 +27,21 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private readonly FillFlowContainer<ModControlSection> modSettingsContent;
|
||||
|
||||
private readonly Container content;
|
||||
|
||||
private const double transition_duration = 400;
|
||||
|
||||
public ModSettingsContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Child = content = new Container
|
||||
{
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
X = 1,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
@ -49,6 +62,7 @@ namespace osu.Game.Overlays.Mods
|
||||
Padding = new MarginPadding(20),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -80,5 +94,17 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||
protected override bool OnHover(HoverEvent e) => true;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
this.FadeIn(transition_duration, Easing.OutQuint);
|
||||
content.MoveToX(0, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
this.FadeOut(transition_duration, Easing.OutQuint);
|
||||
content.MoveToX(1, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user