mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 22:12:53 +08:00
Implement popover for creating mod presets
This commit is contained in:
parent
085080576a
commit
1b3074d098
@ -9,6 +9,7 @@ using osu.Framework.Extensions.ObjectExtensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -22,6 +23,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
protected override bool UseFreshStoragePerRun => true;
|
protected override bool UseFreshStoragePerRun => true;
|
||||||
|
|
||||||
|
private Container<Drawable> content = null!;
|
||||||
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
private RulesetStore rulesets = null!;
|
private RulesetStore rulesets = null!;
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
@ -32,6 +36,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||||
Dependencies.Cache(Realm);
|
Dependencies.Cache(Realm);
|
||||||
|
|
||||||
|
base.Content.Add(content = new PopoverContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding(30),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
@ -57,15 +67,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
public void TestBasicOperation()
|
public void TestBasicOperation()
|
||||||
{
|
{
|
||||||
AddStep("set osu! ruleset", () => Ruleset.Value = rulesets.GetRuleset(0));
|
AddStep("set osu! ruleset", () => Ruleset.Value = rulesets.GetRuleset(0));
|
||||||
AddStep("create content", () => Child = new Container
|
AddStep("create content", () => Child = new ModPresetColumn
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
Anchor = Anchor.Centre,
|
||||||
Padding = new MarginPadding(30),
|
Origin = Anchor.Centre,
|
||||||
Child = new ModPresetColumn
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
AddUntilStep("3 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 3);
|
AddUntilStep("3 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 3);
|
||||||
|
|
||||||
@ -112,15 +117,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
public void TestSoftDeleteSupport()
|
public void TestSoftDeleteSupport()
|
||||||
{
|
{
|
||||||
AddStep("set osu! ruleset", () => Ruleset.Value = rulesets.GetRuleset(0));
|
AddStep("set osu! ruleset", () => Ruleset.Value = rulesets.GetRuleset(0));
|
||||||
AddStep("create content", () => Child = new Container
|
AddStep("create content", () => Child = new ModPresetColumn
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
Anchor = Anchor.Centre,
|
||||||
Padding = new MarginPadding(30),
|
Origin = Anchor.Centre,
|
||||||
Child = new ModPresetColumn
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
AddUntilStep("3 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 3);
|
AddUntilStep("3 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 3);
|
||||||
|
|
||||||
|
@ -2,14 +2,20 @@
|
|||||||
// 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.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
public class AddPresetButton : ShearedToggleButton
|
public class AddPresetButton : ShearedToggleButton, IHasPopover
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; } = null!;
|
private OsuColour colours { get; set; } = null!;
|
||||||
@ -33,6 +39,73 @@ namespace osu.Game.Overlays.Mods
|
|||||||
DarkerColour = Active.Value ? colours.Orange1 : ColourProvider.Background3;
|
DarkerColour = Active.Value ? colours.Orange1 : ColourProvider.Background3;
|
||||||
LighterColour = Active.Value ? colours.Orange0 : ColourProvider.Background1;
|
LighterColour = Active.Value ? colours.Orange0 : ColourProvider.Background1;
|
||||||
TextColour = Active.Value ? ColourProvider.Background6 : ColourProvider.Content1;
|
TextColour = Active.Value ? ColourProvider.Background6 : ColourProvider.Content1;
|
||||||
|
|
||||||
|
if (Active.Value)
|
||||||
|
this.ShowPopover();
|
||||||
|
else
|
||||||
|
this.HidePopover();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Popover GetPopover() => new AddPresetPopover(this);
|
||||||
|
|
||||||
|
private class AddPresetPopover : OsuPopover
|
||||||
|
{
|
||||||
|
private readonly AddPresetButton button;
|
||||||
|
|
||||||
|
private readonly LabelledTextBox nameTextBox;
|
||||||
|
private readonly LabelledTextBox descriptionTextBox;
|
||||||
|
private readonly ShearedButton createButton;
|
||||||
|
|
||||||
|
public AddPresetPopover(AddPresetButton addPresetButton)
|
||||||
|
{
|
||||||
|
button = addPresetButton;
|
||||||
|
|
||||||
|
Child = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Width = 300,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Spacing = new Vector2(7),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
nameTextBox = new LabelledTextBox
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Label = "Name",
|
||||||
|
TabbableContentContainer = this
|
||||||
|
},
|
||||||
|
descriptionTextBox = new LabelledTextBox
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Label = "Description",
|
||||||
|
TabbableContentContainer = this
|
||||||
|
},
|
||||||
|
createButton = new ShearedButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Text = "Create preset",
|
||||||
|
Action = this.HidePopover
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
||||||
|
{
|
||||||
|
createButton.DarkerColour = colours.Orange1;
|
||||||
|
createButton.LighterColour = colours.Orange0;
|
||||||
|
createButton.TextColour = colourProvider.Background6;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateState(ValueChangedEvent<Visibility> state)
|
||||||
|
{
|
||||||
|
base.UpdateState(state);
|
||||||
|
if (state.NewValue == Visibility.Hidden)
|
||||||
|
button.Active.Value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user