1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 00:53:22 +08:00

Merge branch 'master' into skillsrework

This commit is contained in:
smoogipoo 2021-10-10 16:16:54 +09:00
commit e7a3467655
30 changed files with 305 additions and 196 deletions

View File

@ -14,11 +14,11 @@ namespace osu.Game.Rulesets.Catch.Tests
{
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch";
[TestCase(4.050601681491468d, "diffcalc-test")]
[TestCase(4.0505463516206195d, "diffcalc-test")]
public void Test(double expected, string name)
=> base.Test(expected, name);
[TestCase(5.169743871843191d, "diffcalc-test")]
[TestCase(5.1696411260785498d, "diffcalc-test")]
public void TestClockRateAdjusted(double expected, string name)
=> Test(expected, name, new CatchModDoubleTime());

View File

@ -15,13 +15,13 @@ namespace osu.Game.Rulesets.Osu.Tests
{
protected override string ResourceAssembly => "osu.Game.Rulesets.Osu";
[TestCase(6.5867229481955389d, "diffcalc-test")]
[TestCase(1.0416315570967911d, "zero-length-sliders")]
[TestCase(6.6634445062299665d, "diffcalc-test")]
[TestCase(1.0404303969295756d, "zero-length-sliders")]
public void Test(double expected, string name)
=> base.Test(expected, name);
[TestCase(8.2730989071947896d, "diffcalc-test")]
[TestCase(1.2726413186221039d, "zero-length-sliders")]
[TestCase(8.3857915525197733d, "diffcalc-test")]
[TestCase(1.2705229071231638d, "zero-length-sliders")]
public void TestClockRateAdjusted(double expected, string name)
=> Test(expected, name, new OsuModDoubleTime());

View File

@ -12,6 +12,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
public double FlashlightRating { get; set; }
public double ApproachRate { get; set; }
public double OverallDifficulty { get; set; }
public double DrainRate { get; set; }
public int HitCircleCount { get; set; }
public int SpinnerCount { get; set; }
}

View File

@ -57,6 +57,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
double starRating = basePerformance > 0.00001 ? Math.Cbrt(1.12) * 0.027 * (Math.Cbrt(100000 / Math.Pow(2, 1 / 1.1) * basePerformance) + 4) : 0;
double preempt = (int)IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450) / clockRate;
double drainRate = beatmap.Difficulty.DrainRate;
int maxCombo = beatmap.HitObjects.Count;
// Add the ticks + tail of the slider. 1 is subtracted because the head circle would be counted twice (once for the slider itself in the line above)
@ -74,6 +75,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
FlashlightRating = flashlightRating,
ApproachRate = preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5,
OverallDifficulty = (80 - hitWindowGreat) / 6,
DrainRate = drainRate,
MaxCombo = maxCombo,
HitCircleCount = hitCirclesCount,
SpinnerCount = spinnerCount,

View File

@ -115,7 +115,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty
double approachRateBonus = 1.0 + (0.03 + 0.37 * approachRateTotalHitsFactor) * approachRateFactor;
// We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR.
if (mods.Any(h => h is OsuModHidden))
if (mods.Any(m => m is OsuModBlinds))
aimValue *= 1.3 + (totalHits * (0.0016 / (1 + 2 * countMiss)) * Math.Pow(accuracy, 16)) * (1 - 0.003 * Attributes.DrainRate * Attributes.DrainRate);
else if (mods.Any(h => h is OsuModHidden))
aimValue *= 1.0 + 0.04 * (12.0 - Attributes.ApproachRate);
aimValue *= approachRateBonus;
@ -153,7 +155,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty
speedValue *= 1.0 + (0.03 + 0.37 * approachRateTotalHitsFactor) * approachRateFactor;
if (mods.Any(m => m is OsuModHidden))
// Increasing the speed value by object count for Blinds isn't ideal, so the minimum buff is given.
if (mods.Any(m => m is OsuModBlinds))
speedValue *= 1.12;
else if (mods.Any(m => m is OsuModHidden))
speedValue *= 1.0 + 0.04 * (12.0 - Attributes.ApproachRate);
// Scale the speed value with accuracy and OD.
@ -189,7 +194,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty
// Bonus for many hitcircles - it's harder to keep good accuracy up for longer.
accuracyValue *= Math.Min(1.15, Math.Pow(amountHitObjectsWithAccuracy / 1000.0, 0.3));
if (mods.Any(m => m is OsuModHidden))
// Increasing the accuracy value by object count for Blinds isn't ideal, so the minimum buff is given.
if (mods.Any(m => m is OsuModBlinds))
accuracyValue *= 1.14;
else if (mods.Any(m => m is OsuModHidden))
accuracyValue *= 1.08;
if (mods.Any(m => m is OsuModFlashlight))
accuracyValue *= 1.02;

View File

@ -14,13 +14,13 @@ namespace osu.Game.Rulesets.Taiko.Tests
{
protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko";
[TestCase(2.2867022617692685d, "diffcalc-test")]
[TestCase(2.2867022617692685d, "diffcalc-test-strong")]
[TestCase(2.2420075288523802d, "diffcalc-test")]
[TestCase(2.2420075288523802d, "diffcalc-test-strong")]
public void Test(double expected, string name)
=> base.Test(expected, name);
[TestCase(3.1704781712282624d, "diffcalc-test")]
[TestCase(3.1704781712282624d, "diffcalc-test-strong")]
[TestCase(3.134084469440479d, "diffcalc-test")]
[TestCase(3.134084469440479d, "diffcalc-test-strong")]
public void TestClockRateAdjusted(double expected, string name)
=> Test(expected, name, new TaikoModDoubleTime());

View File

@ -47,10 +47,10 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
protected override Beatmap<TaikoHitObject> ConvertBeatmap(IBeatmap original, CancellationToken cancellationToken)
{
if (!(original.Difficulty is TaikoMutliplierAppliedDifficulty))
if (!(original.Difficulty is TaikoMultiplierAppliedDifficulty))
{
// Rewrite the beatmap info to add the slider velocity multiplier
original.Difficulty = new TaikoMutliplierAppliedDifficulty(original.Difficulty);
original.Difficulty = new TaikoMultiplierAppliedDifficulty(original.Difficulty);
}
Beatmap<TaikoHitObject> converted = base.ConvertBeatmap(original, cancellationToken);
@ -191,15 +191,15 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
protected override Beatmap<TaikoHitObject> CreateBeatmap() => new TaikoBeatmap();
private class TaikoMutliplierAppliedDifficulty : BeatmapDifficulty
private class TaikoMultiplierAppliedDifficulty : BeatmapDifficulty
{
public TaikoMutliplierAppliedDifficulty(IBeatmapDifficultyInfo difficulty)
public TaikoMultiplierAppliedDifficulty(IBeatmapDifficultyInfo difficulty)
{
CopyFrom(difficulty);
}
[UsedImplicitly]
public TaikoMutliplierAppliedDifficulty()
public TaikoMultiplierAppliedDifficulty()
{
}
@ -208,14 +208,14 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
public override void CopyTo(BeatmapDifficulty other)
{
base.CopyTo(other);
if (!(other is TaikoMutliplierAppliedDifficulty))
if (!(other is TaikoMultiplierAppliedDifficulty))
SliderMultiplier /= LegacyBeatmapEncoder.LEGACY_TAIKO_VELOCITY_MULTIPLIER;
}
public override void CopyFrom(IBeatmapDifficultyInfo other)
{
base.CopyFrom(other);
if (!(other is TaikoMutliplierAppliedDifficulty))
if (!(other is TaikoMultiplierAppliedDifficulty))
SliderMultiplier *= LegacyBeatmapEncoder.LEGACY_TAIKO_VELOCITY_MULTIPLIER;
}

View File

@ -53,7 +53,11 @@ namespace osu.Game.Tests.Visual.Settings
};
[SettingSource("Sample string", "Change something for a mod")]
public Bindable<string> StringBindable { get; } = new Bindable<string>();
public Bindable<string> StringBindable { get; } = new Bindable<string>
{
Default = string.Empty,
Value = "Sample text"
};
}
private enum TestEnum

View File

@ -36,9 +36,9 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep(@"Add DoubleTime", () => changeMods(doubleTimeMod));
AddAssert(@"Check DoubleTime multiplier", () => assertModsMultiplier(doubleTimeMod));
var mutlipleIncrementMods = new Mod[] { new OsuModDoubleTime(), new OsuModHidden(), new OsuModHardRock() };
AddStep(@"Add multiple Mods", () => changeMods(mutlipleIncrementMods));
AddAssert(@"Check multiple mod multiplier", () => assertModsMultiplier(mutlipleIncrementMods));
var multipleIncrementMods = new Mod[] { new OsuModDoubleTime(), new OsuModHidden(), new OsuModHardRock() };
AddStep(@"Add multiple Mods", () => changeMods(multipleIncrementMods));
AddAssert(@"Check multiple mod multiplier", () => assertModsMultiplier(multipleIncrementMods));
}
[Test]

View File

@ -26,7 +26,7 @@ namespace osu.Game.Tournament.Components
public DateTextBox()
{
base.Current = new Bindable<string>();
base.Current = new Bindable<string>(string.Empty);
((OsuTextBox)Control).OnCommit += (sender, newText) =>
{

View File

@ -10,7 +10,7 @@ namespace osu.Game.Tournament.Models
{
public List<SeedingBeatmap> Beatmaps = new List<SeedingBeatmap>();
public Bindable<string> Mod = new Bindable<string>();
public Bindable<string> Mod = new Bindable<string>(string.Empty);
public Bindable<int> Seed = new BindableInt
{

View File

@ -14,8 +14,8 @@ namespace osu.Game.Tournament.Models
[Serializable]
public class TournamentRound
{
public readonly Bindable<string> Name = new Bindable<string>();
public readonly Bindable<string> Description = new Bindable<string>();
public readonly Bindable<string> Name = new Bindable<string>(string.Empty);
public readonly Bindable<string> Description = new Bindable<string>(string.Empty);
public readonly BindableInt BestOf = new BindableInt(9) { Default = 9, MinValue = 3, MaxValue = 23 };

View File

@ -149,7 +149,7 @@ namespace osu.Game.Tournament.Screens.Editors
private readonly Bindable<int?> beatmapId = new Bindable<int?>();
private readonly Bindable<string> mods = new Bindable<string>();
private readonly Bindable<string> mods = new Bindable<string>(string.Empty);
private readonly Container drawableContainer;

View File

@ -149,7 +149,7 @@ namespace osu.Game.Tournament.Screens.Editors
private readonly Bindable<int?> beatmapId = new Bindable<int?>();
private readonly Bindable<string> score = new Bindable<string>();
private readonly Bindable<string> score = new Bindable<string>(string.Empty);
private readonly Container drawableContainer;

View File

@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private RealmContextFactory realmFactory { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OverlayColourProvider colourProvider)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
EdgeEffect = new EdgeEffectParameters
{
Radius = 2,
Colour = colours.YellowDark.Opacity(0),
Colour = colourProvider.Highlight1.Opacity(0),
Type = EdgeEffectType.Shadow,
Hollow = true,
},
@ -110,13 +110,12 @@ namespace osu.Game.Overlays.Settings.Sections.Input
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.6f,
Colour = colourProvider.Background5,
},
text = new OsuSpriteText
{
Text = action.GetLocalisableDescription(),
Margin = new MarginPadding(padding),
Margin = new MarginPadding(1.5f * padding),
},
buttons = new FillFlowContainer<KeyButton>
{
@ -405,7 +404,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private readonly Box box;
public readonly OsuSpriteText Text;
private Color4 hoverColour;
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
private bool isBinding;
@ -448,7 +448,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
box = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black
},
Text = new OsuSpriteText
{
@ -463,9 +462,9 @@ namespace osu.Game.Overlays.Settings.Sections.Input
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load()
{
hoverColour = colours.YellowDark;
updateHoverState();
}
protected override bool OnHover(HoverEvent e)
@ -484,12 +483,12 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
if (isBinding)
{
box.FadeColour(Color4.White, transition_time, Easing.OutQuint);
box.FadeColour(colourProvider.Light2, transition_time, Easing.OutQuint);
Text.FadeColour(Color4.Black, transition_time, Easing.OutQuint);
}
else
{
box.FadeColour(IsHovered ? hoverColour : Color4.Black, transition_time, Easing.OutQuint);
box.FadeColour(IsHovered ? colourProvider.Light4 : colourProvider.Background6, transition_time, Easing.OutQuint);
Text.FadeColour(IsHovered ? Color4.Black : Color4.White, transition_time, Easing.OutQuint);
}
}

View File

@ -27,8 +27,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
this.variant = variant;
FlowContent.Spacing = new Vector2(0, 1);
FlowContent.Padding = new MarginPadding { Left = SettingsPanel.CONTENT_MARGINS, Right = SettingsPanel.CONTENT_MARGINS };
FlowContent.Spacing = new Vector2(0, 3);
}
[BackgroundDependencyLoader]

View File

@ -165,7 +165,13 @@ namespace osu.Game.Overlays.Settings.Sections.Input
LabelText = TabletSettingsStrings.Rotation,
Current = rotation
},
new RotationPresetButtons(tabletHandler),
new RotationPresetButtons(tabletHandler)
{
Padding = new MarginPadding
{
Horizontal = SettingsPanel.CONTENT_MARGINS
}
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,

View File

@ -6,7 +6,6 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Game.Overlays.Settings.Sections.Maintenance;
using osuTK;
namespace osu.Game.Overlays.Settings.Sections
{
@ -21,7 +20,6 @@ namespace osu.Game.Overlays.Settings.Sections
public MaintenanceSection()
{
FlowContent.Spacing = new Vector2(0, 5);
Children = new Drawable[]
{
new GeneralSettings()

View File

@ -16,7 +16,6 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Skinning;
using osu.Game.Skinning.Editor;
using osuTK;
namespace osu.Game.Overlays.Settings.Sections
{
@ -63,8 +62,6 @@ namespace osu.Game.Overlays.Settings.Sections
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuConfigManager config, [CanBeNull] SkinEditorOverlay skinEditor)
{
FlowContent.Spacing = new Vector2(0, 5);
Children = new Drawable[]
{
skinDropdown = new SkinSettingsDropdown(),

View File

@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Settings
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OverlayColourProvider colourProvider)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Settings
new OsuSpriteText
{
Text = heading,
Font = OsuFont.GetFont(size: 40),
Font = OsuFont.TorusAlternate.With(size: 40),
Margin = new MarginPadding
{
Left = SettingsPanel.CONTENT_MARGINS,
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Settings
},
new OsuSpriteText
{
Colour = colours.Pink,
Colour = colourProvider.Content2,
Text = subheading,
Font = OsuFont.GetFont(size: 18),
Margin = new MarginPadding

View File

@ -12,7 +12,7 @@ using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK.Graphics;
using osuTK;
namespace osu.Game.Overlays.Settings
{
@ -31,9 +31,10 @@ namespace osu.Game.Overlays.Settings
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
public virtual IEnumerable<string> FilterTerms => new[] { Header.ToString() };
private const int header_size = 26;
private const int margin = 20;
private const int border_size = 2;
public const int ITEM_SPACING = 14;
private const int header_size = 24;
private const int border_size = 4;
public bool MatchingFilter
{
@ -54,8 +55,9 @@ namespace osu.Game.Overlays.Settings
{
Margin = new MarginPadding
{
Top = header_size
Top = 36
},
Spacing = new Vector2(0, ITEM_SPACING),
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
@ -63,14 +65,14 @@ namespace osu.Game.Overlays.Settings
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OverlayColourProvider colourProvider, OsuColour colours)
{
AddRangeInternal(new Drawable[]
{
new Box
{
Name = "separator",
Colour = new Color4(0, 0, 0, 255),
Colour = colourProvider.Background6,
RelativeSizeAxes = Axes.X,
Height = border_size,
},
@ -78,8 +80,8 @@ namespace osu.Game.Overlays.Settings
{
Padding = new MarginPadding
{
Top = margin + border_size,
Bottom = margin + 10,
Top = 28,
Bottom = 40,
},
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@ -87,13 +89,11 @@ namespace osu.Game.Overlays.Settings
{
header = new OsuSpriteText
{
Font = OsuFont.GetFont(size: header_size),
Font = OsuFont.TorusAlternate.With(size: header_size),
Text = Header,
Colour = colours.Yellow,
Margin = new MarginPadding
{
Left = SettingsPanel.CONTENT_MARGINS,
Right = SettingsPanel.CONTENT_MARGINS
Horizontal = SettingsPanel.CONTENT_MARGINS
}
},
FlowContent

View File

@ -46,13 +46,17 @@ namespace osu.Game.Overlays.Settings
FlowContent = new FillFlowContainer
{
Margin = new MarginPadding { Top = SettingsSection.ITEM_SPACING },
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 8),
Spacing = new Vector2(0, SettingsSection.ITEM_SPACING),
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
};
}
private const int header_height = 43;
private const int header_font_size = 20;
[BackgroundDependencyLoader]
private void load()
{
@ -60,9 +64,9 @@ namespace osu.Game.Overlays.Settings
{
new OsuSpriteText
{
Text = Header.ToString().ToUpper(), // TODO: Add localisation support after https://github.com/ppy/osu-framework/pull/4603 is merged.
Margin = new MarginPadding { Vertical = 30, Left = SettingsPanel.CONTENT_MARGINS, Right = SettingsPanel.CONTENT_MARGINS },
Font = OsuFont.GetFont(weight: FontWeight.Bold),
Text = Header,
Margin = new MarginPadding { Vertical = (header_height - header_font_size) * 0.5f, Horizontal = SettingsPanel.CONTENT_MARGINS },
Font = OsuFont.GetFont(size: header_font_size),
},
FlowContent
});

View File

@ -1,6 +1,8 @@
// 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 System;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
namespace osu.Game.Overlays.Settings
@ -13,5 +15,17 @@ namespace osu.Game.Overlays.Settings
RelativeSizeAxes = Axes.X,
CommitOnFocusLost = true
};
public override Bindable<string> Current
{
get => base.Current;
set
{
if (value.Default == null)
throw new InvalidOperationException($"Bindable settings of type {nameof(Bindable<string>)} should have a non-null default value.");
base.Current = value;
}
}
}
}

View File

@ -4,6 +4,7 @@
using System;
using System.Linq;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -15,22 +16,23 @@ using osuTK;
namespace osu.Game.Overlays.Settings
{
public class Sidebar : Container<SidebarButton>, IStateful<ExpandedState>
public class Sidebar : Container<SidebarIconButton>, IStateful<ExpandedState>
{
private readonly FillFlowContainer<SidebarButton> content;
public const float DEFAULT_WIDTH = Toolbar.Toolbar.HEIGHT * 1.4f;
private readonly Box background;
private readonly FillFlowContainer<SidebarIconButton> content;
public const float DEFAULT_WIDTH = 70;
public const int EXPANDED_WIDTH = 200;
public event Action<ExpandedState> StateChanged;
protected override Container<SidebarButton> Content => content;
protected override Container<SidebarIconButton> Content => content;
public Sidebar()
{
RelativeSizeAxes = Axes.Y;
InternalChildren = new Drawable[]
{
new Box
background = new Box
{
Colour = OsuColour.Gray(0.02f),
RelativeSizeAxes = Axes.Both,
@ -39,7 +41,7 @@ namespace osu.Game.Overlays.Settings
{
Children = new[]
{
content = new FillFlowContainer<SidebarButton>
content = new FillFlowContainer<SidebarIconButton>
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
@ -52,6 +54,12 @@ namespace osu.Game.Overlays.Settings
};
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
background.Colour = colourProvider.Background5;
}
private ScheduledDelegate expandEvent;
private ExpandedState state;
@ -80,8 +88,6 @@ namespace osu.Game.Overlays.Settings
{
public SidebarScrollContainer()
{
Content.Anchor = Anchor.CentreLeft;
Content.Origin = Anchor.CentreLeft;
RelativeSizeAxes = Axes.Both;
ScrollbarVisible = false;
}

View File

@ -1,110 +1,40 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// 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 osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.Settings
{
public class SidebarButton : OsuButton
public abstract class SidebarButton : OsuButton
{
private readonly ConstrainedIconContainer iconContainer;
private readonly SpriteText headerText;
private readonly Box selectionIndicator;
private readonly Container text;
protected const double FADE_DURATION = 500;
// always consider as part of flow, even when not visible (for the sake of the initial animation).
public override bool IsPresent => true;
private SettingsSection section;
public SettingsSection Section
{
get => section;
set
{
section = value;
headerText.Text = value.Header;
iconContainer.Icon = value.CreateIcon();
}
}
private bool selected;
public bool Selected
{
get => selected;
set
{
selected = value;
if (selected)
{
selectionIndicator.FadeIn(50);
text.FadeColour(Color4.White, 50);
}
else
{
selectionIndicator.FadeOut(50);
text.FadeColour(OsuColour.Gray(0.6f), 50);
}
}
}
public SidebarButton()
{
Height = Sidebar.DEFAULT_WIDTH;
RelativeSizeAxes = Axes.X;
BackgroundColour = Color4.Black;
AddRange(new Drawable[]
{
text = new Container
{
Width = Sidebar.DEFAULT_WIDTH,
RelativeSizeAxes = Axes.Y,
Colour = OsuColour.Gray(0.6f),
Children = new Drawable[]
{
headerText = new OsuSpriteText
{
Position = new Vector2(Sidebar.DEFAULT_WIDTH + 10, 0),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
iconContainer = new ConstrainedIconContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(20),
},
}
},
selectionIndicator = new Box
{
Alpha = 0,
RelativeSizeAxes = Axes.Y,
Width = 5,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
},
});
}
[Resolved]
protected OverlayColourProvider ColourProvider { get; private set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load()
{
selectionIndicator.Colour = colours.Yellow;
BackgroundColour = ColourProvider.Background5;
}
protected override void LoadComplete()
{
base.LoadComplete();
UpdateState();
FinishTransforms(true);
}
protected override bool OnHover(HoverEvent e)
{
UpdateState();
return false;
}
protected override void OnHoverLost(HoverLostEvent e) => UpdateState();
protected abstract void UpdateState();
}
}

View File

@ -0,0 +1,130 @@
// 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 osuTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.Settings
{
public class SidebarIconButton : SidebarButton
{
private const float selection_indicator_height_active = 18;
private const float selection_indicator_height_inactive = 4;
private readonly ConstrainedIconContainer iconContainer;
private readonly SpriteText headerText;
private readonly CircularContainer selectionIndicator;
private readonly Container textIconContent;
// always consider as part of flow, even when not visible (for the sake of the initial animation).
public override bool IsPresent => true;
private SettingsSection section;
public SettingsSection Section
{
get => section;
set
{
section = value;
headerText.Text = value.Header;
iconContainer.Icon = value.CreateIcon();
}
}
private bool selected;
public bool Selected
{
get => selected;
set
{
selected = value;
if (IsLoaded)
UpdateState();
}
}
public SidebarIconButton()
{
RelativeSizeAxes = Axes.X;
Height = 46;
AddRange(new Drawable[]
{
textIconContent = new Container
{
Width = Sidebar.DEFAULT_WIDTH,
RelativeSizeAxes = Axes.Y,
Colour = OsuColour.Gray(0.6f),
Children = new Drawable[]
{
headerText = new OsuSpriteText
{
Position = new Vector2(Sidebar.DEFAULT_WIDTH + 10, 0),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
iconContainer = new ConstrainedIconContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(20),
},
}
},
selectionIndicator = new CircularContainer
{
Alpha = 0,
Width = 4,
Height = selection_indicator_height_inactive,
Masking = true,
CornerRadius = 1.5f,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding
{
Left = 9,
},
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Colour4.White
}
},
});
}
[BackgroundDependencyLoader]
private void load()
{
selectionIndicator.Colour = ColourProvider.Highlight1;
}
protected override void UpdateState()
{
if (Selected)
{
textIconContent.FadeColour(ColourProvider.Content1, FADE_DURATION, Easing.OutQuint);
selectionIndicator.FadeIn(FADE_DURATION, Easing.OutQuint);
selectionIndicator.ResizeHeightTo(selection_indicator_height_active, FADE_DURATION, Easing.OutElasticHalf);
}
else
{
textIconContent.FadeColour(IsHovered ? ColourProvider.Light1 : ColourProvider.Light3, FADE_DURATION, Easing.OutQuint);
selectionIndicator.FadeOut(FADE_DURATION, Easing.OutQuint);
selectionIndicator.ResizeHeightTo(selection_indicator_height_inactive, FADE_DURATION, Easing.OutQuint);
}
}
}
}

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
@ -15,7 +14,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
@ -25,7 +23,7 @@ namespace osu.Game.Overlays
[Cached]
public abstract class SettingsPanel : OsuFocusedOverlayContainer
{
public const float CONTENT_MARGINS = 15;
public const float CONTENT_MARGINS = 20;
public const float TRANSITION_LENGTH = 600;
@ -46,7 +44,7 @@ namespace osu.Game.Overlays
protected override Container<Drawable> Content => ContentContainer;
protected Sidebar Sidebar;
private SidebarButton selectedSidebarButton;
private SidebarIconButton selectedSidebarButton;
public SettingsSectionsContainer SectionsContainer { get; private set; }
@ -64,6 +62,9 @@ namespace osu.Game.Overlays
public IBindable<SettingsSection> CurrentSection = new Bindable<SettingsSection>();
[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
protected SettingsPanel(bool showSidebar)
{
this.showSidebar = showSidebar;
@ -89,7 +90,7 @@ namespace osu.Game.Overlays
Origin = Anchor.TopRight,
Scale = new Vector2(2, 1), // over-extend to the left for transitions
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.05f),
Colour = colourProvider.Background4,
Alpha = 1,
},
loading = new LoadingLayer
@ -105,17 +106,23 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
ExpandableHeader = CreateHeader(),
SelectedSection = { BindTarget = CurrentSection },
FixedHeader = searchTextBox = new SeekLimitedSearchTextBox
FixedHeader = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding
{
Vertical = 20,
Horizontal = CONTENT_MARGINS
},
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Child = searchTextBox = new SeekLimitedSearchTextBox
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Width = 0.95f,
Margin = new MarginPadding
{
Top = 20,
Bottom = 20
},
}
},
Footer = CreateFooter().With(f => f.Alpha = 0)
});
@ -245,11 +252,11 @@ namespace osu.Game.Overlays
});
}
private IEnumerable<SidebarButton> createSidebarButtons()
private IEnumerable<SidebarIconButton> createSidebarButtons()
{
foreach (var section in SectionsContainer)
{
yield return new SidebarButton
yield return new SidebarIconButton
{
Section = section,
Action = () =>
@ -292,11 +299,12 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical,
};
public SettingsSectionsContainer()
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
HeaderBackground = new Box
{
Colour = Color4.Black,
Colour = colourProvider.Background4,
RelativeSizeAxes = Axes.Both
};
}

View File

@ -7,10 +7,8 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
@ -34,18 +32,18 @@ namespace osu.Game.Overlays
protected override bool DimMainContent => false; // dimming is handled by main overlay
private class BackButton : OsuButton
private class BackButton : SidebarButton
{
private Container content;
[BackgroundDependencyLoader]
private void load()
{
Size = new Vector2(Sidebar.DEFAULT_WIDTH);
BackgroundColour = Color4.Black;
AddRange(new Drawable[]
{
new Container
content = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -71,6 +69,11 @@ namespace osu.Game.Overlays
}
});
}
protected override void UpdateState()
{
content.FadeColour(IsHovered ? ColourProvider.Light1 : ColourProvider.Light3, FADE_DURATION, Easing.OutQuint);
}
}
}
}

View File

@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Difficulty.Skills
/// <summary>
/// The current strain level.
/// </summary>
protected double CurrentStrain { get; private set; } = 1;
protected double CurrentStrain { get; private set; }
protected StrainDecaySkill(Mod[] mods)
: base(mods)

View File

@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Difficulty.Skills
/// </summary>
protected virtual int SectionLength => 400;
private double currentSectionPeak = 1; // We also keep track of the peak strain level in the current section.
private double currentSectionPeak; // We also keep track of the peak strain level in the current section.
private double currentSectionEnd;