mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 16:35:37 +08:00
Avoid extra unnecessary DI
Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
parent
8151c3095d
commit
ffc37cece0
@ -161,7 +161,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
/// <returns>The scroll time.</returns>
|
/// <returns>The scroll time.</returns>
|
||||||
public static double ComputeScrollTime(double scrollSpeed) => MAX_TIME_RANGE / scrollSpeed;
|
public static double ComputeScrollTime(double scrollSpeed) => MAX_TIME_RANGE / scrollSpeed;
|
||||||
|
|
||||||
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new ManiaPlayfieldAdjustmentContainer();
|
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new ManiaPlayfieldAdjustmentContainer(this);
|
||||||
|
|
||||||
protected override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages);
|
protected override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages);
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
@ -16,8 +15,11 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
private readonly DrawSizePreservingFillContainer scalingContainer;
|
private readonly DrawSizePreservingFillContainer scalingContainer;
|
||||||
|
|
||||||
public ManiaPlayfieldAdjustmentContainer()
|
private readonly DrawableManiaRuleset drawableManiaRuleset;
|
||||||
|
|
||||||
|
public ManiaPlayfieldAdjustmentContainer(DrawableManiaRuleset drawableManiaRuleset)
|
||||||
{
|
{
|
||||||
|
this.drawableManiaRuleset = drawableManiaRuleset;
|
||||||
InternalChild = scalingContainer = new DrawSizePreservingFillContainer
|
InternalChild = scalingContainer = new DrawSizePreservingFillContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -30,9 +32,6 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private DrawableRuleset drawableRuleset { get; set; } = null!;
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -40,8 +39,6 @@ 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,
|
||||||
|
@ -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;
|
||||||
|
|
||||||
public readonly DrawableRuleset<TObject> DrawableRuleset;
|
private 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)
|
||||||
{
|
{
|
||||||
DrawableRuleset = drawableRuleset;
|
this.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)
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,6 @@ 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[]
|
||||||
|
Loading…
Reference in New Issue
Block a user