mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 17:17:26 +08:00
improve the grid from points
This commit is contained in:
parent
3495510c7b
commit
fea0ceb498
@ -58,12 +58,17 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
gridFromPointsStart = null;
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
return isPlacingGridFromPoints || base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (!isPlacingGridFromPoints)
|
||||
return base.OnClick(e);
|
||||
|
||||
var pos = ToLocalSpace(Composer.FindSnappedPositionAndTime(e.ScreenSpaceMousePosition).ScreenSpacePosition);
|
||||
var pos = ToLocalSpace(Composer.FindSnappedPositionAndTime(e.ScreenSpaceMousePosition, ~SnapType.GlobalGrids).ScreenSpacePosition);
|
||||
|
||||
if (!gridFromPointsStart.HasValue)
|
||||
{
|
||||
@ -78,5 +83,24 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
if (!isPlacingGridFromPoints)
|
||||
return base.OnMouseMove(e);
|
||||
|
||||
var pos = ToLocalSpace(Composer.FindSnappedPositionAndTime(e.ScreenSpaceMousePosition, ~SnapType.GlobalGrids).ScreenSpacePosition);
|
||||
|
||||
if (!gridFromPointsStart.HasValue)
|
||||
{
|
||||
gridToolbox.StartPosition.Value = pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
gridToolbox.SetGridFromPoints(gridFromPointsStart.Value, pos);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
MinValue = 0f,
|
||||
MaxValue = OsuPlayfield.BASE_SIZE.X,
|
||||
Precision = 1f
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -49,7 +48,6 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
MinValue = 0f,
|
||||
MaxValue = OsuPlayfield.BASE_SIZE.Y,
|
||||
Precision = 1f
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -59,7 +57,6 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
MinValue = 4f,
|
||||
MaxValue = 128f,
|
||||
Precision = 1f
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -69,7 +66,6 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
MinValue = -45f,
|
||||
MaxValue = 45f,
|
||||
Precision = 1f
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -105,9 +101,15 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
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;
|
||||
|
||||
// Get the angle between the two points and normalize to the valid range.
|
||||
float period = GridType.Value == PositionSnapGridType.Triangle ? 60 : 90;
|
||||
GridLinesRotation.Value = (MathHelper.RadiansToDegrees(MathF.Atan2(point2.Y - point1.Y, point2.X - point1.X))
|
||||
+ 360 + period / 2) % period - period / 2;
|
||||
|
||||
// Divide the distance so that there is a good density of grid lines.
|
||||
float dist = Vector2.Distance(point1, point2);
|
||||
while (dist > Spacing.MaxValue)
|
||||
while (dist > 32)
|
||||
dist /= 2;
|
||||
Spacing.Value = dist;
|
||||
}
|
||||
@ -181,22 +183,28 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
StartPositionX.BindValueChanged(x =>
|
||||
{
|
||||
startPositionXSlider.ContractedLabelText = $"X: {x.NewValue:N0}";
|
||||
startPositionXSlider.ExpandedLabelText = $"X Offset: {x.NewValue:N0}";
|
||||
startPositionXSlider.ContractedLabelText = $"X: {x.NewValue:#,0.##}";
|
||||
startPositionXSlider.ExpandedLabelText = $"X Offset: {x.NewValue:#,0.##}";
|
||||
StartPosition.Value = new Vector2(x.NewValue, StartPosition.Value.Y);
|
||||
}, true);
|
||||
|
||||
StartPositionY.BindValueChanged(y =>
|
||||
{
|
||||
startPositionYSlider.ContractedLabelText = $"Y: {y.NewValue:N0}";
|
||||
startPositionYSlider.ExpandedLabelText = $"Y Offset: {y.NewValue:N0}";
|
||||
startPositionYSlider.ContractedLabelText = $"Y: {y.NewValue:#,0.##}";
|
||||
startPositionYSlider.ExpandedLabelText = $"Y Offset: {y.NewValue:#,0.##}";
|
||||
StartPosition.Value = new Vector2(StartPosition.Value.X, y.NewValue);
|
||||
}, true);
|
||||
|
||||
StartPosition.BindValueChanged(pos =>
|
||||
{
|
||||
StartPositionX.Value = pos.NewValue.X;
|
||||
StartPositionY.Value = pos.NewValue.Y;
|
||||
});
|
||||
|
||||
Spacing.BindValueChanged(spacing =>
|
||||
{
|
||||
spacingSlider.ContractedLabelText = $"S: {spacing.NewValue:N0}";
|
||||
spacingSlider.ExpandedLabelText = $"Spacing: {spacing.NewValue:N0}";
|
||||
spacingSlider.ContractedLabelText = $"S: {spacing.NewValue:#,0.##}";
|
||||
spacingSlider.ExpandedLabelText = $"Spacing: {spacing.NewValue:#,0.##}";
|
||||
SpacingVector.Value = new Vector2(spacing.NewValue);
|
||||
editorBeatmap.BeatmapInfo.GridSize = (int)spacing.NewValue;
|
||||
}, true);
|
||||
|
Loading…
Reference in New Issue
Block a user