Skip to content

Commit

Permalink
Fix CurrentAspect not being set & revert barline fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vunyunt committed Feb 18, 2024
1 parent e2bd8da commit 8e052fe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 34 deletions.
9 changes: 3 additions & 6 deletions osu.Game.Rulesets.Taiko/Mods/TaikoModClassic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 100,13 @@ private void adjustHidden(
var drawableTaikoRuleset = (DrawableTaikoRuleset)drawableRuleset;
var adjustmentContainer = (TaikoPlayfieldAdjustmentContainer)drawableTaikoRuleset.PlayfieldAdjustmentContainer;

float aspect = Math.Clamp(
adjustmentContainer.CurrentAspect,
adjustmentContainer.MinimumAspect,
adjustmentContainer.MaximumAspect);
float clampedAspect = adjustmentContainer.ClampedCurrentAspect;

float fadeOutDurationAdjustment = aspect / baseAspect - 1;
float fadeOutDurationAdjustment = clampedAspect / baseAspect - 1;
fadeOutDurationAdjustment *= adjustmentRatio;
hiddenFadeOutDuration.Value = baseFadeOutDuration fadeOutDurationAdjustment;

float initialAlphaAdjustment = aspect / baseAspect - 1;
float initialAlphaAdjustment = clampedAspect / baseAspect - 1;
initialAlphaAdjustment *= adjustmentRatio;
hiddenInitialAlpha.Value = baseInitialAlpha initialAlphaAdjustment;
}
Expand Down
6 changes: 1 addition & 5 deletions osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 122,7 @@ private void load(OsuColour colours)
{
Name = "Bar line content",
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding
{
Left = hit_target_width / 2 hit_target_offset,
Right = hit_target_width / 2
}, // To avoid barline appearing before the beginning of playfield when trimmed
Padding = new MarginPadding { Left = hit_target_width / 2 hit_target_offset }, // To avoid barline appearing before the beginning of playfield when trimmed
Children = new Drawable[]
{
UnderlayElements = new Container
Expand Down
47 changes: 24 additions & 23 deletions osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 13,35 @@ public partial class TaikoPlayfieldAdjustmentContainer : PlayfieldAdjustmentCont
{
private const float stable_gamefield_height = 480f;

// <summary>
// The maximum aspect ratio the playfield can be adjusted to.
// </summary>
/// <summary>
/// The maximum aspect ratio the playfield can be adjusted to.
/// </summary>
protected internal float MaximumAspect = 16f / 9f;

// <summary>
// The minimum aspect ratio the playfield can be adjusted to.
// </summary>
/// <summary>
/// The minimum aspect ratio the playfield can be adjusted to.
/// </summary>
protected internal float MinimumAspect = 5f / 4f;

// <summary>
// The current aspect ratio of the playfield. This should be the aspect ratio of the game's resolution.
// </summary>
protected internal float CurrentAspect { get; private set; } = 16f / 9f;
/// <summary>
/// Aspect ratio of the playfield's resolution clamped between <see cref="MinimumAspect"/> and
/// <see cref="MaximumAspect"/>.
/// </summary>
protected internal float ClampedCurrentAspect { get; private set; } = 16f / 9f;

// <summary>
// The maximum relative height of the playfield. This is a fraction of the available area.
// </summary>
/// <summary>
/// The maximum relative height of the playfield. This is a fraction of the available area.
/// </summary>
protected internal float MaximumRelativeHeight = 1f / 3f;

// <summary>
// The minimum relative height of the playfield. This is a fraction of the available area.
// </summary>
/// <summary>
/// The minimum relative height of the playfield. This is a fraction of the available area.
/// </summary>
protected internal float MinimumRelativeHeight = 0f;

// <summary>
// Whether the playfield should be trimmed when the aspect ratio exceeds the maximum.
// </summary>
/// <summary>
/// Whether the playfield should be trimmed when the aspect ratio exceeds the maximum.
/// </summary>
protected internal bool TrimOnOverflow = false;

public TaikoPlayfieldAdjustmentContainer()
Expand Down Expand Up @@ -68,6 69,8 @@ protected override void Update()
//
// As a middle-ground, the aspect ratio can still be adjusted in the downwards direction but has a maximum limit.
// This is still a bit weird, because readability changes with window size, but it is what it is.
//
// This is separate from CurrentAspect as this needs to be the unbounded aspect ratio.
float currentAspect = Parent!.ChildSize.X / Parent!.ChildSize.Y;

if (currentAspect > MaximumAspect)
Expand Down Expand Up @@ -95,16 98,14 @@ protected override void Update()

public double ComputeTimeRange()
{
float currentAspect = Parent!.ChildSize.X / Parent!.ChildSize.Y;

currentAspect = Math.Clamp(currentAspect, MinimumAspect, MaximumAspect);
ClampedCurrentAspect = Math.Clamp(Parent!.ChildSize.X / Parent!.ChildSize.Y, MinimumAspect, MaximumAspect);

// in a game resolution of 1024x768, stable's scrolling system consists of objects being placed 600px (widthScaled - 40) away from their hit location.
// however, the point at which the object renders at the end of the screen is exactly x=640, but stable makes the object start moving from beyond the screen instead of the boundary point.
// therefore, in lazer we have to adjust the "in length" so that it's in a 640px->160px fashion before passing it down as a "time range".
// see stable's "in length": https://github.com/peppy/osu-stable-reference/blob/013c3010a9d495e3471a9c59518de17006f9ad89/osu!/GameplayElements/HitObjectManagerTaiko.cs#L168
const float stable_hit_location = 160f;
float widthScaled = currentAspect * stable_gamefield_height;
float widthScaled = ClampedCurrentAspect * stable_gamefield_height;
float inLength = widthScaled - stable_hit_location;

// also in a game resolution of 1024x768, stable makes hit objects scroll from 760px->160px at a duration of 6000ms, divided by slider velocity (i.e. at a rate of 0.1px/ms)
Expand Down

0 comments on commit 8e052fe

Please sign in to comment.