Merge pull request #23767 from peppy/fix-playfield-border-animation-in-editor

Fix gameplay playfield border being affected by beatmap track time
This commit is contained in:
Bartłomiej Dach 2023-06-06 22:10:18 +02:00 committed by GitHub
commit 244e6cc008
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 14 deletions

View File

@ -11,6 +11,7 @@
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Platform;
using osu.Game.Extensions;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables;
@ -97,8 +98,8 @@ private void load(GameHost host)
new ColumnTouchInputArea(this)
};
applyGameWideClock(background);
applyGameWideClock(keyArea);
background.ApplyGameWideClock(host);
keyArea.ApplyGameWideClock(host);
TopLevelContainer.Add(HitObjectArea.Explosions.CreateProxy());
@ -107,18 +108,6 @@ private void load(GameHost host)
RegisterPool<HeadNote, DrawableHoldNoteHead>(10, 50);
RegisterPool<TailNote, DrawableHoldNoteTail>(10, 50);
RegisterPool<HoldNoteTick, DrawableHoldNoteTick>(50, 250);
// Some elements don't handle rewind correctly and fixing them is non-trivial.
// In the future we need a better solution to this, but as a temporary work-around, give these components the game-wide
// clock so they don't need to worry about rewind.
// This only works because they handle OnPressed/OnReleased which results in a correct state while rewinding.
//
// This is kinda dodgy (and will cause weirdness when pausing gameplay) but is better than completely broken rewind.
void applyGameWideClock(Drawable drawable)
{
drawable.Clock = host.UpdateThread.Clock;
drawable.ProcessCustomClock = false;
}
}
private void onSourceChanged()

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Platform;
using osuTK;
namespace osu.Game.Extensions
@ -43,5 +44,20 @@ public static void Shake(this Drawable target, double shakeDuration = 80, float
/// <returns>The delta vector in Parent's coordinates.</returns>
public static Vector2 ScreenSpaceDeltaToParentSpace(this Drawable drawable, Vector2 delta) =>
drawable.Parent.ToLocalSpace(drawable.Parent.ToScreenSpace(Vector2.Zero) + delta);
/// <summary>
/// Some elements don't handle rewind correctly and fixing them is non-trivial.
/// In the future we need a better solution to this, but as a temporary work-around, give these components the game-wide
/// clock so they don't need to worry about rewind.
///
/// This only works if input handling components handle OnPressed/OnReleased which results in a correct state while rewinding.
///
/// This is kinda dodgy (and will cause weirdness when pausing gameplay) but is better than completely broken rewind.
/// </summary>
public static void ApplyGameWideClock(this Drawable drawable, GameHost host)
{
drawable.Clock = host.UpdateThread.Clock;
drawable.ProcessCustomClock = false;
}
}
}

View File

@ -4,10 +4,13 @@
#nullable disable
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Platform;
using osu.Game.Extensions;
using osuTK;
using osuTK.Graphics;
@ -74,6 +77,12 @@ public PlayfieldBorder()
};
}
[BackgroundDependencyLoader]
private void load(GameHost host)
{
this.ApplyGameWideClock(host);
}
protected override void LoadComplete()
{
base.LoadComplete();