1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-18 10:02:54 +08:00

Fix failing tests

- Caches `DrawableRuleset` in editor compose screen for mania playfield adjustment container (because it's used to wrap the blueprint container as well)
- Fixes `ManiaModWithPlayfieldCover` performing a no-longer-correct direct cast with a naive-but-working approach.
This commit is contained in:
Salman Alshamrani 2025-01-12 22:56:28 -05:00
parent f718696102
commit c1ac27d658
6 changed files with 27 additions and 15 deletions

View File

@ -5,9 +5,9 @@ using System;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mania.UI.Components;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Mania.Mods
foreach (Column column in maniaPlayfield.Stages.SelectMany(stage => stage.Columns)) foreach (Column column in maniaPlayfield.Stages.SelectMany(stage => stage.Columns))
{ {
HitObjectContainer hoc = column.HitObjectContainer; HitObjectContainer hoc = column.HitObjectContainer;
Container hocParent = (Container)hoc.Parent!; ColumnHitObjectArea hocParent = (ColumnHitObjectArea)hoc.Parent!;
hocParent.Remove(hoc, false); hocParent.Remove(hoc, false);
hocParent.Add(CreateCover(hoc).With(c => hocParent.Add(CreateCover(hoc).With(c =>

View File

@ -19,6 +19,16 @@ namespace osu.Game.Rulesets.Mania.UI.Components
InternalChild = child; InternalChild = child;
} }
internal void Add(Drawable drawable)
{
base.AddInternal(drawable);
}
internal void Remove(Drawable drawable, bool disposeImmediately = true)
{
base.RemoveInternal(drawable, disposeImmediately);
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IScrollingInfo scrollingInfo) private void load(IScrollingInfo scrollingInfo)
{ {

View File

@ -32,7 +32,6 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Mania.UI namespace osu.Game.Rulesets.Mania.UI
{ {
[Cached(typeof(DrawableManiaRuleset))]
public partial class DrawableManiaRuleset : DrawableScrollingRuleset<ManiaHitObject> public partial class DrawableManiaRuleset : DrawableScrollingRuleset<ManiaHitObject>
{ {
/// <summary> /// <summary>

View File

@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Mania.UI
} }
[Resolved] [Resolved]
private DrawableManiaRuleset drawableManiaRuleset { get; set; } = null!; private DrawableRuleset drawableRuleset { get; set; } = null!;
protected override void Update() protected override void Update()
{ {
@ -40,6 +40,8 @@ namespace osu.Game.Rulesets.Mania.UI
float aspectRatio = DrawWidth / DrawHeight; float aspectRatio = DrawWidth / DrawHeight;
bool isPortrait = aspectRatio < 1f; bool isPortrait = aspectRatio < 1f;
var drawableManiaRuleset = (DrawableManiaRuleset)drawableRuleset;
if (isPortrait && drawableManiaRuleset.Beatmap.Stages.Count == 1) if (isPortrait && drawableManiaRuleset.Beatmap.Stages.Count == 1)
{ {
// Scale playfield up by 25% to become playable on mobile devices, // Scale playfield up by 25% to become playable on mobile devices,

View File

@ -19,16 +19,16 @@ namespace osu.Game.Rulesets.Edit
internal partial class DrawableEditorRulesetWrapper<TObject> : CompositeDrawable internal partial class DrawableEditorRulesetWrapper<TObject> : CompositeDrawable
where TObject : HitObject where TObject : HitObject
{ {
public Playfield Playfield => drawableRuleset.Playfield; public Playfield Playfield => DrawableRuleset.Playfield;
private readonly DrawableRuleset<TObject> drawableRuleset; public readonly DrawableRuleset<TObject> DrawableRuleset;
[Resolved] [Resolved]
private EditorBeatmap beatmap { get; set; } = null!; private EditorBeatmap beatmap { get; set; } = null!;
public DrawableEditorRulesetWrapper(DrawableRuleset<TObject> drawableRuleset) public DrawableEditorRulesetWrapper(DrawableRuleset<TObject> drawableRuleset)
{ {
this.drawableRuleset = drawableRuleset; DrawableRuleset = drawableRuleset;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Edit
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
drawableRuleset.FrameStablePlayback = false; DrawableRuleset.FrameStablePlayback = false;
Playfield.DisplayJudgements.Value = false; Playfield.DisplayJudgements.Value = false;
} }
@ -67,27 +67,27 @@ namespace osu.Game.Rulesets.Edit
private void regenerateAutoplay() private void regenerateAutoplay()
{ {
var autoplayMod = drawableRuleset.Mods.OfType<ModAutoplay>().Single(); var autoplayMod = DrawableRuleset.Mods.OfType<ModAutoplay>().Single();
drawableRuleset.SetReplayScore(autoplayMod.CreateScoreFromReplayData(drawableRuleset.Beatmap, drawableRuleset.Mods)); DrawableRuleset.SetReplayScore(autoplayMod.CreateScoreFromReplayData(DrawableRuleset.Beatmap, DrawableRuleset.Mods));
} }
private void addHitObject(HitObject hitObject) private void addHitObject(HitObject hitObject)
{ {
drawableRuleset.AddHitObject((TObject)hitObject); DrawableRuleset.AddHitObject((TObject)hitObject);
drawableRuleset.Playfield.PostProcess(); DrawableRuleset.Playfield.PostProcess();
} }
private void removeHitObject(HitObject hitObject) private void removeHitObject(HitObject hitObject)
{ {
drawableRuleset.RemoveHitObject((TObject)hitObject); DrawableRuleset.RemoveHitObject((TObject)hitObject);
drawableRuleset.Playfield.PostProcess(); DrawableRuleset.Playfield.PostProcess();
} }
public override bool PropagatePositionalInputSubTree => false; public override bool PropagatePositionalInputSubTree => false;
public override bool PropagateNonPositionalInputSubTree => false; public override bool PropagateNonPositionalInputSubTree => false;
public PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => drawableRuleset.CreatePlayfieldAdjustmentContainer(); public PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => DrawableRuleset.CreatePlayfieldAdjustmentContainer();
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {

View File

@ -132,6 +132,7 @@ namespace osu.Game.Rulesets.Edit
if (DrawableRuleset is IDrawableScrollingRuleset scrollingRuleset) if (DrawableRuleset is IDrawableScrollingRuleset scrollingRuleset)
dependencies.CacheAs(scrollingRuleset.ScrollingInfo); dependencies.CacheAs(scrollingRuleset.ScrollingInfo);
dependencies.CacheAs<DrawableRuleset>(drawableRulesetWrapper.DrawableRuleset);
dependencies.CacheAs(Playfield); dependencies.CacheAs(Playfield);
InternalChildren = new[] InternalChildren = new[]