mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 02:32:55 +08:00
Add some simple border styles
This commit is contained in:
parent
7c388f1132
commit
267b399f9f
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Configuration;
|
using osu.Game.Rulesets.Configuration;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Configuration
|
namespace osu.Game.Rulesets.Osu.Configuration
|
||||||
{
|
{
|
||||||
@ -19,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Configuration
|
|||||||
Set(OsuRulesetSetting.SnakingInSliders, true);
|
Set(OsuRulesetSetting.SnakingInSliders, true);
|
||||||
Set(OsuRulesetSetting.SnakingOutSliders, true);
|
Set(OsuRulesetSetting.SnakingOutSliders, true);
|
||||||
Set(OsuRulesetSetting.ShowCursorTrail, true);
|
Set(OsuRulesetSetting.ShowCursorTrail, true);
|
||||||
Set(OsuRulesetSetting.ShowPlayfieldBorder, false);
|
Set(OsuRulesetSetting.PlayfieldBorderStyle, PlayfieldBorderStyle.None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +29,6 @@ namespace osu.Game.Rulesets.Osu.Configuration
|
|||||||
SnakingInSliders,
|
SnakingInSliders,
|
||||||
SnakingOutSliders,
|
SnakingOutSliders,
|
||||||
ShowCursorTrail,
|
ShowCursorTrail,
|
||||||
ShowPlayfieldBorder,
|
PlayfieldBorderStyle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,12 +56,18 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
LayerBelowRuleset.Add(new PlayfieldBorder
|
LayerBelowRuleset.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
new PlayfieldBorder
|
||||||
State = { Value = Visibility.Visible }
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
PlayfieldBorderStyle = { Value = PlayfieldBorderStyle.Corners }
|
||||||
|
},
|
||||||
|
distanceSnapGridContainer = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
}
|
||||||
});
|
});
|
||||||
LayerBelowRuleset.Add(distanceSnapGridContainer = new Container { RelativeSizeAxes = Axes.Both });
|
|
||||||
|
|
||||||
selectedHitObjects = EditorBeatmap.SelectedHitObjects.GetBoundCopy();
|
selectedHitObjects = EditorBeatmap.SelectedHitObjects.GetBoundCopy();
|
||||||
selectedHitObjects.CollectionChanged += (_, __) => updateDistanceSnapGrid();
|
selectedHitObjects.CollectionChanged += (_, __) => updateDistanceSnapGrid();
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
protected override GameplayCursorContainer CreateCursor() => new OsuCursorContainer();
|
protected override GameplayCursorContainer CreateCursor() => new OsuCursorContainer();
|
||||||
|
|
||||||
private readonly Bindable<bool> showPlayfieldBorder = new BindableBool();
|
private readonly Bindable<bool> playfieldBorderStyle = new BindableBool();
|
||||||
|
|
||||||
private readonly IDictionary<HitResult, DrawablePool<DrawableOsuJudgement>> poolDictionary = new Dictionary<HitResult, DrawablePool<DrawableOsuJudgement>>();
|
private readonly IDictionary<HitResult, DrawablePool<DrawableOsuJudgement>> poolDictionary = new Dictionary<HitResult, DrawablePool<DrawableOsuJudgement>>();
|
||||||
|
|
||||||
@ -90,13 +90,9 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuRulesetConfigManager config)
|
private void load(OsuRulesetConfigManager config)
|
||||||
{
|
{
|
||||||
config?.BindWith(OsuRulesetSetting.ShowPlayfieldBorder, showPlayfieldBorder);
|
config?.BindWith(OsuRulesetSetting.PlayfieldBorderStyle, playfieldBorder.PlayfieldBorderStyle);
|
||||||
showPlayfieldBorder.BindValueChanged(updateBorderVisibility, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBorderVisibility(ValueChangedEvent<bool> settingChange)
|
|
||||||
=> playfieldBorder.State.Value = settingChange.NewValue ? Visibility.Visible : Visibility.Hidden;
|
|
||||||
|
|
||||||
public override void Add(DrawableHitObject h)
|
public override void Add(DrawableHitObject h)
|
||||||
{
|
{
|
||||||
h.OnNewResult += onNewResult;
|
h.OnNewResult += onNewResult;
|
||||||
|
@ -5,6 +5,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Osu.Configuration;
|
using osu.Game.Rulesets.Osu.Configuration;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.UI
|
namespace osu.Game.Rulesets.Osu.UI
|
||||||
{
|
{
|
||||||
@ -39,10 +40,10 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
LabelText = "Cursor trail",
|
LabelText = "Cursor trail",
|
||||||
Current = config.GetBindable<bool>(OsuRulesetSetting.ShowCursorTrail)
|
Current = config.GetBindable<bool>(OsuRulesetSetting.ShowCursorTrail)
|
||||||
},
|
},
|
||||||
new SettingsCheckbox
|
new SettingsEnumDropdown<PlayfieldBorderStyle>
|
||||||
{
|
{
|
||||||
LabelText = "Show playfield border",
|
LabelText = "Playfield border style",
|
||||||
Current = config.GetBindable<bool>(OsuRulesetSetting.ShowPlayfieldBorder),
|
Current = config.GetBindable<PlayfieldBorderStyle>(OsuRulesetSetting.PlayfieldBorderStyle),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.UI
|
namespace osu.Game.Rulesets.UI
|
||||||
@ -11,27 +15,136 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides a border around the playfield.
|
/// Provides a border around the playfield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlayfieldBorder : VisibilityContainer
|
public class PlayfieldBorder : CompositeDrawable
|
||||||
{
|
{
|
||||||
private const int fade_duration = 200;
|
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()
|
public PlayfieldBorder()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
Masking = true;
|
InternalChildren = new Drawable[]
|
||||||
BorderColour = Color4.White;
|
|
||||||
BorderThickness = 2;
|
|
||||||
|
|
||||||
InternalChild = new Box
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
new Line(Direction.Horizontal)
|
||||||
Alpha = 0,
|
{
|
||||||
AlwaysPresent = true
|
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 PopIn() => this.FadeIn(fade_duration, Easing.OutQuint);
|
protected override void LoadComplete()
|
||||||
protected override void PopOut() => this.FadeOut(fade_duration, Easing.OutQuint);
|
{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user