2022-09-18 19:08:34 +00:00
|
|
|
|
// 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 System;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
|
using osu.Framework.Input.Events;
|
2022-10-04 01:19:05 +00:00
|
|
|
|
using osu.Framework.Logging;
|
2022-09-18 19:08:34 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.UI
|
|
|
|
|
{
|
|
|
|
|
[Cached]
|
|
|
|
|
public class SmokeContainer : Container, IRequireHighFrequencyMousePosition, IKeyBindingHandler<OsuAction>
|
|
|
|
|
{
|
|
|
|
|
public event Action<Vector2, double>? SmokeMoved;
|
|
|
|
|
public event Action<double>? SmokeEnded;
|
|
|
|
|
|
2022-09-19 17:16:05 +00:00
|
|
|
|
public Vector2 LastMousePosition;
|
|
|
|
|
|
2022-09-19 01:32:33 +00:00
|
|
|
|
private bool isSmoking;
|
2022-09-18 19:08:34 +00:00
|
|
|
|
|
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 _) => true;
|
|
|
|
|
|
|
|
|
|
public bool OnPressed(KeyBindingPressEvent<OsuAction> e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Action == OsuAction.Smoke)
|
|
|
|
|
{
|
2022-10-04 01:19:05 +00:00
|
|
|
|
Logger.Log("holy moly");
|
|
|
|
|
|
2022-09-18 19:08:34 +00:00
|
|
|
|
isSmoking = true;
|
|
|
|
|
AddInternal(new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Smoke), _ => new DefaultSmoke()));
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Action == OsuAction.Smoke)
|
|
|
|
|
{
|
|
|
|
|
isSmoking = false;
|
|
|
|
|
SmokeEnded?.Invoke(Time.Current);
|
2022-10-03 23:03:37 +00:00
|
|
|
|
|
|
|
|
|
foreach (SkinnableDrawable skinnable in Children)
|
|
|
|
|
skinnable.LifetimeEnd = skinnable.Drawable.LifetimeEnd;
|
2022-09-18 19:08:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
|
|
|
|
{
|
|
|
|
|
if (isSmoking)
|
|
|
|
|
SmokeMoved?.Invoke(e.MousePosition, Time.Current);
|
|
|
|
|
|
2022-09-19 17:16:05 +00:00
|
|
|
|
LastMousePosition = e.MousePosition;
|
|
|
|
|
|
2022-09-18 19:08:34 +00:00
|
|
|
|
return base.OnMouseMove(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|