change name of interface and expose method instead of seperate values

This commit is contained in:
Albie 2019-11-25 07:24:29 +00:00
parent 9a8e3fe1da
commit 9fdbb2a58e
5 changed files with 33 additions and 51 deletions

View 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);
}
}

View File

@ -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; }
}
}

View File

@ -21,7 +21,7 @@ public virtual void ApplyToDrawableRuleset(DrawableRuleset<T> drawableRuleset)
}
}
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 @@ public void ApplyToHUD(HUDOverlay overlay)
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;
}
}
}

View File

@ -80,8 +80,8 @@ public class Player : ScreenWithBeatmapBackground
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 @@ public override void OnEntering(IScreen last)
.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 @@ public override void OnEntering(IScreen last)
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);
}

View File

@ -9,6 +9,6 @@ public abstract class ScreenWithBeatmapBackground : OsuScreen
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
protected new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background;
public new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background;
}
}