mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 09:23:06 +08:00
Merge pull request #28141 from frenzibyte/footer-v2-mods-display
Add mod display and unranked indicator to new song select footer
This commit is contained in:
commit
6cfe1356cd
@ -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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
@ -10,7 +12,9 @@ using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Screens.Select.FooterV2;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -47,7 +51,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
overlay = new DummyOverlay()
|
||||
};
|
||||
|
||||
footer.AddButton(modsButton = new FooterButtonModsV2(), overlay);
|
||||
footer.AddButton(modsButton = new FooterButtonModsV2 { Current = SelectedMods }, overlay);
|
||||
footer.AddButton(randomButton = new FooterButtonRandomV2
|
||||
{
|
||||
NextRandom = () => nextRandomCalled = true,
|
||||
@ -61,9 +65,34 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
||||
AddStep("set beatmap", () => Beatmap.Value = CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMods()
|
||||
{
|
||||
AddStep("one mod", () => SelectedMods.Value = new List<Mod> { new OsuModHidden() });
|
||||
AddStep("two mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock() });
|
||||
AddStep("three mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime() });
|
||||
AddStep("four mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic() });
|
||||
AddStep("five mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() });
|
||||
|
||||
AddStep("modified", () => SelectedMods.Value = new List<Mod> { new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
||||
AddStep("modified + one", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
||||
AddStep("modified + two", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
||||
AddStep("modified + three", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModClassic(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
||||
AddStep("modified + four", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModClassic(), new OsuModDifficultyAdjust(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } });
|
||||
|
||||
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
||||
AddWaitStep("wait", 3);
|
||||
AddStep("one mod", () => SelectedMods.Value = new List<Mod> { new OsuModHidden() });
|
||||
|
||||
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
||||
AddWaitStep("wait", 3);
|
||||
AddStep("five mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowOptions()
|
||||
{
|
||||
|
@ -0,0 +1,120 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Screens.Select.FooterV2;
|
||||
using osu.Game.Utils;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public partial class TestSceneFooterButtonModsV2 : OsuTestScene
|
||||
{
|
||||
private readonly TestFooterButtonModsV2 footerButtonMods;
|
||||
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
||||
|
||||
public TestSceneFooterButtonModsV2()
|
||||
{
|
||||
Add(footerButtonMods = new TestFooterButtonModsV2
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.CentreLeft,
|
||||
X = -100,
|
||||
Action = () => { },
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDisplay()
|
||||
{
|
||||
AddStep("one mod", () => changeMods(new List<Mod> { new OsuModHidden() }));
|
||||
AddStep("two mods", () => changeMods(new List<Mod> { new OsuModHidden(), new OsuModHardRock() }));
|
||||
AddStep("three mods", () => changeMods(new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime() }));
|
||||
AddStep("four mods", () => changeMods(new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic() }));
|
||||
AddStep("five mods", () => changeMods(new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() }));
|
||||
|
||||
AddStep("modified", () => changeMods(new List<Mod> { new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }));
|
||||
AddStep("modified + one", () => changeMods(new List<Mod> { new OsuModHidden(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }));
|
||||
AddStep("modified + two", () => changeMods(new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }));
|
||||
|
||||
AddStep("clear mods", () => changeMods(Array.Empty<Mod>()));
|
||||
AddWaitStep("wait", 3);
|
||||
AddStep("one mod", () => changeMods(new List<Mod> { new OsuModHidden() }));
|
||||
|
||||
AddStep("clear mods", () => changeMods(Array.Empty<Mod>()));
|
||||
AddWaitStep("wait", 3);
|
||||
AddStep("five mods", () => changeMods(new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIncrementMultiplier()
|
||||
{
|
||||
var hiddenMod = new Mod[] { new OsuModHidden() };
|
||||
AddStep(@"Add Hidden", () => changeMods(hiddenMod));
|
||||
AddAssert(@"Check Hidden multiplier", () => assertModsMultiplier(hiddenMod));
|
||||
|
||||
var hardRockMod = new Mod[] { new OsuModHardRock() };
|
||||
AddStep(@"Add HardRock", () => changeMods(hardRockMod));
|
||||
AddAssert(@"Check HardRock multiplier", () => assertModsMultiplier(hardRockMod));
|
||||
|
||||
var doubleTimeMod = new Mod[] { new OsuModDoubleTime() };
|
||||
AddStep(@"Add DoubleTime", () => changeMods(doubleTimeMod));
|
||||
AddAssert(@"Check DoubleTime multiplier", () => assertModsMultiplier(doubleTimeMod));
|
||||
|
||||
var multipleIncrementMods = new Mod[] { new OsuModDoubleTime(), new OsuModHidden(), new OsuModHardRock() };
|
||||
AddStep(@"Add multiple Mods", () => changeMods(multipleIncrementMods));
|
||||
AddAssert(@"Check multiple mod multiplier", () => assertModsMultiplier(multipleIncrementMods));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecrementMultiplier()
|
||||
{
|
||||
var easyMod = new Mod[] { new OsuModEasy() };
|
||||
AddStep(@"Add Easy", () => changeMods(easyMod));
|
||||
AddAssert(@"Check Easy multiplier", () => assertModsMultiplier(easyMod));
|
||||
|
||||
var noFailMod = new Mod[] { new OsuModNoFail() };
|
||||
AddStep(@"Add NoFail", () => changeMods(noFailMod));
|
||||
AddAssert(@"Check NoFail multiplier", () => assertModsMultiplier(noFailMod));
|
||||
|
||||
var multipleDecrementMods = new Mod[] { new OsuModEasy(), new OsuModNoFail() };
|
||||
AddStep(@"Add Multiple Mods", () => changeMods(multipleDecrementMods));
|
||||
AddAssert(@"Check multiple mod multiplier", () => assertModsMultiplier(multipleDecrementMods));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnrankedBadge()
|
||||
{
|
||||
AddStep(@"Add unranked mod", () => changeMods(new[] { new OsuModDeflate() }));
|
||||
AddUntilStep("Unranked badge shown", () => footerButtonMods.ChildrenOfType<FooterButtonModsV2.UnrankedBadge>().Single().Alpha == 1);
|
||||
AddStep(@"Clear selected mod", () => changeMods(Array.Empty<Mod>()));
|
||||
AddUntilStep("Unranked badge not shown", () => footerButtonMods.ChildrenOfType<FooterButtonModsV2.UnrankedBadge>().Single().Alpha == 0);
|
||||
}
|
||||
|
||||
private void changeMods(IReadOnlyList<Mod> mods) => footerButtonMods.Current.Value = mods;
|
||||
|
||||
private bool assertModsMultiplier(IEnumerable<Mod> mods)
|
||||
{
|
||||
double multiplier = mods.Aggregate(1.0, (current, mod) => current * mod.ScoreMultiplier);
|
||||
string expectedValue = ModUtils.FormatScoreMultiplier(multiplier).ToString();
|
||||
|
||||
return expectedValue == footerButtonMods.MultiplierText.Current.Value;
|
||||
}
|
||||
|
||||
private partial class TestFooterButtonModsV2 : FooterButtonModsV2
|
||||
{
|
||||
public new OsuSpriteText MultiplierText => base.MultiplierText;
|
||||
}
|
||||
}
|
||||
}
|
@ -14,10 +14,16 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString ModSelectTitle => new TranslatableString(getKey(@"mod_select_title"), @"Mod Select");
|
||||
|
||||
/// <summary>
|
||||
/// "{0} mods"
|
||||
/// </summary>
|
||||
public static LocalisableString Mods(int count) => new TranslatableString(getKey(@"mods"), @"{0} mods", count);
|
||||
|
||||
/// <summary>
|
||||
/// "Mods provide different ways to enjoy gameplay. Some have an effect on the score you can achieve during ranked play. Others are just for fun."
|
||||
/// </summary>
|
||||
public static LocalisableString ModSelectDescription => new TranslatableString(getKey(@"mod_select_description"), @"Mods provide different ways to enjoy gameplay. Some have an effect on the score you can achieve during ranked play. Others are just for fun.");
|
||||
public static LocalisableString ModSelectDescription => new TranslatableString(getKey(@"mod_select_description"),
|
||||
@"Mods provide different ways to enjoy gameplay. Some have an effect on the score you can achieve during ranked play. Others are just for fun.");
|
||||
|
||||
/// <summary>
|
||||
/// "Mod Customisation"
|
||||
|
@ -37,10 +37,13 @@ namespace osu.Game.Screens.Play.HUD
|
||||
}
|
||||
}
|
||||
|
||||
private readonly bool showExtendedInformation;
|
||||
private readonly FillFlowContainer<ModIcon> iconsContainer;
|
||||
|
||||
public ModDisplay()
|
||||
public ModDisplay(bool showExtendedInformation = true)
|
||||
{
|
||||
this.showExtendedInformation = showExtendedInformation;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
InternalChild = iconsContainer = new ReverseChildIDFillFlowContainer<ModIcon>
|
||||
@ -57,6 +60,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
Current.BindValueChanged(updateDisplay, true);
|
||||
|
||||
iconsContainer.FadeInFromZero(fade_duration, Easing.OutQuint);
|
||||
|
||||
if (ExpansionMode == ExpansionMode.AlwaysExpanded || ExpansionMode == ExpansionMode.AlwaysContracted)
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private void updateDisplay(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
||||
@ -64,7 +70,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
iconsContainer.Clear();
|
||||
|
||||
foreach (Mod mod in mods.NewValue.AsOrdered())
|
||||
iconsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.6f) });
|
||||
iconsContainer.Add(new ModIcon(mod, showExtendedInformation: showExtendedInformation) { Scale = new Vector2(0.6f) });
|
||||
|
||||
appearTransform();
|
||||
}
|
||||
|
@ -1,20 +1,341 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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.Cursor;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Select.FooterV2
|
||||
{
|
||||
public partial class FooterButtonModsV2 : FooterButtonV2
|
||||
public partial class FooterButtonModsV2 : FooterButtonV2, IHasCurrentValue<IReadOnlyList<Mod>>
|
||||
{
|
||||
// todo: see https://github.com/ppy/osu-framework/issues/3271
|
||||
private const float torus_scale_factor = 1.2f;
|
||||
private const float bar_shear_width = 7f;
|
||||
private const float bar_height = 37f;
|
||||
private const float mod_display_portion = 0.65f;
|
||||
|
||||
private static readonly Vector2 bar_shear = new Vector2(bar_shear_width / bar_height, 0);
|
||||
|
||||
private readonly BindableWithCurrent<IReadOnlyList<Mod>> current = new BindableWithCurrent<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
public Bindable<IReadOnlyList<Mod>> Current
|
||||
{
|
||||
get => current.Current;
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
private Container modDisplayBar = null!;
|
||||
|
||||
private Drawable unrankedBadge = null!;
|
||||
|
||||
private ModDisplay modDisplay = null!;
|
||||
private OsuSpriteText modCountText = null!;
|
||||
|
||||
protected OsuSpriteText MultiplierText { get; private set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colour)
|
||||
private void load()
|
||||
{
|
||||
Text = "Mods";
|
||||
Icon = FontAwesome.Solid.ExchangeAlt;
|
||||
AccentColour = colour.Lime1;
|
||||
AccentColour = colours.Lime1;
|
||||
|
||||
AddRange(new[]
|
||||
{
|
||||
unrankedBadge = new UnrankedBadge(),
|
||||
modDisplayBar = new Container
|
||||
{
|
||||
Y = -5f,
|
||||
Depth = float.MaxValue,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Shear = bar_shear,
|
||||
CornerRadius = CORNER_RADIUS,
|
||||
Size = new Vector2(BUTTON_WIDTH, bar_height),
|
||||
Masking = true,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 4,
|
||||
// Figma says 50% opacity, but it does not match up visually if taken at face value, and looks bad.
|
||||
Colour = Colour4.Black.Opacity(0.25f),
|
||||
Offset = new Vector2(0, 2),
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colourProvider.Background4,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 1f - mod_display_portion,
|
||||
Masking = true,
|
||||
Child = MultiplierText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Shear = -bar_shear,
|
||||
UseFullGlyphHeight = false,
|
||||
Font = OsuFont.Torus.With(size: 14 * torus_scale_factor, weight: FontWeight.Bold)
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
CornerRadius = CORNER_RADIUS,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = mod_display_portion,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colourProvider.Background3,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
modDisplay = new ModDisplay(showExtendedInformation: false)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Shear = -bar_shear,
|
||||
Scale = new Vector2(0.6f),
|
||||
Current = { BindTarget = Current },
|
||||
ExpansionMode = ExpansionMode.AlwaysContracted,
|
||||
},
|
||||
modCountText = new ModCountText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Shear = -bar_shear,
|
||||
Font = OsuFont.Torus.With(size: 14 * torus_scale_factor, weight: FontWeight.Bold),
|
||||
Mods = { BindTarget = Current },
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private ModSettingChangeTracker? modSettingChangeTracker;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Current.BindValueChanged(m =>
|
||||
{
|
||||
modSettingChangeTracker?.Dispose();
|
||||
|
||||
updateDisplay();
|
||||
|
||||
if (m.NewValue != null)
|
||||
{
|
||||
modSettingChangeTracker = new ModSettingChangeTracker(m.NewValue);
|
||||
modSettingChangeTracker.SettingChanged += _ => updateDisplay();
|
||||
}
|
||||
}, true);
|
||||
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private const double duration = 240;
|
||||
private const Easing easing = Easing.OutQuint;
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
if (Current.Value.Count == 0)
|
||||
{
|
||||
modDisplayBar.MoveToY(20, duration, easing);
|
||||
modDisplayBar.FadeOut(duration, easing);
|
||||
modDisplay.FadeOut(duration, easing);
|
||||
modCountText.FadeOut(duration, easing);
|
||||
|
||||
unrankedBadge.MoveToY(20, duration, easing);
|
||||
unrankedBadge.FadeOut(duration, easing);
|
||||
|
||||
// add delay to let unranked indicator hide first before resizing the button back to its original width.
|
||||
this.Delay(duration).ResizeWidthTo(BUTTON_WIDTH, duration, easing);
|
||||
}
|
||||
else
|
||||
{
|
||||
modDisplay.Hide();
|
||||
modCountText.Hide();
|
||||
|
||||
if (Current.Value.Count >= 5)
|
||||
modCountText.Show();
|
||||
else
|
||||
modDisplay.Show();
|
||||
|
||||
if (Current.Value.Any(m => !m.Ranked))
|
||||
{
|
||||
unrankedBadge.MoveToX(0, duration, easing);
|
||||
unrankedBadge.FadeIn(duration, easing);
|
||||
|
||||
this.ResizeWidthTo(BUTTON_WIDTH + 5 + unrankedBadge.DrawWidth, duration, easing);
|
||||
}
|
||||
else
|
||||
{
|
||||
unrankedBadge.MoveToX(-unrankedBadge.DrawWidth, duration, easing);
|
||||
unrankedBadge.FadeOut(duration, easing);
|
||||
|
||||
this.ResizeWidthTo(BUTTON_WIDTH, duration, easing);
|
||||
}
|
||||
|
||||
modDisplayBar.MoveToY(-5, duration, Easing.OutQuint);
|
||||
unrankedBadge.MoveToY(-5, duration, easing);
|
||||
modDisplayBar.FadeIn(duration, easing);
|
||||
}
|
||||
|
||||
double multiplier = Current.Value?.Aggregate(1.0, (current, mod) => current * mod.ScoreMultiplier) ?? 1;
|
||||
MultiplierText.Text = ModUtils.FormatScoreMultiplier(multiplier);
|
||||
|
||||
if (multiplier > 1)
|
||||
MultiplierText.FadeColour(colours.Red1, duration, easing);
|
||||
else if (multiplier < 1)
|
||||
MultiplierText.FadeColour(colours.Lime1, duration, easing);
|
||||
else
|
||||
MultiplierText.FadeColour(Color4.White, duration, easing);
|
||||
}
|
||||
|
||||
private partial class ModCountText : OsuSpriteText, IHasCustomTooltip<IReadOnlyList<Mod>>
|
||||
{
|
||||
public readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>();
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Mods.BindValueChanged(v => Text = ModSelectOverlayStrings.Mods(v.NewValue.Count).ToUpper(), true);
|
||||
}
|
||||
|
||||
public ITooltip<IReadOnlyList<Mod>> GetCustomTooltip() => new ModTooltip(colourProvider);
|
||||
|
||||
public IReadOnlyList<Mod>? TooltipContent => Mods.Value;
|
||||
|
||||
public partial class ModTooltip : VisibilityContainer, ITooltip<IReadOnlyList<Mod>>
|
||||
{
|
||||
private ModDisplay extendedModDisplay = null!;
|
||||
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider;
|
||||
|
||||
public ModTooltip(OverlayColourProvider colourProvider)
|
||||
{
|
||||
this.colourProvider = colourProvider;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
CornerRadius = CORNER_RADIUS;
|
||||
Masking = true;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background5,
|
||||
},
|
||||
extendedModDisplay = new ModDisplay
|
||||
{
|
||||
Margin = new MarginPadding { Vertical = 2f, Horizontal = 10f },
|
||||
Scale = new Vector2(0.6f),
|
||||
ExpansionMode = ExpansionMode.AlwaysExpanded,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public void SetContent(IReadOnlyList<Mod> content)
|
||||
{
|
||||
extendedModDisplay.Current.Value = content;
|
||||
}
|
||||
|
||||
public void Move(Vector2 pos) => Position = pos;
|
||||
|
||||
protected override void PopIn() => this.FadeIn(240, Easing.OutQuint);
|
||||
protected override void PopOut() => this.FadeOut(240, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
internal partial class UnrankedBadge : CompositeDrawable, IHasTooltip
|
||||
{
|
||||
public LocalisableString TooltipText { get; }
|
||||
|
||||
public UnrankedBadge()
|
||||
{
|
||||
Margin = new MarginPadding { Left = BUTTON_WIDTH + 5f };
|
||||
Y = -5f;
|
||||
Depth = float.MaxValue;
|
||||
Origin = Anchor.BottomLeft;
|
||||
Shear = bar_shear;
|
||||
CornerRadius = CORNER_RADIUS;
|
||||
AutoSizeAxes = Axes.X;
|
||||
Height = bar_height;
|
||||
Masking = true;
|
||||
BorderColour = Color4.White;
|
||||
BorderThickness = 2f;
|
||||
TooltipText = ModSelectOverlayStrings.UnrankedExplanation;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Orange2,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Shear = -bar_shear,
|
||||
Text = ModSelectOverlayStrings.Unranked.ToUpper(),
|
||||
Margin = new MarginPadding { Horizontal = 15 },
|
||||
UseFullGlyphHeight = false,
|
||||
Font = OsuFont.Torus.With(size: 14 * torus_scale_factor, weight: FontWeight.Bold),
|
||||
Colour = Color4.Black,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,17 +24,18 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
{
|
||||
public partial class FooterButtonV2 : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private const int button_height = 90;
|
||||
private const int button_width = 140;
|
||||
private const int corner_radius = 10;
|
||||
private const int transition_length = 500;
|
||||
|
||||
// This should be 12 by design, but an extra allowance is added due to the corner radius specification.
|
||||
public const float SHEAR_WIDTH = 13.5f;
|
||||
private const float shear_width = 13.5f;
|
||||
|
||||
protected const int CORNER_RADIUS = 10;
|
||||
protected const int BUTTON_HEIGHT = 90;
|
||||
protected const int BUTTON_WIDTH = 140;
|
||||
|
||||
public Bindable<Visibility> OverlayState = new Bindable<Visibility>();
|
||||
|
||||
protected static readonly Vector2 SHEAR = new Vector2(SHEAR_WIDTH / button_height, 0);
|
||||
protected static readonly Vector2 BUTTON_SHEAR = new Vector2(shear_width / BUTTON_HEIGHT, 0);
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
@ -70,68 +71,72 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
|
||||
public FooterButtonV2()
|
||||
{
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 4,
|
||||
// Figma says 50% opacity, but it does not match up visually if taken at face value, and looks bad.
|
||||
Colour = Colour4.Black.Opacity(0.25f),
|
||||
Offset = new Vector2(0, 2),
|
||||
};
|
||||
Shear = SHEAR;
|
||||
Size = new Vector2(button_width, button_height);
|
||||
Masking = true;
|
||||
CornerRadius = corner_radius;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
backgroundBox = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
Size = new Vector2(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
|
||||
// For elements that should not be sheared.
|
||||
new Container
|
||||
Child = new Container
|
||||
{
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Shear = -SHEAR,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
TextContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Y = 42,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Child = text = new OsuSpriteText
|
||||
{
|
||||
// figma design says the size is 16, but due to the issues with font sizes 19 matches better
|
||||
Font = OsuFont.TorusAlternate.With(size: 19),
|
||||
AlwaysPresent = true
|
||||
}
|
||||
},
|
||||
icon = new SpriteIcon
|
||||
{
|
||||
Y = 12,
|
||||
Size = new Vector2(20),
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
},
|
||||
}
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 4,
|
||||
// Figma says 50% opacity, but it does not match up visually if taken at face value, and looks bad.
|
||||
Colour = Colour4.Black.Opacity(0.25f),
|
||||
Offset = new Vector2(0, 2),
|
||||
},
|
||||
new Container
|
||||
Shear = BUTTON_SHEAR,
|
||||
Masking = true,
|
||||
CornerRadius = CORNER_RADIUS,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Shear = -SHEAR,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.Centre,
|
||||
Y = -corner_radius,
|
||||
Size = new Vector2(120, 6),
|
||||
Masking = true,
|
||||
CornerRadius = 3,
|
||||
Child = bar = new Box
|
||||
backgroundBox = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
// For elements that should not be sheared.
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Shear = -BUTTON_SHEAR,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
TextContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Y = 42,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Child = text = new OsuSpriteText
|
||||
{
|
||||
// figma design says the size is 16, but due to the issues with font sizes 19 matches better
|
||||
Font = OsuFont.TorusAlternate.With(size: 19),
|
||||
AlwaysPresent = true
|
||||
}
|
||||
},
|
||||
icon = new SpriteIcon
|
||||
{
|
||||
Y = 12,
|
||||
Size = new Vector2(20),
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
},
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Shear = -BUTTON_SHEAR,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.Centre,
|
||||
Y = -CORNER_RADIUS,
|
||||
Size = new Vector2(120, 6),
|
||||
Masking = true,
|
||||
CornerRadius = 3,
|
||||
Child = bar = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -72,7 +72,7 @@ namespace osu.Game.Screens.Select.FooterV2
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(-FooterButtonV2.SHEAR_WIDTH + 7, 0),
|
||||
Spacing = new Vector2(7, 0),
|
||||
AutoSizeAxes = Axes.Both
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user