mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Move slider range control to song select
This commit is contained in:
@ -38,8 +38,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private T lastSampleValue;
|
private T lastSampleValue;
|
||||||
|
|
||||||
protected readonly Nub Nub;
|
protected readonly Nub Nub;
|
||||||
private readonly Box leftBox;
|
protected readonly Box LeftBox;
|
||||||
private readonly Box rightBox;
|
protected readonly Box RightBox;
|
||||||
private readonly Container nubContainer;
|
private readonly Container nubContainer;
|
||||||
|
|
||||||
public virtual LocalisableString TooltipText { get; private set; }
|
public virtual LocalisableString TooltipText { get; private set; }
|
||||||
@ -57,7 +57,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
accentColour = value;
|
accentColour = value;
|
||||||
leftBox.Colour = value;
|
LeftBox.Colour = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
backgroundColour = value;
|
backgroundColour = value;
|
||||||
rightBox.Colour = value;
|
RightBox.Colour = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
CornerRadius = 5f,
|
CornerRadius = 5f,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
leftBox = new Box
|
LeftBox = new Box
|
||||||
{
|
{
|
||||||
Height = 5,
|
Height = 5,
|
||||||
EdgeSmoothness = new Vector2(0, 0.5f),
|
EdgeSmoothness = new Vector2(0, 0.5f),
|
||||||
@ -104,7 +104,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
},
|
},
|
||||||
rightBox = new Box
|
RightBox = new Box
|
||||||
{
|
{
|
||||||
Height = 5,
|
Height = 5,
|
||||||
EdgeSmoothness = new Vector2(0, 0.5f),
|
EdgeSmoothness = new Vector2(0, 0.5f),
|
||||||
@ -225,9 +225,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
leftBox.Scale = new Vector2(Math.Clamp(
|
LeftBox.Scale = new Vector2(Math.Clamp(
|
||||||
RangePadding + Nub.DrawPosition.X - Nub.DrawWidth / 2, 0, DrawWidth), 1);
|
RangePadding + Nub.DrawPosition.X - Nub.DrawWidth / 2, 0, DrawWidth), 1);
|
||||||
rightBox.Scale = new Vector2(Math.Clamp(
|
RightBox.Scale = new Vector2(Math.Clamp(
|
||||||
DrawWidth - Nub.DrawPosition.X - RangePadding - Nub.DrawWidth / 2, 0, DrawWidth), 1);
|
DrawWidth - Nub.DrawPosition.X - RangePadding - Nub.DrawWidth / 2, 0, DrawWidth), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,13 +3,10 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Overlays.Mods.Input;
|
using osu.Game.Overlays.Mods.Input;
|
||||||
|
|
||||||
@ -17,20 +14,11 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
|
|||||||
{
|
{
|
||||||
public class SongSelectSettings : SettingsSubsection
|
public class SongSelectSettings : SettingsSubsection
|
||||||
{
|
{
|
||||||
private Bindable<double> minStars;
|
|
||||||
private Bindable<double> maxStars;
|
|
||||||
|
|
||||||
protected override LocalisableString Header => UserInterfaceStrings.SongSelectHeader;
|
protected override LocalisableString Header => UserInterfaceStrings.SongSelectHeader;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
minStars = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum);
|
|
||||||
maxStars = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum);
|
|
||||||
|
|
||||||
minStars.ValueChanged += min => maxStars.Value = Math.Max(min.NewValue, maxStars.Value);
|
|
||||||
maxStars.ValueChanged += max => minStars.Value = Math.Min(max.NewValue, minStars.Value);
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
@ -44,20 +32,6 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
|
|||||||
LabelText = UserInterfaceStrings.ShowConvertedBeatmaps,
|
LabelText = UserInterfaceStrings.ShowConvertedBeatmaps,
|
||||||
Current = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps),
|
Current = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps),
|
||||||
},
|
},
|
||||||
new SettingsSlider<double, StarsSlider>
|
|
||||||
{
|
|
||||||
LabelText = UserInterfaceStrings.StarsMinimum,
|
|
||||||
Current = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum),
|
|
||||||
KeyboardStep = 0.1f,
|
|
||||||
Keywords = new[] { "minimum", "maximum", "star", "difficulty" }
|
|
||||||
},
|
|
||||||
new SettingsSlider<double, MaximumStarsSlider>
|
|
||||||
{
|
|
||||||
LabelText = UserInterfaceStrings.StarsMaximum,
|
|
||||||
Current = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum),
|
|
||||||
KeyboardStep = 0.1f,
|
|
||||||
Keywords = new[] { "minimum", "maximum", "star", "difficulty" }
|
|
||||||
},
|
|
||||||
new SettingsEnumDropdown<RandomSelectAlgorithm>
|
new SettingsEnumDropdown<RandomSelectAlgorithm>
|
||||||
{
|
{
|
||||||
LabelText = UserInterfaceStrings.RandomSelectionAlgorithm,
|
LabelText = UserInterfaceStrings.RandomSelectionAlgorithm,
|
||||||
@ -71,15 +45,5 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MaximumStarsSlider : StarsSlider
|
|
||||||
{
|
|
||||||
public override LocalisableString TooltipText => Current.IsDefault ? UserInterfaceStrings.NoLimit : base.TooltipText;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class StarsSlider : OsuSliderBar<double>
|
|
||||||
{
|
|
||||||
public override LocalisableString TooltipText => Current.Value.ToString(@"0.## stars");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
90
osu.Game/Screens/Select/DifficultyRangeFilterControl.cs
Normal file
90
osu.Game/Screens/Select/DifficultyRangeFilterControl.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Select
|
||||||
|
{
|
||||||
|
internal class DifficultyRangeFilterControl : CompositeDrawable
|
||||||
|
{
|
||||||
|
private Bindable<double> minStars;
|
||||||
|
private Bindable<double> maxStars;
|
||||||
|
|
||||||
|
private StarsSlider lowerSlider;
|
||||||
|
private MaximumStarsSlider upperSlider;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
const float vertical_offset = 15;
|
||||||
|
|
||||||
|
InternalChildren = new[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = "Difficulty range",
|
||||||
|
Font = OsuFont.GetFont(size: 14),
|
||||||
|
},
|
||||||
|
upperSlider = new MaximumStarsSlider
|
||||||
|
{
|
||||||
|
Current = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum),
|
||||||
|
KeyboardStep = 0.1f,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Y = vertical_offset,
|
||||||
|
},
|
||||||
|
lowerSlider = new StarsSlider
|
||||||
|
{
|
||||||
|
Current = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum),
|
||||||
|
KeyboardStep = 0.1f,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Y = vertical_offset,
|
||||||
|
},
|
||||||
|
lowerSlider.Nub.CreateProxy(),
|
||||||
|
upperSlider.Nub.CreateProxy(),
|
||||||
|
};
|
||||||
|
|
||||||
|
lowerSlider.LeftBox.Height = 6;
|
||||||
|
|
||||||
|
minStars = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum);
|
||||||
|
maxStars = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum);
|
||||||
|
|
||||||
|
lowerSlider.AccentColour = lowerSlider.BackgroundColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
minStars.ValueChanged += min => maxStars.Value = Math.Max(min.NewValue, maxStars.Value);
|
||||||
|
maxStars.ValueChanged += max => minStars.Value = Math.Min(max.NewValue, minStars.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MaximumStarsSlider : StarsSlider
|
||||||
|
{
|
||||||
|
public override LocalisableString TooltipText => Current.IsDefault ? UserInterfaceStrings.NoLimit : base.TooltipText;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class StarsSlider : OsuSliderBar<double>
|
||||||
|
{
|
||||||
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Nub.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
|
||||||
|
public override LocalisableString TooltipText => Current.Value.ToString(@"0.## stars");
|
||||||
|
|
||||||
|
public new Nub Nub => base.Nub;
|
||||||
|
public new Box LeftBox => base.LeftBox;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -158,6 +158,11 @@ namespace osu.Game.Screens.Select
|
|||||||
Height = 20,
|
Height = 20,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
new DifficultyRangeFilterControl
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Width = 0.5f,
|
||||||
|
},
|
||||||
collectionDropdown = new CollectionFilterDropdown
|
collectionDropdown = new CollectionFilterDropdown
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
|
Reference in New Issue
Block a user