Merge pull request #1879 from UselessToucan/VisualSettingsOverlay

Implement a gameplay visual settings overlay
This commit is contained in:
Dan Balasescu 2018-02-01 16:44:53 +09:00 committed by GitHub
commit 2971991dfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 112 additions and 49 deletions

View File

@ -4,7 +4,7 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Play.ReplaySettings; using osu.Game.Screens.Play.PlayerSettings;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual
{ {
ExampleContainer container; ExampleContainer container;
Add(new ReplaySettingsOverlay Add(new PlayerSettingsOverlay
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual
Text = @"Button", Text = @"Button",
})); }));
AddStep(@"Add checkbox", () => container.Add(new ReplayCheckbox AddStep(@"Add checkbox", () => container.Add(new PlayerCheckbox
{ {
LabelText = "Checkbox", LabelText = "Checkbox",
})); }));
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual
})); }));
} }
private class ExampleContainer : ReplayGroup private class ExampleContainer : PlayerSettingsGroup
{ {
protected override string Title => @"example"; protected override string Title => @"example";
} }

View File

@ -2,11 +2,11 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Screens.Play.ReplaySettings; using osu.Game.Screens.Play.PlayerSettings;
namespace osu.Game.Rulesets.Edit namespace osu.Game.Rulesets.Edit
{ {
public class ToolboxGroup : ReplayGroup public class ToolboxGroup : PlayerSettingsGroup
{ {
protected override string Title => "toolbox"; protected override string Title => "toolbox";

View File

@ -3,29 +3,30 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Screens.Play.ReplaySettings;
using OpenTK; using OpenTK;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Screens.Play.PlayerSettings;
using OpenTK.Input; using OpenTK.Input;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public class ReplaySettingsOverlay : VisibilityContainer public class PlayerSettingsOverlay : VisibilityContainer
{ {
private const int fade_duration = 200; private const int fade_duration = 200;
public bool ReplayLoaded; public bool ReplayLoaded;
public readonly PlaybackSettings PlaybackSettings; public readonly PlaybackSettings PlaybackSettings;
public readonly VisualSettings VisualSettings;
//public readonly CollectionSettings CollectionSettings; //public readonly CollectionSettings CollectionSettings;
//public readonly DiscussionSettings DiscussionSettings; //public readonly DiscussionSettings DiscussionSettings;
public ReplaySettingsOverlay() public PlayerSettingsOverlay()
{ {
AlwaysPresent = true; AlwaysPresent = true;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Child = new FillFlowContainer<ReplayGroup> Child = new FillFlowContainer<PlayerSettingsGroup>
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
@ -33,11 +34,12 @@ namespace osu.Game.Screens.Play.HUD
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20), Spacing = new Vector2(0, 20),
Margin = new MarginPadding { Top = 100, Right = 10 }, Margin = new MarginPadding { Top = 100, Right = 10 },
Children = new[] Children = new PlayerSettingsGroup[]
{ {
//CollectionSettings = new CollectionSettings(), //CollectionSettings = new CollectionSettings(),
//DiscussionSettings = new DiscussionSettings(), //DiscussionSettings = new DiscussionSettings(),
PlaybackSettings = new PlaybackSettings(), PlaybackSettings = new PlaybackSettings(),
VisualSettings = new VisualSettings()
} }
}; };

View File

@ -34,7 +34,7 @@ namespace osu.Game.Screens.Play
public readonly HealthDisplay HealthDisplay; public readonly HealthDisplay HealthDisplay;
public readonly SongProgress Progress; public readonly SongProgress Progress;
public readonly ModDisplay ModDisplay; public readonly ModDisplay ModDisplay;
public readonly ReplaySettingsOverlay ReplaySettingsOverlay; public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
private Bindable<bool> showHud; private Bindable<bool> showHud;
private readonly BindableBool replayLoaded = new BindableBool(); private readonly BindableBool replayLoaded = new BindableBool();
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Play
HealthDisplay = CreateHealthDisplay(), HealthDisplay = CreateHealthDisplay(),
Progress = CreateProgress(), Progress = CreateProgress(),
ModDisplay = CreateModsContainer(), ModDisplay = CreateModsContainer(),
ReplaySettingsOverlay = CreateReplaySettingsOverlay(), PlayerSettingsOverlay = CreatePlayerSettingsOverlay()
} }
}); });
@ -72,7 +72,7 @@ namespace osu.Game.Screens.Play
ModDisplay.Current.BindTo(working.Mods); ModDisplay.Current.BindTo(working.Mods);
ReplaySettingsOverlay.PlaybackSettings.AdjustableClock = adjustableSourceClock; PlayerSettingsOverlay.PlaybackSettings.AdjustableClock = adjustableSourceClock;
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
@ -115,16 +115,16 @@ namespace osu.Game.Screens.Play
private void replayLoadedValueChanged(bool loaded) private void replayLoadedValueChanged(bool loaded)
{ {
ReplaySettingsOverlay.ReplayLoaded = loaded; PlayerSettingsOverlay.ReplayLoaded = loaded;
if (loaded) if (loaded)
{ {
ReplaySettingsOverlay.Show(); PlayerSettingsOverlay.Show();
ModDisplay.FadeIn(200); ModDisplay.FadeIn(200);
} }
else else
{ {
ReplaySettingsOverlay.Hide(); PlayerSettingsOverlay.Hide();
ModDisplay.Delay(2000).FadeOut(200); ModDisplay.Delay(2000).FadeOut(200);
} }
} }
@ -213,7 +213,7 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding { Top = 20, Right = 10 }, Margin = new MarginPadding { Top = 20, Right = 10 },
}; };
protected virtual ReplaySettingsOverlay CreateReplaySettingsOverlay() => new ReplaySettingsOverlay(); protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
protected virtual void BindProcessor(ScoreProcessor processor) protected virtual void BindProcessor(ScoreProcessor processor)
{ {

View File

@ -13,6 +13,7 @@ using osu.Game.Screens.Backgrounds;
using OpenTK; using OpenTK;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.Play.PlayerSettings;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -21,6 +22,7 @@ namespace osu.Game.Screens.Play
private Player player; private Player player;
private BeatmapMetadataDisplay info; private BeatmapMetadataDisplay info;
private VisualSettings visualSettings;
private bool showOverlays = true; private bool showOverlays = true;
public override bool ShowOverlaysOnEnter => showOverlays; public override bool ShowOverlaysOnEnter => showOverlays;
@ -49,6 +51,12 @@ namespace osu.Game.Screens.Play
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
}); });
Add(visualSettings = new VisualSettings
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Margin = new MarginPadding(25)
});
LoadComponentAsync(player); LoadComponentAsync(player);
} }
@ -110,7 +118,7 @@ namespace osu.Game.Screens.Play
private void pushWhenLoaded() private void pushWhenLoaded()
{ {
if (player.LoadState != LoadState.Ready) if (player.LoadState != LoadState.Ready || visualSettings.IsHovered)
{ {
Schedule(pushWhenLoaded); Schedule(pushWhenLoaded);
return; return;

View File

@ -1,15 +1,15 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Music; using osu.Game.Overlays.Music;
using System.Collections.Generic;
namespace osu.Game.Screens.Play.ReplaySettings namespace osu.Game.Screens.Play.PlayerSettings
{ {
public class CollectionSettings : ReplayGroup public class CollectionSettings : PlayerSettingsGroup
{ {
protected override string Title => @"collections"; protected override string Title => @"collections";

View File

@ -6,9 +6,9 @@ using osu.Framework.Graphics;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Play.ReplaySettings namespace osu.Game.Screens.Play.PlayerSettings
{ {
public class DiscussionSettings : ReplayGroup public class DiscussionSettings : PlayerSettingsGroup
{ {
protected override string Title => @"discussions"; protected override string Title => @"discussions";
@ -17,7 +17,7 @@ namespace osu.Game.Screens.Play.ReplaySettings
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new ReplayCheckbox new PlayerCheckbox
{ {
LabelText = "Show floating comments", LabelText = "Show floating comments",
Bindable = config.GetBindable<bool>(OsuSetting.FloatingComments) Bindable = config.GetBindable<bool>(OsuSetting.FloatingComments)

View File

@ -1,15 +1,15 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Timing;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Play.ReplaySettings namespace osu.Game.Screens.Play.PlayerSettings
{ {
public class PlaybackSettings : ReplayGroup public class PlaybackSettings : PlayerSettingsGroup
{ {
private const int padding = 10; private const int padding = 10;
@ -17,7 +17,7 @@ namespace osu.Game.Screens.Play.ReplaySettings
public IAdjustableClock AdjustableClock { set; get; } public IAdjustableClock AdjustableClock { set; get; }
private readonly ReplaySliderBar<double> sliderbar; private readonly PlayerSliderBar<double> sliderbar;
public PlaybackSettings() public PlaybackSettings()
{ {
@ -47,7 +47,7 @@ namespace osu.Game.Screens.Play.ReplaySettings
} }
}, },
}, },
sliderbar = new ReplaySliderBar<double> sliderbar = new PlayerSliderBar<double>
{ {
Bindable = new BindableDouble(1) Bindable = new BindableDouble(1)
{ {

View File

@ -5,9 +5,9 @@ using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Play.ReplaySettings namespace osu.Game.Screens.Play.PlayerSettings
{ {
public class ReplayCheckbox : OsuCheckbox public class PlayerCheckbox : OsuCheckbox
{ {
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)

View File

@ -1,8 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -10,10 +8,12 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Screens.Play.ReplaySettings namespace osu.Game.Screens.Play.PlayerSettings
{ {
public abstract class ReplayGroup : Container public abstract class PlayerSettingsGroup : Container
{ {
/// <summary> /// <summary>
/// The title to be displayed in the header of this group. /// The title to be displayed in the header of this group.
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Play.ReplaySettings
private Color4 buttonActiveColour; private Color4 buttonActiveColour;
protected ReplayGroup() protected PlayerSettingsGroup()
{ {
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
Width = container_width; Width = container_width;

View File

@ -1,16 +1,16 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Game.Graphics.UserInterface;
using System; using System;
using osu.Game.Graphics; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
namespace osu.Game.Screens.Play.ReplaySettings namespace osu.Game.Screens.Play.PlayerSettings
{ {
public class ReplaySliderBar<T> : SettingsSlider<T> public class PlayerSliderBar<T> : SettingsSlider<T>
where T : struct, IEquatable<T>, IComparable, IConvertible where T : struct, IEquatable<T>, IComparable, IConvertible
{ {
protected override Drawable CreateControl() => new Sliderbar protected override Drawable CreateControl() => new Sliderbar

View File

@ -0,0 +1,52 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Play.PlayerSettings
{
public class VisualSettings : PlayerSettingsGroup
{
protected override string Title => "Visual settings";
private readonly PlayerSliderBar<double> dimSliderBar;
private readonly PlayerSliderBar<double> blurSliderBar;
private readonly PlayerCheckbox showStoryboardToggle;
private readonly PlayerCheckbox mouseWheelDisabledToggle;
public VisualSettings()
{
Children = new Drawable[]
{
new OsuSpriteText
{
Text = "Background dim:"
},
dimSliderBar = new PlayerSliderBar<double>(),
new OsuSpriteText
{
Text = "Background blur:"
},
blurSliderBar = new PlayerSliderBar<double>(),
new OsuSpriteText
{
Text = "Toggles:"
},
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" },
mouseWheelDisabledToggle = new PlayerCheckbox { LabelText = "Disable mouse wheel" }
};
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
dimSliderBar.Bindable = config.GetBindable<double>(OsuSetting.DimLevel);
blurSliderBar.Bindable = config.GetBindable<double>(OsuSetting.BlurLevel);
showStoryboardToggle.Bindable = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
mouseWheelDisabledToggle.Bindable = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
}
}
}

View File

@ -339,6 +339,7 @@
<Compile Include="Overlays\Social\SocialListPanel.cs" /> <Compile Include="Overlays\Social\SocialListPanel.cs" />
<Compile Include="Overlays\Social\SocialPanel.cs" /> <Compile Include="Overlays\Social\SocialPanel.cs" />
<Compile Include="Rulesets\Mods\IApplicableToDrawableHitObject.cs" /> <Compile Include="Rulesets\Mods\IApplicableToDrawableHitObject.cs" />
<Compile Include="Screens\Play\PlayerSettings\VisualSettings.cs" />
<Compile Include="Rulesets\UI\HitObjectContainer.cs" /> <Compile Include="Rulesets\UI\HitObjectContainer.cs" />
<Compile Include="Rulesets\UI\Scrolling\Visualisers\SequentialSpeedChangeVisualiser.cs" /> <Compile Include="Rulesets\UI\Scrolling\Visualisers\SequentialSpeedChangeVisualiser.cs" />
<Compile Include="Rulesets\UI\Scrolling\Visualisers\ISpeedChangeVisualiser.cs" /> <Compile Include="Rulesets\UI\Scrolling\Visualisers\ISpeedChangeVisualiser.cs" />
@ -769,13 +770,13 @@
<Compile Include="Screens\Play\Player.cs" /> <Compile Include="Screens\Play\Player.cs" />
<Compile Include="Screens\Play\PlayerLoader.cs" /> <Compile Include="Screens\Play\PlayerLoader.cs" />
<Compile Include="Screens\Play\ReplayPlayer.cs" /> <Compile Include="Screens\Play\ReplayPlayer.cs" />
<Compile Include="Screens\Play\HUD\ReplaySettingsOverlay.cs" /> <Compile Include="Screens\Play\HUD\PlayerSettingsOverlay.cs" />
<Compile Include="Screens\Play\ReplaySettings\CollectionSettings.cs" /> <Compile Include="Screens\Play\PlayerSettings\CollectionSettings.cs" />
<Compile Include="Screens\Play\ReplaySettings\DiscussionSettings.cs" /> <Compile Include="Screens\Play\PlayerSettings\DiscussionSettings.cs" />
<Compile Include="Screens\Play\ReplaySettings\PlaybackSettings.cs" /> <Compile Include="Screens\Play\PlayerSettings\PlaybackSettings.cs" />
<Compile Include="Screens\Play\ReplaySettings\ReplayCheckbox.cs" /> <Compile Include="Screens\Play\PlayerSettings\PlayerCheckbox.cs" />
<Compile Include="Screens\Play\ReplaySettings\ReplayGroup.cs" /> <Compile Include="Screens\Play\PlayerSettings\PlayerSettingsGroup.cs" />
<Compile Include="Screens\Play\ReplaySettings\ReplaySliderBar.cs" /> <Compile Include="Screens\Play\PlayerSettings\PlayerSliderBar.cs" />
<Compile Include="Screens\Play\SkipButton.cs" /> <Compile Include="Screens\Play\SkipButton.cs" />
<Compile Include="Screens\Play\SongProgress.cs" /> <Compile Include="Screens\Play\SongProgress.cs" />
<Compile Include="Screens\Play\SongProgressBar.cs" /> <Compile Include="Screens\Play\SongProgressBar.cs" />