mirror of
https://github.com/ppy/osu.git
synced 2025-03-06 11:07:20 +08:00
Merge pull request #9488 from peppy/osu-cursor-visibility
Make default skin cursor more visible against bright backgrounds
This commit is contained in:
commit
a0268b4d3d
@ -5,7 +5,9 @@ using System;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Testing.Input;
|
using osu.Framework.Testing.Input;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
@ -24,9 +26,34 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuConfigManager config { get; set; }
|
private OsuConfigManager config { get; set; }
|
||||||
|
|
||||||
|
private Drawable background;
|
||||||
|
|
||||||
public TestSceneGameplayCursor()
|
public TestSceneGameplayCursor()
|
||||||
{
|
{
|
||||||
gameplayBeatmap = new GameplayBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
|
gameplayBeatmap = new GameplayBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
|
||||||
|
|
||||||
|
AddStep("change background colour", () =>
|
||||||
|
{
|
||||||
|
background?.Expire();
|
||||||
|
|
||||||
|
Add(background = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Depth = float.MaxValue,
|
||||||
|
Colour = new Colour4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AddSliderStep("circle size", 0f, 10f, 0f, val =>
|
||||||
|
{
|
||||||
|
config.Set(OsuSetting.AutoCursorSize, true);
|
||||||
|
gameplayBeatmap.BeatmapInfo.BaseDifficulty.CircleSize = val;
|
||||||
|
Scheduler.AddOnce(recreate);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("test cursor container", recreate);
|
||||||
|
|
||||||
|
void recreate() => SetContents(() => new OsuInputManager(new OsuRuleset().RulesetInfo) { Child = new OsuCursorContainer() });
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(1, 1)]
|
[TestCase(1, 1)]
|
||||||
@ -69,16 +96,27 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
private class ClickingCursorContainer : OsuCursorContainer
|
private class ClickingCursorContainer : OsuCursorContainer
|
||||||
{
|
{
|
||||||
|
private bool pressed;
|
||||||
|
|
||||||
|
public bool Pressed
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == pressed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pressed = value;
|
||||||
|
if (value)
|
||||||
|
OnPressed(OsuAction.LeftButton);
|
||||||
|
else
|
||||||
|
OnReleased(OsuAction.LeftButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
Pressed = ((int)(Time.Current / 1000)) % 2 == 0;
|
||||||
double currentTime = Time.Current;
|
|
||||||
|
|
||||||
if (((int)(currentTime / 1000)) % 2 == 0)
|
|
||||||
OnPressed(OsuAction.LeftButton);
|
|
||||||
else
|
|
||||||
OnReleased(OsuAction.LeftButton);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +125,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
public MovingCursorInputManager()
|
public MovingCursorInputManager()
|
||||||
{
|
{
|
||||||
UseParentInput = false;
|
UseParentInput = false;
|
||||||
|
ShowVisualCursorGuide = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
@ -59,10 +59,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
{
|
{
|
||||||
if (!cursorExpand) return;
|
if (!cursorExpand) return;
|
||||||
|
|
||||||
expandTarget.ScaleTo(released_scale).ScaleTo(pressed_scale, 100, Easing.OutQuad);
|
expandTarget.ScaleTo(released_scale).ScaleTo(pressed_scale, 400, Easing.OutElasticHalf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Contract() => expandTarget.ScaleTo(released_scale, 100, Easing.OutQuad);
|
public void Contract() => expandTarget.ScaleTo(released_scale, 400, Easing.OutQuad);
|
||||||
|
|
||||||
private class DefaultCursor : OsuCursorSprite
|
private class DefaultCursor : OsuCursorSprite
|
||||||
{
|
{
|
||||||
@ -115,24 +115,22 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new CircularContainer
|
},
|
||||||
{
|
},
|
||||||
Origin = Anchor.Centre,
|
new Circle
|
||||||
Anchor = Anchor.Centre,
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
Origin = Anchor.Centre,
|
||||||
Scale = new Vector2(0.1f),
|
Anchor = Anchor.Centre,
|
||||||
Masking = true,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Scale = new Vector2(0.14f),
|
||||||
{
|
Colour = new Color4(34, 93, 204, 255),
|
||||||
new Box
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
Type = EdgeEffectType.Glow,
|
||||||
Colour = Color4.White,
|
Radius = 8,
|
||||||
},
|
Colour = Color4.White,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
|
|
||||||
private readonly Drawable cursorTrail;
|
private readonly Drawable cursorTrail;
|
||||||
|
|
||||||
public Bindable<float> CursorScale = new BindableFloat(1);
|
public IBindable<float> CursorScale => cursorScale;
|
||||||
|
|
||||||
|
private readonly Bindable<float> cursorScale = new BindableFloat(1);
|
||||||
|
|
||||||
private Bindable<float> userCursorScale;
|
private Bindable<float> userCursorScale;
|
||||||
private Bindable<bool> autoCursorScale;
|
private Bindable<bool> autoCursorScale;
|
||||||
@ -68,13 +70,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
autoCursorScale = config.GetBindable<bool>(OsuSetting.AutoCursorSize);
|
autoCursorScale = config.GetBindable<bool>(OsuSetting.AutoCursorSize);
|
||||||
autoCursorScale.ValueChanged += _ => calculateScale();
|
autoCursorScale.ValueChanged += _ => calculateScale();
|
||||||
|
|
||||||
CursorScale.ValueChanged += e =>
|
CursorScale.BindValueChanged(e =>
|
||||||
{
|
{
|
||||||
var newScale = new Vector2(e.NewValue);
|
var newScale = new Vector2(e.NewValue);
|
||||||
|
|
||||||
ActiveCursor.Scale = newScale;
|
ActiveCursor.Scale = newScale;
|
||||||
cursorTrail.Scale = newScale;
|
cursorTrail.Scale = newScale;
|
||||||
};
|
}, true);
|
||||||
|
|
||||||
calculateScale();
|
calculateScale();
|
||||||
}
|
}
|
||||||
@ -95,7 +97,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
scale *= GetScaleForCircleSize(beatmap.BeatmapInfo.BaseDifficulty.CircleSize);
|
scale *= GetScaleForCircleSize(beatmap.BeatmapInfo.BaseDifficulty.CircleSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
CursorScale.Value = scale;
|
cursorScale.Value = scale;
|
||||||
|
|
||||||
var newScale = new Vector2(scale);
|
var newScale = new Vector2(scale);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
private OsuClickToResumeCursor clickToResumeCursor;
|
private OsuClickToResumeCursor clickToResumeCursor;
|
||||||
|
|
||||||
private OsuCursorContainer localCursorContainer;
|
private OsuCursorContainer localCursorContainer;
|
||||||
private Bindable<float> localCursorScale;
|
private IBindable<float> localCursorScale;
|
||||||
|
|
||||||
public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null;
|
public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user