mirror of
https://github.com/osukey/osukey.git
synced 2025-05-21 13:37:20 +09:00
Add basic banana shower placement tool
This commit is contained in:
parent
4d7a877795
commit
e8907b53a8
20
osu.Game.Rulesets.Catch/Edit/BananaShowerCompositionTool.cs
Normal file
20
osu.Game.Rulesets.Catch/Edit/BananaShowerCompositionTool.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// 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.Game.Rulesets.Catch.Edit.Blueprints;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Edit
|
||||||
|
{
|
||||||
|
public class BananaShowerCompositionTool : HitObjectCompositionTool
|
||||||
|
{
|
||||||
|
public BananaShowerCompositionTool()
|
||||||
|
: base(nameof(BananaShower))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override PlacementBlueprint CreatePlacementBlueprint() => new BananaShowerPlacementBlueprint();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
// 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.Input.Events;
|
||||||
|
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Edit.Blueprints
|
||||||
|
{
|
||||||
|
public class BananaShowerPlacementBlueprint : CatchPlacementBlueprint<BananaShower>
|
||||||
|
{
|
||||||
|
private readonly TimeSpanOutline outline;
|
||||||
|
|
||||||
|
public BananaShowerPlacementBlueprint()
|
||||||
|
{
|
||||||
|
InternalChild = outline = new TimeSpanOutline();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
outline.UpdateFrom(HitObjectContainer, HitObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
|
{
|
||||||
|
switch (PlacementActive)
|
||||||
|
{
|
||||||
|
case PlacementState.Waiting:
|
||||||
|
if (e.Button != MouseButton.Left) break;
|
||||||
|
|
||||||
|
BeginPlacement(true);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case PlacementState.Active:
|
||||||
|
if (e.Button != MouseButton.Right) break;
|
||||||
|
|
||||||
|
if (HitObject.Duration < 0)
|
||||||
|
{
|
||||||
|
HitObject.StartTime = HitObject.EndTime;
|
||||||
|
HitObject.Duration = -HitObject.Duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
EndPlacement(HitObject.Duration > 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnMouseDown(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateTimeAndPosition(SnapResult result)
|
||||||
|
{
|
||||||
|
base.UpdateTimeAndPosition(result);
|
||||||
|
|
||||||
|
if (!(result.Time is double time)) return;
|
||||||
|
|
||||||
|
switch (PlacementActive)
|
||||||
|
{
|
||||||
|
case PlacementState.Waiting:
|
||||||
|
HitObject.StartTime = time;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PlacementState.Active:
|
||||||
|
HitObject.EndTime = time;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
|
||||||
|
{
|
||||||
|
public class TimeSpanOutline : CompositeDrawable
|
||||||
|
{
|
||||||
|
private const float border_width = 4;
|
||||||
|
|
||||||
|
private bool isEmpty = true;
|
||||||
|
|
||||||
|
public TimeSpanOutline()
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft;
|
||||||
|
Origin = Anchor.BottomLeft;
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
Masking = true;
|
||||||
|
BorderThickness = border_width;
|
||||||
|
|
||||||
|
// a box is needed to make edge visible
|
||||||
|
InternalChild = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.Transparent
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour osuColour)
|
||||||
|
{
|
||||||
|
BorderColour = osuColour.Yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateFrom(ScrollingHitObjectContainer hitObjectContainer, BananaShower hitObject)
|
||||||
|
{
|
||||||
|
float startY = hitObjectContainer.PositionAtTime(hitObject.StartTime);
|
||||||
|
float endY = hitObjectContainer.PositionAtTime(hitObject.EndTime);
|
||||||
|
|
||||||
|
Y = Math.Max(startY, endY);
|
||||||
|
float height = Math.Abs(startY - endY);
|
||||||
|
|
||||||
|
bool wasEmpty = isEmpty;
|
||||||
|
isEmpty = height == 0;
|
||||||
|
if (wasEmpty != isEmpty)
|
||||||
|
this.FadeTo(isEmpty ? 0.5f : 1f, 150);
|
||||||
|
|
||||||
|
Height = Math.Max(height, border_width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@ namespace osu.Game.Rulesets.Catch.Edit
|
|||||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||||
{
|
{
|
||||||
new FruitCompositionTool(),
|
new FruitCompositionTool(),
|
||||||
|
new BananaShowerCompositionTool()
|
||||||
};
|
};
|
||||||
|
|
||||||
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user