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;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Utils;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit
|
|
|
|
|
{
|
2023-11-20 04:17:43 +00:00
|
|
|
|
public partial class OsuSliderDrawingSettingsProvider : Drawable
|
2023-11-11 09:45:22 +00:00
|
|
|
|
{
|
2023-11-14 07:52:45 +00:00
|
|
|
|
public BindableFloat Tolerance { get; } = new BindableFloat(1.5f)
|
|
|
|
|
{
|
|
|
|
|
MinValue = 0.05f,
|
|
|
|
|
MaxValue = 3f,
|
|
|
|
|
Precision = 0.01f
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-20 06:54:43 +00:00
|
|
|
|
private readonly BindableInt sliderTolerance = new BindableInt(40)
|
2023-11-14 07:52:45 +00:00
|
|
|
|
{
|
|
|
|
|
MinValue = 5,
|
|
|
|
|
MaxValue = 100
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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-11-14 07:52:45 +00:00
|
|
|
|
private readonly BindableInt sliderCornerThreshold = new BindableInt(40)
|
2023-11-11 09:45:22 +00:00
|
|
|
|
{
|
|
|
|
|
MinValue = 5,
|
|
|
|
|
MaxValue = 100
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private ExpandableSlider<int> toleranceSlider = null!;
|
2023-11-14 07:52:45 +00:00
|
|
|
|
private ExpandableSlider<int> cornerThresholdSlider = null!;
|
2023-11-11 09:45:22 +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-11 09:45:22 +00:00
|
|
|
|
sliderTolerance.BindValueChanged(v =>
|
|
|
|
|
{
|
2023-11-14 07:52:45 +00:00
|
|
|
|
float newValue = v.NewValue / 33f;
|
2023-11-15 06:09:33 +00:00
|
|
|
|
if (!Precision.AlmostEquals(newValue, Tolerance.Value))
|
2023-11-11 09:45:22 +00:00
|
|
|
|
Tolerance.Value = newValue;
|
|
|
|
|
});
|
|
|
|
|
Tolerance.BindValueChanged(v =>
|
|
|
|
|
{
|
2023-11-14 07:52:45 +00:00
|
|
|
|
int newValue = (int)Math.Round(v.NewValue * 33f);
|
2023-11-11 09:45:22 +00:00
|
|
|
|
if (sliderTolerance.Value != newValue)
|
|
|
|
|
sliderTolerance.Value = newValue;
|
|
|
|
|
});
|
2023-11-14 07:52:45 +00:00
|
|
|
|
sliderCornerThreshold.BindValueChanged(v =>
|
|
|
|
|
{
|
|
|
|
|
float newValue = v.NewValue / 100f;
|
2023-11-15 06:09:33 +00:00
|
|
|
|
if (!Precision.AlmostEquals(newValue, CornerThreshold.Value))
|
2023-11-14 07:52:45 +00:00
|
|
|
|
CornerThreshold.Value = newValue;
|
|
|
|
|
});
|
|
|
|
|
CornerThreshold.BindValueChanged(v =>
|
|
|
|
|
{
|
|
|
|
|
int newValue = (int)Math.Round(v.NewValue * 100f);
|
|
|
|
|
if (sliderCornerThreshold.Value != newValue)
|
|
|
|
|
sliderCornerThreshold.Value = newValue;
|
|
|
|
|
});
|
2023-11-11 09:45:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AttachToToolbox(ExpandingToolboxContainer toolboxContainer)
|
|
|
|
|
{
|
2023-11-15 06:09:33 +00:00
|
|
|
|
toolboxContainer.Add(new EditorToolboxGroup("slider")
|
2023-11-11 09:45:22 +00:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
toleranceSlider = new ExpandableSlider<int>
|
|
|
|
|
{
|
|
|
|
|
Current = sliderTolerance
|
2023-11-14 07:52:45 +00:00
|
|
|
|
},
|
|
|
|
|
cornerThresholdSlider = new ExpandableSlider<int>
|
|
|
|
|
{
|
|
|
|
|
Current = sliderCornerThreshold
|
2023-11-11 09:45:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
sliderTolerance.BindValueChanged(e =>
|
|
|
|
|
{
|
2023-11-11 14:02:06 +00:00
|
|
|
|
toleranceSlider.ContractedLabelText = $"C. P. S.: {e.NewValue:N0}";
|
|
|
|
|
toleranceSlider.ExpandedLabelText = $"Control Point Spacing: {e.NewValue:N0}";
|
2023-11-11 09:45:22 +00:00
|
|
|
|
}, true);
|
2023-11-14 07:52:45 +00:00
|
|
|
|
|
|
|
|
|
sliderCornerThreshold.BindValueChanged(e =>
|
|
|
|
|
{
|
|
|
|
|
cornerThresholdSlider.ContractedLabelText = $"C. T.: {e.NewValue:N0}";
|
|
|
|
|
cornerThresholdSlider.ExpandedLabelText = $"Corner Threshold: {e.NewValue:N0}";
|
|
|
|
|
}, true);
|
2023-11-11 09:45:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|