mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Merge branch 'master' into sheared_slider_implementation_clean_ii
This commit is contained in:
@ -294,8 +294,14 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
vertexBatch = renderer.CreateQuadBatch<TexturedVertex2D>(Source.AimCount, 1);
|
||||
}
|
||||
|
||||
// Due to triangles having various sizes we would need to set a different "texelSize" value for each of them, which is insanely expensive, thus we should use one single value.
|
||||
// texelSize computed for an average triangle (size 100) will result in big triangles becoming blurry, so we may just use 0 for all of them.
|
||||
// But we still need to specify at least something, because otherwise other shader usages will override this value.
|
||||
float texelSize = 0f;
|
||||
|
||||
shader.Bind();
|
||||
shader.GetUniform<float>("thickness").UpdateValue(ref fill);
|
||||
shader.GetUniform<float>("texelSize").UpdateValue(ref texelSize);
|
||||
|
||||
foreach (TriangleParticle particle in parts)
|
||||
{
|
||||
|
@ -34,6 +34,12 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
/// </summary>
|
||||
protected virtual bool CreateNewTriangles => true;
|
||||
|
||||
/// <summary>
|
||||
/// If enabled, only the portion of triangles that falls within this <see cref="Drawable"/>'s
|
||||
/// shape is drawn to the screen.
|
||||
/// </summary>
|
||||
public bool Masking { get; set; }
|
||||
|
||||
private readonly BindableFloat spawnRatio = new BindableFloat(1f);
|
||||
|
||||
/// <summary>
|
||||
@ -189,6 +195,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
private Vector2 size;
|
||||
private float thickness;
|
||||
private float texelSize;
|
||||
private bool masking;
|
||||
|
||||
private IVertexBatch<TexturedVertex2D>? vertexBatch;
|
||||
|
||||
@ -205,6 +212,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
texture = Source.texture;
|
||||
size = Source.DrawSize;
|
||||
thickness = Source.Thickness;
|
||||
masking = Source.Masking;
|
||||
|
||||
Quad triangleQuad = new Quad(
|
||||
Vector2Extensions.Transform(Vector2.Zero, DrawInfo.Matrix),
|
||||
@ -236,26 +244,31 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
shader.GetUniform<float>("thickness").UpdateValue(ref thickness);
|
||||
shader.GetUniform<float>("texelSize").UpdateValue(ref texelSize);
|
||||
|
||||
float relativeHeight = triangleSize.Y / size.Y;
|
||||
float relativeWidth = triangleSize.X / size.X;
|
||||
Vector2 relativeSize = Vector2.Divide(triangleSize, size);
|
||||
|
||||
foreach (TriangleParticle particle in parts)
|
||||
{
|
||||
Vector2 topLeft = particle.Position - new Vector2(relativeWidth * 0.5f, 0f);
|
||||
Vector2 topRight = topLeft + new Vector2(relativeWidth, 0f);
|
||||
Vector2 bottomLeft = topLeft + new Vector2(0f, relativeHeight);
|
||||
Vector2 bottomRight = bottomLeft + new Vector2(relativeWidth, 0f);
|
||||
Vector2 topLeft = particle.Position - new Vector2(relativeSize.X * 0.5f, 0f);
|
||||
|
||||
Quad triangleQuad = masking ? clampToDrawable(topLeft, relativeSize) : new Quad(topLeft.X, topLeft.Y, relativeSize.X, relativeSize.Y);
|
||||
|
||||
var drawQuad = new Quad(
|
||||
Vector2Extensions.Transform(topLeft * size, DrawInfo.Matrix),
|
||||
Vector2Extensions.Transform(topRight * size, DrawInfo.Matrix),
|
||||
Vector2Extensions.Transform(bottomLeft * size, DrawInfo.Matrix),
|
||||
Vector2Extensions.Transform(bottomRight * size, DrawInfo.Matrix)
|
||||
Vector2Extensions.Transform(triangleQuad.TopLeft * size, DrawInfo.Matrix),
|
||||
Vector2Extensions.Transform(triangleQuad.TopRight * size, DrawInfo.Matrix),
|
||||
Vector2Extensions.Transform(triangleQuad.BottomLeft * size, DrawInfo.Matrix),
|
||||
Vector2Extensions.Transform(triangleQuad.BottomRight * size, DrawInfo.Matrix)
|
||||
);
|
||||
|
||||
ColourInfo colourInfo = triangleColourInfo(DrawColourInfo.Colour, new Quad(topLeft, topRight, bottomLeft, bottomRight));
|
||||
ColourInfo colourInfo = triangleColourInfo(DrawColourInfo.Colour, triangleQuad);
|
||||
|
||||
renderer.DrawQuad(texture, drawQuad, colourInfo, vertexAction: vertexBatch.AddAction);
|
||||
RectangleF textureCoords = new RectangleF(
|
||||
triangleQuad.TopLeft.X - topLeft.X,
|
||||
triangleQuad.TopLeft.Y - topLeft.Y,
|
||||
triangleQuad.Width,
|
||||
triangleQuad.Height
|
||||
) / relativeSize;
|
||||
|
||||
renderer.DrawQuad(texture, drawQuad, colourInfo, new RectangleF(0, 0, 1, 1), vertexBatch.AddAction, textureCoords: textureCoords);
|
||||
}
|
||||
|
||||
shader.Unbind();
|
||||
@ -272,6 +285,19 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
};
|
||||
}
|
||||
|
||||
private static Quad clampToDrawable(Vector2 topLeft, Vector2 size)
|
||||
{
|
||||
float leftClamped = Math.Clamp(topLeft.X, 0f, 1f);
|
||||
float topClamped = Math.Clamp(topLeft.Y, 0f, 1f);
|
||||
|
||||
return new Quad(
|
||||
leftClamped,
|
||||
topClamped,
|
||||
Math.Clamp(topLeft.X + size.X, 0f, 1f) - leftClamped,
|
||||
Math.Clamp(topLeft.Y + size.Y, 0f, 1f) - topClamped
|
||||
);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
@ -42,8 +42,12 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
|
||||
protected override void AddFootnoteBacklink(FootnoteLink footnoteBacklink) => AddDrawable(new OsuMarkdownFootnoteBacklink(footnoteBacklink));
|
||||
|
||||
protected override SpriteText CreateEmphasisedSpriteText(bool bold, bool italic)
|
||||
=> CreateSpriteText().With(t => t.Font = t.Font.With(weight: bold ? FontWeight.Bold : FontWeight.Regular, italics: italic));
|
||||
protected override void ApplyEmphasisedCreationParameters(SpriteText spriteText, bool bold, bool italic)
|
||||
{
|
||||
base.ApplyEmphasisedCreationParameters(spriteText, bold, italic);
|
||||
|
||||
spriteText.Font = spriteText.Font.With(weight: bold ? FontWeight.Bold : FontWeight.Regular, italics: italic);
|
||||
}
|
||||
|
||||
protected override void AddCustomComponent(CustomContainerInline inline)
|
||||
{
|
||||
|
@ -44,8 +44,11 @@ namespace osu.Game.Graphics.Containers
|
||||
content.AutoSizeAxes = AutoSizeAxes;
|
||||
}
|
||||
|
||||
AddInternal(content);
|
||||
Add(CreateHoverSounds(sampleSet));
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
content,
|
||||
CreateHoverSounds(sampleSet)
|
||||
});
|
||||
}
|
||||
|
||||
protected override void ClearInternal(bool disposeChildren = true) =>
|
||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition))
|
||||
if (buttons.Contains(e.Button))
|
||||
{
|
||||
var channel = Enabled.Value ? sampleClick?.GetChannel() : sampleClickDisabled?.GetChannel();
|
||||
|
||||
|
@ -5,19 +5,22 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Configuration;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles debouncing hover sounds at a global level to ensure the effects are not overwhelming.
|
||||
/// </summary>
|
||||
public abstract partial class HoverSampleDebounceComponent : CompositeDrawable
|
||||
public abstract partial class HoverSampleDebounceComponent : Component
|
||||
{
|
||||
private Bindable<double?> lastPlaybackTime;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) == true;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(SessionStatics statics)
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
});
|
||||
|
||||
if (hoverSounds.HasValue)
|
||||
Add(new HoverClickSounds(hoverSounds.Value) { Enabled = { BindTarget = Enabled } });
|
||||
AddInternal(new HoverClickSounds(hoverSounds.Value) { Enabled = { BindTarget = Enabled } });
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
Reference in New Issue
Block a user