Merge pull request #30512 from bdach/improve-mania-selection-blueprints

Improve visual appearance of mania selection blueprints
This commit is contained in:
Dean Herbert 2024-11-15 19:36:01 +09:00 committed by GitHub
commit d28d54feb7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 175 additions and 58 deletions

View File

@ -5,6 +5,7 @@
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.Edit.Blueprints;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Screens.Edit.Compose.Components;
@ -106,7 +107,7 @@ public void TestOffScreenObjectsRemainSelectedOnColumnChange()
AddStep("select everything", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
AddStep("start drag", () =>
{
InputManager.MoveMouseTo(this.ChildrenOfType<Column>().First());
InputManager.MoveMouseTo(this.ChildrenOfType<NoteSelectionBlueprint>().Single(blueprint => blueprint.IsSelected && blueprint.HitObject.StartTime == 0));
InputManager.PressButton(MouseButton.Left);
});
AddStep("end drag", () =>

View File

@ -3,21 +3,39 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Skinning.Default;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints.Components
{
public partial class EditBodyPiece : DefaultBodyPiece
public partial class EditBodyPiece : CompositeDrawable
{
private readonly Container border;
public EditBodyPiece()
{
InternalChildren = new Drawable[]
{
border = new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = 3,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour.Value = colours.Yellow;
Background.Alpha = 0.5f;
border.BorderColour = colours.YellowDarker;
}
protected override Drawable CreateForeground() => base.CreateForeground().With(d => d.Alpha = 0);
}
}

View File

@ -4,6 +4,7 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
@ -26,10 +27,11 @@ private void load()
{
Height = DefaultNotePiece.NOTE_HEIGHT;
CornerRadius = 5;
Masking = true;
InternalChild = new DefaultNotePiece();
InternalChild = new EditNotePiece
{
RelativeSizeAxes = Axes.Both,
Height = 1,
};
}
protected override void LoadComplete()
@ -60,19 +62,23 @@ protected override void OnDrag(DragEvent e)
{
base.OnDrag(e);
Dragging?.Invoke(e.ScreenSpaceMousePosition);
updateState();
}
protected override void OnDragEnd(DragEndEvent e)
{
base.OnDragEnd(e);
DragEnded?.Invoke();
updateState();
}
private void updateState()
{
InternalChild.Colour = Colour4.White;
var colour = colours.Yellow;
if (IsHovered)
if (IsHovered || IsDragged)
colour = colour.Lighten(1);
Colour = colour;

View File

@ -2,28 +2,63 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Skinning.Default;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints.Components
{
public partial class EditNotePiece : CompositeDrawable
{
private readonly Container border;
private readonly Box box;
[Resolved]
private Column? column { get; set; }
public EditNotePiece()
{
Height = DefaultNotePiece.NOTE_HEIGHT;
CornerRadius = 5;
Masking = true;
InternalChild = new DefaultNotePiece();
InternalChildren = new Drawable[]
{
border = new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = 3,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
},
box = new Box
{
RelativeSizeAxes = Axes.X,
Height = 3,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = colours.Yellow;
border.BorderColour = colours.YellowDark;
box.Colour = colours.YellowLight;
}
protected override void Update()
{
base.Update();
if (column != null)
Scale = new Vector2(1, column.ScrollingInfo.Direction.Value == ScrollingDirection.Down ? 1 : -1);
}
}
}

View File

@ -4,8 +4,10 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects;
@ -17,9 +19,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
public partial class HoldNotePlacementBlueprint : ManiaPlacementBlueprint<HoldNote>
{
private readonly EditBodyPiece bodyPiece;
private readonly EditNotePiece headPiece;
private readonly EditNotePiece tailPiece;
private EditBodyPiece bodyPiece = null!;
private Circle headPiece = null!;
private Circle tailPiece = null!;
[Resolved]
private IScrollingInfo scrollingInfo { get; set; } = null!;
@ -28,14 +30,29 @@ public partial class HoldNotePlacementBlueprint : ManiaPlacementBlueprint<HoldNo
public HoldNotePlacementBlueprint()
: base(new HoldNote())
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
bodyPiece = new EditBodyPiece { Origin = Anchor.TopCentre },
headPiece = new EditNotePiece { Origin = Anchor.Centre },
tailPiece = new EditNotePiece { Origin = Anchor.Centre }
headPiece = new Circle
{
Origin = Anchor.Centre,
Colour = colours.Yellow,
Height = 10
},
tailPiece = new Circle
{
Origin = Anchor.Centre,
Colour = colours.Yellow,
Height = 10
},
};
}

View File

@ -2,14 +2,14 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Screens.Edit;
using osuTK;
@ -17,9 +17,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
public partial class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint<HoldNote>
{
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved]
private IEditorChangeHandler? changeHandler { get; set; }
@ -29,9 +26,12 @@ public partial class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint<HoldNo
[Resolved]
private IPositionSnapProvider? positionSnapProvider { get; set; }
private EditBodyPiece body = null!;
private EditHoldNoteEndPiece head = null!;
private EditHoldNoteEndPiece tail = null!;
protected new DrawableHoldNote DrawableObject => (DrawableHoldNote)base.DrawableObject;
public HoldNoteSelectionBlueprint(HoldNote hold)
: base(hold)
{
@ -42,9 +42,17 @@ private void load()
{
InternalChildren = new Drawable[]
{
body = new EditBodyPiece
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
},
head = new EditHoldNoteEndPiece
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
DragStarted = () => changeHandler?.BeginChange(),
Dragging = pos =>
{
@ -64,6 +72,8 @@ private void load()
tail = new EditHoldNoteEndPiece
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
DragStarted = () => changeHandler?.BeginChange(),
Dragging = pos =>
{
@ -79,19 +89,6 @@ private void load()
},
DragEnded = () => changeHandler?.EndChange(),
},
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = 1,
BorderColour = colours.Yellow,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
}
}
};
}
@ -99,11 +96,23 @@ protected override void Update()
{
base.Update();
head.Height = DrawableObject.Head.DrawHeight;
head.Y = HitObjectContainer.PositionAtTime(HitObject.Head.StartTime, HitObject.StartTime);
tail.Height = DrawableObject.Tail.DrawHeight;
tail.Y = HitObjectContainer.PositionAtTime(HitObject.Tail.StartTime, HitObject.StartTime);
Height = HitObjectContainer.LengthAtTime(HitObject.StartTime, HitObject.EndTime) + tail.DrawHeight;
}
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
{
Origin = direction.NewValue == ScrollingDirection.Down ? Anchor.BottomCentre : Anchor.TopCentre;
foreach (var child in InternalChildren)
child.Anchor = Origin;
head.Scale = tail.Scale = body.Scale = new Vector2(1, direction.NewValue == ScrollingDirection.Down ? 1 : -1);
}
public override Quad SelectionQuad => ScreenSpaceDrawQuad;
public override Vector2 ScreenSpaceSelectionPoint => head.ScreenSpaceDrawQuad.Centre;

View File

@ -37,16 +37,10 @@ private void load(IScrollingInfo scrollingInfo)
protected override void LoadComplete()
{
base.LoadComplete();
directionBindable.BindValueChanged(onDirectionChanged, true);
directionBindable.BindValueChanged(OnDirectionChanged, true);
}
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
{
var anchor = direction.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
Anchor = Origin = anchor;
foreach (var child in InternalChildren)
child.Anchor = child.Origin = anchor;
}
protected abstract void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> direction);
protected override void Update()
{

View File

@ -1,10 +1,12 @@
// 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.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects;
using osuTK.Input;
@ -12,14 +14,25 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
public partial class NotePlacementBlueprint : ManiaPlacementBlueprint<Note>
{
private readonly EditNotePiece piece;
private Circle piece = null!;
public NotePlacementBlueprint()
: base(new Note())
{
RelativeSizeAxes = Axes.Both;
}
InternalChild = piece = new EditNotePiece { Origin = Anchor.Centre };
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
RelativeSizeAxes = Axes.Both;
Masking = true;
InternalChild = piece = new Circle
{
Origin = Anchor.Centre,
Colour = colours.Yellow,
Height = 10
};
}
public override void UpdateTimeAndPosition(SnapResult result)

View File

@ -1,18 +1,42 @@
// 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.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
public partial class NoteSelectionBlueprint : ManiaSelectionBlueprint<Note>
{
private readonly EditNotePiece notePiece;
public NoteSelectionBlueprint(Note note)
: base(note)
{
AddInternal(new EditNotePiece { RelativeSizeAxes = Axes.X });
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
AddInternal(notePiece = new EditNotePiece
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
});
}
protected override void Update()
{
base.Update();
notePiece.Height = DrawableObject.DrawHeight;
}
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
{
notePiece.Scale = new Vector2(1, direction.NewValue == ScrollingDirection.Down ? 1 : -1);
}
}
}