mirror of
https://github.com/ppy/osu
synced 2024-12-29 10:22:43 +00:00
Add button for creating new mod presets
This commit is contained in:
parent
227906e30e
commit
085080576a
@ -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;
|
||||
|
38
osu.Game/Overlays/Mods/AddPresetButton.cs
Normal file
38
osu.Game/Overlays/Mods/AddPresetButton.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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(_ =>
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user