mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 15:44:04 +09:00
Merge branch 'master' into key-counter-fixes
This commit is contained in:
88
osu.Game/Screens/Play/DimmableVideo.cs
Normal file
88
osu.Game/Screens/Play/DimmableVideo.cs
Normal file
@ -0,0 +1,88 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class DimmableVideo : UserDimContainer
|
||||
{
|
||||
private readonly VideoSprite video;
|
||||
private DrawableVideo drawableVideo;
|
||||
|
||||
public DimmableVideo(VideoSprite video)
|
||||
{
|
||||
this.video = video;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
initializeVideo(false);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
ShowVideo.BindValueChanged(_ => initializeVideo(true), true);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
protected override bool ShowDimContent => ShowVideo.Value && DimLevel < 1;
|
||||
|
||||
private void initializeVideo(bool async)
|
||||
{
|
||||
if (video == null)
|
||||
return;
|
||||
|
||||
if (drawableVideo != null)
|
||||
return;
|
||||
|
||||
if (!ShowVideo.Value)
|
||||
return;
|
||||
|
||||
drawableVideo = new DrawableVideo(video);
|
||||
|
||||
if (async)
|
||||
LoadComponentAsync(drawableVideo, Add);
|
||||
else
|
||||
Add(drawableVideo);
|
||||
}
|
||||
|
||||
private class DrawableVideo : Container
|
||||
{
|
||||
public DrawableVideo(VideoSprite video)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
|
||||
video.RelativeSizeAxes = Axes.Both;
|
||||
video.FillMode = FillMode.Fit;
|
||||
video.Anchor = Anchor.Centre;
|
||||
video.Origin = Anchor.Centre;
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
video,
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameplayClock clock)
|
||||
{
|
||||
if (clock != null)
|
||||
Clock = clock;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -80,6 +80,7 @@ namespace osu.Game.Screens.Play
|
||||
protected GameplayClockContainer GameplayClockContainer { get; private set; }
|
||||
|
||||
protected DimmableStoryboard DimmableStoryboard { get; private set; }
|
||||
protected DimmableVideo DimmableVideo { get; private set; }
|
||||
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||
@ -142,6 +143,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private void addUnderlayComponents(Container target)
|
||||
{
|
||||
target.Add(DimmableVideo = new DimmableVideo(Beatmap.Value.Video) { RelativeSizeAxes = Axes.Both });
|
||||
target.Add(DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both });
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
private readonly PlayerSliderBar<double> dimSliderBar;
|
||||
private readonly PlayerSliderBar<double> blurSliderBar;
|
||||
private readonly PlayerCheckbox showStoryboardToggle;
|
||||
private readonly PlayerCheckbox showVideoToggle;
|
||||
private readonly PlayerCheckbox beatmapSkinsToggle;
|
||||
private readonly PlayerCheckbox beatmapHitsoundsToggle;
|
||||
|
||||
@ -37,6 +38,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
Text = "Toggles:"
|
||||
},
|
||||
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" },
|
||||
showVideoToggle = new PlayerCheckbox { LabelText = "Video" },
|
||||
beatmapSkinsToggle = new PlayerCheckbox { LabelText = "Beatmap skins" },
|
||||
beatmapHitsoundsToggle = new PlayerCheckbox { LabelText = "Beatmap hitsounds" }
|
||||
};
|
||||
@ -48,6 +50,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
dimSliderBar.Bindable = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||
blurSliderBar.Bindable = config.GetBindable<double>(OsuSetting.BlurLevel);
|
||||
showStoryboardToggle.Current = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
showVideoToggle.Current = config.GetBindable<bool>(OsuSetting.ShowVideoBackground);
|
||||
beatmapSkinsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
|
||||
beatmapHitsoundsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
|
||||
}
|
||||
|
Reference in New Issue
Block a user