mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:07:44 +08:00
Merge pull request #9484 from FlashyReese/visible-playfield-boundary
This commit is contained in:
commit
8273715bde
41
osu.Game.Rulesets.Osu.Tests/TestPlayfieldBorder.cs
Normal file
41
osu.Game.Rulesets.Osu.Tests/TestPlayfieldBorder.cs
Normal file
@ -0,0 +1,41 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
public class TestPlayfieldBorder : OsuTestScene
|
||||
{
|
||||
public TestPlayfieldBorder()
|
||||
{
|
||||
Bindable<PlayfieldBorderStyle> playfieldBorderStyle = new Bindable<PlayfieldBorderStyle>();
|
||||
|
||||
AddStep("add drawables", () =>
|
||||
{
|
||||
Child = new Container
|
||||
{
|
||||
Size = new Vector2(400, 300),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PlayfieldBorder
|
||||
{
|
||||
PlayfieldBorderStyle = { BindTarget = playfieldBorderStyle }
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("Set none", () => playfieldBorderStyle.Value = PlayfieldBorderStyle.None);
|
||||
AddStep("Set corners", () => playfieldBorderStyle.Value = PlayfieldBorderStyle.Corners);
|
||||
AddStep("Set full", () => playfieldBorderStyle.Value = PlayfieldBorderStyle.Full);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Configuration;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Configuration
|
||||
{
|
||||
@ -19,6 +20,7 @@ namespace osu.Game.Rulesets.Osu.Configuration
|
||||
Set(OsuRulesetSetting.SnakingInSliders, true);
|
||||
Set(OsuRulesetSetting.SnakingOutSliders, true);
|
||||
Set(OsuRulesetSetting.ShowCursorTrail, true);
|
||||
Set(OsuRulesetSetting.PlayfieldBorderStyle, PlayfieldBorderStyle.None);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +28,7 @@ namespace osu.Game.Rulesets.Osu.Configuration
|
||||
{
|
||||
SnakingInSliders,
|
||||
SnakingOutSliders,
|
||||
ShowCursorTrail
|
||||
ShowCursorTrail,
|
||||
PlayfieldBorderStyle,
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,18 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
LayerBelowRuleset.Add(distanceSnapGridContainer = new Container { RelativeSizeAxes = Axes.Both });
|
||||
LayerBelowRuleset.AddRange(new Drawable[]
|
||||
{
|
||||
new PlayfieldBorder
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
PlayfieldBorderStyle = { Value = PlayfieldBorderStyle.Corners }
|
||||
},
|
||||
distanceSnapGridContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
});
|
||||
|
||||
selectedHitObjects = EditorBeatmap.SelectedHitObjects.GetBoundCopy();
|
||||
selectedHitObjects.CollectionChanged += (_, __) => updateDistanceSnapGrid();
|
||||
|
@ -17,12 +17,16 @@ using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets.Osu.Configuration;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
public class OsuPlayfield : Playfield
|
||||
{
|
||||
private readonly PlayfieldBorder playfieldBorder;
|
||||
private readonly ProxyContainer approachCircles;
|
||||
private readonly ProxyContainer spinnerProxies;
|
||||
private readonly JudgementContainer<DrawableOsuJudgement> judgementLayer;
|
||||
@ -33,12 +37,19 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
protected override GameplayCursorContainer CreateCursor() => new OsuCursorContainer();
|
||||
|
||||
private readonly Bindable<bool> playfieldBorderStyle = new BindableBool();
|
||||
|
||||
private readonly IDictionary<HitResult, DrawablePool<DrawableOsuJudgement>> poolDictionary = new Dictionary<HitResult, DrawablePool<DrawableOsuJudgement>>();
|
||||
|
||||
public OsuPlayfield()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
playfieldBorder = new PlayfieldBorder
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = 3
|
||||
},
|
||||
spinnerProxies = new ProxyContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
@ -76,6 +87,12 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
AddRangeInternal(poolDictionary.Values);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuRulesetConfigManager config)
|
||||
{
|
||||
config?.BindWith(OsuRulesetSetting.PlayfieldBorderStyle, playfieldBorder.PlayfieldBorderStyle);
|
||||
}
|
||||
|
||||
public override void Add(DrawableHitObject h)
|
||||
{
|
||||
h.OnNewResult += onNewResult;
|
||||
|
@ -5,6 +5,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets.Osu.Configuration;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
@ -39,6 +40,11 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
LabelText = "Cursor trail",
|
||||
Current = config.GetBindable<bool>(OsuRulesetSetting.ShowCursorTrail)
|
||||
},
|
||||
new SettingsEnumDropdown<PlayfieldBorderStyle>
|
||||
{
|
||||
LabelText = "Playfield border style",
|
||||
Current = config.GetBindable<PlayfieldBorderStyle>(OsuRulesetSetting.PlayfieldBorderStyle),
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
LabelText = "Score display mode",
|
||||
Current = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode),
|
||||
Keywords = new[] { "scoring" }
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows)
|
||||
|
@ -100,11 +100,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
Children = new Drawable[]
|
||||
{
|
||||
// layers below playfield
|
||||
drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChildren(new Drawable[]
|
||||
{
|
||||
LayerBelowRuleset,
|
||||
new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both }
|
||||
}),
|
||||
drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChild(LayerBelowRuleset),
|
||||
drawableRulesetWrapper,
|
||||
// layers above playfield
|
||||
drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer()
|
||||
|
149
osu.Game/Rulesets/UI/PlayfieldBorder.cs
Normal file
149
osu.Game/Rulesets/UI/PlayfieldBorder.cs
Normal file
@ -0,0 +1,149 @@
|
||||
// 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 System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a border around the playfield.
|
||||
/// </summary>
|
||||
public class PlayfieldBorder : CompositeDrawable
|
||||
{
|
||||
public Bindable<PlayfieldBorderStyle> PlayfieldBorderStyle { get; } = new Bindable<PlayfieldBorderStyle>();
|
||||
|
||||
private const int fade_duration = 500;
|
||||
|
||||
private const float corner_length = 0.05f;
|
||||
private const float corner_thickness = 2;
|
||||
|
||||
public PlayfieldBorder()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Line(Direction.Horizontal)
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
},
|
||||
new Line(Direction.Horizontal)
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
},
|
||||
new Line(Direction.Horizontal)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
},
|
||||
new Line(Direction.Horizontal)
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
},
|
||||
new Line(Direction.Vertical)
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
},
|
||||
new Line(Direction.Vertical)
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
},
|
||||
new Line(Direction.Vertical)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
},
|
||||
new Line(Direction.Vertical)
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
PlayfieldBorderStyle.BindValueChanged(updateStyle, true);
|
||||
}
|
||||
|
||||
private void updateStyle(ValueChangedEvent<PlayfieldBorderStyle> style)
|
||||
{
|
||||
switch (style.NewValue)
|
||||
{
|
||||
case UI.PlayfieldBorderStyle.None:
|
||||
this.FadeOut(fade_duration, Easing.OutQuint);
|
||||
foreach (var line in InternalChildren.OfType<Line>())
|
||||
line.TweenLength(0);
|
||||
|
||||
break;
|
||||
|
||||
case UI.PlayfieldBorderStyle.Corners:
|
||||
this.FadeIn(fade_duration, Easing.OutQuint);
|
||||
foreach (var line in InternalChildren.OfType<Line>())
|
||||
line.TweenLength(corner_length);
|
||||
|
||||
break;
|
||||
|
||||
case UI.PlayfieldBorderStyle.Full:
|
||||
this.FadeIn(fade_duration, Easing.OutQuint);
|
||||
foreach (var line in InternalChildren.OfType<Line>())
|
||||
line.TweenLength(0.5f);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private class Line : Box
|
||||
{
|
||||
private readonly Direction direction;
|
||||
|
||||
public Line(Direction direction)
|
||||
{
|
||||
this.direction = direction;
|
||||
|
||||
Colour = Color4.White;
|
||||
// starting in relative avoids the framework thinking it knows best and setting the width to 1 initially.
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Horizontal:
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Size = new Vector2(0, corner_thickness);
|
||||
break;
|
||||
|
||||
case Direction.Vertical:
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Size = new Vector2(corner_thickness, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void TweenLength(float value)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Horizontal:
|
||||
this.ResizeWidthTo(value, fade_duration, Easing.OutQuint);
|
||||
break;
|
||||
|
||||
case Direction.Vertical:
|
||||
this.ResizeHeightTo(value, fade_duration, Easing.OutQuint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
osu.Game/Rulesets/UI/PlayfieldBorderStyle.cs
Normal file
12
osu.Game/Rulesets/UI/PlayfieldBorderStyle.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.Rulesets.UI
|
||||
{
|
||||
public enum PlayfieldBorderStyle
|
||||
{
|
||||
None,
|
||||
Corners,
|
||||
Full
|
||||
}
|
||||
}
|
@ -1,32 +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.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a border around the playfield.
|
||||
/// </summary>
|
||||
public class EditorPlayfieldBorder : CompositeDrawable
|
||||
{
|
||||
public EditorPlayfieldBorder()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Masking = true;
|
||||
BorderColour = Color4.White;
|
||||
BorderThickness = 2;
|
||||
|
||||
InternalChild = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user