2023-11-11 09:45:22 +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;
|
2023-11-20 15:25:23 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2023-11-11 09:45:22 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit
|
|
|
|
|
{
|
2023-11-21 00:59:49 +00:00
|
|
|
|
public partial class FreehandSliderToolboxGroup : EditorToolboxGroup
|
2023-11-11 09:45:22 +00:00
|
|
|
|
{
|
2023-11-21 00:59:49 +00:00
|
|
|
|
public FreehandSliderToolboxGroup()
|
2023-11-20 15:25:23 +00:00
|
|
|
|
: base("slider")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-07 00:15:42 +00:00
|
|
|
|
public BindableFloat Tolerance { get; } = new BindableFloat(1.8f)
|
2023-11-14 07:52:45 +00:00
|
|
|
|
{
|
|
|
|
|
MinValue = 0.05f,
|
2023-12-06 15:36:24 +00:00
|
|
|
|
MaxValue = 2.0f,
|
2023-11-14 07:52:45 +00:00
|
|
|
|
Precision = 0.01f
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public BindableFloat CornerThreshold { get; } = new BindableFloat(0.4f)
|
2023-11-11 09:45:22 +00:00
|
|
|
|
{
|
|
|
|
|
MinValue = 0.05f,
|
|
|
|
|
MaxValue = 1f,
|
|
|
|
|
Precision = 0.01f
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-07 00:15:42 +00:00
|
|
|
|
public BindableFloat CircleThreshold { get; } = new BindableFloat(0.0015f)
|
2023-12-06 23:43:34 +00:00
|
|
|
|
{
|
|
|
|
|
MinValue = 0f,
|
|
|
|
|
MaxValue = 0.005f,
|
|
|
|
|
Precision = 0.0001f
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 00:59:49 +00:00
|
|
|
|
// We map internal ranges to a more standard range of values for display to the user.
|
2023-12-07 00:15:42 +00:00
|
|
|
|
private readonly BindableInt displayTolerance = new BindableInt(90)
|
2023-11-20 15:21:44 +00:00
|
|
|
|
{
|
|
|
|
|
MinValue = 5,
|
|
|
|
|
MaxValue = 100
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 00:59:49 +00:00
|
|
|
|
private readonly BindableInt displayCornerThreshold = new BindableInt(40)
|
2023-11-11 09:45:22 +00:00
|
|
|
|
{
|
|
|
|
|
MinValue = 5,
|
|
|
|
|
MaxValue = 100
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-07 00:15:42 +00:00
|
|
|
|
private readonly BindableInt displayCircleThreshold = new BindableInt(30)
|
2023-12-06 23:43:34 +00:00
|
|
|
|
{
|
|
|
|
|
MinValue = 0,
|
|
|
|
|
MaxValue = 100
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-11 09:45:22 +00:00
|
|
|
|
private ExpandableSlider<int> toleranceSlider = null!;
|
2023-11-14 07:52:45 +00:00
|
|
|
|
private ExpandableSlider<int> cornerThresholdSlider = null!;
|
2023-12-06 23:43:34 +00:00
|
|
|
|
private ExpandableSlider<int> circleThresholdSlider = null!;
|
2023-11-11 09:45:22 +00:00
|
|
|
|
|
2023-11-20 15:25:23 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
toleranceSlider = new ExpandableSlider<int>
|
|
|
|
|
{
|
2023-11-21 00:59:49 +00:00
|
|
|
|
Current = displayTolerance
|
2023-11-20 15:25:23 +00:00
|
|
|
|
},
|
|
|
|
|
cornerThresholdSlider = new ExpandableSlider<int>
|
|
|
|
|
{
|
2023-11-21 00:59:49 +00:00
|
|
|
|
Current = displayCornerThreshold
|
2023-12-06 23:43:34 +00:00
|
|
|
|
},
|
|
|
|
|
circleThresholdSlider = new ExpandableSlider<int>
|
|
|
|
|
{
|
|
|
|
|
Current = displayCircleThreshold
|
2023-11-20 15:25:23 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-13 07:24:09 +00:00
|
|
|
|
protected override void LoadComplete()
|
2023-11-11 09:45:22 +00:00
|
|
|
|
{
|
2023-11-13 07:24:09 +00:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2023-11-21 00:59:49 +00:00
|
|
|
|
displayTolerance.BindValueChanged(tolerance =>
|
2023-11-14 07:52:45 +00:00
|
|
|
|
{
|
2023-11-21 00:59:49 +00:00
|
|
|
|
toleranceSlider.ContractedLabelText = $"C. P. S.: {tolerance.NewValue:N0}";
|
|
|
|
|
toleranceSlider.ExpandedLabelText = $"Control Point Spacing: {tolerance.NewValue:N0}";
|
|
|
|
|
|
|
|
|
|
Tolerance.Value = displayToInternalTolerance(tolerance.NewValue);
|
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
|
|
displayCornerThreshold.BindValueChanged(threshold =>
|
2023-11-14 07:52:45 +00:00
|
|
|
|
{
|
2023-11-21 00:59:49 +00:00
|
|
|
|
cornerThresholdSlider.ContractedLabelText = $"C. T.: {threshold.NewValue:N0}";
|
|
|
|
|
cornerThresholdSlider.ExpandedLabelText = $"Corner Threshold: {threshold.NewValue:N0}";
|
|
|
|
|
|
|
|
|
|
CornerThreshold.Value = displayToInternalCornerThreshold(threshold.NewValue);
|
|
|
|
|
}, true);
|
|
|
|
|
|
2023-12-06 23:43:34 +00:00
|
|
|
|
displayCircleThreshold.BindValueChanged(threshold =>
|
|
|
|
|
{
|
|
|
|
|
circleThresholdSlider.ContractedLabelText = $"P. C. T.: {threshold.NewValue:N0}";
|
|
|
|
|
circleThresholdSlider.ExpandedLabelText = $"Perfect Curve Threshold: {threshold.NewValue:N0}";
|
|
|
|
|
|
|
|
|
|
CircleThreshold.Value = displayToInternalCircleThreshold(threshold.NewValue);
|
|
|
|
|
}, true);
|
|
|
|
|
|
2023-11-21 00:59:49 +00:00
|
|
|
|
Tolerance.BindValueChanged(tolerance =>
|
|
|
|
|
displayTolerance.Value = internalToDisplayTolerance(tolerance.NewValue)
|
|
|
|
|
);
|
|
|
|
|
CornerThreshold.BindValueChanged(threshold =>
|
|
|
|
|
displayCornerThreshold.Value = internalToDisplayCornerThreshold(threshold.NewValue)
|
|
|
|
|
);
|
2023-12-06 23:43:34 +00:00
|
|
|
|
CircleThreshold.BindValueChanged(threshold =>
|
|
|
|
|
displayCircleThreshold.Value = internalToDisplayCircleThreshold(threshold.NewValue)
|
|
|
|
|
);
|
2023-11-21 00:59:49 +00:00
|
|
|
|
|
2023-12-06 15:36:24 +00:00
|
|
|
|
float displayToInternalTolerance(float v) => v / 50f;
|
|
|
|
|
int internalToDisplayTolerance(float v) => (int)Math.Round(v * 50f);
|
2023-11-21 00:59:49 +00:00
|
|
|
|
|
|
|
|
|
float displayToInternalCornerThreshold(float v) => v / 100f;
|
|
|
|
|
int internalToDisplayCornerThreshold(float v) => (int)Math.Round(v * 100f);
|
2023-12-06 23:43:34 +00:00
|
|
|
|
|
|
|
|
|
float displayToInternalCircleThreshold(float v) => v / 20000f;
|
|
|
|
|
int internalToDisplayCircleThreshold(float v) => (int)Math.Round(v * 20000f);
|
2023-11-11 09:45:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|