Skip to content

Commit

Permalink
Merge branch 'master' into fix-key-binding-corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte authored Jun 24, 2024
2 parents 1dc9f10 + 3bf742b commit 7cbd04d
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Rulesets.Objects.Types;
Expand All @@ -16,7 +15,6 @@
using osu.Game.Screens.Edit;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
{
Expand Down Expand Up @@ -48,13 +46,6 @@ public HitCircleOverlapMarker()
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
ring = new RingPiece
{
BorderThickness = 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Game.Configuration;
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
Expand All @@ -16,6 +19,7 @@ public partial class HitCircleSelectionBlueprint : OsuSelectionBlueprint<HitCirc

protected readonly HitCirclePiece CirclePiece;
private readonly HitCircleOverlapMarker marker;
private readonly Bindable<bool> showHitMarkers = new Bindable<bool>();

public HitCircleSelectionBlueprint(HitCircle circle)
: base(circle)
Expand All @@ -27,12 +31,32 @@ public HitCircleSelectionBlueprint(HitCircle circle)
};
}

[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.EditorShowHitMarkers, showHitMarkers);
}

protected override void LoadComplete()
{
base.LoadComplete();

showHitMarkers.BindValueChanged(_ =>
{
if (!showHitMarkers.Value)
DrawableObject.RestoreHitAnimations();
});
}

protected override void Update()
{
base.Update();

CirclePiece.UpdateFrom(HitObject);
marker.UpdateFrom(HitObject);

if (showHitMarkers.Value)
DrawableObject.SuppressHitAnimations();
}

public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.HitArea.ReceivePositionalInputAt(screenSpacePos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
using osu.Game.Rulesets.Osu.Objects;
Expand All @@ -14,18 +13,17 @@ public partial class SliderCircleOverlay : CompositeDrawable

private readonly Slider slider;
private readonly SliderPosition position;
private readonly HitCircleOverlapMarker marker;
private readonly HitCircleOverlapMarker? marker;

public SliderCircleOverlay(Slider slider, SliderPosition position)
{
this.slider = slider;
this.position = position;

InternalChildren = new Drawable[]
{
marker = new HitCircleOverlapMarker(),
CirclePiece = new HitCirclePiece(),
};
if (position == SliderPosition.Start)
AddInternal(marker = new HitCircleOverlapMarker());

AddInternal(CirclePiece = new HitCirclePiece());
}

protected override void Update()
Expand All @@ -35,7 +33,7 @@ protected override void Update()
var circle = position == SliderPosition.Start ? (HitCircle)slider.HeadCircle : slider.TailCircle;

CirclePiece.UpdateFrom(circle);
marker.UpdateFrom(circle);
marker?.UpdateFrom(circle);
}

public override void Hide()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
Expand Down Expand Up @@ -59,21 +60,24 @@ public partial class SliderSelectionBlueprint : OsuSelectionBlueprint<Slider>
private readonly BindableList<PathControlPoint> controlPoints = new BindableList<PathControlPoint>();
private readonly IBindable<int> pathVersion = new Bindable<int>();
private readonly BindableList<HitObject> selectedObjects = new BindableList<HitObject>();
private readonly Bindable<bool> showHitMarkers = new Bindable<bool>();

public SliderSelectionBlueprint(Slider slider)
: base(slider)
{
}

[BackgroundDependencyLoader]
private void load()
private void load(OsuConfigManager config)
{
InternalChildren = new Drawable[]
{
BodyPiece = new SliderBodyPiece(),
HeadOverlay = CreateCircleOverlay(HitObject, SliderPosition.Start),
TailOverlay = CreateCircleOverlay(HitObject, SliderPosition.End),
};

config.BindWith(OsuSetting.EditorShowHitMarkers, showHitMarkers);
}

protected override void LoadComplete()
Expand All @@ -90,6 +94,11 @@ protected override void LoadComplete()
if (editorBeatmap != null)
selectedObjects.BindTo(editorBeatmap.SelectedHitObjects);
selectedObjects.BindCollectionChanged((_, _) => updateVisualDefinition(), true);
showHitMarkers.BindValueChanged(_ =>
{
if (!showHitMarkers.Value)
DrawableObject.RestoreHitAnimations();
});
}

public override bool HandleQuickDeletion()
Expand All @@ -110,6 +119,9 @@ protected override void Update()

if (IsSelected)
BodyPiece.UpdateFrom(HitObject);

if (showHitMarkers.Value)
DrawableObject.SuppressHitAnimations();
}

protected override bool OnHover(HoverEvent e)
Expand Down
27 changes: 27 additions & 0 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
Expand Down Expand Up @@ -319,5 +320,31 @@ public ProxyableSkinnableDrawable(ISkinComponentLookup lookup, Func<ISkinCompone
{
}
}

#region FOR EDITOR USE ONLY, DO NOT USE FOR ANY OTHER PURPOSE

internal void SuppressHitAnimations()
{
UpdateState(ArmedState.Idle);
UpdateComboColour();

// This method is called every frame. If we need to, the following can likely be converted
// to code which doesn't use transforms at all.

// Matches stable (see https://github.com/peppy/osu-stable-reference/blob/bb57924c1552adbed11ee3d96cdcde47cf96f2b6/osu!/GameplayElements/HitObjects/Osu/HitCircleOsu.cs#L336-L338)
using (BeginAbsoluteSequence(StateUpdateTime - 5))
this.TransformBindableTo(AccentColour, Color4.White, Math.Max(0, HitStateUpdateTime - StateUpdateTime));

using (BeginAbsoluteSequence(HitStateUpdateTime))
this.FadeOut(700).Expire();
}

internal void RestoreHitAnimations()
{
UpdateState(ArmedState.Hit, force: true);
UpdateComboColour();
}

#endregion
}
}
18 changes: 18 additions & 0 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,23 @@ protected override void UpdateHitStateTransforms(ArmedState state)
private partial class DefaultSliderBody : PlaySliderBody
{
}

#region FOR EDITOR USE ONLY, DO NOT USE FOR ANY OTHER PURPOSE

internal void SuppressHitAnimations()
{
UpdateState(ArmedState.Idle);
HeadCircle.SuppressHitAnimations();
TailCircle.SuppressHitAnimations();
}

internal void RestoreHitAnimations()
{
UpdateState(ArmedState.Hit, force: true);
HeadCircle.RestoreHitAnimations();
TailCircle.RestoreHitAnimations();
}

#endregion
}
}
24 changes: 24 additions & 0 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#nullable disable

using System;
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Allocation;
Expand All @@ -12,6 +13,7 @@
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
Expand Down Expand Up @@ -125,5 +127,27 @@ protected override void OnApply()
if (Slider != null)
Position = Slider.CurvePositionAt(HitObject.RepeatIndex % 2 == 0 ? 1 : 0);
}

#region FOR EDITOR USE ONLY, DO NOT USE FOR ANY OTHER PURPOSE

internal void SuppressHitAnimations()
{
UpdateState(ArmedState.Idle);
UpdateComboColour();

using (BeginAbsoluteSequence(StateUpdateTime - 5))
this.TransformBindableTo(AccentColour, Color4.White, Math.Max(0, HitStateUpdateTime - StateUpdateTime));

using (BeginAbsoluteSequence(HitStateUpdateTime))
this.FadeOut(700).Expire();
}

internal void RestoreHitAnimations()
{
UpdateState(ArmedState.Hit);
UpdateComboColour();
}

#endregion
}
}
18 changes: 9 additions & 9 deletions osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ protected sealed override void OnApply(HitObjectLifetimeEntry entry)
private void updateStateFromResult()
{
if (Result.IsHit)
updateState(ArmedState.Hit, true);
UpdateState(ArmedState.Hit, true);
else if (Result.HasResult)
updateState(ArmedState.Miss, true);
UpdateState(ArmedState.Miss, true);
else
updateState(ArmedState.Idle, true);
UpdateState(ArmedState.Idle, true);
}

protected sealed override void OnFree(HitObjectLifetimeEntry entry)
Expand Down Expand Up @@ -402,7 +402,7 @@ protected virtual void LoadSamples()

private void onRevertResult()
{
updateState(ArmedState.Idle);
UpdateState(ArmedState.Idle);
OnRevertResult?.Invoke(this, Result);
}

Expand All @@ -421,7 +421,7 @@ private void onDefaultsApplied(HitObject hitObject)
if (Result is not null)
{
Result.TimeOffset = 0;
updateState(State.Value, true);
UpdateState(State.Value, true);
}

DefaultsApplied?.Invoke(this);
Expand Down Expand Up @@ -461,7 +461,7 @@ protected override void ClearInternal(bool disposeChildren = true) =>
throw new InvalidOperationException(
$"Should never clear a {nameof(DrawableHitObject)} as the base implementation adds components. If attempting to use {nameof(InternalChild)} or {nameof(InternalChildren)}, using {nameof(AddInternal)} or {nameof(AddRangeInternal)} instead.");

private void updateState(ArmedState newState, bool force = false)
protected void UpdateState(ArmedState newState, bool force = false)
{
if (State.Value == newState && !force)
return;
Expand Down Expand Up @@ -506,7 +506,7 @@ private void clearExistingStateTransforms()
/// <summary>
/// Reapplies the current <see cref="ArmedState"/>.
/// </summary>
public void RefreshStateTransforms() => updateState(State.Value, true);
public void RefreshStateTransforms() => UpdateState(State.Value, true);

/// <summary>
/// Apply (generally fade-in) transforms leading into the <see cref="HitObject"/> start time.
Expand Down Expand Up @@ -565,7 +565,7 @@ private void skinChanged()
ApplySkin(CurrentSkin, true);

if (IsLoaded)
updateState(State.Value, true);
UpdateState(State.Value, true);
}

protected void UpdateComboColour()
Expand Down Expand Up @@ -725,7 +725,7 @@ protected void ApplyResult<T>(Action<JudgementResult, T> application, T state)
Result.GameplayRate = (Clock as IGameplayClock)?.GetTrueGameplayRate() ?? Clock.Rate;

if (Result.HasResult)
updateState(Result.IsHit ? ArmedState.Hit : ArmedState.Miss);
UpdateState(Result.IsHit ? ArmedState.Hit : ArmedState.Miss);

OnNewResult?.Invoke(this, Result);
}
Expand Down

0 comments on commit 7cbd04d

Please sign in to comment.