1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-21 08:52:54 +08:00

Merge branch 'master' into update-framework

This commit is contained in:
Dean Herbert 2024-01-21 13:49:44 +09:00 committed by GitHub
commit 3b7a47aded
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 105 additions and 68 deletions

View File

@ -13,7 +13,7 @@ using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Skinning.Argon namespace osu.Game.Rulesets.Osu.Skinning.Argon
{ {
public partial class ArgonCursor : OsuCursorSprite public partial class ArgonCursor : SkinnableCursor
{ {
public ArgonCursor() public ArgonCursor()
{ {

View File

@ -15,6 +15,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
{ {
TriangleScale = 1.2f; TriangleScale = 1.2f;
HideAlphaDiscrepancies = false; HideAlphaDiscrepancies = false;
ClampToDrawable = false;
} }
protected override void Update() protected override void Update()

View File

@ -9,8 +9,11 @@ using osuTK;
namespace osu.Game.Rulesets.Osu.Skinning.Legacy namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{ {
public partial class LegacyCursor : OsuCursorSprite public partial class LegacyCursor : SkinnableCursor
{ {
private const float pressed_scale = 1.3f;
private const float released_scale = 1f;
private readonly ISkin skin; private readonly ISkin skin;
private bool spin; private bool spin;
@ -51,5 +54,16 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
if (spin) if (spin)
ExpandTarget.Spin(10000, RotationDirection.Clockwise); ExpandTarget.Spin(10000, RotationDirection.Clockwise);
} }
public override void Expand()
{
ExpandTarget?.ScaleTo(released_scale)
.ScaleTo(pressed_scale, 100, Easing.Out);
}
public override void Contract()
{
ExpandTarget?.ScaleTo(released_scale, 100, Easing.Out);
}
} }
} }

View File

@ -24,15 +24,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
{ {
public const float SIZE = 28; public const float SIZE = 28;
private const float pressed_scale = 1.2f;
private const float released_scale = 1f;
private bool cursorExpand; private bool cursorExpand;
private SkinnableDrawable cursorSprite; private SkinnableDrawable cursorSprite;
private Container cursorScaleContainer = null!; private Container cursorScaleContainer = null!;
private Drawable expandTarget => (cursorSprite.Drawable as OsuCursorSprite)?.ExpandTarget ?? cursorSprite; private SkinnableCursor skinnableCursor => (SkinnableCursor)cursorSprite.Drawable;
public IBindable<float> CursorScale => cursorScale; public IBindable<float> CursorScale => cursorScale;
@ -108,10 +105,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
{ {
if (!cursorExpand) return; if (!cursorExpand) return;
expandTarget.ScaleTo(released_scale).ScaleTo(pressed_scale, 400, Easing.OutElasticHalf); skinnableCursor.Expand();
} }
public void Contract() => expandTarget.ScaleTo(released_scale, 400, Easing.OutQuad); public void Contract() => skinnableCursor.Contract();
/// <summary> /// <summary>
/// Get the scale applicable to the ActiveCursor based on a beatmap's circle size. /// Get the scale applicable to the ActiveCursor based on a beatmap's circle size.
@ -119,7 +116,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
public static float GetScaleForCircleSize(float circleSize) => public static float GetScaleForCircleSize(float circleSize) =>
1f - 0.7f * (1f + circleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY; 1f - 0.7f * (1f + circleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
private partial class DefaultCursor : OsuCursorSprite private partial class DefaultCursor : SkinnableCursor
{ {
public DefaultCursor() public DefaultCursor()
{ {

View File

@ -1,19 +0,0 @@
// 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.
#nullable disable
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Rulesets.Osu.UI.Cursor
{
public abstract partial class OsuCursorSprite : CompositeDrawable
{
/// <summary>
/// The an optional piece of the cursor to expand when in a clicked state.
/// If null, the whole cursor will be affected by expansion.
/// </summary>
public Drawable ExpandTarget { get; protected set; }
}
}

View File

@ -0,0 +1,31 @@
// 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;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Rulesets.Osu.UI.Cursor
{
public abstract partial class SkinnableCursor : CompositeDrawable
{
private const float pressed_scale = 1.2f;
private const float released_scale = 1f;
public virtual void Expand()
{
ExpandTarget?.ScaleTo(released_scale)
.ScaleTo(pressed_scale, 400, Easing.OutElasticHalf);
}
public virtual void Contract()
{
ExpandTarget?.ScaleTo(released_scale, 400, Easing.OutQuad);
}
/// <summary>
/// The an optional piece of the cursor to expand when in a clicked state.
/// If null, the whole cursor will be affected by expansion.
/// </summary>
public Drawable? ExpandTarget { get; protected set; }
}
}

View File

@ -40,7 +40,7 @@ namespace osu.Game.Tests.Visual.Background
AddSliderStep("Triangle scale", 0f, 10f, 1f, s => triangles.TriangleScale = s); AddSliderStep("Triangle scale", 0f, 10f, 1f, s => triangles.TriangleScale = s);
AddSliderStep("Seed", 0, 1000, 0, s => triangles.Reset(s)); AddSliderStep("Seed", 0, 1000, 0, s => triangles.Reset(s));
AddToggleStep("Masking", m => triangles.Masking = m); AddToggleStep("ClampToDrawable", c => triangles.ClampToDrawable = c);
} }
} }
} }

View File

@ -128,7 +128,7 @@ namespace osu.Game.Tests.Visual.Background
AddStep("White colour", () => box.Colour = triangles.Colour = maskedTriangles.Colour = Color4.White); AddStep("White colour", () => box.Colour = triangles.Colour = maskedTriangles.Colour = Color4.White);
AddStep("Vertical gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientVertical(Color4.White, Color4.Red)); AddStep("Vertical gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientVertical(Color4.White, Color4.Red));
AddStep("Horizontal gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.Red)); AddStep("Horizontal gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.Red));
AddToggleStep("Masking", m => maskedTriangles.Masking = m); AddToggleStep("ClampToDrawable", c => maskedTriangles.ClampToDrawable = c);
} }
} }
} }

View File

@ -40,8 +40,15 @@ namespace osu.Game.Tests.Visual.Settings
AddStep("change value from default", () => textBox.Current.Value = "non-default"); AddStep("change value from default", () => textBox.Current.Value = "non-default");
AddUntilStep("restore button shown", () => revertToDefaultButton.Alpha > 0); AddUntilStep("restore button shown", () => revertToDefaultButton.Alpha > 0);
AddStep("disable setting", () => textBox.Current.Disabled = true);
AddUntilStep("restore button still shown", () => revertToDefaultButton.Alpha > 0);
AddStep("enable setting", () => textBox.Current.Disabled = false);
AddStep("restore default", () => textBox.Current.SetDefault()); AddStep("restore default", () => textBox.Current.SetDefault());
AddUntilStep("restore button hidden", () => revertToDefaultButton.Alpha == 0); AddUntilStep("restore button hidden", () => revertToDefaultButton.Alpha == 0);
AddStep("disable setting", () => textBox.Current.Disabled = true);
AddUntilStep("restore button still hidden", () => revertToDefaultButton.Alpha == 0);
} }
[Test] [Test]

View File

@ -12,6 +12,7 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Models;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osuTK; using osuTK;
@ -101,11 +102,25 @@ namespace osu.Game.Tournament.Components
private void refreshContent() private void refreshContent()
{ {
if (beatmap == null) beatmap ??= new BeatmapInfo
{ {
flow.Clear(); Metadata = new BeatmapMetadata
return; {
} Artist = "unknown",
Title = "no beatmap selected",
Author = new RealmUser { Username = "unknown" },
},
DifficultyName = "unknown",
BeatmapSet = new BeatmapSetInfo(),
StarRating = 0,
Difficulty = new BeatmapDifficulty
{
CircleSize = 0,
DrainRate = 0,
OverallDifficulty = 0,
ApproachRate = 0,
},
};
double bpm = beatmap.BPM; double bpm = beatmap.BPM;
double length = beatmap.Length; double length = beatmap.Length;

View File

@ -194,7 +194,7 @@ namespace osu.Game.Tournament.Components
// Use DelayedLoadWrapper to avoid content unloading when switching away to another screen. // Use DelayedLoadWrapper to avoid content unloading when switching away to another screen.
protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> createContentFunc, double timeBeforeLoad) protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> createContentFunc, double timeBeforeLoad)
=> new DelayedLoadWrapper(createContentFunc, timeBeforeLoad); => new DelayedLoadWrapper(createContentFunc(), timeBeforeLoad);
} }
} }
} }

View File

@ -15,7 +15,6 @@ using osu.Framework.Graphics.Primitives;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Rendering.Vertices;
using osu.Framework.Lists; using osu.Framework.Lists;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -79,9 +78,9 @@ namespace osu.Game.Graphics.Backgrounds
/// <summary> /// <summary>
/// If enabled, only the portion of triangles that falls within this <see cref="Drawable"/>'s /// If enabled, only the portion of triangles that falls within this <see cref="Drawable"/>'s
/// shape is drawn to the screen. /// shape is drawn to the screen. Default is true.
/// </summary> /// </summary>
public bool Masking { get; set; } public bool ClampToDrawable { get; set; } = true;
/// <summary> /// <summary>
/// Whether we should drop-off alpha values of triangles more quickly to improve /// Whether we should drop-off alpha values of triangles more quickly to improve
@ -258,13 +257,12 @@ namespace osu.Game.Graphics.Backgrounds
private IShader shader; private IShader shader;
private Texture texture; private Texture texture;
private bool masking; private bool clamp;
private readonly List<TriangleParticle> parts = new List<TriangleParticle>(); private readonly List<TriangleParticle> parts = new List<TriangleParticle>();
private readonly Vector2 triangleSize = new Vector2(1f, equilateral_triangle_ratio) * triangle_size; private readonly Vector2 triangleSize = new Vector2(1f, equilateral_triangle_ratio) * triangle_size;
private Vector2 size; private Vector2 size;
private IVertexBatch<TexturedVertex2D> vertexBatch;
public TrianglesDrawNode(Triangles source) public TrianglesDrawNode(Triangles source)
: base(source) : base(source)
@ -278,7 +276,7 @@ namespace osu.Game.Graphics.Backgrounds
shader = Source.shader; shader = Source.shader;
texture = Source.texture; texture = Source.texture;
size = Source.DrawSize; size = Source.DrawSize;
masking = Source.Masking; clamp = Source.ClampToDrawable;
parts.Clear(); parts.Clear();
parts.AddRange(Source.parts); parts.AddRange(Source.parts);
@ -290,12 +288,6 @@ namespace osu.Game.Graphics.Backgrounds
{ {
base.Draw(renderer); base.Draw(renderer);
if (Source.AimCount > 0 && (vertexBatch == null || vertexBatch.Size != Source.AimCount))
{
vertexBatch?.Dispose();
vertexBatch = renderer.CreateQuadBatch<TexturedVertex2D>(Source.AimCount, 1);
}
borderDataBuffer ??= renderer.CreateUniformBuffer<TriangleBorderData>(); borderDataBuffer ??= renderer.CreateUniformBuffer<TriangleBorderData>();
borderDataBuffer.Data = borderDataBuffer.Data with borderDataBuffer.Data = borderDataBuffer.Data with
{ {
@ -314,7 +306,7 @@ namespace osu.Game.Graphics.Backgrounds
Vector2 topLeft = particle.Position - new Vector2(relativeSize.X * 0.5f, 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); Quad triangleQuad = clamp ? clampToDrawable(topLeft, relativeSize) : new Quad(topLeft.X, topLeft.Y, relativeSize.X, relativeSize.Y);
var drawQuad = new Quad( var drawQuad = new Quad(
Vector2Extensions.Transform(triangleQuad.TopLeft * size, DrawInfo.Matrix), Vector2Extensions.Transform(triangleQuad.TopLeft * size, DrawInfo.Matrix),
@ -333,7 +325,7 @@ namespace osu.Game.Graphics.Backgrounds
triangleQuad.Height triangleQuad.Height
) / relativeSize; ) / relativeSize;
renderer.DrawQuad(texture, drawQuad, colourInfo, new RectangleF(0, 0, 1, 1), vertexBatch.AddAction, textureCoords: textureCoords); renderer.DrawQuad(texture, drawQuad, colourInfo, new RectangleF(0, 0, 1, 1), textureCoords: textureCoords);
} }
shader.Unbind(); shader.Unbind();
@ -356,7 +348,6 @@ namespace osu.Game.Graphics.Backgrounds
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
vertexBatch?.Dispose();
borderDataBuffer?.Dispose(); borderDataBuffer?.Dispose();
} }
} }

View File

@ -10,7 +10,6 @@ using osu.Framework.Graphics.Primitives;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Rendering.Vertices;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -35,9 +34,9 @@ namespace osu.Game.Graphics.Backgrounds
/// <summary> /// <summary>
/// If enabled, only the portion of triangles that falls within this <see cref="Drawable"/>'s /// If enabled, only the portion of triangles that falls within this <see cref="Drawable"/>'s
/// shape is drawn to the screen. /// shape is drawn to the screen. Default is true.
/// </summary> /// </summary>
public bool Masking { get; set; } public bool ClampToDrawable { get; set; } = true;
private readonly BindableFloat spawnRatio = new BindableFloat(1f); private readonly BindableFloat spawnRatio = new BindableFloat(1f);
@ -194,9 +193,7 @@ namespace osu.Game.Graphics.Backgrounds
private Vector2 size; private Vector2 size;
private float thickness; private float thickness;
private float texelSize; private float texelSize;
private bool masking; private bool clamp;
private IVertexBatch<TexturedVertex2D>? vertexBatch;
public TrianglesDrawNode(TrianglesV2 source) public TrianglesDrawNode(TrianglesV2 source)
: base(source) : base(source)
@ -211,7 +208,7 @@ namespace osu.Game.Graphics.Backgrounds
texture = Source.texture; texture = Source.texture;
size = Source.DrawSize; size = Source.DrawSize;
thickness = Source.Thickness; thickness = Source.Thickness;
masking = Source.Masking; clamp = Source.ClampToDrawable;
Quad triangleQuad = new Quad( Quad triangleQuad = new Quad(
Vector2Extensions.Transform(Vector2.Zero, DrawInfo.Matrix), Vector2Extensions.Transform(Vector2.Zero, DrawInfo.Matrix),
@ -235,12 +232,6 @@ namespace osu.Game.Graphics.Backgrounds
if (Source.AimCount == 0 || thickness == 0) if (Source.AimCount == 0 || thickness == 0)
return; return;
if (vertexBatch == null || vertexBatch.Size != Source.AimCount)
{
vertexBatch?.Dispose();
vertexBatch = renderer.CreateQuadBatch<TexturedVertex2D>(Source.AimCount, 1);
}
borderDataBuffer ??= renderer.CreateUniformBuffer<TriangleBorderData>(); borderDataBuffer ??= renderer.CreateUniformBuffer<TriangleBorderData>();
borderDataBuffer.Data = borderDataBuffer.Data with borderDataBuffer.Data = borderDataBuffer.Data with
{ {
@ -257,7 +248,7 @@ namespace osu.Game.Graphics.Backgrounds
{ {
Vector2 topLeft = particle.Position - new Vector2(relativeSize.X * 0.5f, 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); Quad triangleQuad = clamp ? clampToDrawable(topLeft, relativeSize) : new Quad(topLeft.X, topLeft.Y, relativeSize.X, relativeSize.Y);
var drawQuad = new Quad( var drawQuad = new Quad(
Vector2Extensions.Transform(triangleQuad.TopLeft * size, DrawInfo.Matrix), Vector2Extensions.Transform(triangleQuad.TopLeft * size, DrawInfo.Matrix),
@ -273,7 +264,7 @@ namespace osu.Game.Graphics.Backgrounds
triangleQuad.Height triangleQuad.Height
) / relativeSize; ) / relativeSize;
renderer.DrawQuad(texture, drawQuad, DrawColourInfo.Colour.Interpolate(triangleQuad), new RectangleF(0, 0, 1, 1), vertexBatch.AddAction, textureCoords: textureCoords); renderer.DrawQuad(texture, drawQuad, DrawColourInfo.Colour.Interpolate(triangleQuad), new RectangleF(0, 0, 1, 1), textureCoords: textureCoords);
} }
shader.Unbind(); shader.Unbind();
@ -296,7 +287,6 @@ namespace osu.Game.Graphics.Backgrounds
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
vertexBatch?.Dispose();
borderDataBuffer?.Dispose(); borderDataBuffer?.Dispose();
} }
} }

View File

@ -150,6 +150,7 @@ namespace osu.Game.Graphics.UserInterface
TriangleScale = 4, TriangleScale = 4,
ColourDark = OsuColour.Gray(0.88f), ColourDark = OsuColour.Gray(0.88f),
Shear = new Vector2(-0.2f, 0), Shear = new Vector2(-0.2f, 0),
ClampToDrawable = false
}, },
}, },
}, },

View File

@ -28,6 +28,9 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty("latest_build")] [JsonProperty("latest_build")]
public APIChangelogBuild LatestBuild { get; set; } public APIChangelogBuild LatestBuild { get; set; }
[JsonProperty("user_count")]
public int UserCount { get; set; }
public bool Equals(APIUpdateStream other) => Id == other?.Id; public bool Equals(APIUpdateStream other) => Id == other?.Id;
internal static readonly Dictionary<string, Color4> KNOWN_STREAMS = new Dictionary<string, Color4> internal static readonly Dictionary<string, Color4> KNOWN_STREAMS = new Dictionary<string, Color4>

View File

@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Changelog
protected override LocalisableString AdditionalText => Value.LatestBuild.DisplayVersion; protected override LocalisableString AdditionalText => Value.LatestBuild.DisplayVersion;
protected override LocalisableString InfoText => Value.LatestBuild.Users > 0 ? $"{"user".ToQuantity(Value.LatestBuild.Users, "N0")} online" : null; protected override LocalisableString InfoText => Value.UserCount > 0 ? $"{"user".ToQuantity(Value.UserCount, "N0")} online" : null;
protected override Color4 GetBarColour(OsuColour colours) => Value.Colour; protected override Color4 GetBarColour(OsuColour colours) => Value.Colour;
} }

View File

@ -95,6 +95,7 @@ namespace osu.Game.Overlays.Mods
Height = header_height, Height = header_height,
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0), Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
Velocity = 0.7f, Velocity = 0.7f,
ClampToDrawable = false
}, },
headerText = new OsuTextFlowContainer(t => headerText = new OsuTextFlowContainer(t =>
{ {

View File

@ -115,7 +115,12 @@ namespace osu.Game.Overlays
Enabled.Value = !current.Disabled; Enabled.Value = !current.Disabled;
this.FadeTo(current.Disabled ? 0.2f : (current.IsDefault ? 0 : 1), fade_duration, Easing.OutQuint); if (current.IsDefault)
this.FadeTo(0, fade_duration, Easing.OutQuint);
else if (current.Disabled)
this.FadeTo(0.2f, fade_duration, Easing.OutQuint);
else
this.FadeTo(1, fade_duration, Easing.OutQuint);
if (IsHovered && Enabled.Value) if (IsHovered && Enabled.Value)
{ {