Merge pull request #25028 from peppy/bindable-fixes

Fix some incorrect bindable-related code
This commit is contained in:
Bartłomiej Dach 2023-10-06 22:31:30 +02:00 committed by GitHub
commit cfcdbe1c30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 34 additions and 24 deletions

View File

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania.Edit
{
public partial class DrawableManiaEditorRuleset : DrawableManiaRuleset, ISupportConstantAlgorithmToggle
{
public BindableBool ShowSpeedChanges { get; set; } = new BindableBool();
public BindableBool ShowSpeedChanges { get; } = new BindableBool();
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Taiko.Edit
{
public partial class DrawableTaikoEditorRuleset : DrawableTaikoRuleset, ISupportConstantAlgorithmToggle
{
public BindableBool ShowSpeedChanges { get; set; } = new BindableBool();
public BindableBool ShowSpeedChanges { get; } = new BindableBool();
public DrawableTaikoEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
: base(ruleset, beatmap, mods)

View File

@ -42,22 +42,22 @@ namespace osu.Game.Tests.Mods
private class ClassWithSettings
{
[SettingSource("Unordered setting", "Should be last")]
public BindableFloat UnorderedSetting { get; set; } = new BindableFloat();
public BindableFloat UnorderedSetting { get; } = new BindableFloat();
[SettingSource("Second setting", "Another description", 2)]
public BindableBool SecondSetting { get; set; } = new BindableBool();
public BindableBool SecondSetting { get; } = new BindableBool();
[SettingSource("First setting", "A description", 1)]
public BindableDouble FirstSetting { get; set; } = new BindableDouble();
public BindableDouble FirstSetting { get; } = new BindableDouble();
[SettingSource("Third setting", "Yet another description", 3)]
public BindableInt ThirdSetting { get; set; } = new BindableInt();
public BindableInt ThirdSetting { get; } = new BindableInt();
}
private class ClassWithCustomSettingControl
{
[SettingSource("Custom setting", "Should be a custom control", SettingControlType = typeof(CustomSettingsControl))]
public BindableInt UnorderedSetting { get; set; } = new BindableInt();
public BindableInt UnorderedSetting { get; } = new BindableInt();
}
private partial class CustomSettingsControl : SettingsItem<int>

View File

@ -4,7 +4,6 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Online.API.Requests.Responses;
@ -80,11 +79,11 @@ namespace osu.Game.Tournament.Tests.Components
{
Team1 =
{
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { redUser } }
Value = new TournamentTeam { Players = { redUser } }
},
Team2 =
{
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { blueUser, blueUserWithCustomColour } }
Value = new TournamentTeam { Players = { blueUser, blueUserWithCustomColour } }
}
});

View File

@ -56,7 +56,7 @@ namespace osu.Game.Tournament.Models
};
[JsonProperty]
public BindableList<TournamentUser> Players { get; set; } = new BindableList<TournamentUser>();
public BindableList<TournamentUser> Players { get; } = new BindableList<TournamentUser>();
public TournamentTeam()
{

View File

@ -47,7 +47,7 @@ namespace osu.Game.Graphics.Containers
/// <summary>
/// The amount of dim to be used when <see cref="IgnoreUserSettings"/> is <c>true</c>.
/// </summary>
public Bindable<float> DimWhenUserSettingsIgnored { get; set; } = new Bindable<float>();
public Bindable<float> DimWhenUserSettingsIgnored { get; } = new Bindable<float>();
protected Bindable<bool> LightenDuringBreaks { get; private set; } = null!;

View File

@ -23,7 +23,18 @@ namespace osu.Game.Screens.OnlinePlay
{
public partial class FooterButtonFreeMods : FooterButton, IHasCurrentValue<IReadOnlyList<Mod>>
{
public Bindable<IReadOnlyList<Mod>> Current { get; set; } = new BindableWithCurrent<IReadOnlyList<Mod>>();
private readonly BindableWithCurrent<IReadOnlyList<Mod>> current = new BindableWithCurrent<IReadOnlyList<Mod>>(Array.Empty<Mod>());
public Bindable<IReadOnlyList<Mod>> Current
{
get => current.Current;
set
{
ArgumentNullException.ThrowIfNull(value);
current.Current = value;
}
}
private OsuSpriteText count = null!;
@ -106,17 +117,17 @@ namespace osu.Game.Screens.OnlinePlay
private void updateModDisplay()
{
int current = Current.Value.Count;
int currentCount = Current.Value.Count;
if (current == allAvailableAndValidMods.Count())
if (currentCount == allAvailableAndValidMods.Count())
{
count.Text = "all";
count.FadeColour(colours.Gray2, 200, Easing.OutQuint);
circle.FadeColour(colours.Yellow, 200, Easing.OutQuint);
}
else if (current > 0)
else if (currentCount > 0)
{
count.Text = $"{current} mods";
count.Text = $"{currentCount} mods";
count.FadeColour(colours.Gray2, 200, Easing.OutQuint);
circle.FadeColour(colours.YellowDark, 200, Easing.OutQuint);
}

View File

@ -22,16 +22,16 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
public bool UsesFixedAnchor { get; set; }
[SettingSource(typeof(JudgementCounterDisplayStrings), nameof(JudgementCounterDisplayStrings.JudgementDisplayMode))]
public Bindable<DisplayMode> Mode { get; set; } = new Bindable<DisplayMode>();
public Bindable<DisplayMode> Mode { get; } = new Bindable<DisplayMode>();
[SettingSource(typeof(JudgementCounterDisplayStrings), nameof(JudgementCounterDisplayStrings.FlowDirection))]
public Bindable<Direction> FlowDirection { get; set; } = new Bindable<Direction>();
public Bindable<Direction> FlowDirection { get; } = new Bindable<Direction>();
[SettingSource(typeof(JudgementCounterDisplayStrings), nameof(JudgementCounterDisplayStrings.ShowJudgementNames))]
public BindableBool ShowJudgementNames { get; set; } = new BindableBool(true);
public BindableBool ShowJudgementNames { get; } = new BindableBool(true);
[SettingSource(typeof(JudgementCounterDisplayStrings), nameof(JudgementCounterDisplayStrings.ShowMaxJudgement))]
public BindableBool ShowMaxJudgement { get; set; } = new BindableBool(true);
public BindableBool ShowMaxJudgement { get; } = new BindableBool(true);
[Resolved]
private JudgementCountController judgementCountController { get; set; } = null!;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Screens.Play.HUD
{
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.CornerRadius), nameof(SkinnableComponentStrings.CornerRadiusDescription),
SettingControlType = typeof(SettingsPercentageSlider<float>))]
public new BindableFloat CornerRadius { get; set; } = new BindableFloat(0.25f)
public new BindableFloat CornerRadius { get; } = new BindableFloat(0.25f)
{
MinValue = 0,
MaxValue = 0.5f,

View File

@ -138,7 +138,7 @@ namespace osu.Game.Screens.Select
[Resolved]
internal IOverlayManager? OverlayManager { get; private set; }
private Bindable<bool> configBackgroundBlur { get; set; } = new BindableBool();
private Bindable<bool> configBackgroundBlur = null!;
[BackgroundDependencyLoader(true)]
private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog? manageCollectionsDialog, DifficultyRecommender? recommender, OsuConfigManager config)

View File

@ -30,7 +30,7 @@ namespace osu.Game.Skinning.Components
public Bindable<BeatmapAttribute> Attribute { get; } = new Bindable<BeatmapAttribute>(BeatmapAttribute.StarRating);
[SettingSource(typeof(BeatmapAttributeTextStrings), nameof(BeatmapAttributeTextStrings.Template), nameof(BeatmapAttributeTextStrings.TemplateDescription))]
public Bindable<string> Template { get; set; } = new Bindable<string>("{Label}: {Value}");
public Bindable<string> Template { get; } = new Bindable<string>("{Label}: {Value}");
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;