mirror of
https://github.com/ppy/osu.git
synced 2024-11-08 06:19:38 +08:00
Merge pull request #6752 from smoogipoo/fix-mania-compose-crash
Fix possible crash when loading mania compose screen
This commit is contained in:
commit
7d5b6226a9
@ -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.Edit.Blueprints.Components;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
{
|
||||
public class HoldNoteNoteSelectionBlueprint : ManiaSelectionBlueprint
|
||||
{
|
||||
protected new DrawableHoldNote DrawableObject => (DrawableHoldNote)base.DrawableObject;
|
||||
|
||||
private readonly HoldNotePosition position;
|
||||
|
||||
public HoldNoteNoteSelectionBlueprint(DrawableHoldNote holdNote, HoldNotePosition position)
|
||||
: base(holdNote)
|
||||
{
|
||||
this.position = position;
|
||||
InternalChild = new EditNotePiece { RelativeSizeAxes = Axes.X };
|
||||
|
||||
Select();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// Todo: This shouldn't exist, mania should not reference the drawable hitobject directly.
|
||||
if (DrawableObject.IsLoaded)
|
||||
{
|
||||
DrawableNote note = position == HoldNotePosition.Start ? DrawableObject.Head : DrawableObject.Tail;
|
||||
|
||||
Anchor = note.Anchor;
|
||||
Origin = note.Origin;
|
||||
|
||||
Size = note.DrawSize;
|
||||
Position = note.DrawPosition;
|
||||
}
|
||||
}
|
||||
|
||||
// Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input.
|
||||
public override bool HandlePositionalInput => false;
|
||||
}
|
||||
}
|
11
osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePosition.cs
Normal file
11
osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePosition.cs
Normal file
@ -0,0 +1,11 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
{
|
||||
public enum HoldNotePosition
|
||||
{
|
||||
Start,
|
||||
End
|
||||
}
|
||||
}
|
@ -40,8 +40,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new HoldNoteNoteSelectionBlueprint(DrawableObject.Head),
|
||||
new HoldNoteNoteSelectionBlueprint(DrawableObject.Tail),
|
||||
new HoldNoteNoteSelectionBlueprint(DrawableObject, HoldNotePosition.Start),
|
||||
new HoldNoteNoteSelectionBlueprint(DrawableObject, HoldNotePosition.End),
|
||||
new BodyPiece
|
||||
{
|
||||
AccentColour = Color4.Transparent,
|
||||
@ -54,6 +54,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// Todo: This shouldn't exist, mania should not reference the drawable hitobject directly.
|
||||
if (DrawableObject.IsLoaded)
|
||||
{
|
||||
Size = DrawableObject.DrawSize + new Vector2(0, DrawableObject.Tail.DrawHeight);
|
||||
|
||||
// This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do
|
||||
@ -62,29 +65,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
if (direction.Value == ScrollingDirection.Down)
|
||||
Y -= DrawableObject.Tail.DrawHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public override Quad SelectionQuad => ScreenSpaceDrawQuad;
|
||||
|
||||
private class HoldNoteNoteSelectionBlueprint : NoteSelectionBlueprint
|
||||
{
|
||||
public HoldNoteNoteSelectionBlueprint(DrawableNote note)
|
||||
: base(note)
|
||||
{
|
||||
Select();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Anchor = DrawableObject.Anchor;
|
||||
Origin = DrawableObject.Origin;
|
||||
|
||||
Position = DrawableObject.DrawPosition;
|
||||
}
|
||||
|
||||
// Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input.
|
||||
public override bool HandlePositionalInput => false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// Todo: This shouldn't exist, mania should not reference the drawable hitobject directly.
|
||||
if (DrawableObject.IsLoaded)
|
||||
Size = DrawableObject.DrawSize;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user