Add button for creating new mod presets

This commit is contained in:
Bartłomiej Dach 2022-07-22 21:17:27 +02:00
parent 227906e30e
commit 085080576a
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
4 changed files with 49 additions and 7 deletions

View File

@ -49,15 +49,15 @@ namespace osu.Game.Graphics.UserInterface
Active.BindDisabledChanged(disabled => Action = disabled ? null : Active.Toggle, true);
Active.BindValueChanged(_ =>
{
updateActiveState();
UpdateActiveState();
playSample();
});
updateActiveState();
UpdateActiveState();
base.LoadComplete();
}
private void updateActiveState()
protected virtual void UpdateActiveState()
{
DarkerColour = Active.Value ? ColourProvider.Highlight1 : ColourProvider.Background3;
LighterColour = Active.Value ? ColourProvider.Colour0 : ColourProvider.Background1;

View File

@ -0,0 +1,38 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osuTK;
namespace osu.Game.Overlays.Mods
{
public class AddPresetButton : ShearedToggleButton
{
[Resolved]
private OsuColour colours { get; set; } = null!;
public AddPresetButton()
: base(1)
{
RelativeSizeAxes = Axes.X;
Height = ModSelectPanel.HEIGHT;
// shear will be applied at a higher level in `ModPresetColumn`.
Content.Shear = Vector2.Zero;
Padding = new MarginPadding();
Text = "+";
TextSize = 30;
}
protected override void UpdateActiveState()
{
DarkerColour = Active.Value ? colours.Orange1 : ColourProvider.Background3;
LighterColour = Active.Value ? colours.Orange0 : ColourProvider.Background1;
TextColour = Active.Value ? ColourProvider.Background6 : ColourProvider.Content1;
}
}
}

View File

@ -31,6 +31,10 @@ namespace osu.Game.Overlays.Mods
{
AccentColour = colours.Orange1;
HeaderText = ModSelectOverlayStrings.PersonalPresets;
AddPresetButton addPresetButton;
ItemsFlow.Add(addPresetButton = new AddPresetButton());
ItemsFlow.SetLayoutPosition(addPresetButton, float.PositiveInfinity);
}
protected override void LoadComplete()
@ -64,7 +68,7 @@ namespace osu.Game.Overlays.Mods
if (!presets.Any())
{
ItemsFlow.Clear();
ItemsFlow.RemoveAll(panel => panel is ModPresetPanel);
return;
}
@ -77,7 +81,8 @@ namespace osu.Game.Overlays.Mods
latestLoadTask = loadTask = LoadComponentsAsync(panels, loaded =>
{
ItemsFlow.ChildrenEnumerable = loaded;
ItemsFlow.RemoveAll(panel => panel is ModPresetPanel);
ItemsFlow.AddRange(loaded);
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
loadTask.ContinueWith(_ =>
{

View File

@ -43,8 +43,7 @@ namespace osu.Game.Overlays.Mods
}
public const float CORNER_RADIUS = 7;
protected const float HEIGHT = 42;
public const float HEIGHT = 42;
protected virtual float IdleSwitchWidth => 14;
protected virtual float ExpandedSwitchWidth => 30;