1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-04 04:13:37 +08:00

Improve visual appearance of mania selection blueprints

This commit is contained in:
Bartłomiej Dach
2024-11-05 15:23:09 +01:00
Unverified
parent 2bd12e14db
commit dfda5e1b66
4 changed files with 51 additions and 7 deletions
@@ -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;
@@ -29,7 +30,11 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints.Components
CornerRadius = 5;
Masking = true;
InternalChild = new DefaultNotePiece();
InternalChild = new EditNotePiece
{
RelativeSizeAxes = Axes.Both,
Height = 1,
};
}
protected override void LoadComplete()
@@ -60,19 +65,23 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints.Components
{
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;
@@ -1,10 +1,14 @@
// 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 System;
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 osuTK.Graphics;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints.Components
{
@@ -12,12 +16,17 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints.Components
{
public EditNotePiece()
{
Masking = true;
BorderThickness = 9; // organoleptically chosen to look good enough for all default skins
BorderColour = Color4.White;
Height = DefaultNotePiece.NOTE_HEIGHT;
CornerRadius = 5;
Masking = true;
InternalChild = new DefaultNotePiece();
InternalChild = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
};
}
[BackgroundDependencyLoader]
@@ -25,5 +34,17 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints.Components
{
Colour = colours.Yellow;
}
protected override void Update()
{
base.Update();
// from anecdotal experience, there are generally two types of user skins:
// one type uses rectangles for notes, and the other uses circles / squarish sprites (various stepmania-likes).
// this is a crude heuristic that attempts to choose the best of both worlds based on aspect ratio alone.
float aspectRatio = DrawWidth / DrawHeight;
bool isSquarish = aspectRatio > 4f / 5 && aspectRatio < 5f / 4;
CornerRadius = isSquarish ? Math.Min(DrawWidth, DrawHeight) / 2 : 5;
}
}
}
@@ -10,6 +10,7 @@ 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.Screens.Edit;
using osuTK;
@@ -32,6 +33,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
private EditHoldNoteEndPiece head = null!;
private EditHoldNoteEndPiece tail = null!;
protected new DrawableHoldNote DrawableObject => (DrawableHoldNote)base.DrawableObject;
public HoldNoteSelectionBlueprint(HoldNote hold)
: base(hold)
{
@@ -99,7 +102,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
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;
}
@@ -9,10 +9,19 @@ 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 });
AddInternal(notePiece = new EditNotePiece { RelativeSizeAxes = Axes.X });
}
protected override void Update()
{
base.Update();
notePiece.Height = DrawableObject.DrawHeight;
}
}
}