From f584d6593acbd028287049eed49f335832480a16 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 17 Sep 2021 18:10:53 +0900 Subject: [PATCH 1/5] Fix flashlight alignment --- osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs index 1253b7c8ae..3578e3a734 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs @@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Taiko.Mods if (!flashlightProperties.IsValid) { - FlashlightPosition = taikoPlayfield.HitTarget.ToSpaceOfOtherDrawable(taikoPlayfield.HitTarget.OriginPosition, this); + FlashlightPosition = ToLocalSpace(taikoPlayfield.HitTarget.ScreenSpaceDrawQuad.Centre); flashlightProperties.Validate(); } } From 2d3913120259fdb34311c423bc691828d2d99c58 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 17 Sep 2021 18:41:03 +0900 Subject: [PATCH 2/5] Refactor taiko flashlight a bit --- .../Mods/TaikoModFlashlight.cs | 17 +++++++++-------- osu.Game/Rulesets/Mods/ModFlashlight.cs | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs index 3578e3a734..19ba99586b 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs @@ -36,24 +36,25 @@ namespace osu.Game.Rulesets.Taiko.Mods public TaikoFlashlight(TaikoPlayfield taikoPlayfield) { this.taikoPlayfield = taikoPlayfield; - FlashlightSize = new Vector2(0, getSizeFor(0)); + FlashlightSize = getSizeFor(0); AddLayout(flashlightProperties); } - private float getSizeFor(int combo) + private Vector2 getSizeFor(int combo) { if (combo > 200) - return default_flashlight_size * 0.8f; - else if (combo > 100) - return default_flashlight_size * 0.9f; - else - return default_flashlight_size; + return new Vector2(0, default_flashlight_size * 0.8f); + + if (combo > 100) + return new Vector2(0, default_flashlight_size * 0.9f); + + return new Vector2(0, default_flashlight_size); } protected override void OnComboChange(ValueChangedEvent e) { - this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(e.NewValue)), FLASHLIGHT_FADE_DURATION); + this.TransformTo(nameof(FlashlightSize), getSizeFor(e.NewValue), FLASHLIGHT_FADE_DURATION); } protected override string FragmentShader => "CircularFlashlight"; diff --git a/osu.Game/Rulesets/Mods/ModFlashlight.cs b/osu.Game/Rulesets/Mods/ModFlashlight.cs index 7abae71273..f96f8a3c1b 100644 --- a/osu.Game/Rulesets/Mods/ModFlashlight.cs +++ b/osu.Game/Rulesets/Mods/ModFlashlight.cs @@ -81,7 +81,7 @@ namespace osu.Game.Rulesets.Mods public abstract class Flashlight : Drawable { - internal BindableInt Combo; + protected internal BindableInt Combo { get; internal set; } private IShader shader; protected override DrawNode CreateDrawNode() => new FlashlightDrawNode(this); From 35c3d75cb8d720583e7b010ff026fdd7885b773c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 17 Sep 2021 18:51:43 +0900 Subject: [PATCH 3/5] Preserve flashlight size through aspect adjustment --- .../Mods/TaikoModFlashlight.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs index 19ba99586b..12f19a0086 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs @@ -43,13 +43,17 @@ namespace osu.Game.Rulesets.Taiko.Mods private Vector2 getSizeFor(int combo) { + Vector2 size; + if (combo > 200) - return new Vector2(0, default_flashlight_size * 0.8f); + size = new Vector2(0, default_flashlight_size * 0.8f); + else if (combo > 100) + size = new Vector2(0, default_flashlight_size * 0.9f); + else + size = new Vector2(0, default_flashlight_size); - if (combo > 100) - return new Vector2(0, default_flashlight_size * 0.9f); - - return new Vector2(0, default_flashlight_size); + // Preserve flashlight size through the playfield's aspect adjustment. + return size * taikoPlayfield.DrawHeight / TaikoPlayfield.DEFAULT_HEIGHT; } protected override void OnComboChange(ValueChangedEvent e) @@ -66,6 +70,10 @@ namespace osu.Game.Rulesets.Taiko.Mods if (!flashlightProperties.IsValid) { FlashlightPosition = ToLocalSpace(taikoPlayfield.HitTarget.ScreenSpaceDrawQuad.Centre); + + ClearTransforms(targetMember: nameof(FlashlightSize)); + FlashlightSize = getSizeFor(Combo.Value); + flashlightProperties.Validate(); } } From a743a3f3067e375516a0d1bd7c8a37b93400c7cf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Sep 2021 19:15:14 +0900 Subject: [PATCH 4/5] Change combo bind logic to be non-weird --- osu.Game/Rulesets/Mods/ModFlashlight.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Mods/ModFlashlight.cs b/osu.Game/Rulesets/Mods/ModFlashlight.cs index f96f8a3c1b..a77a83b36c 100644 --- a/osu.Game/Rulesets/Mods/ModFlashlight.cs +++ b/osu.Game/Rulesets/Mods/ModFlashlight.cs @@ -69,9 +69,11 @@ namespace osu.Game.Rulesets.Mods public virtual void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) { var flashlight = CreateFlashlight(); - flashlight.Combo = Combo; + flashlight.RelativeSizeAxes = Axes.Both; flashlight.Colour = Color4.Black; + + flashlight.Combo.BindTo(Combo); drawableRuleset.KeyBindingInputManager.Add(flashlight); flashlight.Breaks = drawableRuleset.Beatmap.Breaks; @@ -81,7 +83,8 @@ namespace osu.Game.Rulesets.Mods public abstract class Flashlight : Drawable { - protected internal BindableInt Combo { get; internal set; } + public readonly BindableInt Combo = new BindableInt(); + private IShader shader; protected override DrawNode CreateDrawNode() => new FlashlightDrawNode(this); From be7346d0b76febd7e741e0fe6f97518d3140d2c0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Sep 2021 19:18:37 +0900 Subject: [PATCH 5/5] Refactor `getSizeFor` to read a touch better --- osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs index 12f19a0086..0a325f174e 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs @@ -43,17 +43,15 @@ namespace osu.Game.Rulesets.Taiko.Mods private Vector2 getSizeFor(int combo) { - Vector2 size; + float size = default_flashlight_size; if (combo > 200) - size = new Vector2(0, default_flashlight_size * 0.8f); + size *= 0.8f; else if (combo > 100) - size = new Vector2(0, default_flashlight_size * 0.9f); - else - size = new Vector2(0, default_flashlight_size); + size *= 0.9f; // Preserve flashlight size through the playfield's aspect adjustment. - return size * taikoPlayfield.DrawHeight / TaikoPlayfield.DEFAULT_HEIGHT; + return new Vector2(0, size * taikoPlayfield.DrawHeight / TaikoPlayfield.DEFAULT_HEIGHT); } protected override void OnComboChange(ValueChangedEvent e)