mirror of
https://github.com/ppy/osu
synced 2025-03-25 04:18:03 +00:00
Rewrite circle pieces to use custom graphics again.
Also using FontAwesome for now to enforce the same size, because otherwise you have to mess around with sprites + the custom graphics. This will all be changed when sprites are fixed to maintain aspect ratios and when glow/border use relative axes.
This commit is contained in:
parent
405c6f9691
commit
fdd17c1575
@ -2,10 +2,15 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Screens.Testing;
|
using osu.Framework.Screens.Testing;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Modes.Taiko.Objects;
|
||||||
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
|
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
|
||||||
|
|
||||||
namespace osu.Desktop.VisualTests.Tests
|
namespace osu.Desktop.VisualTests.Tests
|
||||||
@ -26,7 +31,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Reset();
|
Reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new CentreHitCircle(new CirclePiece(@"centre")
|
Add(new CentreHitCircle(new CirclePiece()
|
||||||
{
|
{
|
||||||
KiaiMode = kiai
|
KiaiMode = kiai
|
||||||
})
|
})
|
||||||
@ -34,7 +39,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Position = new Vector2(100, 100)
|
Position = new Vector2(100, 100)
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new CentreHitCircle(new AccentedCirclePiece(@"centre")
|
Add(new CentreHitCircle(new AccentedCirclePiece()
|
||||||
{
|
{
|
||||||
KiaiMode = kiai
|
KiaiMode = kiai
|
||||||
})
|
})
|
||||||
@ -42,7 +47,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Position = new Vector2(350, 100)
|
Position = new Vector2(350, 100)
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new RimHitCircle(new CirclePiece(@"rim")
|
Add(new RimHitCircle(new CirclePiece()
|
||||||
{
|
{
|
||||||
KiaiMode = kiai
|
KiaiMode = kiai
|
||||||
})
|
})
|
||||||
@ -50,7 +55,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Position = new Vector2(100, 300)
|
Position = new Vector2(100, 300)
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new RimHitCircle(new AccentedCirclePiece(@"rim")
|
Add(new RimHitCircle(new AccentedCirclePiece()
|
||||||
{
|
{
|
||||||
KiaiMode = kiai
|
KiaiMode = kiai
|
||||||
})
|
})
|
||||||
@ -58,7 +63,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Position = new Vector2(350, 300)
|
Position = new Vector2(350, 300)
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new SwellCircle(new CirclePiece(@"swell")
|
Add(new SwellCircle(new CirclePiece()
|
||||||
{
|
{
|
||||||
KiaiMode = kiai
|
KiaiMode = kiai
|
||||||
})
|
})
|
||||||
@ -66,7 +71,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Position = new Vector2(100, 500)
|
Position = new Vector2(100, 500)
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new SwellCircle(new AccentedCirclePiece(@"swell")
|
Add(new SwellCircle(new AccentedCirclePiece()
|
||||||
{
|
{
|
||||||
KiaiMode = kiai
|
KiaiMode = kiai
|
||||||
})
|
})
|
||||||
@ -74,7 +79,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Position = new Vector2(350, 500)
|
Position = new Vector2(350, 500)
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new DrumRollCircle(new CirclePiece(string.Empty)
|
Add(new DrumRollCircle(new CirclePiece()
|
||||||
{
|
{
|
||||||
Width = 250,
|
Width = 250,
|
||||||
KiaiMode = kiai
|
KiaiMode = kiai
|
||||||
@ -83,7 +88,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Position = new Vector2(575, 100)
|
Position = new Vector2(575, 100)
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new DrumRollCircle(new AccentedCirclePiece(string.Empty)
|
Add(new DrumRollCircle(new AccentedCirclePiece()
|
||||||
{
|
{
|
||||||
Width = 250,
|
Width = 250,
|
||||||
KiaiMode = kiai
|
KiaiMode = kiai
|
||||||
@ -95,13 +100,22 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
|
|
||||||
private class SwellCircle : BaseCircle
|
private class SwellCircle : BaseCircle
|
||||||
{
|
{
|
||||||
|
private const float symbol_size = TaikoHitObject.CIRCLE_RADIUS * 2f * 0.35f;
|
||||||
|
|
||||||
public SwellCircle(CirclePiece piece)
|
public SwellCircle(CirclePiece piece)
|
||||||
: base(piece)
|
: base(piece)
|
||||||
{
|
{
|
||||||
|
Piece.Add(new TextAwesome
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
TextSize = symbol_size,
|
||||||
|
Shadow = false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours, TextureStore textures)
|
||||||
{
|
{
|
||||||
Piece.AccentColour = colours.YellowDark;
|
Piece.AccentColour = colours.YellowDark;
|
||||||
}
|
}
|
||||||
@ -123,9 +137,25 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
|
|
||||||
private class CentreHitCircle : BaseCircle
|
private class CentreHitCircle : BaseCircle
|
||||||
{
|
{
|
||||||
|
private const float symbol_size = TaikoHitObject.CIRCLE_RADIUS * 2f * 0.35f;
|
||||||
|
|
||||||
public CentreHitCircle(CirclePiece piece)
|
public CentreHitCircle(CirclePiece piece)
|
||||||
: base(piece)
|
: base(piece)
|
||||||
{
|
{
|
||||||
|
Piece.Add(new CircularContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(symbol_size),
|
||||||
|
Masking = true,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -137,9 +167,29 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
|
|
||||||
private class RimHitCircle : BaseCircle
|
private class RimHitCircle : BaseCircle
|
||||||
{
|
{
|
||||||
|
private const float symbol_size = TaikoHitObject.CIRCLE_RADIUS * 2f * 0.45f;
|
||||||
|
|
||||||
public RimHitCircle(CirclePiece piece)
|
public RimHitCircle(CirclePiece piece)
|
||||||
: base(piece)
|
: base(piece)
|
||||||
{
|
{
|
||||||
|
Piece.Add(new CircularContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(symbol_size),
|
||||||
|
BorderThickness = 8,
|
||||||
|
BorderColour = Color4.White,
|
||||||
|
Masking = true,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
AlwaysPresent = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -15,9 +15,9 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const float accent_scale = 1.5f;
|
private const float accent_scale = 1.5f;
|
||||||
|
|
||||||
public AccentedCirclePiece(string symbolName)
|
public AccentedCirclePiece()
|
||||||
: base(symbolName)
|
|
||||||
{
|
{
|
||||||
|
SymbolContainer.Scale = new Vector2(accent_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Vector2 Size => new Vector2(base.Size.X, base.Size.Y * accent_scale);
|
public override Vector2 Size => new Vector2(base.Size.X, base.Size.Y * accent_scale);
|
||||||
|
@ -7,8 +7,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
||||||
@ -63,18 +61,16 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
|||||||
set { throw new InvalidOperationException($"{nameof(CirclePiece)} must always use CentreLeft origin."); }
|
set { throw new InvalidOperationException($"{nameof(CirclePiece)} must always use CentreLeft origin."); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override Container<Framework.Graphics.Drawable> Content => SymbolContainer;
|
||||||
|
protected readonly Container SymbolContainer;
|
||||||
|
|
||||||
private readonly Container innerLayer;
|
private readonly Container innerLayer;
|
||||||
private readonly Container innerCircleContainer;
|
private readonly Container innerCircleContainer;
|
||||||
private readonly Box innerBackground;
|
private readonly Box innerBackground;
|
||||||
private readonly Triangles triangles;
|
private readonly Triangles triangles;
|
||||||
private readonly Sprite symbol;
|
|
||||||
|
|
||||||
private readonly string symbolName;
|
public CirclePiece()
|
||||||
|
|
||||||
public CirclePiece(string symbolName)
|
|
||||||
{
|
{
|
||||||
this.symbolName = symbolName;
|
|
||||||
|
|
||||||
Height = TaikoHitObject.CIRCLE_RADIUS * 2;
|
Height = TaikoHitObject.CIRCLE_RADIUS * 2;
|
||||||
|
|
||||||
// The "inner layer" is the body of the CirclePiece that overshoots it by Height/2 px on both sides
|
// The "inner layer" is the body of the CirclePiece that overshoots it by Height/2 px on both sides
|
||||||
@ -130,24 +126,16 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
symbol = new Sprite
|
SymbolContainer = new Container
|
||||||
{
|
{
|
||||||
Name = "Symbol",
|
Name = "Symbol",
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(TextureStore textures)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(symbolName))
|
|
||||||
symbol.Texture = textures.Get($@"Play/Taiko/{symbolName}-symbol");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
// Add the overshoot to compensate for corner radius
|
// Add the overshoot to compensate for corner radius
|
||||||
|
Loading…
Reference in New Issue
Block a user