mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 00:42:55 +08: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.BindDisabledChanged(disabled => Action = disabled ? null : Active.Toggle, true);
|
||||||
Active.BindValueChanged(_ =>
|
Active.BindValueChanged(_ =>
|
||||||
{
|
{
|
||||||
updateActiveState();
|
UpdateActiveState();
|
||||||
playSample();
|
playSample();
|
||||||
});
|
});
|
||||||
|
|
||||||
updateActiveState();
|
UpdateActiveState();
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateActiveState()
|
protected virtual void UpdateActiveState()
|
||||||
{
|
{
|
||||||
DarkerColour = Active.Value ? ColourProvider.Highlight1 : ColourProvider.Background3;
|
DarkerColour = Active.Value ? ColourProvider.Highlight1 : ColourProvider.Background3;
|
||||||
LighterColour = Active.Value ? ColourProvider.Colour0 : ColourProvider.Background1;
|
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;
|
AccentColour = colours.Orange1;
|
||||||
HeaderText = ModSelectOverlayStrings.PersonalPresets;
|
HeaderText = ModSelectOverlayStrings.PersonalPresets;
|
||||||
|
|
||||||
|
AddPresetButton addPresetButton;
|
||||||
|
ItemsFlow.Add(addPresetButton = new AddPresetButton());
|
||||||
|
ItemsFlow.SetLayoutPosition(addPresetButton, float.PositiveInfinity);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -64,7 +68,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
if (!presets.Any())
|
if (!presets.Any())
|
||||||
{
|
{
|
||||||
ItemsFlow.Clear();
|
ItemsFlow.RemoveAll(panel => panel is ModPresetPanel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +81,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
latestLoadTask = loadTask = LoadComponentsAsync(panels, loaded =>
|
latestLoadTask = loadTask = LoadComponentsAsync(panels, loaded =>
|
||||||
{
|
{
|
||||||
ItemsFlow.ChildrenEnumerable = loaded;
|
ItemsFlow.RemoveAll(panel => panel is ModPresetPanel);
|
||||||
|
ItemsFlow.AddRange(loaded);
|
||||||
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
|
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
|
||||||
loadTask.ContinueWith(_ =>
|
loadTask.ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
|
@ -43,8 +43,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
public const float CORNER_RADIUS = 7;
|
public const float CORNER_RADIUS = 7;
|
||||||
|
public const float HEIGHT = 42;
|
||||||
protected const float HEIGHT = 42;
|
|
||||||
|
|
||||||
protected virtual float IdleSwitchWidth => 14;
|
protected virtual float IdleSwitchWidth => 14;
|
||||||
protected virtual float ExpandedSwitchWidth => 30;
|
protected virtual float ExpandedSwitchWidth => 30;
|
||||||
|
Loading…
Reference in New Issue
Block a user