Skip to content

Commit

Permalink
Add logo hat
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Dec 19, 2024
1 parent 6dd8058 commit 6375281
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
11 changes: 10 additions & 1 deletion osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
}
50 changes: 50 additions & 0 deletions osu.Game/Screens/Menu/OsuLogo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#nullable disable

using System;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
Expand Down Expand Up @@ -211,6 +212,15 @@ public OsuLogo()
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
Expand Down Expand Up @@ -284,6 +294,8 @@ private void load(TextureStore textures, AudioManager audio)

logo.Texture = textures.Get(@"Menu/logo");
ripple.Texture = textures.Get(@"Menu/logo");
if (hat != null)
hat.Texture = textures.Get(@"Menu/hat");
}

private int lastBeatIndex;
Expand Down Expand Up @@ -369,6 +381,9 @@ protected override void Update()

const float scale_adjust_cutoff = 0.4f;

if (SeasonalUI.ENABLED)
updateHat();

if (musicController.CurrentTrack.IsRunning)
{
float maxAmplitude = lastBeatIndex >= 0 ? musicController.CurrentTrack.CurrentAmplitudes.Maximum : 0;
Expand All @@ -382,6 +397,38 @@ protected override void Update()
}
}

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)
Expand Down Expand Up @@ -459,6 +506,9 @@ protected override void OnDragEnd(DragEndEvent e)
private Container currentProxyTarget;
private Drawable proxy;

[CanBeNull]
private readonly Sprite hat;

public void StopSamplePlayback() => sampleClickChannel?.Stop();

public Drawable ProxyToContainer(Container c)
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/osu.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</PackageReference>
<PackageReference Include="Realm" Version="11.5.0" />
<PackageReference Include="ppy.osu.Framework" Version="2024.1206.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.1219.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.1219.1" />
<PackageReference Include="Sentry" Version="4.13.0" />
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
<PackageReference Include="SharpCompress" Version="0.38.0" />
Expand Down

0 comments on commit 6375281

Please sign in to comment.