1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Refactor internal visibility logic to route back to PopIn/PopOut

This commit is contained in:
Salman Ahmed 2022-10-12 17:50:04 +03:00
parent 0a97ee71a9
commit 8305d886e6

View File

@ -28,10 +28,6 @@ namespace osu.Game.Graphics.Cursor
private Cursor activeCursor = null!;
private readonly Container fadeContainer;
protected override Container<Drawable> Content => fadeContainer;
private DragRotationState dragRotationState;
private Vector2 positionMouseDown;
private Vector2 lastMovePosition;
@ -39,11 +35,6 @@ namespace osu.Game.Graphics.Cursor
private Bindable<bool> cursorRotate = null!;
private Sample tapSample = null!;
public MenuCursorContainer()
{
InternalChild = fadeContainer = new Container { RelativeSizeAxes = Axes.Both };
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, ScreenshotManager? screenshotManager, AudioManager audio)
{
@ -58,14 +49,37 @@ namespace osu.Game.Graphics.Cursor
[Resolved]
private OsuUserInputManager inputManager { get; set; } = null!;
private IBindable<bool> mouseInputSource = null!;
private readonly IBindable<bool> mouseInputSource = new BindableBool();
private readonly Bindable<Visibility> internalState = new Bindable<Visibility>();
protected override void LoadComplete()
{
base.LoadComplete();
mouseInputSource = inputManager.IsMouseInputSource.GetBoundCopy();
mouseInputSource.BindValueChanged(m => updateInternalVisibilityState(m.NewValue), true);
internalState.ValueChanged += onInternalStateChanged;
mouseInputSource.BindTo(inputManager.IsMouseInputSource);
mouseInputSource.BindValueChanged(_ => updateInternalVisibility(), true);
}
private void updateInternalVisibility()
{
bool visible = mouseInputSource.Value;
internalState.Value = visible ? Visibility.Visible : Visibility.Hidden;
}
private void onInternalStateChanged(ValueChangedEvent<Visibility> internalState)
{
if (State.Value == Visibility.Visible)
base.UpdateState(internalState);
}
protected override void UpdateState(ValueChangedEvent<Visibility> state)
{
if (internalState.Value == Visibility.Visible)
base.UpdateState(state);
}
protected override void Update()
@ -168,8 +182,6 @@ namespace osu.Game.Graphics.Cursor
activeCursor.ScaleTo(0.6f, 250, Easing.In);
}
private void updateInternalVisibilityState(bool show) => fadeContainer.FadeTo(show ? 1 : 0, 120, Easing.OutQuint);
private void playTapSample(double baseFrequency = 1f)
{
const float random_range = 0.02f;