mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
introduce main menu background modes
This commit is contained in:
parent
9fe7675be8
commit
b8d147a3b4
12
osu.Game/Configuration/BackgroundMode.cs
Normal file
12
osu.Game/Configuration/BackgroundMode.cs
Normal 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
|
||||
}
|
||||
}
|
@ -117,6 +117,8 @@ namespace osu.Game.Configuration
|
||||
Set(OsuSetting.UIHoldActivationDelay, 200, 0, 500);
|
||||
|
||||
Set(OsuSetting.IntroSequence, IntroSequence.Triangles);
|
||||
|
||||
Set(OsuSetting.BackgroundMode, BackgroundMode.Default);
|
||||
}
|
||||
|
||||
public OsuConfigManager(Storage storage)
|
||||
@ -186,6 +188,7 @@ namespace osu.Game.Configuration
|
||||
UIScale,
|
||||
IntroSequence,
|
||||
UIHoldActivationDelay,
|
||||
HitLighting
|
||||
HitLighting,
|
||||
BackgroundMode
|
||||
}
|
||||
}
|
||||
|
28
osu.Game/Graphics/Backgrounds/BeatmapBackground.cs
Normal file
28
osu.Game/Graphics/Backgrounds/BeatmapBackground.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<BackgroundMode>
|
||||
{
|
||||
LabelText = "Background",
|
||||
Bindable = config.GetBindable<BackgroundMode>(OsuSetting.BackgroundMode),
|
||||
Items = Enum.GetValues(typeof(BackgroundMode)).Cast<BackgroundMode>()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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<BackgroundMode> mode;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
public BackgroundScreenDefault(bool animateOnEnter = true)
|
||||
: base(animateOnEnter)
|
||||
@ -31,13 +37,15 @@ 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<BackgroundMode>(OsuSetting.BackgroundMode);
|
||||
|
||||
user.ValueChanged += _ => Next();
|
||||
skin.ValueChanged += _ => Next();
|
||||
mode.ValueChanged += _ => Next();
|
||||
|
||||
currentDisplay = RNG.Next(0, background_count);
|
||||
|
||||
@ -66,9 +74,28 @@ namespace osu.Game.Screens.Backgrounds
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user