mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 07:32:55 +08:00
Add AspectAdjust to HitRenderer to allow playfield to consume ful HitRenderer size when needed.
This commit is contained in:
parent
960ea27684
commit
b9ce98efd6
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Modes.Osu.Beatmaps;
|
||||
@ -46,5 +47,7 @@ namespace osu.Game.Modes.Osu.UI
|
||||
return new DrawableSpinner(spinner);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override Vector2 GetPlayfieldAspectAdjust() => new Vector2(0.75f);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ using osu.Game.Modes.Taiko.Objects.Drawables;
|
||||
using osu.Game.Modes.Taiko.Scoring;
|
||||
using osu.Game.Modes.UI;
|
||||
using osu.Game.Modes.Taiko.Replays;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.UI
|
||||
{
|
||||
@ -100,6 +101,17 @@ namespace osu.Game.Modes.Taiko.UI
|
||||
}
|
||||
}
|
||||
|
||||
protected override Vector2 GetPlayfieldAspectAdjust()
|
||||
{
|
||||
const float default_relative_height = TaikoPlayfield.DEFAULT_PLAYFIELD_HEIGHT / 768;
|
||||
const float default_aspect = 16f / 9f;
|
||||
|
||||
float aspectAdjust = MathHelper.Clamp(DrawWidth / DrawHeight, 0.4f, 4) / default_aspect;
|
||||
|
||||
return new Vector2(1, default_relative_height * aspectAdjust);
|
||||
}
|
||||
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);
|
||||
|
||||
protected override IBeatmapConverter<TaikoHitObject> CreateBeatmapConverter() => new TaikoBeatmapConverter();
|
||||
|
@ -16,6 +16,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Game.Modes.Replays;
|
||||
using osu.Game.Modes.Scoring;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.UI
|
||||
{
|
||||
@ -167,6 +168,11 @@ namespace osu.Game.Modes.UI
|
||||
{
|
||||
public event Action<TJudgement> OnJudgement;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to apply adjustments to the child <see cref="Playfield{TObject,TJudgement}"/> based on our own size.
|
||||
/// </summary>
|
||||
public bool AspectAdjust = true;
|
||||
|
||||
public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
@ -219,6 +225,19 @@ namespace osu.Game.Modes.UI
|
||||
Playfield.PostProcess();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Playfield.Size = AspectAdjust ? GetPlayfieldAspectAdjust() : Vector2.One;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In some cases we want to apply changes to the relative size of our contained <see cref="Playfield{TObject, TJudgement}"/> based on custom conditions.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual Vector2 GetPlayfieldAspectAdjust() => new Vector2(0.75f); //a sane default
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an object's Judgement is updated.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user