1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Merge pull request #21173 from peppy/toggle-hit-markers

Add the ability to toggle off hit marker displays in the editor
This commit is contained in:
Dan Balasescu 2022-11-10 12:23:53 +09:00 committed by GitHub
commit 051f7f4c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 15 deletions

View File

@ -4,9 +4,12 @@
#nullable disable #nullable disable
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Skinning.Default; using osu.Game.Rulesets.Osu.Skinning.Default;
@ -27,31 +30,45 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
private readonly RingPiece ring; private readonly RingPiece ring;
private readonly Container content;
[Resolved] [Resolved]
private EditorClock editorClock { get; set; } private EditorClock editorClock { get; set; }
private Bindable<bool> showHitMarkers;
public HitCircleOverlapMarker() public HitCircleOverlapMarker()
{ {
Origin = Anchor.Centre; Origin = Anchor.Centre;
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
InternalChildren = new Drawable[] InternalChild = content = new Container
{ {
new Circle RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{ {
Anchor = Anchor.Centre, new Circle
Origin = Anchor.Centre, {
RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre,
Colour = Color4.White, Origin = Anchor.Centre,
}, RelativeSizeAxes = Axes.Both,
ring = new RingPiece Colour = Color4.White,
{ },
BorderThickness = 4, ring = new RingPiece
{
BorderThickness = 4,
}
} }
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
showHitMarkers = config.GetBindable<bool>(OsuSetting.EditorShowHitMarkers);
}
[Resolved] [Resolved]
private ISkinSource skin { get; set; } private ISkinSource skin { get; set; }
@ -68,21 +85,26 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
double hitObjectTime = hitObject.StartTime; double hitObjectTime = hitObject.StartTime;
bool hasReachedObject = editorTime >= hitObjectTime; bool hasReachedObject = editorTime >= hitObjectTime;
if (hasReachedObject) if (hasReachedObject && showHitMarkers.Value)
{ {
float alpha = Interpolation.ValueAt(editorTime, 0, 1f, hitObjectTime, hitObjectTime + FADE_OUT_EXTENSION, Easing.In); float alpha = Interpolation.ValueAt(editorTime, 0, 1f, hitObjectTime, hitObjectTime + FADE_OUT_EXTENSION, Easing.In);
float ringScale = MathHelper.Clamp(Interpolation.ValueAt(editorTime, 0, 1f, hitObjectTime, hitObjectTime + FADE_OUT_EXTENSION / 2, Easing.OutQuint), 0, 1); float ringScale = MathHelper.Clamp(Interpolation.ValueAt(editorTime, 0, 1f, hitObjectTime, hitObjectTime + FADE_OUT_EXTENSION / 2, Easing.OutQuint), 0, 1);
ring.Scale = new Vector2(1 + 0.1f * ringScale); ring.Scale = new Vector2(1 + 0.1f * ringScale);
Alpha = 0.9f * (1 - alpha); content.Alpha = 0.9f * (1 - alpha);
} }
else else
Alpha = 0; content.Alpha = 0;
}
public override void Show()
{
// intentional no op so SelectionBlueprint Selection/Deselection logic doesn't touch us.
} }
public override void Hide() public override void Hide()
{ {
// intentional no op so we are not hidden when not selected. // intentional no op so SelectionBlueprint Selection/Deselection logic doesn't touch us.
} }
} }
} }

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints
protected override bool AlwaysShowWhenSelected => true; protected override bool AlwaysShowWhenSelected => true;
protected override bool ShouldBeAlive => base.ShouldBeAlive protected override bool ShouldBeAlive => base.ShouldBeAlive
|| (editorClock.CurrentTime >= Item.StartTime && editorClock.CurrentTime - Item.GetEndTime() < HitCircleOverlapMarker.FADE_OUT_EXTENSION); || (ShowHitMarkers.Value && editorClock.CurrentTime >= Item.StartTime && editorClock.CurrentTime - Item.GetEndTime() < HitCircleOverlapMarker.FADE_OUT_EXTENSION);
protected OsuSelectionBlueprint(T hitObject) protected OsuSelectionBlueprint(T hitObject)
: base(hitObject) : base(hitObject)

View File

@ -173,6 +173,7 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.EditorDim, 0.25f, 0f, 0.75f, 0.25f); SetDefault(OsuSetting.EditorDim, 0.25f, 0f, 0.75f, 0.25f);
SetDefault(OsuSetting.EditorWaveformOpacity, 0.25f, 0f, 1f, 0.25f); SetDefault(OsuSetting.EditorWaveformOpacity, 0.25f, 0f, 1f, 0.25f);
SetDefault(OsuSetting.EditorShowHitMarkers, true);
SetDefault(OsuSetting.LastProcessedMetadataId, -1); SetDefault(OsuSetting.LastProcessedMetadataId, -1);
} }
@ -367,5 +368,6 @@ namespace osu.Game.Configuration
ShowOnlineExplicitContent, ShowOnlineExplicitContent,
LastProcessedMetadataId, LastProcessedMetadataId,
SafeAreaConsiderations, SafeAreaConsiderations,
EditorShowHitMarkers
} }
} }

View File

@ -3,7 +3,10 @@
#nullable disable #nullable disable
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
@ -23,6 +26,11 @@ namespace osu.Game.Rulesets.Edit
/// </summary> /// </summary>
protected virtual bool AlwaysShowWhenSelected => false; protected virtual bool AlwaysShowWhenSelected => false;
/// <summary>
/// Whether extra animations should be shown to convey hit position / state in addition to gameplay animations.
/// </summary>
protected Bindable<bool> ShowHitMarkers { get; private set; }
protected override bool ShouldBeAlive => (DrawableObject?.IsAlive == true && DrawableObject.IsPresent) || (AlwaysShowWhenSelected && State == SelectionState.Selected); protected override bool ShouldBeAlive => (DrawableObject?.IsAlive == true && DrawableObject.IsPresent) || (AlwaysShowWhenSelected && State == SelectionState.Selected);
protected HitObjectSelectionBlueprint(HitObject hitObject) protected HitObjectSelectionBlueprint(HitObject hitObject)
@ -30,6 +38,12 @@ namespace osu.Game.Rulesets.Edit
{ {
} }
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
ShowHitMarkers = config.GetBindable<bool>(OsuSetting.EditorShowHitMarkers);
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.ReceivePositionalInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.ReceivePositionalInputAt(screenSpacePos);
public override Vector2 ScreenSpaceSelectionPoint => DrawableObject.ScreenSpaceDrawQuad.Centre; public override Vector2 ScreenSpaceSelectionPoint => DrawableObject.ScreenSpaceDrawQuad.Centre;

View File

@ -176,6 +176,7 @@ namespace osu.Game.Screens.Edit
private OnScreenDisplay onScreenDisplay { get; set; } private OnScreenDisplay onScreenDisplay { get; set; }
private Bindable<float> editorBackgroundDim; private Bindable<float> editorBackgroundDim;
private Bindable<bool> editorHitMarkers;
public Editor(EditorLoader loader = null) public Editor(EditorLoader loader = null)
{ {
@ -262,6 +263,7 @@ namespace osu.Game.Screens.Edit
OsuMenuItem redoMenuItem; OsuMenuItem redoMenuItem;
editorBackgroundDim = config.GetBindable<float>(OsuSetting.EditorDim); editorBackgroundDim = config.GetBindable<float>(OsuSetting.EditorDim);
editorHitMarkers = config.GetBindable<bool>(OsuSetting.EditorShowHitMarkers);
AddInternal(new OsuContextMenuContainer AddInternal(new OsuContextMenuContainer
{ {
@ -316,6 +318,10 @@ namespace osu.Game.Screens.Edit
{ {
new WaveformOpacityMenuItem(config.GetBindable<float>(OsuSetting.EditorWaveformOpacity)), new WaveformOpacityMenuItem(config.GetBindable<float>(OsuSetting.EditorWaveformOpacity)),
new BackgroundDimMenuItem(editorBackgroundDim), new BackgroundDimMenuItem(editorBackgroundDim),
new ToggleMenuItem("Show hit markers")
{
State = { BindTarget = editorHitMarkers },
}
} }
} }
} }