introduce main menu background modes

This commit is contained in:
LeNitrous 2019-09-24 17:42:06 +08:00
parent 9fe7675be8
commit b8d147a3b4
6 changed files with 80 additions and 21 deletions

View File

@ -0,0 +1,12 @@
// 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 BackgroundMode
{
Default,
Seasonal,
Beatmap
}
}

View File

@ -117,6 +117,8 @@ protected override void InitialiseDefaults()
Set(OsuSetting.UIHoldActivationDelay, 200, 0, 500);
Set(OsuSetting.IntroSequence, IntroSequence.Triangles);
Set(OsuSetting.BackgroundMode, BackgroundMode.Default);
}
public OsuConfigManager(Storage storage)
@ -186,6 +188,7 @@ public enum OsuSetting
UIScale,
IntroSequence,
UIHoldActivationDelay,
HitLighting
HitLighting,
BackgroundMode
}
}

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 @@ private void load(OsuConfigManager config)
Bindable = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence),
Items = Enum.GetValues(typeof(IntroSequence)).Cast<IntroSequence>()
},
new SettingsDropdown<BackgroundMode>
{
LabelText = "Background",
Bindable = config.GetBindable<BackgroundMode>(OsuSetting.BackgroundMode),
Items = Enum.GetValues(typeof(BackgroundMode)).Cast<BackgroundMode>()
}
};
}
}

View File

@ -6,7 +6,6 @@
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 @@ public override bool Equals(BackgroundScreen other)
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.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 @@ public class BackgroundScreenDefault : BackgroundScreen
private Bindable<User> user;
private Bindable<Skin> skin;
private Bindable<BackgroundMode> mode;
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; }
public BackgroundScreenDefault(bool animateOnEnter = true)
: base(animateOnEnter)
@ -31,13 +37,15 @@ public BackgroundScreenDefault(bool animateOnEnter = true)
}
[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<BackgroundMode>(OsuSetting.BackgroundMode);
user.ValueChanged += _ => Next();
skin.ValueChanged += _ => Next();
mode.ValueChanged += _ => Next();
currentDisplay = RNG.Next(0, background_count);
@ -66,9 +74,28 @@ private Background createBackground()
Background newBackground;
if (user.Value?.IsSupporter ?? false)
newBackground = new SkinnedBackground(skin.Value, backgroundName);
{
switch (mode.Value)
{
case BackgroundMode.Beatmap:
newBackground = new BeatmapBackground(beatmap.Value, backgroundName);
break;
default:
newBackground = new SkinnedBackground(skin.Value, backgroundName);
break;
}
}
else
newBackground = new Background(backgroundName);
{
switch (mode.Value)
{
case BackgroundMode.Seasonal:
default:
newBackground = new Background(backgroundName);
break;
}
}
newBackground.Depth = currentDisplay;