mirror of https://github.com/ppy/osu
Merge pull request #9236 from MiraiSubject/logovisualisation-subclass
Move user and skin specific settings for LogoVisualisation to a subclass
This commit is contained in:
commit
527577d7c3
|
@ -12,17 +12,16 @@
|
|||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Users;
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Utils;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
/// <summary>
|
||||
/// A visualiser that reacts to music coming from beatmaps.
|
||||
/// </summary>
|
||||
public class LogoVisualisation : Drawable, IHasAccentColour
|
||||
{
|
||||
private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
@ -71,9 +70,6 @@ public class LogoVisualisation : Drawable, IHasAccentColour
|
|||
private IShader shader;
|
||||
private readonly Texture texture;
|
||||
|
||||
private Bindable<User> user;
|
||||
private Bindable<Skin> skin;
|
||||
|
||||
public LogoVisualisation()
|
||||
{
|
||||
texture = Texture.WhitePixel;
|
||||
|
@ -81,15 +77,10 @@ public LogoVisualisation()
|
|||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ShaderManager shaders, IBindable<WorkingBeatmap> beatmap, IAPIProvider api, SkinManager skinManager)
|
||||
private void load(ShaderManager shaders, IBindable<WorkingBeatmap> beatmap)
|
||||
{
|
||||
this.beatmap.BindTo(beatmap);
|
||||
shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
|
||||
user = api.LocalUser.GetBoundCopy();
|
||||
skin = skinManager.CurrentSkin.GetBoundCopy();
|
||||
|
||||
user.ValueChanged += _ => updateColour();
|
||||
skin.BindValueChanged(_ => updateColour(), true);
|
||||
}
|
||||
|
||||
private void updateAmplitudes()
|
||||
|
@ -118,16 +109,6 @@ private void updateAmplitudes()
|
|||
indexOffset = (indexOffset + index_change) % bars_per_visualiser;
|
||||
}
|
||||
|
||||
private void updateColour()
|
||||
{
|
||||
Color4 defaultColour = Color4.White.Opacity(0.2f);
|
||||
|
||||
if (user.Value?.IsSupporter ?? false)
|
||||
AccentColour = skin.Value.GetConfig<GlobalSkinColours, Color4>(GlobalSkinColours.MenuGlow)?.Value ?? defaultColour;
|
||||
else
|
||||
AccentColour = defaultColour;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osuTK.Graphics;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
internal class MenuLogoVisualisation : LogoVisualisation
|
||||
{
|
||||
private Bindable<User> user;
|
||||
private Bindable<Skin> skin;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAPIProvider api, SkinManager skinManager)
|
||||
{
|
||||
user = api.LocalUser.GetBoundCopy();
|
||||
skin = skinManager.CurrentSkin.GetBoundCopy();
|
||||
|
||||
user.ValueChanged += _ => updateColour();
|
||||
skin.BindValueChanged(_ => updateColour(), true);
|
||||
}
|
||||
|
||||
private void updateColour()
|
||||
{
|
||||
Color4 defaultColour = Color4.White.Opacity(0.2f);
|
||||
|
||||
if (user.Value?.IsSupporter ?? false)
|
||||
AccentColour = skin.Value.GetConfig<GlobalSkinColours, Color4>(GlobalSkinColours.MenuGlow)?.Value ?? defaultColour;
|
||||
else
|
||||
AccentColour = defaultColour;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ public class OsuLogo : BeatSyncedContainer
|
|||
private readonly Container logoBeatContainer;
|
||||
private readonly Container logoAmplitudeContainer;
|
||||
private readonly Container logoHoverContainer;
|
||||
private readonly LogoVisualisation visualizer;
|
||||
private readonly MenuLogoVisualisation visualizer;
|
||||
|
||||
private readonly IntroSequence intro;
|
||||
|
||||
|
@ -139,7 +139,7 @@ public OsuLogo()
|
|||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
visualizer = new LogoVisualisation
|
||||
visualizer = new MenuLogoVisualisation
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Origin = Anchor.Centre,
|
||||
|
|
Loading…
Reference in New Issue