1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 18:32:55 +08:00

Merge branch 'master' into import-task-improve

This commit is contained in:
Bartłomiej Dach 2023-09-14 19:37:01 +02:00
commit 9b391cd661
No known key found for this signature in database
24 changed files with 424 additions and 538 deletions

View File

@ -10,7 +10,7 @@
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.904.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.914.0" />
</ItemGroup>
<PropertyGroup>
<!-- Fody does not handle Android build well, and warns when unchanged.

View File

@ -286,7 +286,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
if (time - part.Time >= 1)
continue;
vertexBatch.Add(new TexturedTrailVertex(renderer)
vertexBatch.Add(new TexturedTrailVertex
{
Position = new Vector2(part.Position.X - size.X * originPosition.X, part.Position.Y + size.Y * (1 - originPosition.Y)),
TexturePosition = textureRect.BottomLeft,
@ -295,7 +295,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
Time = part.Time
});
vertexBatch.Add(new TexturedTrailVertex(renderer)
vertexBatch.Add(new TexturedTrailVertex
{
Position = new Vector2(part.Position.X + size.X * (1 - originPosition.X), part.Position.Y + size.Y * (1 - originPosition.Y)),
TexturePosition = textureRect.BottomRight,
@ -304,7 +304,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
Time = part.Time
});
vertexBatch.Add(new TexturedTrailVertex(renderer)
vertexBatch.Add(new TexturedTrailVertex
{
Position = new Vector2(part.Position.X + size.X * (1 - originPosition.X), part.Position.Y - size.Y * originPosition.Y),
TexturePosition = textureRect.TopRight,
@ -313,7 +313,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
Time = part.Time
});
vertexBatch.Add(new TexturedTrailVertex(renderer)
vertexBatch.Add(new TexturedTrailVertex
{
Position = new Vector2(part.Position.X - size.X * originPosition.X, part.Position.Y - size.Y * originPosition.Y),
TexturePosition = textureRect.TopLeft,
@ -362,22 +362,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
[VertexMember(1, VertexAttribPointerType.Float)]
public float Time;
[VertexMember(1, VertexAttribPointerType.Int)]
private readonly int maskingIndex;
public TexturedTrailVertex(IRenderer renderer)
{
this = default;
maskingIndex = renderer.CurrentMaskingIndex;
}
public bool Equals(TexturedTrailVertex other)
{
return Position.Equals(other.Position)
&& TexturePosition.Equals(other.TexturePosition)
&& Colour.Equals(other.Colour)
&& Time.Equals(other.Time)
&& maskingIndex == other.maskingIndex;
&& Time.Equals(other.Time);
}
}
}

View File

@ -13,7 +13,7 @@ layout(location = 4) out mediump vec2 v_BlendRange;
void main(void)
{
// Transform from screen space to masking space.
highp vec3 maskingPos = g_MaskingInfo.ToMaskingSpace * vec3(m_Position, 1.0);
highp vec3 maskingPos = g_ToMaskingSpace * vec3(m_Position, 1.0);
v_MaskingPosition = maskingPos.xy / maskingPos.z;
v_Colour = m_Colour;

View File

@ -115,7 +115,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("mod multiplier correct", () =>
{
double multiplier = SelectedMods.Value.Aggregate(1d, (m, mod) => m * mod.ScoreMultiplier);
return Precision.AlmostEquals(multiplier, modSelectOverlay.ChildrenOfType<DifficultyMultiplierDisplay>().Single().Current.Value);
return Precision.AlmostEquals(multiplier, modSelectOverlay.ChildrenOfType<ScoreMultiplierDisplay>().Single().Current.Value);
});
assertCustomisationToggleState(disabled: false, active: false);
AddAssert("setting items created", () => modSelectOverlay.ChildrenOfType<ISettingsItem>().Any());
@ -130,7 +130,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("mod multiplier correct", () =>
{
double multiplier = SelectedMods.Value.Aggregate(1d, (m, mod) => m * mod.ScoreMultiplier);
return Precision.AlmostEquals(multiplier, modSelectOverlay.ChildrenOfType<DifficultyMultiplierDisplay>().Single().Current.Value);
return Precision.AlmostEquals(multiplier, modSelectOverlay.ChildrenOfType<ScoreMultiplierDisplay>().Single().Current.Value);
});
assertCustomisationToggleState(disabled: false, active: false);
AddAssert("setting items created", () => modSelectOverlay.ChildrenOfType<ISettingsItem>().Any());
@ -787,7 +787,7 @@ namespace osu.Game.Tests.Visual.UserInterface
InputManager.MoveMouseTo(this.ChildrenOfType<ModPresetPanel>().Single(preset => preset.Preset.Value.Name == "Half Time 0.5x"));
InputManager.Click(MouseButton.Left);
});
AddAssert("difficulty multiplier display shows correct value", () => modSelectOverlay.ChildrenOfType<DifficultyMultiplierDisplay>().Single().Current.Value, () => Is.EqualTo(0.5));
AddAssert("difficulty multiplier display shows correct value", () => modSelectOverlay.ChildrenOfType<ScoreMultiplierDisplay>().Single().Current.Value, () => Is.EqualTo(0.5));
// this is highly unorthodox in a test, but because the `ModSettingChangeTracker` machinery heavily leans on events and object disposal and re-creation,
// it is instrumental in the reproduction of the failure scenario that this test is supposed to cover.
@ -796,7 +796,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("open customisation area", () => modSelectOverlay.CustomisationButton!.TriggerClick());
AddStep("reset half time speed to default", () => modSelectOverlay.ChildrenOfType<ModSettingsArea>().Single()
.ChildrenOfType<RevertToDefaultButton<double>>().Single().TriggerClick());
AddUntilStep("difficulty multiplier display shows correct value", () => modSelectOverlay.ChildrenOfType<DifficultyMultiplierDisplay>().Single().Current.Value, () => Is.EqualTo(0.7));
AddUntilStep("difficulty multiplier display shows correct value", () => modSelectOverlay.ChildrenOfType<ScoreMultiplierDisplay>().Single().Current.Value, () => Is.EqualTo(0.7));
}
private void waitForColumnLoad() => AddUntilStep("all column content loaded",

View File

@ -1,68 +0,0 @@
// 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.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Framework.Testing;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets.Mods;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.UserInterface
{
[TestFixture]
public partial class TestSceneModsEffectDisplay : OsuTestScene
{
[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
[Resolved]
private OsuColour colours { get; set; } = null!;
[Test]
public void TestModsEffectDisplay()
{
TestDisplay testDisplay = null!;
Box background = null!;
AddStep("add display", () =>
{
Add(testDisplay = new TestDisplay
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
var boxes = testDisplay.ChildrenOfType<Box>();
background = boxes.First();
});
AddStep("set value to default", () => testDisplay.Current.Value = 50);
AddUntilStep("colours are correct", () => testDisplay.Container.Colour == Color4.White && background.Colour == colourProvider.Background3);
AddStep("set value to less", () => testDisplay.Current.Value = 40);
AddUntilStep("colours are correct", () => testDisplay.Container.Colour == colourProvider.Background5 && background.Colour == colours.ForModType(ModType.DifficultyReduction));
AddStep("set value to bigger", () => testDisplay.Current.Value = 60);
AddUntilStep("colours are correct", () => testDisplay.Container.Colour == colourProvider.Background5 && background.Colour == colours.ForModType(ModType.DifficultyIncrease));
}
private partial class TestDisplay : ModCounterDisplay
{
public Container<Drawable> Container => Content;
protected override LocalisableString Label => "Test display";
public TestDisplay()
{
Current.Default = 50;
}
}
}
}

View File

@ -1,10 +1,9 @@
// 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.
#nullable disable
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
@ -12,17 +11,17 @@ using osu.Game.Overlays.Mods;
namespace osu.Game.Tests.Visual.UserInterface
{
[TestFixture]
public partial class TestSceneDifficultyMultiplierDisplay : OsuTestScene
public partial class TestSceneScoreMultiplierDisplay : OsuTestScene
{
[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
[Test]
public void TestDifficultyMultiplierDisplay()
public void TestBasic()
{
DifficultyMultiplierDisplay multiplierDisplay = null;
ScoreMultiplierDisplay multiplierDisplay = null!;
AddStep("create content", () => Child = multiplierDisplay = new DifficultyMultiplierDisplay
AddStep("create content", () => Child = multiplierDisplay = new ScoreMultiplierDisplay
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
@ -34,7 +33,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddSliderStep("set multiplier", 0, 2, 1d, multiplier =>
{
if (multiplierDisplay != null)
if (multiplierDisplay.IsNotNull())
multiplierDisplay.Current.Value = multiplier;
});
}

View File

@ -1,19 +0,0 @@
// 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.Localisation;
namespace osu.Game.Localisation
{
public static class DifficultyMultiplierDisplayStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.DifficultyMultiplierDisplay";
/// <summary>
/// "Difficulty Multiplier"
/// </summary>
public static LocalisableString DifficultyMultiplier => new TranslatableString(getKey(@"difficulty_multiplier"), @"Difficulty Multiplier");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -44,6 +44,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString TabToSearch => new TranslatableString(getKey(@"tab_to_search"), @"tab to search...");
/// <summary>
/// "Score Multiplier"
/// </summary>
public static LocalisableString ScoreMultiplier => new TranslatableString(getKey(@"score_multiplier"), @"Score Multiplier");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}
}

View File

@ -7,9 +7,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
@ -18,7 +15,6 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Mods;
using osuTK;
using osuTK.Graphics;
using System.Threading;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
@ -29,36 +25,24 @@ namespace osu.Game.Overlays.Mods
/// On the mod select overlay, this provides a local updating view of BPM, star rating and other
/// difficulty attributes so the user can have a better insight into what mods are changing.
/// </summary>
public partial class BeatmapAttributesDisplay : CompositeDrawable
public partial class BeatmapAttributesDisplay : ModFooterInformationDisplay
{
private Container content = null!;
private Container innerContent = null!;
private Box background = null!;
private Box innerBackground = null!;
private StarRatingDisplay starRatingDisplay = null!;
private BPMDisplay bpmDisplay = null!;
private FillFlowContainer<VerticalAttributeDisplay> outerContent = null!;
private VerticalAttributeDisplay circleSizeDisplay = null!;
private VerticalAttributeDisplay drainRateDisplay = null!;
private VerticalAttributeDisplay approachRateDisplay = null!;
private VerticalAttributeDisplay overallDifficultyDisplay = null!;
private const float transition_duration = 250;
public Bindable<IBeatmapInfo?> BeatmapInfo { get; } = new Bindable<IBeatmapInfo?>();
public BindableBool Collapsed { get; } = new BindableBool(true);
[Resolved]
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
private ModSettingChangeTracker? modSettingChangeTracker;
public BindableBool Collapsed { get; } = new BindableBool(true);
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
private ModSettingChangeTracker? modSettingChangeTracker;
[Resolved]
private BeatmapDifficultyCache difficultyCache { get; set; } = null!;
@ -66,117 +50,44 @@ namespace osu.Game.Overlays.Mods
private CancellationTokenSource? cancellationSource;
private IBindable<StarDifficulty?> starDifficulty = null!;
private const float transition_duration = 250;
[BackgroundDependencyLoader]
private void load()
{
const float shear = ShearedOverlayContainer.SHEAR;
AutoSizeAxes = Axes.Both;
InternalChild = content = new Container
LeftContent.AddRange(new Drawable[]
{
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
AutoSizeAxes = Axes.X,
Height = ShearedButton.HEIGHT,
Shear = new Vector2(shear, 0),
CornerRadius = ShearedButton.CORNER_RADIUS,
BorderThickness = ShearedButton.BORDER_THICKNESS,
Masking = true,
Children = new Drawable[]
starRatingDisplay = new StarRatingDisplay(default, animated: true)
{
background = new Box
{
RelativeSizeAxes = Axes.Both
},
new FillFlowContainer // divide inner and outer content
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
innerContent = new Container
{
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
BorderThickness = ShearedButton.BORDER_THICKNESS,
CornerRadius = ShearedButton.CORNER_RADIUS,
Masking = true,
Children = new Drawable[]
{
innerBackground = new Box
{
RelativeSizeAxes = Axes.Both
},
new Container // actual inner content
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Width = 140,
RelativeSizeAxes = Axes.Y,
Margin = new MarginPadding { Horizontal = 15 },
Children = new Drawable[]
{
starRatingDisplay = new StarRatingDisplay(default, animated: true)
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Shear = new Vector2(-shear, 0),
},
bpmDisplay = new BPMDisplay
{
Origin = Anchor.CentreRight,
Anchor = Anchor.CentreRight,
Shear = new Vector2(-shear, 0),
}
}
}
}
},
outerContent = new FillFlowContainer<VerticalAttributeDisplay>
{
Alpha = 0,
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Children = new[]
{
circleSizeDisplay = new VerticalAttributeDisplay("CS")
{
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
},
drainRateDisplay = new VerticalAttributeDisplay("HP")
{
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
},
approachRateDisplay = new VerticalAttributeDisplay("AR")
{
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
},
overallDifficultyDisplay = new VerticalAttributeDisplay("OD")
{
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
},
}
}
}
}
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Shear = new Vector2(-shear, 0),
},
bpmDisplay = new BPMDisplay
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Shear = new Vector2(-shear, 0),
AutoSizeAxes = Axes.Y,
Width = 75,
}
};
});
RightContent.Alpha = 0;
RightContent.AddRange(new Drawable[]
{
circleSizeDisplay = new VerticalAttributeDisplay("CS") { Shear = new Vector2(-shear, 0), },
drainRateDisplay = new VerticalAttributeDisplay("HP") { Shear = new Vector2(-shear, 0), },
approachRateDisplay = new VerticalAttributeDisplay("AR") { Shear = new Vector2(-shear, 0), },
overallDifficultyDisplay = new VerticalAttributeDisplay("OD") { Shear = new Vector2(-shear, 0), },
});
}
protected override void LoadComplete()
{
background.Colour = colourProvider.Background4;
innerBackground.Colour = colourProvider.Background3;
Color4 glowColour = colourProvider.Background1;
content.BorderColour = ColourInfo.GradientVertical(background.Colour, glowColour);
innerContent.BorderColour = ColourInfo.GradientVertical(innerBackground.Colour, glowColour);
base.LoadComplete();
mods.BindValueChanged(_ =>
{
@ -187,15 +98,16 @@ namespace osu.Game.Overlays.Mods
updateValues();
}, true);
BeatmapInfo.BindValueChanged(_ => updateValues(), true);
Collapsed.BindValueChanged(_ =>
{
// Only start autosize animations on first collapse toggle. This avoids an ugly initial presentation.
startAnimating();
updateCollapsedState();
});
BeatmapInfo.BindValueChanged(_ => updateValues(), true);
updateCollapsedState();
}
protected override bool OnHover(HoverEvent e)
@ -217,8 +129,13 @@ namespace osu.Game.Overlays.Mods
private void startAnimating()
{
content.AutoSizeEasing = Easing.OutQuint;
content.AutoSizeDuration = transition_duration;
Content.AutoSizeEasing = Easing.OutQuint;
Content.AutoSizeDuration = transition_duration;
}
private void updateCollapsedState()
{
RightContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint);
}
private void updateValues() => Scheduler.AddOnce(() =>
@ -253,11 +170,6 @@ namespace osu.Game.Overlays.Mods
overallDifficultyDisplay.Current.Value = adjustedDifficulty.OverallDifficulty;
});
private void updateCollapsedState()
{
outerContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint);
}
private partial class BPMDisplay : RollingCounter<double>
{
protected override double RollingDuration => 500;
@ -266,6 +178,8 @@ namespace osu.Game.Overlays.Mods
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Font = OsuFont.Default.With(size: 20, weight: FontWeight.SemiBold),
UseFullGlyphHeight = false,
};

View File

@ -1,41 +0,0 @@
// 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.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osuTK;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Mods
{
public sealed partial class DifficultyMultiplierDisplay : ModCounterDisplay
{
protected override LocalisableString Label => DifficultyMultiplierDisplayStrings.DifficultyMultiplier;
protected override string CounterFormat => @"N2";
public DifficultyMultiplierDisplay()
{
Current.Default = 1d;
Current.Value = 1d;
Add(new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Icon = FontAwesome.Solid.Times,
Size = new Vector2(7),
Margin = new MarginPadding { Top = 1 }
});
}
protected override void LoadComplete()
{
base.LoadComplete();
// required to prevent the counter initially rolling up from 0 to 1
// due to `Current.Value` having a nonstandard default value of 1.
Counter.SetCountWithoutRolling(Current.Value);
}
}
}

View File

@ -1,223 +0,0 @@
// 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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Mods;
using osuTK;
namespace osu.Game.Overlays.Mods
{
/// <summary>
/// Base class for displays of singular counters. Not to be confused with <see cref="BeatmapAttributesDisplay"/> which aggregates multiple attributes.
/// </summary>
public abstract partial class ModCounterDisplay : Container, IHasCurrentValue<double>
{
public const float HEIGHT = 42;
private const float transition_duration = 200;
private readonly Box contentBackground;
private readonly Box labelBackground;
private readonly FillFlowContainer content;
public Bindable<double> Current
{
get => current.Current;
set => current.Current = value;
}
private readonly BindableWithCurrent<double> current = new BindableWithCurrent<double>();
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
/// <summary>
/// Text to display in the left area of the display.
/// </summary>
protected abstract LocalisableString Label { get; }
protected virtual float ValueAreaWidth => 56;
protected virtual string CounterFormat => @"N0";
protected override Container<Drawable> Content => content;
protected readonly RollingCounter<double> Counter;
protected ModCounterDisplay()
{
Height = HEIGHT;
AutoSizeAxes = Axes.X;
InternalChild = new InputBlockingContainer
{
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Masking = true,
CornerRadius = ModSelectPanel.CORNER_RADIUS,
Shear = new Vector2(ShearedOverlayContainer.SHEAR, 0),
Children = new Drawable[]
{
contentBackground = new Box
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
RelativeSizeAxes = Axes.Y,
Width = ValueAreaWidth + ModSelectPanel.CORNER_RADIUS
},
new GridContainer
{
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.Absolute, ValueAreaWidth)
},
Content = new[]
{
new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Masking = true,
CornerRadius = ModSelectPanel.CORNER_RADIUS,
Children = new Drawable[]
{
labelBackground = new Box
{
RelativeSizeAxes = Axes.Both
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding { Horizontal = 18 },
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
Text = Label,
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
}
}
},
content = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
Spacing = new Vector2(2, 0),
Child = Counter = new EffectCounter(CounterFormat)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Current = { BindTarget = Current }
}
}
}
}
}
}
};
}
[BackgroundDependencyLoader]
private void load()
{
labelBackground.Colour = colourProvider.Background4;
}
protected override void LoadComplete()
{
Current.BindValueChanged(e =>
{
var effect = CalculateEffectForComparison(e.NewValue.CompareTo(Current.Default));
setColours(effect);
}, true);
}
/// <summary>
/// Fades colours of text and its background according to displayed value.
/// </summary>
/// <param name="effect">Effect of the value.</param>
private void setColours(ModEffect effect)
{
switch (effect)
{
case ModEffect.NotChanged:
contentBackground.FadeColour(colourProvider.Background3, transition_duration, Easing.OutQuint);
content.FadeColour(Colour4.White, transition_duration, Easing.OutQuint);
break;
case ModEffect.DifficultyReduction:
contentBackground.FadeColour(colours.ForModType(ModType.DifficultyReduction), transition_duration, Easing.OutQuint);
content.FadeColour(colourProvider.Background5, transition_duration, Easing.OutQuint);
break;
case ModEffect.DifficultyIncrease:
contentBackground.FadeColour(colours.ForModType(ModType.DifficultyIncrease), transition_duration, Easing.OutQuint);
content.FadeColour(colourProvider.Background5, transition_duration, Easing.OutQuint);
break;
default:
throw new ArgumentOutOfRangeException(nameof(effect));
}
}
/// <summary>
/// Converts signed integer into <see cref="ModEffect"/>. Negative values are counted as difficulty reduction, positive as increase.
/// </summary>
/// <param name="comparison">Value to convert. Will arrive from comparison between <see cref="Current"/> bindable once it changes and it's <see cref="Bindable{T}.Default"/>.</param>
/// <returns>Effect of the value.</returns>
protected virtual ModEffect CalculateEffectForComparison(int comparison)
{
if (comparison == 0)
return ModEffect.NotChanged;
if (comparison < 0)
return ModEffect.DifficultyReduction;
return ModEffect.DifficultyIncrease;
}
protected enum ModEffect
{
NotChanged,
DifficultyReduction,
DifficultyIncrease
}
private partial class EffectCounter : RollingCounter<double>
{
private readonly string? format;
public EffectCounter(string? format)
{
this.format = format;
}
protected override double RollingDuration => 500;
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(format);
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
{
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
};
}
}
}

View File

@ -0,0 +1,109 @@
// 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.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.UserInterface;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.Mods
{
public abstract partial class ModFooterInformationDisplay : CompositeDrawable
{
protected FillFlowContainer LeftContent { get; private set; } = null!;
protected FillFlowContainer RightContent { get; private set; } = null!;
protected Container Content { get; private set; } = null!;
private Container innerContent = null!;
protected Box MainBackground { get; private set; } = null!;
protected Box FrontBackground { get; private set; } = null!;
[Resolved]
protected OverlayColourProvider ColourProvider { get; private set; } = null!;
[BackgroundDependencyLoader]
private void load()
{
AutoSizeAxes = Axes.Both;
InternalChild = Content = new Container
{
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
AutoSizeAxes = Axes.X,
Height = ShearedButton.HEIGHT,
Shear = new Vector2(ShearedOverlayContainer.SHEAR, 0),
CornerRadius = ShearedButton.CORNER_RADIUS,
BorderThickness = ShearedButton.BORDER_THICKNESS,
Masking = true,
Children = new Drawable[]
{
MainBackground = new Box
{
RelativeSizeAxes = Axes.Both
},
new FillFlowContainer // divide inner and outer content
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
innerContent = new Container
{
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
BorderThickness = ShearedButton.BORDER_THICKNESS,
CornerRadius = ShearedButton.CORNER_RADIUS,
Masking = true,
Children = new Drawable[]
{
FrontBackground = new Box
{
RelativeSizeAxes = Axes.Both
},
LeftContent = new FillFlowContainer // actual inner content
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Margin = new MarginPadding { Horizontal = 15 },
Spacing = new Vector2(10),
}
}
},
RightContent = new FillFlowContainer
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
}
}
}
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
MainBackground.Colour = ColourProvider.Background4;
FrontBackground.Colour = ColourProvider.Background3;
Color4 glowColour = ColourProvider.Background1;
Content.BorderColour = ColourInfo.GradientVertical(MainBackground.Colour, glowColour);
innerContent.BorderColour = ColourInfo.GradientVertical(FrontBackground.Colour, glowColour);
}
}
}

View File

@ -26,6 +26,8 @@ namespace osu.Game.Overlays.Mods
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
private const float contracted_width = WIDTH - 120;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@ -42,6 +44,8 @@ namespace osu.Game.Overlays.Mods
base.LoadComplete();
ruleset.BindValueChanged(_ => rulesetChanged(), true);
Width = contracted_width;
}
private IDisposable? presetSubscription;
@ -65,7 +69,11 @@ namespace osu.Game.Overlays.Mods
{
cancellationTokenSource?.Cancel();
if (!presets.Any())
bool hasPresets = presets.Any();
this.ResizeWidthTo(hasPresets ? WIDTH : contracted_width, 200, Easing.OutQuint);
if (!hasPresets)
{
removeAndDisposePresetPanels();
return;

View File

@ -61,9 +61,11 @@ namespace osu.Game.Overlays.Mods
private const float header_height = 42;
protected const float WIDTH = 320;
protected ModSelectColumn()
{
Width = 320;
Width = WIDTH;
RelativeSizeAxes = Axes.Y;
Shear = new Vector2(ShearedOverlayContainer.SHEAR, 0);

View File

@ -120,11 +120,12 @@ namespace osu.Game.Overlays.Mods
private ColumnScrollContainer columnScroll = null!;
private ColumnFlowContainer columnFlow = null!;
private FillFlowContainer<ShearedButton> footerButtonFlow = null!;
private FillFlowContainer footerContentFlow = null!;
private DeselectAllModsButton deselectAllModsButton = null!;
private Container aboveColumnsContent = null!;
private DifficultyMultiplierDisplay? multiplierDisplay;
private BeatmapAttributesDisplay? modEffectPreviewPanel;
private ScoreMultiplierDisplay? multiplierDisplay;
private BeatmapAttributesDisplay? beatmapAttributesDisplay;
protected ShearedButton BackButton { get; private set; } = null!;
protected ShearedToggleButton? CustomisationButton { get; private set; }
@ -142,8 +143,8 @@ namespace osu.Game.Overlays.Mods
if (beatmap == value) return;
beatmap = value;
if (IsLoaded && modEffectPreviewPanel != null)
modEffectPreviewPanel.BeatmapInfo.Value = beatmap?.BeatmapInfo;
if (IsLoaded && beatmapAttributesDisplay != null)
beatmapAttributesDisplay.BeatmapInfo.Value = beatmap?.BeatmapInfo;
}
}
@ -181,7 +182,7 @@ namespace osu.Game.Overlays.Mods
aboveColumnsContent = new Container
{
RelativeSizeAxes = Axes.X,
Height = ModCounterDisplay.HEIGHT,
Height = ScoreMultiplierDisplay.HEIGHT,
Padding = new MarginPadding { Horizontal = 100 },
Child = SearchTextBox = new ShearedSearchTextBox
{
@ -196,7 +197,7 @@ namespace osu.Game.Overlays.Mods
{
Padding = new MarginPadding
{
Top = ModCounterDisplay.HEIGHT + PADDING,
Top = ScoreMultiplierDisplay.HEIGHT + PADDING,
Bottom = PADDING
},
RelativeSizeAxes = Axes.Both,
@ -251,22 +252,32 @@ namespace osu.Game.Overlays.Mods
if (ShowModEffects)
{
aboveColumnsContent.Add(multiplierDisplay = new DifficultyMultiplierDisplay
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight
});
FooterContent.Add(modEffectPreviewPanel = new BeatmapAttributesDisplay
FooterContent.Add(footerContentFlow = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(30, 10),
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Margin = new MarginPadding
{
Vertical = PADDING,
Horizontal = 70
Horizontal = 20
},
BeatmapInfo = { Value = beatmap?.BeatmapInfo }
Children = new Drawable[]
{
multiplierDisplay = new ScoreMultiplierDisplay
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight
},
beatmapAttributesDisplay = new BeatmapAttributesDisplay
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
BeatmapInfo = { Value = beatmap?.BeatmapInfo }
},
}
});
}
@ -339,15 +350,23 @@ namespace osu.Game.Overlays.Mods
SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? Resources.Localisation.Web.CommonStrings.InputSearch : ModSelectOverlayStrings.TabToSearch;
// only update preview panel's collapsed state after we are fully visible, to ensure all the buttons are where we expect them to be.
if (modEffectPreviewPanel != null && Alpha == 1)
if (beatmapAttributesDisplay != null)
{
float rightEdgeOfLastButton = footerButtonFlow.Last().ScreenSpaceDrawQuad.TopRight.X;
// this is cheating a bit; the 375 value is hardcoded based on how wide the expanded panel _generally_ is.
// this is cheating a bit; the 640 value is hardcoded based on how wide the expanded panel _generally_ is.
// due to the transition applied, the raw screenspace quad of the panel cannot be used, as it will trigger an ugly feedback cycle of expanding and collapsing.
float projectedLeftEdgeOfExpandedModEffectPreviewPanel = footerButtonFlow.ToScreenSpace(footerButtonFlow.DrawSize - new Vector2(375 + 70, 0)).X;
modEffectPreviewPanel.Collapsed.Value = rightEdgeOfLastButton > projectedLeftEdgeOfExpandedModEffectPreviewPanel;
float projectedLeftEdgeOfExpandedBeatmapAttributesDisplay = footerButtonFlow.ToScreenSpace(footerButtonFlow.DrawSize - new Vector2(640, 0)).X;
bool screenIsntWideEnough = rightEdgeOfLastButton > projectedLeftEdgeOfExpandedBeatmapAttributesDisplay;
// only update preview panel's collapsed state after we are fully visible, to ensure all the buttons are where we expect them to be.
if (Alpha == 1)
beatmapAttributesDisplay.Collapsed.Value = screenIsntWideEnough;
footerContentFlow.LayoutDuration = 200;
footerContentFlow.LayoutEasing = Easing.OutQuint;
footerContentFlow.Direction = screenIsntWideEnough ? FillDirection.Vertical : FillDirection.Horizontal;
}
}

View File

@ -0,0 +1,160 @@
// 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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Rulesets.Mods;
using osuTK;
namespace osu.Game.Overlays.Mods
{
/// <summary>
/// On the mod select overlay, this provides a local updating view of the aggregate score multiplier coming from mods.
/// </summary>
public partial class ScoreMultiplierDisplay : ModFooterInformationDisplay, IHasCurrentValue<double>
{
public const float HEIGHT = 42;
public Bindable<double> Current
{
get => current.Current;
set => current.Current = value;
}
private readonly BindableWithCurrent<double> current = new BindableWithCurrent<double>();
private const float transition_duration = 200;
private RollingCounter<double> counter = null!;
private Box flashLayer = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
public ScoreMultiplierDisplay()
{
Current.Default = 1d;
Current.Value = 1d;
}
[BackgroundDependencyLoader]
private void load()
{
// You would think that we could add this to `Content`, but borders don't mix well
// with additive blending children elements.
AddInternal(new Container
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
RelativeSizeAxes = Axes.Both,
Shear = new Vector2(ShearedOverlayContainer.SHEAR, 0),
CornerRadius = ShearedButton.CORNER_RADIUS,
Masking = true,
Children = new Drawable[]
{
flashLayer = new Box
{
Alpha = 0,
Blending = BlendingParameters.Additive,
RelativeSizeAxes = Axes.Both,
}
}
});
LeftContent.AddRange(new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
Text = ModSelectOverlayStrings.ScoreMultiplier,
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
}
});
RightContent.Add(new Container
{
Width = 40,
RelativeSizeAxes = Axes.Y,
Margin = new MarginPadding(10),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = counter = new EffectCounter
{
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Current = { BindTarget = Current }
}
});
}
protected override void LoadComplete()
{
base.LoadComplete();
Current.BindValueChanged(e =>
{
if (e.NewValue > Current.Default)
{
MainBackground
.FadeColour(colours.ForModType(ModType.DifficultyIncrease), transition_duration, Easing.OutQuint);
counter.FadeColour(ColourProvider.Background5, transition_duration, Easing.OutQuint);
}
else if (e.NewValue < Current.Default)
{
MainBackground
.FadeColour(colours.ForModType(ModType.DifficultyReduction), transition_duration, Easing.OutQuint);
counter.FadeColour(ColourProvider.Background5, transition_duration, Easing.OutQuint);
}
else
{
MainBackground.FadeColour(ColourProvider.Background4, transition_duration, Easing.OutQuint);
counter.FadeColour(Colour4.White, transition_duration, Easing.OutQuint);
}
flashLayer
.FadeOutFromOne()
.FadeTo(0.15f, 60, Easing.OutQuint)
.Then().FadeOut(500, Easing.OutQuint);
const float move_amount = 4;
if (e.NewValue > e.OldValue)
counter.MoveToY(Math.Max(-move_amount * 2, counter.Y - move_amount)).Then().MoveToY(0, transition_duration * 2, Easing.OutQuint);
else
counter.MoveToY(Math.Min(move_amount * 2, counter.Y + move_amount)).Then().MoveToY(0, transition_duration * 2, Easing.OutQuint);
}, true);
// required to prevent the counter initially rolling up from 0 to 1
// due to `Current.Value` having a nonstandard default value of 1.
counter.SetCountWithoutRolling(Current.Value);
}
private partial class EffectCounter : RollingCounter<double>
{
protected override double RollingDuration => 500;
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(@"0.00x");
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
};
}
}
}

View File

@ -0,0 +1,24 @@
// 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.Localisation;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings
{
public partial class MultiplierSettingsSlider : SettingsSlider<double, MultiplierSettingsSlider.MultiplierRoundedSliderBar>
{
public MultiplierSettingsSlider()
{
KeyboardStep = 0.01f;
}
/// <summary>
/// A slider bar which adds a "x" to the end of the tooltip string.
/// </summary>
public partial class MultiplierRoundedSliderBar : RoundedSliderBar<double>
{
public override LocalisableString TooltipText => $"{base.TooltipText}x";
}
}
}

View File

@ -10,6 +10,7 @@ using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
@ -35,7 +36,7 @@ namespace osu.Game.Rulesets.Mods
public override Type[] IncompatibleMods => new[] { typeof(ModRateAdjust), typeof(ModTimeRamp), typeof(ModAutoplay) };
[SettingSource("Initial rate", "The starting speed of the track")]
[SettingSource("Initial rate", "The starting speed of the track", SettingControlType = typeof(MultiplierSettingsSlider))]
public BindableNumber<double> InitialRate { get; } = new BindableDouble(1)
{
MinValue = 0.5,

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Overlays.Settings;
namespace osu.Game.Rulesets.Mods
{
@ -17,7 +18,7 @@ namespace osu.Game.Rulesets.Mods
public override ModType Type => ModType.DifficultyIncrease;
public override LocalisableString Description => "Zoooooooooom...";
[SettingSource("Speed increase", "The actual increase to apply")]
[SettingSource("Speed increase", "The actual increase to apply", SettingControlType = typeof(MultiplierSettingsSlider))]
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble(1.5)
{
MinValue = 1.01,

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Overlays.Settings;
namespace osu.Game.Rulesets.Mods
{
@ -17,7 +18,7 @@ namespace osu.Game.Rulesets.Mods
public override ModType Type => ModType.DifficultyReduction;
public override LocalisableString Description => "Less zoom...";
[SettingSource("Speed decrease", "The actual decrease to apply")]
[SettingSource("Speed decrease", "The actual decrease to apply", SettingControlType = typeof(MultiplierSettingsSlider))]
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble(0.75)
{
MinValue = 0.5,

View File

@ -7,6 +7,7 @@ using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Mods
@ -20,10 +21,10 @@ namespace osu.Game.Rulesets.Mods
public override double ScoreMultiplier => 0.5;
[SettingSource("Initial rate", "The starting speed of the track")]
[SettingSource("Initial rate", "The starting speed of the track", SettingControlType = typeof(MultiplierSettingsSlider))]
public abstract BindableNumber<double> InitialRate { get; }
[SettingSource("Final rate", "The final speed to ramp to")]
[SettingSource("Final rate", "The final speed to ramp to", SettingControlType = typeof(MultiplierSettingsSlider))]
public abstract BindableNumber<double> FinalRate { get; }
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]

View File

@ -126,9 +126,12 @@ namespace osu.Game.Screens
private void load(ShaderManager manager)
{
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE));
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2_NO_MASKING, FragmentShaderDescriptor.BLUR));
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.BLUR));
loadTargets.Add(manager.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE));
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, "TriangleBorder"));
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE));
}

View File

@ -36,8 +36,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="11.1.2" />
<PackageReference Include="ppy.osu.Framework" Version="2023.904.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.822.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.914.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.914.0" />
<PackageReference Include="Sentry" Version="3.28.1" />
<PackageReference Include="SharpCompress" Version="0.32.2" />
<PackageReference Include="NUnit" Version="3.13.3" />

View File

@ -23,6 +23,6 @@
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.904.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.914.0" />
</ItemGroup>
</Project>