mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 02:32:55 +08:00
Limit taiko playfield aspect ratio to 5:4 - 16:9
This commit is contained in:
parent
58ace1d613
commit
76df5fd3e2
@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
|
|||||||
public void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
|
public void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
var drawableTaikoRuleset = (DrawableTaikoRuleset)drawableRuleset;
|
var drawableTaikoRuleset = (DrawableTaikoRuleset)drawableRuleset;
|
||||||
drawableTaikoRuleset.LockPlayfieldMaxAspect.Value = false;
|
drawableTaikoRuleset.LockPlayfieldAspectRange.Value = false;
|
||||||
|
|
||||||
var playfield = (TaikoPlayfield)drawableRuleset.Playfield;
|
var playfield = (TaikoPlayfield)drawableRuleset.Playfield;
|
||||||
playfield.ClassicHitTargetPosition.Value = true;
|
playfield.ClassicHitTargetPosition.Value = true;
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
public new BindableDouble TimeRange => base.TimeRange;
|
public new BindableDouble TimeRange => base.TimeRange;
|
||||||
|
|
||||||
public readonly BindableBool LockPlayfieldMaxAspect = new BindableBool(true);
|
public readonly BindableBool LockPlayfieldAspectRange = new BindableBool(true);
|
||||||
|
|
||||||
public new TaikoInputManager KeyBindingInputManager => (TaikoInputManager)base.KeyBindingInputManager;
|
public new TaikoInputManager KeyBindingInputManager => (TaikoInputManager)base.KeyBindingInputManager;
|
||||||
|
|
||||||
@ -69,7 +69,9 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
const float scroll_rate = 10;
|
const float scroll_rate = 10;
|
||||||
|
|
||||||
// Since the time range will depend on a positional value, it is referenced to the x480 pixel space.
|
// Since the time range will depend on a positional value, it is referenced to the x480 pixel space.
|
||||||
float ratio = DrawHeight / 480;
|
// Width is used because it defines how many notes fit on the playfield.
|
||||||
|
// We clamp the ratio to the maximum aspect ratio to keep scroll speed consistent on widths lower than the default.
|
||||||
|
float ratio = Math.Max(DrawSize.X / 768f, TaikoPlayfieldAdjustmentContainer.MAXIMUM_ASPECT);
|
||||||
|
|
||||||
TimeRange.Value = (Playfield.HitObjectContainer.DrawWidth / ratio) * scroll_rate;
|
TimeRange.Value = (Playfield.HitObjectContainer.DrawWidth / ratio) * scroll_rate;
|
||||||
}
|
}
|
||||||
@ -92,7 +94,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer
|
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer
|
||||||
{
|
{
|
||||||
LockPlayfieldMaxAspect = { BindTarget = LockPlayfieldMaxAspect }
|
LockPlayfieldAspectRange = { BindTarget = LockPlayfieldAspectRange }
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);
|
protected override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);
|
||||||
|
@ -11,9 +11,11 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
public partial class TaikoPlayfieldAdjustmentContainer : PlayfieldAdjustmentContainer
|
public partial class TaikoPlayfieldAdjustmentContainer : PlayfieldAdjustmentContainer
|
||||||
{
|
{
|
||||||
private const float default_relative_height = TaikoPlayfield.DEFAULT_HEIGHT / 768;
|
private const float default_relative_height = TaikoPlayfield.DEFAULT_HEIGHT / 768;
|
||||||
private const float default_aspect = 16f / 9f;
|
|
||||||
|
|
||||||
public readonly IBindable<bool> LockPlayfieldMaxAspect = new BindableBool(true);
|
public const float MAXIMUM_ASPECT = 16f / 9f;
|
||||||
|
public const float MINIMUM_ASPECT = 5f / 4f;
|
||||||
|
|
||||||
|
public readonly IBindable<bool> LockPlayfieldAspectRange = new BindableBool(true);
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
@ -26,12 +28,22 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
//
|
//
|
||||||
// As a middle-ground, the aspect ratio can still be adjusted in the downwards direction but has a maximum limit.
|
// 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 still a bit weird, because readability changes with window size, but it is what it is.
|
||||||
if (LockPlayfieldMaxAspect.Value && Parent.ChildSize.X / Parent.ChildSize.Y > default_aspect)
|
if (LockPlayfieldAspectRange.Value)
|
||||||
height *= Math.Clamp(Parent.ChildSize.X / Parent.ChildSize.Y, 0.4f, 4) / default_aspect;
|
{
|
||||||
|
float currentAspect = Parent.ChildSize.X / Parent.ChildSize.Y;
|
||||||
|
|
||||||
|
if (currentAspect > MAXIMUM_ASPECT)
|
||||||
|
height *= currentAspect / MAXIMUM_ASPECT;
|
||||||
|
else if (currentAspect < MINIMUM_ASPECT)
|
||||||
|
height *= currentAspect / MINIMUM_ASPECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the maximum relative height of the playfield to one-third of available area to avoid it masking out on extreme resolutions.
|
||||||
|
height = Math.Min(height, 1f / 3f);
|
||||||
Height = height;
|
Height = height;
|
||||||
|
|
||||||
// Position the taiko playfield exactly one playfield from the top of the screen.
|
// Position the taiko playfield exactly one playfield from the top of the screen, if there is enough space for it.
|
||||||
|
// Note that the relative height cannot exceed one-third - if that limit is hit, the playfield will be exactly centered.
|
||||||
RelativePositionAxes = Axes.Y;
|
RelativePositionAxes = Axes.Y;
|
||||||
Y = height;
|
Y = height;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user