1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 05:42:56 +08:00

Add option to show beatmap backgrounds at main menu (#6239)

Add option to show beatmap backgrounds at main menu

Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert 2019-11-22 02:55:42 +09:00 committed by GitHub
commit 88cb1fc705
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 71 additions and 31 deletions

View File

@ -0,0 +1,11 @@
// 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.
namespace osu.Game.Configuration
{
public enum BackgroundSource
{
Skin,
Beatmap
}
}

View File

@ -117,6 +117,8 @@ namespace osu.Game.Configuration
Set(OsuSetting.UIHoldActivationDelay, 200f, 0f, 500f, 50f);
Set(OsuSetting.IntroSequence, IntroSequence.Triangles);
Set(OsuSetting.MenuBackgroundSource, BackgroundSource.Skin);
}
public OsuConfigManager(Storage storage)
@ -186,6 +188,7 @@ namespace osu.Game.Configuration
UIScale,
IntroSequence,
UIHoldActivationDelay,
HitLighting
HitLighting,
MenuBackgroundSource
}
}

View File

@ -0,0 +1,28 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
namespace osu.Game.Graphics.Backgrounds
{
public class BeatmapBackground : Background
{
public readonly WorkingBeatmap Beatmap;
private readonly string fallbackTextureName;
public BeatmapBackground(WorkingBeatmap beatmap, string fallbackTextureName = @"Backgrounds/bg1")
{
Beatmap = beatmap;
this.fallbackTextureName = fallbackTextureName;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName);
}
}
}

View File

@ -34,6 +34,12 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
Bindable = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence),
Items = Enum.GetValues(typeof(IntroSequence)).Cast<IntroSequence>()
},
new SettingsDropdown<BackgroundSource>
{
LabelText = "Background source",
Bindable = config.GetBindable<BackgroundSource>(OsuSetting.MenuBackgroundSource),
Items = Enum.GetValues(typeof(BackgroundSource)).Cast<BackgroundSource>()
}
};
}
}

View File

@ -6,7 +6,6 @@ using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Backgrounds;
@ -107,22 +106,6 @@ namespace osu.Game.Screens.Backgrounds
return base.Equals(other) && beatmap == otherBeatmapBackground.Beatmap;
}
protected class BeatmapBackground : Background
{
public readonly WorkingBeatmap Beatmap;
public BeatmapBackground(WorkingBeatmap beatmap)
{
Beatmap = beatmap;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Sprite.Texture = Beatmap?.Background ?? textures.Get(@"Backgrounds/bg1");
}
}
public class DimmableBackground : UserDimContainer
{
/// <summary>

View File

@ -6,6 +6,8 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Online.API;
using osu.Game.Skinning;
@ -24,6 +26,10 @@ namespace osu.Game.Screens.Backgrounds
private Bindable<User> user;
private Bindable<Skin> skin;
private Bindable<BackgroundSource> mode;
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; }
public BackgroundScreenDefault(bool animateOnEnter = true)
: base(animateOnEnter)
@ -31,13 +37,16 @@ namespace osu.Game.Screens.Backgrounds
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api, SkinManager skinManager)
private void load(IAPIProvider api, SkinManager skinManager, OsuConfigManager config)
{
user = api.LocalUser.GetBoundCopy();
skin = skinManager.CurrentSkin.GetBoundCopy();
mode = config.GetBindable<BackgroundSource>(OsuSetting.MenuBackgroundSource);
user.ValueChanged += _ => Next();
skin.ValueChanged += _ => Next();
mode.ValueChanged += _ => Next();
beatmap.ValueChanged += _ => Next();
currentDisplay = RNG.Next(0, background_count);
@ -66,7 +75,18 @@ namespace osu.Game.Screens.Backgrounds
Background newBackground;
if (user.Value?.IsSupporter ?? false)
newBackground = new SkinnedBackground(skin.Value, backgroundName);
{
switch (mode.Value)
{
case BackgroundSource.Beatmap:
newBackground = new BeatmapBackground(beatmap.Value, backgroundName);
break;
default:
newBackground = new SkinnedBackground(skin.Value, backgroundName);
break;
}
}
else
newBackground = new Background(backgroundName);

View File

@ -10,7 +10,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@ -170,8 +169,6 @@ namespace osu.Game.Screens.Menu
track.Start();
}
}
Beatmap.ValueChanged += beatmap_ValueChanged;
}
private bool exitConfirmed;
@ -220,14 +217,6 @@ namespace osu.Game.Screens.Menu
seq.OnAbort(_ => buttons.SetOsuLogo(null));
}
private void beatmap_ValueChanged(ValueChangedEvent<WorkingBeatmap> e)
{
if (!this.IsCurrentScreen())
return;
((BackgroundScreenDefault)Background).Next();
}
public override void OnSuspending(IScreen next)
{
base.OnSuspending(next);