mirror of
https://github.com/ppy/osu
synced 2025-02-05 04:42:18 +00:00
change name of interface and expose method instead of seperate values
This commit is contained in:
parent
9a8e3fe1da
commit
9fdbb2a58e
15
osu.Game/Rulesets/Mods/IApplicableToPlayer.cs
Normal file
15
osu.Game/Rulesets/Mods/IApplicableToPlayer.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for a mod which can temporarily override the <see cref="Player"/> settings.
|
||||
/// </summary>
|
||||
public interface IApplicableToPlayer : IApplicableMod
|
||||
{
|
||||
void ApplyToPlayer(Player player);
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
// 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.Rulesets.Mods
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for a mod which can temporarily override screen settings.
|
||||
/// </summary>
|
||||
public interface IApplicableToScreen : IApplicableMod
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether to enable image, video and storyboard dimming
|
||||
/// </summary>
|
||||
bool EnableDim { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Weather to force the video (if present)
|
||||
/// </summary>
|
||||
bool ForceVideo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Weather to force the storyboard (if present)
|
||||
/// </summary>
|
||||
bool ForceStoryboard { get; }
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
}
|
||||
}
|
||||
|
||||
public class ModCinema : ModAutoplay, IApplicableToHUD, IApplicableToScreen
|
||||
public class ModCinema : ModAutoplay, IApplicableToHUD, IApplicableToPlayer
|
||||
{
|
||||
public override string Name => "Cinema";
|
||||
public override string Acronym => "CN";
|
||||
@ -34,8 +34,14 @@ namespace osu.Game.Rulesets.Mods
|
||||
overlay.Hide();
|
||||
}
|
||||
|
||||
public bool EnableDim => false;
|
||||
public bool ForceVideo => true;
|
||||
public bool ForceStoryboard => true;
|
||||
public void ApplyToPlayer(Player player)
|
||||
{
|
||||
player.Background.EnableUserDim.Value = false;
|
||||
player.DimmableVideo.EnableUserDim.Value = false;
|
||||
player.DimmableStoryboard.EnableUserDim.Value = false;
|
||||
|
||||
player.DimmableVideo.IgnoreUserSettings.Value = true;
|
||||
player.DimmableStoryboard.IgnoreUserSettings.Value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected GameplayClockContainer GameplayClockContainer { get; private set; }
|
||||
|
||||
protected DimmableStoryboard DimmableStoryboard { get; private set; }
|
||||
protected DimmableVideo DimmableVideo { get; private set; }
|
||||
public DimmableStoryboard DimmableStoryboard { get; private set; }
|
||||
public DimmableVideo DimmableVideo { get; private set; }
|
||||
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||
@ -498,24 +498,8 @@ namespace osu.Game.Screens.Play
|
||||
.Delay(250)
|
||||
.FadeIn(250);
|
||||
|
||||
var screenOverride = Mods.Value.OfType<IApplicableToScreen>();
|
||||
|
||||
if (screenOverride.Count() == 1)
|
||||
{
|
||||
var setting = screenOverride.Single();
|
||||
|
||||
Background.EnableUserDim.Value = setting.EnableDim;
|
||||
DimmableVideo.EnableUserDim.Value = setting.EnableDim;
|
||||
DimmableStoryboard.EnableUserDim.Value = setting.EnableDim;
|
||||
|
||||
DimmableVideo.IgnoreUserSettings.Value = setting.ForceVideo;
|
||||
DimmableStoryboard.IgnoreUserSettings.Value = setting.ForceStoryboard;
|
||||
}
|
||||
else
|
||||
{
|
||||
Background.EnableUserDim.Value = true;
|
||||
Background.BlurAmount.Value = 0;
|
||||
}
|
||||
Background.EnableUserDim.Value = true;
|
||||
Background.BlurAmount.Value = 0;
|
||||
|
||||
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
@ -525,6 +509,9 @@ namespace osu.Game.Screens.Play
|
||||
GameplayClockContainer.Restart();
|
||||
GameplayClockContainer.FadeInFromZero(750, Easing.OutQuint);
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToPlayer>())
|
||||
mod.ApplyToPlayer(this);
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToHUD>())
|
||||
mod.ApplyToHUD(HUDOverlay);
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
|
||||
|
||||
protected new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background;
|
||||
public new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user