mirror of
https://github.com/ppy/osu
synced 2025-01-08 23:29:43 +00:00
Implement mania note skinning
This commit is contained in:
parent
b926d570ee
commit
c4f76ffdaf
24
osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneHoldNote.cs
Normal file
24
osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneHoldNote.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
{
|
||||
public class TestSceneHoldNote : ManiaHitObjectTestScene
|
||||
{
|
||||
protected override DrawableManiaHitObject CreateHitObject()
|
||||
{
|
||||
var note = new HoldNote { Duration = 1000 };
|
||||
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
return new DrawableHoldNote(note)
|
||||
{
|
||||
Height = 200,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
21
osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneNote.cs
Normal file
21
osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneNote.cs
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
{
|
||||
public class TestSceneNote : ManiaHitObjectTestScene
|
||||
{
|
||||
protected override DrawableManiaHitObject CreateHitObject()
|
||||
{
|
||||
var note = new Note();
|
||||
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
return new DrawableNote(note);
|
||||
}
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Y = -0.25f,
|
||||
Size = new Vector2(Column.COLUMN_WIDTH, NotePiece.NOTE_HEIGHT),
|
||||
Size = new Vector2(Column.COLUMN_WIDTH, DefaultNotePiece.NOTE_HEIGHT),
|
||||
};
|
||||
|
||||
int runcount = 0;
|
||||
|
@ -12,12 +12,12 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints.Components
|
||||
{
|
||||
public EditNotePiece()
|
||||
{
|
||||
Height = NotePiece.NOTE_HEIGHT;
|
||||
Height = DefaultNotePiece.NOTE_HEIGHT;
|
||||
|
||||
CornerRadius = 5;
|
||||
Masking = true;
|
||||
|
||||
InternalChild = new NotePiece();
|
||||
InternalChild = new DefaultNotePiece();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -122,11 +122,11 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
switch (scrollingInfo.Direction.Value)
|
||||
{
|
||||
case ScrollingDirection.Up:
|
||||
mousePosition.Y -= NotePiece.NOTE_HEIGHT / 2;
|
||||
mousePosition.Y -= DefaultNotePiece.NOTE_HEIGHT / 2;
|
||||
break;
|
||||
|
||||
case ScrollingDirection.Down:
|
||||
mousePosition.Y += NotePiece.NOTE_HEIGHT / 2;
|
||||
mousePosition.Y += DefaultNotePiece.NOTE_HEIGHT / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -143,11 +143,11 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
switch (scrollingInfo.Direction.Value)
|
||||
{
|
||||
case ScrollingDirection.Up:
|
||||
hitObjectPosition.Y += NotePiece.NOTE_HEIGHT / 2;
|
||||
hitObjectPosition.Y += DefaultNotePiece.NOTE_HEIGHT / 2;
|
||||
break;
|
||||
|
||||
case ScrollingDirection.Down:
|
||||
hitObjectPosition.Y -= NotePiece.NOTE_HEIGHT / 2;
|
||||
hitObjectPosition.Y -= DefaultNotePiece.NOTE_HEIGHT / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,9 @@ namespace osu.Game.Rulesets.Mania
|
||||
{
|
||||
ColumnBackground,
|
||||
HitTarget,
|
||||
KeyArea
|
||||
KeyArea,
|
||||
Note,
|
||||
HoldNoteHead,
|
||||
HoldNoteTail,
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,12 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
@ -18,7 +17,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
/// </summary>
|
||||
public class DrawableNote : DrawableManiaHitObject<Note>, IKeyBindingHandler<ManiaAction>
|
||||
{
|
||||
private readonly NotePiece headPiece;
|
||||
protected virtual ManiaSkinComponents Component => ManiaSkinComponents.Note;
|
||||
|
||||
private readonly Drawable headPiece;
|
||||
|
||||
public DrawableNote(Note hitObject)
|
||||
: base(hitObject)
|
||||
@ -26,22 +27,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
CornerRadius = 5;
|
||||
Masking = true;
|
||||
|
||||
AddInternal(headPiece = new NotePiece());
|
||||
|
||||
AccentColour.BindValueChanged(colour =>
|
||||
AddInternal(headPiece = new SkinnableDrawable(new ManiaSkinComponent(Component), _ => new DefaultNotePiece())
|
||||
{
|
||||
headPiece.AccentColour = colour.NewValue;
|
||||
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Glow,
|
||||
Colour = colour.NewValue.Lighten(1f).Opacity(0.2f),
|
||||
Radius = 10,
|
||||
};
|
||||
}, true);
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> e)
|
||||
|
@ -7,8 +7,9 @@ using osuTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
|
||||
@ -16,20 +17,24 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
|
||||
/// <summary>
|
||||
/// Represents the static hit markers of notes.
|
||||
/// </summary>
|
||||
internal class NotePiece : Container, IHasAccentColour
|
||||
internal class DefaultNotePiece : CompositeDrawable
|
||||
{
|
||||
public const float NOTE_HEIGHT = 12;
|
||||
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
||||
|
||||
private readonly Box colouredBox;
|
||||
|
||||
public NotePiece()
|
||||
public DefaultNotePiece()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = NOTE_HEIGHT;
|
||||
|
||||
Children = new[]
|
||||
CornerRadius = 5;
|
||||
Masking = true;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
@ -45,29 +50,32 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IScrollingInfo scrollingInfo)
|
||||
private void load(IScrollingInfo scrollingInfo, DrawableHitObject drawableObject)
|
||||
{
|
||||
direction.BindTo(scrollingInfo.Direction);
|
||||
direction.BindValueChanged(dir =>
|
||||
{
|
||||
colouredBox.Anchor = colouredBox.Origin = dir.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
|
||||
}, true);
|
||||
direction.BindValueChanged(onDirectionChanged, true);
|
||||
|
||||
accentColour.BindTo(drawableObject.AccentColour);
|
||||
accentColour.BindValueChanged(onAccentChanged, true);
|
||||
}
|
||||
|
||||
private Color4 accentColour;
|
||||
|
||||
public Color4 AccentColour
|
||||
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
||||
{
|
||||
get => accentColour;
|
||||
set
|
||||
colouredBox.Anchor = colouredBox.Origin = direction.NewValue == ScrollingDirection.Up
|
||||
? Anchor.TopCentre
|
||||
: Anchor.BottomCentre;
|
||||
}
|
||||
|
||||
private void onAccentChanged(ValueChangedEvent<Color4> accent)
|
||||
{
|
||||
colouredBox.Colour = accent.NewValue.Lighten(0.9f);
|
||||
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
if (accentColour == value)
|
||||
return;
|
||||
|
||||
accentColour = value;
|
||||
|
||||
colouredBox.Colour = AccentColour.Lighten(0.9f);
|
||||
}
|
||||
Type = EdgeEffectType.Glow,
|
||||
Colour = accent.NewValue.Lighten(1f).Opacity(0.2f),
|
||||
Radius = 10,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
17
osu.Game.Rulesets.Mania/Skinning/LegacyHoldNoteHeadPiece.cs
Normal file
17
osu.Game.Rulesets.Mania/Skinning/LegacyHoldNoteHeadPiece.cs
Normal file
@ -0,0 +1,17 @@
|
||||
// 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.Textures;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
public class LegacyHoldNoteHeadPiece : LegacyNotePiece
|
||||
{
|
||||
protected override Texture GetTexture(ISkinSource skin)
|
||||
{
|
||||
return GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage)
|
||||
?? GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
|
||||
}
|
||||
}
|
||||
}
|
27
osu.Game.Rulesets.Mania/Skinning/LegacyHoldNoteTailPiece.cs
Normal file
27
osu.Game.Rulesets.Mania/Skinning/LegacyHoldNoteTailPiece.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// 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.Textures;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
public class LegacyHoldNoteTailPiece : LegacyNotePiece
|
||||
{
|
||||
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
||||
{
|
||||
// Invert the direction
|
||||
base.OnDirectionChanged(direction.NewValue == ScrollingDirection.Up
|
||||
? new ValueChangedEvent<ScrollingDirection>(ScrollingDirection.Down, ScrollingDirection.Down)
|
||||
: new ValueChangedEvent<ScrollingDirection>(ScrollingDirection.Up, ScrollingDirection.Up));
|
||||
}
|
||||
|
||||
protected override Texture GetTexture(ISkinSource skin)
|
||||
{
|
||||
return GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteTailImage)
|
||||
?? GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage);
|
||||
}
|
||||
}
|
||||
}
|
93
osu.Game.Rulesets.Mania/Skinning/LegacyNotePiece.cs
Normal file
93
osu.Game.Rulesets.Mania/Skinning/LegacyNotePiece.cs
Normal file
@ -0,0 +1,93 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
public class LegacyNotePiece : LegacyManiaColumnElement
|
||||
{
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
private Container directionContainer;
|
||||
private Sprite noteSprite;
|
||||
|
||||
public LegacyNotePiece()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
||||
{
|
||||
InternalChild = directionContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = noteSprite = new Sprite { Texture = GetTexture(skin) }
|
||||
};
|
||||
|
||||
direction.BindTo(scrollingInfo.Direction);
|
||||
direction.BindValueChanged(OnDirectionChanged, true);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (noteSprite.Texture != null)
|
||||
{
|
||||
var scale = DrawWidth / noteSprite.Texture.DisplayWidth;
|
||||
noteSprite.Scale = new Vector2(scale);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
||||
{
|
||||
if (direction.NewValue == ScrollingDirection.Up)
|
||||
{
|
||||
directionContainer.Origin = Anchor.BottomCentre;
|
||||
directionContainer.Scale = new Vector2(1, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
directionContainer.Origin = Anchor.TopCentre;
|
||||
directionContainer.Scale = Vector2.One;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual Texture GetTexture(ISkinSource skin) => GetTextureFromLookup(skin, LegacyManiaSkinConfigurationLookups.NoteImage);
|
||||
|
||||
protected Texture GetTextureFromLookup(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
|
||||
{
|
||||
string suffix = string.Empty;
|
||||
|
||||
switch (lookup)
|
||||
{
|
||||
case LegacyManiaSkinConfigurationLookups.HoldNoteHeadImage:
|
||||
suffix = "H";
|
||||
break;
|
||||
|
||||
case LegacyManiaSkinConfigurationLookups.HoldNoteTailImage:
|
||||
suffix = "T";
|
||||
break;
|
||||
}
|
||||
|
||||
string noteImage = skin.GetConfig<LegacyManiaSkinConfigurationLookup, string>(
|
||||
new LegacyManiaSkinConfigurationLookup(Stage?.Columns.Count ?? 4, lookup, Column.Index))?.Value
|
||||
?? $"mania-note{FallbackColumnIndex}{suffix}";
|
||||
|
||||
return skin.GetTexture(noteImage);
|
||||
}
|
||||
}
|
||||
}
|
@ -52,6 +52,15 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
|
||||
case ManiaSkinComponents.KeyArea:
|
||||
return new LegacyKeyArea();
|
||||
|
||||
case ManiaSkinComponents.Note:
|
||||
return new LegacyNotePiece();
|
||||
|
||||
case ManiaSkinComponents.HoldNoteHead:
|
||||
return new LegacyHoldNoteHeadPiece();
|
||||
|
||||
case ManiaSkinComponents.HoldNoteTail:
|
||||
return new LegacyHoldNoteTailPiece();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -64,14 +64,14 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
||||
hitTarget.Anchor = hitTarget.Origin = Anchor.TopLeft;
|
||||
|
||||
Padding = new MarginPadding { Top = hitPosition };
|
||||
Explosions.Padding = new MarginPadding { Top = NotePiece.NOTE_HEIGHT };
|
||||
Explosions.Padding = new MarginPadding { Top = DefaultNotePiece.NOTE_HEIGHT };
|
||||
}
|
||||
else
|
||||
{
|
||||
hitTarget.Anchor = hitTarget.Origin = Anchor.BottomLeft;
|
||||
|
||||
Padding = new MarginPadding { Bottom = hitPosition };
|
||||
Explosions.Padding = new MarginPadding { Bottom = NotePiece.NOTE_HEIGHT };
|
||||
Explosions.Padding = new MarginPadding { Bottom = DefaultNotePiece.NOTE_HEIGHT };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
||||
hitTargetBar = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = NotePiece.NOTE_HEIGHT,
|
||||
Height = DefaultNotePiece.NOTE_HEIGHT,
|
||||
Alpha = 0.6f,
|
||||
Colour = Color4.Black
|
||||
},
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
public HitExplosion(Color4 objectColour, bool isSmall = false)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = NotePiece.NOTE_HEIGHT;
|
||||
Height = DefaultNotePiece.NOTE_HEIGHT;
|
||||
|
||||
// scale roughly in-line with visual appearance of notes
|
||||
Scale = new Vector2(1f, 0.6f);
|
||||
|
@ -26,6 +26,9 @@ namespace osu.Game.Skinning
|
||||
HitTargetImage,
|
||||
ShowJudgementLine,
|
||||
KeyImage,
|
||||
KeyImageDown
|
||||
KeyImageDown,
|
||||
NoteImage,
|
||||
HoldNoteHeadImage,
|
||||
HoldNoteTailImage
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user