1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 16:22:57 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Edit/Blueprints/Spinners/SpinnerPlacementBlueprint.cs

64 lines
1.7 KiB
C#
Raw Normal View History

// 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.
2018-10-29 17:35:46 +08:00
using System;
2018-10-29 17:35:46 +08:00
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit;
2018-11-07 15:08:56 +08:00
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
2018-10-29 17:35:46 +08:00
using osu.Game.Rulesets.Osu.Objects;
2018-11-01 18:24:58 +08:00
using osu.Game.Rulesets.Osu.UI;
using osuTK.Input;
2018-10-29 17:35:46 +08:00
2018-11-07 15:08:56 +08:00
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
2018-10-29 17:35:46 +08:00
{
2018-11-06 17:04:03 +08:00
public class SpinnerPlacementBlueprint : PlacementBlueprint
2018-10-29 17:35:46 +08:00
{
public new Spinner HitObject => (Spinner)base.HitObject;
private readonly SpinnerPiece piece;
private bool isPlacingEnd;
2018-11-06 17:04:03 +08:00
public SpinnerPlacementBlueprint()
2018-11-01 18:24:58 +08:00
: base(new Spinner { Position = OsuPlayfield.BASE_SIZE / 2 })
2018-10-29 17:35:46 +08:00
{
InternalChild = piece = new SpinnerPiece { Alpha = 0.5f };
}
protected override void Update()
{
base.Update();
if (isPlacingEnd)
HitObject.EndTime = Math.Max(HitObject.StartTime, EditorClock.CurrentTime);
piece.UpdateFrom(HitObject);
2018-10-29 17:35:46 +08:00
}
protected override bool OnMouseDown(MouseDownEvent e)
2018-10-29 17:35:46 +08:00
{
if (isPlacingEnd)
{
if (e.Button != MouseButton.Right)
return false;
2018-10-29 17:35:46 +08:00
HitObject.EndTime = EditorClock.CurrentTime;
EndPlacement(true);
2018-10-29 17:35:46 +08:00
}
else
{
if (e.Button != MouseButton.Left)
return false;
BeginPlacement(commitStart: true);
2020-02-07 23:28:52 +08:00
piece.FadeTo(1f, 150, Easing.OutQuint);
isPlacingEnd = true;
2018-10-29 17:35:46 +08:00
}
return true;
}
}
}