mirror of
https://github.com/ppy/osu.git
synced 2024-12-18 07:22:57 +08:00
kinda working grid from points
This commit is contained in:
parent
09852bc46b
commit
3495510c7b
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
||||||
@ -8,16 +10,26 @@ using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
|
|||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit
|
namespace osu.Game.Rulesets.Osu.Edit
|
||||||
{
|
{
|
||||||
public partial class OsuBlueprintContainer : ComposeBlueprintContainer
|
public partial class OsuBlueprintContainer : ComposeBlueprintContainer
|
||||||
{
|
{
|
||||||
|
private OsuGridToolboxGroup gridToolbox = null!;
|
||||||
|
|
||||||
public OsuBlueprintContainer(HitObjectComposer composer)
|
public OsuBlueprintContainer(HitObjectComposer composer)
|
||||||
: base(composer)
|
: base(composer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuGridToolboxGroup gridToolbox)
|
||||||
|
{
|
||||||
|
this.gridToolbox = gridToolbox;
|
||||||
|
gridToolbox.GridFromPointsClicked += OnGridFromPointsClicked;
|
||||||
|
}
|
||||||
|
|
||||||
protected override SelectionHandler<HitObject> CreateSelectionHandler() => new OsuSelectionHandler();
|
protected override SelectionHandler<HitObject> CreateSelectionHandler() => new OsuSelectionHandler();
|
||||||
|
|
||||||
public override HitObjectSelectionBlueprint? CreateHitObjectBlueprintFor(HitObject hitObject)
|
public override HitObjectSelectionBlueprint? CreateHitObjectBlueprintFor(HitObject hitObject)
|
||||||
@ -36,5 +48,35 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
|
|
||||||
return base.CreateHitObjectBlueprintFor(hitObject);
|
return base.CreateHitObjectBlueprintFor(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool isPlacingGridFromPoints;
|
||||||
|
private Vector2? gridFromPointsStart;
|
||||||
|
|
||||||
|
private void OnGridFromPointsClicked()
|
||||||
|
{
|
||||||
|
isPlacingGridFromPoints = true;
|
||||||
|
gridFromPointsStart = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
if (!isPlacingGridFromPoints)
|
||||||
|
return base.OnClick(e);
|
||||||
|
|
||||||
|
var pos = ToLocalSpace(Composer.FindSnappedPositionAndTime(e.ScreenSpaceMousePosition).ScreenSpacePosition);
|
||||||
|
|
||||||
|
if (!gridFromPointsStart.HasValue)
|
||||||
|
{
|
||||||
|
gridFromPointsStart = pos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gridToolbox.SetGridFromPoints(gridFromPointsStart.Value, pos);
|
||||||
|
isPlacingGridFromPoints = false;
|
||||||
|
gridFromPointsStart = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -12,6 +13,7 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
@ -90,6 +92,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
private ExpandableSlider<float> gridLinesRotationSlider = null!;
|
private ExpandableSlider<float> gridLinesRotationSlider = null!;
|
||||||
private EditorRadioButtonCollection gridTypeButtons = null!;
|
private EditorRadioButtonCollection gridTypeButtons = null!;
|
||||||
|
|
||||||
|
public event Action? GridFromPointsClicked;
|
||||||
|
|
||||||
public OsuGridToolboxGroup()
|
public OsuGridToolboxGroup()
|
||||||
: base("grid")
|
: base("grid")
|
||||||
{
|
{
|
||||||
@ -97,6 +101,17 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
|
|
||||||
private const float max_automatic_spacing = 64;
|
private const float max_automatic_spacing = 64;
|
||||||
|
|
||||||
|
public void SetGridFromPoints(Vector2 point1, Vector2 point2)
|
||||||
|
{
|
||||||
|
StartPositionX.Value = point1.X;
|
||||||
|
StartPositionY.Value = point1.Y;
|
||||||
|
GridLinesRotation.Value = (MathHelper.RadiansToDegrees(MathF.Atan2(point2.Y - point1.Y, point2.X - point1.X)) + 405) % 90 - 45;
|
||||||
|
float dist = Vector2.Distance(point1, point2);
|
||||||
|
while (dist > Spacing.MaxValue)
|
||||||
|
dist /= 2;
|
||||||
|
Spacing.Value = dist;
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -129,6 +144,12 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
Spacing = new Vector2(0f, 10f),
|
Spacing = new Vector2(0f, 10f),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
new RoundedButton
|
||||||
|
{
|
||||||
|
Action = () => GridFromPointsClicked?.Invoke(),
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Text = "Grid from points",
|
||||||
|
},
|
||||||
gridTypeButtons = new EditorRadioButtonCollection
|
gridTypeButtons = new EditorRadioButtonCollection
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Loading…
Reference in New Issue
Block a user