From 80ae7942dfd4e6a8c4ece991243dfcc7e5cf167a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Dec 2024 17:52:50 +0900 Subject: [PATCH 01/19] Add christmas-specific logo heartbeat --- osu.Game/Screens/Menu/OsuLogo.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index f2e2e25fa6..f3c37c6960 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -271,8 +271,16 @@ namespace osu.Game.Screens.Menu private void load(TextureStore textures, AudioManager audio) { sampleClick = audio.Samples.Get(@"Menu/osu-logo-select"); - sampleBeat = audio.Samples.Get(@"Menu/osu-logo-heartbeat"); - sampleDownbeat = audio.Samples.Get(@"Menu/osu-logo-downbeat"); + + if (SeasonalUI.ENABLED) + { + sampleDownbeat = sampleBeat = audio.Samples.Get(@"Menu/osu-logo-heartbeat-bell"); + } + else + { + sampleBeat = audio.Samples.Get(@"Menu/osu-logo-heartbeat"); + sampleDownbeat = audio.Samples.Get(@"Menu/osu-logo-downbeat"); + } logo.Texture = textures.Get(@"Menu/logo"); ripple.Texture = textures.Get(@"Menu/logo"); @@ -303,7 +311,10 @@ namespace osu.Game.Screens.Menu else { var channel = sampleBeat.GetChannel(); - channel.Frequency.Value = 0.95 + RNG.NextDouble(0.1); + if (SeasonalUI.ENABLED) + channel.Frequency.Value = 0.99 + RNG.NextDouble(0.02); + else + channel.Frequency.Value = 0.95 + RNG.NextDouble(0.1); channel.Play(); } }); From 180a381b6fb0973b04d414c6b7f4755a8958d724 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Dec 2024 17:57:12 +0900 Subject: [PATCH 02/19] Adjust menu side flashes to be brighter and coloured when seasonal active --- osu.Game/Screens/Menu/MenuSideFlashes.cs | 25 +++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index 533c39826c..cc2d22a7fa 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -3,22 +3,23 @@ #nullable disable -using osuTK.Graphics; +using System; using osu.Framework.Allocation; +using osu.Framework.Audio.Track; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Shapes; +using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Skinning; using osu.Game.Online.API; -using System; -using osu.Framework.Audio.Track; -using osu.Framework.Bindables; using osu.Game.Online.API.Requests.Responses; +using osu.Game.Skinning; +using osuTK.Graphics; namespace osu.Game.Screens.Menu { @@ -67,7 +68,7 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, RelativeSizeAxes = Axes.Y, - Width = box_width * 2, + Width = box_width * (SeasonalUI.ENABLED ? 4 : 2), Height = 1.5f, // align off-screen to make sure our edges don't become visible during parallax. X = -box_width, @@ -79,7 +80,7 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, RelativeSizeAxes = Axes.Y, - Width = box_width * 2, + Width = box_width * (SeasonalUI.ENABLED ? 4 : 2), Height = 1.5f, X = box_width, Alpha = 0, @@ -104,7 +105,11 @@ namespace osu.Game.Screens.Menu private void flash(Drawable d, double beatLength, bool kiai, ChannelAmplitudes amplitudes) { - d.FadeTo(Math.Max(0, ((ReferenceEquals(d, leftBox) ? amplitudes.LeftChannel : amplitudes.RightChannel) - amplitude_dead_zone) / (kiai ? kiai_multiplier : alpha_multiplier)), box_fade_in_time) + if (SeasonalUI.ENABLED) + updateColour(); + + d.FadeTo(Math.Clamp(0.1f + ((ReferenceEquals(d, leftBox) ? amplitudes.LeftChannel : amplitudes.RightChannel) - amplitude_dead_zone) / (kiai ? kiai_multiplier : alpha_multiplier), 0.1f, 1), + box_fade_in_time) .Then() .FadeOut(beatLength, Easing.In); } @@ -113,7 +118,9 @@ namespace osu.Game.Screens.Menu { Color4 baseColour = colours.Blue; - if (user.Value?.IsSupporter ?? false) + if (SeasonalUI.ENABLED) + baseColour = RNG.NextBool() ? SeasonalUI.PRIMARY_COLOUR_1 : SeasonalUI.PRIMARY_COLOUR_2; + else if (user.Value?.IsSupporter ?? false) baseColour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? baseColour; // linear colour looks better in this case, so let's use it for now. From a4bf29e98f4aac7306164eb90edab065d83198eb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Dec 2024 17:57:42 +0900 Subject: [PATCH 03/19] Adjust menu logo visualiser to use seasonal colours --- osu.Game/Screens/Menu/MenuLogoVisualisation.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Menu/MenuLogoVisualisation.cs b/osu.Game/Screens/Menu/MenuLogoVisualisation.cs index f4e992be9a..4537b79b62 100644 --- a/osu.Game/Screens/Menu/MenuLogoVisualisation.cs +++ b/osu.Game/Screens/Menu/MenuLogoVisualisation.cs @@ -3,12 +3,12 @@ #nullable disable -using osuTK.Graphics; -using osu.Game.Skinning; -using osu.Game.Online.API; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; +using osu.Game.Skinning; +using osuTK.Graphics; namespace osu.Game.Screens.Menu { @@ -29,7 +29,9 @@ namespace osu.Game.Screens.Menu private void updateColour() { - if (user.Value?.IsSupporter ?? false) + if (SeasonalUI.ENABLED) + Colour = SeasonalUI.AMBIENT_COLOUR_1; + else if (user.Value?.IsSupporter ?? false) Colour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? Color4.White; else Colour = Color4.White; From 618a9849e314a99aff70baec7f2b1ef295b4e1e0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Dec 2024 17:59:31 +0900 Subject: [PATCH 04/19] Increase intro time allowance to account for seasonal tracks with actual long intros --- osu.Game/Screens/Menu/IntroScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index 0dc54b321f..9885c061a9 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -207,7 +207,7 @@ namespace osu.Game.Screens.Menu Text = NotificationsStrings.AudioPlaybackIssue }); } - }, 5000); + }, 8000); } public override void OnResuming(ScreenTransitionEvent e) From 024029822ab0e74880de27ce073fe88d735659b8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Dec 2024 17:59:48 +0900 Subject: [PATCH 05/19] Add christmas intro --- .../Visual/Menus/TestSceneIntroChristmas.cs | 15 + osu.Game/Screens/Loader.cs | 3 + osu.Game/Screens/Menu/IntroChristmas.cs | 328 ++++++++++++++++++ osu.Game/Screens/SeasonalUI.cs | 21 ++ 4 files changed, 367 insertions(+) create mode 100644 osu.Game.Tests/Visual/Menus/TestSceneIntroChristmas.cs create mode 100644 osu.Game/Screens/Menu/IntroChristmas.cs create mode 100644 osu.Game/Screens/SeasonalUI.cs diff --git a/osu.Game.Tests/Visual/Menus/TestSceneIntroChristmas.cs b/osu.Game.Tests/Visual/Menus/TestSceneIntroChristmas.cs new file mode 100644 index 0000000000..13377f49df --- /dev/null +++ b/osu.Game.Tests/Visual/Menus/TestSceneIntroChristmas.cs @@ -0,0 +1,15 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Screens.Menu; + +namespace osu.Game.Tests.Visual.Menus +{ + [TestFixture] + public partial class TestSceneIntroChristmas : IntroTestScene + { + protected override bool IntroReliesOnTrack => true; + protected override IntroScreen CreateScreen() => new IntroChristmas(); + } +} diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index d71ee05b27..811e4600eb 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -37,6 +37,9 @@ namespace osu.Game.Screens private IntroScreen getIntroSequence() { + if (SeasonalUI.ENABLED) + return new IntroChristmas(createMainMenu); + if (introSequence == IntroSequence.Random) introSequence = (IntroSequence)RNG.Next(0, (int)IntroSequence.Random); diff --git a/osu.Game/Screens/Menu/IntroChristmas.cs b/osu.Game/Screens/Menu/IntroChristmas.cs new file mode 100644 index 0000000000..0a1cf32b85 --- /dev/null +++ b/osu.Game/Screens/Menu/IntroChristmas.cs @@ -0,0 +1,328 @@ +// Copyright (c) ppy Pty Ltd . 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.Audio.Track; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Textures; +using osu.Framework.Screens; +using osu.Framework.Timing; +using osu.Framework.Utils; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.Menu +{ + public partial class IntroChristmas : IntroScreen + { + protected override string BeatmapHash => "7e26183e72a496f672c3a21292e6b469fdecd084d31c259ea10a31df5b46cd77"; + + protected override string BeatmapFile => "christmas2024.osz"; + + private const double beat_length = 60000 / 172.0; + private const double offset = 5924; + + protected override string SeeyaSampleName => "Intro/Welcome/seeya"; + + private TrianglesIntroSequence intro = null!; + + public IntroChristmas(Func? createNextScreen = null) + : base(createNextScreen) + { + } + + protected override void LogoArriving(OsuLogo logo, bool resuming) + { + base.LogoArriving(logo, resuming); + + if (!resuming) + { + PrepareMenuLoad(); + + var decouplingClock = new DecouplingFramedClock(UsingThemedIntro ? Track : null); + + LoadComponentAsync(intro = new TrianglesIntroSequence(logo, () => FadeInBackground()) + { + RelativeSizeAxes = Axes.Both, + Clock = new InterpolatingFramedClock(decouplingClock), + LoadMenu = LoadMenu + }, _ => + { + AddInternal(intro); + + // There is a chance that the intro timed out before being displayed, and this scheduled callback could + // happen during the outro rather than intro. + // In such a scenario, we don't want to play the intro sample, nor attempt to start the intro track + // (that may have already been since disposed by MusicController). + if (DidLoadMenu) + return; + + // If the user has requested no theme, fallback to the same intro voice and delay as IntroCircles. + // The triangles intro voice and theme are combined which makes it impossible to use. + StartTrack(); + + // no-op for the case of themed intro, no harm in calling for both scenarios as a safety measure. + decouplingClock.Start(); + }); + } + } + + public override void OnSuspending(ScreenTransitionEvent e) + { + base.OnSuspending(e); + + // important as there is a clock attached to a track which will likely be disposed before returning to this screen. + intro.Expire(); + } + + private partial class TrianglesIntroSequence : CompositeDrawable + { + private readonly OsuLogo logo; + private readonly Action showBackgroundAction; + private OsuSpriteText welcomeText = null!; + + private Container logoContainerSecondary = null!; + private LazerLogo lazerLogo = null!; + + private Drawable triangles = null!; + + public Action LoadMenu = null!; + + [Resolved] + private OsuGameBase game { get; set; } = null!; + + public TrianglesIntroSequence(OsuLogo logo, Action showBackgroundAction) + { + this.logo = logo; + this.showBackgroundAction = showBackgroundAction; + } + + [BackgroundDependencyLoader] + private void load() + { + InternalChildren = new[] + { + welcomeText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Padding = new MarginPadding { Bottom = 10 }, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 42), + Alpha = 1, + Spacing = new Vector2(5), + }, + logoContainerSecondary = new Container + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Child = lazerLogo = new LazerLogo + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + } + }, + triangles = new CircularContainer + { + Alpha = 0, + Masking = true, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(960), + Child = new GlitchingTriangles + { + RelativeSizeAxes = Axes.Both, + }, + } + }; + } + + private static double getTimeForBeat(int beat) => offset + beat_length * beat; + + protected override void LoadComplete() + { + base.LoadComplete(); + + lazerLogo.Hide(); + + using (BeginAbsoluteSequence(0)) + { + using (BeginDelayedSequence(getTimeForBeat(-16))) + welcomeText.FadeIn().OnComplete(t => t.Text = "welcome to osu!"); + + using (BeginDelayedSequence(getTimeForBeat(-15))) + welcomeText.FadeIn().OnComplete(t => t.Text = ""); + + using (BeginDelayedSequence(getTimeForBeat(-14))) + welcomeText.FadeIn().OnComplete(t => t.Text = "welcome to osu!"); + + using (BeginDelayedSequence(getTimeForBeat(-13))) + welcomeText.FadeIn().OnComplete(t => t.Text = ""); + + using (BeginDelayedSequence(getTimeForBeat(-12))) + welcomeText.FadeIn().OnComplete(t => t.Text = "merry christmas!"); + + using (BeginDelayedSequence(getTimeForBeat(-11))) + welcomeText.FadeIn().OnComplete(t => t.Text = ""); + + using (BeginDelayedSequence(getTimeForBeat(-10))) + welcomeText.FadeIn().OnComplete(t => t.Text = "merry osumas!"); + + using (BeginDelayedSequence(getTimeForBeat(-9))) + { + welcomeText.FadeIn().OnComplete(t => t.Text = ""); + } + + lazerLogo.Scale = new Vector2(0.2f); + triangles.Scale = new Vector2(0.2f); + + for (int i = 0; i < 8; i++) + { + using (BeginDelayedSequence(getTimeForBeat(-8 + i))) + { + triangles.FadeIn(); + + lazerLogo.ScaleTo(new Vector2(0.2f + (i + 1) / 8f * 0.3f), beat_length * 1, Easing.OutQuint); + triangles.ScaleTo(new Vector2(0.2f + (i + 1) / 8f * 0.3f), beat_length * 1, Easing.OutQuint); + lazerLogo.FadeTo((i + 1) * 0.06f); + lazerLogo.TransformTo(nameof(LazerLogo.Progress), (i + 1) / 10f); + } + } + + GameWideFlash flash = new GameWideFlash(); + + using (BeginDelayedSequence(getTimeForBeat(-2))) + { + lazerLogo.FadeIn().OnComplete(_ => game.Add(flash)); + } + + flash.FadeInCompleted = () => + { + logoContainerSecondary.Remove(lazerLogo, true); + triangles.FadeOut(); + logo.FadeIn(); + showBackgroundAction(); + LoadMenu(); + }; + } + } + + private partial class GameWideFlash : Box + { + public Action? FadeInCompleted; + + public GameWideFlash() + { + Colour = Color4.White; + RelativeSizeAxes = Axes.Both; + Blending = BlendingParameters.Additive; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + Alpha = 0; + + this.FadeTo(0.5f, beat_length * 2, Easing.In) + .OnComplete(_ => FadeInCompleted?.Invoke()); + + this.Delay(beat_length * 2) + .Then() + .FadeOutFromOne(3000, Easing.OutQuint); + } + } + + private partial class LazerLogo : CompositeDrawable + { + private LogoAnimation highlight = null!; + private LogoAnimation background = null!; + + public float Progress + { + get => background.AnimationProgress; + set + { + background.AnimationProgress = value; + highlight.AnimationProgress = value; + } + } + + public LazerLogo() + { + Size = new Vector2(960); + } + + [BackgroundDependencyLoader] + private void load(LargeTextureStore textures) + { + InternalChildren = new Drawable[] + { + highlight = new LogoAnimation + { + RelativeSizeAxes = Axes.Both, + Texture = textures.Get(@"Intro/Triangles/logo-highlight"), + Colour = Color4.White, + }, + background = new LogoAnimation + { + RelativeSizeAxes = Axes.Both, + Texture = textures.Get(@"Intro/Triangles/logo-background"), + Colour = OsuColour.Gray(0.6f), + }, + }; + } + } + + private partial class GlitchingTriangles : BeatSyncedContainer + { + private int beatsHandled; + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes) + { + base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + + Divisor = beatsHandled < 4 ? 1 : 4; + + for (int i = 0; i < (beatsHandled + 1); i++) + { + float angle = (float)(RNG.NextDouble() * 2 * Math.PI); + float randomRadius = (float)(Math.Sqrt(RNG.NextDouble())); + + float x = 0.5f + 0.5f * randomRadius * (float)Math.Cos(angle); + float y = 0.5f + 0.5f * randomRadius * (float)Math.Sin(angle); + + Color4 christmasColour = RNG.NextBool() ? SeasonalUI.PRIMARY_COLOUR_1 : SeasonalUI.PRIMARY_COLOUR_2; + + Drawable triangle = new Triangle + { + Size = new Vector2(RNG.NextSingle() + 1.2f) * 80, + Origin = Anchor.Centre, + RelativePositionAxes = Axes.Both, + Position = new Vector2(x, y), + Colour = christmasColour + }; + + if (beatsHandled >= 10) + triangle.Blending = BlendingParameters.Additive; + + AddInternal(triangle); + triangle + .ScaleTo(0.9f) + .ScaleTo(1, beat_length / 2, Easing.Out); + triangle.FadeInFromZero(100, Easing.OutQuint); + } + + beatsHandled += 1; + } + } + } + } +} diff --git a/osu.Game/Screens/SeasonalUI.cs b/osu.Game/Screens/SeasonalUI.cs new file mode 100644 index 0000000000..ebe4d74301 --- /dev/null +++ b/osu.Game/Screens/SeasonalUI.cs @@ -0,0 +1,21 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Extensions.Color4Extensions; +using osuTK.Graphics; + +namespace osu.Game.Screens +{ + public static class SeasonalUI + { + public static readonly bool ENABLED = true; + + public static readonly Color4 PRIMARY_COLOUR_1 = Color4Extensions.FromHex("D32F2F"); + + public static readonly Color4 PRIMARY_COLOUR_2 = Color4Extensions.FromHex("388E3C"); + + public static readonly Color4 AMBIENT_COLOUR_1 = Color4Extensions.FromHex("FFC"); + + public static readonly Color4 AMBIENT_COLOUR_2 = Color4Extensions.FromHex("FFE4B5"); + } +} From 0954e0b0321d6872e16b73055a7b171f1cbbc9f9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Dec 2024 18:00:00 +0900 Subject: [PATCH 06/19] Add seasonal lighting Replaces kiai fountains for now. --- .../TestSceneMainMenuSeasonalLighting.cs | 46 +++++ osu.Game/Screens/Menu/MainMenu.cs | 4 +- .../Screens/Menu/MainMenuSeasonalLighting.cs | 188 ++++++++++++++++++ 3 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs create mode 100644 osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs diff --git a/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs new file mode 100644 index 0000000000..bfdc07fba6 --- /dev/null +++ b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs @@ -0,0 +1,46 @@ +// Copyright (c) ppy Pty Ltd . 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.Testing; +using osu.Game.Beatmaps; +using osu.Game.Database; +using osu.Game.Screens.Menu; + +namespace osu.Game.Tests.Visual.Menus +{ + public partial class TestSceneMainMenuSeasonalLighting : OsuTestScene + { + [Resolved] + private BeatmapManager beatmaps { get; set; } = null!; + + [Resolved] + private RealmAccess realm { get; set; } = null!; + + [SetUpSteps] + public void SetUpSteps() + { + AddStep("prepare beatmap", () => + { + var setInfo = beatmaps.QueryBeatmapSet(b => b.Protected && b.Hash == "7e26183e72a496f672c3a21292e6b469fdecd084d31c259ea10a31df5b46cd77"); + + Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo!.Value.Beatmaps.First()); + }); + + AddStep("create lighting", () => Child = new MainMenuSeasonalLighting()); + + AddStep("restart beatmap", () => + { + Beatmap.Value.Track.Start(); + Beatmap.Value.Track.Seek(4000); + }); + } + + [Test] + public void TestBasic() + { + } + } +} diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 0630b9612e..42aa2342da 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -124,6 +124,7 @@ namespace osu.Game.Screens.Menu AddRangeInternal(new[] { + SeasonalUI.ENABLED ? new MainMenuSeasonalLighting() : Empty(), buttonsContainer = new ParallaxContainer { ParallaxAmount = 0.01f, @@ -166,7 +167,8 @@ namespace osu.Game.Screens.Menu Origin = Anchor.TopRight, Margin = new MarginPadding { Right = 15, Top = 5 } }, - new KiaiMenuFountains(), + // For now, this is too much alongside the seasonal lighting. + SeasonalUI.ENABLED ? Empty() : new KiaiMenuFountains(), bottomElementsFlow = new FillFlowContainer { AutoSizeAxes = Axes.Both, diff --git a/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs b/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs new file mode 100644 index 0000000000..7ba4e998d2 --- /dev/null +++ b/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs @@ -0,0 +1,188 @@ +// Copyright (c) ppy Pty Ltd . 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.Diagnostics; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Effects; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Timing; +using osu.Framework.Utils; +using osu.Game.Audio; +using osu.Game.Beatmaps; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Types; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.Menu +{ + public partial class MainMenuSeasonalLighting : CompositeDrawable + { + private IBindable working = null!; + + private InterpolatingFramedClock beatmapClock = null!; + + private List hitObjects = null!; + + [Resolved] + private RulesetStore rulesets { get; set; } = null!; + + public MainMenuSeasonalLighting() + { + RelativeChildSize = new Vector2(512, 384); + + RelativeSizeAxes = Axes.X; + + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + } + + [BackgroundDependencyLoader] + private void load(IBindable working) + { + this.working = working.GetBoundCopy(); + this.working.BindValueChanged(_ => Scheduler.AddOnce(updateBeatmap), true); + } + + private void updateBeatmap() + { + lastObjectIndex = null; + beatmapClock = new InterpolatingFramedClock(new FramedClock(working.Value.Track)); + hitObjects = working.Value.GetPlayableBeatmap(rulesets.GetRuleset(0)).HitObjects.SelectMany(h => h.NestedHitObjects.Prepend(h)) + .OrderBy(h => h.StartTime) + .ToList(); + } + + private int? lastObjectIndex; + + protected override void Update() + { + base.Update(); + + Height = DrawWidth / 16 * 10; + + beatmapClock.ProcessFrame(); + + // intentionally slightly early since we are doing fades on the lighting. + double time = beatmapClock.CurrentTime + 50; + + // handle seeks or OOB by skipping to current. + if (lastObjectIndex == null || lastObjectIndex >= hitObjects.Count || (lastObjectIndex >= 0 && hitObjects[lastObjectIndex.Value].StartTime > time) + || Math.Abs(beatmapClock.ElapsedFrameTime) > 500) + lastObjectIndex = hitObjects.Count(h => h.StartTime < time) - 1; + + while (lastObjectIndex < hitObjects.Count - 1) + { + var h = hitObjects[lastObjectIndex.Value + 1]; + + if (h.StartTime > time) + break; + + // Don't add lighting if the game is running too slow. + if (Clock.ElapsedFrameTime < 20) + addLight(h); + + lastObjectIndex++; + } + } + + private void addLight(HitObject h) + { + var light = new Light + { + RelativePositionAxes = Axes.Both, + Position = ((IHasPosition)h).Position + }; + + AddInternal(light); + + if (h.GetType().Name.Contains("Tick")) + { + light.Colour = SeasonalUI.AMBIENT_COLOUR_1; + light.Scale = new Vector2(0.5f); + light + .FadeInFromZero(250) + .Then() + .FadeOutFromOne(1000, Easing.Out); + + light.MoveToOffset(new Vector2(RNG.Next(-20, 20), RNG.Next(-20, 20)), 1400, Easing.Out); + } + else + { + // default green + Color4 col = SeasonalUI.PRIMARY_COLOUR_2; + + // whistle red + if (h.Samples.Any(s => s.Name == HitSampleInfo.HIT_WHISTLE)) + col = SeasonalUI.PRIMARY_COLOUR_1; + // clap is third colour + else if (h.Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)) + col = SeasonalUI.AMBIENT_COLOUR_1; + + light.Colour = col; + + // finish larger lighting + if (h.Samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH)) + light.Scale = new Vector2(3); + + light + .FadeInFromZero(150) + .Then() + .FadeOutFromOne(1000, Easing.In); + + light.Expire(); + } + } + + public partial class Light : CompositeDrawable + { + private readonly Circle circle; + + public new Color4 Colour + { + set + { + circle.Colour = value.Darken(0.8f); + circle.EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Glow, + Colour = value, + Radius = 80, + }; + } + } + + public Light() + { + InternalChildren = new Drawable[] + { + circle = new Circle + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(12), + Colour = SeasonalUI.AMBIENT_COLOUR_1, + Blending = BlendingParameters.Additive, + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Glow, + Colour = SeasonalUI.AMBIENT_COLOUR_2, + Radius = 80, + } + } + }; + + Origin = Anchor.Centre; + Alpha = 0.5f; + } + } + } +} From 22f3831c0d46d11f7770c62c2dab4c2ee1132e36 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Dec 2024 18:44:44 +0900 Subject: [PATCH 07/19] Add logo hat --- .../Visual/UserInterface/TestSceneOsuLogo.cs | 11 +++- osu.Game/Screens/Menu/OsuLogo.cs | 50 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs index 62a493815b..c112d26870 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs @@ -4,22 +4,31 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Game.Screens.Menu; +using osuTK; namespace osu.Game.Tests.Visual.UserInterface { public partial class TestSceneOsuLogo : OsuTestScene { + private OsuLogo? logo; + [Test] public void TestBasic() { AddStep("Add logo", () => { - Child = new OsuLogo + Child = logo = new OsuLogo { Anchor = Anchor.Centre, Origin = Anchor.Centre, }; }); + + AddSliderStep("scale", 0.1, 2, 1, scale => + { + if (logo != null) + Child.Scale = new Vector2((float)scale); + }); } } } diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index f3c37c6960..2c62a10a8f 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -4,6 +4,7 @@ #nullable disable using System; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -211,6 +212,15 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.Centre, Origin = Anchor.Centre, }, + SeasonalUI.ENABLED + ? hat = new Sprite + { + BypassAutoSizeAxes = Axes.Both, + Alpha = 0, + Origin = Anchor.BottomCentre, + Scale = new Vector2(-1, 1), + } + : Empty(), } }, impactContainer = new CircularContainer @@ -284,6 +294,8 @@ namespace osu.Game.Screens.Menu logo.Texture = textures.Get(@"Menu/logo"); ripple.Texture = textures.Get(@"Menu/logo"); + if (hat != null) + hat.Texture = textures.Get(@"Menu/hat"); } private int lastBeatIndex; @@ -369,6 +381,9 @@ namespace osu.Game.Screens.Menu const float scale_adjust_cutoff = 0.4f; + if (SeasonalUI.ENABLED) + updateHat(); + if (musicController.CurrentTrack.IsRunning) { float maxAmplitude = lastBeatIndex >= 0 ? musicController.CurrentTrack.CurrentAmplitudes.Maximum : 0; @@ -382,6 +397,38 @@ namespace osu.Game.Screens.Menu } } + private bool hasHat; + + private void updateHat() + { + if (hat == null) + return; + + bool shouldHat = DrawWidth * Scale.X < 400; + + if (shouldHat != hasHat) + { + hasHat = shouldHat; + + if (hasHat) + { + hat.Delay(400) + .Then() + .MoveTo(new Vector2(120, 160)) + .RotateTo(0) + .RotateTo(-20, 500, Easing.OutQuint) + .FadeIn(250, Easing.OutQuint); + } + else + { + hat.Delay(100) + .Then() + .MoveToOffset(new Vector2(0, -5), 500, Easing.OutQuint) + .FadeOut(500, Easing.OutQuint); + } + } + } + public override bool HandlePositionalInput => base.HandlePositionalInput && Alpha > 0.2f; protected override bool OnMouseDown(MouseDownEvent e) @@ -459,6 +506,9 @@ namespace osu.Game.Screens.Menu private Container currentProxyTarget; private Drawable proxy; + [CanBeNull] + private readonly Sprite hat; + public void StopSamplePlayback() => sampleClickChannel?.Stop(); public Drawable ProxyToContainer(Container c) From 4924a35c3133345ebc314d1fea03c8c69d8665c4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Dec 2024 19:14:48 +0900 Subject: [PATCH 08/19] Fix light expiry --- osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs b/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs index 7ba4e998d2..fb16e8e0bb 100644 --- a/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs +++ b/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -137,9 +136,9 @@ namespace osu.Game.Screens.Menu .FadeInFromZero(150) .Then() .FadeOutFromOne(1000, Easing.In); - - light.Expire(); } + + light.Expire(); } public partial class Light : CompositeDrawable From 8c7af79f9667e1cd4db2e1ec3f480f98542b5945 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Dec 2024 14:21:45 +0900 Subject: [PATCH 09/19] Tidy up for pull request attempt --- .../TestSceneMainMenuSeasonalLighting.cs | 6 +-- osu.Game/Screens/Menu/IntroChristmas.cs | 5 ++- .../Screens/Menu/MainMenuSeasonalLighting.cs | 38 +++++++++++++------ osu.Game/Screens/Menu/OsuLogo.cs | 2 +- osu.Game/Screens/SeasonalUI.cs | 8 ++-- 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs index bfdc07fba6..81862da9df 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs @@ -6,7 +6,6 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Beatmaps; -using osu.Game.Database; using osu.Game.Screens.Menu; namespace osu.Game.Tests.Visual.Menus @@ -16,15 +15,12 @@ namespace osu.Game.Tests.Visual.Menus [Resolved] private BeatmapManager beatmaps { get; set; } = null!; - [Resolved] - private RealmAccess realm { get; set; } = null!; - [SetUpSteps] public void SetUpSteps() { AddStep("prepare beatmap", () => { - var setInfo = beatmaps.QueryBeatmapSet(b => b.Protected && b.Hash == "7e26183e72a496f672c3a21292e6b469fdecd084d31c259ea10a31df5b46cd77"); + var setInfo = beatmaps.QueryBeatmapSet(b => b.Protected && b.Hash == IntroChristmas.CHRISTMAS_BEATMAP_SET_HASH); Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo!.Value.Beatmaps.First()); }); diff --git a/osu.Game/Screens/Menu/IntroChristmas.cs b/osu.Game/Screens/Menu/IntroChristmas.cs index 0a1cf32b85..273baa3c52 100644 --- a/osu.Game/Screens/Menu/IntroChristmas.cs +++ b/osu.Game/Screens/Menu/IntroChristmas.cs @@ -22,7 +22,10 @@ namespace osu.Game.Screens.Menu { public partial class IntroChristmas : IntroScreen { - protected override string BeatmapHash => "7e26183e72a496f672c3a21292e6b469fdecd084d31c259ea10a31df5b46cd77"; + // nekodex - circle the halls + public const string CHRISTMAS_BEATMAP_SET_HASH = "7e26183e72a496f672c3a21292e6b469fdecd084d31c259ea10a31df5b46cd77"; + + protected override string BeatmapHash => CHRISTMAS_BEATMAP_SET_HASH; protected override string BeatmapFile => "christmas2024.osz"; diff --git a/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs b/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs index fb16e8e0bb..f46a1387ab 100644 --- a/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs +++ b/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs @@ -31,11 +31,13 @@ namespace osu.Game.Screens.Menu private List hitObjects = null!; - [Resolved] - private RulesetStore rulesets { get; set; } = null!; + private RulesetInfo? osuRuleset; + + private int? lastObjectIndex; public MainMenuSeasonalLighting() { + // match beatmap playfield RelativeChildSize = new Vector2(512, 384); RelativeSizeAxes = Axes.X; @@ -45,23 +47,37 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(IBindable working) + private void load(IBindable working, RulesetStore rulesets) { this.working = working.GetBoundCopy(); this.working.BindValueChanged(_ => Scheduler.AddOnce(updateBeatmap), true); + + // operate in osu! ruleset to keep things simple for now. + osuRuleset = rulesets.GetRuleset(0); } private void updateBeatmap() { lastObjectIndex = null; + + if (osuRuleset == null) + { + beatmapClock = new InterpolatingFramedClock(Clock); + hitObjects = new List(); + return; + } + + // Intentionally maintain separately so the lighting is not in audio clock space (it shouldn't rewind etc.) beatmapClock = new InterpolatingFramedClock(new FramedClock(working.Value.Track)); - hitObjects = working.Value.GetPlayableBeatmap(rulesets.GetRuleset(0)).HitObjects.SelectMany(h => h.NestedHitObjects.Prepend(h)) + + hitObjects = working.Value + .GetPlayableBeatmap(osuRuleset) + .HitObjects + .SelectMany(h => h.NestedHitObjects.Prepend(h)) .OrderBy(h => h.StartTime) .ToList(); } - private int? lastObjectIndex; - protected override void Update() { base.Update(); @@ -116,19 +132,19 @@ namespace osu.Game.Screens.Menu } else { - // default green + // default are green Color4 col = SeasonalUI.PRIMARY_COLOUR_2; - // whistle red + // whistles are red if (h.Samples.Any(s => s.Name == HitSampleInfo.HIT_WHISTLE)) col = SeasonalUI.PRIMARY_COLOUR_1; - // clap is third colour + // clap is third ambient (yellow) colour else if (h.Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)) col = SeasonalUI.AMBIENT_COLOUR_1; light.Colour = col; - // finish larger lighting + // finish results in larger lighting if (h.Samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH)) light.Scale = new Vector2(3); @@ -141,7 +157,7 @@ namespace osu.Game.Screens.Menu light.Expire(); } - public partial class Light : CompositeDrawable + private partial class Light : CompositeDrawable { private readonly Circle circle; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 2c62a10a8f..272f53e087 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -163,7 +163,7 @@ namespace osu.Game.Screens.Menu new Container { AutoSizeAxes = Axes.Both, - Children = new Drawable[] + Children = new[] { logoContainer = new CircularContainer { diff --git a/osu.Game/Screens/SeasonalUI.cs b/osu.Game/Screens/SeasonalUI.cs index ebe4d74301..fc2303f285 100644 --- a/osu.Game/Screens/SeasonalUI.cs +++ b/osu.Game/Screens/SeasonalUI.cs @@ -10,12 +10,12 @@ namespace osu.Game.Screens { public static readonly bool ENABLED = true; - public static readonly Color4 PRIMARY_COLOUR_1 = Color4Extensions.FromHex("D32F2F"); + public static readonly Color4 PRIMARY_COLOUR_1 = Color4Extensions.FromHex(@"D32F2F"); - public static readonly Color4 PRIMARY_COLOUR_2 = Color4Extensions.FromHex("388E3C"); + public static readonly Color4 PRIMARY_COLOUR_2 = Color4Extensions.FromHex(@"388E3C"); - public static readonly Color4 AMBIENT_COLOUR_1 = Color4Extensions.FromHex("FFC"); + public static readonly Color4 AMBIENT_COLOUR_1 = Color4Extensions.FromHex(@"FFFFCC"); - public static readonly Color4 AMBIENT_COLOUR_2 = Color4Extensions.FromHex("FFE4B5"); + public static readonly Color4 AMBIENT_COLOUR_2 = Color4Extensions.FromHex(@"FFE4B5"); } } From e5dbf9ce453e359a2e07b375ba9cbdcbe159b764 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Dec 2024 14:46:34 +0900 Subject: [PATCH 10/19] Subclass osu logo instead of adding much code to it --- .../TestSceneMainMenuSeasonalLighting.cs | 1 + .../Visual/UserInterface/TestSceneOsuLogo.cs | 29 ++++++- osu.Game/OsuGame.cs | 6 +- osu.Game/Screens/Loader.cs | 3 +- osu.Game/Screens/Menu/IntroChristmas.cs | 3 +- osu.Game/Screens/Menu/MainMenu.cs | 5 +- .../Screens/Menu/MenuLogoVisualisation.cs | 5 +- osu.Game/Screens/Menu/MenuSideFlashes.cs | 11 +-- osu.Game/Screens/Menu/OsuLogo.cs | 83 ++++--------------- .../MainMenuSeasonalLighting.cs | 14 ++-- osu.Game/Seasonal/OsuLogoChristmas.cs | 74 +++++++++++++++++ .../SeasonalUIConfig.cs} | 7 +- 12 files changed, 148 insertions(+), 93 deletions(-) rename osu.Game/{Screens/Menu => Seasonal}/MainMenuSeasonalLighting.cs (93%) create mode 100644 osu.Game/Seasonal/OsuLogoChristmas.cs rename osu.Game/{Screens/SeasonalUI.cs => Seasonal/SeasonalUIConfig.cs} (78%) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs index 81862da9df..bf499f1beb 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs @@ -7,6 +7,7 @@ using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Screens.Menu; +using osu.Game.Seasonal; namespace osu.Game.Tests.Visual.Menus { diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs index c112d26870..27d2ff97fa 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Game.Screens.Menu; +using osu.Game.Seasonal; using osuTK; namespace osu.Game.Tests.Visual.UserInterface @@ -12,6 +13,19 @@ namespace osu.Game.Tests.Visual.UserInterface { private OsuLogo? logo; + private float scale = 1; + + protected override void LoadComplete() + { + base.LoadComplete(); + + AddSliderStep("scale", 0.1, 2, 1, scale => + { + if (logo != null) + Child.Scale = new Vector2(this.scale = (float)scale); + }); + } + [Test] public void TestBasic() { @@ -21,13 +35,22 @@ namespace osu.Game.Tests.Visual.UserInterface { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Scale = new Vector2(scale), }; }); + } - AddSliderStep("scale", 0.1, 2, 1, scale => + [Test] + public void TestChristmas() + { + AddStep("Add logo", () => { - if (logo != null) - Child.Scale = new Vector2((float)scale); + Child = logo = new OsuLogoChristmas + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(scale), + }; }); } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index e808e570c7..0dd1746aa4 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -69,6 +69,7 @@ using osu.Game.Screens.OnlinePlay.Multiplayer; using osu.Game.Screens.Play; using osu.Game.Screens.Ranking; using osu.Game.Screens.Select; +using osu.Game.Seasonal; using osu.Game.Skinning; using osu.Game.Updater; using osu.Game.Users; @@ -362,7 +363,10 @@ namespace osu.Game { SentryLogger.AttachUser(API.LocalUser); - dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 }); + if (SeasonalUIConfig.ENABLED) + dependencies.CacheAs(osuLogo = new OsuLogoChristmas { Alpha = 0 }); + else + dependencies.CacheAs(osuLogo = new OsuLogo { Alpha = 0 }); // bind config int to database RulesetInfo configRuleset = LocalConfig.GetBindable(OsuSetting.Ruleset); diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index 811e4600eb..dfa5d2c369 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -15,6 +15,7 @@ using osu.Framework.Screens; using osu.Framework.Threading; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; +using osu.Game.Seasonal; using IntroSequence = osu.Game.Configuration.IntroSequence; namespace osu.Game.Screens @@ -37,7 +38,7 @@ namespace osu.Game.Screens private IntroScreen getIntroSequence() { - if (SeasonalUI.ENABLED) + if (SeasonalUIConfig.ENABLED) return new IntroChristmas(createMainMenu); if (introSequence == IntroSequence.Random) diff --git a/osu.Game/Screens/Menu/IntroChristmas.cs b/osu.Game/Screens/Menu/IntroChristmas.cs index 273baa3c52..aa16f33c3d 100644 --- a/osu.Game/Screens/Menu/IntroChristmas.cs +++ b/osu.Game/Screens/Menu/IntroChristmas.cs @@ -15,6 +15,7 @@ using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Seasonal; using osuTK; using osuTK.Graphics; @@ -302,7 +303,7 @@ namespace osu.Game.Screens.Menu float x = 0.5f + 0.5f * randomRadius * (float)Math.Cos(angle); float y = 0.5f + 0.5f * randomRadius * (float)Math.Sin(angle); - Color4 christmasColour = RNG.NextBool() ? SeasonalUI.PRIMARY_COLOUR_1 : SeasonalUI.PRIMARY_COLOUR_2; + Color4 christmasColour = RNG.NextBool() ? SeasonalUIConfig.PRIMARY_COLOUR_1 : SeasonalUIConfig.PRIMARY_COLOUR_2; Drawable triangle = new Triangle { diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 42aa2342da..a4b269ad0d 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -35,6 +35,7 @@ using osu.Game.Screens.OnlinePlay.DailyChallenge; using osu.Game.Screens.OnlinePlay.Multiplayer; using osu.Game.Screens.OnlinePlay.Playlists; using osu.Game.Screens.Select; +using osu.Game.Seasonal; using osuTK; using osuTK.Graphics; @@ -124,7 +125,7 @@ namespace osu.Game.Screens.Menu AddRangeInternal(new[] { - SeasonalUI.ENABLED ? new MainMenuSeasonalLighting() : Empty(), + SeasonalUIConfig.ENABLED ? new MainMenuSeasonalLighting() : Empty(), buttonsContainer = new ParallaxContainer { ParallaxAmount = 0.01f, @@ -168,7 +169,7 @@ namespace osu.Game.Screens.Menu Margin = new MarginPadding { Right = 15, Top = 5 } }, // For now, this is too much alongside the seasonal lighting. - SeasonalUI.ENABLED ? Empty() : new KiaiMenuFountains(), + SeasonalUIConfig.ENABLED ? Empty() : new KiaiMenuFountains(), bottomElementsFlow = new FillFlowContainer { AutoSizeAxes = Axes.Both, diff --git a/osu.Game/Screens/Menu/MenuLogoVisualisation.cs b/osu.Game/Screens/Menu/MenuLogoVisualisation.cs index 4537b79b62..32b5c706a3 100644 --- a/osu.Game/Screens/Menu/MenuLogoVisualisation.cs +++ b/osu.Game/Screens/Menu/MenuLogoVisualisation.cs @@ -7,6 +7,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; +using osu.Game.Seasonal; using osu.Game.Skinning; using osuTK.Graphics; @@ -29,8 +30,8 @@ namespace osu.Game.Screens.Menu private void updateColour() { - if (SeasonalUI.ENABLED) - Colour = SeasonalUI.AMBIENT_COLOUR_1; + if (SeasonalUIConfig.ENABLED) + Colour = SeasonalUIConfig.AMBIENT_COLOUR_1; else if (user.Value?.IsSupporter ?? false) Colour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? Color4.White; else diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index cc2d22a7fa..808da5dd47 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -18,6 +18,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; +using osu.Game.Seasonal; using osu.Game.Skinning; using osuTK.Graphics; @@ -68,7 +69,7 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, RelativeSizeAxes = Axes.Y, - Width = box_width * (SeasonalUI.ENABLED ? 4 : 2), + Width = box_width * (SeasonalUIConfig.ENABLED ? 4 : 2), Height = 1.5f, // align off-screen to make sure our edges don't become visible during parallax. X = -box_width, @@ -80,7 +81,7 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, RelativeSizeAxes = Axes.Y, - Width = box_width * (SeasonalUI.ENABLED ? 4 : 2), + Width = box_width * (SeasonalUIConfig.ENABLED ? 4 : 2), Height = 1.5f, X = box_width, Alpha = 0, @@ -105,7 +106,7 @@ namespace osu.Game.Screens.Menu private void flash(Drawable d, double beatLength, bool kiai, ChannelAmplitudes amplitudes) { - if (SeasonalUI.ENABLED) + if (SeasonalUIConfig.ENABLED) updateColour(); d.FadeTo(Math.Clamp(0.1f + ((ReferenceEquals(d, leftBox) ? amplitudes.LeftChannel : amplitudes.RightChannel) - amplitude_dead_zone) / (kiai ? kiai_multiplier : alpha_multiplier), 0.1f, 1), @@ -118,8 +119,8 @@ namespace osu.Game.Screens.Menu { Color4 baseColour = colours.Blue; - if (SeasonalUI.ENABLED) - baseColour = RNG.NextBool() ? SeasonalUI.PRIMARY_COLOUR_1 : SeasonalUI.PRIMARY_COLOUR_2; + if (SeasonalUIConfig.ENABLED) + baseColour = RNG.NextBool() ? SeasonalUIConfig.PRIMARY_COLOUR_1 : SeasonalUIConfig.PRIMARY_COLOUR_2; else if (user.Value?.IsSupporter ?? false) baseColour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? baseColour; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 272f53e087..dc2dfefddb 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -4,7 +4,6 @@ #nullable disable using System; -using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -54,8 +53,10 @@ namespace osu.Game.Screens.Menu private Sample sampleClick; private SampleChannel sampleClickChannel; - private Sample sampleBeat; - private Sample sampleDownbeat; + protected virtual double BeatSampleVariance => 0.1; + + protected Sample SampleBeat; + protected Sample SampleDownbeat; private readonly Container colourAndTriangles; private readonly TrianglesV2 triangles; @@ -160,10 +161,10 @@ namespace osu.Game.Screens.Menu Alpha = visualizer_default_alpha, Size = SCALE_ADJUST }, - new Container + LogoElements = new Container { AutoSizeAxes = Axes.Both, - Children = new[] + Children = new Drawable[] { logoContainer = new CircularContainer { @@ -212,15 +213,6 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.Centre, Origin = Anchor.Centre, }, - SeasonalUI.ENABLED - ? hat = new Sprite - { - BypassAutoSizeAxes = Axes.Both, - Alpha = 0, - Origin = Anchor.BottomCentre, - Scale = new Vector2(-1, 1), - } - : Empty(), } }, impactContainer = new CircularContainer @@ -253,6 +245,8 @@ namespace osu.Game.Screens.Menu }; } + public Container LogoElements { get; private set; } + /// /// Schedule a new external animation. Handled queueing and finishing previous animations in a sane way. /// @@ -282,20 +276,11 @@ namespace osu.Game.Screens.Menu { sampleClick = audio.Samples.Get(@"Menu/osu-logo-select"); - if (SeasonalUI.ENABLED) - { - sampleDownbeat = sampleBeat = audio.Samples.Get(@"Menu/osu-logo-heartbeat-bell"); - } - else - { - sampleBeat = audio.Samples.Get(@"Menu/osu-logo-heartbeat"); - sampleDownbeat = audio.Samples.Get(@"Menu/osu-logo-downbeat"); - } + SampleBeat = audio.Samples.Get(@"Menu/osu-logo-heartbeat"); + SampleDownbeat = audio.Samples.Get(@"Menu/osu-logo-downbeat"); logo.Texture = textures.Get(@"Menu/logo"); ripple.Texture = textures.Get(@"Menu/logo"); - if (hat != null) - hat.Texture = textures.Get(@"Menu/hat"); } private int lastBeatIndex; @@ -318,15 +303,13 @@ namespace osu.Game.Screens.Menu { if (beatIndex % timingPoint.TimeSignature.Numerator == 0) { - sampleDownbeat?.Play(); + SampleDownbeat?.Play(); } else { - var channel = sampleBeat.GetChannel(); - if (SeasonalUI.ENABLED) - channel.Frequency.Value = 0.99 + RNG.NextDouble(0.02); - else - channel.Frequency.Value = 0.95 + RNG.NextDouble(0.1); + var channel = SampleBeat.GetChannel(); + + channel.Frequency.Value = 1 - BeatSampleVariance / 2 + RNG.NextDouble(BeatSampleVariance); channel.Play(); } }); @@ -381,9 +364,6 @@ namespace osu.Game.Screens.Menu const float scale_adjust_cutoff = 0.4f; - if (SeasonalUI.ENABLED) - updateHat(); - if (musicController.CurrentTrack.IsRunning) { float maxAmplitude = lastBeatIndex >= 0 ? musicController.CurrentTrack.CurrentAmplitudes.Maximum : 0; @@ -397,38 +377,6 @@ namespace osu.Game.Screens.Menu } } - private bool hasHat; - - private void updateHat() - { - if (hat == null) - return; - - bool shouldHat = DrawWidth * Scale.X < 400; - - if (shouldHat != hasHat) - { - hasHat = shouldHat; - - if (hasHat) - { - hat.Delay(400) - .Then() - .MoveTo(new Vector2(120, 160)) - .RotateTo(0) - .RotateTo(-20, 500, Easing.OutQuint) - .FadeIn(250, Easing.OutQuint); - } - else - { - hat.Delay(100) - .Then() - .MoveToOffset(new Vector2(0, -5), 500, Easing.OutQuint) - .FadeOut(500, Easing.OutQuint); - } - } - } - public override bool HandlePositionalInput => base.HandlePositionalInput && Alpha > 0.2f; protected override bool OnMouseDown(MouseDownEvent e) @@ -506,9 +454,6 @@ namespace osu.Game.Screens.Menu private Container currentProxyTarget; private Drawable proxy; - [CanBeNull] - private readonly Sprite hat; - public void StopSamplePlayback() => sampleClickChannel?.Stop(); public Drawable ProxyToContainer(Container c) diff --git a/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs b/osu.Game/Seasonal/MainMenuSeasonalLighting.cs similarity index 93% rename from osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs rename to osu.Game/Seasonal/MainMenuSeasonalLighting.cs index f46a1387ab..a382785499 100644 --- a/osu.Game/Screens/Menu/MainMenuSeasonalLighting.cs +++ b/osu.Game/Seasonal/MainMenuSeasonalLighting.cs @@ -21,7 +21,7 @@ using osu.Game.Rulesets.Objects.Types; using osuTK; using osuTK.Graphics; -namespace osu.Game.Screens.Menu +namespace osu.Game.Seasonal { public partial class MainMenuSeasonalLighting : CompositeDrawable { @@ -121,7 +121,7 @@ namespace osu.Game.Screens.Menu if (h.GetType().Name.Contains("Tick")) { - light.Colour = SeasonalUI.AMBIENT_COLOUR_1; + light.Colour = SeasonalUIConfig.AMBIENT_COLOUR_1; light.Scale = new Vector2(0.5f); light .FadeInFromZero(250) @@ -133,14 +133,14 @@ namespace osu.Game.Screens.Menu else { // default are green - Color4 col = SeasonalUI.PRIMARY_COLOUR_2; + Color4 col = SeasonalUIConfig.PRIMARY_COLOUR_2; // whistles are red if (h.Samples.Any(s => s.Name == HitSampleInfo.HIT_WHISTLE)) - col = SeasonalUI.PRIMARY_COLOUR_1; + col = SeasonalUIConfig.PRIMARY_COLOUR_1; // clap is third ambient (yellow) colour else if (h.Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP)) - col = SeasonalUI.AMBIENT_COLOUR_1; + col = SeasonalUIConfig.AMBIENT_COLOUR_1; light.Colour = col; @@ -184,12 +184,12 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(12), - Colour = SeasonalUI.AMBIENT_COLOUR_1, + Colour = SeasonalUIConfig.AMBIENT_COLOUR_1, Blending = BlendingParameters.Additive, EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow, - Colour = SeasonalUI.AMBIENT_COLOUR_2, + Colour = SeasonalUIConfig.AMBIENT_COLOUR_2, Radius = 80, } } diff --git a/osu.Game/Seasonal/OsuLogoChristmas.cs b/osu.Game/Seasonal/OsuLogoChristmas.cs new file mode 100644 index 0000000000..ec9cac94ea --- /dev/null +++ b/osu.Game/Seasonal/OsuLogoChristmas.cs @@ -0,0 +1,74 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Screens.Menu; +using osuTK; + +namespace osu.Game.Seasonal +{ + public partial class OsuLogoChristmas : OsuLogo + { + protected override double BeatSampleVariance => 0.02; + + private Sprite? hat; + + private bool hasHat; + + [BackgroundDependencyLoader] + private void load(TextureStore textures, AudioManager audio) + { + LogoElements.Add(hat = new Sprite + { + BypassAutoSizeAxes = Axes.Both, + Alpha = 0, + Origin = Anchor.BottomCentre, + Scale = new Vector2(-1, 1), + Texture = textures.Get(@"Menu/hat"), + }); + + // override base samples with our preferred ones. + SampleDownbeat = SampleBeat = audio.Samples.Get(@"Menu/osu-logo-heartbeat-bell"); + } + + protected override void Update() + { + base.Update(); + updateHat(); + } + + private void updateHat() + { + if (hat == null) + return; + + bool shouldHat = DrawWidth * Scale.X < 400; + + if (shouldHat != hasHat) + { + hasHat = shouldHat; + + if (hasHat) + { + hat.Delay(400) + .Then() + .MoveTo(new Vector2(120, 160)) + .RotateTo(0) + .RotateTo(-20, 500, Easing.OutQuint) + .FadeIn(250, Easing.OutQuint); + } + else + { + hat.Delay(100) + .Then() + .MoveToOffset(new Vector2(0, -5), 500, Easing.OutQuint) + .FadeOut(500, Easing.OutQuint); + } + } + } + } +} diff --git a/osu.Game/Screens/SeasonalUI.cs b/osu.Game/Seasonal/SeasonalUIConfig.cs similarity index 78% rename from osu.Game/Screens/SeasonalUI.cs rename to osu.Game/Seasonal/SeasonalUIConfig.cs index fc2303f285..060913a8bf 100644 --- a/osu.Game/Screens/SeasonalUI.cs +++ b/osu.Game/Seasonal/SeasonalUIConfig.cs @@ -4,9 +4,12 @@ using osu.Framework.Extensions.Color4Extensions; using osuTK.Graphics; -namespace osu.Game.Screens +namespace osu.Game.Seasonal { - public static class SeasonalUI + /// + /// General configuration setting for seasonal event adjustments to the game. + /// + public static class SeasonalUIConfig { public static readonly bool ENABLED = true; From 2a720ef200897f0430a630d2d565ab52c8875278 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Dec 2024 14:51:33 +0900 Subject: [PATCH 11/19] Move christmas intro screen to seasonal namespace --- osu.Game.Tests/Visual/Menus/TestSceneIntroChristmas.cs | 1 + .../Visual/Menus/TestSceneMainMenuSeasonalLighting.cs | 1 - osu.Game/{Screens/Menu => Seasonal}/IntroChristmas.cs | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) rename osu.Game/{Screens/Menu => Seasonal}/IntroChristmas.cs (99%) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneIntroChristmas.cs b/osu.Game.Tests/Visual/Menus/TestSceneIntroChristmas.cs index 13377f49df..0398b4fbb6 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneIntroChristmas.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneIntroChristmas.cs @@ -3,6 +3,7 @@ using NUnit.Framework; using osu.Game.Screens.Menu; +using osu.Game.Seasonal; namespace osu.Game.Tests.Visual.Menus { diff --git a/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs index bf499f1beb..11356f7eeb 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs @@ -6,7 +6,6 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Beatmaps; -using osu.Game.Screens.Menu; using osu.Game.Seasonal; namespace osu.Game.Tests.Visual.Menus diff --git a/osu.Game/Screens/Menu/IntroChristmas.cs b/osu.Game/Seasonal/IntroChristmas.cs similarity index 99% rename from osu.Game/Screens/Menu/IntroChristmas.cs rename to osu.Game/Seasonal/IntroChristmas.cs index aa16f33c3d..ac3286f277 100644 --- a/osu.Game/Screens/Menu/IntroChristmas.cs +++ b/osu.Game/Seasonal/IntroChristmas.cs @@ -15,11 +15,11 @@ using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; -using osu.Game.Seasonal; +using osu.Game.Screens.Menu; using osuTK; using osuTK.Graphics; -namespace osu.Game.Screens.Menu +namespace osu.Game.Seasonal { public partial class IntroChristmas : IntroScreen { From ad4a8a1e0a345c75b0f43186f00d985e653ad7bc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Dec 2024 14:58:45 +0900 Subject: [PATCH 12/19] Subclass menu flashes instead of adding local code to it --- osu.Game/Screens/Menu/MainMenu.cs | 2 +- osu.Game/Screens/Menu/MenuSideFlashes.cs | 31 +++++++++++++------- osu.Game/Seasonal/SeasonalMenuSideFlashes.cs | 18 ++++++++++++ 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 osu.Game/Seasonal/SeasonalMenuSideFlashes.cs diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index a4b269ad0d..58d97bfe16 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -161,7 +161,7 @@ namespace osu.Game.Screens.Menu } }, logoTarget = new Container { RelativeSizeAxes = Axes.Both, }, - sideFlashes = new MenuSideFlashes(), + sideFlashes = SeasonalUIConfig.ENABLED ? new SeasonalMenuSideFlashes() : new MenuSideFlashes(), songTicker = new SongTicker { Anchor = Anchor.TopRight, diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index 808da5dd47..426896825e 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -11,14 +11,12 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Shapes; -using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; -using osu.Game.Seasonal; using osu.Game.Skinning; using osuTK.Graphics; @@ -26,6 +24,10 @@ namespace osu.Game.Screens.Menu { public partial class MenuSideFlashes : BeatSyncedContainer { + protected virtual bool RefreshColoursEveryFlash => false; + + protected virtual float Intensity => 2; + private readonly IBindable beatmap = new Bindable(); private Box leftBox; @@ -69,7 +71,7 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, RelativeSizeAxes = Axes.Y, - Width = box_width * (SeasonalUIConfig.ENABLED ? 4 : 2), + Width = box_width * Intensity, Height = 1.5f, // align off-screen to make sure our edges don't become visible during parallax. X = -box_width, @@ -81,7 +83,7 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, RelativeSizeAxes = Axes.Y, - Width = box_width * (SeasonalUIConfig.ENABLED ? 4 : 2), + Width = box_width * Intensity, Height = 1.5f, X = box_width, Alpha = 0, @@ -89,8 +91,11 @@ namespace osu.Game.Screens.Menu } }; - user.ValueChanged += _ => updateColour(); - skin.BindValueChanged(_ => updateColour(), true); + if (!RefreshColoursEveryFlash) + { + user.ValueChanged += _ => updateColour(); + skin.BindValueChanged(_ => updateColour(), true); + } } protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes) @@ -106,7 +111,7 @@ namespace osu.Game.Screens.Menu private void flash(Drawable d, double beatLength, bool kiai, ChannelAmplitudes amplitudes) { - if (SeasonalUIConfig.ENABLED) + if (RefreshColoursEveryFlash) updateColour(); d.FadeTo(Math.Clamp(0.1f + ((ReferenceEquals(d, leftBox) ? amplitudes.LeftChannel : amplitudes.RightChannel) - amplitude_dead_zone) / (kiai ? kiai_multiplier : alpha_multiplier), 0.1f, 1), @@ -115,15 +120,19 @@ namespace osu.Game.Screens.Menu .FadeOut(beatLength, Easing.In); } - private void updateColour() + protected virtual Color4 GetBaseColour() { Color4 baseColour = colours.Blue; - if (SeasonalUIConfig.ENABLED) - baseColour = RNG.NextBool() ? SeasonalUIConfig.PRIMARY_COLOUR_1 : SeasonalUIConfig.PRIMARY_COLOUR_2; - else if (user.Value?.IsSupporter ?? false) + if (user.Value?.IsSupporter ?? false) baseColour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? baseColour; + return baseColour; + } + + private void updateColour() + { + var baseColour = GetBaseColour(); // linear colour looks better in this case, so let's use it for now. Color4 gradientDark = baseColour.Opacity(0).ToLinear(); Color4 gradientLight = baseColour.Opacity(0.6f).ToLinear(); diff --git a/osu.Game/Seasonal/SeasonalMenuSideFlashes.cs b/osu.Game/Seasonal/SeasonalMenuSideFlashes.cs new file mode 100644 index 0000000000..46a0a973bb --- /dev/null +++ b/osu.Game/Seasonal/SeasonalMenuSideFlashes.cs @@ -0,0 +1,18 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Utils; +using osu.Game.Screens.Menu; +using osuTK.Graphics; + +namespace osu.Game.Seasonal +{ + public partial class SeasonalMenuSideFlashes : MenuSideFlashes + { + protected override bool RefreshColoursEveryFlash => true; + + protected override float Intensity => 4; + + protected override Color4 GetBaseColour() => RNG.NextBool() ? SeasonalUIConfig.PRIMARY_COLOUR_1 : SeasonalUIConfig.PRIMARY_COLOUR_2; + } +} From 8e9377914d96a4d65a96335da0cd169e3721128d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Dec 2024 15:04:37 +0900 Subject: [PATCH 13/19] Subclass menu logo visualisation --- .../Screens/Menu/MenuLogoVisualisation.cs | 19 +++++++------------ osu.Game/Screens/Menu/OsuLogo.cs | 16 +++++++++------- osu.Game/Seasonal/OsuLogoChristmas.cs | 2 ++ .../Seasonal/SeasonalMenuLogoVisualisation.cs | 12 ++++++++++++ 4 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 osu.Game/Seasonal/SeasonalMenuLogoVisualisation.cs diff --git a/osu.Game/Screens/Menu/MenuLogoVisualisation.cs b/osu.Game/Screens/Menu/MenuLogoVisualisation.cs index 32b5c706a3..f152c0c93c 100644 --- a/osu.Game/Screens/Menu/MenuLogoVisualisation.cs +++ b/osu.Game/Screens/Menu/MenuLogoVisualisation.cs @@ -1,22 +1,19 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; -using osu.Game.Seasonal; using osu.Game.Skinning; using osuTK.Graphics; namespace osu.Game.Screens.Menu { - internal partial class MenuLogoVisualisation : LogoVisualisation + public partial class MenuLogoVisualisation : LogoVisualisation { - private IBindable user; - private Bindable skin; + private IBindable user = null!; + private Bindable skin = null!; [BackgroundDependencyLoader] private void load(IAPIProvider api, SkinManager skinManager) @@ -24,15 +21,13 @@ namespace osu.Game.Screens.Menu user = api.LocalUser.GetBoundCopy(); skin = skinManager.CurrentSkin.GetBoundCopy(); - user.ValueChanged += _ => updateColour(); - skin.BindValueChanged(_ => updateColour(), true); + user.ValueChanged += _ => UpdateColour(); + skin.BindValueChanged(_ => UpdateColour(), true); } - private void updateColour() + protected virtual void UpdateColour() { - if (SeasonalUIConfig.ENABLED) - Colour = SeasonalUIConfig.AMBIENT_COLOUR_1; - else if (user.Value?.IsSupporter ?? false) + if (user.Value?.IsSupporter ?? false) Colour = skin.Value.GetConfig(GlobalSkinColours.MenuGlow)?.Value ?? Color4.White; else Colour = Color4.White; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index dc2dfefddb..31f47c1349 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -53,6 +53,8 @@ namespace osu.Game.Screens.Menu private Sample sampleClick; private SampleChannel sampleClickChannel; + protected virtual MenuLogoVisualisation CreateMenuLogoVisualisation() => new MenuLogoVisualisation(); + protected virtual double BeatSampleVariance => 0.1; protected Sample SampleBeat; @@ -153,14 +155,14 @@ namespace osu.Game.Screens.Menu AutoSizeAxes = Axes.Both, Children = new Drawable[] { - visualizer = new MenuLogoVisualisation + visualizer = CreateMenuLogoVisualisation().With(v => { - RelativeSizeAxes = Axes.Both, - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Alpha = visualizer_default_alpha, - Size = SCALE_ADJUST - }, + v.RelativeSizeAxes = Axes.Both; + v.Origin = Anchor.Centre; + v.Anchor = Anchor.Centre; + v.Alpha = visualizer_default_alpha; + v.Size = SCALE_ADJUST; + }), LogoElements = new Container { AutoSizeAxes = Axes.Both, diff --git a/osu.Game/Seasonal/OsuLogoChristmas.cs b/osu.Game/Seasonal/OsuLogoChristmas.cs index ec9cac94ea..8975a69c32 100644 --- a/osu.Game/Seasonal/OsuLogoChristmas.cs +++ b/osu.Game/Seasonal/OsuLogoChristmas.cs @@ -19,6 +19,8 @@ namespace osu.Game.Seasonal private bool hasHat; + protected override MenuLogoVisualisation CreateMenuLogoVisualisation() => new SeasonalMenuLogoVisualisation(); + [BackgroundDependencyLoader] private void load(TextureStore textures, AudioManager audio) { diff --git a/osu.Game/Seasonal/SeasonalMenuLogoVisualisation.cs b/osu.Game/Seasonal/SeasonalMenuLogoVisualisation.cs new file mode 100644 index 0000000000..f00da3fe7e --- /dev/null +++ b/osu.Game/Seasonal/SeasonalMenuLogoVisualisation.cs @@ -0,0 +1,12 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Screens.Menu; + +namespace osu.Game.Seasonal +{ + internal partial class SeasonalMenuLogoVisualisation : MenuLogoVisualisation + { + protected override void UpdateColour() => Colour = SeasonalUIConfig.AMBIENT_COLOUR_1; + } +} From 3fc99904113036e4edd0fbd750e17605e900d953 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Dec 2024 15:28:33 +0900 Subject: [PATCH 14/19] Fix some failing tests --- .../Editor/TestSceneSliderVelocityAdjust.cs | 3 ++- .../Visual/Menus/TestSceneMainMenuSeasonalLighting.cs | 3 ++- osu.Game/Screens/Menu/IntroScreen.cs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderVelocityAdjust.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderVelocityAdjust.cs index 175cbeca6e..6690d043f8 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderVelocityAdjust.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderVelocityAdjust.cs @@ -7,6 +7,7 @@ using osu.Framework.Input; using osu.Framework.Testing; using osu.Framework.Utils; using osu.Game.Beatmaps; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.UI; using osu.Game.Screens.Edit; @@ -29,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor private Slider? slider => editorBeatmap.HitObjects.OfType().FirstOrDefault(); - private TimelineHitObjectBlueprint blueprint => editor.ChildrenOfType().FirstOrDefault()!; + private TimelineHitObjectBlueprint blueprint => editor.ChildrenOfType().FirstOrDefault(b => b.Item.GetEndTime() != b.Item.StartTime)!; private DifficultyPointPiece difficultyPointPiece => blueprint.ChildrenOfType().First(); diff --git a/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs index 11356f7eeb..46fddf823e 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneMainMenuSeasonalLighting.cs @@ -22,7 +22,8 @@ namespace osu.Game.Tests.Visual.Menus { var setInfo = beatmaps.QueryBeatmapSet(b => b.Protected && b.Hash == IntroChristmas.CHRISTMAS_BEATMAP_SET_HASH); - Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo!.Value.Beatmaps.First()); + if (setInfo != null) + Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo.Value.Beatmaps.First()); }); AddStep("create lighting", () => Child = new MainMenuSeasonalLighting()); diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index 9885c061a9..a5c2497618 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -12,6 +12,7 @@ using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; using osu.Framework.Bindables; +using osu.Framework.Development; using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Screens; @@ -200,7 +201,7 @@ namespace osu.Game.Screens.Menu PrepareMenuLoad(); LoadMenu(); - if (!Debugger.IsAttached) + if (!Debugger.IsAttached && !DebugUtils.IsNUnitRunning) { notifications.Post(new SimpleErrorNotification { From 7ebc9dd843b0b801bbfb3a1e72c1be669fff197a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Dec 2024 15:32:00 +0900 Subject: [PATCH 15/19] Disable seasonal for now --- osu.Game/Seasonal/SeasonalUIConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Seasonal/SeasonalUIConfig.cs b/osu.Game/Seasonal/SeasonalUIConfig.cs index 060913a8bf..b894a42108 100644 --- a/osu.Game/Seasonal/SeasonalUIConfig.cs +++ b/osu.Game/Seasonal/SeasonalUIConfig.cs @@ -11,7 +11,7 @@ namespace osu.Game.Seasonal /// public static class SeasonalUIConfig { - public static readonly bool ENABLED = true; + public static readonly bool ENABLED = false; public static readonly Color4 PRIMARY_COLOUR_1 = Color4Extensions.FromHex(@"D32F2F"); From f5b019807730a4b1d45158939f55299d54ac5cc6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Dec 2024 16:02:43 +0900 Subject: [PATCH 16/19] Fix test faiulres when seasonal set to `true` due to non-circles intro --- osu.Game/Screens/Loader.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index dfa5d2c369..9e7ff80f7c 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shaders; @@ -38,7 +39,9 @@ namespace osu.Game.Screens private IntroScreen getIntroSequence() { - if (SeasonalUIConfig.ENABLED) + // Headless tests run too fast to load non-circles intros correctly. + // They will hit the "audio can't play" notification and cause random test failures. + if (SeasonalUIConfig.ENABLED && !DebugUtils.IsNUnitRunning) return new IntroChristmas(createMainMenu); if (introSequence == IntroSequence.Random) From 139fb2cdd3a60faee550be9a9cb816c4943c9141 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Dec 2024 19:44:43 +0900 Subject: [PATCH 17/19] Revert and fix some tests still --- .../Editor/TestSceneSliderVelocityAdjust.cs | 3 +-- osu.Game/Screens/Menu/IntroScreen.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderVelocityAdjust.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderVelocityAdjust.cs index 6690d043f8..175cbeca6e 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderVelocityAdjust.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderVelocityAdjust.cs @@ -7,7 +7,6 @@ using osu.Framework.Input; using osu.Framework.Testing; using osu.Framework.Utils; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.UI; using osu.Game.Screens.Edit; @@ -30,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor private Slider? slider => editorBeatmap.HitObjects.OfType().FirstOrDefault(); - private TimelineHitObjectBlueprint blueprint => editor.ChildrenOfType().FirstOrDefault(b => b.Item.GetEndTime() != b.Item.StartTime)!; + private TimelineHitObjectBlueprint blueprint => editor.ChildrenOfType().FirstOrDefault()!; private DifficultyPointPiece difficultyPointPiece => blueprint.ChildrenOfType().First(); diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs index a5c2497618..9885c061a9 100644 --- a/osu.Game/Screens/Menu/IntroScreen.cs +++ b/osu.Game/Screens/Menu/IntroScreen.cs @@ -12,7 +12,6 @@ using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; using osu.Framework.Bindables; -using osu.Framework.Development; using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Screens; @@ -201,7 +200,7 @@ namespace osu.Game.Screens.Menu PrepareMenuLoad(); LoadMenu(); - if (!Debugger.IsAttached && !DebugUtils.IsNUnitRunning) + if (!Debugger.IsAttached) { notifications.Post(new SimpleErrorNotification { From 1fcd953e4a55c8d6576e64c737fa05b19a40a829 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 21 Dec 2024 20:17:27 +0900 Subject: [PATCH 18/19] Fetch ruleset before initialising beatmap the first time --- osu.Game/Seasonal/MainMenuSeasonalLighting.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Seasonal/MainMenuSeasonalLighting.cs b/osu.Game/Seasonal/MainMenuSeasonalLighting.cs index a382785499..718dd38fe7 100644 --- a/osu.Game/Seasonal/MainMenuSeasonalLighting.cs +++ b/osu.Game/Seasonal/MainMenuSeasonalLighting.cs @@ -49,11 +49,11 @@ namespace osu.Game.Seasonal [BackgroundDependencyLoader] private void load(IBindable working, RulesetStore rulesets) { - this.working = working.GetBoundCopy(); - this.working.BindValueChanged(_ => Scheduler.AddOnce(updateBeatmap), true); - // operate in osu! ruleset to keep things simple for now. osuRuleset = rulesets.GetRuleset(0); + + this.working = working.GetBoundCopy(); + this.working.BindValueChanged(_ => Scheduler.AddOnce(updateBeatmap), true); } private void updateBeatmap() From d897a31f0c5b63534f60d165857bd67123a854e4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 21 Dec 2024 20:30:00 +0900 Subject: [PATCH 19/19] Add extra safeties against null ref when rulesets are missing --- osu.Game/Seasonal/MainMenuSeasonalLighting.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Seasonal/MainMenuSeasonalLighting.cs b/osu.Game/Seasonal/MainMenuSeasonalLighting.cs index 718dd38fe7..30ad7acefe 100644 --- a/osu.Game/Seasonal/MainMenuSeasonalLighting.cs +++ b/osu.Game/Seasonal/MainMenuSeasonalLighting.cs @@ -27,7 +27,7 @@ namespace osu.Game.Seasonal { private IBindable working = null!; - private InterpolatingFramedClock beatmapClock = null!; + private InterpolatingFramedClock? beatmapClock; private List hitObjects = null!; @@ -82,6 +82,9 @@ namespace osu.Game.Seasonal { base.Update(); + if (osuRuleset == null || beatmapClock == null) + return; + Height = DrawWidth / 16 * 10; beatmapClock.ProcessFrame();