1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 06:42:56 +08:00

Move beat divisor tick size retrieval to static methods

This commit is contained in:
Dean Herbert 2022-05-24 17:02:19 +09:00
parent db593fe0f0
commit 4a88affd03
2 changed files with 35 additions and 50 deletions

View File

@ -5,6 +5,7 @@ using System.Linq;
using osu.Framework.Bindables;
using osu.Game.Graphics;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Edit
@ -100,6 +101,32 @@ namespace osu.Game.Screens.Edit
}
}
/// <summary>
/// Get a relative display size for the specified divisor.
/// </summary>
/// <param name="beatDivisor">The beat divisor.</param>
/// <returns>A relative size which can be used to display ticks.</returns>
public static Vector2 GetSize(int beatDivisor)
{
switch (beatDivisor)
{
case 1:
case 2:
return new Vector2(0.6f, 0.9f);
case 3:
case 4:
return new Vector2(0.5f, 0.8f);
case 6:
case 8:
return new Vector2(0.4f, 0.7f);
default:
return new Vector2(0.3f, 0.6f);
}
}
/// <summary>
/// Retrieves the applicable divisor for a specific beat index.
/// </summary>

View File

@ -11,6 +11,7 @@ using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
using osuTK;
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{
@ -132,10 +133,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
// even though "bar lines" take up the full vertical space, we render them in two pieces because it allows for less anchor/origin churn.
Vector2 size = Vector2.One;
if (indexInBar != 1)
size = BindableBeatDivisor.GetSize(divisor);
var line = getNextUsableLine();
line.X = xPos;
line.Width = PointVisualisation.MAX_WIDTH * getWidth(indexInBar, divisor);
line.Height = 0.9f * getHeight(indexInBar, divisor);
line.Width = PointVisualisation.MAX_WIDTH * size.X;
line.Height = 0.9f * size.Y;
line.Colour = colour;
}
@ -170,54 +176,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
}
}
private static float getWidth(int indexInBar, int divisor)
{
if (indexInBar == 0)
return 1;
switch (divisor)
{
case 1:
case 2:
return 0.6f;
case 3:
case 4:
return 0.5f;
case 6:
case 8:
return 0.4f;
default:
return 0.3f;
}
}
private static float getHeight(int indexInBar, int divisor)
{
if (indexInBar == 0)
return 1;
switch (divisor)
{
case 1:
case 2:
return 0.9f;
case 3:
case 4:
return 0.8f;
case 6:
case 8:
return 0.7f;
default:
return 0.6f;
}
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);