mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:52:53 +08:00
Merge branch 'master' into NowPlaying
This commit is contained in:
commit
69bf0df179
@ -52,7 +52,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.1127.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.1126.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.1130.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
|
||||
|
@ -62,7 +62,6 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
section.Children.Where(f => f.IsPresent)
|
||||
.OfType<ISettingsItem>()
|
||||
.OfType<IFilterable>()
|
||||
.Where(f => !(f is IHasFilterableChildren))
|
||||
.All(f => f.FilterTerms.Any(t => t.ToString().Contains("scaling")))
|
||||
));
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Screens.Select;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
public partial class TestSceneDifficultyRangeFilterControl : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
AddStep("create control", () =>
|
||||
{
|
||||
Child = new DifficultyRangeFilterControl
|
||||
{
|
||||
Width = 200,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(3),
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
79
osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs
Normal file
79
osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs
Normal file
@ -0,0 +1,79 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public partial class TestSceneRangeSlider : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Red);
|
||||
|
||||
private readonly BindableNumber<double> customStart = new BindableNumber<double>
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 100,
|
||||
Precision = 0.1f
|
||||
};
|
||||
|
||||
private readonly BindableNumber<double> customEnd = new BindableNumber<double>(100)
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 100,
|
||||
Precision = 0.1f
|
||||
};
|
||||
|
||||
private RangeSlider rangeSlider = null!;
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("create control", () => Child = rangeSlider = new RangeSlider
|
||||
{
|
||||
Width = 200,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(3),
|
||||
LowerBound = customStart,
|
||||
UpperBound = customEnd,
|
||||
TooltipSuffix = "suffix",
|
||||
NubWidth = Nub.HEIGHT * 2,
|
||||
DefaultStringLowerBound = "Start",
|
||||
DefaultStringUpperBound = "End",
|
||||
MinRange = 10
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAdjustRange()
|
||||
{
|
||||
AddAssert("Initial lower bound is correct", () => rangeSlider.LowerBound.Value, () => Is.EqualTo(0).Within(0.1f));
|
||||
AddAssert("Initial upper bound is correct", () => rangeSlider.UpperBound.Value, () => Is.EqualTo(100).Within(0.1f));
|
||||
|
||||
AddStep("Adjust range", () =>
|
||||
{
|
||||
customStart.Value = 50;
|
||||
customEnd.Value = 75;
|
||||
});
|
||||
|
||||
AddAssert("Adjusted lower bound is correct", () => rangeSlider.LowerBound.Value, () => Is.EqualTo(50).Within(0.1f));
|
||||
AddAssert("Adjusted upper bound is correct", () => rangeSlider.UpperBound.Value, () => Is.EqualTo(75).Within(0.1f));
|
||||
|
||||
AddStep("Test nub pushing", () =>
|
||||
{
|
||||
customStart.Value = 90;
|
||||
});
|
||||
|
||||
AddAssert("Pushed lower bound is correct", () => rangeSlider.LowerBound.Value, () => Is.EqualTo(90).Within(0.1f));
|
||||
AddAssert("Pushed upper bound is correct", () => rangeSlider.UpperBound.Value, () => Is.EqualTo(100).Within(0.1f));
|
||||
}
|
||||
}
|
||||
}
|
@ -227,6 +227,9 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
private Texture texture = null!;
|
||||
|
||||
private readonly List<TriangleParticle> parts = new List<TriangleParticle>();
|
||||
|
||||
private readonly Vector2 triangleSize = new Vector2(1f, equilateral_triangle_ratio) * triangle_size;
|
||||
|
||||
private Vector2 size;
|
||||
private float thickness;
|
||||
private float texelSize;
|
||||
@ -246,7 +249,15 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
texture = Source.texture;
|
||||
size = Source.DrawSize;
|
||||
thickness = Source.Thickness;
|
||||
texelSize = Math.Max(1.5f / Source.ScreenSpaceDrawQuad.Size.X, 1.5f / Source.ScreenSpaceDrawQuad.Size.Y);
|
||||
|
||||
Quad triangleQuad = new Quad(
|
||||
Vector2Extensions.Transform(Vector2.Zero, DrawInfo.Matrix),
|
||||
Vector2Extensions.Transform(new Vector2(triangle_size, 0f), DrawInfo.Matrix),
|
||||
Vector2Extensions.Transform(new Vector2(0f, triangleSize.Y), DrawInfo.Matrix),
|
||||
Vector2Extensions.Transform(triangleSize, DrawInfo.Matrix)
|
||||
);
|
||||
|
||||
texelSize = 1.5f / triangleQuad.Height;
|
||||
|
||||
parts.Clear();
|
||||
parts.AddRange(Source.parts);
|
||||
@ -256,7 +267,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
{
|
||||
base.Draw(renderer);
|
||||
|
||||
if (Source.AimCount == 0)
|
||||
if (Source.AimCount == 0 || thickness == 0)
|
||||
return;
|
||||
|
||||
if (vertexBatch == null || vertexBatch.Size != Source.AimCount)
|
||||
@ -269,14 +280,15 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
shader.GetUniform<float>("thickness").UpdateValue(ref thickness);
|
||||
shader.GetUniform<float>("texelSize").UpdateValue(ref texelSize);
|
||||
|
||||
float texturePartWidth = triangleSize.X / size.X;
|
||||
float texturePartHeight = triangleSize.Y / size.Y * texture_height;
|
||||
|
||||
foreach (TriangleParticle particle in parts)
|
||||
{
|
||||
var offset = triangle_size * new Vector2(0.5f, equilateral_triangle_ratio);
|
||||
|
||||
Vector2 topLeft = particle.Position * size + new Vector2(-offset.X, 0f);
|
||||
Vector2 topRight = particle.Position * size + new Vector2(offset.X, 0);
|
||||
Vector2 bottomLeft = particle.Position * size + new Vector2(-offset.X, offset.Y);
|
||||
Vector2 bottomRight = particle.Position * size + new Vector2(offset.X, offset.Y);
|
||||
Vector2 topLeft = particle.Position * size - new Vector2(triangleSize.X * 0.5f, 0f);
|
||||
Vector2 topRight = topLeft + new Vector2(triangleSize.X, 0f);
|
||||
Vector2 bottomLeft = topLeft + new Vector2(0f, triangleSize.Y);
|
||||
Vector2 bottomRight = topLeft + triangleSize;
|
||||
|
||||
var drawQuad = new Quad(
|
||||
Vector2Extensions.Transform(topLeft, DrawInfo.Matrix),
|
||||
@ -288,8 +300,8 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
var tRect = new Quad(
|
||||
topLeft.X / size.X,
|
||||
topLeft.Y / size.Y * texture_height,
|
||||
(topRight.X - topLeft.X) / size.X,
|
||||
(bottomRight.Y - topRight.Y) / size.Y * texture_height
|
||||
texturePartWidth,
|
||||
texturePartHeight
|
||||
).AABBFloat;
|
||||
|
||||
renderer.DrawQuad(texture, drawQuad, DrawColourInfo.Colour, tRect, vertexBatch.AddAction, textureCoords: tRect);
|
||||
|
212
osu.Game/Graphics/UserInterface/RangeSlider.cs
Normal file
212
osu.Game/Graphics/UserInterface/RangeSlider.cs
Normal file
@ -0,0 +1,212 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public partial class RangeSlider : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// The lower limiting value
|
||||
/// </summary>
|
||||
public Bindable<double> LowerBound
|
||||
{
|
||||
get => lowerBound.Current;
|
||||
set => lowerBound.Current = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The upper limiting value
|
||||
/// </summary>
|
||||
public Bindable<double> UpperBound
|
||||
{
|
||||
get => upperBound.Current;
|
||||
set => upperBound.Current = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Text that describes this RangeSlider's functionality
|
||||
/// </summary>
|
||||
public string Label
|
||||
{
|
||||
set => label.Text = value;
|
||||
}
|
||||
|
||||
public float NubWidth
|
||||
{
|
||||
set => lowerBound.NubWidth = upperBound.NubWidth = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Minimum difference between the lower bound and higher bound
|
||||
/// </summary>
|
||||
public float MinRange
|
||||
{
|
||||
set => minRange = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// lower bound display for when it is set to its default value
|
||||
/// </summary>
|
||||
public string DefaultStringLowerBound
|
||||
{
|
||||
set => lowerBound.DefaultString = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// upper bound display for when it is set to its default value
|
||||
/// </summary>
|
||||
public string DefaultStringUpperBound
|
||||
{
|
||||
set => upperBound.DefaultString = value;
|
||||
}
|
||||
|
||||
public LocalisableString DefaultTooltipLowerBound
|
||||
{
|
||||
set => lowerBound.DefaultTooltip = value;
|
||||
}
|
||||
|
||||
public LocalisableString DefaultTooltipUpperBound
|
||||
{
|
||||
set => upperBound.DefaultTooltip = value;
|
||||
}
|
||||
|
||||
public string TooltipSuffix
|
||||
{
|
||||
set => upperBound.TooltipSuffix = lowerBound.TooltipSuffix = value;
|
||||
}
|
||||
|
||||
private float minRange = 0.1f;
|
||||
|
||||
private readonly OsuSpriteText label;
|
||||
|
||||
private readonly LowerBoundSlider lowerBound;
|
||||
private readonly UpperBoundSlider upperBound;
|
||||
|
||||
public RangeSlider()
|
||||
{
|
||||
const float vertical_offset = 13;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
label = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 14),
|
||||
},
|
||||
upperBound = new UpperBoundSlider
|
||||
{
|
||||
KeyboardStep = 0.1f,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Y = vertical_offset,
|
||||
},
|
||||
lowerBound = new LowerBoundSlider
|
||||
{
|
||||
KeyboardStep = 0.1f,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Y = vertical_offset,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
lowerBound.Current.ValueChanged += min => upperBound.Current.Value = Math.Max(min.NewValue + minRange, upperBound.Current.Value);
|
||||
upperBound.Current.ValueChanged += max => lowerBound.Current.Value = Math.Min(max.NewValue - minRange, lowerBound.Current.Value);
|
||||
}
|
||||
|
||||
private partial class LowerBoundSlider : BoundSlider
|
||||
{
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
LeftBox.Height = 6; // hide any colour bleeding from overlap
|
||||
|
||||
AccentColour = BackgroundColour;
|
||||
BackgroundColour = Color4.Transparent;
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
|
||||
base.ReceivePositionalInputAt(screenSpacePos)
|
||||
&& screenSpacePos.X <= Nub.ScreenSpaceDrawQuad.TopRight.X;
|
||||
}
|
||||
|
||||
private partial class UpperBoundSlider : BoundSlider
|
||||
{
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
RightBox.Height = 6; // just to match the left bar height really
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
|
||||
base.ReceivePositionalInputAt(screenSpacePos)
|
||||
&& screenSpacePos.X >= Nub.ScreenSpaceDrawQuad.TopLeft.X;
|
||||
}
|
||||
|
||||
protected partial class BoundSlider : OsuSliderBar<double>
|
||||
{
|
||||
public string? DefaultString;
|
||||
public LocalisableString? DefaultTooltip;
|
||||
public string? TooltipSuffix;
|
||||
public float NubWidth { get; set; } = Nub.HEIGHT;
|
||||
|
||||
public override LocalisableString TooltipText =>
|
||||
(Current.IsDefault ? DefaultTooltip : Current.Value.ToString($@"0.## {TooltipSuffix}")) ?? Current.Value.ToString($@"0.## {TooltipSuffix}");
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
base.OnHover(e);
|
||||
return true; // Make sure only one nub shows hover effect at once.
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Nub.Width = NubWidth;
|
||||
RangePadding = Nub.Width / 2;
|
||||
|
||||
OsuSpriteText currentDisplay;
|
||||
|
||||
Nub.Add(currentDisplay = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Y = -0.5f,
|
||||
Colour = Color4.White,
|
||||
Font = OsuFont.Torus.With(size: 10),
|
||||
});
|
||||
|
||||
Current.BindValueChanged(current =>
|
||||
{
|
||||
currentDisplay.Text = (current.NewValue != Current.Default ? current.NewValue.ToString("N1") : DefaultString) ?? current.NewValue.ToString("N1");
|
||||
}, true);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider? colourProvider)
|
||||
{
|
||||
if (colourProvider == null) return;
|
||||
|
||||
AccentColour = colourProvider.Background2;
|
||||
Nub.AccentColour = colourProvider.Background2;
|
||||
Nub.GlowingAccentColour = colourProvider.Background1;
|
||||
Nub.GlowColour = colourProvider.Background2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,8 +7,6 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Online.Rooms
|
||||
{
|
||||
// TODO: Remove disable below after merging https://github.com/ppy/osu-framework/pull/5548 and applying follow-up changes game-side.
|
||||
// ReSharper disable once PartialTypeWithSinglePart
|
||||
public partial class APICreatedRoom : Room
|
||||
{
|
||||
[JsonProperty("error")]
|
||||
|
@ -16,7 +16,7 @@ using osu.Game.Online.Rooms.RoomStatuses;
|
||||
namespace osu.Game.Online.Rooms
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public partial class Room
|
||||
public partial class Room : IDependencyInjectionCandidate
|
||||
{
|
||||
[Cached]
|
||||
[JsonProperty("id")]
|
||||
|
@ -331,11 +331,11 @@ namespace osu.Game.Overlays.Comments
|
||||
if (WasDeleted)
|
||||
makeDeleted();
|
||||
|
||||
actionsContainer.AddLink("Copy link", copyUrl);
|
||||
actionsContainer.AddLink(CommonStrings.ButtonsPermalink, copyUrl);
|
||||
actionsContainer.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
|
||||
|
||||
if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id)
|
||||
actionsContainer.AddLink("Delete", deleteComment);
|
||||
actionsContainer.AddLink(CommonStrings.ButtonsDelete, deleteComment);
|
||||
else
|
||||
actionsContainer.AddArbitraryDrawable(new CommentReportButton(Comment));
|
||||
|
||||
@ -553,12 +553,12 @@ namespace osu.Game.Overlays.Comments
|
||||
};
|
||||
}
|
||||
|
||||
private string getParentMessage()
|
||||
private LocalisableString getParentMessage()
|
||||
{
|
||||
if (parentComment == null)
|
||||
return string.Empty;
|
||||
|
||||
return parentComment.HasMessage ? parentComment.Message : parentComment.IsDeleted ? "deleted" : string.Empty;
|
||||
return parentComment.HasMessage ? parentComment.Message : parentComment.IsDeleted ? CommentsStrings.Deleted : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ namespace osu.Game.Overlays.FirstRunSetup
|
||||
return parentDependencies.Get(type, info);
|
||||
}
|
||||
|
||||
public void Inject<T>(T instance) where T : class
|
||||
public void Inject<T>(T instance) where T : class, IDependencyInjectionCandidate
|
||||
{
|
||||
parentDependencies.Inject(instance);
|
||||
}
|
||||
|
@ -177,13 +177,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
updateScreenModeWarning();
|
||||
}, true);
|
||||
|
||||
windowModes.BindCollectionChanged((_, _) =>
|
||||
{
|
||||
if (windowModes.Count > 1)
|
||||
windowModeDropdown.Show();
|
||||
else
|
||||
windowModeDropdown.Hide();
|
||||
}, true);
|
||||
windowModes.BindCollectionChanged((_, _) => updateDisplaySettingsVisibility());
|
||||
|
||||
currentDisplay.BindValueChanged(display => Schedule(() =>
|
||||
{
|
||||
@ -219,7 +213,11 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
|
||||
|
||||
scalingSettings.AutoSizeAxes = scalingMode.Value != ScalingMode.Off ? Axes.Y : Axes.None;
|
||||
scalingSettings.ForEach(s => s.TransferValueOnCommit = scalingMode.Value == ScalingMode.Everything);
|
||||
scalingSettings.ForEach(s =>
|
||||
{
|
||||
s.TransferValueOnCommit = scalingMode.Value == ScalingMode.Everything;
|
||||
s.CanBeShown.Value = scalingMode.Value != ScalingMode.Off;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,20 +232,10 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
|
||||
private void updateDisplaySettingsVisibility()
|
||||
{
|
||||
if (resolutions.Count > 1 && windowModeDropdown.Current.Value == WindowMode.Fullscreen)
|
||||
resolutionDropdown.Show();
|
||||
else
|
||||
resolutionDropdown.Hide();
|
||||
|
||||
if (displayDropdown.Items.Count() > 1)
|
||||
displayDropdown.Show();
|
||||
else
|
||||
displayDropdown.Hide();
|
||||
|
||||
if (host.Window?.SafeAreaPadding.Value.Total != Vector2.Zero)
|
||||
safeAreaConsiderationsCheckbox.Show();
|
||||
else
|
||||
safeAreaConsiderationsCheckbox.Hide();
|
||||
windowModeDropdown.CanBeShown.Value = windowModes.Count > 1;
|
||||
resolutionDropdown.CanBeShown.Value = resolutions.Count > 1 && windowModeDropdown.Current.Value == WindowMode.Fullscreen;
|
||||
displayDropdown.CanBeShown.Value = displayDropdown.Items.Count() > 1;
|
||||
safeAreaConsiderationsCheckbox.CanBeShown.Value = host.Window?.SafeAreaPadding.Value.Total != Vector2.Zero;
|
||||
}
|
||||
|
||||
private void updateScreenModeWarning()
|
||||
|
@ -143,6 +143,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
areaOffset.SetDefault();
|
||||
areaSize.SetDefault();
|
||||
},
|
||||
CanBeShown = { BindTarget = enabled }
|
||||
},
|
||||
new SettingsButton
|
||||
{
|
||||
@ -150,25 +151,29 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
Action = () =>
|
||||
{
|
||||
forceAspectRatio((float)host.Window.ClientSize.Width / host.Window.ClientSize.Height);
|
||||
}
|
||||
},
|
||||
CanBeShown = { BindTarget = enabled }
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = TabletSettingsStrings.XOffset,
|
||||
Current = offsetX
|
||||
Current = offsetX,
|
||||
CanBeShown = { BindTarget = enabled }
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = TabletSettingsStrings.YOffset,
|
||||
Current = offsetY
|
||||
Current = offsetY,
|
||||
CanBeShown = { BindTarget = enabled }
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = TabletSettingsStrings.Rotation,
|
||||
Current = rotation
|
||||
Current = rotation,
|
||||
CanBeShown = { BindTarget = enabled }
|
||||
},
|
||||
new RotationPresetButtons(tabletHandler)
|
||||
{
|
||||
@ -181,24 +186,28 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = TabletSettingsStrings.AspectRatio,
|
||||
Current = aspectRatio
|
||||
Current = aspectRatio,
|
||||
CanBeShown = { BindTarget = enabled }
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = TabletSettingsStrings.LockAspectRatio,
|
||||
Current = aspectLock
|
||||
Current = aspectLock,
|
||||
CanBeShown = { BindTarget = enabled }
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = CommonStrings.Width,
|
||||
Current = sizeX
|
||||
Current = sizeX,
|
||||
CanBeShown = { BindTarget = enabled }
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = CommonStrings.Height,
|
||||
Current = sizeY
|
||||
Current = sizeY,
|
||||
CanBeShown = { BindTarget = enabled }
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -3,14 +3,16 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public partial class SettingsButton : RoundedButton, IHasTooltip
|
||||
public partial class SettingsButton : RoundedButton, IHasTooltip, IConditionalFilterable
|
||||
{
|
||||
public SettingsButton()
|
||||
{
|
||||
@ -20,6 +22,9 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
public LocalisableString TooltipText { get; set; }
|
||||
|
||||
public BindableBool CanBeShown { get; } = new BindableBool(true);
|
||||
IBindable<bool> IConditionalFilterable.CanBeShown => CanBeShown;
|
||||
|
||||
public override IEnumerable<LocalisableString> FilterTerms
|
||||
{
|
||||
get
|
||||
|
@ -22,7 +22,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public abstract partial class SettingsItem<T> : Container, IFilterable, ISettingsItem, IHasCurrentValue<T>, IHasTooltip
|
||||
public abstract partial class SettingsItem<T> : Container, IConditionalFilterable, ISettingsItem, IHasCurrentValue<T>, IHasTooltip
|
||||
{
|
||||
protected abstract Drawable CreateControl();
|
||||
|
||||
@ -144,6 +144,9 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
public bool FilteringActive { get; set; }
|
||||
|
||||
public BindableBool CanBeShown { get; } = new BindableBool(true);
|
||||
IBindable<bool> IConditionalFilterable.CanBeShown => CanBeShown;
|
||||
|
||||
public event Action SettingChanged;
|
||||
|
||||
private T classicDefault;
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -19,7 +18,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public abstract partial class SettingsSection : Container, IHasFilterableChildren
|
||||
public abstract partial class SettingsSection : Container, IFilterable
|
||||
{
|
||||
protected FillFlowContainer FlowContent;
|
||||
protected override Container<Drawable> Content => FlowContent;
|
||||
@ -33,7 +32,6 @@ namespace osu.Game.Overlays.Settings
|
||||
public abstract Drawable CreateIcon();
|
||||
public abstract LocalisableString Header { get; }
|
||||
|
||||
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
|
||||
public virtual IEnumerable<LocalisableString> FilterTerms => new[] { Header };
|
||||
|
||||
public const int ITEM_SPACING = 14;
|
||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Testing;
|
||||
@ -17,7 +16,7 @@ using osu.Game.Graphics;
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
[ExcludeFromDynamicCompile]
|
||||
public abstract partial class SettingsSubsection : FillFlowContainer, IHasFilterableChildren
|
||||
public abstract partial class SettingsSubsection : FillFlowContainer, IFilterable
|
||||
{
|
||||
protected override Container<Drawable> Content => FlowContent;
|
||||
|
||||
@ -25,8 +24,6 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
protected abstract LocalisableString Header { get; }
|
||||
|
||||
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
|
||||
|
||||
public virtual IEnumerable<LocalisableString> FilterTerms => new[] { Header };
|
||||
|
||||
public bool MatchingFilter
|
||||
|
@ -1,152 +0,0 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
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;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
internal partial class DifficultyRangeFilterControl : CompositeDrawable
|
||||
{
|
||||
private Bindable<double> lowerStars = null!;
|
||||
private Bindable<double> upperStars = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
const float vertical_offset = 13;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "Difficulty range",
|
||||
Font = OsuFont.GetFont(size: 14),
|
||||
},
|
||||
new MaximumStarsSlider
|
||||
{
|
||||
Current = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum),
|
||||
KeyboardStep = 0.1f,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Y = vertical_offset,
|
||||
},
|
||||
new MinimumStarsSlider
|
||||
{
|
||||
Current = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum),
|
||||
KeyboardStep = 0.1f,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Y = vertical_offset,
|
||||
}
|
||||
};
|
||||
|
||||
lowerStars = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum);
|
||||
upperStars = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
lowerStars.ValueChanged += min => upperStars.Value = Math.Max(min.NewValue + 0.1, upperStars.Value);
|
||||
upperStars.ValueChanged += max => lowerStars.Value = Math.Min(max.NewValue - 0.1, lowerStars.Value);
|
||||
}
|
||||
|
||||
private partial class MinimumStarsSlider : StarsSlider
|
||||
{
|
||||
public MinimumStarsSlider()
|
||||
: base("0")
|
||||
{
|
||||
}
|
||||
|
||||
public override LocalisableString TooltipText => Current.Value.ToString(@"0.## stars");
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
LeftBox.Height = 6; // hide any colour bleeding from overlap
|
||||
|
||||
AccentColour = BackgroundColour;
|
||||
BackgroundColour = Color4.Transparent;
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
|
||||
base.ReceivePositionalInputAt(screenSpacePos)
|
||||
&& screenSpacePos.X <= Nub.ScreenSpaceDrawQuad.TopRight.X;
|
||||
}
|
||||
|
||||
private partial class MaximumStarsSlider : StarsSlider
|
||||
{
|
||||
public MaximumStarsSlider()
|
||||
: base("∞")
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
RightBox.Height = 6; // just to match the left bar height really
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
|
||||
base.ReceivePositionalInputAt(screenSpacePos)
|
||||
&& screenSpacePos.X >= Nub.ScreenSpaceDrawQuad.TopLeft.X;
|
||||
}
|
||||
|
||||
private partial class StarsSlider : OsuSliderBar<double>
|
||||
{
|
||||
private readonly string defaultString;
|
||||
|
||||
public override LocalisableString TooltipText => Current.IsDefault
|
||||
? UserInterfaceStrings.NoLimit
|
||||
: Current.Value.ToString(@"0.## stars");
|
||||
|
||||
protected StarsSlider(string defaultString)
|
||||
{
|
||||
this.defaultString = defaultString;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
base.OnHover(e);
|
||||
return true; // Make sure only one nub shows hover effect at once.
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Nub.Width = Nub.HEIGHT;
|
||||
RangePadding = Nub.Width / 2;
|
||||
|
||||
OsuSpriteText currentDisplay;
|
||||
|
||||
Nub.Add(currentDisplay = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Y = -0.5f,
|
||||
Colour = Color4.White,
|
||||
Font = OsuFont.Torus.With(size: 10),
|
||||
});
|
||||
|
||||
Current.BindValueChanged(current =>
|
||||
{
|
||||
currentDisplay.Text = current.NewValue != Current.Default ? current.NewValue.ToString("N1") : defaultString;
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
@ -172,12 +173,19 @@ namespace osu.Game.Screens.Select
|
||||
Height = 40,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DifficultyRangeFilterControl
|
||||
new RangeSlider
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
Label = "Difficulty range",
|
||||
LowerBound = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum),
|
||||
UpperBound = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.48f,
|
||||
DefaultStringLowerBound = "0",
|
||||
DefaultStringUpperBound = "∞",
|
||||
DefaultTooltipUpperBound = UserInterfaceStrings.NoLimit,
|
||||
TooltipSuffix = "stars"
|
||||
},
|
||||
collectionDropdown = new CollectionDropdown
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
return fallback.Get(type, info);
|
||||
}
|
||||
|
||||
public void Inject<T>(T instance) where T : class
|
||||
public void Inject<T>(T instance) where T : class, IDependencyInjectionCandidate
|
||||
{
|
||||
// Never used directly
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
||||
=> OnlinePlayDependencies?.Get(type, info) ?? parent.Get(type, info);
|
||||
|
||||
public void Inject<T>(T instance)
|
||||
where T : class
|
||||
where T : class, IDependencyInjectionCandidate
|
||||
=> injectableDependencies.Inject(instance);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
||||
=> dependencies.Get(type, info);
|
||||
|
||||
public void Inject<T>(T instance)
|
||||
where T : class
|
||||
where T : class, IDependencyInjectionCandidate
|
||||
=> dependencies.Inject(instance);
|
||||
|
||||
protected void Cache(object instance)
|
||||
|
@ -35,7 +35,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Realm" Version="10.18.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2022.1126.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2022.1130.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.1127.0" />
|
||||
<PackageReference Include="Sentry" Version="3.23.1" />
|
||||
<PackageReference Include="SharpCompress" Version="0.32.2" />
|
||||
|
@ -62,7 +62,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.1127.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.1126.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.1130.0" />
|
||||
</ItemGroup>
|
||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
|
||||
<PropertyGroup>
|
||||
@ -82,7 +82,7 @@
|
||||
<PackageReference Include="DiffPlex" Version="1.7.1" />
|
||||
<PackageReference Include="Humanizer" Version="2.14.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2022.1126.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2022.1130.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.32.2" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user