1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-12 20:57:31 +08:00

Apply code feedback and also resize catcher trails when any is shown

This commit is contained in:
Darius Wattimena 2024-10-24 23:17:47 +02:00
parent b75437ee13
commit 5e642cbce7
5 changed files with 35 additions and 13 deletions

View File

@ -22,10 +22,5 @@ namespace osu.Game.Rulesets.Catch.Edit
// TODO: disable hit lighting as well // TODO: disable hit lighting as well
} }
public void ApplyCircleSizeToCatcher(IBeatmapDifficultyInfo difficulty)
{
Catcher.SetScaleAndCatchWidth(difficulty);
}
} }
} }

View File

@ -49,7 +49,14 @@ namespace osu.Game.Rulesets.Catch.Edit
editorBeatmap.BeatmapReprocessed -= onBeatmapReprocessed; editorBeatmap.BeatmapReprocessed -= onBeatmapReprocessed;
} }
private void onBeatmapReprocessed() => (Playfield as CatchEditorPlayfield)?.ApplyCircleSizeToCatcher(editorBeatmap.Difficulty); private void onBeatmapReprocessed()
{
if (Playfield is CatchEditorPlayfield catchPlayfield)
{
catchPlayfield.Catcher.ApplyDifficulty(editorBeatmap.Difficulty);
catchPlayfield.CatcherArea.CatcherTrails.UpdateCatcherTrailsScale(catchPlayfield.Catcher.BodyScale);
}
}
protected override Playfield CreatePlayfield() => new CatchEditorPlayfield(Beatmap.Difficulty); protected override Playfield CreatePlayfield() => new CatchEditorPlayfield(Beatmap.Difficulty);

View File

@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Catch.UI
/// <summary> /// <summary>
/// Width of the area that can be used to attempt catches during gameplay. /// Width of the area that can be used to attempt catches during gameplay.
/// </summary> /// </summary>
public float CatchWidth; public float CatchWidth { get; private set; }
private readonly SkinnableCatcher body; private readonly SkinnableCatcher body;
@ -142,7 +142,7 @@ namespace osu.Game.Rulesets.Catch.UI
Size = new Vector2(BASE_SIZE); Size = new Vector2(BASE_SIZE);
SetScaleAndCatchWidth(difficulty); ApplyDifficulty(difficulty);
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
@ -312,7 +312,7 @@ namespace osu.Game.Rulesets.Catch.UI
/// <summary> /// <summary>
/// Set the scale and catch width. /// Set the scale and catch width.
/// </summary> /// </summary>
public void SetScaleAndCatchWidth(IBeatmapDifficultyInfo? difficulty) public void ApplyDifficulty(IBeatmapDifficultyInfo? difficulty)
{ {
if (difficulty != null) if (difficulty != null)
Scale = calculateScale(difficulty); Scale = calculateScale(difficulty);

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Catch.UI
private readonly CatchComboDisplay comboDisplay; private readonly CatchComboDisplay comboDisplay;
private readonly CatcherTrailDisplay catcherTrails; public readonly CatcherTrailDisplay CatcherTrails;
private Catcher catcher = null!; private Catcher catcher = null!;
@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Catch.UI
Children = new Drawable[] Children = new Drawable[]
{ {
catcherContainer = new Container<Catcher> { RelativeSizeAxes = Axes.Both }, catcherContainer = new Container<Catcher> { RelativeSizeAxes = Axes.Both },
catcherTrails = new CatcherTrailDisplay(), CatcherTrails = new CatcherTrailDisplay(),
comboDisplay = new CatchComboDisplay comboDisplay = new CatchComboDisplay
{ {
RelativeSizeAxes = Axes.None, RelativeSizeAxes = Axes.None,
@ -112,7 +112,7 @@ namespace osu.Game.Rulesets.Catch.UI
{ {
const double trail_generation_interval = 16; const double trail_generation_interval = 16;
if (Time.Current - catcherTrails.LastDashTrailTime >= trail_generation_interval) if (Time.Current - CatcherTrails.LastDashTrailTime >= trail_generation_interval)
displayCatcherTrail(Catcher.HyperDashing ? CatcherTrailAnimation.HyperDashing : CatcherTrailAnimation.Dashing); displayCatcherTrail(Catcher.HyperDashing ? CatcherTrailAnimation.HyperDashing : CatcherTrailAnimation.Dashing);
} }
@ -170,6 +170,6 @@ namespace osu.Game.Rulesets.Catch.UI
} }
} }
private void displayCatcherTrail(CatcherTrailAnimation animation) => catcherTrails.Add(new CatcherTrailEntry(Time.Current, Catcher.CurrentState, Catcher.X, Catcher.BodyScale, animation)); private void displayCatcherTrail(CatcherTrailAnimation animation) => CatcherTrails.Add(new CatcherTrailEntry(Time.Current, Catcher.CurrentState, Catcher.X, Catcher.BodyScale, animation));
} }
} }

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Pooling;
using osu.Game.Rulesets.Catch.Skinning; using osu.Game.Rulesets.Catch.Skinning;
using osu.Game.Rulesets.Objects.Pooling; using osu.Game.Rulesets.Objects.Pooling;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Rulesets.Catch.UI namespace osu.Game.Rulesets.Catch.UI
@ -55,6 +56,25 @@ namespace osu.Game.Rulesets.Catch.UI
}; };
} }
/// <summary>
/// Update the scale of all trails.
/// </summary>
/// <param name="scale">The new body scale of the Catcher</param>
public void UpdateCatcherTrailsScale(Vector2 scale)
{
applyScaleChange(scale, dashTrails);
applyScaleChange(scale, hyperDashTrails);
applyScaleChange(scale, hyperDashAfterImages);
}
private void applyScaleChange(Vector2 scale, Container<CatcherTrail> trails)
{
foreach (var trail in trails)
{
trail.Scale = scale;
}
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();