Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 1px flashlight gaps when gameplay scaling mode is active #27533

Merged
merged 2 commits into from Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -43,7 +43,7 @@ public void TestPlayfieldBasedSize()
PassCondition = () =>
{
var flashlightOverlay = Player.DrawableRuleset.Overlays
.OfType<ModFlashlight<OsuHitObject>.Flashlight>()
.ChildrenOfType<ModFlashlight<OsuHitObject>.Flashlight>()
.First();

return Precision.AlmostEquals(mod.DefaultFlashlightSize * .5f, flashlightOverlay.GetSize());
Expand Down
9 changes: 8 additions & 1 deletion osu.Game/Rulesets/Mods/ModFlashlight.cs
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Rendering.Vertices;
Expand Down Expand Up @@ -88,7 +89,13 @@ public virtual void ApplyToDrawableRuleset(DrawableRuleset<T> drawableRuleset)
flashlight.Combo.BindTo(Combo);
flashlight.GetPlayfieldScale = () => drawableRuleset.Playfield.Scale;

drawableRuleset.Overlays.Add(flashlight);
drawableRuleset.Overlays.Add(new Container
{
RelativeSizeAxes = Axes.Both,
// workaround for 1px gaps on the edges of the playfield which would sometimes show with "gameplay" screen scaling active.
Padding = new MarginPadding(-1),
Child = flashlight,
});
}

protected abstract Flashlight CreateFlashlight();
Expand Down