mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 00:42:55 +08:00
Merge pull request #21467 from peppy/catch-relax-no-cursor
Hide the game mouse cursor when playing osu!catch with relax mod
This commit is contained in:
commit
f050125c32
@ -4,8 +4,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Rulesets.Catch.Mods;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.UI;
|
||||
@ -55,6 +57,21 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
|
||||
}
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestGameCursorHidden()
|
||||
{
|
||||
CreateModTest(new ModTestData
|
||||
{
|
||||
Mod = new CatchModRelax(),
|
||||
Autoplay = false,
|
||||
PassCondition = () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<DrawableCatchRuleset>().Single());
|
||||
return this.ChildrenOfType<MenuCursorContainer>().Single().State.Value == Visibility.Hidden;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private bool passCondition()
|
||||
{
|
||||
var playfield = this.ChildrenOfType<CatchPlayfield>().Single();
|
||||
|
@ -3,13 +3,16 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osuTK;
|
||||
|
||||
@ -49,6 +52,14 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
protected override GameplayCursorContainer CreateCursor()
|
||||
{
|
||||
if (Mods != null && Mods.Any(m => m is ModRelax))
|
||||
return new CatchRelaxCursorContainer();
|
||||
|
||||
return base.CreateCursor();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
|
15
osu.Game.Rulesets.Catch/UI/CatchRelaxCursorContainer.cs
Normal file
15
osu.Game.Rulesets.Catch/UI/CatchRelaxCursorContainer.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
public partial class CatchRelaxCursorContainer : GameplayCursorContainer
|
||||
{
|
||||
// Just hide the cursor in relax.
|
||||
// The main goal here is to show that we have a cursor so the game never shows the global one.
|
||||
protected override Drawable CreateCursor() => Empty();
|
||||
}
|
||||
}
|
@ -93,7 +93,8 @@ namespace osu.Game.Rulesets.UI
|
||||
public readonly BindableBool DisplayJudgements = new BindableBool(true);
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IReadOnlyList<Mod> mods { get; set; }
|
||||
[CanBeNull]
|
||||
protected IReadOnlyList<Mod> Mods { get; private set; }
|
||||
|
||||
private readonly HitObjectEntryManager entryManager = new HitObjectEntryManager();
|
||||
|
||||
@ -243,9 +244,9 @@ namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (!IsNested && mods != null)
|
||||
if (!IsNested && Mods != null)
|
||||
{
|
||||
foreach (var mod in mods)
|
||||
foreach (var mod in Mods)
|
||||
{
|
||||
if (mod is IUpdatableByPlayfield updatable)
|
||||
updatable.Update(this);
|
||||
@ -374,9 +375,9 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
// If this is the first time this DHO is being used, then apply the DHO mods.
|
||||
// This is done before Apply() so that the state is updated once when the hitobject is applied.
|
||||
if (mods != null)
|
||||
if (Mods != null)
|
||||
{
|
||||
foreach (var m in mods.OfType<IApplicableToDrawableHitObject>())
|
||||
foreach (var m in Mods.OfType<IApplicableToDrawableHitObject>())
|
||||
m.ApplyToDrawableHitObject(dho);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user