Skip to content

Commit

Permalink
Fix mania notes disappearing on seek to their end time
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Nov 18, 2024
1 parent 28fb0bf commit 15a8cfe
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 6 deletions.
45 changes: 45 additions & 0 deletions osu.Game.Rulesets.Mania/Edit/EditorColumn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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.

using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects.Drawables;

namespace osu.Game.Rulesets.Mania.Edit
{
public partial class EditorColumn : Column
{
public EditorColumn(int index, bool isSpecial)
: base(index, isSpecial)
{
}

protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObject)
{
base.OnNewDrawableHitObject(drawableHitObject);
drawableHitObject.ApplyCustomUpdateState += (dho, state) =>
{
switch (dho)
{
// hold note heads are exempt from what follows due to the "freezing" mechanic
// which already ensures they'll never fade away on their own.
case DrawableHoldNoteHead:
break;

// mania features instantaneous hitobject fade-outs.
// this means that without manual intervention stopping the clock at the precise time of hitting the object
// means the object will fade out.
// this is anti-user in editor contexts, as the user is expecting to continue the see the note on the receptor line.
// therefore, apply a crude workaround to prevent it from going away.
default:
{
if (state == ArmedState.Hit)
dho.FadeTo(1).Delay(1).FadeOut().Expire();
break;
}
}
};
}
}
}
18 changes: 18 additions & 0 deletions osu.Game.Rulesets.Mania/Edit/EditorStage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.UI;

namespace osu.Game.Rulesets.Mania.Edit
{
public partial class EditorStage : Stage
{
public EditorStage(int firstColumnIndex, StageDefinition definition, ref ManiaAction columnStartAction)
: base(firstColumnIndex, definition, ref columnStartAction)
{
}

protected override Column CreateColumn(int index, bool isSpecial) => new EditorColumn(index, isSpecial);
}
}
3 changes: 3 additions & 0 deletions osu.Game.Rulesets.Mania/Edit/ManiaEditorPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ public ManiaEditorPlayfield(List<StageDefinition> stages)
: base(stages)
{
}

protected override Stage CreateStage(int firstColumnIndex, StageDefinition stageDefinition, ref ManiaAction columnAction)
=> new EditorStage(firstColumnIndex, stageDefinition, ref columnAction);
}
}
6 changes: 5 additions & 1 deletion osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics.Containers;
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Mania.Beatmaps;
Expand Down Expand Up @@ -71,7 +72,7 @@ public ManiaPlayfield(List<StageDefinition> stageDefinitions)

for (int i = 0; i < stageDefinitions.Count; i++)
{
var newStage = new Stage(firstColumnIndex, stageDefinitions[i], ref columnAction);
var newStage = CreateStage(firstColumnIndex, stageDefinitions[i], ref columnAction);

playfieldGrid.Content[0][i] = newStage;

Expand All @@ -82,6 +83,9 @@ public ManiaPlayfield(List<StageDefinition> stageDefinitions)
}
}

[Pure]
protected virtual Stage CreateStage(int firstColumnIndex, StageDefinition stageDefinition, ref ManiaAction columnAction) => new Stage(firstColumnIndex, stageDefinition, ref columnAction);

public override void Add(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Add(hitObject);

public override bool Remove(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Remove(hitObject);
Expand Down
16 changes: 11 additions & 5 deletions osu.Game.Rulesets.Mania/UI/Stage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
Expand Down Expand Up @@ -134,12 +135,14 @@ public Stage(int firstColumnIndex, StageDefinition definition, ref ManiaAction c
{
bool isSpecial = definition.IsSpecialColumn(i);

var column = new Column(firstColumnIndex + i, isSpecial)
var action = columnStartAction;
columnStartAction++;
var column = CreateColumn(firstColumnIndex + i, isSpecial).With(c =>
{
RelativeSizeAxes = Axes.Both,
Width = 1,
Action = { Value = columnStartAction++ }
};
c.RelativeSizeAxes = Axes.Both;
c.Width = 1;
c.Action.Value = action;
});

topLevelContainer.Add(column.TopLevelContainer.CreateProxy());
columnBackgrounds.Add(column.BackgroundContainer.CreateProxy());
Expand All @@ -154,6 +157,9 @@ public Stage(int firstColumnIndex, StageDefinition definition, ref ManiaAction c
RegisterPool<BarLine, DrawableBarLine>(50, 200);
}

[Pure]
protected virtual Column CreateColumn(int index, bool isSpecial) => new Column(index, isSpecial);

[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
Expand Down

0 comments on commit 15a8cfe

Please sign in to comment.